phonebookui/Phonebook2/ccapplication/ccapp/src/ccapppluginloader.cpp
branchRCL_3
changeset 5 81f8547efd4f
parent 0 e686773b3f54
child 6 e8e3147d53eb
equal deleted inserted replaced
3:04ab22b956c2 5:81f8547efd4f
    20 #include <centralrepository.h>
    20 #include <centralrepository.h>
    21 
    21 
    22 #include <mccaparentcleaner.h>
    22 #include <mccaparentcleaner.h>
    23 #include <mccapluginfactory.h>
    23 #include <mccapluginfactory.h>
    24 
    24 
       
    25 #include <cpbk2applicationservices.h>
       
    26 #include <cvpbkcontactmanager.h>
       
    27 #include <MVPbkContactStoreProperties.h>
       
    28 #include <VPbkContactStoreUris.h>
       
    29 #include <TVPbkContactStoreUriPtr.h>
       
    30 #include <MVPbkContactStore.h>
    25 #include "Phonebook2PrivateCRKeys.h"
    31 #include "Phonebook2PrivateCRKeys.h"
    26 #include "ccappheaders.h"
    32 #include "ccappheaders.h"
    27 #include "tccapluginsorderinfo.h"
    33 #include "tccapluginsorderinfo.h"
    28 #include "ccapluginfactoryowner.h"
    34 #include "ccapluginfactoryowner.h"
    29 #include "../../ccadetailsviewplugin/inc/ccappdetailsviewpluginuids.hrh"
    35 #include "../../ccadetailsviewplugin/inc/ccappdetailsviewpluginuids.hrh"
    30 #include "../../ccacommlauncherplugin/inc/ccappcommlauncherpluginuids.hrh"
    36 #include "../../ccacommlauncherplugin/inc/ccappcommlauncherpluginuids.hrh"
       
    37 #include "../inc/ccappmycardpluginuids.hrh"
       
    38 
       
    39 #include <Pbk2DataCaging.hrh>
       
    40 
    31 
    41 
    32 // ======== CONSTANTS ==============
    42 // ======== CONSTANTS ==============
    33 const TInt KMaxPlugins = 255;
    43 const TInt KMaxPlugins = 255;
    34 //TODO: put these to common header
    44 //TODO: put these to common header
    35 _LIT8( KCcaOpaqueNameDelimiter,     "\t" ); //Name=value pairs separated by tabs
    45 _LIT8( KCcaOpaqueNameDelimiter,     "\t" ); //Name=value pairs separated by tabs
    36 _LIT8( KCcaOpaqueValueDelimiter,    "=" );  //Names and values separated by =
    46 _LIT8( KCcaOpaqueValueDelimiter,    "=" );  //Names and values separated by =
    37 _LIT8( KCcaOpaqueTABP,              "TABP" );  //Tab position
    47 _LIT8( KCcaOpaqueTABP,              "TABP" );  //Tab position
    38 
    48 
       
    49 _LIT(KPbk2CommandsDllResFileName,   "Pbk2Commands.rsc");
       
    50 _LIT(KPbk2UiControlsDllResFileName, "Pbk2UiControls.rsc");
       
    51 _LIT(KPbk2CommonUiDllResFileName,   "Pbk2CommonUi.rsc"  );
       
    52 
    39 // ======== LOCAL FUNCTIONS ========
    53 // ======== LOCAL FUNCTIONS ========
    40 
    54 
    41 // ---------------------------------------------------------------------------
    55 // ---------------------------------------------------------------------------
    42 // OrderOfPlugins (local function)
    56 // OrderOfPlugins (local function)
    43 //
    57 //
    85 
    99 
    86 // ---------------------------------------------------------------------------
   100 // ---------------------------------------------------------------------------
    87 // CCCAppPluginLoader::CCCAppPluginLoader
   101 // CCCAppPluginLoader::CCCAppPluginLoader
    88 // ---------------------------------------------------------------------------
   102 // ---------------------------------------------------------------------------
    89 //
   103 //
    90 CCCAppPluginLoader::CCCAppPluginLoader(MCCAppEngine* aAppEngine) : iAppEngine(aAppEngine)
   104 CCCAppPluginLoader::CCCAppPluginLoader(MCCAppEngine* aAppEngine) : 
       
   105 	iAppEngine(aAppEngine),
       
   106     iCommandsResourceFile( *CCoeEnv::Static() ),
       
   107     iUiControlsResourceFile( *CCoeEnv::Static() ),
       
   108     iCommonUiResourceFile( *CCoeEnv::Static() )
    91     {
   109     {
    92     CCA_DP( KCCAppLogFile, CCA_L("CCCAppPluginData::CCCAppPluginLoader"));
   110     CCA_DP( KCCAppLogFile, CCA_L("CCCAppPluginData::CCCAppPluginLoader"));
    93     }
   111     }
    94 
   112 
    95 // ---------------------------------------------------------------------------
   113 // ---------------------------------------------------------------------------
   110         }
   128         }
   111 
   129 
   112     iPluginDataArray.ResetAndDestroy();
   130     iPluginDataArray.ResetAndDestroy();
   113     delete iFactoryTempPtr;
   131     delete iFactoryTempPtr;
   114     CCA_DP( KCCAppLogFile, CCA_L("<-CCCAppPluginData::~CCCAppPluginLoader"));
   132     CCA_DP( KCCAppLogFile, CCA_L("<-CCCAppPluginData::~CCCAppPluginLoader"));
       
   133     
       
   134     Release( iAppServices );
       
   135 
       
   136     iCommandsResourceFile.Close();
       
   137     iUiControlsResourceFile.Close();
       
   138     iCommonUiResourceFile.Close();
   115     }
   139     }
   116 
   140 
   117 // ---------------------------------------------------------------------------
   141 // ---------------------------------------------------------------------------
   118 // CCCAppPluginLoader::NewL
   142 // CCCAppPluginLoader::NewL
   119 // ---------------------------------------------------------------------------
   143 // ---------------------------------------------------------------------------
   145     CCA_DP( KCCAppLogFile, CCA_L("->CCCAppPluginData::ConstructL"));
   169     CCA_DP( KCCAppLogFile, CCA_L("->CCCAppPluginData::ConstructL"));
   146 
   170 
   147     //PERFORMANCE LOGGING: 3. Loading plugins
   171     //PERFORMANCE LOGGING: 3. Loading plugins
   148     WriteToPerfLog();
   172     WriteToPerfLog();
   149 
   173 
       
   174     PreparePbk2ApplicationServicesL();
       
   175     
   150     RPointerArray<CImplementationInformation> oldImplInfoArray;
   176     RPointerArray<CImplementationInformation> oldImplInfoArray;
   151     CleanupStack::PushL(TCleanupItem(CleanupResetAndDestroy, &oldImplInfoArray));
   177     CleanupStack::PushL(TCleanupItem(CleanupResetAndDestroy, &oldImplInfoArray));
   152     RPointerArray<CImplementationInformation> newImplInfoArray;
   178     RPointerArray<CImplementationInformation> newImplInfoArray;
   153     CleanupStack::PushL(TCleanupItem(CleanupResetAndDestroy, &newImplInfoArray));
   179     CleanupStack::PushL(TCleanupItem(CleanupResetAndDestroy, &newImplInfoArray));
   154 
   180 
   259     delete iFactoryTempPtr;
   285     delete iFactoryTempPtr;
   260     iFactoryTempPtr = NULL;
   286     iFactoryTempPtr = NULL;
   261    }
   287    }
   262 
   288 
   263 // ---------------------------------------------------------------------------
   289 // ---------------------------------------------------------------------------
       
   290 // CCCAppPluginLoader::IsSimStoreUri
       
   291 // Determine whether a Contact Store URI is SIM Card storage.
       
   292 // ---------------------------------------------------------------------------
       
   293 //
       
   294 TBool CCCAppPluginLoader::IsSimStoreUri( const TVPbkContactStoreUriPtr& aUri ) const
       
   295     {
       
   296     TBool isSimUri(EFalse);
       
   297 
       
   298     isSimUri = !aUri.Compare(VPbkContactStoreUris::SimGlobalAdnUri(),
       
   299                     TVPbkContactStoreUriPtr::EContactStoreUriAllComponents) ||
       
   300                !aUri.Compare(VPbkContactStoreUris::SimGlobalFdnUri(),
       
   301                     TVPbkContactStoreUriPtr::EContactStoreUriAllComponents) ||
       
   302                !aUri.Compare(VPbkContactStoreUris::SimGlobalSdnUri(),
       
   303                     TVPbkContactStoreUriPtr::EContactStoreUriAllComponents) ||
       
   304                !aUri.Compare(VPbkContactStoreUris::SimGlobalOwnNumberUri(),
       
   305                     TVPbkContactStoreUriPtr::EContactStoreUriAllComponents);
       
   306     return isSimUri;
       
   307     }
       
   308 
       
   309 // ---------------------------------------------------------------------------
       
   310 // CCCAppPluginLoader::IsCurrentContactStoreSupportL
       
   311 // Determine whether an implementation plug-in is supported by Current Contact Store. 
       
   312 // ---------------------------------------------------------------------------
       
   313 //
       
   314 TBool CCCAppPluginLoader::IsCurrentContactStoreSupportL( const TInt& aImplmentationUid ) const
       
   315     {
       
   316     TBool isCurrentContactStoreSupport(ETrue);
       
   317 
       
   318     if( ( KCCADetailsViewPluginImplmentationUid != aImplmentationUid )
       
   319             && ( KCCACommLauncherPluginImplmentationUid != aImplmentationUid )
       
   320             && ( KCCAMyCardPluginImplmentationUid != aImplmentationUid ) )
       
   321         {
       
   322         MVPbkContactLink* link = NULL;
       
   323         MVPbkContactLinkArray* contactArray = NULL;
       
   324         HBufC& contactData = iAppEngine->Parameter().ContactDataL();
       
   325         HBufC8* contactData8 = HBufC8::NewLC(contactData.Size());
       
   326         TPtr8 contactData8Ptr(contactData8->Des());
       
   327         contactData8Ptr.Copy(contactData.Des());
       
   328           
       
   329         contactArray = iAppServices->ContactManager().CreateLinksLC(contactData8Ptr);
       
   330 
       
   331         if (contactArray->Count() > 0)
       
   332             {
       
   333             link = contactArray->At(0).CloneLC();
       
   334             }
       
   335 
       
   336         if (link)
       
   337             {
       
   338             const MVPbkContactStoreProperties& storeProperties =
       
   339                     link->ContactStore().StoreProperties();
       
   340             TVPbkContactStoreUriPtr uri = storeProperties.Uri();
       
   341             isCurrentContactStoreSupport = !IsSimStoreUri( uri );
       
   342             }
       
   343             
       
   344 
       
   345         if( link )
       
   346             {
       
   347             CleanupStack::PopAndDestroy(); //link
       
   348             }
       
   349         if( contactArray )
       
   350             {
       
   351             CleanupStack::PopAndDestroy(); //contactArray
       
   352             }
       
   353 
       
   354         CleanupStack::PopAndDestroy(); //contactData8
       
   355         }
       
   356 
       
   357     return isCurrentContactStoreSupport;
       
   358     }
       
   359 
       
   360 // ---------------------------------------------------------------------------
       
   361 // CCCAppPluginLoader::PreparePbk2ApplicationServicesL
       
   362 // ---------------------------------------------------------------------------
       
   363 //
       
   364 void CCCAppPluginLoader::PreparePbk2ApplicationServicesL()
       
   365     {   
       
   366     iCommandsResourceFile.OpenL(
       
   367         KPbk2RomFileDrive, KDC_RESOURCE_FILES_DIR, KPbk2CommandsDllResFileName );
       
   368     iUiControlsResourceFile.OpenL(
       
   369         KPbk2RomFileDrive, KDC_RESOURCE_FILES_DIR, KPbk2UiControlsDllResFileName );
       
   370     iCommonUiResourceFile.OpenL(
       
   371         KPbk2RomFileDrive, KDC_RESOURCE_FILES_DIR, KPbk2CommonUiDllResFileName );
       
   372 
       
   373     iAppServices = CPbk2ApplicationServices::InstanceL();
       
   374     }
       
   375 
       
   376 // ---------------------------------------------------------------------------
   264 // CCCAppPluginLoader::LoadAllPlugins
   377 // CCCAppPluginLoader::LoadAllPlugins
   265 // ---------------------------------------------------------------------------
   378 // ---------------------------------------------------------------------------
   266 //
   379 //
   267 void CCCAppPluginLoader::LoadAllPlugins(
   380 void CCCAppPluginLoader::LoadAllPlugins(
   268         const RArray<TCCAPluginsOrderInfo>& aPluginOrderInfoArray, const TDesC8& aPluginProperties )
   381         const RArray<TCCAPluginsOrderInfo>& aPluginOrderInfoArray, const TDesC8& aPluginProperties )
   271 
   384 
   272     const TInt count = aPluginOrderInfoArray.Count();
   385     const TInt count = aPluginOrderInfoArray.Count();
   273     CCA_DP( KCCAppLogFile, CCA_L("::LoadAllPlugins - plugin count: %d"), count );
   386     CCA_DP( KCCAppLogFile, CCA_L("::LoadAllPlugins - plugin count: %d"), count );
   274     for ( TInt i = 0; i < count; ++i )
   387     for ( TInt i = 0; i < count; ++i )
   275         {
   388         {
       
   389         TInt tempImplmentationUid = aPluginOrderInfoArray[i].iPluginInfor->ImplementationUid().iUid;
       
   390         TBool isCurrentContactStoreSupport = EFalse;
       
   391         TRAPD( err, isCurrentContactStoreSupport = IsCurrentContactStoreSupportL( tempImplmentationUid ) );
       
   392         if( err != KErrNone || !isCurrentContactStoreSupport )
       
   393             {
       
   394             /* If problems with Contact Link related operations or the Contact Link is in SIM Store,
       
   395              * don't load current plugin. Just continuing
       
   396              * to load the next one. */
       
   397             continue;
       
   398             }
   276         /* If problems with plugin loading, that plugin is
   399         /* If problems with plugin loading, that plugin is
   277          * not included to the plugin array. Just continuing
   400          * not included to the plugin array. Just continuing
   278          * and trying to load the next one. */
   401          * and trying to load the next one. */
   279         TRAP_IGNORE( CheckAndLoadPluginL(
   402         TRAP_IGNORE( CheckAndLoadPluginL(
   280                 aPluginOrderInfoArray[i], aPluginProperties ));
   403                 aPluginOrderInfoArray[i], aPluginProperties ));