phonebookui/Phonebook2/ccapplication/ccacommlauncherplugin/src/ccappcommlauncherplugin.cpp
branchRCL_3
changeset 39 a6539d1e8e43
parent 23 5586b4d2ec3e
child 64 c1e8ba0c2b16
equal deleted inserted replaced
35:4ae315f230bc 39:a6539d1e8e43
    38     };
    38     };
    39 
    39 
    40 const TInt KSupportedMethodsArrayLength = sizeof( KSupportedMethodsArray ) / sizeof( TInt );
    40 const TInt KSupportedMethodsArrayLength = sizeof( KSupportedMethodsArray ) / sizeof( TInt );
    41 const TInt KDelayTime = 30000000; // 30s
    41 const TInt KDelayTime = 30000000; // 30s
    42 
    42 
       
    43 /**
       
    44  * Panic codes for the class TCCAppCommandState
       
    45  */
       
    46 enum TCCAppCommandStatePanicCode
       
    47     {
       
    48     ETCCAppCommandState_SetRunning_PreCond = 1
       
    49     };
       
    50 
       
    51 // ---------------------------------------------------------------------------
       
    52 // Panic function for the class TCCAppCommandState
       
    53 // ---------------------------------------------------------------------------
       
    54 //
       
    55 void Panic(TCCAppCommandStatePanicCode aPanicCode)
       
    56     {
       
    57     _LIT( KPanicText, "TCCAppCommandState" );
       
    58     User::Panic( KPanicText, aPanicCode );
       
    59     }
       
    60 
    43 // ======== MEMBER FUNCTIONS ========
    61 // ======== MEMBER FUNCTIONS ========
    44 
    62 
       
    63 // ---------------------------------------------------------------------------
       
    64 // TCCAppCommandState::TCCAppCommandState
       
    65 // ---------------------------------------------------------------------------
       
    66 //
       
    67 TCCAppCommandState::TCCAppCommandState()
       
    68     : iState( EFalse )
       
    69     {
       
    70     }
       
    71     
       
    72 // ---------------------------------------------------------------------------
       
    73 // TCCAppCommandState::SetRunning
       
    74 // ---------------------------------------------------------------------------
       
    75 //
       
    76 void TCCAppCommandState::SetRunning()
       
    77     {
       
    78     // Catch all the implementation errors in release build too.
       
    79     __ASSERT_ALWAYS( !IsRunning(), 
       
    80             Panic( ETCCAppCommandState_SetRunning_PreCond ) );
       
    81     iState = ETrue;
       
    82     }
       
    83 
       
    84 // ---------------------------------------------------------------------------
       
    85 // TCCAppCommandState::SetNotRunning
       
    86 // ---------------------------------------------------------------------------
       
    87 //
       
    88 void TCCAppCommandState::SetNotRunning()
       
    89     {
       
    90     iState = EFalse;
       
    91     }
       
    92 
       
    93 // ---------------------------------------------------------------------------
       
    94 // TCCAppCommandState::SetRunningAndPushCleanupL
       
    95 // ---------------------------------------------------------------------------
       
    96 //
       
    97 void TCCAppCommandState::SetRunningAndPushCleanupL()
       
    98     {
       
    99     SetRunning();
       
   100     PushCleanupL();
       
   101     }
       
   102 
       
   103 // ---------------------------------------------------------------------------
       
   104 // TCCAppCommandState::SetNotRunningAndPopCleanup
       
   105 // ---------------------------------------------------------------------------
       
   106 //
       
   107 void TCCAppCommandState::SetNotRunningAndPopCleanup()
       
   108     {
       
   109     SetNotRunning();
       
   110     PopCleanup();
       
   111     }
       
   112 
       
   113 // ---------------------------------------------------------------------------
       
   114 // TCCAppCommandState::PushCleanupL
       
   115 // ---------------------------------------------------------------------------
       
   116 //
       
   117 void TCCAppCommandState::PushCleanupL()
       
   118     {
       
   119     CleanupStack::PushL( TCleanupItem( TCCAppCommandState::CleanupOperation, 
       
   120             this) );
       
   121     }
       
   122 
       
   123 // ---------------------------------------------------------------------------
       
   124 // TCCAppCommandState::PopCleanup
       
   125 // ---------------------------------------------------------------------------
       
   126 //
       
   127 void TCCAppCommandState::PopCleanup()
       
   128     {
       
   129     CleanupStack::Pop();
       
   130     }
       
   131 
       
   132 // ---------------------------------------------------------------------------
       
   133 // TCCAppCommandState::CleanupOperation
       
   134 // ---------------------------------------------------------------------------
       
   135 //
       
   136 void TCCAppCommandState::CleanupOperation( TAny* aCommanState )
       
   137     {
       
   138     TCCAppCommandState* state = static_cast<TCCAppCommandState*>( 
       
   139             aCommanState );
       
   140     state->SetNotRunning();
       
   141     }
       
   142     
       
   143         
    45 // ---------------------------------------------------------------------------
   144 // ---------------------------------------------------------------------------
    46 // CCCAppCommLauncherPlugin::NewL
   145 // CCCAppCommLauncherPlugin::NewL
    47 // ---------------------------------------------------------------------------
   146 // ---------------------------------------------------------------------------
    48 //
   147 //
    49 CCCAppCommLauncherPlugin* CCCAppCommLauncherPlugin::NewL()
   148 CCCAppCommLauncherPlugin* CCCAppCommLauncherPlugin::NewL()
   377 
   476 
   378 // ---------------------------------------------------------------------------
   477 // ---------------------------------------------------------------------------
   379 // CCCAppCommLauncherContainer::ContactorService
   478 // CCCAppCommLauncherContainer::ContactorService
   380 // ---------------------------------------------------------------------------
   479 // ---------------------------------------------------------------------------
   381 //
   480 //
   382 CCAContactorService* CCCAppCommLauncherPlugin::ContactorService()
   481 const CCAContactorService* CCCAppCommLauncherPlugin::ContactorService()
   383     {
   482     {
   384     return iContactorService;
   483     return iContactorService;
       
   484     }
       
   485 
       
   486 // ---------------------------------------------------------------------------
       
   487 // CCCAppCommLauncherPlugin::ExecuteServiceL
       
   488 // ---------------------------------------------------------------------------
       
   489 //
       
   490 void CCCAppCommLauncherPlugin::ExecuteServiceL(
       
   491         const CCAContactorService::TCSParameter& aParameter)
       
   492     {
       
   493     if (iContactorService)
       
   494         {
       
   495         iCommandState.SetRunningAndPushCleanupL();
       
   496         iContactorService->ExecuteServiceL( aParameter );
       
   497         iCommandState.SetNotRunningAndPopCleanup();
       
   498         }
   385     }
   499     }
   386 
   500 
   387 // ---------------------------------------------------------------------------
   501 // ---------------------------------------------------------------------------
   388 // CCCAppCommLauncherPlugin::StartTimerL
   502 // CCCAppCommLauncherPlugin::StartTimerL
   389 // ---------------------------------------------------------------------------
   503 // ---------------------------------------------------------------------------
   440 // CCCAppCommLauncherPlugin::HandleCommandL
   554 // CCCAppCommLauncherPlugin::HandleCommandL
   441 // ---------------------------------------------------------------------------
   555 // ---------------------------------------------------------------------------
   442 //
   556 //
   443 void CCCAppCommLauncherPlugin::HandleCommandL( TInt aCommand )
   557 void CCCAppCommLauncherPlugin::HandleCommandL( TInt aCommand )
   444     {
   558     {
   445     // Make sure the aiw request timer is canceled before executing another command.
   559     if ( !iCommandState.IsRunning() )
   446     CancelTimer();
   560         {
   447     
   561         // Make sure the aiw request timer is canceled before executing 
   448     // Forward the command handling 1st to base-class.
   562         // another command.
   449     // The "Exit"- and "Back"-commands are handled there.
   563         CancelTimer();
   450     CCCAppViewPluginAknView::HandleCommandL( aCommand );
   564         
   451 
   565         // Forward the command handling 1st to base-class.
   452     // Rest to menuhandler
   566         // The "Exit"- and "Back"-commands are handled there.
   453     EnsureMenuHandlerCreatedL();
   567         CCCAppViewPluginAknView::HandleCommandL( aCommand );
   454     iMenuHandler->HandleCommandL( aCommand );
   568     
       
   569         // Rest to menuhandler
       
   570         EnsureMenuHandlerCreatedL();
       
   571         iMenuHandler->HandleCommandL( aCommand );
       
   572         }
   455     }
   573     }
   456 
   574 
   457 // ---------------------------------------------------------------------------
   575 // ---------------------------------------------------------------------------
   458 // CCCAppCommLauncherPlugin::PreferredCommMethods
   576 // CCCAppCommLauncherPlugin::PreferredCommMethods
   459 // ---------------------------------------------------------------------------
   577 // ---------------------------------------------------------------------------