os/mm/devsoundextensions/mmextfw/custominterfaceutility/CustomInterfaceUtility/src/ProxyCustomInterfaceUtility.cpp
First public contribution.
2 * Copyright (c) 2002-2006 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: CustomInterfaceUtility Proxy implementation
21 #include <ProxyCustomInterfaceUtility.h>
22 #include "CustomInterfaceBuilderTypes.h"
23 #include "CustomInterfaceProxyFactory.h"
26 EXPORT_C CProxyCustomInterfaceUtility* CProxyCustomInterfaceUtility::NewL(CCustomCommandUtility* aCustomCommandUtility)
28 CProxyCustomInterfaceUtility* self = new(ELeave) CProxyCustomInterfaceUtility(aCustomCommandUtility);
29 CleanupStack::PushL(self);
31 CleanupStack::Pop(self);
35 EXPORT_C CProxyCustomInterfaceUtility* CProxyCustomInterfaceUtility::NewL(MCustomCommand& aMCustomCommand)
37 CProxyCustomInterfaceUtility* self = new(ELeave) CProxyCustomInterfaceUtility(aMCustomCommand);
38 CleanupStack::PushL(self);
40 CleanupStack::Pop(self);
44 CProxyCustomInterfaceUtility::CProxyCustomInterfaceUtility(CCustomCommandUtility* aCustomCommandUtility) :
45 CCustomInterfaceUtility(),
46 iCustomCommandUtility(aCustomCommandUtility)
50 CProxyCustomInterfaceUtility::CProxyCustomInterfaceUtility(MCustomCommand& aMCustomCommand) :
51 CCustomInterfaceUtility(),
52 iMCustomCommand(&aMCustomCommand)
57 CProxyCustomInterfaceUtility::~CProxyCustomInterfaceUtility()
59 delete iCustomCommandUtility;
60 // Do not delete iMCustomCommand. Unlike iCustomCommandUtility we don't own
64 void CProxyCustomInterfaceUtility::ConstructL()
66 TMMFMessageDestination destination(KUidCustomInterfaceBuilder);
67 TMMFMessageDestinationPckg destinationPckg(destination);
68 TMMFMessageDestination builderHandle;
69 TMMFMessageDestinationPckg builderHandlePckg(builderHandle);
70 iBuilderHandle = builderHandlePckg;
72 if (iCustomCommandUtility)
74 iCustomCommandUtility->CustomCommandSync(destinationPckg, ECibGetBuilder, KNullDesC8, KNullDesC8, iBuilderHandle);
76 else if (iMCustomCommand)
78 iMCustomCommand->CustomCommandSync(destinationPckg, ECibGetBuilder, KNullDesC8, KNullDesC8, iBuilderHandle);
81 if(iBuilderHandle().InterfaceId() == KNullUid)
83 User::Leave(KErrNotFound);
87 EXPORT_C TAny* CProxyCustomInterfaceUtility::CustomInterface(TUid aInterfaceId)
90 TMMFMessageDestination handle;
91 TMMFMessageDestinationPckg handlePckg(handle);
92 TPckgBuf<TUid> uidPckg;
93 uidPckg() = aInterfaceId;
95 if (iCustomCommandUtility)
97 iCustomCommandUtility->CustomCommandSync(iBuilderHandle, ECibBuild, uidPckg, KNullDesC8, handlePckg);
99 else if (iMCustomCommand)
101 iMCustomCommand->CustomCommandSync(iBuilderHandle, ECibBuild, uidPckg, KNullDesC8, handlePckg);
106 if(handlePckg().InterfaceId() == KNullUid)
112 if (iCustomCommandUtility)
114 result = CCustomInterfaceProxyFactory::CreateProxy(aInterfaceId, handlePckg, *iCustomCommandUtility, this);
116 else if (iMCustomCommand)
118 result = CCustomInterfaceProxyFactory::CreateProxy(aInterfaceId, handlePckg, *iMCustomCommand, this);
127 EXPORT_C void CProxyCustomInterfaceUtility::RemoveCustomInterface(TMMFMessageDestinationPckg aMessageHandler)
130 TMMFMessageDestination handle;
131 TMMFMessageDestinationPckg handlePckg(handle);
134 if (iCustomCommandUtility)
136 iCustomCommandUtility->CustomCommandSync(iBuilderHandle, ECibRemove, aMessageHandler, KNullDesC8);
138 else if (iMCustomCommand)
140 iMCustomCommand->CustomCommandSync(iBuilderHandle, ECibRemove, aMessageHandler, KNullDesC8);