devsoundextensions/telephonyaudiorouting/Session/src/TelephonyAudioRoutingRequest.cpp
changeset 0 b8ed18f6c07b
equal deleted inserted replaced
-1:000000000000 0:b8ed18f6c07b
       
     1 /*
       
     2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     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".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:   Active object for each asynchronous request in RTelephonyAudioRoutingSession.
       
    15 *				 Notifies MTelephonyAudioObserver upon request completion.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 // INCLUDE FILES
       
    23 #include "TelephonyAudioRoutingRequest.h"
       
    24 #include "MTelephonyAudioRoutingObserver.h"
       
    25 #include "TelephonyAudioRoutingClientServer.h"
       
    26 
       
    27 // ============================ MEMBER FUNCTIONS ===============================
       
    28 
       
    29 // -----------------------------------------------------------------------------
       
    30 // CTelephonyAudioRoutingRequest::CTelephonyAudioRoutingRequest
       
    31 // C++ default constructor can NOT contain any code, that
       
    32 // might leave.
       
    33 // -----------------------------------------------------------------------------
       
    34 //
       
    35 CTelephonyAudioRoutingRequest::CTelephonyAudioRoutingRequest(
       
    36 	RTelephonyAudioRoutingSession& aSession,
       
    37 	MTelephonyAudioRoutingObserver& aObserver,
       
    38 	CTelephonyAudioRouting& aAudioRouting,
       
    39 	TTelAudRtngServRqst aRequest )
       
    40 	:	CActive(EPriorityStandard),
       
    41 		iSession(aSession),
       
    42 		iObserver(aObserver),
       
    43 		iAudioRouting(aAudioRouting),
       
    44 		iRequestOpcode(aRequest)
       
    45 	{
       
    46 	  
       
    47     }
       
    48     
       
    49 
       
    50 // -----------------------------------------------------------------------------
       
    51 // CTelephonyAudioRoutingRequest::ConstructL
       
    52 // Symbian 2nd phase constructor can leave.
       
    53 // -----------------------------------------------------------------------------
       
    54 //
       
    55 void CTelephonyAudioRoutingRequest::ConstructL()
       
    56     {
       
    57 	TELAUDRTNG_RDEBUG(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingRequest::ConstructL"));    
       
    58 	CActiveScheduler::Add(this);
       
    59     }
       
    60 
       
    61 // -----------------------------------------------------------------------------
       
    62 // CTelephonyAudioRoutingRequest::NewL
       
    63 // Two-phased constructor.
       
    64 // -----------------------------------------------------------------------------
       
    65 //
       
    66 CTelephonyAudioRoutingRequest* CTelephonyAudioRoutingRequest::NewL(
       
    67 	RTelephonyAudioRoutingSession& aSession,
       
    68 	MTelephonyAudioRoutingObserver& aObserver,
       
    69 	CTelephonyAudioRouting& aAudioRouting,
       
    70 	TTelAudRtngServRqst aRequest )
       
    71     {
       
    72 	CTelephonyAudioRoutingRequest* self = new( ELeave ) CTelephonyAudioRoutingRequest(aSession, aObserver, aAudioRouting, aRequest);
       
    73 	CleanupStack::PushL( self );
       
    74 	self->ConstructL();
       
    75 	CleanupStack::Pop();
       
    76 	return self;
       
    77     }
       
    78     
       
    79 // Destructor
       
    80 CTelephonyAudioRoutingRequest::~CTelephonyAudioRoutingRequest()
       
    81     {
       
    82 	TELAUDRTNG_RDEBUG(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingRequest::~CTelephonyAudioRoutingRequest"));       
       
    83 
       
    84 	Cancel();
       
    85 
       
    86     }
       
    87 
       
    88 // -----------------------------------------------------------------------------
       
    89 // CTelephonyAudioRoutingRequest::DoCancel
       
    90 // -----------------------------------------------------------------------------
       
    91 //
       
    92 void CTelephonyAudioRoutingRequest::DoCancel()
       
    93     {
       
    94 	iSession.CancelRequest(iRequestOpcode);
       
    95     }
       
    96 
       
    97 // -----------------------------------------------------------------------------
       
    98 // CTelephonyAudioRoutingRequest::RunL 
       
    99 // -----------------------------------------------------------------------------
       
   100 //
       
   101 void CTelephonyAudioRoutingRequest::RunL()
       
   102     {
       
   103     TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingRequest::RunL with: %d"), iStatus.Int());
       
   104 
       
   105 	TPckgBuf<TInt> errPkgBuf;
       
   106 	TInt error = KErrNone;
       
   107 
       
   108 	switch( iStatus.Int() )
       
   109 	{
       
   110 	case ETelAudRtngServSetOutputComplete:
       
   111 		{
       
   112  		TELAUDRTNG_RDEBUG(_L("[TELAUDRTNG]\t RunL: Handling SetOutputComplete"));		
       
   113     	errPkgBuf = iSession.ErrPkg();
       
   114     	error = errPkgBuf(); 
       
   115     	if (error != KErrNone)
       
   116     	{
       
   117     		TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingRequest: SetOutput Completed with an ERROR: %d"),error); 
       
   118     		iSession.ResetShowNoteMode(); // don't allow retrieval if errored   		
       
   119     	}
       
   120     	else  // Set iSession's showNoteMode if there's no error
       
   121     	{
       
   122     		iSession.SetShowNoteMode();	
       
   123     	}
       
   124     
       
   125        	TELAUDRTNG_RDEBUG(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingRequest: Will Call Observer's SetOutputComplete..."));  			
       
   126  		iObserver.SetOutputComplete(iAudioRouting, error );       
       
   127 		}
       
   128 		break;
       
   129 		
       
   130 	case ETelAudRtngServOutputChanged:
       
   131 		{	
       
   132 		TELAUDRTNG_RDEBUG(_L("[TELAUDRTNG]\t RunL: Handling OutputChanged"));
       
   133     	iSession.SetShowNoteMode(); // Set flag any time adaptation initiates output change
       
   134     			
       
   135 		TELAUDRTNG_RDEBUG(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingRequest: Call Observer's OutputChanged..."));
       
   136     	iSession.NotifyIfOutputChanged();		
       
   137        	iObserver.OutputChanged(iAudioRouting);
       
   138     	}
       
   139 		break;
       
   140 		
       
   141 	case ETelAudRtngServAvailableOutputsChanged:
       
   142 		{
       
   143 		TELAUDRTNG_RDEBUG(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingRequest: Call Observer's AvailableOutputsChanged..."));
       
   144     	iSession.NotifyIfAvailableOutputsChanged();		
       
   145 		iObserver.AvailableOutputsChanged(iAudioRouting);
       
   146 		}
       
   147 		break;
       
   148 		
       
   149 	case KErrPermissionDenied:
       
   150 		{
       
   151 		TELAUDRTNG_RDEBUG(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingRequest: ERROR: Permission Denied..."));
       
   152   		iObserver.SetOutputComplete(iAudioRouting, KErrPermissionDenied );  
       
   153   	//	User::Leave(KErrPermissionDenied);
       
   154 		}
       
   155 		break;
       
   156 								
       
   157 	case KErrCancel:
       
   158     TELAUDRTNG_RDEBUG(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingRequest: KErrCancel"));	
       
   159 		iObserver.SetOutputComplete(iAudioRouting, KErrCancel );      
       
   160 		break;
       
   161 				
       
   162 	default:
       
   163 		{
       
   164 	    TELAUDRTNG_RDEBUG(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingRequest::RunL: Default - Error Case!! "));
       
   165 		User::Panic(_L("TelephonyAudioRouting"), KErrGeneral );
       
   166 		break;
       
   167 		}
       
   168 	}
       
   169     }
       
   170 
       
   171 //  End of File
       
   172