sl@0: // Copyright (c) 2007-2009 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: sl@0: // sl@0: sl@0: sl@0: #include "pluginallocator.h" sl@0: #include "uloggeroutputplugin.h" sl@0: #include sl@0: #include sl@0: sl@0: namespace Ulogger sl@0: { sl@0: sl@0: /*!Default constructor. sl@0: */ sl@0: CPluginAllocator::CPluginAllocator() sl@0: { sl@0: iOutputPluginBase = NULL; sl@0: iInputPluginBase = NULL; sl@0: } sl@0: sl@0: sl@0: /*!Destructor. sl@0: */ sl@0: EXPORT_C CPluginAllocator::~CPluginAllocator() sl@0: { sl@0: if(iOutputPluginBase) sl@0: { sl@0: delete iOutputPluginBase; sl@0: iOutputPluginBase = NULL; sl@0: } sl@0: iOutputLib.Close(); sl@0: sl@0: if((iOutputLibName.Compare(iInputLibName)!=0) && iInputPluginBase) sl@0: { sl@0: delete iInputPluginBase; sl@0: iInputPluginBase = NULL; sl@0: } sl@0: iInputLib.Close(); sl@0: sl@0: REComSession::FinalClose(); sl@0: } sl@0: sl@0: sl@0: /*!Standard Symbian OS construction method which leaves object on CleanupStack. sl@0: */ sl@0: EXPORT_C CPluginAllocator* CPluginAllocator::NewLC(const TPtrC8& aOutputPluginName, const TPtrC8& aInputPluginName) sl@0: { sl@0: CPluginAllocator* obj = new (ELeave) CPluginAllocator(); sl@0: CleanupStack::PushL(obj); sl@0: obj->ConstructL(aOutputPluginName, aInputPluginName); sl@0: return obj; sl@0: } sl@0: sl@0: sl@0: /*!Standard Symbian OS construction method which does not leaves object on CleanupStack. sl@0: */ sl@0: EXPORT_C CPluginAllocator* CPluginAllocator::NewL(const TPtrC8& aOutputPluginName, const TPtrC8& aInputPluginName) sl@0: { sl@0: CPluginAllocator* obj = CPluginAllocator::NewLC(aOutputPluginName, aInputPluginName); sl@0: CleanupStack::Pop(); //obj sl@0: return obj; sl@0: } sl@0: sl@0: sl@0: /*!Standard Symbian OS construction method. sl@0: */ sl@0: EXPORT_C void CPluginAllocator::ConstructL(const TPtrC8& aOutputPluginName, const TPtrC8& aInputPluginName) sl@0: { sl@0: //create output and control channels sl@0: User::LeaveIfError(this->CreateChannelsL(aOutputPluginName, aInputPluginName)); sl@0: } sl@0: sl@0: /*!This function create Output channel according to aOutputSettings. sl@0: */ sl@0: TInt CPluginAllocator::CreateChannelsL(const TPtrC8& aOutputPluginName, const TPtrC8& aInputPluginName) sl@0: { sl@0: TInt retVal = KErrNone; sl@0: sl@0: iOutputLibName.Copy(aOutputPluginName); sl@0: iInputLibName.Copy(aInputPluginName); sl@0: sl@0: //create output plugin sl@0: iOutputPluginBase = (CPlugin*)(CPlugin::NewL(aOutputPluginName)); sl@0: sl@0: //create control plugin sl@0: if(iOutputLibName.Compare(iInputLibName) == 0) sl@0: { sl@0: //share implementation sl@0: if(aInputPluginName.Length()>0) sl@0: iInputPluginBase = iOutputPluginBase; sl@0: } sl@0: else sl@0: { sl@0: //create new instance of control plugin sl@0: //ulogger can work without control plugin as this is optional functionality sl@0: if(aInputPluginName.Length()>0) sl@0: iInputPluginBase = (CPlugin*)(CPlugin::NewL(aInputPluginName)); sl@0: } sl@0: sl@0: return retVal; sl@0: } sl@0: sl@0: sl@0: EXPORT_C MOutputPlugin* CPluginAllocator::GetOutputPlugin() sl@0: { sl@0: if(iOutputPluginBase) sl@0: return (MOutputPlugin*)iOutputPluginBase->GetInterfaceL(MOutputPlugin::iInterfaceId); sl@0: else sl@0: return NULL; sl@0: } sl@0: sl@0: EXPORT_C MInputPlugin* CPluginAllocator::GetInputPlugin() sl@0: { sl@0: if(iInputPluginBase) sl@0: return (MInputPlugin*)iInputPluginBase->GetInterfaceL(MInputPlugin::iInterfaceId); sl@0: else sl@0: return NULL; sl@0: } sl@0: sl@0: EXPORT_C void CPluginAllocator::ListAllImplementationsL(RImplInfoPtrArray& aImplInfoArray) sl@0: { sl@0: REComSession::ListImplementationsL(KCPluginUid, aImplInfoArray); sl@0: } sl@0: sl@0: } //