sl@0: /* sl@0: * Copyright (c) 2002-2006 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: CustomInterfaceUtility Proxy implementation sl@0: * sl@0: */ sl@0: sl@0: sl@0: sl@0: // INCLUDE FILES sl@0: #include sl@0: #include "CustomInterfaceBuilderTypes.h" sl@0: #include "CustomInterfaceProxyFactory.h" sl@0: sl@0: sl@0: EXPORT_C CProxyCustomInterfaceUtility* CProxyCustomInterfaceUtility::NewL(CCustomCommandUtility* aCustomCommandUtility) sl@0: { sl@0: CProxyCustomInterfaceUtility* self = new(ELeave) CProxyCustomInterfaceUtility(aCustomCommandUtility); sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(); sl@0: CleanupStack::Pop(self); sl@0: return self; sl@0: } sl@0: sl@0: EXPORT_C CProxyCustomInterfaceUtility* CProxyCustomInterfaceUtility::NewL(MCustomCommand& aMCustomCommand) sl@0: { sl@0: CProxyCustomInterfaceUtility* self = new(ELeave) CProxyCustomInterfaceUtility(aMCustomCommand); sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(); sl@0: CleanupStack::Pop(self); sl@0: return self; sl@0: } sl@0: sl@0: CProxyCustomInterfaceUtility::CProxyCustomInterfaceUtility(CCustomCommandUtility* aCustomCommandUtility) : sl@0: CCustomInterfaceUtility(), sl@0: iCustomCommandUtility(aCustomCommandUtility) sl@0: { sl@0: } sl@0: sl@0: CProxyCustomInterfaceUtility::CProxyCustomInterfaceUtility(MCustomCommand& aMCustomCommand) : sl@0: CCustomInterfaceUtility(), sl@0: iMCustomCommand(&aMCustomCommand) sl@0: { sl@0: } sl@0: sl@0: sl@0: CProxyCustomInterfaceUtility::~CProxyCustomInterfaceUtility() sl@0: { sl@0: delete iCustomCommandUtility; sl@0: // Do not delete iMCustomCommand. Unlike iCustomCommandUtility we don't own sl@0: // iMCustomCommand. sl@0: } sl@0: sl@0: void CProxyCustomInterfaceUtility::ConstructL() sl@0: { sl@0: TMMFMessageDestination destination(KUidCustomInterfaceBuilder); sl@0: TMMFMessageDestinationPckg destinationPckg(destination); sl@0: TMMFMessageDestination builderHandle; sl@0: TMMFMessageDestinationPckg builderHandlePckg(builderHandle); sl@0: iBuilderHandle = builderHandlePckg; sl@0: sl@0: if (iCustomCommandUtility) sl@0: { sl@0: iCustomCommandUtility->CustomCommandSync(destinationPckg, ECibGetBuilder, KNullDesC8, KNullDesC8, iBuilderHandle); sl@0: } sl@0: else if (iMCustomCommand) sl@0: { sl@0: iMCustomCommand->CustomCommandSync(destinationPckg, ECibGetBuilder, KNullDesC8, KNullDesC8, iBuilderHandle); sl@0: } sl@0: sl@0: if(iBuilderHandle().InterfaceId() == KNullUid) sl@0: { sl@0: User::Leave(KErrNotFound); sl@0: } sl@0: } sl@0: sl@0: EXPORT_C TAny* CProxyCustomInterfaceUtility::CustomInterface(TUid aInterfaceId) sl@0: { sl@0: // Get Handle sl@0: TMMFMessageDestination handle; sl@0: TMMFMessageDestinationPckg handlePckg(handle); sl@0: TPckgBuf uidPckg; sl@0: uidPckg() = aInterfaceId; sl@0: sl@0: if (iCustomCommandUtility) sl@0: { sl@0: iCustomCommandUtility->CustomCommandSync(iBuilderHandle, ECibBuild, uidPckg, KNullDesC8, handlePckg); sl@0: } sl@0: else if (iMCustomCommand) sl@0: { sl@0: iMCustomCommand->CustomCommandSync(iBuilderHandle, ECibBuild, uidPckg, KNullDesC8, handlePckg); sl@0: } sl@0: sl@0: TAny* result = NULL; sl@0: sl@0: if(handlePckg().InterfaceId() == KNullUid) sl@0: { sl@0: result = NULL; sl@0: } sl@0: else sl@0: { sl@0: if (iCustomCommandUtility) sl@0: { sl@0: result = CCustomInterfaceProxyFactory::CreateProxy(aInterfaceId, handlePckg, *iCustomCommandUtility, this); sl@0: } sl@0: else if (iMCustomCommand) sl@0: { sl@0: result = CCustomInterfaceProxyFactory::CreateProxy(aInterfaceId, handlePckg, *iMCustomCommand, this); sl@0: } sl@0: sl@0: } sl@0: sl@0: return result; sl@0: } sl@0: sl@0: sl@0: EXPORT_C void CProxyCustomInterfaceUtility::RemoveCustomInterface(TMMFMessageDestinationPckg aMessageHandler) sl@0: { sl@0: // Get Handle sl@0: TMMFMessageDestination handle; sl@0: TMMFMessageDestinationPckg handlePckg(handle); sl@0: sl@0: sl@0: if (iCustomCommandUtility) sl@0: { sl@0: iCustomCommandUtility->CustomCommandSync(iBuilderHandle, ECibRemove, aMessageHandler, KNullDesC8); sl@0: } sl@0: else if (iMCustomCommand) sl@0: { sl@0: iMCustomCommand->CustomCommandSync(iBuilderHandle, ECibRemove, aMessageHandler, KNullDesC8); sl@0: } sl@0: } sl@0: sl@0: sl@0: // End of File