os/mm/devsoundextensions/telephonyaudiorouting/Session/src/TelephonyAudioRoutingRequest.cpp
First public contribution.
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: Active object for each asynchronous request in RTelephonyAudioRoutingSession.
15 * Notifies MTelephonyAudioObserver upon request completion.
23 #include "TelephonyAudioRoutingRequest.h"
24 #include "MTelephonyAudioRoutingObserver.h"
25 #include "TelephonyAudioRoutingClientServer.h"
27 // ============================ MEMBER FUNCTIONS ===============================
29 // -----------------------------------------------------------------------------
30 // CTelephonyAudioRoutingRequest::CTelephonyAudioRoutingRequest
31 // C++ default constructor can NOT contain any code, that
33 // -----------------------------------------------------------------------------
35 CTelephonyAudioRoutingRequest::CTelephonyAudioRoutingRequest(
36 RTelephonyAudioRoutingSession& aSession,
37 MTelephonyAudioRoutingObserver& aObserver,
38 CTelephonyAudioRouting& aAudioRouting,
39 TTelAudRtngServRqst aRequest )
40 : CActive(EPriorityStandard),
43 iAudioRouting(aAudioRouting),
44 iRequestOpcode(aRequest)
50 // -----------------------------------------------------------------------------
51 // CTelephonyAudioRoutingRequest::ConstructL
52 // Symbian 2nd phase constructor can leave.
53 // -----------------------------------------------------------------------------
55 void CTelephonyAudioRoutingRequest::ConstructL()
57 TELAUDRTNG_RDEBUG(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingRequest::ConstructL"));
58 CActiveScheduler::Add(this);
61 // -----------------------------------------------------------------------------
62 // CTelephonyAudioRoutingRequest::NewL
63 // Two-phased constructor.
64 // -----------------------------------------------------------------------------
66 CTelephonyAudioRoutingRequest* CTelephonyAudioRoutingRequest::NewL(
67 RTelephonyAudioRoutingSession& aSession,
68 MTelephonyAudioRoutingObserver& aObserver,
69 CTelephonyAudioRouting& aAudioRouting,
70 TTelAudRtngServRqst aRequest )
72 CTelephonyAudioRoutingRequest* self = new( ELeave ) CTelephonyAudioRoutingRequest(aSession, aObserver, aAudioRouting, aRequest);
73 CleanupStack::PushL( self );
80 CTelephonyAudioRoutingRequest::~CTelephonyAudioRoutingRequest()
82 TELAUDRTNG_RDEBUG(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingRequest::~CTelephonyAudioRoutingRequest"));
88 // -----------------------------------------------------------------------------
89 // CTelephonyAudioRoutingRequest::DoCancel
90 // -----------------------------------------------------------------------------
92 void CTelephonyAudioRoutingRequest::DoCancel()
94 iSession.CancelRequest(iRequestOpcode);
97 // -----------------------------------------------------------------------------
98 // CTelephonyAudioRoutingRequest::RunL
99 // -----------------------------------------------------------------------------
101 void CTelephonyAudioRoutingRequest::RunL()
103 TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingRequest::RunL with: %d"), iStatus.Int());
105 TPckgBuf<TInt> errPkgBuf;
106 TInt error = KErrNone;
108 switch( iStatus.Int() )
110 case ETelAudRtngServSetOutputComplete:
112 TELAUDRTNG_RDEBUG(_L("[TELAUDRTNG]\t RunL: Handling SetOutputComplete"));
113 errPkgBuf = iSession.ErrPkg();
115 if (error != KErrNone)
117 TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingRequest: SetOutput Completed with an ERROR: %d"),error);
118 iSession.ResetShowNoteMode(); // don't allow retrieval if errored
120 else // Set iSession's showNoteMode if there's no error
122 iSession.SetShowNoteMode();
125 TELAUDRTNG_RDEBUG(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingRequest: Will Call Observer's SetOutputComplete..."));
126 iObserver.SetOutputComplete(iAudioRouting, error );
130 case ETelAudRtngServOutputChanged:
132 TELAUDRTNG_RDEBUG(_L("[TELAUDRTNG]\t RunL: Handling OutputChanged"));
133 iSession.SetShowNoteMode(); // Set flag any time adaptation initiates output change
135 TELAUDRTNG_RDEBUG(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingRequest: Call Observer's OutputChanged..."));
136 iSession.NotifyIfOutputChanged();
137 iObserver.OutputChanged(iAudioRouting);
141 case ETelAudRtngServAvailableOutputsChanged:
143 TELAUDRTNG_RDEBUG(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingRequest: Call Observer's AvailableOutputsChanged..."));
144 iSession.NotifyIfAvailableOutputsChanged();
145 iObserver.AvailableOutputsChanged(iAudioRouting);
149 case KErrPermissionDenied:
151 TELAUDRTNG_RDEBUG(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingRequest: ERROR: Permission Denied..."));
152 iObserver.SetOutputComplete(iAudioRouting, KErrPermissionDenied );
153 // User::Leave(KErrPermissionDenied);
158 TELAUDRTNG_RDEBUG(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingRequest: KErrCancel"));
159 iObserver.SetOutputComplete(iAudioRouting, KErrCancel );
164 TELAUDRTNG_RDEBUG(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingRequest::RunL: Default - Error Case!! "));
165 User::Panic(_L("TelephonyAudioRouting"), KErrGeneral );