os/mm/devsound/devsoundrefplugin/src/platsec/SoundDevice/MmfDevSoundCIMuxUtility.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/devsound/devsoundrefplugin/src/platsec/SoundDevice/MmfDevSoundCIMuxUtility.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,147 @@
     1.4 +// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#include "MmfDevSoundCIMuxUtility.h"
    1.20 +#include <mmf/plugin/mmfdevsoundcustominterface.hrh>
    1.21 +#include <mmf/server/mmfdevsoundcustominterface.h>
    1.22 +#include <mmf/server/mmfdevsoundcustomcommands.h>
    1.23 +#include <ecom/ecom.h>
    1.24 +#include <mm/mmpluginutils.h>
    1.25 +
    1.26 +
    1.27 +CMMFDevSoundCIMuxUtility* CMMFDevSoundCIMuxUtility::NewL(MMMFDevSoundCustomInterfaceChannel* aCustomChannel)
    1.28 +	{
    1.29 +	CMMFDevSoundCIMuxUtility* self = new (ELeave) CMMFDevSoundCIMuxUtility(aCustomChannel);
    1.30 +	CleanupStack::PushL(self);
    1.31 +	self->ConstructL();
    1.32 +	CleanupStack::Pop(self);
    1.33 +	return self;
    1.34 +	}
    1.35 +
    1.36 +void CMMFDevSoundCIMuxUtility::ConstructL()
    1.37 +	{
    1.38 +	// nothing needed in this implementation
    1.39 +	}
    1.40 +
    1.41 +CMMFDevSoundCIMuxUtility::~CMMFDevSoundCIMuxUtility()
    1.42 +	{
    1.43 +
    1.44 +	}
    1.45 +
    1.46 +const TInt KMuxTempBufferSize = 20;
    1.47 +
    1.48 +// create a custom interface Mux implementation
    1.49 +MMMFDevSoundCustomInterfaceMuxPlugin* CMMFDevSoundCIMuxUtility::CreateCustomInterfaceMuxL(TUid aInterfaceId)
    1.50 +	{
    1.51 +	// The Uid of the plugin will be the match string
    1.52 +	TInt uidAsInteger = aInterfaceId.iUid;
    1.53 +	TBuf8<KMuxTempBufferSize> tempBuffer;
    1.54 +	tempBuffer.Num(uidAsInteger, EHex); // has value
    1.55 +	TUid interfaceUid = {KUidDevSoundCustomInterfaceMux};
    1.56 +	
    1.57 +	TUid destructorKey;
    1.58 +	MMMFDevSoundCustomInterfaceMuxPlugin* self = 
    1.59 +		static_cast<MMMFDevSoundCustomInterfaceMuxPlugin*>
    1.60 +		(MmPluginUtils::CreateImplementationL(interfaceUid, destructorKey, tempBuffer, KRomOnlyResolverUid));
    1.61 +
    1.62 +	// pass the destructor key so class can destroy itself
    1.63 +	self->PassDestructorKey(destructorKey);
    1.64 +	CleanupReleasePushL(*self);
    1.65 +
    1.66 +	// attempt to construct the plugin
    1.67 +	self->CompleteConstructL(this);
    1.68 +	CleanupStack::Pop(); // self
    1.69 +		
    1.70 +	return self;
    1.71 +	}
    1.72 +
    1.73 +	
    1.74 +// from MMMFDevSoundCustomInterfaceMux interface
    1.75 +TInt CMMFDevSoundCIMuxUtility::OpenSlave(TUid aInterface, const TDesC8& aPackageBuf)
    1.76 +	{
    1.77 +	// 1. send openslave custom command to remote side
    1.78 +	// 2. devsoundsession intercepts this custom command
    1.79 +	//    and creates / opens interface
    1.80 +	// open packet = command, interface, inBuff
    1.81 +	TUid commandId(KNullUid);
    1.82 +	commandId.iUid = EMMFDevSoundCustomCommandCIOpenSlave;
    1.83 +	TPckgBuf<TUid> idBuffer(aInterface);
    1.84 +	
    1.85 +	return iCustomChannel->SyncCustomCommand(commandId, idBuffer, aPackageBuf, NULL);
    1.86 +	}
    1.87 +	
    1.88 +void CMMFDevSoundCIMuxUtility::CloseSlave(TInt aHandle)
    1.89 +	{
    1.90 +	// 1. send closeslave custom command to remote side
    1.91 +	// 2. demuxplugin removes its handle for this interface
    1.92 +	TUid commandId(KNullUid);
    1.93 +	commandId.iUid = EMMFDevSoundCustomCommandCICloseSlave;
    1.94 +	TPckgBuf<TInt> handleBuffer(aHandle);
    1.95 +	
    1.96 +	iCustomChannel->SyncCustomCommand(commandId, handleBuffer, KNullDesC8, NULL);
    1.97 +	}
    1.98 +
    1.99 +
   1.100 +TInt CMMFDevSoundCIMuxUtility::SendSlaveSyncCommand(TInt aHandle, TInt aCommand, const TDesC8& aPackageBuf)
   1.101 +	{
   1.102 +	TUid commandId(KNullUid);
   1.103 +	commandId.iUid = EMMFDevSoundCustomCommandCISendSlaveSyncCommand;
   1.104 +		
   1.105 +	TMMFDevSoundCustomInterfaceCommand commandPair;
   1.106 +	commandPair.iCommand = aCommand;
   1.107 +	commandPair.iHandle = aHandle;
   1.108 +	TPckgBuf<TMMFDevSoundCustomInterfaceCommand> comBuffer(commandPair);
   1.109 +	
   1.110 +	return iCustomChannel->SyncCustomCommand(commandId, comBuffer, aPackageBuf, NULL);
   1.111 +	}
   1.112 +
   1.113 +TInt CMMFDevSoundCIMuxUtility::SendSlaveSyncCommandResult(TInt aHandle, TInt aCommand, const TDesC8& aPackageBuf, TDes8& aResultBuf)
   1.114 +	{
   1.115 +	TUid commandId(KNullUid);
   1.116 +	commandId.iUid = EMMFDevSoundCustomCommandCISendSlaveSyncCommandResult;
   1.117 +		
   1.118 +	TMMFDevSoundCustomInterfaceCommand commandPair;
   1.119 +	commandPair.iCommand = aCommand;
   1.120 +	commandPair.iHandle = aHandle;
   1.121 +	TPckgBuf<TMMFDevSoundCustomInterfaceCommand> comBuffer(commandPair);
   1.122 +
   1.123 +	return iCustomChannel->SyncCustomCommand(commandId, comBuffer, aPackageBuf, &aResultBuf);
   1.124 +	}
   1.125 +
   1.126 +void CMMFDevSoundCIMuxUtility::SendSlaveAsyncCommand(TMMFDevSoundCustomInterfaceCommandPackage& aComPackage, TRequestStatus& aStatus, const TDesC8& aPackageBuf)
   1.127 +	{
   1.128 +	TUid commandId(KNullUid);
   1.129 +	commandId.iUid = EMMFDevSoundCustomCommandCISendSlaveAsyncCommand;
   1.130 +	
   1.131 +	// command and handle comes from client with asynchronous commands
   1.132 +		
   1.133 +	iCustomChannel->AsyncCustomCommand(commandId, aStatus, aComPackage, aPackageBuf, NULL);
   1.134 +	}
   1.135 +	
   1.136 +void CMMFDevSoundCIMuxUtility::SendSlaveAsyncCommandResult(TMMFDevSoundCustomInterfaceCommandPackage& aComPackage, TRequestStatus& aStatus, const TDesC8& aPackageBuf, TDes8& aResultBuf)
   1.137 +	{
   1.138 +	TUid commandId(KNullUid);
   1.139 +	commandId.iUid = EMMFDevSoundCustomCommandCISendSlaveAsyncCommandResult;
   1.140 +		
   1.141 +	// command and handle comes from client with asynchronous commands
   1.142 +
   1.143 +	iCustomChannel->AsyncCustomCommand(commandId, aStatus, aComPackage, aPackageBuf, &aResultBuf);
   1.144 +	}
   1.145 +
   1.146 +CMMFDevSoundCIMuxUtility::CMMFDevSoundCIMuxUtility(MMMFDevSoundCustomInterfaceChannel* aCustomChannel)
   1.147 +: iCustomChannel(aCustomChannel)
   1.148 +	{
   1.149 +	}
   1.150 +