sl@0: /* sl@0: * Copyright (c) 2006 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: Server-side session implementation sl@0: * sl@0: */ sl@0: sl@0: sl@0: sl@0: #include sl@0: #include sl@0: #include // for stream classes sl@0: #include "TelephonyAudioRoutingServerSession.h" sl@0: sl@0: const TInt KMaxNumberOfOutputs = 100; sl@0: sl@0: // ============================ MEMBER FUNCTIONS =============================== sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CTelephonyAudioRoutingServerSession::CTelephonyAudioRoutingServerSession sl@0: // C++ default constructor can NOT contain any code, that sl@0: // might leave. sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: CTelephonyAudioRoutingServerSession::CTelephonyAudioRoutingServerSession( sl@0: TInt aSessionId) sl@0: :iSessionId(aSessionId), sl@0: iMessageArray() sl@0: { sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingServerSession[%x]::CTelephonyAudioRoutingServerSession "),this); sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t iMessageArrayCount = %d "),iMessageArray.Count()); sl@0: sl@0: } sl@0: sl@0: // Destructor sl@0: CTelephonyAudioRoutingServerSession::~CTelephonyAudioRoutingServerSession() sl@0: { sl@0: sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingServerSession[%x]::~CTelephonyAudioRoutingServerSession "),this); sl@0: sl@0: if (&Server() != NULL) sl@0: { sl@0: Server().RemoveSession(iSessionId); sl@0: } sl@0: sl@0: iSessionAvailableOutputs.Close(); sl@0: iMessageArray.Close(); sl@0: sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CTelephonyAudioRoutingServerSession::Server sl@0: // Creates the server. sl@0: // (other items were commented in a header). sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: CTelephonyAudioRoutingServer& CTelephonyAudioRoutingServerSession::Server() sl@0: { sl@0: return *static_cast(const_cast(CSession2::Server())); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CTelephonyAudioRoutingServerSession::ServiceError sl@0: // Handle an error from ServiceL sl@0: // (other items were commented in a header). sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: void CTelephonyAudioRoutingServerSession::ServiceError( sl@0: const RMessage2& aMessage, sl@0: TInt aError) sl@0: { sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingServerSession::ServiceError - %d "), aError); sl@0: PanicClient (aMessage, EPanicIllegalFunction); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CTelephonyAudioRoutingServerSession::ServiceL sl@0: // Handles the servicing of a client request that has been passed to the server. sl@0: // (other items were commented in a header). sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: void CTelephonyAudioRoutingServerSession::ServiceL ( sl@0: const RMessage2& aMessage) sl@0: { sl@0: sl@0: switch (aMessage.Function()) sl@0: { sl@0: case ETelAudRtngServDoSetOutput: sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingServerSession[%x]::ServiceL - ETelAudRtngServDoSetOutput "),this); sl@0: DoSetOutputL(aMessage); sl@0: break; sl@0: sl@0: case ETelAudRtngServNotifyIfOutputChanged: sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingServerSession[%x]::ServiceL - ETelAudRtngServNotifyIfOutputChanged "),this); sl@0: NotifyIfOutputChangedL(aMessage); sl@0: break; sl@0: sl@0: case ETelAudRtngServNotifyIfAvailOutputsChanged: sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingServerSession[%x]::ServiceL - ETelAudRtngServNotifyIfAvailOutputsChanged "),this); sl@0: NotifyIfAvailOutputsChangedL(aMessage); sl@0: break; sl@0: sl@0: case ETelAudRtngServGetNoOutputs: sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingServerSession[%x]::ServiceL - ETelAudRtngServGetNoOutputs "),this); sl@0: GetNoOfAvailableOutputs(aMessage); sl@0: break; sl@0: sl@0: case ETelAudRtngServGetAvailableOutputs: sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingServerSession[%x]::ServiceL - ETelAudRtngServGetAvailableOutputs "),this); sl@0: GetAvailableOutputsL(aMessage); sl@0: break; sl@0: sl@0: case ETelAudRtngServMonitorOutputChange: sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingServerSession[%x]::ServiceL - ETelAudRtngServMonitorOutputChange "),this); sl@0: MonitorOutputChangeL(aMessage); sl@0: break; sl@0: sl@0: case ETelAudRtngServSetPolicySessionId: sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingServerSession[%x]::ServiceL - ETelAudRtngServSetPolicySessionId "),this); sl@0: SetPolicySessionId(aMessage); sl@0: break; sl@0: sl@0: case ETelAudRtngServOutputChangeComplete: sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingServerSession[%x]::ServiceL - ETelAudRtngServOutputChangeComplete "),this); sl@0: OutputChangeCompleteL(aMessage); sl@0: break; sl@0: sl@0: case ETelAudRtngDoAvailableOutputsChanged: sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingServerSession[%x]::ServiceL - ETelAudRtngDoAvailableOutputsChanged "),this); sl@0: DoAvailableOutputsChangedL(aMessage); sl@0: break; sl@0: sl@0: case ETelAudRtngServCancelRequest: sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingServerSession[%x]::ServiceL - ETelAudRtngServCancelRequest "),this); sl@0: CancelRequestL(aMessage); sl@0: break; sl@0: sl@0: case ETelAudRtngServInitialize: sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingServerSession[%x]::ServiceL - ETelAudRtngServInitialize "),this); sl@0: InitializeL(aMessage); sl@0: break; sl@0: sl@0: case ETelAudRtngServOutputChangedByPolicy: sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingServerSession[%x]::ServiceL - ETelAudRtngServOutputChangedByPolicy "),this); sl@0: OutputChangedL(aMessage); sl@0: break; sl@0: sl@0: case ETelAudRtngServGetDefaultValues: sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingServerSession[%x]::ServiceL - ETelAudRtngServGetDefaultValues "),this); sl@0: GetDefaultValuesL(aMessage); sl@0: break; sl@0: sl@0: default: sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingServerSession[%x]::ServiceL - default !! "),this); sl@0: PanicClient (aMessage, EPanicIllegalFunction); sl@0: } sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingServerSession[%x]::ServiceL EXIT"), this); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CTelephonyAudioRoutingServerSession::InitializeL sl@0: // Session initialization. sl@0: // (other items were commented in a header). sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: void CTelephonyAudioRoutingServerSession::InitializeL( sl@0: const RMessage2& aMessage) sl@0: { sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingServerSession[%x]::IntitializeL enter"),this); sl@0: iConnected = ETrue; sl@0: Server().AddSession(); sl@0: aMessage.Complete(KErrNone); sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingServerSession[%x]::IntitializeL exit"),this); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CTelephonyAudioRoutingServerSession::CancelRequestL sl@0: // Cancel the outstanding request. sl@0: // (other items were commented in a header). sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: void CTelephonyAudioRoutingServerSession::CancelRequestL( sl@0: const RMessage2& aMessage) sl@0: { sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingServerSession[%x]::CancelRequestL"),this); sl@0: TTelAudRtngServRqst req; sl@0: req = (TTelAudRtngServRqst) aMessage.Int1(); sl@0: TPckgBuf count; sl@0: aMessage.ReadL( 0, count); sl@0: req = (TTelAudRtngServRqst)count(); sl@0: aMessage.Complete(KErrNone); sl@0: TInt messageCount = iMessageArray.Count(); sl@0: TInt messageIndex = 0; sl@0: sl@0: if(messageCount > 0) sl@0: { sl@0: for(TInt i=0;i< messageCount; i++) sl@0: { sl@0: if(iMessageArray[i].Function()== req) sl@0: { sl@0: messageIndex=i; sl@0: break; sl@0: } sl@0: sl@0: } sl@0: iMessageArray[messageIndex].Complete(KErrCancel); sl@0: iMessageArray.Remove(messageIndex); sl@0: } sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CTelephonyAudioRoutingServerSession::DoSetOutputL sl@0: // Send a request to audio policy to set audio output. sl@0: // (other items were commented in a header). sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: void CTelephonyAudioRoutingServerSession::DoSetOutputL ( sl@0: const RMessage2& aMessage) sl@0: { sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingServerSession[%x]::DoSetOutputL "),this); sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t Appending aMessage to iMessageArray. Current count = %d "),iMessageArray.Count()); sl@0: iMessageArray.AppendL(aMessage); sl@0: Server().DoSetOutputL(iSessionId,aMessage); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CTelephonyAudioRoutingServerSession::NotifyIfOutputChangedL sl@0: // Add a message to message queue. Complete the message when output changes sl@0: // (other items were commented in a header). sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: void CTelephonyAudioRoutingServerSession::NotifyIfOutputChangedL ( sl@0: const RMessage2& aMessage) sl@0: { sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingServerSession[%x]::NotifyIfOutputChangedL "),this); sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t Appending aMessage to iMessageArray. Current count = %d "),iMessageArray.Count()); sl@0: iMessageArray.AppendL(aMessage); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CTelephonyAudioRoutingServerSession::NotifyIfAvailOutputsChangedL sl@0: // Add a message to message queue. Complete the message when available audio sl@0: // outputs change sl@0: // (other items were commented in a header). sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: void CTelephonyAudioRoutingServerSession::NotifyIfAvailOutputsChangedL ( sl@0: const RMessage2& aMessage) sl@0: { sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingServerSession[%x]::NotifyIfAvailOutputsChangedL "),this); sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t Appending aMessage to iMessageArray. Current count = %d "),iMessageArray.Count()); sl@0: iMessageArray.AppendL(aMessage); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CTelephonyAudioRoutingServerSession::SetPolicySessionId sl@0: // Set the policy session Id. sl@0: // (other items were commented in a header). sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: void CTelephonyAudioRoutingServerSession::SetPolicySessionId( sl@0: const RMessage2& aMessage) sl@0: { sl@0: if(!iPolicyFlag) sl@0: { sl@0: Server().SetPolicySessionId(iSessionId); sl@0: iPolicyFlag = ETrue; sl@0: } sl@0: sl@0: aMessage.Complete(KErrNone); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CTelephonyAudioRoutingServerSession::OutputChangeCompleteL sl@0: // Used by policy session to indicate that the SetOutput request is complete. sl@0: // (other items were commented in a header). sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: void CTelephonyAudioRoutingServerSession::OutputChangeCompleteL( sl@0: const RMessage2& aMessage) sl@0: { sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingServerSession[%x]::OutputChangeCompleteL "),this); sl@0: TPckgBuf xPackage; sl@0: aMessage.ReadL( 0, xPackage); sl@0: CTelephonyAudioRouting::TAudioOutput audioOutput = xPackage(); sl@0: sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingServerSession::OutputChangeComplete: AudioOutput = %d"), audioOutput); sl@0: sl@0: TPckgBuf errPkg; sl@0: aMessage.ReadL(1, errPkg); sl@0: TInt err = errPkg(); sl@0: sl@0: if (Server().CurrentAudioOutput() != CTelephonyAudioRouting::ENone) sl@0: { sl@0: Server().PreviousAudioOutput() = Server().CurrentAudioOutput(); sl@0: sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingServerSession::OutputChangeComplete: iPreviousAudioOutput set to: %d"), Server().PreviousAudioOutput()); sl@0: } sl@0: sl@0: Server().CurrentAudioOutput() = audioOutput; sl@0: sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingServerSession::OutputChangeCompleteL: Server will be sent audioOutput = %d"), audioOutput); sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingServerSession::OutputChangeCompleteL: previousAudioOutput = %d"), Server().PreviousAudioOutput()); sl@0: aMessage.Complete(KErrNone); sl@0: Server().SetOutputCompleteL(audioOutput, err); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CTelephonyAudioRoutingServerSession::MonitorOutputChangeL sl@0: // Used by policy session to listen to any SetOutput request from other sessions. sl@0: // (other items were commented in a header). sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: void CTelephonyAudioRoutingServerSession::MonitorOutputChangeL ( sl@0: const RMessage2& aMessage) sl@0: { sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingServerSession[%x]::MonitorOutputChangeL "),this); sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t Appending aMessage to iMessageArray. Current count = %d "),iMessageArray.Count()); sl@0: sl@0: TRAPD(err, iMessageArray.AppendL(aMessage)); sl@0: if (err != KErrNone) sl@0: { sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t MonitorOutputChangeL ERROR: %d "),err); sl@0: PanicClient (aMessage, EPanicIllegalFunction); sl@0: } sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CTelephonyAudioRoutingServerSession::GetNoOfAvailableOutputs sl@0: // Returns the number of available outputs to client-side session. sl@0: // (other items were commented in a header). sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: void CTelephonyAudioRoutingServerSession::GetNoOfAvailableOutputs ( sl@0: const RMessage2& aMessage) sl@0: { sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingServerSession[%x]::GetNoOfAvailableOutputs"),this); sl@0: TPckgBuf xPackage; sl@0: xPackage() = (Server().AvailableOutputs()).Count(); sl@0: sl@0: TInt res = aMessage.Write(0, xPackage); sl@0: if (res != KErrNone) sl@0: { sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t GetNoOfAvailableOutputs WRITE ERROR: %d"),res); sl@0: PanicClient(aMessage, EPanicIllegalFunction); sl@0: } sl@0: sl@0: else sl@0: aMessage.Complete(KErrNone); sl@0: sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CTelephonyAudioRoutingServerSession::GetAvailableOutputsL sl@0: // Returns the available audio outputs to client-side session. sl@0: // (other items were commented in a header). sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: void CTelephonyAudioRoutingServerSession::GetAvailableOutputsL ( sl@0: const RMessage2& aMessage) sl@0: { sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingServerSession[%x]::GetAvailableOutputsL "),this); sl@0: TInt KBufExpandSize8 = 8;//two TInts sl@0: CBufFlat* dataCopyBuffer = CBufFlat::NewL(KBufExpandSize8); sl@0: CleanupStack::PushL(dataCopyBuffer); sl@0: RBufWriteStream stream; sl@0: stream.Open(*dataCopyBuffer); sl@0: CleanupClosePushL(stream); sl@0: sl@0: // Write out server's available outputs to caller: sl@0: CTelephonyAudioRouting::TAudioOutput output; sl@0: TInt count = (Server().AvailableOutputs()).Count(); sl@0: for (TInt i=0;iPtr(0)); sl@0: stream.Close(); sl@0: CleanupStack::PopAndDestroy(2); // dataCopyBuffer, stream sl@0: sl@0: aMessage.Complete(KErrNone); sl@0: sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CTelephonyAudioRoutingServerSession::DoAvailableOutputsChangedL sl@0: // Notify the client-side session that available outputs have changed. sl@0: // (other items were commented in a header). sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: void CTelephonyAudioRoutingServerSession::DoAvailableOutputsChangedL ( sl@0: const RMessage2& aMessage) sl@0: { sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingServerSession[%x]::DoAvailableOutputsChangedL"),this); sl@0: TInt err(KErrNone); sl@0: TBool validData(ETrue); sl@0: TPckgBuf count; sl@0: TRAP(err,aMessage.ReadL( 0, count)); sl@0: if (err != KErrNone) sl@0: { sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t DoAvailableOutputsChangedL(1) ERROR: %d "),err); sl@0: PanicClient (aMessage, EPanicIllegalFunction); sl@0: return; sl@0: } sl@0: sl@0: if ((count() <0) || (count() > KMaxNumberOfOutputs)) sl@0: { sl@0: validData = EFalse; sl@0: iSessionAvailableOutputs.Reset(); sl@0: } sl@0: sl@0: if (validData) sl@0: { sl@0: HBufC8* buf = HBufC8::NewLC(count()*sizeof(CTelephonyAudioRouting::TAudioOutput)); sl@0: TPtr8 ptr = buf->Des(); sl@0: sl@0: TRAP(err,aMessage.ReadL(1, ptr )); sl@0: if (err != KErrNone) sl@0: { sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t DoAvailableOutputsChangedL(2) ERROR: %d "),err); sl@0: PanicClient (aMessage, EPanicIllegalFunction); sl@0: return; sl@0: } sl@0: sl@0: RDesReadStream stream(ptr); sl@0: CleanupClosePushL(stream); sl@0: iSessionAvailableOutputs.Reset(); sl@0: TInt element(0); sl@0: sl@0: for (TInt i=0; i xPackage; sl@0: xPackage() = aOutput; sl@0: sl@0: sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingServerSession::SetOutputComplete: iPreviousAudioOutput Write out: %d"), Server().PreviousAudioOutput()); sl@0: sl@0: TPckgBuf yPackage; sl@0: yPackage() = Server().PreviousAudioOutput(); sl@0: sl@0: TPckgBuf errorPackage; sl@0: errorPackage() = aError; sl@0: sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingServerSession::SetOutputComplete: ShowNote Val to pass to client: %d"), aShowNote); sl@0: TPckgBuf showNotePackage; sl@0: showNotePackage() = aShowNote; sl@0: sl@0: TInt messageCount = iMessageArray.Count(); sl@0: TInt messageIndex = -1; sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t iMessageArrayCount = %d "),iMessageArray.Count()); sl@0: sl@0: for(TInt i=0;i< messageCount; i++) sl@0: { sl@0: if(iMessageArray[i].Function()== ETelAudRtngServDoSetOutput) sl@0: { sl@0: messageIndex = i; sl@0: break; sl@0: } sl@0: } sl@0: sl@0: if (messageIndex != -1) sl@0: { sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t Current Index = %d "), messageIndex); sl@0: sl@0: TInt res = iMessageArray[messageIndex].Write(0, xPackage); sl@0: TInt res2 = iMessageArray[messageIndex].Write(1, yPackage); sl@0: TInt res3 = iMessageArray[messageIndex].Write(2, errorPackage); sl@0: TInt res4 = iMessageArray[messageIndex].Write(3, showNotePackage); sl@0: sl@0: if ( (res != KErrNone) || (res2 != KErrNone) || (res3 != KErrNone) || (res4 != KErrNone)) sl@0: { sl@0: PanicClient(iMessageArray[messageIndex], EPanicIllegalFunction); sl@0: } sl@0: else sl@0: { sl@0: iMessageArray[messageIndex].Complete(ETelAudRtngServSetOutputComplete); sl@0: iMessageArray.Remove(messageIndex); sl@0: } sl@0: } sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CTelephonyAudioRoutingServerSession::OutputChangeRequested sl@0: // Notification that client is requesting to change audio output sl@0: // (other items were commented in a header). sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: void CTelephonyAudioRoutingServerSession::OutputChangeRequested( sl@0: CTelephonyAudioRouting::TAudioOutput aOutput) sl@0: { sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingServerSession[%x]::OutputChangeRequested"),this); sl@0: sl@0: TPckgBuf xPackage; sl@0: xPackage() = aOutput; sl@0: sl@0: TInt messageCount = iMessageArray.Count(); sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t iMessageArrayCount = %d "),iMessageArray.Count()); sl@0: sl@0: TInt messageIndex = -1; sl@0: sl@0: for(TInt i=0;i< messageCount; i++) sl@0: { sl@0: if(iMessageArray[i].Function()== ETelAudRtngServNotifyIfOutputChanged && !iPolicyFlag) sl@0: { sl@0: messageIndex=i; sl@0: break; sl@0: } sl@0: sl@0: if(iMessageArray[i].Function()== ETelAudRtngServMonitorOutputChange && iPolicyFlag) sl@0: { sl@0: messageIndex=i; sl@0: break; sl@0: } sl@0: } sl@0: sl@0: if (messageIndex != -1) // Don't perform if message not found sl@0: { sl@0: TInt res = iMessageArray[messageIndex].Write(0, xPackage); sl@0: if (res != KErrNone) sl@0: { sl@0: PanicClient(iMessageArray[messageIndex], EPanicIllegalFunction); sl@0: } sl@0: sl@0: else sl@0: { sl@0: iMessageArray[messageIndex].Complete(ETelAudRtngServOutputChangeRequested); sl@0: iMessageArray.Remove(messageIndex); sl@0: } sl@0: } sl@0: #ifdef _DEBUG sl@0: else sl@0: { sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingServerSession[%x]::OutputChangeRequested: ServerSession NOT Handling this msg! "),this); sl@0: } sl@0: #endif sl@0: sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CTelephonyAudioRoutingServerSession::OutputChangedL sl@0: // Telephony Audio Routing Manager uses to notify TAR that policy has initiated an output change. sl@0: // (other items were commented in a header). sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: void CTelephonyAudioRoutingServerSession::OutputChangedL( sl@0: const RMessage2& aMessage) sl@0: { sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingServerSession[%x]::OutputChangedL Enter"),this); sl@0: sl@0: TPckgBuf xPackage; sl@0: sl@0: aMessage.ReadL( 0, xPackage); sl@0: CTelephonyAudioRouting::TAudioOutput audioOutput = xPackage(); sl@0: sl@0: Server().PreviousAudioOutput() = Server().CurrentAudioOutput(); sl@0: sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingServerSession::OutputChangedL: iCurrentAudioOutput was: %d"), Server().CurrentAudioOutput()); sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingServerSession::OutputChangedL: iPreviousAudioOutput set to: %d"), Server().PreviousAudioOutput()); sl@0: sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingServerSession::OutputChangedL: iCurrentAudioOutput set to: %d"), audioOutput); sl@0: Server().CurrentAudioOutput() = audioOutput; sl@0: Server().SetShowNoteMode(ETrue); // Always set if output changes initiated by adaptation sl@0: sl@0: aMessage.Complete(KErrNone); sl@0: sl@0: // Server needs to send notification of output change to clients sl@0: Server().OutputChanged(audioOutput); sl@0: sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingServerSession[%x]::OutputChangedL Exit"),this); sl@0: sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CTelephonyAudioRoutingServerSession::OutputChanged sl@0: // Notification to be sent to all clients about the change of audio output. sl@0: // (other items were commented in a header). sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: void CTelephonyAudioRoutingServerSession::OutputChanged( sl@0: CTelephonyAudioRouting::TAudioOutput aOutput, sl@0: TBool aShowNote) sl@0: { sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingServerSession[%x]::OutputChanged"), this); sl@0: sl@0: TPckgBuf xPackage; sl@0: TPckgBuf yPackage; sl@0: sl@0: TPckgBuf errorPackage; sl@0: errorPackage() = KErrNone; sl@0: sl@0: TPckgBuf zPackage; sl@0: sl@0: xPackage() = aOutput; sl@0: sl@0: // Provide client with previous output value: sl@0: CTelephonyAudioRouting::TAudioOutput prevOutput = Server().PreviousAudioOutput(); sl@0: yPackage() = prevOutput; sl@0: sl@0: // Provide client with showNote: sl@0: zPackage() = aShowNote; sl@0: sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingServerSession::OutputChanged Current output: %d"), aOutput); sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingServerSession::OutputChanged Previous output: %d"), yPackage()); sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingServerSession::OutputChanged aShowNote: %d"), zPackage()); sl@0: sl@0: TInt messageCount = iMessageArray.Count(); sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t iMessageArrayCount = %d "),iMessageArray.Count()); sl@0: sl@0: TInt messageIndex = -1; sl@0: sl@0: for(TInt i=0;i< messageCount; i++) sl@0: { sl@0: if(iMessageArray[i].Function()== ETelAudRtngServNotifyIfOutputChanged) sl@0: { sl@0: messageIndex = i; sl@0: break; sl@0: } sl@0: } sl@0: sl@0: if (messageIndex != -1) sl@0: { sl@0: TInt res = iMessageArray[messageIndex].Write(0, xPackage); sl@0: TInt res2 = iMessageArray[messageIndex].Write(1, yPackage); sl@0: TInt res3 = iMessageArray[messageIndex].Write(2, errorPackage); sl@0: TInt res4 = iMessageArray[messageIndex].Write(3, zPackage); sl@0: sl@0: if ( (res != KErrNone) || (res2 != KErrNone) || (res3 != KErrNone) || (res3 != KErrNone) ) sl@0: { sl@0: PanicClient(iMessageArray[messageIndex], EPanicIllegalFunction); sl@0: } sl@0: sl@0: else sl@0: { sl@0: iMessageArray[messageIndex].Complete(ETelAudRtngServOutputChanged); sl@0: iMessageArray.Remove(messageIndex); sl@0: } sl@0: } sl@0: #ifdef _DEBUG sl@0: else sl@0: { sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingServerSession[%x]::OutputChanged: ServerSession NOT Handling this msg! "),this); sl@0: } sl@0: #endif sl@0: sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingServerSession[%x]::OutputChanged Exit"), this); sl@0: } sl@0: // ----------------------------------------------------------------------------- sl@0: // CTelephonyAudioRoutingServerSession::AvailableOutputsChanged sl@0: // Notifies the client-side session that available audio outputs have changed. sl@0: // (other items were commented in a header). sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: void CTelephonyAudioRoutingServerSession::AvailableOutputsChanged( sl@0: const TArray& aOutputs) sl@0: { sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingServerSession[%x]::AvailableOutputsChanged Enter "),this); sl@0: TInt count = aOutputs.Count(); sl@0: iSessionAvailableOutputs.Reset(); sl@0: sl@0: for(TInt i=0;i defaultParamsPkg; sl@0: defaultParamsPkg() = defaultParams; sl@0: aMessage.WriteL(0, defaultParamsPkg); sl@0: aMessage.Complete(KErrNone); sl@0: sl@0: } sl@0: sl@0: sl@0: // End of file.