03.01.2013 Views

Chapter 1

Chapter 1

Chapter 1

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

construct shutdown timer<br />

iShutdown=new(ELeave) CGsdpDelayedShutdown(this);<br />

iShutdown->ConstructL();<br />

// construct port allocator<br />

iPortAllocator=new(ELeave) CGsdpPortAllocator;<br />

iPortAllocator->ConstructL(); // Initialize the protocol info<br />

InitProtocolsL();<br />

iProtocolUpdater=CGsdpProtocolUpdater::NewL(*this);<br />

// identify ourselves and open for service<br />

StartL(KGsdpServerName);<br />

// initiate shut down unless we get client connections<br />

iShutdown->Start();<br />

}<br />

ConstructL() creates all the objects that the server will need. This includes the receive<br />

queue, a port allocator, and a shutdown timer. It then initializes the protocols via<br />

InitProtocolsL():<br />

void CGsdpServer::InitProtocolsL()<br />

{<br />

REComSession::ListImplementationsL(KGdpProtocolImpl,<br />

iProtocolInfo);<br />

CGdpSession* loop = CGdpSession::NewL(KGdpLoopbackUid);<br />

CleanupStack::PushL(loop);<br />

CGsdpGdpAdapter* adapter = CGsdpGdpAdapter::NewL(loop, *this);<br />

CleanupStack::Pop(loop);<br />

CleanupStack::PushL(adapter);<br />

User::LeaveIfError(iAdapters.Append(adapter));<br />

CleanupStack::Pop(adapter);<br />

}<br />

This uses REcomSession::ListImplementations() to fill the iProtocolInfo array<br />

with data on each of the GDP implementations. Since ECOM manages many different plugin<br />

systems, the specific interface required is identified by UID. In the case of the<br />

CGdpSession interface, this is KGdpProtocolImpl (0x101F8B52).<br />

Note<br />

One of the confusing aspects of the ECOM framework is the number of UIDs<br />

involved. There are at least three separate UIDs used:<br />

� a UID to identify the interface – 0x101F8B52 for GDP<br />

� a UID for each DLL that provides implementations – 0x101F8B54 for<br />

GDPLOOP.DLL<br />

� a UID for each individual implementation – 0x101F8B53 for the GDP<br />

loopback protocol.<br />

Once all the protocols available have been recorded, InitProtocolsL() tries to load the<br />

loopback protocol. If successful, an adapter is created for it and the adapter is stored in the

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!