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 MTelephonyAudioRoutingPolicyObserver upon request completion. sl@0: * sl@0: */ sl@0: sl@0: sl@0: sl@0: sl@0: // INCLUDE FILES sl@0: #include "TelephonyAudioRoutingPolicyRequest.h" sl@0: #include "MTelephonyAudioRoutingPolicyObserver.h" sl@0: #include "TelephonyAudioRoutingClientServer.h" sl@0: sl@0: sl@0: // ============================ MEMBER FUNCTIONS =============================== sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CTelephonyAudioRoutingPolicyRequest::CTelephonyAudioRoutingPolicyRequest sl@0: // C++ default constructor can NOT contain any code, that sl@0: // might leave. sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: sl@0: CTelephonyAudioRoutingPolicyRequest::CTelephonyAudioRoutingPolicyRequest( sl@0: RTelephonyAudioRoutingManagerSession& aManagerSession, sl@0: MTelephonyAudioRoutingPolicyObserver& aObserver, sl@0: CTelephonyAudioRoutingManager& aAudioRouting, sl@0: TTelAudRtngServRqst aRequest ) sl@0: : CActive(EPriorityStandard), sl@0: iManagerSession(aManagerSession), sl@0: iPolicyObserver(aObserver), sl@0: iAudioRoutingManager(aAudioRouting), sl@0: iRequest(aRequest) sl@0: { sl@0: sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CTelephonyAudioRoutingPolicyRequest::ConstructL sl@0: // Symbian 2nd phase constructor can leave. sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: void CTelephonyAudioRoutingPolicyRequest::ConstructL() sl@0: { sl@0: TELAUDRTNG_RDEBUG(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingPolicyRequest::ConstructL")); sl@0: CActiveScheduler::Add(this); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CTelephonyAudioRoutingPolicyRequest::NewL sl@0: // Two-phased constructor. sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: sl@0: CTelephonyAudioRoutingPolicyRequest* CTelephonyAudioRoutingPolicyRequest::NewL( sl@0: RTelephonyAudioRoutingManagerSession& aManagerSession, sl@0: MTelephonyAudioRoutingPolicyObserver& aObserver, sl@0: CTelephonyAudioRoutingManager& aAudioRouting, sl@0: TTelAudRtngServRqst aRequest ) sl@0: { sl@0: CTelephonyAudioRoutingPolicyRequest* self = new( ELeave ) CTelephonyAudioRoutingPolicyRequest(aManagerSession, 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: CTelephonyAudioRoutingPolicyRequest::~CTelephonyAudioRoutingPolicyRequest() sl@0: { sl@0: TELAUDRTNG_RDEBUG(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingPolicyRequest::~CTelephonyAudioRoutingPolicyRequest")); sl@0: Cancel(); sl@0: sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CTelephonyAudioRoutingPolicyRequest::CompleteRequest sl@0: // This method completes the request status and sets the object active sl@0: // to provide asynchronous behavior. sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: void CTelephonyAudioRoutingPolicyRequest::CompleteRequest( sl@0: TTelAudRtngServRqst aRequest, sl@0: TInt aError ) sl@0: { sl@0: iRequest = aRequest; sl@0: TRequestStatus* stat = &iStatus; sl@0: User::RequestComplete(stat, aError); sl@0: SetActive(); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CTelephonyAudioRoutingPolicyRequest::DoCancel sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: void CTelephonyAudioRoutingPolicyRequest::DoCancel() sl@0: { sl@0: iManagerSession.CancelRequest(iRequest); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CTelephonyAudioRoutingPolicyRequest::RunL sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: void CTelephonyAudioRoutingPolicyRequest::RunL() sl@0: { sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingPolicyRequest::RunL with %d "), iStatus.Int()); sl@0: CTelephonyAudioRouting::TAudioOutput aResponse; sl@0: sl@0: switch( iStatus.Int() ) sl@0: { sl@0: case ETelAudRtngServOutputChangeRequested: sl@0: { sl@0: sl@0: aResponse = (iManagerSession.AudioOutputPkg())(); sl@0: sl@0: sl@0: TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingPolicyRequest::RunL, Calling OutputChangeRequested With: %d "), aResponse); sl@0: iPolicyObserver.OutputChangeRequested(iAudioRoutingManager, aResponse); sl@0: iManagerSession.MonitorOutputChangeRequest(); sl@0: } sl@0: break; sl@0: sl@0: default: sl@0: { 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: