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: Active object for each asynchronous request in RTelephonyAudioRoutingSession. sl@0: * Notifies MTelephonyAudioObserver upon request completion. sl@0: * sl@0: */ sl@0: sl@0: sl@0: sl@0: sl@0: // INCLUDE FILES sl@0: #include "TelephonyAudioRoutingRequest.h" sl@0: #include "MTelephonyAudioRoutingObserver.h" sl@0: #include "TelephonyAudioRoutingClientServer.h" sl@0: sl@0: // ============================ MEMBER FUNCTIONS =============================== sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CTelephonyAudioRoutingRequest::CTelephonyAudioRoutingRequest sl@0: // C++ default constructor can NOT contain any code, that sl@0: // might leave. sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: CTelephonyAudioRoutingRequest::CTelephonyAudioRoutingRequest( sl@0: RTelephonyAudioRoutingSession& aSession, sl@0: MTelephonyAudioRoutingObserver& aObserver, sl@0: CTelephonyAudioRouting& aAudioRouting, sl@0: TTelAudRtngServRqst aRequest ) sl@0: : CActive(EPriorityStandard), sl@0: iSession(aSession), sl@0: iObserver(aObserver), sl@0: iAudioRouting(aAudioRouting), sl@0: iRequestOpcode(aRequest) sl@0: { sl@0: sl@0: } sl@0: sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CTelephonyAudioRoutingRequest::ConstructL sl@0: // Symbian 2nd phase constructor can leave. sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: void CTelephonyAudioRoutingRequest::ConstructL() sl@0: { sl@0: TELAUDRTNG_RDEBUG(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingRequest::ConstructL")); sl@0: CActiveScheduler::Add(this); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CTelephonyAudioRoutingRequest::NewL sl@0: // Two-phased constructor. sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: CTelephonyAudioRoutingRequest* CTelephonyAudioRoutingRequest::NewL( sl@0: RTelephonyAudioRoutingSession& aSession, sl@0: MTelephonyAudioRoutingObserver& aObserver, sl@0: CTelephonyAudioRouting& aAudioRouting, sl@0: TTelAudRtngServRqst aRequest ) sl@0: { sl@0: CTelephonyAudioRoutingRequest* self = new( ELeave ) CTelephonyAudioRoutingRequest(aSession, aObserver, aAudioRouting, aRequest); sl@0: CleanupStack::PushL( self ); sl@0: self->ConstructL(); sl@0: CleanupStack::Pop(); sl@0: return self; sl@0: } sl@0: sl@0: // Destructor sl@0: CTelephonyAudioRoutingRequest::~CTelephonyAudioRoutingRequest() sl@0: { sl@0: TELAUDRTNG_RDEBUG(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingRequest::~CTelephonyAudioRoutingRequest")); sl@0: sl@0: Cancel(); sl@0: sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CTelephonyAudioRoutingRequest::DoCancel sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: void CTelephonyAudioRoutingRequest::DoCancel() sl@0: { sl@0: iSession.CancelRequest(iRequestOpcode); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CTelephonyAudioRoutingRequest::RunL sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: void CTelephonyAudioRoutingRequest::RunL() sl@0: { sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingRequest::RunL with: %d"), iStatus.Int()); sl@0: sl@0: TPckgBuf errPkgBuf; sl@0: TInt error = KErrNone; sl@0: sl@0: switch( iStatus.Int() ) sl@0: { sl@0: case ETelAudRtngServSetOutputComplete: sl@0: { sl@0: TELAUDRTNG_RDEBUG(_L("[TELAUDRTNG]\t RunL: Handling SetOutputComplete")); sl@0: errPkgBuf = iSession.ErrPkg(); sl@0: error = errPkgBuf(); sl@0: if (error != KErrNone) sl@0: { sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingRequest: SetOutput Completed with an ERROR: %d"),error); sl@0: iSession.ResetShowNoteMode(); // don't allow retrieval if errored sl@0: } sl@0: else // Set iSession's showNoteMode if there's no error sl@0: { sl@0: iSession.SetShowNoteMode(); sl@0: } sl@0: sl@0: TELAUDRTNG_RDEBUG(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingRequest: Will Call Observer's SetOutputComplete...")); sl@0: iObserver.SetOutputComplete(iAudioRouting, error ); sl@0: } sl@0: break; sl@0: sl@0: case ETelAudRtngServOutputChanged: sl@0: { sl@0: TELAUDRTNG_RDEBUG(_L("[TELAUDRTNG]\t RunL: Handling OutputChanged")); sl@0: iSession.SetShowNoteMode(); // Set flag any time adaptation initiates output change sl@0: sl@0: TELAUDRTNG_RDEBUG(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingRequest: Call Observer's OutputChanged...")); sl@0: iSession.NotifyIfOutputChanged(); sl@0: iObserver.OutputChanged(iAudioRouting); sl@0: } sl@0: break; sl@0: sl@0: case ETelAudRtngServAvailableOutputsChanged: sl@0: { sl@0: TELAUDRTNG_RDEBUG(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingRequest: Call Observer's AvailableOutputsChanged...")); sl@0: iSession.NotifyIfAvailableOutputsChanged(); sl@0: iObserver.AvailableOutputsChanged(iAudioRouting); sl@0: } sl@0: break; sl@0: sl@0: case KErrPermissionDenied: sl@0: { sl@0: TELAUDRTNG_RDEBUG(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingRequest: ERROR: Permission Denied...")); sl@0: iObserver.SetOutputComplete(iAudioRouting, KErrPermissionDenied ); sl@0: // User::Leave(KErrPermissionDenied); sl@0: } sl@0: break; sl@0: sl@0: case KErrCancel: sl@0: TELAUDRTNG_RDEBUG(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingRequest: KErrCancel")); sl@0: iObserver.SetOutputComplete(iAudioRouting, KErrCancel ); sl@0: break; sl@0: sl@0: default: sl@0: { sl@0: TELAUDRTNG_RDEBUG(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingRequest::RunL: Default - Error Case!! ")); sl@0: User::Panic(_L("TelephonyAudioRouting"), KErrGeneral ); sl@0: break; sl@0: } sl@0: } sl@0: } sl@0: sl@0: // End of File sl@0: