phoneuis/easydialing/src/easydialingcontactdatamanager.cpp
branchRCL_3
changeset 23 40a3f856b14d
parent 20 3c221667e687
equal deleted inserted replaced
22:94dc1107e8b2 23:40a3f856b14d
    19 #include <fbs.h>
    19 #include <fbs.h>
    20 #include <CPbk2ImageManager.h>
    20 #include <CPbk2ImageManager.h>
    21 #include <CVPbkContactManager.h>
    21 #include <CVPbkContactManager.h>
    22 #include <MVPbkContactStoreList.h>
    22 #include <MVPbkContactStoreList.h>
    23 #include <MVPbkContactLink.h>
    23 #include <MVPbkContactLink.h>
       
    24 #include <CPbk2StoreConfiguration.h>
       
    25 #include <CVPbkContactStoreUriArray.h>
    24 #include <VPbkContactStoreUris.h>
    26 #include <VPbkContactStoreUris.h>
    25 #include <TVPbkContactStoreUriPtr.h>
    27 #include <TVPbkContactStoreUriPtr.h>
    26 #include <CVPbkTopContactManager.h>
    28 #include <CVPbkTopContactManager.h>
    27 #include <MVPbkContactOperationBase.h>
    29 #include <MVPbkContactOperationBase.h>
    28 #include <TVPbkStoreContactAnalyzer.h>
    30 #include <TVPbkStoreContactAnalyzer.h>
    29 #include <MVPbkFieldType.h>
    31 #include <MVPbkFieldType.h>
    30 #include <VPbkEng.rsg>
    32 #include <VPbkEng.rsg>
    31 
       
    32 #include <MVPbkContactViewBase.h>
    33 #include <MVPbkContactViewBase.h>
    33 #include <MVPbkBaseContactFieldCollection.h>
    34 #include <MVPbkBaseContactFieldCollection.h>
    34 #include <MVPbkContactFieldTextData.h>
    35 #include <MVPbkContactFieldTextData.h>
    35 #include <MVPbkContactFieldData.h>
    36 #include <MVPbkContactFieldData.h>
    36 
       
    37 #include <CVPbkContactLinkArray.h>
    37 #include <CVPbkContactLinkArray.h>
    38 #include <MVPbkContactLink.h>
    38 #include <MVPbkContactLink.h>
    39 #include <MVPbkContactOperationBase.h>
    39 #include <MVPbkContactOperationBase.h>
    40 #include <MVPbkOperationObserver.h>
    40 #include <MVPbkOperationObserver.h>
    41 #include <MVPbkContactStore.h>          // MVPbkContactStore
    41 #include <MVPbkContactStore.h>
       
    42 #include <MVPbkContactStoreProperties.h>
    42 #include <MVPbkStoreContact.h>
    43 #include <MVPbkStoreContact.h>
       
    44 #include <PbkGlobalSettingFactory.h>
    43 #include <centralrepository.h>
    45 #include <centralrepository.h>
    44 
       
    45 #include <PbkGlobalSettingFactory.h>
       
    46 
    46 
    47 #include "easydialingcontactdata.h"
    47 #include "easydialingcontactdata.h"
    48 #include "easydialingcontactdatamanager.h"
    48 #include "easydialingcontactdatamanager.h"
    49 #include "easydialingutils.h"
    49 #include "easydialingutils.h"
    50 #include "mcontactdatamanagerobserver.h"
    50 #include "mcontactdatamanagerobserver.h"
    51 #include "easydialingcrkeys.h"
    51 #include "easydialingcrkeys.h"
    52 #include "easydialinglogger.h"
    52 #include "easydialinglogger.h"
    53 
    53 
    54 // ---------------------------------------------------------------------------
    54 // ---------------------------------------------------------------------------
       
    55 // CEasyDialingContactDataManager::NewL
       
    56 // ---------------------------------------------------------------------------
       
    57 //
       
    58 CEasyDialingContactDataManager* CEasyDialingContactDataManager::NewL()
       
    59     {
       
    60     CEasyDialingContactDataManager* self = 
       
    61             new ( ELeave ) CEasyDialingContactDataManager();
       
    62     CleanupStack::PushL( self );
       
    63     self->ConstructL();
       
    64     CleanupStack::Pop( self );
       
    65     return self;
       
    66     }
       
    67 
       
    68 // ---------------------------------------------------------------------------
    55 // CEasyDialingContactDataManager::CEasyDialingContactDataManager
    69 // CEasyDialingContactDataManager::CEasyDialingContactDataManager
    56 // ---------------------------------------------------------------------------
    70 // ---------------------------------------------------------------------------
    57 //
    71 //
    58 CEasyDialingContactDataManager::CEasyDialingContactDataManager(CVPbkContactManager* aContactManager)
    72 CEasyDialingContactDataManager::CEasyDialingContactDataManager()
    59         : iImageOperation(NULL), iContactManager(aContactManager), iContactOperation(NULL),
    73         : iPbkStoreConfiguration(NULL), 
    60           iContactThumbnailSetting(ETrue), iStoreReady(EFalse)
    74           iImageOperation(NULL), 
       
    75           iContactManager(NULL), 
       
    76           iContactOperation(NULL),
       
    77           iContactThumbnailSetting(ETrue), 
       
    78           iStoreReady(EFalse)
    61     {
    79     {
    62     }
    80     }
    63 
    81 
    64 
    82 
    65 // ---------------------------------------------------------------------------
    83 // ---------------------------------------------------------------------------
    74     delete iImageManager;
    92     delete iImageManager;
    75     delete iVPbkTopContactManager;
    93     delete iVPbkTopContactManager;
    76     delete iImageOperation;
    94     delete iImageOperation;
    77     delete iContactOperation;
    95     delete iContactOperation;
    78     delete iFavsView;
    96     delete iFavsView;
    79     if (iContactStore)
    97 
    80         {
    98     if ( iContactManager )
    81         iContactStore->Close( *this);
    99         {
    82         }
   100         TRAP_IGNORE( iContactManager->ContactStoresL().CloseAll( *this ) );
    83     
   101         }
       
   102     delete iContactManager;
       
   103     
       
   104     if ( iPbkStoreConfiguration )
       
   105         {
       
   106         iPbkStoreConfiguration->RemoveObserver( *this );
       
   107         }
       
   108     delete iPbkStoreConfiguration;
       
   109 
    84     if ( iPbkSettings )
   110     if ( iPbkSettings )
    85         {
   111         {
    86         iPbkSettings->Close();
   112         iPbkSettings->Close();
    87         }
   113         }
    88     delete iPbkSettings;
   114     delete iPbkSettings;
    92 // CEasyDialingContactDataManager::ConstructL
   118 // CEasyDialingContactDataManager::ConstructL
    93 // ---------------------------------------------------------------------------
   119 // ---------------------------------------------------------------------------
    94 //
   120 //
    95 void CEasyDialingContactDataManager::ConstructL()
   121 void CEasyDialingContactDataManager::ConstructL()
    96     {
   122     {
       
   123     // Create contact store configuration handler
       
   124     iPbkStoreConfiguration = CPbk2StoreConfiguration::NewL();
       
   125     iPbkStoreConfiguration->AddObserverL( *this );
       
   126     
       
   127     // Create manager for all the supported contact stores
       
   128     CVPbkContactStoreUriArray* supportedStores = 
       
   129             iPbkStoreConfiguration->SupportedStoreConfigurationL();
       
   130     CleanupStack::PushL( supportedStores );
       
   131     iContactManager = CVPbkContactManager::NewL( *supportedStores );
       
   132     CleanupStack::PopAndDestroy( supportedStores );
       
   133     
       
   134     // Open the stores and start observing them
       
   135     iContactManager->ContactStoresL().OpenAllL( *this );
       
   136 
    97     iImageManager = CPbk2ImageManager::NewL(*iContactManager);
   137     iImageManager = CPbk2ImageManager::NewL(*iContactManager);
    98     
   138     
    99     TVPbkContactStoreUriPtr uri( VPbkContactStoreUris::DefaultCntDbUri() );
       
   100     iContactStore = iContactManager->ContactStoresL().Find( uri );
       
   101 
       
   102     iVPbkTopContactManager = CVPbkTopContactManager::NewL( *iContactManager );
   139     iVPbkTopContactManager = CVPbkTopContactManager::NewL( *iContactManager );
   103 
   140 
   104     iImageManagerParams.iFlags = TPbk2ImageManagerParams::EScaleImage | TPbk2ImageManagerParams::EKeepAspectRatio;
   141     iImageManagerParams.iFlags = TPbk2ImageManagerParams::EScaleImage | TPbk2ImageManagerParams::EKeepAspectRatio;
   105     iThumbnailFieldType = iContactManager->FieldTypes().Find( R_VPBK_FIELD_TYPE_THUMBNAILPIC );
   142     iThumbnailFieldType = iContactManager->FieldTypes().Find( R_VPBK_FIELD_TYPE_THUMBNAILPIC );
   106 
   143 
   107     // Open the store
       
   108     iContactStore->OpenL( *this );
       
   109     
       
   110     // Read easydialing setting from cenrep.
   144     // Read easydialing setting from cenrep.
   111     CRepository* cenrep = CRepository::NewL( KCRUidEasyDialSettings );
   145     CRepository* cenrep = CRepository::NewL( KCRUidEasyDialSettings );
   112     CleanupStack::PushL( cenrep );
   146     CleanupStack::PushL( cenrep );
   113     User::LeaveIfError( cenrep->Get( KEasyDialingContactThumbnails, iContactThumbnailSetting ) );
   147     User::LeaveIfError( cenrep->Get( KEasyDialingContactThumbnails, iContactThumbnailSetting ) );
   114     CleanupStack::PopAndDestroy( cenrep );
   148     CleanupStack::PopAndDestroy( cenrep );
   115     
   149     
       
   150     // Start observing Phoenbook setting for the name order
   116     iPbkSettings = PbkGlobalSettingFactory::CreatePersistentSettingL();
   151     iPbkSettings = PbkGlobalSettingFactory::CreatePersistentSettingL();
   117     iPbkSettings->ConnectL( MPbkGlobalSetting::EGeneralSettingCategory );
   152     iPbkSettings->ConnectL( MPbkGlobalSetting::EGeneralSettingCategory );
   118     iPbkSettings->RegisterObserverL( this );
   153     iPbkSettings->RegisterObserverL( this );
   119 
   154 
   120     // Get name order from Phonebook settings
   155     // Get name order from Phonebook settings
   121     UpdateNameOrderL();
   156     UpdateNameOrderL();
       
   157     
       
   158     // Check if store with favourites is configured to be searched.
       
   159     SetupFavStoreSearchedL();
   122     }
   160     }
   123 
   161 
   124 // ---------------------------------------------------------------------------
   162 // ---------------------------------------------------------------------------
   125 // CEasyDialingContactDataManager::SetObserver
   163 // CEasyDialingContactDataManager::SetObserver
   126 // ---------------------------------------------------------------------------
   164 // ---------------------------------------------------------------------------
   127 //
   165 //
   128 void CEasyDialingContactDataManager::SetObserver(MContactDataManagerObserver* aObserver)
   166 void CEasyDialingContactDataManager::SetObserver(MContactDataManagerObserver* aObserver)
   129     {
   167     {
   130     iObserver = aObserver;
   168     iObserver = aObserver;
       
   169     }
       
   170 
       
   171 // ---------------------------------------------------------------------------
       
   172 // CEasyDialingContactDataManager::ContactManager
       
   173 // ---------------------------------------------------------------------------
       
   174 //
       
   175 CVPbkContactManager& CEasyDialingContactDataManager::ContactManager()
       
   176     {
       
   177     return *iContactManager;
   131     }
   178     }
   132 
   179 
   133 // ---------------------------------------------------------------------------
   180 // ---------------------------------------------------------------------------
   134 // CEasyDialingContactDataManager::SetThumbnailSize
   181 // CEasyDialingContactDataManager::SetThumbnailSize
   135 // ---------------------------------------------------------------------------
   182 // ---------------------------------------------------------------------------
   159     
   206     
   160     LOGSTRING1("newIndex = %d", newIndex);
   207     LOGSTRING1("newIndex = %d", newIndex);
   161     if (newIndex == KErrNotFound)
   208     if (newIndex == KErrNotFound)
   162         {
   209         {
   163         MVPbkContactLink* newLink = aContact->CloneLC();
   210         MVPbkContactLink* newLink = aContact->CloneLC();
   164         CEasyDialingContactData *newThumbnail = new (ELeave) CEasyDialingContactData(newLink);
   211         CEasyDialingContactData* newData = new (ELeave) CEasyDialingContactData(newLink);
   165         CleanupStack::Pop(); // newLink
   212         CleanupStack::Pop(); // newLink
   166         newIndex = iContactDataArray.Count();
   213         newIndex = iContactDataArray.Count();
   167         CleanupStack::PushL(newThumbnail);
   214         CleanupStack::PushL(newData);
   168         iContactDataArray.AppendL(newThumbnail);
   215         iContactDataArray.AppendL(newData);
   169         CleanupStack::Pop(newThumbnail);
   216         CleanupStack::Pop(newData);
       
   217         SetStoreFlagsForContact(newData);
   170         }
   218         }
   171     
   219     
   172     iContactDataArray[ newIndex ]->SetFav( aFav );
   220     iContactDataArray[ newIndex ]->SetFav( aFav );
   173     
   221     
   174     HBufC* id = HBufC::NewL( sizeof(TInt) * 2 ); // space for hex representation of TInt
   222     HBufC* id = HBufC::NewL( sizeof(TInt) * 2 ); // space for hex representation of TInt
   177     LOGSTRING1("CEasyDialingContactDataManager: GetThumbnailIdL returns %S", id);
   225     LOGSTRING1("CEasyDialingContactDataManager: GetThumbnailIdL returns %S", id);
   178     return id;
   226     return id;
   179     }
   227     }
   180 
   228 
   181 // ---------------------------------------------------------------------------
   229 // ---------------------------------------------------------------------------
   182 // CEasyDialingContactDataManager::GetThumbnailAndFav 
   230 // CEasyDialingContactDataManager::IndexForId 
   183 // ---------------------------------------------------------------------------
   231 // ---------------------------------------------------------------------------
   184 //
   232 //
   185 TBool CEasyDialingContactDataManager::GetThumbnailAndFav(const TDesC& aId, CFbsBitmap*& aThumbnail, TBool& aFav)
   233 TInt CEasyDialingContactDataManager::IndexForId( const TDesC& aId ) const
   186     {
   234     {
   187     LOGSTRING("CEasyDialingContactDataManager: GetThumbnailAndFav");
       
   188     TUint idVal(0);
   235     TUint idVal(0);
   189     TLex lex(aId);
   236     TLex lex(aId);
   190     lex.Val(idVal, EHex);
   237     lex.Val(idVal, EHex);
       
   238     return idVal;
       
   239     }
       
   240 
       
   241 // ---------------------------------------------------------------------------
       
   242 // CEasyDialingContactDataManager::GetThumbnail 
       
   243 // ---------------------------------------------------------------------------
       
   244 //
       
   245 TBool CEasyDialingContactDataManager::GetThumbnail( TInt aIndex, CFbsBitmap*& aThumbnail )
       
   246     {
       
   247     LOGSTRING("CEasyDialingContactDataManager: GetThumbnail");
   191     
   248     
   192     TBool retVal;
   249     TBool retVal;
   193     
   250     
   194     CEasyDialingContactData* thumbnail = iContactDataArray[idVal];
   251     CEasyDialingContactData* contactData = iContactDataArray[aIndex];
   195     aFav = thumbnail->Fav();
   252     if ( contactData->IsLoaded() )
   196     if (thumbnail->IsLoaded())
   253         {
   197         {
   254         aThumbnail = contactData->Thumbnail();
   198         aThumbnail = thumbnail->Thumbnail();
       
   199         retVal = ETrue;
   255         retVal = ETrue;
   200         }
   256         }
   201     else
   257     else
   202         {
   258         {
   203         aThumbnail = NULL;
   259         aThumbnail = NULL;
   204         retVal = EFalse;
   260         retVal = EFalse;
   205         if (iWaitingContacts.Find(idVal) == KErrNotFound)
   261         if (iWaitingContacts.Find(aIndex) == KErrNotFound)
   206             {
   262             {
   207             LOGSTRING1("iWaitingContacts.Append %d", idVal);
   263             LOGSTRING1("iWaitingContacts.Append %d", aIndex);
   208             iWaitingContacts.Append(idVal);
   264             iWaitingContacts.Append(aIndex);
   209             TRAPD(err, LoadNextContactDataL());
   265             TRAPD(err, LoadNextContactDataL());
   210             if (err)
   266             if (err)
   211                 {
   267                 {
   212                 HandleError(err);
   268                 HandleError(err);
   213                 }
   269                 }
   214             }
   270             }
   215         }    
   271         }    
   216     LOGSTRING("CEasyDialingContactDataManager: GetThumbnailAndFav Exit");
   272     LOGSTRING("CEasyDialingContactDataManager: GetThumbnail Exit");
   217     return retVal;
   273     return retVal;
   218     }
   274     }
   219 
   275 
   220 // ---------------------------------------------------------------------------
   276 // ---------------------------------------------------------------------------
       
   277 // CEasyDialingContactDataManager::IsFav
       
   278 // ---------------------------------------------------------------------------
       
   279 //
       
   280 TBool CEasyDialingContactDataManager::IsFav( TInt aIndex ) const
       
   281     {
       
   282     CEasyDialingContactData* contactData = iContactDataArray[aIndex];
       
   283     return contactData->Fav();
       
   284     }
       
   285 
       
   286 // ---------------------------------------------------------------------------
       
   287 // CEasyDialingContactDataManager::IsSimContact
       
   288 // ---------------------------------------------------------------------------
       
   289 //
       
   290 TBool CEasyDialingContactDataManager::IsSimContact( TInt aIndex ) const
       
   291     {
       
   292     CEasyDialingContactData* contactData = iContactDataArray[aIndex];
       
   293     return contactData->IsSimContact();
       
   294     }
       
   295 
       
   296 // ---------------------------------------------------------------------------
       
   297 // CEasyDialingContactDataManager::IsSdnContact
       
   298 // ---------------------------------------------------------------------------
       
   299 //
       
   300 TBool CEasyDialingContactDataManager::IsSdnContact( TInt aIndex ) const
       
   301     {
       
   302     CEasyDialingContactData* contactData = iContactDataArray[aIndex];
       
   303     return contactData->IsSdnContact();
       
   304     }
       
   305 
       
   306 // ---------------------------------------------------------------------------
   221 // CEasyDialingContactDataManager::IsFavL
   307 // CEasyDialingContactDataManager::IsFavL
   222 // ---------------------------------------------------------------------------
   308 // ---------------------------------------------------------------------------
   223 //
   309 //
   224 TBool CEasyDialingContactDataManager::IsFavL( MVPbkContactLink* aLink )
   310 TBool CEasyDialingContactDataManager::IsFavL( MVPbkContactLink* aLink )
   225     {
   311     {
   237 // CEasyDialingContactDataManager::NumberOfFavsL
   323 // CEasyDialingContactDataManager::NumberOfFavsL
   238 // ---------------------------------------------------------------------------
   324 // ---------------------------------------------------------------------------
   239 //
   325 //
   240 TInt CEasyDialingContactDataManager::NumberOfFavsL()
   326 TInt CEasyDialingContactDataManager::NumberOfFavsL()
   241     {
   327     {
   242     if ( iFavsView && iFavsViewReady )
   328     if ( iFavsView && iFavsViewReady && iFavStoreSearched )
   243         {
   329         {
   244         return iFavsView->ContactCountL();
   330         return iFavsView->ContactCountL();
   245         }
   331         }
   246     else
   332     else
   247         {
   333         {
   253 // CEasyDialingContactDataManager::FavLinkLC
   339 // CEasyDialingContactDataManager::FavLinkLC
   254 // ---------------------------------------------------------------------------
   340 // ---------------------------------------------------------------------------
   255 //
   341 //
   256 MVPbkContactLink* CEasyDialingContactDataManager::FavLinkLC( TInt aIndex )
   342 MVPbkContactLink* CEasyDialingContactDataManager::FavLinkLC( TInt aIndex )
   257     {
   343     {
   258     if ( !iFavsView || !iFavsViewReady )
   344     if ( !iFavsView || !iFavsViewReady || !iFavStoreSearched )
   259         {
   345         {
   260         // LC function should not return normally unless it has actually
   346         // LC function should not return normally unless it has actually
   261         // put something to cleanup stack
   347         // put something to cleanup stack
   262         User::Leave( KErrNotFound );
   348         User::Leave( KErrNotFound );
   263         }
   349         }
   316     {
   402     {
   317     return iNameOrder;
   403     return iNameOrder;
   318     }
   404     }
   319 
   405 
   320 // ---------------------------------------------------------------------------
   406 // ---------------------------------------------------------------------------
       
   407 // CEasyDialingContactDataManager::GetCurrentStoreUrisL
       
   408 // ---------------------------------------------------------------------------
       
   409 //
       
   410 void CEasyDialingContactDataManager::GetCurrentStoreUrisL( RPointerArray<TDesC>& aUris )
       
   411     {
       
   412     CVPbkContactStoreUriArray* storeUris = iPbkStoreConfiguration->CurrentConfigurationL();
       
   413     CleanupStack::PushL( storeUris );
       
   414     for ( TInt i = 0 ; i < storeUris->Count() ; ++i )
       
   415         {
       
   416         HBufC* dbUri = (*storeUris)[i].UriDes().AllocLC();
       
   417         aUris.AppendL( dbUri );
       
   418         CleanupStack::Pop( dbUri );
       
   419         }
       
   420     CleanupStack::PopAndDestroy( storeUris );
       
   421     }
       
   422 
       
   423 // ---------------------------------------------------------------------------
   321 // CEasyDialingContactDataManager::Pause
   424 // CEasyDialingContactDataManager::Pause
   322 // ---------------------------------------------------------------------------
   425 // ---------------------------------------------------------------------------
   323 //
   426 //
   324 void CEasyDialingContactDataManager::Pause( TBool aPause )
   427 void CEasyDialingContactDataManager::Pause( TBool aPause )
   325     {
   428     {
   386     {
   489     {
   387     LOGSTRING("CEasyDialingContactDataManager: LoadNextContactDataL");
   490     LOGSTRING("CEasyDialingContactDataManager: LoadNextContactDataL");
   388     if ( !iImageOperation && !iContactOperation && iWaitingContacts.Count() && iStoreReady && !iPause )
   491     if ( !iImageOperation && !iContactOperation && iWaitingContacts.Count() && iStoreReady && !iPause )
   389         {
   492         {
   390         // first we need to load the contact item
   493         // first we need to load the contact item
   391         CEasyDialingContactData* tn = iContactDataArray[iWaitingContacts[0]];
   494         const TInt index( iWaitingContacts[0] );
   392         iContactOperation = iContactManager->RetrieveContactL( *(tn->ContactLink()), *this);
   495         
   393 
   496         if ( index >= 0 && index < iContactDataArray.Count() )
   394         if (!iContactOperation)
   497             {
   395             {
   498             CEasyDialingContactData* data = iContactDataArray[index];
   396             tn->LoadingComplete();
   499             iContactOperation = iContactManager->RetrieveContactL( *(data->ContactLink()), *this);
   397             RDebug::Print(_L("iWaitingContacts.Remove %d"), iWaitingContacts[0]);            
   500             if (!iContactOperation)
   398             iWaitingContacts.Remove(0);
   501                 {
   399             LoadNextContactDataL();
   502                 data->LoadingComplete();
   400             }
   503                 RDebug::Print(_L("iWaitingContacts.Remove %d"), iWaitingContacts[0]);
   401         }          
   504                 iWaitingContacts.Remove(0);
       
   505                 LoadNextContactDataL();
       
   506                 }
       
   507             }
       
   508         }
   402     LOGSTRING("CEasyDialingContactDataManager: LoadNextContactDataL Exit");
   509     LOGSTRING("CEasyDialingContactDataManager: LoadNextContactDataL Exit");
   403     }
   510     }
   404 
   511 
   405 // ---------------------------------------------------------------------------
   512 // ---------------------------------------------------------------------------
   406 // CEasyDialingContactDataManager::PbkImageGetComplete
   513 // CEasyDialingContactDataManager::PbkImageGetComplete
   408 // ---------------------------------------------------------------------------
   515 // ---------------------------------------------------------------------------
   409 //
   516 //
   410 void CEasyDialingContactDataManager::Pbk2ImageGetComplete(MPbk2ImageOperation& aOperation, CFbsBitmap* aBitmap)
   517 void CEasyDialingContactDataManager::Pbk2ImageGetComplete(MPbk2ImageOperation& aOperation, CFbsBitmap* aBitmap)
   411     {
   518     {
   412     LOGSTRING("CEasyDialingContactDataManager: Pbk2ImageGetComplete");
   519     LOGSTRING("CEasyDialingContactDataManager: Pbk2ImageGetComplete");
   413     TInt index = iWaitingContacts[0];
   520     TInt index( KErrNotFound );
   414     LOGSTRING1("iWaitingContacts.Remove %d", iWaitingContacts[0]);            
   521     if ( iWaitingContacts.Count() > 0 )
   415     iWaitingContacts.Remove(0);
   522         {
       
   523         index = iWaitingContacts[0];
       
   524         LOGSTRING1("iWaitingContacts.Remove %d", iWaitingContacts[0]);
       
   525         iWaitingContacts.Remove(0);
       
   526         }
       
   527     
   416     delete &aOperation;
   528     delete &aOperation;
   417     iImageOperation = NULL;
   529     iImageOperation = NULL;
   418     delete iStoreContact;
   530     delete iStoreContact;
   419     iStoreContact = NULL;
   531     iStoreContact = NULL;
   420         
   532         
   433 //
   545 //
   434 void CEasyDialingContactDataManager::Pbk2ImageGetFailed(MPbk2ImageOperation& aOperation, TInt /*aError*/)
   546 void CEasyDialingContactDataManager::Pbk2ImageGetFailed(MPbk2ImageOperation& aOperation, TInt /*aError*/)
   435     {
   547     {
   436     LOGSTRING("CEasyDialingContactDataManager: Pbk2ImageGetFailed");
   548     LOGSTRING("CEasyDialingContactDataManager: Pbk2ImageGetFailed");
   437     Pbk2ImageGetComplete(aOperation, NULL);
   549     Pbk2ImageGetComplete(aOperation, NULL);
       
   550     }
       
   551 
       
   552 // -----------------------------------------------------------------------------
       
   553 // ConfigurationChanged
       
   554 // From MPbk2StoreConfigurationObserver
       
   555 // Called when contact store configuration changes
       
   556 // -----------------------------------------------------------------------------
       
   557 //
       
   558 void CEasyDialingContactDataManager::ConfigurationChanged()
       
   559     {
       
   560     TRAP_IGNORE( SetupFavStoreSearchedL() );
       
   561     iObserver->StoreConfigurationChanged();
       
   562     }
       
   563 
       
   564 // -----------------------------------------------------------------------------
       
   565 // ConfigurationChangedComplete
       
   566 // From MPbk2StoreConfigurationObserver
       
   567 // Called when contact store configuration change has been informed to all
       
   568 // observers
       
   569 // -----------------------------------------------------------------------------
       
   570 //
       
   571 void CEasyDialingContactDataManager::ConfigurationChangedComplete()
       
   572     {
       
   573     // no implementation needed
   438     }
   574     }
   439 
   575 
   440 // ---------------------------------------------------------------------------
   576 // ---------------------------------------------------------------------------
   441 // CEasyDialingContactDataManager::SettingChangedL
   577 // CEasyDialingContactDataManager::SettingChangedL
   442 // From MPbkGlobalSettingObserver
   578 // From MPbkGlobalSettingObserver
   507 // ---------------------------------------------------------------------------
   643 // ---------------------------------------------------------------------------
   508 //
   644 //
   509 void CEasyDialingContactDataManager::DoHandleImageGetCompleteL(CFbsBitmap* aBitmap, TInt aIndex)
   645 void CEasyDialingContactDataManager::DoHandleImageGetCompleteL(CFbsBitmap* aBitmap, TInt aIndex)
   510     {
   646     {
   511     LOGSTRING("CEasyDialingContactDataManager: DoHandleImageGetCompleteL");
   647     LOGSTRING("CEasyDialingContactDataManager: DoHandleImageGetCompleteL");
   512     CEasyDialingContactData *tn = iContactDataArray[aIndex];
   648     if ( aIndex >= 0 && aIndex < iContactDataArray.Count() ) 
   513     tn->LoadingComplete();
   649         {
   514     if (aBitmap)
   650         CEasyDialingContactData* data = iContactDataArray[aIndex];
   515         {
   651         data->LoadingComplete();
   516         tn->SetThumbnail(aBitmap);
   652         if (aBitmap)
   517         }
   653             {
   518     
   654             data->SetThumbnail(aBitmap);
       
   655             }
       
   656         }
   519     LoadNextContactDataL();
   657     LoadNextContactDataL();
   520     InformObserver();
   658     InformObserver();
   521     LOGSTRING("CEasyDialingContactDataManager: DoHandleImageGetCompleteL Exit");
   659     LOGSTRING("CEasyDialingContactDataManager: DoHandleImageGetCompleteL Exit");
   522     }
   660     }
   523 
   661 
   554         // If the parsed index is valid, return the availability.
   692         // If the parsed index is valid, return the availability.
   555         ret = iContactDataArray[ aIndex ]->VoiceCallAvailable();
   693         ret = iContactDataArray[ aIndex ]->VoiceCallAvailable();
   556         }
   694         }
   557     
   695     
   558     LOGSTRING1("CEasyDialingContactDataManager: VoiceCallAvailable returns %d", ret);
   696     LOGSTRING1("CEasyDialingContactDataManager: VoiceCallAvailable returns %d", ret);
   559     return ret;    
   697     return ret;
   560     }
   698     }
   561 
   699 
   562 
   700 
   563 // ---------------------------------------------------------------------------
   701 // ---------------------------------------------------------------------------
   564 // CEasyDialingContactDataManager::VideoCallAvailable
   702 // CEasyDialingContactDataManager::VideoCallAvailable
   575         // If the parsed index is valid, return the availability.
   713         // If the parsed index is valid, return the availability.
   576         ret = iContactDataArray[ aIndex ]->VideoCallAvailable();
   714         ret = iContactDataArray[ aIndex ]->VideoCallAvailable();
   577         }
   715         }
   578     
   716     
   579     LOGSTRING1("CEasyDialingContactDataManager: VideoCallAvailable returns %d", ret);
   717     LOGSTRING1("CEasyDialingContactDataManager: VideoCallAvailable returns %d", ret);
   580     return ret;    
   718     return ret;
   581     }
   719     }
   582 
   720 
   583 
   721 
   584 // ---------------------------------------------------------------------------
   722 // ---------------------------------------------------------------------------
   585 // CEasyDialingContactDataManager::UniEditorAvailable
   723 // CEasyDialingContactDataManager::UniEditorAvailable
   596         // If the parsed index is valid, return the availability.
   734         // If the parsed index is valid, return the availability.
   597         ret = iContactDataArray[ aIndex ]->UniEditorAvailable();
   735         ret = iContactDataArray[ aIndex ]->UniEditorAvailable();
   598         }
   736         }
   599     
   737     
   600     LOGSTRING1("CEasyDialingContactDataManager: UniEditorAvailable returns %d", ret);
   738     LOGSTRING1("CEasyDialingContactDataManager: UniEditorAvailable returns %d", ret);
   601     return ret;    
   739     return ret;
   602     }
   740     }
   603 
   741 
   604 
   742 
   605 // ---------------------------------------------------------------------------
   743 // ---------------------------------------------------------------------------
   606 // CEasyDialingContactDataManager::ContactLinkLC
   744 // CEasyDialingContactDataManager::ContactLinkLC
   645     if ( iObserver )
   783     if ( iObserver )
   646         {
   784         {
   647         iObserver->AllContactDataLoaded();
   785         iObserver->AllContactDataLoaded();
   648         }
   786         }
   649     }
   787     }
   650     	
   788 
   651 // ---------------------------------------------------------------------------
   789 // ---------------------------------------------------------------------------
   652 // CEasyDialingContactDataManager::StoreReady
   790 // CEasyDialingContactDataManager::StoreReady
   653 // from MVPbkContactStoreObserver
   791 // from MVPbkContactStoreListObserver
   654 // Called when the contact store is ready to be used, signals
       
   655 // the next engine state.
       
   656 // @param aContactStore The store that is ready.
   792 // @param aContactStore The store that is ready.
   657 // ---------------------------------------------------------------------------
   793 // ---------------------------------------------------------------------------
   658 //
   794 //
   659 
       
   660 void CEasyDialingContactDataManager::StoreReady( MVPbkContactStore& /*aContactStore*/ )
   795 void CEasyDialingContactDataManager::StoreReady( MVPbkContactStore& /*aContactStore*/ )
   661     {
   796     {
   662     // next open the favourites view
   797     }
   663     TRAPD( err, iVPbkTopContactManager->GetTopContactsViewL( *this, *this ) );
   798 
   664     if ( err )
       
   665         {
       
   666         HandleError( err );
       
   667         }
       
   668     }
       
   669     
       
   670 // ---------------------------------------------------------------------------
   799 // ---------------------------------------------------------------------------
   671 // CEasyDialingContactDataManager::StoreUnavailable
   800 // CEasyDialingContactDataManager::StoreUnavailable
   672 // from MVPbkContactStoreObserver
   801 // from MVPbkContactStoreListObserver
   673 // Called when a contact store becomes unavailable.
   802 // Called when a contact store becomes unavailable.
   674 // @param aContactStore The store that became unavailable.
   803 // @param aContactStore The store that became unavailable.
   675 // @param aReason The reason why the store is unavailable.
   804 // @param aReason The reason why the store is unavailable.
   676 //                This is one of the system wide error codes.
   805 //                This is one of the system wide error codes.
   677 // ---------------------------------------------------------------------------
   806 // ---------------------------------------------------------------------------
   678 //
   807 //
   679 void CEasyDialingContactDataManager::StoreUnavailable( MVPbkContactStore& /*aContactStore*/,
   808 void CEasyDialingContactDataManager::StoreUnavailable( MVPbkContactStore& /*aContactStore*/,
   680         TInt /*aReason*/ )
   809         TInt /*aReason*/ )
   681     {
   810     {
   682     // Opening main contact database failed. Easydialing can operate without
   811     // Opening some contact database failed. Easydialing can operate without
   683     // it, but thumbnails and favourite stars can't be shown, and availability
   812     // any database connections, but thumbnails and favourite stars can't be 
   684     // of action menu items can't be checked.
   813     // shown, and availability of action menu items can't be checked.
   685     //   Of course, if easydialing can't open the database, probably PCSServer
   814     //   Of course, if easydialing can't open the database, probably PCSServer
   686     // can't open it either...
   815     // can't open it either...
   687     }
   816     }
   688 
   817 
   689 // ---------------------------------------------------------------------------
   818 // ---------------------------------------------------------------------------
   690 // CEasyDialingContactDataManager::HandleStoreEventL
   819 // CEasyDialingContactDataManager::HandleStoreEventL
   691 // from MVPbkContactStoreObserver
   820 // from MVPbkContactStoreListObserver
   692 // Called when changes occur in the contact store.
   821 // Called when changes occur in the contact store.
   693 // IGNORED.
   822 // IGNORED because ED plugin reacts to contact modifications by listening
       
   823 // to PCS cache update events.
   694 // @param aContactStore A store whose event it is.
   824 // @param aContactStore A store whose event it is.
   695 // @param aStoreEvent The event that has occurred.
   825 // @param aStoreEvent The event that has occurred.
   696 // ---------------------------------------------------------------------------
   826 // ---------------------------------------------------------------------------
   697 //
   827 //
   698 void CEasyDialingContactDataManager::HandleStoreEventL(MVPbkContactStore& /*aContactStore*/,
   828 void CEasyDialingContactDataManager::HandleStoreEventL( MVPbkContactStore& /*aContactStore*/,
   699         TVPbkContactStoreEvent /*aStoreEvent*/)
   829         TVPbkContactStoreEvent /*aStoreEvent*/ )
   700     {
   830     {
       
   831     }
       
   832 
       
   833 // -----------------------------------------------------------------------------
       
   834 // CEasyDialingPlugin::OpenComplete
       
   835 // From MVPbkContactStoreListObserver.
       
   836 // Called when all contact stores are ready to be used, signals
       
   837 // the next engine state.
       
   838 //
       
   839 // -----------------------------------------------------------------------------
       
   840 //
       
   841 void CEasyDialingContactDataManager::OpenComplete()
       
   842     {
       
   843     // next open the favourites view
       
   844     TRAPD( err, iVPbkTopContactManager->GetTopContactsViewL( *this, *this ) );
       
   845     if ( err )
       
   846         {
       
   847         HandleError( err );
       
   848         }
   701     }
   849     }
   702 
   850 
   703 // ---------------------------------------------------------------------------
   851 // ---------------------------------------------------------------------------
   704 // CEasyDialingContactDataManager::VPbkOperationFailed
   852 // CEasyDialingContactDataManager::VPbkOperationFailed
   705 // ---------------------------------------------------------------------------
   853 // ---------------------------------------------------------------------------
   709         TInt /*aError*/ )
   857         TInt /*aError*/ )
   710     {
   858     {
   711     // Loading list of favourite contacts failed.
   859     // Loading list of favourite contacts failed.
   712     // Continue as if none of the contacts are favourited.
   860     // Continue as if none of the contacts are favourited.
   713     delete iFavsOperation;
   861     delete iFavsOperation;
   714     iFavsOperation = NULL;        
   862     iFavsOperation = NULL;
   715     delete iFavsView;
   863     delete iFavsView;
   716     iFavsView = NULL;
   864     iFavsView = NULL;
   717     iFavsViewReady = EFalse;
   865     iFavsViewReady = EFalse;
   718 
   866 
   719     InitReady();
   867     InitReady();
   841         iStoreContact = aContact;
   989         iStoreContact = aContact;
   842         
   990         
   843         // Find out the available communication methods for the contact.
   991         // Find out the available communication methods for the contact.
   844         GetAvailableServicesL( aContact, aIndex );
   992         GetAvailableServicesL( aContact, aIndex );
   845         
   993         
   846                 
       
   847         // Next initiate async thumbnail get operation.
   994         // Next initiate async thumbnail get operation.
   848         
   995         
   849         if(GetContactThumbnailSetting()) // reads the iContactThumbnailSetting value if it is false we dont fetch images
   996         if (GetContactThumbnailSetting()) // reads the iContactThumbnailSetting value if it is false we dont fetch images
   850             {
   997             {
   851             if (iImageManager->HasImage(*iStoreContact, *iThumbnailFieldType))
   998             if (iImageManager->HasImage(*iStoreContact, *iThumbnailFieldType))
   852                 {
   999                 {
   853                 iImageOperation = iImageManager->GetImageAsyncL(
  1000                 iImageOperation = iImageManager->GetImageAsyncL(
   854                         &iImageManagerParams,
  1001                         &iImageManagerParams,
   859             }
  1006             }
   860         if (!iImageOperation)
  1007         if (!iImageOperation)
   861             {
  1008             {
   862             CEasyDialingContactData *tn = iContactDataArray[aIndex];
  1009             CEasyDialingContactData *tn = iContactDataArray[aIndex];
   863             tn->LoadingComplete();
  1010             tn->LoadingComplete();
   864             LOGSTRING1("iWaitingContacts.Remove %d", iWaitingContacts[0]);            
  1011             LOGSTRING1("iWaitingContacts.Remove %d", iWaitingContacts[0]);
   865             iWaitingContacts.Remove(0);
  1012             iWaitingContacts.Remove(0);
   866             delete iStoreContact;
  1013             delete iStoreContact;
   867             iStoreContact = NULL;
  1014             iStoreContact = NULL;
   868             LoadNextContactDataL();
  1015             LoadNextContactDataL();
   869             InformObserver();
  1016             InformObserver();
   870             }
  1017             }
   871         }
  1018         }
   872     else
  1019     else
   873         {
  1020         {
   874         // Opening contact failed. Mark contact data loaded, so it's not opened again.
  1021         // Opening contact failed. Mark contact data loaded, so it's not opened again.
   875         CEasyDialingContactData *tn = iContactDataArray[aIndex];
  1022         CEasyDialingContactData* data = iContactDataArray[aIndex];
   876         tn->LoadingComplete();
  1023         data->LoadingComplete();
   877         LOGSTRING1("iWaitingContacts.Remove %d", iWaitingContacts[0]);            
  1024         LOGSTRING1("iWaitingContacts.Remove %d", iWaitingContacts[0]);
   878         iWaitingContacts.Remove(0);
  1025         iWaitingContacts.Remove(0);
   879         LoadNextContactDataL();
  1026         LoadNextContactDataL();
   880         InformObserver();
  1027         InformObserver();
   881         }
  1028         }
   882     LOGSTRING("CEasyDialingContactDataManager: DoHandleContactOperationCompleteL Exit");
  1029     LOGSTRING("CEasyDialingContactDataManager: DoHandleContactOperationCompleteL Exit");
   922         MVPbkStoreContact* aContact )
  1069         MVPbkStoreContact* aContact )
   923     {
  1070     {
   924     LOGSTRING("CEasyDialingContactDataManager: VPbkSingleContactOperationComplete");
  1071     LOGSTRING("CEasyDialingContactDataManager: VPbkSingleContactOperationComplete");
   925     delete &aOperation;
  1072     delete &aOperation;
   926     iContactOperation = NULL;
  1073     iContactOperation = NULL;
   927     TInt index = iWaitingContacts[0];
  1074     if ( iWaitingContacts.Count() > 0 )
   928     LOGSTRING1("VPbkSingleContactOperationComplete, Index=%d", index);
  1075         {
   929     TRAPD(err, DoHandleContactOperationCompleteL(aContact, index));
  1076         TInt index = iWaitingContacts[0];
   930     if (err)
  1077         LOGSTRING1("VPbkSingleContactOperationComplete, Index=%d", index);
   931         {
  1078         TRAPD(err, DoHandleContactOperationCompleteL(aContact, index));
   932         HandleError(err);
  1079         if ( err )
   933         }
  1080             {
       
  1081             HandleError(err);
       
  1082             }
       
  1083         }
       
  1084     
   934     LOGSTRING("CEasyDialingContactDataManager: VPbkSingleContactOperationComplete Exit");
  1085     LOGSTRING("CEasyDialingContactDataManager: VPbkSingleContactOperationComplete Exit");
   935     }
  1086     }
   936 
  1087 
   937 // ---------------------------------------------------------------------------
  1088 // ---------------------------------------------------------------------------
   938 // CEasyDialingContactDataManager::VPbkSingleContactOperationFailed
  1089 // CEasyDialingContactDataManager::VPbkSingleContactOperationFailed
   997         {
  1148         {
   998         iContactDataArray[ i ]->DeleteThumbnail();
  1149         iContactDataArray[ i ]->DeleteThumbnail();
   999         }
  1150         }
  1000     }
  1151     }
  1001 
  1152 
       
  1153 // ---------------------------------------------------------------------------
       
  1154 // CEasyDialingContactDataManager::SetupFavStoreSearchedL
       
  1155 // ---------------------------------------------------------------------------
       
  1156 //
       
  1157 void CEasyDialingContactDataManager::SetupFavStoreSearchedL()
       
  1158     {
       
  1159     // Check if favourite contact store (i.e. the default contact store) is one
       
  1160     // of the stores configured to be searched.
       
  1161     CVPbkContactStoreUriArray* storeUris = 
       
  1162             iPbkStoreConfiguration->CurrentConfigurationL();
       
  1163     iFavStoreSearched = 
       
  1164             storeUris->IsIncluded( VPbkContactStoreUris::DefaultCntDbUri() );
       
  1165     delete storeUris;
       
  1166     }
       
  1167 
       
  1168 // ---------------------------------------------------------------------------
       
  1169 // CEasyDialingContactDataManager::SetStoreFlagsForContact
       
  1170 // ---------------------------------------------------------------------------
       
  1171 //
       
  1172 void CEasyDialingContactDataManager::SetStoreFlagsForContact( 
       
  1173         CEasyDialingContactData* aContactData ) const
       
  1174     {
       
  1175     MVPbkContactLink* link = aContactData->ContactLink();
       
  1176     const TDesC& uri = link->ContactStore().StoreProperties().Uri().UriDes();
       
  1177     
       
  1178     TBool isSim = ( uri.Compare( VPbkContactStoreUris::SimGlobalAdnUri() ) == 0 );
       
  1179     aContactData->SetSimContact( isSim );
       
  1180     
       
  1181     TBool isSdn = ( uri.Compare( VPbkContactStoreUris::SimGlobalSdnUri() ) == 0 );
       
  1182     aContactData->SetSdnContact( isSdn );
       
  1183     }
       
  1184 
  1002 
  1185 
  1003 //  End of File
  1186 //  End of File
  1004 
  1187