os/mm/devsoundextensions/mmextfw/custominterfaceutility/CustomInterfaceUtility/src/ProxyCustomInterfaceUtility.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/devsoundextensions/mmextfw/custominterfaceutility/CustomInterfaceUtility/src/ProxyCustomInterfaceUtility.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,145 @@
     1.4 +/*
     1.5 +* Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies). 
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description: CustomInterfaceUtility Proxy implementation
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +
    1.23 +// INCLUDE FILES
    1.24 +#include <ProxyCustomInterfaceUtility.h>
    1.25 +#include "CustomInterfaceBuilderTypes.h"
    1.26 +#include "CustomInterfaceProxyFactory.h"
    1.27 +
    1.28 +
    1.29 +EXPORT_C CProxyCustomInterfaceUtility* CProxyCustomInterfaceUtility::NewL(CCustomCommandUtility* aCustomCommandUtility)
    1.30 +	{
    1.31 +	CProxyCustomInterfaceUtility* self = new(ELeave) CProxyCustomInterfaceUtility(aCustomCommandUtility);
    1.32 +	CleanupStack::PushL(self);
    1.33 +	self->ConstructL();
    1.34 +	CleanupStack::Pop(self);
    1.35 +	return self;
    1.36 +	}
    1.37 +
    1.38 +EXPORT_C CProxyCustomInterfaceUtility* CProxyCustomInterfaceUtility::NewL(MCustomCommand& aMCustomCommand)
    1.39 +	{
    1.40 +	CProxyCustomInterfaceUtility* self = new(ELeave) CProxyCustomInterfaceUtility(aMCustomCommand);
    1.41 +	CleanupStack::PushL(self);
    1.42 +	self->ConstructL();
    1.43 +	CleanupStack::Pop(self);
    1.44 +	return self;
    1.45 +	}
    1.46 +
    1.47 +CProxyCustomInterfaceUtility::CProxyCustomInterfaceUtility(CCustomCommandUtility* aCustomCommandUtility) :
    1.48 +														CCustomInterfaceUtility(),
    1.49 +														iCustomCommandUtility(aCustomCommandUtility)
    1.50 +	{
    1.51 +	}
    1.52 +
    1.53 +CProxyCustomInterfaceUtility::CProxyCustomInterfaceUtility(MCustomCommand& aMCustomCommand) :
    1.54 +														CCustomInterfaceUtility(),
    1.55 +														iMCustomCommand(&aMCustomCommand)
    1.56 +	{
    1.57 +	}
    1.58 +
    1.59 +
    1.60 +CProxyCustomInterfaceUtility::~CProxyCustomInterfaceUtility()
    1.61 +	{
    1.62 +	delete iCustomCommandUtility;
    1.63 +    // Do not delete iMCustomCommand. Unlike iCustomCommandUtility we don't own
    1.64 +    // iMCustomCommand.
    1.65 +	}
    1.66 +
    1.67 +void CProxyCustomInterfaceUtility::ConstructL()
    1.68 +	{
    1.69 +	TMMFMessageDestination     destination(KUidCustomInterfaceBuilder);
    1.70 +	TMMFMessageDestinationPckg destinationPckg(destination);
    1.71 +	TMMFMessageDestination     builderHandle;
    1.72 +	TMMFMessageDestinationPckg builderHandlePckg(builderHandle);
    1.73 +	iBuilderHandle = builderHandlePckg;
    1.74 +
    1.75 +    if (iCustomCommandUtility)
    1.76 +        {
    1.77 +	    iCustomCommandUtility->CustomCommandSync(destinationPckg, ECibGetBuilder, KNullDesC8, KNullDesC8, iBuilderHandle);
    1.78 +        }
    1.79 +    else if (iMCustomCommand)
    1.80 +        {
    1.81 +        iMCustomCommand->CustomCommandSync(destinationPckg, ECibGetBuilder, KNullDesC8, KNullDesC8, iBuilderHandle);
    1.82 +        }
    1.83 +
    1.84 +	if(iBuilderHandle().InterfaceId() == KNullUid)
    1.85 +		{
    1.86 +		User::Leave(KErrNotFound);
    1.87 +		}
    1.88 +	}
    1.89 +
    1.90 +EXPORT_C TAny* CProxyCustomInterfaceUtility::CustomInterface(TUid aInterfaceId)
    1.91 +	{
    1.92 +	// Get Handle
    1.93 +	TMMFMessageDestination     handle;
    1.94 +	TMMFMessageDestinationPckg handlePckg(handle);
    1.95 +	TPckgBuf<TUid> uidPckg;
    1.96 +	uidPckg() = aInterfaceId;
    1.97 +
    1.98 +	if (iCustomCommandUtility)
    1.99 +        {
   1.100 +        iCustomCommandUtility->CustomCommandSync(iBuilderHandle, ECibBuild, uidPckg, KNullDesC8, handlePckg);
   1.101 +        }
   1.102 +    else if (iMCustomCommand)
   1.103 +        {
   1.104 +        iMCustomCommand->CustomCommandSync(iBuilderHandle, ECibBuild, uidPckg, KNullDesC8, handlePckg);
   1.105 +        }
   1.106 +	
   1.107 +	TAny* result = NULL;
   1.108 +
   1.109 +	if(handlePckg().InterfaceId() == KNullUid)
   1.110 +		{
   1.111 +		result = NULL;
   1.112 +		}
   1.113 +	else
   1.114 +		{
   1.115 +	    if (iCustomCommandUtility)
   1.116 +            {
   1.117 +    		result = CCustomInterfaceProxyFactory::CreateProxy(aInterfaceId, handlePckg, *iCustomCommandUtility, this);
   1.118 +            }
   1.119 +        else if (iMCustomCommand)
   1.120 +            {
   1.121 +            result = CCustomInterfaceProxyFactory::CreateProxy(aInterfaceId, handlePckg, *iMCustomCommand, this);
   1.122 +            }
   1.123 +        
   1.124 +		}
   1.125 +
   1.126 +	return result;
   1.127 +	}
   1.128 +
   1.129 +
   1.130 +EXPORT_C void CProxyCustomInterfaceUtility::RemoveCustomInterface(TMMFMessageDestinationPckg aMessageHandler)
   1.131 +	{
   1.132 +	// Get Handle
   1.133 +	TMMFMessageDestination     handle;
   1.134 +	TMMFMessageDestinationPckg handlePckg(handle);
   1.135 +
   1.136 +	
   1.137 +	if (iCustomCommandUtility)
   1.138 +        {
   1.139 +        iCustomCommandUtility->CustomCommandSync(iBuilderHandle, ECibRemove, aMessageHandler, KNullDesC8);
   1.140 +        }
   1.141 +    else if (iMCustomCommand)
   1.142 +        {
   1.143 +        iMCustomCommand->CustomCommandSync(iBuilderHandle, ECibRemove, aMessageHandler, KNullDesC8);
   1.144 +        }
   1.145 +	}
   1.146 +
   1.147 +
   1.148 +// End of File