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