os/mm/devsound/devsoundpluginsupport/src/CustomInterfaces/gsmconfigci.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/devsound/devsoundpluginsupport/src/CustomInterfaces/gsmconfigci.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,358 @@
     1.4 +// Copyright (c) 2007-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 <ecom/implementationproxy.h>
    1.20 +#include <ecom/implementationproxy.h>
    1.21 +#include <ecom/ecom.h>
    1.22 +#include <s32mem.h>
    1.23 +
    1.24 +#include "gsmconfigci.h"
    1.25 +
    1.26 +
    1.27 +// MUX //
    1.28 +
    1.29 +TInt CMMFGsmConfigMux::OpenInterface(TUid /*aInterfaceId*/)
    1.30 +	{
    1.31 +	// attempt to open the interface link with the
    1.32 +	// remote slave device
    1.33 +	iRemoteHandle = -1;
    1.34 +	TUid slaveId = {KMmfUidCustomInterfaceGsmConfigDeMux};
    1.35 +
    1.36 +	TInt handle = iUtility->OpenSlave(slaveId, KNullDesC8);
    1.37 +	if (handle >= 0)
    1.38 +		{
    1.39 +		iRemoteHandle = handle;
    1.40 +		}
    1.41 +
    1.42 +	return iRemoteHandle;
    1.43 +	}
    1.44 +
    1.45 +
    1.46 +void CMMFGsmConfigMux::Release()
    1.47 +	{
    1.48 +	// close the slave device if it exists
    1.49 +	if (iRemoteHandle > 0)
    1.50 +		{
    1.51 +		// we assume the slave is closed correctly
    1.52 +		iUtility->CloseSlave(iRemoteHandle);
    1.53 +		}
    1.54 +
    1.55 +	TUid key = iKey;
    1.56 +	delete this;
    1.57 +
    1.58 +	// tell ECom to destroy us
    1.59 +	REComSession::DestroyedImplementation(key);
    1.60 +	}
    1.61 +
    1.62 +
    1.63 +void CMMFGsmConfigMux::PassDestructorKey(TUid aDestructorKey)
    1.64 +	{
    1.65 +	// store the destructor key
    1.66 +	iKey = aDestructorKey;
    1.67 +	}
    1.68 +
    1.69 +
    1.70 +void CMMFGsmConfigMux::CompleteConstructL(MMMFDevSoundCustomInterfaceMuxUtility* aCustomUtility)
    1.71 +	{
    1.72 +	// store a pointer to the utility
    1.73 +	iUtility = aCustomUtility;
    1.74 +	}
    1.75 +
    1.76 +
    1.77 +MMMFDevSoundCustomInterfaceMuxPlugin* CMMFGsmConfigMux::NewL()
    1.78 +	{
    1.79 +	CMMFGsmConfigMux* self = new (ELeave) CMMFGsmConfigMux;
    1.80 +	return self;
    1.81 +	}
    1.82 +
    1.83 +
    1.84 +TAny* CMMFGsmConfigMux::CustomInterface(TUid /*aInterfaceId*/)
    1.85 +	{
    1.86 +	MMMFGsmConfig* interface = this;
    1.87 +	return interface;
    1.88 +	}
    1.89 +
    1.90 +
    1.91 +CMMFGsmConfigMux::CMMFGsmConfigMux() :
    1.92 +iRemoteHandle(-1)
    1.93 +	{
    1.94 +	}
    1.95 +
    1.96 +
    1.97 +CMMFGsmConfigMux::~CMMFGsmConfigMux()
    1.98 +	{
    1.99 +	}
   1.100 +
   1.101 +
   1.102 +// from MMMFGsmConfig
   1.103 +TInt CMMFGsmConfigMux::SetConversionFormat(TMMFGsmConversionFormat aConvFormat)
   1.104 +	{
   1.105 +	TInt result = KErrGeneral;
   1.106 +
   1.107 +	if (iRemoteHandle > 0)
   1.108 +		{
   1.109 +		// send the convFormat in the sync command
   1.110 +		TPckgBuf<TMMFGsmConversionFormat> convFormat(aConvFormat);
   1.111 +
   1.112 +		// any return code other than zero is an error
   1.113 +		result = iUtility->SendSlaveSyncCommand(iRemoteHandle,
   1.114 +												EMMFDevSoundCIGsmConfigSetConversionFormat,
   1.115 +												convFormat);
   1.116 +		}
   1.117 +
   1.118 +	return result;
   1.119 +	}
   1.120 +
   1.121 +
   1.122 +// from MMMFGsmConfig
   1.123 +TInt CMMFGsmConfigMux::ConversionFormat(TMMFGsmConversionFormat& aConvFormat) const
   1.124 +	{
   1.125 +	TInt result = KErrGeneral;
   1.126 +
   1.127 +	if (iRemoteHandle > 0)
   1.128 +		{
   1.129 +		// send the retConvFormat in the sync command
   1.130 +		TPckgBuf<TMMFGsmConversionFormat> retConvFormat;
   1.131 +
   1.132 +		result = iUtility->SendSlaveSyncCommandResult(iRemoteHandle,
   1.133 +													  EMMFDevSoundCIGsmConfigGetConversionFormat,
   1.134 +													  KNullDesC8,
   1.135 +													  retConvFormat);
   1.136 +
   1.137 +		// assign return values to aConvFormat. Do nothing if there is an error
   1.138 +		if(result == KErrNone)
   1.139 +			{
   1.140 +			aConvFormat = retConvFormat();
   1.141 +			}
   1.142 +		}
   1.143 +
   1.144 +	return result;
   1.145 +	}
   1.146 +
   1.147 +
   1.148 +
   1.149 +// DEMUX //
   1.150 +
   1.151 +TInt CMMFGsmConfigDeMux::OpenInterface(TUid /*aInterfaceId*/)
   1.152 +	{
   1.153 +	return KErrNone;
   1.154 +	}
   1.155 +
   1.156 +
   1.157 +void CMMFGsmConfigDeMux::Release()
   1.158 +	{
   1.159 +	TUid key = iKey;
   1.160 +
   1.161 +	delete this;
   1.162 +
   1.163 +	// tell ECom to destroy us
   1.164 +	REComSession::DestroyedImplementation(key);
   1.165 +	}
   1.166 +
   1.167 +
   1.168 +void CMMFGsmConfigDeMux::PassDestructorKey(TUid aDestructorKey)
   1.169 +	{
   1.170 +	// store the destructor key
   1.171 +	iKey = aDestructorKey;
   1.172 +	}
   1.173 +
   1.174 +
   1.175 +void CMMFGsmConfigDeMux::SetInterfaceTarget(MMMFDevSoundCustomInterfaceTarget* aTarget)
   1.176 +	{
   1.177 +	iTarget = aTarget;
   1.178 +	}
   1.179 +
   1.180 +
   1.181 +void CMMFGsmConfigDeMux::CompleteConstructL(MMMFDevSoundCustomInterfaceDeMuxUtility* aCustomUtility)
   1.182 +	{
   1.183 +	// store a pointer to the utility
   1.184 +	iUtility = aCustomUtility;
   1.185 +	}
   1.186 +
   1.187 +
   1.188 +void CMMFGsmConfigDeMux::RefreshL()
   1.189 +	{
   1.190 +	// refetch the Gsm config custom interface if we already have a target
   1.191 +	if (iTarget)
   1.192 +		{
   1.193 +		iInterfaceGsmConfig = static_cast <MMMFGsmConfig*> (iTarget->CustomInterface(KUidGsmConfig));
   1.194 +
   1.195 +		if (!iInterfaceGsmConfig)
   1.196 +			{
   1.197 +			iInterfaceGsmConfig = NULL;
   1.198 +			User::Leave(KErrNotSupported);
   1.199 +			}
   1.200 +		}
   1.201 +	}
   1.202 +
   1.203 +
   1.204 +MMMFDevSoundCustomInterfaceDeMuxPlugin* CMMFGsmConfigDeMux::NewL()
   1.205 +	{
   1.206 +	CMMFGsmConfigDeMux* self = new (ELeave) CMMFGsmConfigDeMux;
   1.207 +	return self;
   1.208 +	}
   1.209 +
   1.210 +
   1.211 +CMMFGsmConfigDeMux::CMMFGsmConfigDeMux()
   1.212 +	{
   1.213 +	}
   1.214 +
   1.215 +
   1.216 +CMMFGsmConfigDeMux::~CMMFGsmConfigDeMux()
   1.217 +	{
   1.218 +	}
   1.219 +
   1.220 +
   1.221 +TInt CMMFGsmConfigDeMux::DoOpenSlaveL(TUid /*aInterface*/, const TDesC8& /*aPackageBuf*/)
   1.222 +	{
   1.223 +	// fetch the Gsm Config Hw Device custom interface
   1.224 +	iInterfaceGsmConfig = static_cast<MMMFGsmConfig*> (iTarget->CustomInterface(KUidGsmConfig)); 
   1.225 +
   1.226 +	if (!iInterfaceGsmConfig)
   1.227 +		{
   1.228 +		iInterfaceGsmConfig = NULL;
   1.229 +		User::Leave(KErrNotSupported);
   1.230 +		}
   1.231 +
   1.232 +	return KErrNone;
   1.233 +	}
   1.234 +
   1.235 +
   1.236 +void CMMFGsmConfigDeMux::DoCloseSlaveL(TInt /*aHandle*/)
   1.237 +	{
   1.238 +	// nothing to do
   1.239 +	}
   1.240 +
   1.241 +
   1.242 +// original RMessage is supplied so that remote demux plugin can extract necessary details
   1.243 +// using DeMux utility
   1.244 +TInt CMMFGsmConfigDeMux::DoSendSlaveSyncCommandL(const RMmfIpcMessage& aMessage)
   1.245 +	{
   1.246 +	TMMFDevSoundCIMessageData data;
   1.247 +	TInt result = KErrNotSupported;
   1.248 +
   1.249 +	// decode message
   1.250 +	iUtility->GetSyncMessageDataL(aMessage, data);
   1.251 +
   1.252 +	switch (data.iCommand)
   1.253 +		{
   1.254 +		case EMMFDevSoundCIGsmConfigSetConversionFormat:
   1.255 +			{
   1.256 +			TPckgBuf<MMMFGsmConfig::TMMFGsmConversionFormat> convFormat; 
   1.257 +			iUtility->ReadFromInputDesL(aMessage, &convFormat);
   1.258 +
   1.259 +			result = DoSetConversionFormatL(convFormat());
   1.260 +
   1.261 +			break;
   1.262 +			}
   1.263 +		default:
   1.264 +			{
   1.265 +			User::Leave(KErrNotSupported);
   1.266 +			}
   1.267 +		}
   1.268 +
   1.269 +	return result;
   1.270 +	}
   1.271 +
   1.272 +
   1.273 +TInt CMMFGsmConfigDeMux::DoSendSlaveSyncCommandResultL(const RMmfIpcMessage& aMessage)
   1.274 +	{
   1.275 +	TMMFDevSoundCIMessageData data;
   1.276 +	TInt result = KErrNotSupported;
   1.277 +
   1.278 +	// decode message
   1.279 +	iUtility->GetSyncMessageDataL(aMessage, data);
   1.280 +
   1.281 +	switch (data.iCommand)
   1.282 +		{
   1.283 +		case EMMFDevSoundCIGsmConfigGetConversionFormat:
   1.284 +			{
   1.285 +			TPckgBuf<MMMFGsmConfig::TMMFGsmConversionFormat> convFormat; 
   1.286 +			iUtility->ReadFromInputDesL(aMessage, &convFormat);
   1.287 +			
   1.288 +			result = DoConversionFormatL(convFormat());
   1.289 +
   1.290 +			TPckgBuf<TBool> des(convFormat());
   1.291 +			iUtility->WriteToOutputDesL(aMessage, des);
   1.292 +			break;
   1.293 +			}
   1.294 +		default:
   1.295 +			{
   1.296 +			User::Leave(KErrNotSupported);
   1.297 +			}
   1.298 +		}
   1.299 +
   1.300 +	return result;
   1.301 +	}
   1.302 +
   1.303 +
   1.304 +void CMMFGsmConfigDeMux::DoSendSlaveAsyncCommandL(const RMmfIpcMessage& /*aMessage*/)
   1.305 +	{
   1.306 +	// not used in this interface
   1.307 +	}
   1.308 +
   1.309 +
   1.310 +void CMMFGsmConfigDeMux::DoSendSlaveAsyncCommandResultL(const RMmfIpcMessage& /*aMessage*/)
   1.311 +	{
   1.312 +	// not used in this interface
   1.313 +	}
   1.314 +
   1.315 +
   1.316 +// Gsm Config custom interface implementation
   1.317 +TInt CMMFGsmConfigDeMux::DoSetConversionFormatL(MMMFGsmConfig::TMMFGsmConversionFormat aConvFormat)
   1.318 +	{
   1.319 +	TInt result = KErrNotFound;
   1.320 +
   1.321 +	if (iInterfaceGsmConfig)
   1.322 +		{
   1.323 +		result = iInterfaceGsmConfig->SetConversionFormat(aConvFormat);
   1.324 +		}
   1.325 +
   1.326 +	return result;
   1.327 +	}
   1.328 +
   1.329 +
   1.330 +// Gsm Config custom interface implementation
   1.331 +TInt CMMFGsmConfigDeMux::DoConversionFormatL(MMMFGsmConfig::TMMFGsmConversionFormat& aConvFormat) const
   1.332 +	{
   1.333 +	TInt result = KErrNotFound;
   1.334 +
   1.335 +	if (iInterfaceGsmConfig)
   1.336 +		{
   1.337 +		result = iInterfaceGsmConfig->ConversionFormat(aConvFormat);
   1.338 +		}
   1.339 +
   1.340 +	return result;
   1.341 +	}
   1.342 +
   1.343 +
   1.344 +//
   1.345 +// ImplementationTable
   1.346 +//
   1.347 +const TImplementationProxy ImplementationTable[] = 
   1.348 +	{
   1.349 +	IMPLEMENTATION_PROXY_ENTRY(KMmfUidCustomInterfaceGsmConfigMux,		CMMFGsmConfigMux::NewL),
   1.350 +	IMPLEMENTATION_PROXY_ENTRY(KMmfUidCustomInterfaceGsmConfigDeMux,	CMMFGsmConfigDeMux::NewL),
   1.351 +	};
   1.352 +
   1.353 +//
   1.354 +// ImplementationGroupProxy
   1.355 +//
   1.356 +EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
   1.357 +	{
   1.358 +	aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
   1.359 +
   1.360 +	return ImplementationTable;
   1.361 +	}