sl@0: /* sl@0: * Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: Class definition of server plugin wrapper implementing S60 custom interface. sl@0: * sl@0: */ sl@0: sl@0: #include "ciextnserverpluginwrapper.h" sl@0: #include "citraces.h" sl@0: #include sl@0: #include sl@0: sl@0: #define KMuxTempBufferSize 20 sl@0: sl@0: #ifdef __WINSCW__ sl@0: class MyMCustomInterface sl@0: { sl@0: public: sl@0: virtual TAny* CustomInterface(TUid aCustomeInterface) = 0; sl@0: virtual void Release() = 0; sl@0: virtual void PassDestructionKey(TUid aUid) = 0; sl@0: }; sl@0: #endif sl@0: sl@0: CIExtnServerPluginWrapper* CIExtnServerPluginWrapper::NewL( sl@0: MCustomInterface& aInterfaceRef) sl@0: { sl@0: DEB_TRACE0(_L("CIExtnServerPluginWrapper::NewL Begin")); sl@0: CIExtnServerPluginWrapper* self = new (ELeave) CIExtnServerPluginWrapper( sl@0: aInterfaceRef); sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(); sl@0: CleanupStack::Pop(self); sl@0: DEB_TRACE0(_L("CIExtnServerPluginWrapper::NewL End")); sl@0: return self; sl@0: } sl@0: sl@0: CIExtnServerPluginWrapper::~CIExtnServerPluginWrapper() sl@0: { sl@0: DEB_TRACE0(_L("CIExtnServerPluginWrappers::~CIExtnServerPluginWrapper Begin")); sl@0: DEB_TRACE0(_L("CIExtnServerPluginWrapper::~CIExtnServerPluginWrapper End")); sl@0: } sl@0: sl@0: CIExtnServerPluginWrapper::CIExtnServerPluginWrapper( sl@0: MCustomInterface& aInterfaceRef) : sl@0: iCustomInterfaceRef(&aInterfaceRef) sl@0: { sl@0: } sl@0: sl@0: void CIExtnServerPluginWrapper::ConstructL() sl@0: { sl@0: #ifdef __WINSCW__ sl@0: DEB_TRACE0(_L("Try Loading CI Stub Plugin")); sl@0: TUid interfaceUid = sl@0: { sl@0: 0x10207C71 sl@0: }; sl@0: TAny* pluginRef; sl@0: TRAPD(error, pluginRef = REComSession::CreateImplementationL( interfaceUid, iDtor_ID_Key )); sl@0: if (pluginRef) sl@0: { sl@0: DEB_TRACE1(_L("CreateImplementationL Uid [0x%x]"), iDtor_ID_Key.iUid); sl@0: iCustomInterfaceStub = (MyMCustomInterface*) pluginRef; sl@0: iCustomInterfaceStub->PassDestructionKey(iDtor_ID_Key); sl@0: DEB_TRACE0(_L("CI Stub Loaded")); sl@0: } sl@0: #endif sl@0: sl@0: } sl@0: sl@0: MCustomInterface* CIExtnServerPluginWrapper::GetInterface() sl@0: { sl@0: DEB_TRACE0(_L("CIExtnServerPluginWrappers::GetInterface")); sl@0: return (MCustomInterface*) this; sl@0: } sl@0: sl@0: TAny* CIExtnServerPluginWrapper::CustomInterface(TUid aInterfaceId) sl@0: { sl@0: DEB_TRACE0(_L("*CI* CIExtnServerPluginWrapper::CustomInterface")); sl@0: TAny* pluginRef = NULL; sl@0: pluginRef = iCustomInterfaceRef->CustomInterface(aInterfaceId); sl@0: #ifdef __WINSCW__ sl@0: if (!pluginRef) sl@0: { sl@0: DEB_TRACE0(_L("*CI* Try Loading CI Stub if present")); sl@0: pluginRef = iCustomInterfaceStub->CustomInterface(aInterfaceId); sl@0: if (pluginRef) sl@0: { sl@0: DEB_TRACE0(_L("*CI* CI Stub Loaded")); sl@0: } sl@0: } sl@0: #endif sl@0: return pluginRef; sl@0: } sl@0: sl@0: void CIExtnServerPluginWrapper::Release() sl@0: { sl@0: DEB_TRACE0(_L("CIExtnServerPluginWrappers::Release >> ENTER")); sl@0: #ifdef __WINSCW__ sl@0: iCustomInterfaceStub->Release(); sl@0: #endif sl@0: DEB_TRACE0(_L("CIExtnServerPluginWrappers::Release >> EXIT")); sl@0: delete this; sl@0: } sl@0: sl@0: /* sl@0: TAny* CIExtnServerPluginWrapper::CustomInterface(TUid aInterfaceId) sl@0: { sl@0: DEB_TRACE0(_L("CIExtnServerPluginWrappers::CustomInterface")); sl@0: TUid interfaceUid = sl@0: { sl@0: 0x10207C49 sl@0: }; sl@0: TEComResolverParams resolverParams; sl@0: DEB_TRACE1(_L("Findig CustomInterface with Uid [0x%x]"),aInterfaceId.iUid); sl@0: TInt uidAsInteger = aInterfaceId.iUid; sl@0: TBuf8 tempBuffer; sl@0: tempBuffer.Num(uidAsInteger, EHex); sl@0: resolverParams.SetDataType(tempBuffer); sl@0: sl@0: TAny* ptr = NULL; sl@0: TRAPD(err, ptr=REComSession::CreateImplementationL( sl@0: interfaceUid, sl@0: _FOFF(CIExtnServerPluginWrapper, iDtor_ID_Key),resolverParams)); sl@0: if (err != KErrNone) sl@0: { sl@0: DEB_TRACE1(_L("No Custom Interface found: Error [%d]"),err); sl@0: } sl@0: if (ptr) sl@0: { sl@0: DEB_TRACE1(_L("Stub Present for Uid [0x%x]"),interfaceUid); sl@0: return ptr; sl@0: } sl@0: else sl@0: { sl@0: return iCustomInterfaceRef->CustomInterface(aInterfaceId); sl@0: } sl@0: } sl@0: */