phonebookui/Phonebook2/ccapplication/ccacommlauncherplugin/src/ccappcommlauncherplugin.cpp
branchRCL_3
changeset 63 f4a778e096c2
child 64 c1e8ba0c2b16
equal deleted inserted replaced
62:5b6f26637ad3 63:f4a778e096c2
       
     1 /*
       
     2 * Copyright (c) 2007-2007 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 comm launcher view plugin
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "ccappcommlauncherheaders.h"
       
    20 #include <phonebook2ece.mbg>
       
    21 
       
    22 
       
    23 #include <mccappengine.h>
       
    24 
       
    25 // Consts
       
    26 _LIT( KCCAppCommLauncherResourceFileName, "\\resource\\ccappcommlauncherpluginrsc.rsc" );
       
    27 const TInt KCCAppCommLauncherMaxOrderBufLength = 128;
       
    28 
       
    29 const TInt KSupportedMethodsArray[] = {
       
    30     VPbkFieldTypeSelectorFactory::EVoiceCallSelector,
       
    31     VPbkFieldTypeSelectorFactory::EVOIPCallSelector,
       
    32     VPbkFieldTypeSelectorFactory::EUniEditorSelector,
       
    33     VPbkFieldTypeSelectorFactory::EEmailEditorSelector,
       
    34     VPbkFieldTypeSelectorFactory::EInstantMessagingSelector,
       
    35     VPbkFieldTypeSelectorFactory::EURLSelector,
       
    36     VPbkFieldTypeSelectorFactory::EVideoCallSelector,
       
    37     VPbkFieldTypeSelectorFactory::EFindOnMapSelector
       
    38     };
       
    39 
       
    40 const TInt KSupportedMethodsArrayLength = sizeof( KSupportedMethodsArray ) / sizeof( TInt );
       
    41 const TInt KDelayTime = 30000000; // 30s
       
    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 
       
    61 // ======== MEMBER FUNCTIONS ========
       
    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         
       
   144 // ---------------------------------------------------------------------------
       
   145 // CCCAppCommLauncherPlugin::NewL
       
   146 // ---------------------------------------------------------------------------
       
   147 //
       
   148 CCCAppCommLauncherPlugin* CCCAppCommLauncherPlugin::NewL()
       
   149     {
       
   150     CCA_DP(KCommLauncherLogFile, CCA_L("->CCCAppCommLauncherPlugin::NewL()"));
       
   151     CCCAppCommLauncherPlugin* self = new ( ELeave ) CCCAppCommLauncherPlugin();
       
   152     CleanupStack::PushL( self );
       
   153     self->ConstructL();
       
   154     CleanupStack::Pop( self );
       
   155     CCA_DP(KCommLauncherLogFile, CCA_L("<-CCCAppCommLauncherPlugin::NewL()"));
       
   156     return self;
       
   157     }
       
   158 
       
   159 // ---------------------------------------------------------------------------
       
   160 // CCCAppCommLauncherPlugin::~CCCAppCommLauncherPlugin
       
   161 // ---------------------------------------------------------------------------
       
   162 //
       
   163 CCCAppCommLauncherPlugin::~CCCAppCommLauncherPlugin()
       
   164     {
       
   165     CCA_DP(KCommLauncherLogFile, CCA_L("->CCCAppCommLauncherPlugin::~CCCAppCommLauncherPlugin()"));
       
   166     iPreferredCommMethods.Close();
       
   167 
       
   168     if (AppEngine())
       
   169         {
       
   170         AppEngine()->RemoveObserver(*this);
       
   171         }
       
   172 
       
   173     delete iMenuHandler;
       
   174 
       
   175     delete iContactHandler;
       
   176     delete iContactorService;
       
   177     
       
   178     
       
   179     delete iAiwRequestTimer;
       
   180 
       
   181     CCA_DP(KCommLauncherLogFile, CCA_L("<-CCCAppCommLauncherPlugin::~CCCAppCommLauncherPlugin()"));
       
   182     }
       
   183 
       
   184 // ---------------------------------------------------------------------------
       
   185 // CCCAppCommLauncherPlugin::CCCAppCommLauncherPlugin()
       
   186 // ---------------------------------------------------------------------------
       
   187 //
       
   188 CCCAppCommLauncherPlugin::CCCAppCommLauncherPlugin() : iIsCcaForeground( ETrue ),
       
   189         iIsTimerStart( EFalse )
       
   190     {
       
   191     CCA_DP(KCommLauncherLogFile, CCA_L("CCCAppCommLauncherPlugin()"));
       
   192     }
       
   193 
       
   194 // ---------------------------------------------------------------------------
       
   195 // CCCAppCommLauncherPlugin::ConstructL
       
   196 // ---------------------------------------------------------------------------
       
   197 //
       
   198 void CCCAppCommLauncherPlugin::ConstructL()
       
   199     {
       
   200     CCA_DP(KCommLauncherLogFile, CCA_L("ConstructL()"));
       
   201     // ConstructL should be as light as possible.
       
   202     }
       
   203 
       
   204 // ---------------------------------------------------------------------------
       
   205 // CCCAppCommLauncherPlugin::PreparePluginViewL
       
   206 // ---------------------------------------------------------------------------
       
   207 //
       
   208 void CCCAppCommLauncherPlugin::PreparePluginViewL(
       
   209     MCCAppPluginParameter& /*aPluginParameter*/ )
       
   210     {
       
   211     CCA_DP(KCommLauncherLogFile, CCA_L("->CCCAppCommLauncherPlugin::PreparePluginViewL()"));
       
   212 
       
   213     // This plugin has no usage for the aPluginParameter
       
   214 
       
   215     if (AppEngine())
       
   216         {
       
   217         AppEngine()->AddObserverL(*this);
       
   218         }
       
   219 
       
   220     //PERFORMANCE LOGGING: 7. Preparing plugin
       
   221     WriteToPerfLog();
       
   222 
       
   223     PrepareViewResourcesL();
       
   224     InitialisePreferredCommMethods();
       
   225 
       
   226     BaseConstructL( R_COMMLAUNCHER_VIEW );
       
   227    
       
   228 
       
   229     CCA_DP(KCommLauncherLogFile, CCA_L("<-CCCAppCommLauncherPlugin::PreparePluginViewL()"));
       
   230     }
       
   231 
       
   232 // ---------------------------------------------------------------------------
       
   233 // CCCAppCommLauncherPlugin::DoActivateL
       
   234 // ---------------------------------------------------------------------------
       
   235 //
       
   236 void CCCAppCommLauncherPlugin::DoActivateL(
       
   237     const TVwsViewId& aPrevViewId,
       
   238     TUid aCustomMessageId,
       
   239     const TDesC8& aCustomMessage )
       
   240     {
       
   241     CCA_DP(KCommLauncherLogFile, CCA_L("->CCCAppCommLauncherPlugin::DoActivateL()"));
       
   242 
       
   243     //PERFORMANCE LOGGING: 8. Activating view
       
   244     WriteToPerfLog();
       
   245 
       
   246     AppUi()->SetKeyEventFlags(
       
   247         CAknAppUiBase::EDisableSendKeyShort |
       
   248         CAknAppUiBase::EDisableSendKeyLong );
       
   249     // Forward the activation-call to base-class
       
   250     CCCAppViewPluginAknView::DoActivateL(
       
   251         aPrevViewId, aCustomMessageId, aCustomMessage );
       
   252 
       
   253     CCA_DP(KCommLauncherLogFile, CCA_L("::DoActivateL() - create iContactHandler"));
       
   254     iContactHandler = CCCAppCommLauncherContactHandler::NewL(
       
   255         *static_cast<CCCAppCommLauncherContainer*>(iContainer),
       
   256         *this);
       
   257     CCA_DP(KCommLauncherLogFile, CCA_L("::DoActivateL() - request contact data"));
       
   258 
       
   259     if (iRefetchContact)
       
   260     	{
       
   261         iContactHandler->RefetchContactL();
       
   262         iRefetchContact = EFalse;
       
   263       	}
       
   264     else
       
   265     	{
       
   266         iContactHandler->RequestContactDataL();
       
   267     	}
       
   268 
       
   269     if (!iContactorService)
       
   270         {
       
   271         iContactorService = CCAContactorService::NewL();
       
   272         }
       
   273 
       
   274     CCA_DP(KCommLauncherLogFile, CCA_L("<-CCCAppCommLauncherPlugin::DoActivateL()"));
       
   275     }
       
   276 
       
   277 // ---------------------------------------------------------------------------
       
   278 // CCCAppCommLauncherPlugin::DoDeactivate
       
   279 // ---------------------------------------------------------------------------
       
   280 //
       
   281 void CCCAppCommLauncherPlugin::DoDeactivate()
       
   282     {
       
   283     CCA_DP(KCommLauncherLogFile, CCA_L("->CCCAppCommLauncherPlugin::DoDeactivate()"));
       
   284 
       
   285     delete iContactHandler;
       
   286     iContactHandler = NULL;
       
   287 
       
   288     AppUi()->SetKeyEventFlags( 0 );
       
   289     // Forward the deactivation-call to base-class
       
   290     CCCAppViewPluginAknView::DoDeactivate();
       
   291 
       
   292     // if plugin is showing notifications, this is good place to disable those
       
   293     // until ActivatePluginViewL is called again
       
   294 
       
   295     // After commlauncher view is deactivated, cancel the timer which started when requests
       
   296     // a call services.
       
   297     CancelTimer();
       
   298     CCA_DP(KCommLauncherLogFile, CCA_L("<-CCCAppCommLauncherPlugin::DoDeactivate()"));
       
   299     }
       
   300 
       
   301 // ---------------------------------------------------------------------------
       
   302 // CCCAppCommLauncherPlugin::InitialisePreferredCommMethods
       
   303 // ---------------------------------------------------------------------------
       
   304 //
       
   305 void CCCAppCommLauncherPlugin::InitialisePreferredCommMethods()
       
   306     {
       
   307     CCA_DP(KCommLauncherLogFile, CCA_L("->CCCAppCommLauncherPlugin::InitialisePreferredCommMethods()"));
       
   308 
       
   309     TRAPD( err, LoadPreferredCommMethodsL() );
       
   310     if ( err )
       
   311         {// something went wrong with loading from cenrep,
       
   312         //  use the default order
       
   313 #ifdef _DEBUG
       
   314         CCA_DP(KCommLauncherLogFile, CCA_L("::InitialisePreferredCommMethods - Comm method variation error."));
       
   315         CCA_DP(KCommLauncherLogFile, CCA_L("::InitialisePreferredCommMethods - err: %d"), err );
       
   316         CEikonEnv::Static()->InfoMsg(_L("Comm method variation error. See logs."));
       
   317 #endif//_DEBUG
       
   318         iPreferredCommMethods.Reset();
       
   319 
       
   320         for ( TInt idx = 0; idx < KSupportedMethodsArrayLength; idx++ )
       
   321             {
       
   322             iPreferredCommMethods.Append(
       
   323                 (VPbkFieldTypeSelectorFactory::TVPbkContactActionTypeSelector)
       
   324                 KSupportedMethodsArray[ idx ]);
       
   325             }
       
   326         }
       
   327     CCA_DP(KCommLauncherLogFile, CCA_L("<-CCCAppCommLauncherPlugin::InitialisePreferredCommMethods()"));
       
   328     }
       
   329 
       
   330 // ---------------------------------------------------------------------------
       
   331 // CCCAppCommLauncherPlugin::LoadPreferredCommMethodsL
       
   332 // ---------------------------------------------------------------------------
       
   333 //
       
   334 void CCCAppCommLauncherPlugin::LoadPreferredCommMethodsL()
       
   335     {
       
   336     CCA_DP(KCommLauncherLogFile, CCA_L("->CCCAppCommLauncherPlugin::LoadPreferredCommMethodsL()"));
       
   337 
       
   338     CRepository* repository = CRepository::NewLC( KCRUidCCACommLauncher );
       
   339     TBuf<KCCAppCommLauncherMaxOrderBufLength> orderBuf;
       
   340     TInt error = repository->Get( KCommunicationMethodOrder, orderBuf );
       
   341     CleanupStack::PopAndDestroy( repository );
       
   342 
       
   343     TLex orderLex( orderBuf );
       
   344     TPtrC numToken;
       
   345     TLex numLex;
       
   346     TInt commMethodType;
       
   347     const TInt bufLength = orderBuf.Length() - 1;
       
   348 
       
   349     while ( orderLex.Offset() < bufLength )
       
   350         {
       
   351         numToken.Set( orderLex.NextToken() );
       
   352         numLex.Assign( numToken );
       
   353         // if defined value is string instead of a number,
       
   354         // use the default array
       
   355         User::LeaveIfError( numLex.Val( commMethodType ));
       
   356         CCA_DP(KCommLauncherLogFile, CCA_L("::LoadPreferredCommMethodsL - found commMethodType: %d"), commMethodType );
       
   357         // if defined value is outside of the possible comm method
       
   358         // values, use the default array
       
   359         TBool knownMethod(EFalse);
       
   360         for( TInt idx = 0; idx < KSupportedMethodsArrayLength; idx++ )
       
   361             {
       
   362             if( KSupportedMethodsArray[ idx ] == commMethodType )
       
   363                 {
       
   364                 knownMethod = ETrue;
       
   365                 break;
       
   366                 }
       
   367             }
       
   368         if(!knownMethod)
       
   369             {
       
   370             CCA_DP(KCommLauncherLogFile, CCA_L("::LoadPreferredCommMethodsL - skippin unsupported method(s): %d"),
       
   371                     commMethodType );
       
   372             User::Leave( KErrArgument );
       
   373             }
       
   374 
       
   375         iPreferredCommMethods.Append(
       
   376             VPbkFieldTypeSelectorFactory::CreateActionTypeSelectorIdL(
       
   377                 commMethodType ) );
       
   378         }
       
   379 
       
   380     // if no comm methods defined, use the default array
       
   381     User::LeaveIfError( iPreferredCommMethods.Count() ? 0 : KErrNotFound );
       
   382 
       
   383     CCA_DP(KCommLauncherLogFile, CCA_L("<-CCCAppCommLauncherPlugin::LoadPreferredCommMethodsL()"));
       
   384     }
       
   385 
       
   386 // ---------------------------------------------------------------------------
       
   387 // CCCAppCommLauncherPlugin::ProvideBitmapL
       
   388 // ---------------------------------------------------------------------------
       
   389 //
       
   390 void CCCAppCommLauncherPlugin::ProvideBitmapL(
       
   391     TCCAppIconType aIconType,
       
   392     CAknIcon& aIcon )
       
   393     {
       
   394     CCA_DP(KCommLauncherLogFile, CCA_L("->CCCAppCommLauncherPlugin::ProvideBitmapL()"));
       
   395 
       
   396     if ( ECCAppTabIcon == aIconType )
       
   397         {
       
   398         CFbsBitmap* bmp = NULL;
       
   399         CFbsBitmap* bmpMask = NULL;
       
   400 
       
   401         AknsUtils::CreateIconL(
       
   402             AknsUtils::SkinInstance(),
       
   403             KAknsIIDQgnPropPbCommTab3,
       
   404             bmp,
       
   405             bmpMask,
       
   406             KPbk2ECEIconFileName,
       
   407             EMbmPhonebook2eceQgn_prop_pb_comm_tab3,
       
   408             EMbmPhonebook2eceQgn_prop_pb_comm_tab3_mask );
       
   409 
       
   410         aIcon.SetBitmap( bmp );
       
   411         aIcon.SetMask( bmpMask );
       
   412         }
       
   413 
       
   414     CCA_DP(KCommLauncherLogFile, CCA_L("<-CCCAppCommLauncherPlugin::ProvideBitmapL()"));
       
   415     }
       
   416 
       
   417 // ---------------------------------------------------------------------------
       
   418 // CCCAppCommLauncherPlugin::CCCAppViewPluginBaseExtension
       
   419 // ---------------------------------------------------------------------------
       
   420 //
       
   421 TAny* CCCAppCommLauncherPlugin::CCCAppViewPluginBaseExtension( TUid aExtensionUid )
       
   422     {
       
   423     if ( aExtensionUid == KMCCAppViewPluginBaseExtension2Uid )
       
   424         {
       
   425         return static_cast<MCCAppViewPluginBase2*>( this );
       
   426         }
       
   427     return NULL;
       
   428     }
       
   429 
       
   430 // ---------------------------------------------------------------------------
       
   431 // CCCAppCommLauncherPlugin::DynInitMenuPaneL
       
   432 // ---------------------------------------------------------------------------
       
   433 //
       
   434 void CCCAppCommLauncherPlugin::DynInitMenuPaneL(
       
   435     TInt aResourceId,
       
   436     CEikMenuPane* aMenuPane )
       
   437     {
       
   438     EnsureMenuHandlerCreatedL();
       
   439     iMenuHandler->DynInitMenuPaneL( aResourceId, aMenuPane );
       
   440     }
       
   441 
       
   442 // ---------------------------------------------------------------------------
       
   443 // CCCAppCommLauncherPlugin::EnsureMenuHandlerCreatedL
       
   444 // ---------------------------------------------------------------------------
       
   445 //
       
   446 void CCCAppCommLauncherPlugin::EnsureMenuHandlerCreatedL()
       
   447     {
       
   448     if ( !iMenuHandler )
       
   449         {
       
   450         iMenuHandler = CCCAppCommLauncherMenuHandler::NewL( *this );
       
   451         iMenuHandler->SetContactStore( iContactHandler->ContactStore() );
       
   452         }
       
   453     }
       
   454 
       
   455 // ---------------------------------------------------------------------------
       
   456 // CCCAppCommLauncherPlugin::CloseCCApp
       
   457 // ---------------------------------------------------------------------------
       
   458 //
       
   459 void CCCAppCommLauncherPlugin::CloseCCApp()
       
   460     {
       
   461     // Cancel timer after timer triggered to make sure the same timer just be 
       
   462     // triggered once.
       
   463     CancelTimer();
       
   464     
       
   465     // If CCA is at background, close CCA application.
       
   466     if ( !iIsCcaForeground )
       
   467         {
       
   468         RWsSession& wsSession = CCoeEnv::Static()->WsSession();
       
   469 
       
   470         TApaTask ccapp( wsSession );
       
   471         TInt wgId = CCoeEnv::Static()->RootWin().WindowGroupId();
       
   472         ccapp.SetWgId( wgId );
       
   473         ccapp.EndTask();
       
   474         }
       
   475     }
       
   476 
       
   477 // ---------------------------------------------------------------------------
       
   478 // CCCAppCommLauncherContainer::ContactorService
       
   479 // ---------------------------------------------------------------------------
       
   480 //
       
   481 const CCAContactorService* CCCAppCommLauncherPlugin::ContactorService()
       
   482     {
       
   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         }
       
   499     }
       
   500 
       
   501 // ---------------------------------------------------------------------------
       
   502 // CCCAppCommLauncherPlugin::StartTimerL
       
   503 // ---------------------------------------------------------------------------
       
   504 //
       
   505 void CCCAppCommLauncherPlugin::StartTimerL()
       
   506     {
       
   507     if ( !iAiwRequestTimer )
       
   508         {
       
   509         iAiwRequestTimer = CPeriodic::NewL( CActive::EPriorityStandard );
       
   510         }
       
   511     
       
   512     // Cancel the timer before start it to make sure formal timer can be canceled
       
   513     // when start a new timer.
       
   514     CancelTimer();
       
   515     
       
   516     TCallBack callback( ServiceTimeOutL, this );
       
   517     iAiwRequestTimer->Start( KDelayTime, KDelayTime, callback );
       
   518     
       
   519     iIsTimerStart = ETrue;
       
   520     }
       
   521 
       
   522 // ---------------------------------------------------------------------------
       
   523 // CCCAppCommLauncherPlugin::CancelTimer
       
   524 // ---------------------------------------------------------------------------
       
   525 //
       
   526 void CCCAppCommLauncherPlugin::CancelTimer()
       
   527     {
       
   528     if ( iAiwRequestTimer && iIsTimerStart )
       
   529         {
       
   530         iAiwRequestTimer->Cancel();
       
   531         iIsTimerStart = EFalse;
       
   532         }
       
   533     }
       
   534 
       
   535 // ---------------------------------------------------------------------------
       
   536 // CCCAppCommLauncherPlugin::IsTopContactL
       
   537 // ---------------------------------------------------------------------------
       
   538 //
       
   539 TBool CCCAppCommLauncherPlugin::IsTopContactL()
       
   540     {
       
   541     return iContactHandler->IsTopContact();
       
   542     }
       
   543 
       
   544 // ---------------------------------------------------------------------------
       
   545 // CCCAppCommLauncherPlugin::IsContactL
       
   546 // ---------------------------------------------------------------------------
       
   547 //
       
   548 TBool CCCAppCommLauncherPlugin::IsContactL()
       
   549     {
       
   550     return ETrue;//todo
       
   551     }
       
   552 
       
   553 // ---------------------------------------------------------------------------
       
   554 // CCCAppCommLauncherPlugin::HandleCommandL
       
   555 // ---------------------------------------------------------------------------
       
   556 //
       
   557 void CCCAppCommLauncherPlugin::HandleCommandL( TInt aCommand )
       
   558     {
       
   559     if ( !iCommandState.IsRunning() )
       
   560         {
       
   561         // Make sure the aiw request timer is canceled before executing 
       
   562         // another command.
       
   563         CancelTimer();
       
   564         
       
   565         // Forward the command handling 1st to base-class.
       
   566         // The "Exit"- and "Back"-commands are handled there.
       
   567         CCCAppViewPluginAknView::HandleCommandL( aCommand );
       
   568     
       
   569         // Rest to menuhandler
       
   570         EnsureMenuHandlerCreatedL();
       
   571         iMenuHandler->HandleCommandL( aCommand );
       
   572         }
       
   573     }
       
   574 
       
   575 // ---------------------------------------------------------------------------
       
   576 // CCCAppCommLauncherPlugin::PreferredCommMethods
       
   577 // ---------------------------------------------------------------------------
       
   578 //
       
   579 RArray<VPbkFieldTypeSelectorFactory::TVPbkContactActionTypeSelector>&
       
   580     CCCAppCommLauncherPlugin::PreferredCommMethods()
       
   581     {
       
   582     CCA_DP(KCommLauncherLogFile, CCA_L("CCCAppCommLauncherPlugin::PreferredCommMethods()"));
       
   583     return iPreferredCommMethods;
       
   584     }
       
   585 
       
   586 // ---------------------------------------------------------------------------
       
   587 // CCCAppCommLauncherPlugin::ErrorNotifierL
       
   588 // ---------------------------------------------------------------------------
       
   589 //
       
   590 void CCCAppCommLauncherPlugin::ErrorNotifierL(
       
   591     TCCAppCommLauncherPluginErrorSource aErrorSource,
       
   592     TInt aError )
       
   593     {
       
   594     // possibility to handle the error cases
       
   595     CCA_DP(KCommLauncherLogFile, CCA_L("CCCAppCommLauncherPlugin::ErrorNotifierL() called"));
       
   596     CCA_DP(KCommLauncherLogFile, CCA_L("::ErrorNotifierL aError: %d"), aError );
       
   597     CCA_DP(KCommLauncherLogFile, CCA_L("::ErrorNotifierL aErrorSource: %d"), (TInt)aErrorSource );
       
   598     }
       
   599 
       
   600 // ---------------------------------------------------------------------------
       
   601 // CCCAppCommLauncherPlugin::Container
       
   602 // ---------------------------------------------------------------------------
       
   603 //
       
   604 CCCAppCommLauncherContainer& CCCAppCommLauncherPlugin::Container()
       
   605     {
       
   606     return *static_cast<CCCAppCommLauncherContainer*>(iContainer);
       
   607     }
       
   608 
       
   609 // ---------------------------------------------------------------------------
       
   610 // CCCAppCommLauncherPlugin::ContactHandler
       
   611 // ---------------------------------------------------------------------------
       
   612 //
       
   613 CCCAppCommLauncherContactHandler& CCCAppCommLauncherPlugin::ContactHandler()
       
   614     {
       
   615     return *iContactHandler;
       
   616     }
       
   617 
       
   618 // ---------------------------------------------------------------------------
       
   619 // CCCAppCommLauncherPlugin::NewContainerL
       
   620 // ---------------------------------------------------------------------------
       
   621 //
       
   622 void CCCAppCommLauncherPlugin::NewContainerL()
       
   623     {
       
   624     iContainer = new (ELeave) CCCAppCommLauncherContainer( *this );
       
   625     }
       
   626 
       
   627 // ---------------------------------------------------------------------------
       
   628 // CCCAppCommLauncherPlugin::PluginBusy()
       
   629 // ---------------------------------------------------------------------------
       
   630 //
       
   631 TBool CCCAppCommLauncherPlugin::PluginBusy()
       
   632     {
       
   633     TBool ret = EFalse;
       
   634     
       
   635     if ( iContactorService != NULL )
       
   636        {
       
   637        ret = iContactorService->IsBusy();
       
   638        }
       
   639     return ret;
       
   640     }
       
   641 
       
   642 // ---------------------------------------------------------------------------
       
   643 // CCCAppCommLauncherPlugin::HandleForegroundEventL()
       
   644 // ---------------------------------------------------------------------------
       
   645 //
       
   646 void CCCAppCommLauncherPlugin::HandleForegroundEventL( TBool aForeground )
       
   647     {
       
   648     iIsCcaForeground = aForeground;
       
   649     }
       
   650 
       
   651 // ---------------------------------------------------------------------------
       
   652 // CCCAppCommLauncherPlugin::Id
       
   653 // ---------------------------------------------------------------------------
       
   654 //
       
   655 TUid CCCAppCommLauncherPlugin::Id()const
       
   656     {
       
   657     return TUid::Uid( KCCACommLauncherPluginImplmentationUid );
       
   658     }
       
   659 
       
   660 // ---------------------------------------------------------------------------
       
   661 // CCCAppCommLauncherPlugin::PrepareViewResourcesL
       
   662 // ---------------------------------------------------------------------------
       
   663 //
       
   664 void CCCAppCommLauncherPlugin::PrepareViewResourcesL()
       
   665     {
       
   666     // preparing resources for use
       
   667     TFileName fileName( KCCAppCommLauncherResourceFileName );
       
   668     BaflUtils::NearestLanguageFile( iCoeEnv->FsSession(), fileName );
       
   669     iResourceLoader.OpenL( fileName );
       
   670     }
       
   671 
       
   672 
       
   673 // ---------------------------------------------------------------------------
       
   674 // CCCAppCommLauncherPlugin::SetTitleL
       
   675 // ---------------------------------------------------------------------------
       
   676 //
       
   677 void CCCAppCommLauncherPlugin::SetTitleL( const TDesC& aTitle )
       
   678     {
       
   679     // Forward the SetTitleL-call to base-class
       
   680     CCCAppViewPluginAknView::SetTitleL( aTitle );
       
   681     }
       
   682 
       
   683 // ---------------------------------------------------------------------------
       
   684 // CCCAppCommLauncherPlugin::NotifyPluginOfContactChangeL
       
   685 // ---------------------------------------------------------------------------
       
   686 //
       
   687 void CCCAppCommLauncherPlugin::NotifyPluginOfContactEventL()
       
   688     {
       
   689     iRefetchContact = ETrue;
       
   690     }
       
   691 
       
   692 // --------------------------------------------------------------------------
       
   693 // CCCAppCommLauncherPlugin::UpdateMSKinCbaL
       
   694 // Sets CBA with empty MSK or MSK with text "Select" when contact has
       
   695 // communication methods available.
       
   696 // --------------------------------------------------------------------------
       
   697 //
       
   698 void CCCAppCommLauncherPlugin::UpdateMSKinCbaL( TBool aCommMethodsAvailable )
       
   699 {
       
   700     CEikButtonGroupContainer* cba = Cba();
       
   701 
       
   702     if ( cba )
       
   703         {
       
   704         cba->SetCommandSetL(aCommMethodsAvailable
       
   705             ? R_AVKON_SOFTKEYS_OPTIONS_BACK__SELECT
       
   706             : R_CCACOMMLAUNCHER_SOFTKEYS_OPTIONS_BACK_EMPTY);
       
   707 
       
   708         cba->DrawDeferred();
       
   709         }
       
   710 }
       
   711 
       
   712 // ---------------------------------------------------------------------------
       
   713 // CCCAppCommLauncherPlugin::ServiceTimeOutL
       
   714 // ---------------------------------------------------------------------------
       
   715 //
       
   716 TInt CCCAppCommLauncherPlugin::ServiceTimeOutL( TAny* aObject )
       
   717     {
       
   718     CCCAppCommLauncherPlugin* self = static_cast<CCCAppCommLauncherPlugin*> (aObject);
       
   719     self->CloseCCApp();
       
   720     return 0;
       
   721     }
       
   722 
       
   723 // End of File