os/mm/devsoundextensions/ciextnfactoryplugins/ciextnserverplugin/src/ciextnserverpluginwrapper.cpp
First public contribution.
2 * Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: Class definition of server plugin wrapper implementing S60 custom interface.
18 #include "ciextnserverpluginwrapper.h"
20 #include <AudioInputMessageTypes.h>
23 #define KMuxTempBufferSize 20
26 class MyMCustomInterface
29 virtual TAny* CustomInterface(TUid aCustomeInterface) = 0;
30 virtual void Release() = 0;
31 virtual void PassDestructionKey(TUid aUid) = 0;
35 CIExtnServerPluginWrapper* CIExtnServerPluginWrapper::NewL(
36 MCustomInterface& aInterfaceRef)
38 DEB_TRACE0(_L("CIExtnServerPluginWrapper::NewL Begin"));
39 CIExtnServerPluginWrapper* self = new (ELeave) CIExtnServerPluginWrapper(
41 CleanupStack::PushL(self);
43 CleanupStack::Pop(self);
44 DEB_TRACE0(_L("CIExtnServerPluginWrapper::NewL End"));
48 CIExtnServerPluginWrapper::~CIExtnServerPluginWrapper()
50 DEB_TRACE0(_L("CIExtnServerPluginWrappers::~CIExtnServerPluginWrapper Begin"));
51 DEB_TRACE0(_L("CIExtnServerPluginWrapper::~CIExtnServerPluginWrapper End"));
54 CIExtnServerPluginWrapper::CIExtnServerPluginWrapper(
55 MCustomInterface& aInterfaceRef) :
56 iCustomInterfaceRef(&aInterfaceRef)
60 void CIExtnServerPluginWrapper::ConstructL()
63 DEB_TRACE0(_L("Try Loading CI Stub Plugin"));
69 TRAPD(error, pluginRef = REComSession::CreateImplementationL( interfaceUid, iDtor_ID_Key ));
72 DEB_TRACE1(_L("CreateImplementationL Uid [0x%x]"), iDtor_ID_Key.iUid);
73 iCustomInterfaceStub = (MyMCustomInterface*) pluginRef;
74 iCustomInterfaceStub->PassDestructionKey(iDtor_ID_Key);
75 DEB_TRACE0(_L("CI Stub Loaded"));
81 MCustomInterface* CIExtnServerPluginWrapper::GetInterface()
83 DEB_TRACE0(_L("CIExtnServerPluginWrappers::GetInterface"));
84 return (MCustomInterface*) this;
87 TAny* CIExtnServerPluginWrapper::CustomInterface(TUid aInterfaceId)
89 DEB_TRACE0(_L("*CI* CIExtnServerPluginWrapper::CustomInterface"));
90 TAny* pluginRef = NULL;
91 pluginRef = iCustomInterfaceRef->CustomInterface(aInterfaceId);
95 DEB_TRACE0(_L("*CI* Try Loading CI Stub if present"));
96 pluginRef = iCustomInterfaceStub->CustomInterface(aInterfaceId);
99 DEB_TRACE0(_L("*CI* CI Stub Loaded"));
106 void CIExtnServerPluginWrapper::Release()
108 DEB_TRACE0(_L("CIExtnServerPluginWrappers::Release >> ENTER"));
110 iCustomInterfaceStub->Release();
112 DEB_TRACE0(_L("CIExtnServerPluginWrappers::Release >> EXIT"));
117 TAny* CIExtnServerPluginWrapper::CustomInterface(TUid aInterfaceId)
119 DEB_TRACE0(_L("CIExtnServerPluginWrappers::CustomInterface"));
124 TEComResolverParams resolverParams;
125 DEB_TRACE1(_L("Findig CustomInterface with Uid [0x%x]"),aInterfaceId.iUid);
126 TInt uidAsInteger = aInterfaceId.iUid;
127 TBuf8<KMuxTempBufferSize> tempBuffer;
128 tempBuffer.Num(uidAsInteger, EHex);
129 resolverParams.SetDataType(tempBuffer);
132 TRAPD(err, ptr=REComSession::CreateImplementationL(
134 _FOFF(CIExtnServerPluginWrapper, iDtor_ID_Key),resolverParams));
137 DEB_TRACE1(_L("No Custom Interface found: Error [%d]"),err);
141 DEB_TRACE1(_L("Stub Present for Uid [0x%x]"),interfaceUid);
146 return iCustomInterfaceRef->CustomInterface(aInterfaceId);