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