phoneapp/phoneuistates/src/cphonegeneralgsmmessageshandler.cpp
changeset 0 5f000ab63145
child 45 6b911d05207e
child 58 40a3f856b14d
equal deleted inserted replaced
-1:000000000000 0:5f000ab63145
       
     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: Implementation of CPhoneGeneralGsmMessagesHandler class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDES
       
    20 #ifdef __SYNCML_DM
       
    21 #include <apgcli.h>
       
    22 #endif
       
    23 #include <mpeengineinfo.h>
       
    24 #include <UikonInternalPSKeys.h>
       
    25 #include <mccessobserver.h>
       
    26 #include <featmgr.h>
       
    27 #include <StringLoader.h>
       
    28 
       
    29 #include "phoneconstants.h"
       
    30 #include "phonerssbase.h"
       
    31 #include "cphonegeneralgsmmessageshandler.h"
       
    32 #include "phonelogger.h"
       
    33 #include "mphonestatemachine.h"
       
    34 #include "mphoneviewcommandhandle.h"
       
    35 #include "phoneui.pan"
       
    36 #include "cphonepubsubproxy.h"
       
    37 #include "tphonecmdparamboolean.h"
       
    38 #include "tphonecmdparamglobalnote.h"
       
    39 #include "tphonecmdparamnote.h"
       
    40 #include "tphonecmdparamappinfo.h"
       
    41 #include "cphonemainresourceresolver.h"
       
    42 #include "tphonecmdparaminteger.h"
       
    43 
       
    44 
       
    45 // ================= MEMBER FUNCTIONS =======================
       
    46 
       
    47 // C++ default constructor can NOT contain any code, that
       
    48 // might leave.
       
    49 //
       
    50 CPhoneGeneralGsmMessagesHandler::CPhoneGeneralGsmMessagesHandler( 
       
    51     MPhoneStateMachine& aStateMachine, 
       
    52     MPhoneViewCommandHandle& aViewCommandHandle,
       
    53     MPhoneState& aActiveState ) : 
       
    54     iStateMachine( aStateMachine ),
       
    55     iViewCommandHandle( aViewCommandHandle ),
       
    56     iActiveState( aActiveState )
       
    57     {
       
    58     }
       
    59 
       
    60 // -----------------------------------------------------------
       
    61 // CPhoneGeneralGsmMessagesHandler::~CPhoneGeneralGsmMessagesHandler()
       
    62 // Destructor
       
    63 // (other items were commented in a header).
       
    64 // -----------------------------------------------------------
       
    65 
       
    66 CPhoneGeneralGsmMessagesHandler::~CPhoneGeneralGsmMessagesHandler()
       
    67     {
       
    68     }
       
    69 
       
    70 // -----------------------------------------------------------
       
    71 // CPhoneGeneralGsmMessagesHandler::NewL()
       
    72 // Constructor
       
    73 // (other items were commented in a header).
       
    74 // -----------------------------------------------------------
       
    75 //
       
    76 CPhoneGeneralGsmMessagesHandler* CPhoneGeneralGsmMessagesHandler::NewL( 
       
    77     MPhoneStateMachine& aStateMachine, 
       
    78     MPhoneViewCommandHandle& aViewCommandHandle,
       
    79     MPhoneState& aActiveState )
       
    80     {
       
    81     CPhoneGeneralGsmMessagesHandler* self = new( ELeave ) 
       
    82         CPhoneGeneralGsmMessagesHandler( aStateMachine, 
       
    83                                          aViewCommandHandle,
       
    84                                          aActiveState );
       
    85     
       
    86     return self;
       
    87     }
       
    88 
       
    89 // -----------------------------------------------------------
       
    90 // CPhoneGeneralGsmMessagesHandler::HandlePhoneEngineMessageL
       
    91 // -----------------------------------------------------------
       
    92 //
       
    93 void CPhoneGeneralGsmMessagesHandler::HandlePhoneEngineMessageL( 
       
    94     const TInt aMessage, 
       
    95     TInt /*aCallId*/ )
       
    96     {
       
    97     __LOGMETHODSTARTEND( EPhoneUIStates, 
       
    98         "CPhoneGeneralGsmMessagesHandler::HandlePhoneEngineMessageL()" );
       
    99 
       
   100     switch ( aMessage )
       
   101         {
       
   102         case MEngineMonitor::EPEMessageCallBarred:
       
   103             SendGlobalInfoNoteL( EPhoneActiveBarrings );
       
   104             break;
       
   105         
       
   106         case MEngineMonitor::EPEMessageIncCallIsForw:
       
   107             HandleIncomingCallForwardedL();
       
   108             break;
       
   109             
       
   110         case MEngineMonitor::EPEMessageIncCallForwToC:
       
   111             SendGlobalInfoNoteL( EPhoneMtCallDiverting );
       
   112             break;
       
   113             
       
   114         case MEngineMonitor::EPEMessageOutCallForwToC:
       
   115             SendGlobalInfoNoteL( EPhoneDiverting );
       
   116             break;
       
   117 
       
   118         case MEngineMonitor::EPEMessageShowVersion:
       
   119             HandleShowVersionL();
       
   120             break;
       
   121             
       
   122         case MEngineMonitor::EPEMessageIssuedSSRequest:
       
   123             {
       
   124             __PHONELOG(
       
   125                 EBasic, 
       
   126                 EPhoneUIStates,
       
   127                 "CPhoneGeneralGsmMessagesHandler::EPEMessageIssuedSSRequest" );
       
   128 
       
   129             TPhoneCmdParamBoolean booleanParam;
       
   130             booleanParam.SetBoolean( EFalse );
       
   131             iViewCommandHandle.ExecuteCommandL( 
       
   132                 EPhoneViewSetBlockingDialogStatus, 
       
   133                 &booleanParam );
       
   134             break;
       
   135             }
       
   136             
       
   137         case MEngineMonitor::EPEMessageIssuingSSRequest:
       
   138             {
       
   139             __PHONELOG(
       
   140                 EBasic, 
       
   141                 EPhoneUIStates,
       
   142                 "CPhoneGeneralGsmMessagesHandler::EPEMessageIssuingSSRequest" );
       
   143                     
       
   144             iStateMachine.SendPhoneEngineMessage( MPEPhoneModel::EPEMessageEndDTMF );
       
   145              
       
   146             // Remove number entry from screen
       
   147             if ( !FeatureManager::FeatureSupported( KFeatureIdOnScreenDialer ) &&
       
   148                  iViewCommandHandle.HandleCommandL( 
       
   149                      EPhoneViewGetNumberEntryIsVisibleStatus ) == 
       
   150                      EPhoneViewResponseSuccess )  
       
   151                 {            
       
   152                 iViewCommandHandle.ExecuteCommandL( 
       
   153                     EPhoneViewRemoveNumberEntry );
       
   154                 }
       
   155             else if ( FeatureManager::FeatureSupported( KFeatureIdOnScreenDialer ) )
       
   156                 {
       
   157                 iViewCommandHandle.ExecuteCommandL( 
       
   158                     EPhoneViewClearNumberEntryContent );
       
   159                 }
       
   160 
       
   161             // Enable global notes
       
   162             TPhoneCmdParamBoolean globalNotifierParam;
       
   163             globalNotifierParam.SetBoolean( EFalse );
       
   164             iViewCommandHandle.ExecuteCommandL( 
       
   165                 EPhoneViewSetGlobalNotifiersDisabled,
       
   166                 &globalNotifierParam );
       
   167             
       
   168             TPhoneCmdParamBoolean booleanParam;
       
   169             booleanParam.SetBoolean( ETrue );
       
   170             iViewCommandHandle.ExecuteCommandL( 
       
   171                 EPhoneViewSetBlockingDialogStatus, 
       
   172                 &booleanParam );
       
   173             
       
   174             // Get active call count
       
   175             TPhoneCmdParamInteger activeCallCount;
       
   176             iViewCommandHandle.ExecuteCommandL(
       
   177                 EPhoneViewGetCountOfActiveCalls, &activeCallCount );
       
   178             
       
   179             if( !activeCallCount.Integer() )
       
   180                 {
       
   181                 __PHONELOG(
       
   182                     EBasic, 
       
   183                     EPhoneUIStates,
       
   184                     "CPhoneGeneralGsmMessagesHandler::EPEMessageIssuingSSRequest no active call" );
       
   185                 // Ensure that the dialer is activated to display local notes and dialogs properly.
       
   186                 TPhoneCmdParamAppInfo param;
       
   187                 param.SetAppUid( KUidPhoneApplication );
       
   188                 param.SetViewUid( KUidViewId );
       
   189                 param.SetCustomMessageId( TUid::Uid( KTouchDiallerViewCommand ) );
       
   190                 iViewCommandHandle.ExecuteCommandL( 
       
   191                     EPhoneViewActivateAppViewWithCustomMessage, 
       
   192                     &param );
       
   193                 }
       
   194             // Remove phoneumber query
       
   195             iViewCommandHandle.ExecuteCommandL( EPhoneViewRemoveQuery );
       
   196             break;
       
   197             }
       
   198 
       
   199         case MEngineMonitor::EPEMessageTempClirActivationUnsuccessful:
       
   200             SendGlobalErrorNoteL( EPhoneSSNotifCLIRSupprReject );
       
   201             break;
       
   202             
       
   203         case MEngineMonitor::EPEMessageForwardUnconditionalModeActive:
       
   204             SendGlobalInfoNoteL( EPhoneAllIncomingCallsDiverted );
       
   205             break;
       
   206             
       
   207         case MEngineMonitor::EPEMessageForwardConditionallyModeActive:
       
   208             SendGlobalInfoNoteL( EPhoneActiveDiverts );
       
   209             break;
       
   210 
       
   211         default:
       
   212             break;
       
   213         }
       
   214     }
       
   215 
       
   216 // ---------------------------------------------------------
       
   217 // CPhoneGeneralGsmMessagesHandler::SendGlobalInfoNoteL
       
   218 // ---------------------------------------------------------
       
   219 //
       
   220 void CPhoneGeneralGsmMessagesHandler::SendGlobalInfoNoteL( TInt aResourceId )
       
   221     {
       
   222     __LOGMETHODSTARTEND( EPhoneUIStates, 
       
   223         "CPhoneGeneralGsmMessagesHandler::SendGlobalInfoNoteL()" );
       
   224     __ASSERT_DEBUG( aResourceId, Panic( EPhoneCtrlParameterNotInitialized ) );
       
   225     if ( CPhonePubSubProxy::Instance()->Value( 
       
   226             KPSUidUikon, KUikGlobalNotesAllowed ) == 1 )
       
   227         {
       
   228         // Re-enable global notes
       
   229         TPhoneCmdParamBoolean globalNotifierParam;
       
   230         globalNotifierParam.SetBoolean( EFalse );
       
   231         iViewCommandHandle.ExecuteCommandL( EPhoneViewSetGlobalNotifiersDisabled,
       
   232             &globalNotifierParam );
       
   233             
       
   234         TPhoneCmdParamGlobalNote globalNoteParam;
       
   235       
       
   236         globalNoteParam.SetType( EAknGlobalInformationNote );
       
   237         globalNoteParam.SetTextResourceId( 
       
   238             CPhoneMainResourceResolver::Instance()->
       
   239             ResolveResourceID( aResourceId ) );
       
   240         globalNoteParam.SetTone( EAvkonSIDInformationTone );
       
   241 
       
   242         iViewCommandHandle.ExecuteCommandL( 
       
   243             EPhoneViewShowGlobalNote, &globalNoteParam );    
       
   244         }
       
   245     }
       
   246 
       
   247 // -----------------------------------------------------------
       
   248 // CPhoneGeneralGsmMessagesHandler::HandleIncomingCallForwardedL
       
   249 // -----------------------------------------------------------
       
   250 //
       
   251 void CPhoneGeneralGsmMessagesHandler::HandleIncomingCallForwardedL()
       
   252     {
       
   253     __LOGMETHODSTARTEND( EPhoneUIStates, 
       
   254         "CPhoneGeneralGsmMessagesHandler::HandleIncomingCallForwardedL()" );
       
   255     
       
   256     iActiveState.SetDivertIndication( ETrue );
       
   257     
       
   258     }
       
   259 
       
   260 // -----------------------------------------------------------
       
   261 // CPhoneGeneralGsmMessagesHandler::HandleShowVersionL
       
   262 // -----------------------------------------------------------
       
   263 //
       
   264 void CPhoneGeneralGsmMessagesHandler::HandleShowVersionL()
       
   265     {
       
   266     __LOGMETHODSTARTEND( EPhoneUIStates, 
       
   267         "CPhoneGeneralGsmMessagesHandler::HandleShowVersionL()" );
       
   268     if ( FeatureManager::FeatureSupported( KFeatureIdOnScreenDialer )  )  
       
   269         {
       
   270         iViewCommandHandle.ExecuteCommandL( EPhoneViewClearNumberEntryContent );       
       
   271         }
       
   272     else
       
   273         {
       
   274         // Remove number entry from screen
       
   275         iViewCommandHandle.ExecuteCommandL( EPhoneViewRemoveNumberEntry );        
       
   276         } 
       
   277 
       
   278 
       
   279 #ifdef __SYNCML_DM
       
   280     // Launch DM UI 
       
   281     RWsSession sess = CCoeEnv::Static()->WsSession();
       
   282     RApaLsSession apaLsSession;        
       
   283   
       
   284     TApaTaskList appList( sess );
       
   285     TApaTask bring = appList.FindApp( KDeviceManagerUid );
       
   286 
       
   287     if ( bring.Exists() )
       
   288         {
       
   289         bring.BringToForeground();
       
   290         }
       
   291     else
       
   292         {
       
   293         if( !apaLsSession.Handle() )
       
   294             {
       
   295             User::LeaveIfError(apaLsSession.Connect());
       
   296             }
       
   297         CleanupClosePushL( apaLsSession );
       
   298         TThreadId thread;
       
   299         User::LeaveIfError( apaLsSession.StartDocument(KNullDesC, KDeviceManagerUid, thread) );
       
   300         CleanupStack::PopAndDestroy( &apaLsSession );  
       
   301         }
       
   302 
       
   303     // Stop dtmf tone. Long key press case key up event go to 
       
   304     // device manager application.
       
   305     iStateMachine.SendPhoneEngineMessage(
       
   306         MPEPhoneModel::EPEMessageEndDTMF );
       
   307     
       
   308 #else    
       
   309     // Fetch version number
       
   310     TPEPhoneIdentityParameters phoneIdentityParameters = iStateMachine.
       
   311         PhoneEngineInfo()->PhoneIdentityParameters();
       
   312 
       
   313     // Add it to the resource string
       
   314     HBufC* buf = HBufC::NewLC( KSysUtilVersionTextLength );
       
   315     buf->Des().Format( phoneIdentityParameters.iRevision );
       
   316         
       
   317     TPhoneCmdParamNote noteParam;
       
   318     noteParam.SetType( EPhoneNoteCustom );
       
   319     noteParam.SetResourceId( CPhoneMainResourceResolver::Instance()->
       
   320         ResolveResourceID( EPhoneInformationWaitNote ) );
       
   321     noteParam.SetText( *buf );
       
   322     
       
   323     // Display note
       
   324     iViewCommandHandle.ExecuteCommandL( EPhoneViewShowNote, &noteParam );
       
   325     
       
   326     CleanupStack::PopAndDestroy( buf );
       
   327 #endif
       
   328     }
       
   329 
       
   330 // ---------------------------------------------------------
       
   331 //  CPhoneGeneralGsmMessagesHandler::SendGlobalErrorNoteL
       
   332 // ---------------------------------------------------------
       
   333 //
       
   334 void CPhoneGeneralGsmMessagesHandler::SendGlobalErrorNoteL( TInt aResourceId )
       
   335     {
       
   336     __LOGMETHODSTARTEND( EPhoneUIStates, 
       
   337         "CPhoneGeneralGsmMessagesHandler::SendGlobalErrorNoteL()" );
       
   338     __ASSERT_DEBUG( aResourceId, Panic( EPhoneCtrlParameterNotInitialized ) );
       
   339 
       
   340     if ( CPhonePubSubProxy::Instance()->Value( 
       
   341             KPSUidUikon, KUikGlobalNotesAllowed ) == 1 )
       
   342         {
       
   343         // Re-enable global notes
       
   344         TPhoneCmdParamBoolean globalNotifierParam;
       
   345         globalNotifierParam.SetBoolean( EFalse );
       
   346         iViewCommandHandle.ExecuteCommandL( EPhoneViewSetGlobalNotifiersDisabled,
       
   347             &globalNotifierParam );
       
   348             
       
   349         TPhoneCmdParamGlobalNote globalNoteParam;
       
   350         globalNoteParam.SetType( EAknGlobalErrorNote );
       
   351         globalNoteParam.SetTextResourceId( 
       
   352             CPhoneMainResourceResolver::Instance()->
       
   353             ResolveResourceID( aResourceId ) );
       
   354         globalNoteParam.SetTone( CAknNoteDialog::EErrorTone );
       
   355 
       
   356         iViewCommandHandle.ExecuteCommandL( 
       
   357             EPhoneViewShowGlobalNote, &globalNoteParam );
       
   358         }
       
   359     }
       
   360 
       
   361 // End of File