phoneapp/phonemediatorcenter/src/cphonemediatorsender.cpp
branchRCL_3
changeset 62 5266b1f337bd
parent 61 41a7f70b3818
equal deleted inserted replaced
61:41a7f70b3818 62:5266b1f337bd
    22 #include "phoneui.hrh"
    22 #include "phoneui.hrh"
    23 #include "cphonemediatorsender.h"
    23 #include "cphonemediatorsender.h"
    24 #include "phonelogger.h"
    24 #include "phonelogger.h"
    25 #include "phoneconstants.h"
    25 #include "phoneconstants.h"
    26 #include "phonemediatorpackagetypes.h"
    26 #include "phonemediatorpackagetypes.h"
       
    27 #include "mphonecoveruiobserver.h"
    27 #include "phoneui.pan"
    28 #include "phoneui.pan"
    28 #include "tphonecmdparamcallheaderdata.h"
    29 #include "tphonecmdparamcallheaderdata.h"
    29 #include "tphonecmdparamboolean.h"
    30 #include "tphonecmdparamboolean.h"
    30 #include "mphoneenginemessagesender.h"
    31 #include "mphoneenginemessagesender.h"
    31 #include "pevirtualengine.h"
    32 #include "pevirtualengine.h"
    46     
    47     
    47     if ( !instance )
    48     if ( !instance )
    48         {
    49         {
    49         TRAPD( err, instance = CPhoneMediatorSender::NewL() );
    50         TRAPD( err, instance = CPhoneMediatorSender::NewL() );
    50         if ( err )
    51         if ( err )
    51             {
    52 	        {
    52             Panic( EPhoneMediatorCenterCouldNotCreateSingleton );   
    53 	        Panic( EPhoneMediatorCenterCouldNotCreateSingleton );	
    53             }
    54 	        }
    54         }
    55         }
    55     return instance;
    56     return instance;
    56     }
    57     }
    57 
    58 
    58 // -----------------------------------------------------------------------------
    59 // -----------------------------------------------------------------------------
    83 void CPhoneMediatorSender::ConstructL()
    84 void CPhoneMediatorSender::ConstructL()
    84     {
    85     {
    85     __LOGMETHODSTARTEND( EPhoneMediatorCenter, "CPhoneMediatorSender::ConstructL( ) ");
    86     __LOGMETHODSTARTEND( EPhoneMediatorCenter, "CPhoneMediatorSender::ConstructL( ) ");
    86     iCommandInitiator = CMediatorCommandInitiator::NewL( this );
    87     iCommandInitiator = CMediatorCommandInitiator::NewL( this );
    87     iEventSender = CMediatorEventProvider::NewL();
    88     iEventSender = CMediatorEventProvider::NewL();
    88     ResetCommandBuffer();
    89 	ResetCommandBuffer();
    89     
    90     
    90     RegisterGenericEvents();        
    91     RegisterGenericEvents();        
    91     }
    92     }
    92 
    93 
    93 // -----------------------------------------------------------
    94 // -----------------------------------------------------------
   111 // -----------------------------------------------------------------------------
   112 // -----------------------------------------------------------------------------
   112 // CPhoneMediatorSender::RegisterGenericEvents
   113 // CPhoneMediatorSender::RegisterGenericEvents
   113 // -----------------------------------------------------------------------------
   114 // -----------------------------------------------------------------------------
   114 //
   115 //
   115 void CPhoneMediatorSender::RegisterGenericEvents()
   116 void CPhoneMediatorSender::RegisterGenericEvents()
   116     {
   117 	{
   117     __LOGMETHODSTARTEND( EPhoneMediatorCenter, "CPhoneMediatorSender::RegisterGenericEvents( ) ");
   118     __LOGMETHODSTARTEND( EPhoneMediatorCenter, "CPhoneMediatorSender::RegisterGenericEvents( ) ");
   118     TCapabilitySet caps;
   119 	TCapabilitySet caps;
   119     caps.SetEmpty();
   120 	caps.SetEmpty();
   120     
   121 	
   121     MediatorService::TEvent newEvent;
   122 	MediatorService::TEvent newEvent;
   122     newEvent.iEventId = EPhoneEventCallData;
   123 	newEvent.iEventId = EPhoneEventCallData;
   123     newEvent.iVersion = TVersion( KTelephonyEventsVersionMajor,
   124 	newEvent.iVersion = TVersion( KTelephonyEventsVersionMajor,
   124                                   KTelephonyEventsVersionMinor, 
   125                               	  KTelephonyEventsVersionMinor, 
   125                                   KTelephonyEventsVersionBuild );
   126                               	  KTelephonyEventsVersionBuild );
   126     newEvent.iCaps = caps;
   127     newEvent.iCaps = caps;
   127     
   128     
   128     TRAPD( errorCode, iGenericEvents.AppendL( newEvent ));
   129     TRAPD( errorCode, iGenericEvents.AppendL( newEvent ));
   129     if( errorCode == ECCPErrorNone )
   130     if( errorCode == ECCPErrorNone )
   130         {
   131         {
   131         TInt res = iEventSender->RegisterEvent( KMediatorTelephonyDomain,
   132         TInt res = iEventSender->RegisterEvent( KMediatorTelephonyDomain,
   132                                      KCatEventsFromTelephony,
   133                                      KCatEventsFromTelephony,
   133                                      iGenericEvents );  
   134                                      iGenericEvents );  
   134         __ASSERT_DEBUG( !res, Panic( EPhoneMediatorCenterRegistrationFailed ) );
   135         __ASSERT_DEBUG( !res, Panic( EPhoneMediatorCenterRegistrationFailed ) );
   135         }
   136         }
   136     }
   137 	}
   137 
   138 
   138 // -----------------------------------------------------------------------------
   139 // -----------------------------------------------------------------------------
   139 // CPhoneMediatorSender::SendEvent
   140 // CPhoneMediatorSender::SendEvent
   140 // -----------------------------------------------------------------------------
   141 // -----------------------------------------------------------------------------
   141 //
   142 //
   148 // -----------------------------------------------------------------------------
   149 // -----------------------------------------------------------------------------
   149 // CPhoneMediatorSender::SendEvent
   150 // CPhoneMediatorSender::SendEvent
   150 // -----------------------------------------------------------------------------
   151 // -----------------------------------------------------------------------------
   151 //
   152 //
   152 EXPORT_C void CPhoneMediatorSender::SendEvent( const TPhoneViewCommandId aCommandId, 
   153 EXPORT_C void CPhoneMediatorSender::SendEvent( const TPhoneViewCommandId aCommandId, 
   153     const TInt aCallId ) const
   154 	const TInt aCallId ) const
   154     {
   155 	{
   155     switch( aCommandId )
   156 	switch( aCommandId )
   156         {
   157 		{
   157         case EPhoneViewRemoveCallHeader:
   158 		case EPhoneViewRemoveCallHeader:
   158             {
   159 		    {
   159             __PHONELOG1( EBasic, EPhoneMediatorCenter, 
   160             __PHONELOG1( EBasic, EPhoneMediatorCenter, 
   160                 "CPhoneMediatorSender::SendEvent - EPhoneEventCallData iCallId:%d" ,aCallId );
   161                 "CPhoneMediatorSender::SendEvent - EPhoneEventCallData iCallId:%d" ,aCallId );
   161             TTelephonyCallDataParam callDataParam;
   162 			TTelephonyCallDataParam callDataParam;
   162             callDataParam.iCallId = aCallId;
   163 			callDataParam.iCallId = aCallId;
   163             callDataParam.iCallState = ECallStateIdle;
   164 			callDataParam.iCallState = ECallStateIdle;
   164             TTelephonyCallDataParamPackage callDataParamPackage( callDataParam );
   165 			TTelephonyCallDataParamPackage callDataParamPackage( callDataParam );
   165             iEventSender->RaiseEvent( KMediatorTelephonyDomain,
   166 			iEventSender->RaiseEvent( KMediatorTelephonyDomain,
   166                                       KCatEventsFromTelephony,
   167 							          KCatEventsFromTelephony,
   167                                       EPhoneEventCallData,
   168 							          EPhoneEventCallData,
   168                                       TVersion( KTelephonyEventsVersionMajor,
   169                                 	  TVersion( KTelephonyEventsVersionMajor,
   169                                         KTelephonyEventsVersionMinor, 
   170                               	      	KTelephonyEventsVersionMinor, 
   170                                         KTelephonyEventsVersionBuild ),
   171                               	      	KTelephonyEventsVersionBuild ),
   171                                       callDataParamPackage );   
   172                                 	  callDataParamPackage );	
   172             }
   173             }
   173             break;
   174 			break;
   174             
   175 			
   175         default:
   176 		default:
   176             break;
   177 			break;
   177         }
   178 		}
   178     }
   179 	}
   179 
   180 
   180 // -----------------------------------------------------------------------------
   181 // -----------------------------------------------------------------------------
   181 // CPhoneMediatorSender::SendEvent
   182 // CPhoneMediatorSender::SendEvent
   182 // -----------------------------------------------------------------------------
   183 // -----------------------------------------------------------------------------
   183 //
   184 //
   184 EXPORT_C void CPhoneMediatorSender::SendEvent( const TPhoneViewCommandId aCommandId, 
   185 EXPORT_C void CPhoneMediatorSender::SendEvent( const TPhoneViewCommandId aCommandId, 
   185     TPhoneCommandParam& aCommandParam )
   186 	TPhoneCommandParam& aCommandParam )
   186     {
   187 	{
   187     switch( aCommandId )
   188 	switch( aCommandId )
   188         {
   189 	    {
   189         case EPhoneViewActivateMuteUIChanges:
   190 		case EPhoneViewActivateMuteUIChanges:
   190             {
   191             {
   191             TPhoneCmdParamBoolean& booleanParam = static_cast<TPhoneCmdParamBoolean&>( aCommandParam );
   192             TPhoneCmdParamBoolean& booleanParam = static_cast<TPhoneCmdParamBoolean&>( aCommandParam );
   192             const TBool audioMute( booleanParam.Boolean() );
   193             const TBool audioMute( booleanParam.Boolean() );
   193             TInt response = KErrNone;
   194             TInt response = KErrNone;
   194 
   195             TInt command = -1;
   195             TInt command = -1; 
       
   196             if( audioMute )
   196             if( audioMute )
   197                 {
   197                 {
   198                 __PHONELOG( EBasic, EPhoneMediatorCenter, 
   198                 __PHONELOG( EBasic, EPhoneMediatorCenter, 
   199                     "CPhoneMediatorSender::SendEvent - transformed to Mediator Command EVtCmdMute" );
   199                     "CPhoneMediatorSender::SendEvent - transformed to Mediator Command EVtCmdMute" );
   200                 command = EVtCmdMute;
   200                 command = EVtCmdMute;
   201                 response = IssueCommand( KMediatorVideoTelephonyDomain,
   201 			    response = IssueCommand( KMediatorVideoTelephonyDomain,
   202                                          KCatPhoneToVideotelCommands, 
   202 			                  			 KCatPhoneToVideotelCommands, 
   203                                          command,
   203 			                  			 command,
   204                                          TVersion( KPhoneToVideotelCmdVersionMajor,
   204                               			 TVersion( KPhoneToVideotelCmdVersionMajor,
   205                                                    KPhoneToVideotelCmdVersionMinor, 
   205                               	        		   KPhoneToVideotelCmdVersionMinor, 
   206                                                    KPhoneToVideotelCmdVersionBuild ),
   206                               	        		   KPhoneToVideotelCmdVersionBuild ),
   207                                          KNullDesC8 );
   207                               			 KNullDesC8 );
   208                 }
   208                 }
   209             else
   209             else
   210                 {
   210                 {
   211                 __PHONELOG( EBasic, EPhoneMediatorCenter, 
   211                 __PHONELOG( EBasic, EPhoneMediatorCenter, 
   212                     "CPhoneMediatorSender::SendEvent - transformed to Mediator Command EVtCmdUnmute" );
   212                     "CPhoneMediatorSender::SendEvent - transformed to Mediator Command EVtCmdUnmute" );
   213                 command = EVtCmdUnmute;
   213                 command = EVtCmdUnmute;
   214                 response = IssueCommand( KMediatorVideoTelephonyDomain,
   214 			    response = IssueCommand( KMediatorVideoTelephonyDomain,
   215                                          KCatPhoneToVideotelCommands, 
   215 			                  			 KCatPhoneToVideotelCommands, 
   216                                          command,
   216 			                  			 command,
   217                                          TVersion( KPhoneToVideotelCmdVersionMajor,
   217                               			 TVersion( KPhoneToVideotelCmdVersionMajor,
   218                                                    KPhoneToVideotelCmdVersionMinor, 
   218                               	        		   KPhoneToVideotelCmdVersionMinor, 
   219                                                    KPhoneToVideotelCmdVersionBuild ),
   219                               	        		   KPhoneToVideotelCmdVersionBuild ),
   220                                          KNullDesC8 );
   220                               			 KNullDesC8 );
   221                 }
   221                 }
   222                 
   222                 
   223             if( ( response == KErrInUse ) && ( iCommandBuffer.iCommandId == KErrNotFound ) )
   223             if( ( response == KErrInUse ) && ( iCommandBuffer.iCommandId == KErrNotFound ) )
   224                 {
   224 	            {
   225                 // Previous command wasn't handled yet so buffer the last unhandled command.
   225 				// Previous command wasn't handled yet so buffer the last unhandled command.
   226                 // This command will be sent after we get response to the previous command
   226 				// This command will be sent after we get response to the previous command
   227                 iCommandBuffer.iCommandId = command;
   227 				iCommandBuffer.iCommandId = command;
   228                 iCommandBuffer.iDomainUid = KMediatorVideoTelephonyDomain;
   228 				iCommandBuffer.iDomainUid = KMediatorVideoTelephonyDomain;
   229                 iCommandBuffer.iCategoryUid = KCatPhoneToVideotelCommands;
   229 				iCommandBuffer.iCategoryUid = KCatPhoneToVideotelCommands;
   230                 iCommandBuffer.iVersion = TVersion( KPhoneToVideotelCmdVersionMajor,
   230 				iCommandBuffer.iVersion = TVersion( KPhoneToVideotelCmdVersionMajor,
   231                                                     KPhoneToVideotelCmdVersionMinor, 
   231                               	        		    KPhoneToVideotelCmdVersionMinor, 
   232                                                     KPhoneToVideotelCmdVersionBuild );
   232                               	        		    KPhoneToVideotelCmdVersionBuild );
   233                 }
   233 	            }
   234             }
   234             }
   235             break;
   235 			break;
   236             
   236             
   237         default:
   237         default:
   238             break;    
   238             break;    
   239         }   
   239 	    }	
   240     }
   240 	}
   241 
   241 
   242 // -----------------------------------------------------------------------------
   242 // -----------------------------------------------------------------------------
   243 // CPhoneMediatorSender::SendEvent
   243 // CPhoneMediatorSender::SendEvent
   244 // -----------------------------------------------------------------------------
   244 // -----------------------------------------------------------------------------
   245 //
   245 //
   246 EXPORT_C void CPhoneMediatorSender::SendEvent( const TPhoneViewCommandId aCommandId, 
   246 EXPORT_C void CPhoneMediatorSender::SendEvent( const TPhoneViewCommandId aCommandId, 
   247     const TInt aCallId, TPhoneCommandParam& aCommandParam ) const
   247  	const TInt aCallId, TPhoneCommandParam& aCommandParam ) const
   248     {
   248 	{
   249     switch( aCommandId )
   249 	switch( aCommandId )
   250         {
   250 		{
   251         case EPhoneViewCreateCallHeader:
   251 		case EPhoneViewCreateCallHeader:
   252             {
   252             {
   253             TPhoneCmdParamCallHeaderData& callHeaderParam = static_cast<TPhoneCmdParamCallHeaderData&>( aCommandParam );
   253             TPhoneCmdParamCallHeaderData& callHeaderParam = static_cast<TPhoneCmdParamCallHeaderData&>( aCommandParam );
   254             __PHONELOG2( EBasic, EPhoneMediatorCenter, 
   254             __PHONELOG2( EBasic, EPhoneMediatorCenter, 
   255                 "CPhoneMediatorSender::SendEvent - EPhoneEventCallData iCallId:%d iCLIText:%S",
   255                 "CPhoneMediatorSender::SendEvent - EPhoneEventCallData iCallId:%d iCLIText:%S",
   256                 aCallId, &callHeaderParam.CLIText() );
   256                 aCallId, &callHeaderParam.CLIText() );
   257             TTelephonyCallDataParam callDataParam;
   257 			TTelephonyCallDataParam callDataParam;
   258             callDataParam.iCallId = aCallId;
   258 			callDataParam.iCallId = aCallId;
   259             callDataParam.iCLIText = callHeaderParam.CLIText();
   259 			callDataParam.iCLIText = callHeaderParam.CLIText();
   260             callDataParam.iCallState = MapCallState( callHeaderParam.CallState() );
   260 			callDataParam.iCallState = MapCallState( callHeaderParam.CallState() );
   261             callDataParam.iRemotePhoneNumber = callHeaderParam.RemotePhoneNumber();
   261 			callDataParam.iRemotePhoneNumber = callHeaderParam.RemotePhoneNumber();
   262             callDataParam.iCallType = MapCallType( callHeaderParam.CallType() );
   262 			callDataParam.iCallType = MapCallType( callHeaderParam.CallType() );
   263             TTelephonyCallDataParamPackage callDataParamPackage( callDataParam );
   263 			TTelephonyCallDataParamPackage callDataParamPackage( callDataParam );
   264             iEventSender->RaiseEvent( KMediatorTelephonyDomain,
   264 			iEventSender->RaiseEvent( KMediatorTelephonyDomain,
   265                                       KCatEventsFromTelephony,
   265 							          KCatEventsFromTelephony,
   266                                       EPhoneEventCallData,
   266 							          EPhoneEventCallData,
   267                                       TVersion( KTelephonyEventsVersionMajor,
   267                                 	  TVersion( KTelephonyEventsVersionMajor,
   268                                         KTelephonyEventsVersionMinor, 
   268                               	      	KTelephonyEventsVersionMinor, 
   269                                         KTelephonyEventsVersionBuild ),
   269                               	      	KTelephonyEventsVersionBuild ),
   270                                       callDataParamPackage );   
   270                                 	  callDataParamPackage );	
   271             }
   271             }
   272             break;
   272 			break;
   273             
   273 			
   274         default:
   274 		default:
   275             break;
   275 			break;
   276         }
   276 		}
   277     }
   277 	}
   278 
   278 
   279 // -----------------------------------------------------------------------------
   279 // -----------------------------------------------------------------------------
   280 // CPhoneMediatorSender::SendEvent
   280 // CPhoneMediatorSender::SendEvent
   281 // -----------------------------------------------------------------------------
   281 // -----------------------------------------------------------------------------
   282 //
   282 //
   296     MPhoneShutdownCommand* aShutdownCommand  )
   296     MPhoneShutdownCommand* aShutdownCommand  )
   297     {
   297     {
   298     __LOGMETHODSTARTEND( EPhoneMediatorCenter, "CPhoneMediatorSender::IssueCommand( ) ");
   298     __LOGMETHODSTARTEND( EPhoneMediatorCenter, "CPhoneMediatorSender::IssueCommand( ) ");
   299     __PHONELOG3( EBasic, EPhoneMediatorCenter, 
   299     __PHONELOG3( EBasic, EPhoneMediatorCenter, 
   300             "aCommandId = %d, aDomain = %d, aCategory = %d", aCommandId, aDomain, aCategory );
   300             "aCommandId = %d, aDomain = %d, aCategory = %d", aCommandId, aDomain, aCategory );
   301     if( aShutdownCommand )
   301 	if( aShutdownCommand )
   302         {
   302     	{
   303         iShutdownCommand = aShutdownCommand;            
   303         iShutdownCommand = aShutdownCommand;    	    
   304         }
   304     	}
   305 
   305 
   306     return iCommandInitiator->IssueCommand( 
   306 	return iCommandInitiator->IssueCommand( 
   307         aDomain, 
   307 		aDomain, 
   308         aCategory, 
   308 		aCategory, 
   309         aCommandId, 
   309 		aCommandId, 
   310         aVersion, 
   310 		aVersion, 
   311         aData );        
   311         aData );		
   312     }
   312 	}
   313 
   313 
   314 // -----------------------------------------------------------------------------
   314 // -----------------------------------------------------------------------------
   315 // CPhoneMediatorSender::CommandResponseL
   315 // CPhoneMediatorSender::CommandResponseL
   316 // -----------------------------------------------------------------------------
   316 // -----------------------------------------------------------------------------
   317 //
   317 //
   318 void CPhoneMediatorSender::CommandResponseL( TUid aDomain, TUid aCategory, 
   318 void CPhoneMediatorSender::CommandResponseL( TUid aDomain, TUid aCategory, 
   319     TInt aCommandId, TInt /*aStatus*/, const TDesC8& /*aData*/ )
   319 	TInt aCommandId, TInt /*aStatus*/, const TDesC8& /*aData*/ )
   320     {
   320 	{
   321     // First check for buffered command
   321     // First check for buffered command
   322     if( iCommandBuffer.iCommandId != KErrNotFound )
   322 	if( iCommandBuffer.iCommandId != KErrNotFound )
   323         {
   323 		{
   324         // We have a buffered command waiting
   324 		// We have a buffered command waiting
   325         __PHONELOG( EBasic, EPhoneMediatorCenter, 
   325         __PHONELOG( EBasic, EPhoneMediatorCenter, 
   326             "CPhoneMediatorSender::VideoTelephonyCommandResponse - Buffered Command waiting" );
   326             "CPhoneMediatorSender::VideoTelephonyCommandResponse - Buffered Command waiting" );
   327         if( iCommandBuffer.iCommandId != aCommandId )
   327 		if( iCommandBuffer.iCommandId != aCommandId )
   328             {
   328 			{
   329             // And it's not identical to the command which response we now received
   329 			// And it's not identical to the command which response we now received
   330             // so it's necessary to re-send it
   330 			// so it's necessary to re-send it
   331             __PHONELOG1( EBasic, EPhoneMediatorCenter, 
   331 	        __PHONELOG1( EBasic, EPhoneMediatorCenter, 
   332                 "CPhoneMediatorSender::VideoTelephonyCommandResponse - Resending command %d", iCommandBuffer.iCommandId );
   332 	            "CPhoneMediatorSender::VideoTelephonyCommandResponse - Resending command %d", iCommandBuffer.iCommandId );
   333             IssueCommand( iCommandBuffer.iDomainUid,
   333 			IssueCommand( iCommandBuffer.iDomainUid,
   334                           iCommandBuffer.iCategoryUid, 
   334 			              iCommandBuffer.iCategoryUid, 
   335                           iCommandBuffer.iCommandId,
   335 			              iCommandBuffer.iCommandId,
   336                           iCommandBuffer.iVersion,
   336                           iCommandBuffer.iVersion,
   337                           KNullDesC8 );
   337                           KNullDesC8 );
   338                           
   338                           
   339             ResetCommandBuffer();
   339 			ResetCommandBuffer();
   340             }
   340 			}
   341         }
   341 		}
   342 
   342 
   343     if( ( aDomain == KMediatorVideoTelephonyDomain ) &&
   343 	if( ( aDomain == KMediatorVideoTelephonyDomain ) &&
   344         ( aCategory == KCatPhoneToVideotelCommands ) )
   344 	    ( aCategory == KCatPhoneToVideotelCommands ) )
   345         {
   345     	{
   346         VideoTelephonyCommandResponse( aCommandId );        
   346         VideoTelephonyCommandResponse( aCommandId );  	    
   347         }
   347     	}
   348     }
   348 	}
   349 
   349 
   350 // -----------------------------------------------------------------------------
   350 // -----------------------------------------------------------------------------
   351 // CPhoneMediatorSender::VideoTelephonyCommandResponse
   351 // CPhoneMediatorSender::VideoTelephonyCommandResponse
   352 // -----------------------------------------------------------------------------
   352 // -----------------------------------------------------------------------------
   353 //
   353 //
   358         "VideoTelephonyCommandResponse aCommandId = %d", aCommandId );
   358         "VideoTelephonyCommandResponse aCommandId = %d", aCommandId );
   359 
   359 
   360     switch( aCommandId )
   360     switch( aCommandId )
   361         {
   361         {
   362         case EVtCmdReleaseDataport:
   362         case EVtCmdReleaseDataport:
   363             __ASSERT_DEBUG( iShutdownCommand, Panic( EPhoneMediatorCenterParameterNotInitialized ) );
   363 		    __ASSERT_DEBUG( iShutdownCommand, Panic( EPhoneMediatorCenterParameterNotInitialized ) );
   364             TRAP_IGNORE( iShutdownCommand->ExecuteLD());
   364             TRAP_IGNORE( iShutdownCommand->ExecuteLD());
   365             break;
   365             break;
   366             
   366             
   367         default:
   367         default:
   368             break;
   368             break;