sl@0: // Copyright (c) 2007-2009 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: sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: #include "gsmconfigci.h" sl@0: sl@0: sl@0: // MUX // sl@0: sl@0: TInt CMMFGsmConfigMux::OpenInterface(TUid /*aInterfaceId*/) sl@0: { sl@0: // attempt to open the interface link with the sl@0: // remote slave device sl@0: iRemoteHandle = -1; sl@0: TUid slaveId = {KMmfUidCustomInterfaceGsmConfigDeMux}; sl@0: sl@0: TInt handle = iUtility->OpenSlave(slaveId, KNullDesC8); sl@0: if (handle >= 0) sl@0: { sl@0: iRemoteHandle = handle; sl@0: } sl@0: sl@0: return iRemoteHandle; sl@0: } sl@0: sl@0: sl@0: void CMMFGsmConfigMux::Release() sl@0: { sl@0: // close the slave device if it exists sl@0: if (iRemoteHandle > 0) sl@0: { sl@0: // we assume the slave is closed correctly sl@0: iUtility->CloseSlave(iRemoteHandle); sl@0: } sl@0: sl@0: TUid key = iKey; sl@0: delete this; sl@0: sl@0: // tell ECom to destroy us sl@0: REComSession::DestroyedImplementation(key); sl@0: } sl@0: sl@0: sl@0: void CMMFGsmConfigMux::PassDestructorKey(TUid aDestructorKey) sl@0: { sl@0: // store the destructor key sl@0: iKey = aDestructorKey; sl@0: } sl@0: sl@0: sl@0: void CMMFGsmConfigMux::CompleteConstructL(MMMFDevSoundCustomInterfaceMuxUtility* aCustomUtility) sl@0: { sl@0: // store a pointer to the utility sl@0: iUtility = aCustomUtility; sl@0: } sl@0: sl@0: sl@0: MMMFDevSoundCustomInterfaceMuxPlugin* CMMFGsmConfigMux::NewL() sl@0: { sl@0: CMMFGsmConfigMux* self = new (ELeave) CMMFGsmConfigMux; sl@0: return self; sl@0: } sl@0: sl@0: sl@0: TAny* CMMFGsmConfigMux::CustomInterface(TUid /*aInterfaceId*/) sl@0: { sl@0: MMMFGsmConfig* interface = this; sl@0: return interface; sl@0: } sl@0: sl@0: sl@0: CMMFGsmConfigMux::CMMFGsmConfigMux() : sl@0: iRemoteHandle(-1) sl@0: { sl@0: } sl@0: sl@0: sl@0: CMMFGsmConfigMux::~CMMFGsmConfigMux() sl@0: { sl@0: } sl@0: sl@0: sl@0: // from MMMFGsmConfig sl@0: TInt CMMFGsmConfigMux::SetConversionFormat(TMMFGsmConversionFormat aConvFormat) sl@0: { sl@0: TInt result = KErrGeneral; sl@0: sl@0: if (iRemoteHandle > 0) sl@0: { sl@0: // send the convFormat in the sync command sl@0: TPckgBuf convFormat(aConvFormat); sl@0: sl@0: // any return code other than zero is an error sl@0: result = iUtility->SendSlaveSyncCommand(iRemoteHandle, sl@0: EMMFDevSoundCIGsmConfigSetConversionFormat, sl@0: convFormat); sl@0: } sl@0: sl@0: return result; sl@0: } sl@0: sl@0: sl@0: // from MMMFGsmConfig sl@0: TInt CMMFGsmConfigMux::ConversionFormat(TMMFGsmConversionFormat& aConvFormat) const sl@0: { sl@0: TInt result = KErrGeneral; sl@0: sl@0: if (iRemoteHandle > 0) sl@0: { sl@0: // send the retConvFormat in the sync command sl@0: TPckgBuf retConvFormat; sl@0: sl@0: result = iUtility->SendSlaveSyncCommandResult(iRemoteHandle, sl@0: EMMFDevSoundCIGsmConfigGetConversionFormat, sl@0: KNullDesC8, sl@0: retConvFormat); sl@0: sl@0: // assign return values to aConvFormat. Do nothing if there is an error sl@0: if(result == KErrNone) sl@0: { sl@0: aConvFormat = retConvFormat(); sl@0: } sl@0: } sl@0: sl@0: return result; sl@0: } sl@0: sl@0: sl@0: sl@0: // DEMUX // sl@0: sl@0: TInt CMMFGsmConfigDeMux::OpenInterface(TUid /*aInterfaceId*/) sl@0: { sl@0: return KErrNone; sl@0: } sl@0: sl@0: sl@0: void CMMFGsmConfigDeMux::Release() sl@0: { sl@0: TUid key = iKey; sl@0: sl@0: delete this; sl@0: sl@0: // tell ECom to destroy us sl@0: REComSession::DestroyedImplementation(key); sl@0: } sl@0: sl@0: sl@0: void CMMFGsmConfigDeMux::PassDestructorKey(TUid aDestructorKey) sl@0: { sl@0: // store the destructor key sl@0: iKey = aDestructorKey; sl@0: } sl@0: sl@0: sl@0: void CMMFGsmConfigDeMux::SetInterfaceTarget(MMMFDevSoundCustomInterfaceTarget* aTarget) sl@0: { sl@0: iTarget = aTarget; sl@0: } sl@0: sl@0: sl@0: void CMMFGsmConfigDeMux::CompleteConstructL(MMMFDevSoundCustomInterfaceDeMuxUtility* aCustomUtility) sl@0: { sl@0: // store a pointer to the utility sl@0: iUtility = aCustomUtility; sl@0: } sl@0: sl@0: sl@0: void CMMFGsmConfigDeMux::RefreshL() sl@0: { sl@0: // refetch the Gsm config custom interface if we already have a target sl@0: if (iTarget) sl@0: { sl@0: iInterfaceGsmConfig = static_cast (iTarget->CustomInterface(KUidGsmConfig)); sl@0: sl@0: if (!iInterfaceGsmConfig) sl@0: { sl@0: iInterfaceGsmConfig = NULL; sl@0: User::Leave(KErrNotSupported); sl@0: } sl@0: } sl@0: } sl@0: sl@0: sl@0: MMMFDevSoundCustomInterfaceDeMuxPlugin* CMMFGsmConfigDeMux::NewL() sl@0: { sl@0: CMMFGsmConfigDeMux* self = new (ELeave) CMMFGsmConfigDeMux; sl@0: return self; sl@0: } sl@0: sl@0: sl@0: CMMFGsmConfigDeMux::CMMFGsmConfigDeMux() sl@0: { sl@0: } sl@0: sl@0: sl@0: CMMFGsmConfigDeMux::~CMMFGsmConfigDeMux() sl@0: { sl@0: } sl@0: sl@0: sl@0: TInt CMMFGsmConfigDeMux::DoOpenSlaveL(TUid /*aInterface*/, const TDesC8& /*aPackageBuf*/) sl@0: { sl@0: // fetch the Gsm Config Hw Device custom interface sl@0: iInterfaceGsmConfig = static_cast (iTarget->CustomInterface(KUidGsmConfig)); sl@0: sl@0: if (!iInterfaceGsmConfig) sl@0: { sl@0: iInterfaceGsmConfig = NULL; sl@0: User::Leave(KErrNotSupported); sl@0: } sl@0: sl@0: return KErrNone; sl@0: } sl@0: sl@0: sl@0: void CMMFGsmConfigDeMux::DoCloseSlaveL(TInt /*aHandle*/) sl@0: { sl@0: // nothing to do sl@0: } sl@0: sl@0: sl@0: // original RMessage is supplied so that remote demux plugin can extract necessary details sl@0: // using DeMux utility sl@0: TInt CMMFGsmConfigDeMux::DoSendSlaveSyncCommandL(const RMmfIpcMessage& aMessage) sl@0: { sl@0: TMMFDevSoundCIMessageData data; sl@0: TInt result = KErrNotSupported; sl@0: sl@0: // decode message sl@0: iUtility->GetSyncMessageDataL(aMessage, data); sl@0: sl@0: switch (data.iCommand) sl@0: { sl@0: case EMMFDevSoundCIGsmConfigSetConversionFormat: sl@0: { sl@0: TPckgBuf convFormat; sl@0: iUtility->ReadFromInputDesL(aMessage, &convFormat); sl@0: sl@0: result = DoSetConversionFormatL(convFormat()); sl@0: sl@0: break; sl@0: } sl@0: default: sl@0: { sl@0: User::Leave(KErrNotSupported); sl@0: } sl@0: } sl@0: sl@0: return result; sl@0: } sl@0: sl@0: sl@0: TInt CMMFGsmConfigDeMux::DoSendSlaveSyncCommandResultL(const RMmfIpcMessage& aMessage) sl@0: { sl@0: TMMFDevSoundCIMessageData data; sl@0: TInt result = KErrNotSupported; sl@0: sl@0: // decode message sl@0: iUtility->GetSyncMessageDataL(aMessage, data); sl@0: sl@0: switch (data.iCommand) sl@0: { sl@0: case EMMFDevSoundCIGsmConfigGetConversionFormat: sl@0: { sl@0: TPckgBuf convFormat; sl@0: iUtility->ReadFromInputDesL(aMessage, &convFormat); sl@0: sl@0: result = DoConversionFormatL(convFormat()); sl@0: sl@0: TPckgBuf des(convFormat()); sl@0: iUtility->WriteToOutputDesL(aMessage, des); sl@0: break; sl@0: } sl@0: default: sl@0: { sl@0: User::Leave(KErrNotSupported); sl@0: } sl@0: } sl@0: sl@0: return result; sl@0: } sl@0: sl@0: sl@0: void CMMFGsmConfigDeMux::DoSendSlaveAsyncCommandL(const RMmfIpcMessage& /*aMessage*/) sl@0: { sl@0: // not used in this interface sl@0: } sl@0: sl@0: sl@0: void CMMFGsmConfigDeMux::DoSendSlaveAsyncCommandResultL(const RMmfIpcMessage& /*aMessage*/) sl@0: { sl@0: // not used in this interface sl@0: } sl@0: sl@0: sl@0: // Gsm Config custom interface implementation sl@0: TInt CMMFGsmConfigDeMux::DoSetConversionFormatL(MMMFGsmConfig::TMMFGsmConversionFormat aConvFormat) sl@0: { sl@0: TInt result = KErrNotFound; sl@0: sl@0: if (iInterfaceGsmConfig) sl@0: { sl@0: result = iInterfaceGsmConfig->SetConversionFormat(aConvFormat); sl@0: } sl@0: sl@0: return result; sl@0: } sl@0: sl@0: sl@0: // Gsm Config custom interface implementation sl@0: TInt CMMFGsmConfigDeMux::DoConversionFormatL(MMMFGsmConfig::TMMFGsmConversionFormat& aConvFormat) const sl@0: { sl@0: TInt result = KErrNotFound; sl@0: sl@0: if (iInterfaceGsmConfig) sl@0: { sl@0: result = iInterfaceGsmConfig->ConversionFormat(aConvFormat); sl@0: } sl@0: sl@0: return result; sl@0: } sl@0: sl@0: sl@0: // sl@0: // ImplementationTable sl@0: // sl@0: const TImplementationProxy ImplementationTable[] = sl@0: { sl@0: IMPLEMENTATION_PROXY_ENTRY(KMmfUidCustomInterfaceGsmConfigMux, CMMFGsmConfigMux::NewL), sl@0: IMPLEMENTATION_PROXY_ENTRY(KMmfUidCustomInterfaceGsmConfigDeMux, CMMFGsmConfigDeMux::NewL), sl@0: }; sl@0: sl@0: // sl@0: // ImplementationGroupProxy sl@0: // sl@0: EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) sl@0: { sl@0: aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); sl@0: sl@0: return ImplementationTable; sl@0: }