uiservicetab/vimpststorage/src/cvimpststoragevpbkserverstore.cpp
changeset 0 5e5d6b214f4f
child 9 9fdee5e1da30
equal deleted inserted replaced
-1:000000000000 0:5e5d6b214f4f
       
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Class that provides handling of vpbk server store
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "cvimpststoragevpbkserverstore.h"
       
    22 
       
    23 #include "cvimpststoragevpbkstorehandler.h"
       
    24 
       
    25 #include <MVPbkContactView.h>
       
    26 #include <CVPbkContactIdConverter.h>
       
    27 #include "vimpstdebugtrace.h" 
       
    28 #include "tvimpstconsts.h"
       
    29 #include "mvimpststorageserviceview.h"
       
    30 #include <CVPbkContactLinkArray.h>
       
    31 #include <MVPbkContactLink.h>
       
    32 #include "cvimpststoragecontact.h"
       
    33 
       
    34 // ================= MEMBER FUNCTIONS =======================
       
    35 
       
    36 // ---------------------------------------------------------------------------
       
    37 // CVIMPSTStorageVPbkServerStore::
       
    38 //      CVIMPSTStorageVPbkServerStore
       
    39 // ---------------------------------------------------------------------------
       
    40 //
       
    41 CVIMPSTStorageVPbkServerStore:: CVIMPSTStorageVPbkServerStore( MVIMPSTStorageServiceCacheWriter& aServiceCacheWriter ):
       
    42     CActive( CActive::EPriorityIdle ),
       
    43     iServiceCacheWriter( aServiceCacheWriter ),
       
    44     iFetchStep( EFetchingUnknown )
       
    45     { 
       
    46     TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::CVIMPSTStorageVPbkServerStore()" )); 
       
    47     CActiveScheduler::Add( this );
       
    48     }
       
    49 
       
    50 // ---------------------------------------------------------------------------
       
    51 // CVIMPSTStorageVPbkServerStore::ConstructL
       
    52 // ---------------------------------------------------------------------------
       
    53 //
       
    54 void CVIMPSTStorageVPbkServerStore::ConstructL( const TDesC& aContactDb, const TDesC& aServiceName)
       
    55     {
       
    56     TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::ConstructL() begin" ));
       
    57     iVPbkStoreHandler = CVIMPSTStorageVPbkStoreHandler::NewL( aContactDb,aServiceName, *this, EFalse );
       
    58     TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::ConstructL() end"));
       
    59     }
       
    60 
       
    61 // ---------------------------------------------------------------------------
       
    62 // CVIMPSTStorageVPbkServerStore::NewL
       
    63 // ---------------------------------------------------------------------------
       
    64 //
       
    65 CVIMPSTStorageVPbkServerStore* 
       
    66     CVIMPSTStorageVPbkServerStore::NewL( const TDesC& aContactDb,
       
    67     									 const TDesC& aServiceName,
       
    68     									MVIMPSTStorageServiceCacheWriter& aServiceCacheWriter )
       
    69     {
       
    70     TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::NewL() begin" ));
       
    71     CVIMPSTStorageVPbkServerStore* self = NewLC( aContactDb, 
       
    72     											 aServiceName, 
       
    73     											 aServiceCacheWriter );
       
    74     CleanupStack::Pop( self );
       
    75     TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::NewL() end" ));
       
    76     return self;
       
    77     
       
    78     }
       
    79 
       
    80 // ---------------------------------------------------------------------------
       
    81 // CVIMPSTStorageVPbkServerStore::NewLC
       
    82 // ---------------------------------------------------------------------------
       
    83 //
       
    84 CVIMPSTStorageVPbkServerStore* 
       
    85     CVIMPSTStorageVPbkServerStore::NewLC(const TDesC& aContactDb,
       
    86     									const TDesC& aServiceName,
       
    87     									MVIMPSTStorageServiceCacheWriter& aServiceCacheWriter )
       
    88     {
       
    89     TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::NewLC() begin" ));
       
    90     CVIMPSTStorageVPbkServerStore* self =
       
    91         new (ELeave) CVIMPSTStorageVPbkServerStore(aServiceCacheWriter);
       
    92     CleanupStack::PushL( self );
       
    93     self->ConstructL( aContactDb,aServiceName );
       
    94     TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::NewLC() end" ));
       
    95     return self;    
       
    96     }
       
    97 
       
    98 // ---------------------------------------------------------------------------
       
    99 // CVIMPSTStorageVPbkServerStore::
       
   100 //      ~CVIMPSTStorageVPbkServerStore
       
   101 // ---------------------------------------------------------------------------
       
   102 //
       
   103 CVIMPSTStorageVPbkServerStore::~CVIMPSTStorageVPbkServerStore()
       
   104     {
       
   105     TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::~CVIMPSTStorageVPbkServerStore() begin"));
       
   106     iRetrivedXSPIdArray.ResetAndDestroy();
       
   107     TRAP_IGNORE( ResetAndDestroyLocalArrayL() );
       
   108     delete iVPbkStoreHandler;
       
   109     TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::~CVIMPSTStorageVPbkServerStore() end"));
       
   110     }
       
   111 
       
   112  // ---------------------------------------------------------------------------
       
   113 // CVIMPSTStorageVPbkServerStore::ResetAndDestroyLocalArrayL
       
   114 // ---------------------------------------------------------------------------
       
   115 //
       
   116 void CVIMPSTStorageVPbkServerStore::ResetAndDestroyLocalArrayL()
       
   117     {
       
   118     TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::ResetAndDestroyLocalArrayL() begin") );
       
   119     TInt count = iFetchContactsToBeAdded.Count();
       
   120    	while( count )
       
   121 	   	{
       
   122 	   	TVIMPSTContactInfo contactInf = iFetchContactsToBeAdded[ count-1 ];
       
   123 	   	iFetchContactsToBeAdded.Remove( count-1 );
       
   124 		delete contactInf.iUserId;
       
   125 		contactInf.iUserId = NULL;	
       
   126 		delete contactInf.iDisplayName;
       
   127 		contactInf.iDisplayName = NULL;				         
       
   128          // not exist need to add 
       
   129         iFetchContactsToBeAdded.Compress();	
       
   130         count = iFetchContactsToBeAdded.Count();
       
   131 	   	}
       
   132 	iFetchContactsToBeAdded.Reset();
       
   133     TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::ResetAndDestroyLocalArrayL() end") );
       
   134     }
       
   135 // ----------------------------------------------------------
       
   136 // CVIMPSTStorageVPbkServerStore::LocalStore
       
   137 // ----------------------------------------------------------
       
   138 //
       
   139 TBool CVIMPSTStorageVPbkServerStore::LocalStore() const 
       
   140 	{
       
   141 	TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::LocalStore Function begin") );
       
   142 	TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::LocalStore Function End") );
       
   143 	return EFalse;	
       
   144 	}
       
   145 
       
   146 // ---------------------------------------------------------------------------
       
   147 // CVIMPSTStorageVPbkServerStore::HandleVPbkStoreEventL
       
   148 // ---------------------------------------------------------------------------
       
   149 //
       
   150 void CVIMPSTStorageVPbkServerStore::HandleVPbkStoreEventL(TVIMPSTVPbkStoreEvent aVPbkStoreEvent) 
       
   151     {
       
   152     TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::HandleVPbkStoreEventL() begin") );
       
   153     switch( aVPbkStoreEvent.iEventType )
       
   154         {
       
   155         case EVPbkContactReadCompleted:
       
   156             {
       
   157             TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::HandleVPbkStoreEventL() EVPbkContactReadCompleted started") );
       
   158             iServiceCacheWriter.NotifyServiceViewL(TVIMPSTEnums::EStorageContactReadComplete);
       
   159             if( iFetchStep == EFetchingCalled )
       
   160                 {
       
   161                 TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::HandleVPbkStoreEventL() EVPbkContactReadCompleted fetcing in progress ") );
       
   162                 IssueRequest();		
       
   163                 }
       
   164             TRACE( T_LIT("iFetchStep set to state EContactReadComplete") );
       
   165             iFetchStep = EContactReadComplete;
       
   166             TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::HandleVPbkStoreEventL completed")  );
       
   167             break;
       
   168             }
       
   169         case EVPbkContactReading:
       
   170             {
       
   171             TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::HandleVPbkStoreEventL EVPbkContactReading started") );
       
   172              // a contact entry has been created in virtual database store
       
   173             // create the cache contact
       
   174             // fetched one by one contact from cdb file
       
   175             // Add to storage cache
       
   176             
       
   177             iServiceCacheWriter.AddContactToCacheL(*aVPbkStoreEvent.iContactLink , 
       
   178                     aVPbkStoreEvent.iUserId ,
       
   179                     aVPbkStoreEvent.iDisplayName ,
       
   180                     aVPbkStoreEvent.iAvatarContent,
       
   181                     TVIMPSTEnums::EStorageContactReading  );
       
   182             TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::HandleVPbkStoreEventL EVPbkContactReading completed" ) );
       
   183 		    break;	
       
   184 		    }
       
   185         case EVPbkContactFetching:
       
   186         case EVPbkContactAdded:
       
   187             {
       
   188             TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::HandleVPbkStoreEventL EVPbkContactAdded or EVPbkContactFetching" ) );
       
   189             TVIMPSTEnums::TVIMPSTStorgaeEventType event = TVIMPSTEnums::EStorageEventContactAddition;
       
   190             // a contact entry has been created in virtual database store
       
   191             // create the cache contact
       
   192             // fetched one by one contact from cdb file
       
   193             // Add to storage cache
       
   194             if( iFetchStep == EFetchingOn )
       
   195                 {
       
   196                 event = TVIMPSTEnums::EStorageContactFetching;
       
   197                 } 
       
   198             iServiceCacheWriter.AddContactToCacheL(*aVPbkStoreEvent.iContactLink , 
       
   199                     aVPbkStoreEvent.iUserId ,
       
   200                     aVPbkStoreEvent.iDisplayName ,
       
   201                     aVPbkStoreEvent.iAvatarContent,
       
   202                     event );
       
   203             if(iFetchStep == EFetchingOn)			
       
   204                 {
       
   205                 TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::HandleVPbkStoreEventL EVPbkContactAdded or EVPbkContactFetching fetchin on" ) );
       
   206                 IssueRequest();
       
   207                 }
       
   208             TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::HandleVPbkStoreEventL EVPbkContactAdded or EVPbkContactFetching completed" ) );
       
   209             break;	
       
   210             }
       
   211         case EVPbkContactSynchronizing:
       
   212             {
       
   213             TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::HandleVPbkStoreEventL EVPbkContactSynchronizing " ) );
       
   214             // a contact entry has been created in virtual database store
       
   215             // create the cache contact
       
   216             // fetched one by one contact from cdb file
       
   217             // Add to storage cache
       
   218             iServiceCacheWriter.AddContactToCacheL(*aVPbkStoreEvent.iContactLink , 
       
   219                     aVPbkStoreEvent.iUserId ,
       
   220                     aVPbkStoreEvent.iDisplayName ,
       
   221                     aVPbkStoreEvent.iAvatarContent,
       
   222                     TVIMPSTEnums::EStorageContactSynchronizing );
       
   223             TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::HandleVPbkStoreEventL EVPbkContactSynchronizing(iFetchStep): %d " ), iFetchStep );
       
   224             if(iFetchStep == EFetchingOn)          
       
   225                    {
       
   226                    TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::HandleVPbkStoreEventL  EVPbkContactSynchronizing fetchin on" ) );
       
   227                    IssueRequest();
       
   228                    }
       
   229             TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::HandleVPbkStoreEventL EVPbkContactSynchronizing completed" ) );
       
   230             break;
       
   231             }
       
   232         case EVPbkContactDeleted:
       
   233             {
       
   234             TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::HandleVPbkStoreEventL EVPbkContactDeleted Event") );
       
   235             // a contact entry has been deleted from virtual database store
       
   236             // delete from cache contact
       
   237             // not Needed in case of server contact
       
   238             iServiceCacheWriter.RemoveContactFromCacheL(*aVPbkStoreEvent.iContactLink,
       
   239                     TVIMPSTEnums::EStorageEventContactDelete );
       
   240             TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::HandleVPbkStoreEventL EVPbkContactDeleted Event done") );
       
   241             break;	 
       
   242             }
       
   243         case EVPbkContactChanged:
       
   244             {
       
   245             TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::HandleVPbkStoreEventL EVPbkContactChanged started") );
       
   246             // a contact entry has been updated to virtual database store
       
   247             // update to cache contact
       
   248             // not Needed in case of server contact
       
   249             iServiceCacheWriter.UpdateCacheContactL(*aVPbkStoreEvent.iContactLink , 
       
   250                     aVPbkStoreEvent.iUserId ,
       
   251                     aVPbkStoreEvent.iDisplayName,
       
   252                     aVPbkStoreEvent.iAvatarContent);
       
   253             if(iFetchStep == EFetchingOn)         
       
   254                   {
       
   255                   TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::HandleVPbkStoreEventL EVPbkContactAdded or EVPbkContactFetching fetchin on" ) );
       
   256                   IssueRequest();
       
   257                   }
       
   258             TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::HandleVPbkStoreEventL EVPbkContactChanged started") );
       
   259             break;	
       
   260             }
       
   261         case EVPbkContactRetriving:
       
   262             {
       
   263             TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::HandleVPbkStoreEventL EVPbkContactRetriving started ") );
       
   264             // ONLY VALID USER ID ALLOWED
       
   265             if( aVPbkStoreEvent.iUserId.Length() )
       
   266                 {
       
   267                 TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::HandleVPbkStoreEventL EVPbkContactRetriving valid id ") );
       
   268                 HBufC* sxpId = aVPbkStoreEvent.iUserId.AllocL();
       
   269                 iRetrivedXSPIdArray.Append( sxpId ); // takes the ownership of retrivedContact
       
   270                 // keep the backup of retrieved contacts
       
   271                 // user can add later once it sent to server
       
   272                 }
       
   273             TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::HandleVPbkStoreEventL EVPbkContactRetriving done") );
       
   274             break;	
       
   275             }
       
   276         case EVPbkUnknownChanges:
       
   277             {
       
   278             TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::HandleVPbkStoreEventL EVPbkUnknownChanges Event in") );
       
   279             // unknow mean all contact deleted from store
       
   280             // Not supported in case of server contact
       
   281             iServiceCacheWriter.RemoveAllCacheContactsL();
       
   282             if(iFetchStep == EFetchingCalled )
       
   283                 { 
       
   284                 TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::HandleVPbkStoreEventL EVPbkUnknownChanges fetching on") );               
       
   285                 IssueRequest();
       
   286                 }
       
   287             TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::HandleVPbkStoreEventL EVPbkUnknownChanges Event done") );
       
   288             break;	
       
   289             }
       
   290         default:
       
   291             {
       
   292             TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::HandleVPbkStoreEventL default") );
       
   293             break;
       
   294             }
       
   295         }
       
   296     TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::HandleVPbkStoreEventL() End") );
       
   297     }
       
   298 
       
   299 
       
   300 // --------------------------------------------------------------------------
       
   301 // CVIMPSTStorageVPbkServerStore::IssueRequest
       
   302 // --------------------------------------------------------------------------
       
   303 //
       
   304 void CVIMPSTStorageVPbkServerStore::IssueRequest()
       
   305     {
       
   306     TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::IssueRequest() begin") );
       
   307     if( !IsActive() )
       
   308         {
       
   309         TRequestStatus* status = &iStatus;
       
   310         TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::IssueRequest() RequestComplete"));
       
   311         User::RequestComplete( status, KErrNone );
       
   312         SetActive();
       
   313         }
       
   314     TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::IssueRequest() end") );
       
   315     }
       
   316     
       
   317 // --------------------------------------------------------------------------
       
   318 // CVIMPSTStorageVPbkServerStore::RunL
       
   319 // --------------------------------------------------------------------------
       
   320 //
       
   321 void CVIMPSTStorageVPbkServerStore::RunL()
       
   322     {
       
   323     TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::RunL() begin") );
       
   324     TInt count = iFetchContactsToBeAdded.Count();
       
   325     TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::FetchContactsToBeAdded count = %d"),count );
       
   326     if( !count )
       
   327         {
       
   328         TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::iFetchStep set to state EContactReadComplete") );
       
   329         iFetchStep = EContactReadComplete;
       
   330         iServiceCacheWriter.NotifyServiceViewL( TVIMPSTEnums::EStorageContactFetchComplete );
       
   331         TRACE( T_LIT("calling NotifyFetchCompleteL") );
       
   332         }
       
   333     else
       
   334         {
       
   335         TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::iFetchStep set to state EFetchingOn") );
       
   336         iFetchStep  = EFetchingOn;
       
   337         TVIMPSTContactInfo contactInfoToAdd = iFetchContactsToBeAdded[0];
       
   338         // pass the display NAme in place of NULL
       
   339         TRACE( T_LIT("calling CreateVPbkContactL") );
       
   340        	iVPbkStoreHandler->CreateVPbkContactL( *contactInfoToAdd.iUserId, *contactInfoToAdd.iDisplayName ); // process always 0th item	
       
   341 	    
       
   342 	    iFetchContactsToBeAdded.Remove( 0 );
       
   343         delete contactInfoToAdd.iUserId;
       
   344         contactInfoToAdd.iUserId = NULL;
       
   345         delete contactInfoToAdd.iDisplayName;
       
   346         contactInfoToAdd.iDisplayName = NULL ;
       
   347         
       
   348         iFetchContactsToBeAdded.Compress();
       
   349         }
       
   350     TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::RunL() end") );
       
   351     }
       
   352 
       
   353 // --------------------------------------------------------------------------
       
   354 // CVIMPSTStorageVPbkServerStore::DoCancel
       
   355 // --------------------------------------------------------------------------
       
   356 //
       
   357 void CVIMPSTStorageVPbkServerStore::DoCancel()
       
   358     {
       
   359     TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::DoCancel begin") );
       
   360     TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::DoCancel end") );
       
   361     }
       
   362 
       
   363 // --------------------------------------------------------------------------
       
   364 // CVIMPSTStorageVPbkServerStore::RunError
       
   365 // --------------------------------------------------------------------------
       
   366 //
       
   367 TInt CVIMPSTStorageVPbkServerStore::RunError( TInt aError )
       
   368     {
       
   369     TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::RunError begin") );
       
   370     TRACE( T_LIT("error code = %d"), aError );
       
   371     TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::RunError end") );
       
   372     return aError;    
       
   373     }
       
   374 
       
   375 //////////////////////////////////////////////////////////
       
   376 // ---------------------------------------------------------------------------
       
   377 // CVIMPSTStorageVPbkServerStore::CreateVPbkContactL
       
   378 // ---------------------------------------------------------------------------
       
   379 // 
       
   380 TInt CVIMPSTStorageVPbkServerStore::CreateVPbkContactL( const TDesC& aUserId, 
       
   381         						 					   const TDesC& aDisplayName,
       
   382         						 					   TBool /*aInvitationAutoAccept = EFalse */ )   
       
   383 	{
       
   384 	TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::CreateVPbkContactL() begin") );	
       
   385     return iVPbkStoreHandler->CreateVPbkContactL( aUserId ,aDisplayName );
       
   386 	}
       
   387 
       
   388 // -----------------------------------------------------------------------------
       
   389 // CVIMPSTStorageVPbkServerStore::AddVPbkFetchContactsL
       
   390 // -----------------------------------------------------------------------------
       
   391 //
       
   392  void CVIMPSTStorageVPbkServerStore::AddVPbkFetchContactsL( RArray <TPtrC>& aFirstNameList, 
       
   393                                                             RArray <TPtrC> &aServiceField ) 
       
   394      {
       
   395      // in case of server case we delete all contacts and then add fetch contacts
       
   396      // in case of server contacts delete all contacts
       
   397      TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::AddVPbkFetchContactsL() begin") );  
       
   398      TInt oldContactCount = RemoveAllVPbkContactsL();
       
   399      TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::AddVPbkFetchContactsL() oldContactCount = %d"), oldContactCount ); 
       
   400      ResetAndDestroyLocalArrayL();
       
   401      TInt fetchContactCount = aServiceField.Count();
       
   402      for( TInt i = 0; i<fetchContactCount; i++ )
       
   403          {
       
   404          TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::FetchContactsToBeAdded Append = %d"),i );
       
   405          TVIMPSTContactInfo contactInf =
       
   406 							         {
       
   407 							         aServiceField[i].AllocL() ,
       
   408 							         aFirstNameList[i].AllocL()	
       
   409 							         };
       
   410          iFetchContactsToBeAdded.Append( contactInf );
       
   411          }
       
   412      TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::AddVPbkFetchContactsL() iFetchStep = %d"), iFetchStep ); 
       
   413      if( iFetchStep == EContactReadComplete || !oldContactCount)
       
   414 	     {
       
   415 	     TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::AddVPbkFetchContactsL() inside if") );
       
   416 	     IssueRequest();	
       
   417 	     }
       
   418 	 else
       
   419 		 {
       
   420          TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::iFetchStep set to state EFetchingCalled") );
       
   421 		 iFetchStep = EFetchingCalled;	
       
   422 		 }
       
   423      TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::AddVPbkFetchContactsL() end") );  
       
   424 	 }
       
   425 // ---------------------------------------------------------------------------
       
   426 // CVIMPSTStorageVPbkServerStore::RemoveVPbkContactL
       
   427 // ---------------------------------------------------------------------------
       
   428 //  
       
   429 TInt CVIMPSTStorageVPbkServerStore::RemoveVPbkContactL(const MVPbkContactLink& aContactLink) 
       
   430     {
       
   431     TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::RemoveVPbkContactL() begin") );  
       
   432     // text now holds the name (or first field of the contact) 
       
   433     CVPbkContactLinkArray* contactsToDelete = CVPbkContactLinkArray::NewLC();
       
   434     MVPbkContactLink* link = aContactLink.CloneLC();    
       
   435     contactsToDelete->AppendL( link ); // takes ownership
       
   436     CleanupStack::Pop(); // link
       
   437     TInt error = iVPbkStoreHandler->RemoveVPbkContactL( *contactsToDelete );
       
   438     CleanupStack::PopAndDestroy(); // contactsToDelete
       
   439     TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::returned error code = %d"), error );
       
   440     TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::RemoveVPbkContactL() end") ); 
       
   441     return error;
       
   442     }
       
   443  
       
   444 // ---------------------------------------------------------------------------
       
   445 // CVIMPSTStorageVPbkServerStore::RemoveAllVPbkContactsL
       
   446 // ---------------------------------------------------------------------------
       
   447 // 
       
   448 TInt CVIMPSTStorageVPbkServerStore::RemoveAllVPbkContactsL() 
       
   449 	{
       
   450 	TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::RemoveAllVPbkContactsL() begin") );
       
   451 	iRetrivedXSPIdArray.ResetAndDestroy();
       
   452 	return iVPbkStoreHandler->RemoveAllVPbkContactsL();
       
   453 	}
       
   454 // ---------------------------------------------------------------------------
       
   455 // CVIMPSTStorageVPbkServerStore::RetrieveVPbkXSPIdL
       
   456 // ---------------------------------------------------------------------------
       
   457 //  
       
   458 TInt CVIMPSTStorageVPbkServerStore::RetrieveVPbkXSPIdL(const TDesC8& aPackedLinks ) 
       
   459 	{
       
   460 	TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::RetrieveVPbkContactL() begin") );
       
   461 	iRetrivedXSPIdArray.ResetAndDestroy();
       
   462 	TRACE( T_LIT("CVIMPSTStorageVPbkLocalStore::RetrieveVPbkXSPIdL() iRetrivedXSPIdArray Reset" ) );
       
   463 	iVPbkStoreHandler->RetrieveVPbkContactL( aPackedLinks );
       
   464 	TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::RetrieveVPbkContactL() end") );
       
   465     return iRetrivedXSPIdArray.Count();
       
   466 	}
       
   467  
       
   468  // ---------------------------------------------------------------------------
       
   469 // CVIMPSTStorageVPbkServerStore::GetRetrieveVPbkXSPIdL
       
   470 // ---------------------------------------------------------------------------
       
   471 //  
       
   472 const TDesC& CVIMPSTStorageVPbkServerStore::GetRetrieveVPbkXSPIdL(TInt aIndex ) 
       
   473 	{
       
   474 	TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::RetrieveVPbkXSPIdL() begin") );
       
   475 	HBufC* contactId = NULL;
       
   476 	if( aIndex >= 0 && aIndex < iRetrivedXSPIdArray.Count() )
       
   477         {
       
   478         contactId = iRetrivedXSPIdArray[ aIndex ];
       
   479         }
       
   480     if( contactId  )
       
   481 	    {
       
   482 		TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::RetrieveVPbkXSPIdL() end") );
       
   483 	    return 	*contactId;
       
   484 	    }
       
   485 	TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::RetrieveVPbkXSPIdL() end") );
       
   486     return KNullDesC ; 
       
   487     }
       
   488  // ---------------------------------------------------------------------------
       
   489 // CVIMPSTStorageVPbkServerStore::CreateRetriveVPbkContactL
       
   490 // ---------------------------------------------------------------------------
       
   491 // 
       
   492 TInt CVIMPSTStorageVPbkServerStore::CreateRetriveVPbkContactL( TInt /*aIndexToUse*/ )   
       
   493     {
       
   494     TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::CreateRetriveVPbkContactL()") );
       
   495     // Not applicable for server store
       
   496     return KErrNotSupported;
       
   497     }
       
   498 // ---------------------------------------------------------------------------
       
   499 // CVIMPSTStorageVPbkServerStore::deleteRetriveVPbkContactL
       
   500 // ---------------------------------------------------------------------------
       
   501 // 
       
   502 TInt CVIMPSTStorageVPbkServerStore::deleteRetriveVPbkContactL( TInt /*aIndexToUse*/ )   
       
   503     {
       
   504     TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::deleteRetriveVPbkContactL()") );
       
   505     // Not applicable for server store
       
   506     return KErrNotSupported;
       
   507     }
       
   508 // CVIMPSTStorageVPbkServerStore::UpdateAvatarFieldDataL()
       
   509 // ---------------------------------------------------------------------------
       
   510 //
       
   511 TInt CVIMPSTStorageVPbkServerStore::UpdateAvatarFieldDataL(const MVPbkContactLink& aContactLink,
       
   512 														  const TDesC8& aAvatartData )
       
   513     {
       
   514     TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::UpdateAvatarFieldDataL() ") );
       
   515     return iVPbkStoreHandler->UpdateAvatarFieldDataL( aContactLink, aAvatartData );
       
   516     }
       
   517 
       
   518 // ---------------------------------------------------------------------------
       
   519 // CVIMPSTStorageVPbkServerStore::RemoveAvatarFieldL()
       
   520 // ---------------------------------------------------------------------------
       
   521 //
       
   522 TInt CVIMPSTStorageVPbkServerStore::RemoveAvatarFieldL(MVPbkStoreContact& aStoreContact)
       
   523 	{
       
   524 	TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::RemoveAvatarFieldL()") );
       
   525 	return iVPbkStoreHandler->RemoveAvatarFieldL( aStoreContact );	
       
   526 	}
       
   527 
       
   528 // ----------------------------------------------------------
       
   529 // CVIMPSTStorageVPbkServerStore::DeleteDatabaseL
       
   530 // ----------------------------------------------------------
       
   531 void CVIMPSTStorageVPbkServerStore::DeleteDatabaseL()
       
   532     {
       
   533     TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::DeleteDatabaseL begin") );
       
   534    	// TODO : Not supported yet
       
   535     TRACE( T_LIT("CVIMPSTStorageVPbkServerStore::DeleteDatabaseL end") );
       
   536     }
       
   537 // End of file
       
   538 
       
   539