uiservicetab/vimpststorage/src/cvimpststoragevpbkstorehandler.cpp
branchRCL_3
changeset 9 9fdee5e1da30
parent 0 5e5d6b214f4f
equal deleted inserted replaced
8:796276a1bdcc 9:9fdee5e1da30
    47 #include <CVPbkContactLinkArray.h>
    47 #include <CVPbkContactLinkArray.h>
    48 #include <CVPbkFieldTypeSelector.h>
    48 #include <CVPbkFieldTypeSelector.h>
    49 #include <CPbk2SortOrderManager.h>
    49 #include <CPbk2SortOrderManager.h>
    50 #include <MVPbkContactFieldBinaryData.h>
    50 #include <MVPbkContactFieldBinaryData.h>
    51 
    51 
    52 #include "vimpstdebugtrace.h" 
    52 #include "uiservicetabtracer.h"
    53 #include "tvimpstconsts.h"
    53 #include "tvimpstconsts.h"
    54 #include <cntdb.h>
    54 #include <cntdb.h>
    55 
    55 
    56 // ================= MEMBER FUNCTIONS =======================
    56 // ================= MEMBER FUNCTIONS =======================
    57 
    57 
    65 	iStoreHandler(aStoreHandler ),
    65 	iStoreHandler(aStoreHandler ),
    66 	iStoreEventType( EVPbkUnknownEvent ),
    66 	iStoreEventType( EVPbkUnknownEvent ),
    67 	iFetcingIndex( 0 ),
    67 	iFetcingIndex( 0 ),
    68 	iLocalStore( aLocalStore )
    68 	iLocalStore( aLocalStore )
    69 	{
    69 	{
    70 	TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::CVIMPSTStorageVPbkStoreHandler()") );
    70 	TRACER_AUTO;
    71     CActiveScheduler::Add( this );
    71     CActiveScheduler::Add( this );
    72     }
    72     }
    73 
    73 
    74 // ---------------------------------------------------------------------------
    74 // ---------------------------------------------------------------------------
    75 // CVIMPSTStorageVPbkStoreHandler::ConstructL
    75 // CVIMPSTStorageVPbkStoreHandler::ConstructL
    76 // ---------------------------------------------------------------------------
    76 // ---------------------------------------------------------------------------
    77 //
    77 //
    78 void CVIMPSTStorageVPbkStoreHandler::ConstructL(const TDesC& aStoreName,const TDesC& aServiceName )
    78 void CVIMPSTStorageVPbkStoreHandler::ConstructL(const TDesC& aStoreName,const TDesC& aServiceName )
    79     { 
    79     { 
    80     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::ConstructL() begin") );
    80 	TRACER_AUTO;
    81     iAddIdInProgress = NULL;
    81     iAddIdInProgress = NULL;
    82     iStoreName = aStoreName.AllocL();
    82     iStoreName = aStoreName.AllocL();
    83     iServiceName = aServiceName.AllocL();
    83     iServiceName = aServiceName.AllocL();
    84     CVPbkContactStoreUriArray* uriArray = CVPbkContactStoreUriArray::NewLC();
    84     CVPbkContactStoreUriArray* uriArray = CVPbkContactStoreUriArray::NewLC();
    85     uriArray->AppendL( TVPbkContactStoreUriPtr( aStoreName ) );    
    85     uriArray->AppendL( TVPbkContactStoreUriPtr( aStoreName ) );    
    86     if( !uriArray->IsIncluded( TVPbkContactStoreUriPtr( KPhoneBookDbURI ) ) )
    86     if( !uriArray->IsIncluded( TVPbkContactStoreUriPtr( KPhoneBookDbURI ) ) )
    87 	    {
    87 	    {
    88 	    TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::ConstructL() phonebook store apended") );
    88 	    TRACE( "phonebook store apended" );
    89 	    uriArray->AppendL( TVPbkContactStoreUriPtr( KPhoneBookDbURI )   );	
    89 	    uriArray->AppendL( TVPbkContactStoreUriPtr( KPhoneBookDbURI )   );	
    90 	    }
    90 	    }
    91     iContactManager = CVPbkContactManager::NewL( *uriArray, NULL );
    91     iContactManager = CVPbkContactManager::NewL( *uriArray, NULL );
    92     CleanupStack::PopAndDestroy( uriArray );
    92     CleanupStack::PopAndDestroy( uriArray );
    93 	TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::ConstructL() iContactManager created") );
    93 	TRACE( "iContactManager created" );
    94     iStores = &iContactManager->ContactStoresL();
    94     iStores = &iContactManager->ContactStoresL();
    95     iStores->OpenAllL( *this );
    95     iStores->OpenAllL( *this );
    96     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::ConstructL() OpenAllL called") );
    96     TRACE( " OpenAllL called" );
    97     iSortOrderManager = CPbk2SortOrderManager::NewL( iContactManager->FieldTypes(), NULL ); 
    97     iSortOrderManager = CPbk2SortOrderManager::NewL( iContactManager->FieldTypes(), NULL ); 
    98     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::ConstructL() end") );
    98    
    99     }
    99     }
   100 
   100 
   101 // ---------------------------------------------------------------------------
   101 // ---------------------------------------------------------------------------
   102 // CVIMPSTStorageVPbkStoreHandler::NewL
   102 // CVIMPSTStorageVPbkStoreHandler::NewL
   103 // ---------------------------------------------------------------------------
   103 // ---------------------------------------------------------------------------
   105 CVIMPSTStorageVPbkStoreHandler* CVIMPSTStorageVPbkStoreHandler::NewL( const TDesC& aContactDb,
   105 CVIMPSTStorageVPbkStoreHandler* CVIMPSTStorageVPbkStoreHandler::NewL( const TDesC& aContactDb,
   106 																	const TDesC& aServiceName,
   106 																	const TDesC& aServiceName,
   107 													                MVIMPSTStorageVPbkStoreHandler& aStoreHandler,
   107 													                MVIMPSTStorageVPbkStoreHandler& aStoreHandler,
   108 													                TBool aLocalStore  )
   108 													                TBool aLocalStore  )
   109 	{
   109 	{
   110 	TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::NewL begin") );
   110 	TRACER_AUTO;
   111 	CVIMPSTStorageVPbkStoreHandler* self = NewLC( aContactDb ,aServiceName, aStoreHandler,aLocalStore );
   111 	CVIMPSTStorageVPbkStoreHandler* self = NewLC( aContactDb ,aServiceName, aStoreHandler,aLocalStore );
   112 	CleanupStack::Pop( self );
   112 	CleanupStack::Pop( self );
   113 	TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::NewL end") );
   113 	
   114 	return self;
   114 	return self;
   115 	}
   115 	}
   116 
   116 
   117 // ---------------------------------------------------------------------------
   117 // ---------------------------------------------------------------------------
   118 // CVIMPSTStorageVPbkStoreHandler::NewLC
   118 // CVIMPSTStorageVPbkStoreHandler::NewLC
   121 CVIMPSTStorageVPbkStoreHandler* CVIMPSTStorageVPbkStoreHandler::NewLC( const TDesC& aContactDb,
   121 CVIMPSTStorageVPbkStoreHandler* CVIMPSTStorageVPbkStoreHandler::NewLC( const TDesC& aContactDb,
   122 																	const TDesC& aServiceName,
   122 																	const TDesC& aServiceName,
   123 																	MVIMPSTStorageVPbkStoreHandler& aStoreHandler,
   123 																	MVIMPSTStorageVPbkStoreHandler& aStoreHandler,
   124 																	TBool aLocalStore   )
   124 																	TBool aLocalStore   )
   125     {
   125     {
   126     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::NewLC begin") );
   126 	TRACER_AUTO;
   127     CVIMPSTStorageVPbkStoreHandler* self =
   127     CVIMPSTStorageVPbkStoreHandler* self =
   128         new (ELeave) CVIMPSTStorageVPbkStoreHandler( aStoreHandler ,aLocalStore );
   128         new (ELeave) CVIMPSTStorageVPbkStoreHandler( aStoreHandler ,aLocalStore );
   129     CleanupStack::PushL( self );
   129     CleanupStack::PushL( self );
   130     self->ConstructL( aContactDb,aServiceName );
   130     self->ConstructL( aContactDb,aServiceName );
   131     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::NewLC end") );
   131    
   132     return self;
   132     return self;
   133     }
   133     }
   134 
   134 
   135 // ---------------------------------------------------------------------------
   135 // ---------------------------------------------------------------------------
   136 // CVIMPSTStorageVPbkStoreHandler::
   136 // CVIMPSTStorageVPbkStoreHandler::
   137 //      ~CVIMPSTStorageVPbkStoreHandler
   137 //      ~CVIMPSTStorageVPbkStoreHandler
   138 // ---------------------------------------------------------------------------
   138 // ---------------------------------------------------------------------------
   139 //
   139 //
   140 CVIMPSTStorageVPbkStoreHandler:: ~CVIMPSTStorageVPbkStoreHandler()
   140 CVIMPSTStorageVPbkStoreHandler:: ~CVIMPSTStorageVPbkStoreHandler()
   141     {
   141     {
   142     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::~CVIMPSTStorageVPbkStoreHandler begin") );
   142 	TRACER_AUTO;
   143     if( iWait.IsStarted() )
   143     if( iWait.IsStarted() )
   144 	    {
   144 	    {
   145 	    iWait.AsyncStop();	
   145 	    iWait.AsyncStop();	
   146 	    }
   146 	    }
   147    	Cancel();
   147    	Cancel();
   153     delete iStoreContact;
   153     delete iStoreContact;
   154     delete iContactView;
   154     delete iContactView;
   155     if ( iContactManager )
   155     if ( iContactManager )
   156         {
   156         {
   157         TRAP_IGNORE( iContactManager->ContactStoresL().CloseAll( *this ) );
   157         TRAP_IGNORE( iContactManager->ContactStoresL().CloseAll( *this ) );
   158         TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::~CVIMPSTStorageVPbkStoreHandler CloseAll called") );
   158         TRACE( "CloseAll called" );
   159         delete iContactManager;
   159         delete iContactManager;
   160         }
   160         }
   161     delete iStoreName;
   161     delete iStoreName;
   162     delete iSortOrderManager;
   162     delete iSortOrderManager;
   163     delete iServiceName;
   163     delete iServiceName;
   164     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::~CVIMPSTStorageVPbkStoreHandler end") );
   164    
   165     }
   165     }
   166  // ---------------------------------------------------------------------------
   166  // ---------------------------------------------------------------------------
   167 // CVIMPSTStorageVPbkStoreHandler::ContactViewReady
   167 // CVIMPSTStorageVPbkStoreHandler::ContactViewReady
   168 // ---------------------------------------------------------------------------
   168 // ---------------------------------------------------------------------------
   169 //
   169 //
   170 void CVIMPSTStorageVPbkStoreHandler::ContactViewReady( 
   170 void CVIMPSTStorageVPbkStoreHandler::ContactViewReady( 
   171     MVPbkContactViewBase& aView )
   171     MVPbkContactViewBase& aView )
   172     {
   172     {
   173     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::ContactViewReady() begin") );
   173 	TRACER_AUTO;
   174     if ( iContactView == &aView && ( iStoreEventType == EVPbkUnknownEvent ) )
   174     if ( iContactView == &aView && ( iStoreEventType == EVPbkUnknownEvent ) )
   175         { 
   175         { 
   176         iStoreEventType = EVPbkContactReading ;          
   176         iStoreEventType = EVPbkContactReading ;          
   177         TRAP_IGNORE( HandleContactViewReadyL( *iContactView ) );
   177         TRAP_IGNORE( HandleContactViewReadyL( *iContactView ) );
   178         }
   178         }
   179     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::ContactViewReady() end") );
   179    
   180     }
   180     }
   181 
   181 
   182 // ---------------------------------------------------------------------------
   182 // ---------------------------------------------------------------------------
   183 // CVIMPSTStorageVPbkStoreHandler::ContactViewUnavailable
   183 // CVIMPSTStorageVPbkStoreHandler::ContactViewUnavailable
   184 // ---------------------------------------------------------------------------
   184 // ---------------------------------------------------------------------------
   185 //
   185 //
   186 void CVIMPSTStorageVPbkStoreHandler::ContactViewUnavailable( 
   186 void CVIMPSTStorageVPbkStoreHandler::ContactViewUnavailable( 
   187     MVPbkContactViewBase& /*aView*/ )
   187     MVPbkContactViewBase& /*aView*/ )
   188     {
   188     {
   189     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::ContactViewUnavailable begin") );
   189 	TRACER_AUTO;
   190     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::ContactViewUnavailable end"));
       
   191     }
   190     }
   192 
   191 
   193 // ---------------------------------------------------------------------------
   192 // ---------------------------------------------------------------------------
   194 // CVIMPSTStorageVPbkStoreHandler::ContactAddedToView
   193 // CVIMPSTStorageVPbkStoreHandler::ContactAddedToView
   195 // ---------------------------------------------------------------------------
   194 // ---------------------------------------------------------------------------
   196 //
   195 //
   197 void CVIMPSTStorageVPbkStoreHandler::ContactAddedToView( 
   196 void CVIMPSTStorageVPbkStoreHandler::ContactAddedToView( 
   198     MVPbkContactViewBase& /*aView*/, 
   197     MVPbkContactViewBase& /*aView*/, 
   199     TInt /*aIndex*/, const MVPbkContactLink& /*aContactLink*/ )
   198     TInt /*aIndex*/, const MVPbkContactLink& /*aContactLink*/ )
   200     {
   199     {
   201     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::ContactAddedToView begin"));
   200 	TRACER_AUTO;
   202     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::ContactAddedToView End "));
       
   203     }
   201     }
   204 
   202 
   205 // ---------------------------------------------------------------------------
   203 // ---------------------------------------------------------------------------
   206 // CVIMPSTStorageVPbkStoreHandler::ContactRemovedFromView
   204 // CVIMPSTStorageVPbkStoreHandler::ContactRemovedFromView
   207 // ---------------------------------------------------------------------------
   205 // ---------------------------------------------------------------------------
   208 //
   206 //
   209 void CVIMPSTStorageVPbkStoreHandler::ContactRemovedFromView( 
   207 void CVIMPSTStorageVPbkStoreHandler::ContactRemovedFromView( 
   210     MVPbkContactViewBase& /*aView*/, 
   208     MVPbkContactViewBase& /*aView*/, 
   211     TInt /*aIndex*/, const MVPbkContactLink& /*aContactLink*/ )
   209     TInt /*aIndex*/, const MVPbkContactLink& /*aContactLink*/ )
   212     {
   210     {
   213     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::ContactRemovedFromView begin") );
   211 	TRACER_AUTO;
   214     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::ContactRemovedFromView End"));
       
   215     }
   212     }
   216 
   213 
   217 // ---------------------------------------------------------------------------
   214 // ---------------------------------------------------------------------------
   218 // CVIMPSTStorageVPbkStoreHandler::ContactViewError
   215 // CVIMPSTStorageVPbkStoreHandler::ContactViewError
   219 // ---------------------------------------------------------------------------
   216 // ---------------------------------------------------------------------------
   220 //
   217 //
   221 void CVIMPSTStorageVPbkStoreHandler::ContactViewError( 
   218 void CVIMPSTStorageVPbkStoreHandler::ContactViewError( 
   222     MVPbkContactViewBase& /*aView*/, 
   219     MVPbkContactViewBase& /*aView*/, 
   223     TInt /*aError*/, TBool /*aErrorNotified*/ )
   220     TInt /*aError*/, TBool /*aErrorNotified*/ )
   224     {
   221     {
   225     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::ContactViewError() begin") );
   222 	TRACER_AUTO;
   226     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::ContactViewError() end"));
       
   227     }
   223     }
   228 
   224 
   229 // ---------------------------------------------------------------------------
   225 // ---------------------------------------------------------------------------
   230 // CVIMPSTStorageVPbkStoreHandler::StoreReady
   226 // CVIMPSTStorageVPbkStoreHandler::StoreReady
   231 // ---------------------------------------------------------------------------
   227 // ---------------------------------------------------------------------------
   232 //
   228 //
   233 void CVIMPSTStorageVPbkStoreHandler::StoreReady( 
   229 void CVIMPSTStorageVPbkStoreHandler::StoreReady( 
   234     MVPbkContactStore& /*aContactStore*/ )
   230     MVPbkContactStore& /*aContactStore*/ )
   235     {
   231     {
   236     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::StoreReady() begin"));
   232 	TRACER_AUTO;
   237     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::StoreReady() end") );
       
   238     }
   233     }
   239     
   234     
   240 // ---------------------------------------------------------------------------
   235 // ---------------------------------------------------------------------------
   241 // CVIMPSTStorageVPbkStoreHandler::StoreUnavailable
   236 // CVIMPSTStorageVPbkStoreHandler::StoreUnavailable
   242 // ---------------------------------------------------------------------------
   237 // ---------------------------------------------------------------------------
   243 //
   238 //
   244 void CVIMPSTStorageVPbkStoreHandler::StoreUnavailable( 
   239 void CVIMPSTStorageVPbkStoreHandler::StoreUnavailable( 
   245     MVPbkContactStore& /*aContactStore*/, 
   240     MVPbkContactStore& /*aContactStore*/, 
   246     TInt /*aReason*/ )
   241     TInt /*aReason*/ )
   247     {
   242     {
   248     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::StoreUnavailable() begin") );
   243 	TRACER_AUTO;
   249     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::StoreUnavailable() end"));
       
   250     }
   244     }
   251 
   245 
   252 // ---------------------------------------------------------------------------
   246 // ---------------------------------------------------------------------------
   253 // CVIMPSTStorageVPbkStoreHandler::HandleStoreEventL
   247 // CVIMPSTStorageVPbkStoreHandler::HandleStoreEventL
   254 // ---------------------------------------------------------------------------
   248 // ---------------------------------------------------------------------------
   255 //
   249 //
   256 MVPbkContactStore* CVIMPSTStorageVPbkStoreHandler::GetDefaultStoreL( const TDesC& aUri )
   250 MVPbkContactStore* CVIMPSTStorageVPbkStoreHandler::GetDefaultStoreL( const TDesC& aUri )
   257 	 {
   251 	 {
   258 	 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::GetDefaultStoreL() "));
   252 	TRACER_AUTO;
   259 	 return iStores->Find( TVPbkContactStoreUriPtr( aUri ) );	
   253 	 return iStores->Find( TVPbkContactStoreUriPtr( aUri ) );	
   260 	 }
   254 	 }
   261 
   255 
   262 // ---------------------------------------------------------------------------
   256 // ---------------------------------------------------------------------------
   263 // CVIMPSTStorageVPbkStoreHandler::HandleStoreEventL
   257 // CVIMPSTStorageVPbkStoreHandler::HandleStoreEventL
   265 //
   259 //
   266 void CVIMPSTStorageVPbkStoreHandler::HandleStoreEventL( 
   260 void CVIMPSTStorageVPbkStoreHandler::HandleStoreEventL( 
   267     MVPbkContactStore& aContactStore , 
   261     MVPbkContactStore& aContactStore , 
   268     TVPbkContactStoreEvent aStoreEvent )
   262     TVPbkContactStoreEvent aStoreEvent )
   269     {
   263     {
   270     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::HandleStoreEventL() begin") );
   264 	TRACER_AUTO;
   271     if( iStore == &aContactStore )
   265     if( iStore == &aContactStore )
   272 	    {
   266 	    {
   273 	    TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::HandleStoreEventL() store event") );
   267 	    TRACE( "store event" );
   274 	  	switch( aStoreEvent.iEventType )
   268 	  	switch( aStoreEvent.iEventType )
   275 		    {
   269 		    {
   276 		    case TVPbkContactStoreEvent::EContactAdded:
   270 		    case TVPbkContactStoreEvent::EContactAdded:
   277 			    {
   271 			    {
   278 			    TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::HandleStoreEventL() EContactAdded event") );
   272 			    TRACE( "EContactAdded event");
   279 			    delete iContactLink;
   273 			    delete iContactLink;
   280 			    iContactLink = NULL;
   274 			    iContactLink = NULL;
   281 				MVPbkContactLink* contactLink = aStoreEvent.iContactLink->CloneLC();
   275 				MVPbkContactLink* contactLink = aStoreEvent.iContactLink->CloneLC();
   282 			 	iContactLink = 	contactLink;
   276 			 	iContactLink = 	contactLink;
   283 				CleanupStack::Pop(); // contactLink
   277 				CleanupStack::Pop(); // contactLink
   284 				IssueRequest(); // complete the request	
   278 				IssueRequest(); // complete the request	
   285 				TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::HandleStoreEventL() EContactAdded done") );
   279 				TRACE( " EContactAdded done" );
   286 			    break;	
   280 			    break;	
   287 			    }
   281 			    }
   288 			case TVPbkContactStoreEvent::EContactDeleted:
   282 			case TVPbkContactStoreEvent::EContactDeleted:
   289 			    {
   283 			    {
   290 			    TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::HandleStoreEventL() EContactDeleted event") );
   284 			    TRACE( "EContactDeleted event" );
   291 			   	MVPbkContactLink* contactLink = aStoreEvent.iContactLink->CloneLC();
   285 			   	MVPbkContactLink* contactLink = aStoreEvent.iContactLink->CloneLC();
   292 			   	delete iContactLink;
   286 			   	delete iContactLink;
   293 		    	iContactLink = NULL;
   287 		    	iContactLink = NULL;
   294 		 		iContactLink = 	contactLink;
   288 		 		iContactLink = 	contactLink;
   295 		 		CleanupStack::Pop(); // contactLink
   289 		 		CleanupStack::Pop(); // contactLink
   296 				TVIMPSTVPbkStoreEvent storeEvent(EVPbkContactDeleted, iContactLink );
   290 				TVIMPSTVPbkStoreEvent storeEvent(EVPbkContactDeleted, iContactLink );
   297 		    	iStoreHandler.HandleVPbkStoreEventL( storeEvent ) ;	
   291 		    	iStoreHandler.HandleVPbkStoreEventL( storeEvent ) ;	
   298 		    	TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::HandleStoreEventL() EContactDeleted done") );
   292 		    	TRACE( "EContactDeleted done" );
   299 			    break;	
   293 			    break;	
   300 			    }
   294 			    }
   301 			case TVPbkContactStoreEvent::EContactChanged:
   295 			case TVPbkContactStoreEvent::EContactChanged:
   302 				{
   296 				{
   303 				TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::HandleStoreEventL() EContactChanged event") );
   297 				TRACE( " EContactChanged event" );
   304 				delete iContactLink;
   298 				delete iContactLink;
   305 				iContactLink = NULL;
   299 				iContactLink = NULL;
   306 				MVPbkContactLink* contactLink = aStoreEvent.iContactLink->CloneLC();
   300 				MVPbkContactLink* contactLink = aStoreEvent.iContactLink->CloneLC();
   307 				iContactLink = 	contactLink;
   301 				iContactLink = 	contactLink;
   308 				CleanupStack::Pop(); // contactLink
   302 				CleanupStack::Pop(); // contactLink
   309 				iStoreEventType = EVPbkContactChanged;
   303 				iStoreEventType = EVPbkContactChanged;
   310 				IssueRequest(); // complete the request which will begin retriving the iContactLink
   304 				IssueRequest(); // complete the request which will begin retriving the iContactLink
   311 				TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::HandleStoreEventL() EContactChanged done") );
   305 				TRACE("EContactChanged done");
   312 				break;	
   306 				break;	
   313 				}
   307 				}
   314 			case TVPbkContactStoreEvent::EUnknownChanges:
   308 			case TVPbkContactStoreEvent::EUnknownChanges:
   315 			    {
   309 			    {
   316 			    TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::HandleStoreEventL() EUnknownChanges event") );
   310 			    TRACE( " EUnknownChanges event" );
   317 			    iStoreEventType = EVPbkUnknownChanges;
   311 			    iStoreEventType = EVPbkUnknownChanges;
   318 			    TVIMPSTVPbkStoreEvent storeEvent(iStoreEventType);
   312 			    TVIMPSTVPbkStoreEvent storeEvent(iStoreEventType);
   319 			    iStoreHandler.HandleVPbkStoreEventL( storeEvent ) ;
   313 			    iStoreHandler.HandleVPbkStoreEventL( storeEvent ) ;
   320 			    TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::HandleStoreEventL() EUnknownChanges done") );
   314 			    TRACE( "EUnknownChanges done" );
   321 			    break;	
   315 			    break;	
   322 			    }
   316 			    }
   323 		    default:
   317 		    default:
   324 			 	break;
   318 			 	break;
   325 		    }
   319 		    }
   326 	    }
   320 	    }
   327     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::HandleStoreEventL() end") ); 
   321    
   328     }
   322     }
   329 // ---------------------------------------------------------------------------
   323 // ---------------------------------------------------------------------------
   330 // CVIMPSTStorageVPbkStoreHandler::OpenComplete
   324 // CVIMPSTStorageVPbkStoreHandler::OpenComplete
   331 // ---------------------------------------------------------------------------
   325 // ---------------------------------------------------------------------------
   332 //
   326 //
   333 void CVIMPSTStorageVPbkStoreHandler::OpenComplete()
   327 void CVIMPSTStorageVPbkStoreHandler::OpenComplete()
   334     {
   328     {
   335     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::OpenComplete() begin") );
   329 	TRACER_AUTO;
   336     // stores OpenAll completed
   330     // stores OpenAll completed
   337     TRAP_IGNORE( DoHnadleOpenCompleteL() );
   331     TRAP_IGNORE( DoHnadleOpenCompleteL() );
   338     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::OpenComplete() end"));
   332    
   339     }
   333     }
   340 
   334 
   341 // ---------------------------------------------------------------------------
   335 // ---------------------------------------------------------------------------
   342 // CVIMPSTStorageVPbkStoreHandler::DoHnadleOpenCompleteL
   336 // CVIMPSTStorageVPbkStoreHandler::DoHnadleOpenCompleteL
   343 // ---------------------------------------------------------------------------
   337 // ---------------------------------------------------------------------------
   344 //
   338 //
   345 void CVIMPSTStorageVPbkStoreHandler::DoHnadleOpenCompleteL()
   339 void CVIMPSTStorageVPbkStoreHandler::DoHnadleOpenCompleteL()
   346     {
   340     {
   347     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::DoHnadleOpenCompleteL() begin") );
   341 	TRACER_AUTO;
   348     iStore = GetDefaultStoreL( *iStoreName ) ;
   342     iStore = GetDefaultStoreL( *iStoreName ) ;
   349     CVPbkContactViewDefinition* viewDefinition = 
   343     CVPbkContactViewDefinition* viewDefinition = 
   350         				CVPbkContactViewDefinition::NewL();
   344         				CVPbkContactViewDefinition::NewL();
   351     CleanupStack::PushL( viewDefinition );    
   345     CleanupStack::PushL( viewDefinition );    
   352     viewDefinition->SetType( EVPbkContactsView );
   346     viewDefinition->SetType( EVPbkContactsView );
   353     viewDefinition->SetUriL( *iStoreName );
   347     viewDefinition->SetUriL( *iStoreName );
   354     if ( iStore )
   348     if ( iStore )
   355         {
   349         {
   356         TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::DoHnadleOpenCompleteL() store view creating"));
   350         TRACE( "store view creating");
   357         MVPbkContactView* tmpView = iStore->CreateViewLC(
   351         MVPbkContactView* tmpView = iStore->CreateViewLC(
   358 						            *viewDefinition,
   352 						            *viewDefinition,
   359 						            *this,
   353 						            *this,
   360 						            iSortOrderManager->SortOrder() );        
   354 						            iSortOrderManager->SortOrder() );        
   361         CleanupStack::Pop(); // tmpView            
   355         CleanupStack::Pop(); // tmpView            
   362         TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::DoHnadleOpenCompleteL() store view created"));        
   356         TRACE( "store view created");        
   363         iContactView = tmpView;
   357         iContactView = tmpView;
   364         }
   358         }
   365     CleanupStack::PopAndDestroy();  //viewDefinition, can not pop ny name
   359     CleanupStack::PopAndDestroy();  //viewDefinition, can not pop ny name
   366     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::DoHnadleOpenCompleteL() end"));
   360     
   367     }
   361     }
   368 	
   362 	
   369 // ---------------------------------------------------------------------------
   363 // ---------------------------------------------------------------------------
   370 // CVIMPSTStorageVPbkStoreHandler::ContactOperationCompleted
   364 // CVIMPSTStorageVPbkStoreHandler::ContactOperationCompleted
   371 // ---------------------------------------------------------------------------
   365 // ---------------------------------------------------------------------------
   372 //
   366 //
   373 void CVIMPSTStorageVPbkStoreHandler::ContactOperationCompleted(
   367 void CVIMPSTStorageVPbkStoreHandler::ContactOperationCompleted(
   374     TContactOpResult /*aResult*/ )
   368     TContactOpResult /*aResult*/ )
   375     {
   369     {
   376     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::ContactOperationCompleted() begin"));
   370 	TRACER_AUTO;
   377     // called when contact commit is successful
   371     // called when contact commit is successful
   378     iOperationError = KErrNone;
   372     iOperationError = KErrNone;
   379     if( iWait.IsStarted() )
   373     if( iWait.IsStarted() )
   380 	    {
   374 	    {
   381 	    iWait.AsyncStop();	
   375 	    iWait.AsyncStop();	
   382 	    }
   376 	    }
   383     TRAP_IGNORE( CommitNextPendingContactsL() );
   377     TRAP_IGNORE( CommitNextPendingContactsL() );
   384 	TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::ContactOperationCompleted() end"));
   378 	
   385 	}
   379 	}
   386 
   380 
   387 // ---------------------------------------------------------------------------
   381 // ---------------------------------------------------------------------------
   388 // CVIMPSTStorageVPbkStoreHandler::ContactOperationFailed
   382 // CVIMPSTStorageVPbkStoreHandler::ContactOperationFailed
   389 // ---------------------------------------------------------------------------
   383 // ---------------------------------------------------------------------------
   390 //
   384 //
   391 void CVIMPSTStorageVPbkStoreHandler::ContactOperationFailed( 
   385 void CVIMPSTStorageVPbkStoreHandler::ContactOperationFailed( 
   392     TContactOp /*aOpCode*/, TInt aErrorCode, TBool /*aErrorNotified*/ )
   386     TContactOp /*aOpCode*/, TInt aErrorCode, TBool /*aErrorNotified*/ )
   393     {
   387     {
   394     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::ContactOperationFailed() begin"));
   388 	TRACER_AUTO;
   395     // called when contact commit is unsuccessful
   389     // called when contact commit is unsuccessful
   396     iOperationError = aErrorCode;
   390     iOperationError = aErrorCode;
   397     if( iWait.IsStarted() )
   391     if( iWait.IsStarted() )
   398 	    {
   392 	    {
   399 	    iWait.AsyncStop();	
   393 	    iWait.AsyncStop();	
   400 	    }
   394 	    }
   401     TRAP_IGNORE( CommitNextPendingContactsL() );
   395     TRAP_IGNORE( CommitNextPendingContactsL() );
   402 	TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::ContactOperationFailed() end"));
   396 	
   403     }    
   397     }    
   404  
   398  
   405  
   399  
   406 // --------------------------------------------------------------------------
   400 // --------------------------------------------------------------------------
   407 // CVIMPSTStorageVPbkStoreHandler::StepComplete
   401 // CVIMPSTStorageVPbkStoreHandler::StepComplete
   409 //
   403 //
   410 void CVIMPSTStorageVPbkStoreHandler::StepComplete(
   404 void CVIMPSTStorageVPbkStoreHandler::StepComplete(
   411         MVPbkContactOperationBase& /*aOperation*/,
   405         MVPbkContactOperationBase& /*aOperation*/,
   412         TInt /*aStepSize*/ )
   406         TInt /*aStepSize*/ )
   413     {
   407     {
   414     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::StepComplete() begin"));
   408 	TRACER_AUTO;
   415     // called when batch operation call
   409     // called when batch operation call
   416     iOperationError = KErrNone;
   410     iOperationError = KErrNone;
   417     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::StepComplete() end"));
   411     
   418     }
   412     }
   419 
   413 
   420 
   414 
   421 // --------------------------------------------------------------------------
   415 // --------------------------------------------------------------------------
   422 // CVIMPSTStorageVPbkStoreHandler::StepFailed
   416 // CVIMPSTStorageVPbkStoreHandler::StepFailed
   425 TBool CVIMPSTStorageVPbkStoreHandler::StepFailed(
   419 TBool CVIMPSTStorageVPbkStoreHandler::StepFailed(
   426         MVPbkContactOperationBase& /*aOperation*/,
   420         MVPbkContactOperationBase& /*aOperation*/,
   427         TInt /*aStepSize*/,
   421         TInt /*aStepSize*/,
   428         TInt aError )
   422         TInt aError )
   429     {
   423     {
   430     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::StepFailed() begin"));
   424 	TRACER_AUTO;
   431     // called when batch operation call
   425     // called when batch operation call
   432     iOperationError = aError;
   426     iOperationError = aError;
   433     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::StepFailed() end"));
   427    
   434    	return EFalse;
   428    	return EFalse;
   435     }
   429     }
   436 
   430 
   437 // --------------------------------------------------------------------------
   431 // --------------------------------------------------------------------------
   438 // CVIMPSTStorageVPbkStoreHandler::OperationComplete
   432 // CVIMPSTStorageVPbkStoreHandler::OperationComplete
   439 // --------------------------------------------------------------------------
   433 // --------------------------------------------------------------------------
   440 //
   434 //
   441 void CVIMPSTStorageVPbkStoreHandler::OperationComplete(
   435 void CVIMPSTStorageVPbkStoreHandler::OperationComplete(
   442         MVPbkContactOperationBase& aOperation )
   436         MVPbkContactOperationBase& aOperation )
   443     {
   437     {
   444     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::OperationComplete() begin"));
   438 	TRACER_AUTO;
   445     // called when batch operation call for opening the multiple store
   439     // called when batch operation call for opening the multiple store
   446     if ( &aOperation == iContactOperation )
   440     if ( &aOperation == iContactOperation )
   447         {
   441         {
   448         delete iContactOperation;
   442         delete iContactOperation;
   449         iContactOperation = NULL;
   443         iContactOperation = NULL;
   451     iOperationError = KErrNone;
   445     iOperationError = KErrNone;
   452     if( iWait.IsStarted() )
   446     if( iWait.IsStarted() )
   453 	    {
   447 	    {
   454 	    iWait.AsyncStop();	
   448 	    iWait.AsyncStop();	
   455 	    }
   449 	    }
   456 	TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::OperationComplete() end"));
   450 	
   457     }   
   451     }   
   458 
   452 
   459 //----------------------------------------------------------------------
   453 //----------------------------------------------------------------------
   460 //CVIMPSTStorageVPbkStoreHandler::VPbkSingleContactOperationComplete()
   454 //CVIMPSTStorageVPbkStoreHandler::VPbkSingleContactOperationComplete()
   461 //----------------------------------------------------------------------
   455 //----------------------------------------------------------------------
   462 void CVIMPSTStorageVPbkStoreHandler::VPbkSingleContactOperationComplete( MVPbkContactOperationBase& aOperation,
   456 void CVIMPSTStorageVPbkStoreHandler::VPbkSingleContactOperationComplete( MVPbkContactOperationBase& aOperation,
   463                                             				MVPbkStoreContact* aContact )
   457                                             				MVPbkStoreContact* aContact )
   464     {  
   458     {  
   465     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::VPbkSingleContactOperationComplete() begin")); 
   459 	TRACER_AUTO;
   466     // called when contact details is retrived
   460     // called when contact details is retrived
   467     TRAP_IGNORE( DoHnadleSingleContactOperationCompleteL( aOperation, aContact ) );
   461     TRAP_IGNORE( DoHnadleSingleContactOperationCompleteL( aOperation, aContact ) );
   468     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::VPbkSingleContactOperationComplete() end"));
   462     
   469     }
   463     }
   470 
   464 
   471 //----------------------------------------------------------------------
   465 //----------------------------------------------------------------------
   472 //CVIMPSTStorageVPbkStoreHandler::DoHnadleSingleContactOperationCompleteL()
   466 //CVIMPSTStorageVPbkStoreHandler::DoHnadleSingleContactOperationCompleteL()
   473 //----------------------------------------------------------------------
   467 //----------------------------------------------------------------------
   474 void CVIMPSTStorageVPbkStoreHandler::DoHnadleSingleContactOperationCompleteL( MVPbkContactOperationBase& aOperation,
   468 void CVIMPSTStorageVPbkStoreHandler::DoHnadleSingleContactOperationCompleteL( MVPbkContactOperationBase& aOperation,
   475                                             								 MVPbkStoreContact* aContact )
   469                                             								 MVPbkStoreContact* aContact )
   476     {  
   470     {  
   477     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::DoHnadleSingleContactOperationCompleteL() begin"));
   471 	TRACER_AUTO;
   478     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::DoHnadleSingleContactOperationCompleteL() StoreEventType: %d"),iStoreEventType);
   472     TRACE( "StoreEventType: %d",iStoreEventType);
   479     // called when contact details is retrived
   473     // called when contact details is retrived
   480     if( iStoreContact )
   474     if( iStoreContact )
   481         {
   475         {
   482         delete 	iStoreContact;
   476         delete 	iStoreContact;
   483         iStoreContact = NULL;
   477         iStoreContact = NULL;
   484         }
   478         }
   485     iStoreContact = aContact ; // iStoreContact  owns thea Contact
   479     iStoreContact = aContact ; // iStoreContact  owns thea Contact
   486     if( ( &aOperation == iContactOperation) && iStoreContact )
   480     if( ( &aOperation == iContactOperation) && iStoreContact )
   487         {
   481         {
   488         TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::DoHnadleSingleContactOperationCompleteL() inside if (operation) "));
   482         TRACE( "inside if (operation) ");
   489         if( iWait.IsStarted() )
   483         if( iWait.IsStarted() )
   490 		    {
   484 		    {
   491 		    iWait.AsyncStop();
   485 		    iWait.AsyncStop();
   492 		    }
   486 		    }
   493         delete iContactOperation;
   487         delete iContactOperation;
   494         iContactOperation = NULL;
   488         iContactOperation = NULL;
   495         TRACE( T_LIT("DoHnadleSingleContactOperationCompleteL() before iCommitOperationInProgress: %d"),iCommitOperationInProgress);
   489         TRACE( " before iCommitOperationInProgress: %d",iCommitOperationInProgress);
   496         iCommitOperationInProgress = EFalse;
   490         iCommitOperationInProgress = EFalse;
   497         TRACE( T_LIT("DoHnadleSingleContactOperationCompleteL()After iCommitOperationInProgress: %d"),iCommitOperationInProgress);
   491         TRACE( "After iCommitOperationInProgress: %d",iCommitOperationInProgress);
   498 
   492 
   499         if( iStoreEventType != EVPbkUpdatingAvatar )
   493         if( iStoreEventType != EVPbkUpdatingAvatar )
   500             {
   494             {
   501             TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::DoHnadleSingleContactOperationCompleteL() inside if (iStoreEventType != EVPbkUpdatingAvatar ) "));
   495             TRACE( " inside if (iStoreEventType != EVPbkUpdatingAvatar ) ");
   502             if( !iLocalStore && iStoreEventType == EVPbkContactRetriving )
   496             if( !iLocalStore && iStoreEventType == EVPbkContactRetriving )
   503                 {
   497                 {
   504                 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::DoHnadleSingleContactOperationCompleteL() EVPbkContactRetriving"));
   498                 TRACE( " EVPbkContactRetriving");
   505 		    	RetriveFieldDataAndSendEventL( *iStoreContact );
   499 		    	RetriveFieldDataAndSendEventL( *iStoreContact );
   506 			   }
   500 			   }
   507             else 
   501             else 
   508                 {
   502                 {
   509                 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::DoHnadleSingleContactOperationCompleteL() inside else start"));
   503                 TRACE( "inside else start");
   510                 HBufC* userId = GetContactFieldDataLC( *iStoreContact, R_VPBK_FIELD_TYPE_IMPP );
   504                 HBufC* userId = GetContactFieldDataLC( *iStoreContact, R_VPBK_FIELD_TYPE_IMPP );
   511                 HBufC* firstname = GetContactFieldDataLC( *iStoreContact,R_VPBK_FIELD_TYPE_FIRSTNAME );
   505                 HBufC* firstname = GetContactFieldDataLC( *iStoreContact,R_VPBK_FIELD_TYPE_FIRSTNAME );
   512                 HBufC* lastname = GetContactFieldDataLC( *iStoreContact,R_VPBK_FIELD_TYPE_LASTNAME );
   506                 HBufC* lastname = GetContactFieldDataLC( *iStoreContact,R_VPBK_FIELD_TYPE_LASTNAME );
   513 
   507 
   514                 HBufC* disname = NULL;
   508                 HBufC* disname = NULL;
   533                 else
   527                 else
   534                     {
   528                     {
   535                     disname = KNullDesC().AllocLC();
   529                     disname = KNullDesC().AllocLC();
   536                     }
   530                     }
   537                 HBufC8* avatarContent = GetContactBinaryFieldDataLC( *iStoreContact,R_VPBK_FIELD_TYPE_THUMBNAILPIC );
   531                 HBufC8* avatarContent = GetContactBinaryFieldDataLC( *iStoreContact,R_VPBK_FIELD_TYPE_THUMBNAILPIC );
   538                 TRACE( T_LIT("DoHnadleSingleContactOperationCompleteL()  iStoreHandler.HandleVPbkStoreEventL: %d"), iStoreEventType);
   532                 TRACE( "iStoreHandler.HandleVPbkStoreEventL: %d", iStoreEventType);
   539                 TPtr useridPtr = userId->Des();
   533                 TPtr useridPtr = userId->Des();
   540                 TRACE( T_LIT("DoHnadleSingleContactOperationCompleteL()  inside else UserId : %S"), &useridPtr);
   534                 TRACE( "inside else UserId : %S", &useridPtr);
   541                 TVIMPSTVPbkStoreEvent storeEvent(iStoreEventType,
   535                 TVIMPSTVPbkStoreEvent storeEvent(iStoreEventType,
   542                         iContactLink,
   536                         iContactLink,
   543                         NULL,
   537                         NULL,
   544                         *userId,
   538                         *userId,
   545                         *disname,
   539                         *disname,
   546                         *avatarContent);
   540                         *avatarContent);
   547                 iStoreHandler.HandleVPbkStoreEventL( storeEvent ) ;
   541                 iStoreHandler.HandleVPbkStoreEventL( storeEvent ) ;
   548                 CleanupStack::PopAndDestroy(5); // disname,lastname,firstname,userId,avatarContent 
   542                 CleanupStack::PopAndDestroy(5); // disname,lastname,firstname,userId,avatarContent 
   549                 TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::DoHnadleSingleContactOperationCompleteL() inside else end"));
   543                 TRACE( " inside else end");
   550                 }
   544                 }
   551             delete iAddIdInProgress;
   545             delete iAddIdInProgress;
   552             iAddIdInProgress = NULL;
   546             iAddIdInProgress = NULL;
   553             }
   547             }
   554 
   548 
   555         iOperationError = KErrNone;
   549         iOperationError = KErrNone;
   556         if( iStoreEventType == EVPbkContactReading && iContactView )
   550         if( iStoreEventType == EVPbkContactReading && iContactView )
   557             {
   551             {
   558             TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::DoHnadleSingleContactOperationCompleteL() if after iOperationError"));
   552             TRACE( " if after iOperationError");
   559             HandleContactViewReadyL( *iContactView );   
   553             HandleContactViewReadyL( *iContactView );   
   560             }
   554             }
   561         
   555         
   562         else if(!iCommitOperationInProgress )
   556         else if(!iCommitOperationInProgress )
   563             {
   557             {
   564             TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::DoHnadleSingleContactOperationCompleteL() else if after if after iOperationError"));
   558             TRACE( "else if after if after iOperationError");
   565             CommitNextPendingContactsL();// commit only if any pending contact
   559             CommitNextPendingContactsL();// commit only if any pending contact
   566             }
   560             }
   567         TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::DoHnadleSingleContactOperationCompleteL() end"));
   561        
   568         }
   562         }
   569     }
   563     }
   570 //----------------------------------------------------------------------
   564 //----------------------------------------------------------------------
   571 //CVIMPSTStorageVPbkStoreHandler::VPbkSingleContactOperationComplete()
   565 //CVIMPSTStorageVPbkStoreHandler::VPbkSingleContactOperationComplete()
   572 //----------------------------------------------------------------------
   566 //----------------------------------------------------------------------
   573 void CVIMPSTStorageVPbkStoreHandler::VPbkSingleContactOperationFailed( MVPbkContactOperationBase& aOperation,
   567 void CVIMPSTStorageVPbkStoreHandler::VPbkSingleContactOperationFailed( MVPbkContactOperationBase& aOperation,
   574                                                                    TInt aError)
   568                                                                    TInt aError)
   575     {
   569     {
   576     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::VPbkSingleContactOperationFailed() begin"));
   570 	TRACER_AUTO;
   577 	if( &aOperation == iContactOperation )
   571 	if( &aOperation == iContactOperation )
   578         {
   572         {
   579         delete iContactOperation;
   573         delete iContactOperation;
   580         iContactOperation = NULL;
   574         iContactOperation = NULL;
   581         }
   575         }
   584     if( iWait.IsStarted() )
   578     if( iWait.IsStarted() )
   585 	    {
   579 	    {
   586 	    iWait.AsyncStop();	
   580 	    iWait.AsyncStop();	
   587 	    }
   581 	    }
   588     TRAP_IGNORE( CommitNextPendingContactsL() );// commit only if any pending contact
   582     TRAP_IGNORE( CommitNextPendingContactsL() );// commit only if any pending contact
   589 	TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::VPbkSingleContactOperationFailed() begin"));
   583 	
   590     }
   584     }
   591 // --------------------------------------------------------------------------
   585 // --------------------------------------------------------------------------
   592 // CVIMPSTStorageVPbkStoreHandler::HandleContactViewReadyL
   586 // CVIMPSTStorageVPbkStoreHandler::HandleContactViewReadyL
   593 // --------------------------------------------------------------------------
   587 // --------------------------------------------------------------------------
   594 //
   588 //
   595 void CVIMPSTStorageVPbkStoreHandler::HandleContactViewReadyL( MVPbkContactViewBase& aView  )
   589 void CVIMPSTStorageVPbkStoreHandler::HandleContactViewReadyL( MVPbkContactViewBase& aView  )
   596 	{
   590 	{
   597 	TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::HandleContactViewReadyL() begin"));
   591 	TRACER_AUTO;
   598 	TInt contactCount = aView.ContactCountL();
   592 	TInt contactCount = aView.ContactCountL();
   599 	TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::HandleContactViewReadyL() begin"));
   593 	TRACE( "begin");
   600 	if( contactCount == iFetcingIndex  && iStoreEventType == EVPbkContactReading )
   594 	if( contactCount == iFetcingIndex  && iStoreEventType == EVPbkContactReading )
   601 		{
   595 		{
   602 		TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::HandleContactViewReadyL() reading completed") );
   596 		TRACE( "reading completed" );
   603 		iStoreEventType = EVPbkContactReadCompleted;
   597 		iStoreEventType = EVPbkContactReadCompleted;
   604 		TVIMPSTVPbkStoreEvent storeEvent(iStoreEventType);
   598 		TVIMPSTVPbkStoreEvent storeEvent(iStoreEventType);
   605 		iStoreHandler.HandleVPbkStoreEventL( storeEvent ) ;
   599 		iStoreHandler.HandleVPbkStoreEventL( storeEvent ) ;
   606 		}
   600 		}
   607 	else if( iFetcingIndex < contactCount && iFetcingIndex>=0 )
   601 	else if( iFetcingIndex < contactCount && iFetcingIndex>=0 )
   608 		{
   602 		{
   609 		TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::HandleContactViewReadyL() reading"));
   603 		TRACE( " reading");
   610 		const MVPbkViewContact& contact =  aView.ContactAtL( iFetcingIndex );
   604 		const MVPbkViewContact& contact =  aView.ContactAtL( iFetcingIndex );
   611 		MVPbkContactLink* contactLink = contact.CreateLinkLC();
   605 		MVPbkContactLink* contactLink = contact.CreateLinkLC();
   612 		delete iContactLink;
   606 		delete iContactLink;
   613 		iContactLink = NULL;
   607 		iContactLink = NULL;
   614 		iContactLink = 	contactLink;
   608 		iContactLink = 	contactLink;
   615 		CleanupStack::Pop(); // contactLink
   609 		CleanupStack::Pop(); // contactLink
   616 		IssueRequest();
   610 		IssueRequest();
   617 		iFetcingIndex++;
   611 		iFetcingIndex++;
   618 		}
   612 		}
   619 	TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::HandleContactViewReadyL() end"));
   613 	
   620 	}
   614 	}
   621 // --------------------------------------------------------------------------
   615 // --------------------------------------------------------------------------
   622 // CVIMPSTStorageVPbkStoreHandler::IssueRequest
   616 // CVIMPSTStorageVPbkStoreHandler::IssueRequest
   623 // --------------------------------------------------------------------------
   617 // --------------------------------------------------------------------------
   624 //
   618 //
   625 void CVIMPSTStorageVPbkStoreHandler::IssueRequest()
   619 void CVIMPSTStorageVPbkStoreHandler::IssueRequest()
   626     {
   620     {
   627     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::IssueRequest() begin"));
   621 	TRACER_AUTO;
   628     if( !IsActive() )
   622     if( !IsActive() )
   629 	    {
   623 	    {
   630 	    TRequestStatus* status = &iStatus;
   624 	    TRequestStatus* status = &iStatus;
   631 	    User::RequestComplete( status, KErrNone );
   625 	    User::RequestComplete( status, KErrNone );
   632 	    SetActive();
   626 	    SetActive();
   633 	    }
   627 	    }
   634 	TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::IssueRequest() end"));
   628 	
   635     }
   629     }
   636 	
   630 	
   637 // --------------------------------------------------------------------------
   631 // --------------------------------------------------------------------------
   638 // CVIMPSTStorageVPbkStoreHandler::RunL
   632 // CVIMPSTStorageVPbkStoreHandler::RunL
   639 // --------------------------------------------------------------------------
   633 // --------------------------------------------------------------------------
   640 //
   634 //
   641 void CVIMPSTStorageVPbkStoreHandler::RunL()
   635 void CVIMPSTStorageVPbkStoreHandler::RunL()
   642     {
   636     {
   643     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::RunL() begin") );
   637 	TRACER_AUTO;
   644     if( iContactLink )
   638     if( iContactLink )
   645 	    {
   639 	    {
   646 	    delete iContactOperation;
   640 	    delete iContactOperation;
   647 	    iContactOperation = NULL;
   641 	    iContactOperation = NULL;
   648 	    iContactOperation = iContactManager->RetrieveContactL( *iContactLink, *this );	
   642 	    iContactOperation = iContactManager->RetrieveContactL( *iContactLink, *this );	
   649 	    }
   643 	    }
   650 	TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::RunL() end"));
   644 	
   651     }
   645     }
   652 
   646 
   653 // --------------------------------------------------------------------------
   647 // --------------------------------------------------------------------------
   654 // CVIMPSTStorageVPbkStoreHandler::DoCancel
   648 // CVIMPSTStorageVPbkStoreHandler::DoCancel
   655 // --------------------------------------------------------------------------
   649 // --------------------------------------------------------------------------
   656 //
   650 //
   657 void CVIMPSTStorageVPbkStoreHandler::DoCancel()
   651 void CVIMPSTStorageVPbkStoreHandler::DoCancel()
   658     {
   652     {
   659     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::DoCancel() begin") );
   653 	TRACER_AUTO;
   660     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::DoCancel() end") );
       
   661     }
   654     }
   662 
   655 
   663 // --------------------------------------------------------------------------
   656 // --------------------------------------------------------------------------
   664 // CVIMPSTStorageVPbkStoreHandler::RunError
   657 // CVIMPSTStorageVPbkStoreHandler::RunError
   665 // --------------------------------------------------------------------------
   658 // --------------------------------------------------------------------------
   666 //
   659 //
   667 TInt CVIMPSTStorageVPbkStoreHandler::RunError( TInt aError )
   660 TInt CVIMPSTStorageVPbkStoreHandler::RunError( TInt aError )
   668     {  
   661     {  
   669     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::RunError()") );  
   662 	TRACER_AUTO;
   670     return aError;
   663     return aError;
   671     }
   664     }
   672 
   665 
   673 //////////////////////////////////////////////////////////
   666 //////////////////////////////////////////////////////////
   674 // ---------------------------------------------------------------------------
   667 // ---------------------------------------------------------------------------
   676 // ---------------------------------------------------------------------------
   669 // ---------------------------------------------------------------------------
   677 // 
   670 // 
   678 TInt CVIMPSTStorageVPbkStoreHandler::CreateVPbkContactL(const TDesC& aUserId, 
   671 TInt CVIMPSTStorageVPbkStoreHandler::CreateVPbkContactL(const TDesC& aUserId, 
   679         						 						const TDesC& aDisplayName )   
   672         						 						const TDesC& aDisplayName )   
   680 	{
   673 	{
   681 	TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::CreateVPbkContactL() begin") );
   674 	TRACER_AUTO;
   682 	TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::CreateVPbkContactL() aUserId = %S"), &aUserId );
   675 	TRACE( "aUserId = %S", &aUserId );
   683 	
   676 	
   684 	if( iAddIdInProgress && iAddIdInProgress->Compare( aUserId ) == 0 )
   677 	if( iAddIdInProgress && iAddIdInProgress->Compare( aUserId ) == 0 )
   685 		{
   678 		{
   686 		TPtr iAddIdInProgressPtr = iAddIdInProgress->Des();
   679 		TPtr iAddIdInProgressPtr = iAddIdInProgress->Des();
   687 		TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::CreateVPbkContactL() iAddIdInProgressPtr = %S"), &iAddIdInProgressPtr );
   680 		TRACE("iAddIdInProgressPtr = %S", &iAddIdInProgressPtr );
   688 		TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::CreateVPbkContactL() already Adding") );
   681 		TRACE("already Adding" );
   689 		return KErrAlreadyExists;	
   682 		return KErrAlreadyExists;	
   690 		}
   683 		}
   691 	TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::CreateVPbkContactL() After If") );
   684 	TRACE( "After If" );
   692 	delete iAddIdInProgress;
   685 	delete iAddIdInProgress;
   693 	iAddIdInProgress = NULL;
   686 	iAddIdInProgress = NULL;
   694 	iAddIdInProgress = aUserId.AllocL();
   687 	iAddIdInProgress = aUserId.AllocL();
   695 	
   688 	
   696     if(iStore)
   689     if(iStore)
   700 			{
   693 			{
   701 			return NULL;    
   694 			return NULL;    
   702 			}
   695 			}
   703 		if(aUserId.Length()!= 0)
   696 		if(aUserId.Length()!= 0)
   704 			{
   697 			{
   705 			TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::CreateVPbkContactL() valid xsp Id") );
   698 			TRACE( " valid xsp Id" );
   706 			TInt prefixLocation = aUserId.Locate( ':' );
   699 			TInt prefixLocation = aUserId.Locate( ':' );
   707 			const MVPbkContactStoreProperties& storeProperties =  storedContact->ParentStore().StoreProperties();
   700 			const MVPbkContactStoreProperties& storeProperties =  storedContact->ParentStore().StoreProperties();
   708 			const MVPbkFieldTypeList& supportedFieldTypes = storeProperties.SupportedFields();
   701 			const MVPbkFieldTypeList& supportedFieldTypes = storeProperties.SupportedFields();
   709 			TInt fieldCount = supportedFieldTypes.FieldTypeCount();
   702 			TInt fieldCount = supportedFieldTypes.FieldTypeCount();
   710 
   703 
   711 			for( TInt index = 0 ; index < fieldCount ; index++ )
   704 			for( TInt index = 0 ; index < fieldCount ; index++ )
   712 				{        
   705 				{        
   713 				const MVPbkFieldType* fieldType = &(supportedFieldTypes.FieldTypeAt(index));
   706 				const MVPbkFieldType* fieldType = &(supportedFieldTypes.FieldTypeAt(index));
   714 				if ( fieldType && ( fieldType->FieldTypeResId() == R_VPBK_FIELD_TYPE_IMPP ))
   707 				if ( fieldType && ( fieldType->FieldTypeResId() == R_VPBK_FIELD_TYPE_IMPP ))
   715 					{
   708 					{
   716 					TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::CreateVPbkContactL() XSP Id-IMMP field creating") );
   709 					TRACE(" XSP Id-IMMP field creating" );
   717 					MVPbkStoreContactField* fielduri = storedContact->CreateFieldLC(*fieldType);  //2
   710 					MVPbkStoreContactField* fielduri = storedContact->CreateFieldLC(*fieldType);  //2
   718 					// Check for prefix and remove if found
   711 					// Check for prefix and remove if found
   719 					//append the internettelephoney field.
   712 					//append the internettelephoney field.
   720 					HBufC* fieldData = NULL;
   713 					HBufC* fieldData = NULL;
   721 					TInt serFieldLength = aUserId.Length();
   714 					TInt serFieldLength = aUserId.Length();
   740 						}//End if (fieldData)
   733 						}//End if (fieldData)
   741 					else
   734 					else
   742 						{
   735 						{
   743 						CleanupStack::PopAndDestroy(); //2 fielduri 	
   736 						CleanupStack::PopAndDestroy(); //2 fielduri 	
   744 						}
   737 						}
   745 					TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::CreateVPbkContactL() XSP Id-IMMP field created") );
   738 					TRACE( " XSP Id-IMMP field created" );
   746 					}//end of if
   739 					}//end of if
   747 				else if ( fieldType &&  
   740 				else if ( fieldType &&  
   748 					( fieldType->FieldTypeResId() == R_VPBK_FIELD_TYPE_FIRSTNAME ))
   741 					( fieldType->FieldTypeResId() == R_VPBK_FIELD_TYPE_FIRSTNAME ))
   749 					{
   742 					{
   750 					TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::CreateVPbkContactL() first name field creating") );
   743 					TRACE( " first name field creating" );
   751 					HBufC* firstName = NULL;
   744 					HBufC* firstName = NULL;
   752 					
   745 					
   753 					// if there is no display name then allocate hte user id as displayname.
   746 					// if there is no display name then allocate hte user id as displayname.
   754 					if(!(aDisplayName.Length()))
   747 					if(!(aDisplayName.Length()))
   755                        {
   748                        {
   782 						storedContact->AddFieldL(firstNamefield); // firstNamefield ownership transfered to storedContact
   775 						storedContact->AddFieldL(firstNamefield); // firstNamefield ownership transfered to storedContact
   783 						CleanupStack::Pop();  //firstNamefield  2 
   776 						CleanupStack::Pop();  //firstNamefield  2 
   784 						CleanupStack::PopAndDestroy(firstName); // 3
   777 						CleanupStack::PopAndDestroy(firstName); // 3
   785 						}//End if (firstName)
   778 						}//End if (firstName)
   786 
   779 
   787 					TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::CreateVPbkContactL() first name field created") );                    
   780 					TRACE( "first name field created" );                    
   788 					}//end of if.
   781 					}//end of if.
   789 				}//end of for.
   782 				}//end of for.
   790 			TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::CreateVPbkContactL() iCommitOperationInProgress = %d"),iCommitOperationInProgress );
   783 			TRACE( "iCommitOperationInProgress = %d",iCommitOperationInProgress );
   791 			if( iCommitOperationInProgress )
   784 			if( iCommitOperationInProgress )
   792 			    {
   785 			    {
   793 			    TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::CreateVPbkContactL() inside if") );
   786 			    TRACE("inside if" );
   794 			    iUnCommittedVPbkContacts.AppendL( storedContact ); //takes ownership
   787 			    iUnCommittedVPbkContacts.AppendL( storedContact ); //takes ownership
   795 			    CleanupStack::Pop(); //storedContact
   788 			    CleanupStack::Pop(); //storedContact
   796 			    }
   789 			    }
   797 			else
   790 			else
   798 			    {
   791 			    {
   799 			    TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::CreateVPbkContactL() inside else") );
   792 			    TRACE( "inside else");
   800 			    iCommitOperationInProgress = ETrue;
   793 			    iCommitOperationInProgress = ETrue;
   801 			    if(iStoreContact)
   794 			    if(iStoreContact)
   802 			        {
   795 			        {
   803 			        delete iStoreContact;
   796 			        delete iStoreContact;
   804 			        iStoreContact = NULL;
   797 			        iStoreContact = NULL;
   805 			        }
   798 			        }
   806 			    TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::CreateVPbkContactL() contact fields added") );
   799 			    TRACE( "contact fields added" );
   807 			    iStoreContact = storedContact;
   800 			    iStoreContact = storedContact;
   808 			    CleanupStack::Pop(); //storedContact
   801 			    CleanupStack::Pop(); //storedContact
   809 			    iStoreContact->CommitL(*this);
   802 			    iStoreContact->CommitL(*this);
   810 			    iStoreEventType = EVPbkContactAdded;
   803 			    iStoreEventType = EVPbkContactAdded;
   811 			    }
   804 			    }
   812 			TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::CreateVPbkContactL() contact commited") );
   805 			TRACE( "contact commited");
   813 			//Start the wait untill adding of new contact is complete
   806 			//Start the wait untill adding of new contact is complete
   814 			}
   807 			}
   815 		}
   808 		}
   816     //return the added contact 
   809     //return the added contact 
   817     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::CreateVPbkContactL() iOperationError =%d"),iOperationError );
   810     TRACE( "iOperationError =%d",iOperationError );
   818 	TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::CreateVPbkContactL() end") );        
   811 	      
   819 	return iOperationError; 
   812 	return iOperationError; 
   820 	}
   813 	}
   821 
   814 
   822 // ---------------------------------------------------------------------------
   815 // ---------------------------------------------------------------------------
   823 // CVIMPSTStorageVPbkStoreHandler::CommitNextPendingContactsL
   816 // CVIMPSTStorageVPbkStoreHandler::CommitNextPendingContactsL
   824 // ---------------------------------------------------------------------------
   817 // ---------------------------------------------------------------------------
   825 //  
   818 //  
   826 void CVIMPSTStorageVPbkStoreHandler::CommitNextPendingContactsL() 
   819 void CVIMPSTStorageVPbkStoreHandler::CommitNextPendingContactsL() 
   827     {
   820     {
   828     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::CommitNextPendingContactsL() Start") );
   821 	
   829     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::CommitNextPendingContactsL() iStoreEventType = %d"),iStoreEventType );
   822 	TRACER_AUTO;
       
   823     TRACE("iStoreEventType = %d",iStoreEventType );
   830     if( !iCommitOperationInProgress && iUnCommittedVPbkContacts.Count() && iStoreEventType != EVPbkUpdatingAvatar)
   824     if( !iCommitOperationInProgress && iUnCommittedVPbkContacts.Count() && iStoreEventType != EVPbkUpdatingAvatar)
   831         {
   825         {
   832         TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::CommitNextPendingContactsL() Commit next") );
   826         TRACE( " Commit next" );
   833         iCommitOperationInProgress = ETrue;
   827         iCommitOperationInProgress = ETrue;
   834         if(iStoreContact)
   828         if(iStoreContact)
   835             {
   829             {
   836             delete iStoreContact;
   830             delete iStoreContact;
   837             iStoreContact = NULL;
   831             iStoreContact = NULL;
   838             }
   832             }
   839         TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::CommitNextPendingContactsL() comming...") );
   833         TRACE( "comming..." );
   840         iStoreContact = iUnCommittedVPbkContacts[0];
   834         iStoreContact = iUnCommittedVPbkContacts[0];
   841         iUnCommittedVPbkContacts.Remove(0);
   835         iUnCommittedVPbkContacts.Remove(0);
   842         iUnCommittedVPbkContacts.Compress();
   836         iUnCommittedVPbkContacts.Compress();
   843         iStoreContact->CommitL(*this);
   837         iStoreContact->CommitL(*this);
   844         iStoreEventType = EVPbkContactSynchronizing;
   838         iStoreEventType = EVPbkContactSynchronizing;
   845         TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::CommitNextPendingContactsL() Commit called") );
   839         TRACE( " Commit called" );
   846         }
   840         }
   847     else if(!iCommitOperationInProgress && iPendingAvatars.Count()  && iStoreEventType != EVPbkUpdatingAvatar)
   841     else if(!iCommitOperationInProgress && iPendingAvatars.Count()  && iStoreEventType != EVPbkUpdatingAvatar)
   848         {
   842         {
   849         TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::CommitNextPendingContactsL() Commit next pending avatar") );
   843         TRACE( "Commit next pending avatar" );
   850         TVIMPSTAvatarData avatarData = iPendingAvatars[0];
   844         TVIMPSTAvatarData avatarData = iPendingAvatars[0];
   851         UpdateAvatarFieldDataL( *avatarData.iContactLink, *avatarData.iAvatarContent );
   845         UpdateAvatarFieldDataL( *avatarData.iContactLink, *avatarData.iAvatarContent );
   852         iPendingAvatars.Remove( 0 );
   846         iPendingAvatars.Remove( 0 );
   853         delete avatarData.iContactLink;
   847         delete avatarData.iContactLink;
   854         avatarData.iContactLink = NULL;
   848         avatarData.iContactLink = NULL;
   855         delete avatarData.iAvatarContent;
   849         delete avatarData.iAvatarContent;
   856         avatarData.iAvatarContent = NULL;
   850         avatarData.iAvatarContent = NULL;
   857         iPendingAvatars.Compress();
   851         iPendingAvatars.Compress();
   858         }
   852         }
   859     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::CommitNextPendingContactsL() End") );
   853     
   860     }
   854     }
   861 
   855 
   862 // ---------------------------------------------------------------------------
   856 // ---------------------------------------------------------------------------
   863 // CVIMPSTStorageVPbkStoreHandler::RemoveVPbkContactL
   857 // CVIMPSTStorageVPbkStoreHandler::RemoveVPbkContactL
   864 // ---------------------------------------------------------------------------
   858 // ---------------------------------------------------------------------------
   865 //  
   859 //  
   866 TInt CVIMPSTStorageVPbkStoreHandler::RemoveVPbkContactL(const CVPbkContactLinkArray& aContactLinkArray ) 
   860 TInt CVIMPSTStorageVPbkStoreHandler::RemoveVPbkContactL(const CVPbkContactLinkArray& aContactLinkArray ) 
   867 	{
   861 	{
   868 	TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::RemoveVPbkContactL() begin") );
   862 	TRACER_AUTO;
   869 	// text now holds the name (or first field of the contact) 
   863 	// text now holds the name (or first field of the contact) 
   870     delete iContactOperation;
   864     delete iContactOperation;
   871     iContactOperation = NULL;
   865     iContactOperation = NULL;
   872     iContactOperation = iContactManager->DeleteContactsL(aContactLinkArray, *this  );
   866     iContactOperation = iContactManager->DeleteContactsL(aContactLinkArray, *this  );
   873     if( !iWait.IsStarted() )
   867     if( !iWait.IsStarted() )
   874 	    {
   868 	    {
   875 	    iWait.Start();	
   869 	    iWait.Start();	
   876 	    }
   870 	    }
   877 	TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::RemoveVPbkContactL() iOperationError=%d"),iOperationError ); 
   871 	TRACE( "iOperationError=%d",iOperationError ); 
   878 	TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::RemoveVPbkContactL() end") );     
   872 	 
   879     return iOperationError;
   873     return iOperationError;
   880   	}
   874   	}
   881 
   875 
   882 // ---------------------------------------------------------------------------
   876 // ---------------------------------------------------------------------------
   883 // CVIMPSTStorageVPbkStoreHandler::RetrieveVPbkContactL
   877 // CVIMPSTStorageVPbkStoreHandler::RetrieveVPbkContactL
   884 // ---------------------------------------------------------------------------
   878 // ---------------------------------------------------------------------------
   885 //  
   879 //  
   886 TInt CVIMPSTStorageVPbkStoreHandler::RetrieveVPbkContactL(const TDesC8& aPackedLinks) 
   880 TInt CVIMPSTStorageVPbkStoreHandler::RetrieveVPbkContactL(const TDesC8& aPackedLinks) 
   887 	{
   881 	{
   888 	TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::RetrieveVPbkContactL() begin") );   
   882 	TRACER_AUTO;  
   889 	iStoreEventType = EVPbkContactRetriving;
   883 	iStoreEventType = EVPbkContactRetriving;
   890 	CVPbkContactLinkArray* linkArray = CVPbkContactLinkArray::NewLC(aPackedLinks, *iStores );
   884 	CVPbkContactLinkArray* linkArray = CVPbkContactLinkArray::NewLC(aPackedLinks, *iStores );
   891     // text now holds the name (or first field of the contact) 
   885     // text now holds the name (or first field of the contact) 
   892     TInt count = linkArray->Count();
   886     TInt count = linkArray->Count();
   893     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::StoreReady() count=%d"),count );   
   887     TRACE( "count=%d",count );   
   894     for ( TInt i=0; i<count; i++ )
   888     for ( TInt i=0; i<count; i++ )
   895 	    {
   889 	    {
   896 	    delete iContactLink;
   890 	    delete iContactLink;
   897 	    iContactLink = NULL;
   891 	    iContactLink = NULL;
   898 	    // local variable caz cant push member variable to cleanup stack
   892 	    // local variable caz cant push member variable to cleanup stack
   908 		    {
   902 		    {
   909 		    iWait.Start();	
   903 		    iWait.Start();	
   910 		    }
   904 		    }
   911 	    }
   905 	    }
   912     CleanupStack::PopAndDestroy();//linkArray
   906     CleanupStack::PopAndDestroy();//linkArray
   913     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::RetrieveVPbkContactL() end") );   
   907    
   914     return iOperationError;
   908     return iOperationError;
   915     }
   909     }
   916  
   910  
   917                 
   911                 
   918                 
   912                 
   921 // ---------------------------------------------------------------------------
   915 // ---------------------------------------------------------------------------
   922 //
   916 //
   923 TInt CVIMPSTStorageVPbkStoreHandler::UpdateAvatarFieldDataL(const MVPbkContactLink& aContactLink,
   917 TInt CVIMPSTStorageVPbkStoreHandler::UpdateAvatarFieldDataL(const MVPbkContactLink& aContactLink,
   924 														    const TDesC8& aAvatartData )
   918 														    const TDesC8& aAvatartData )
   925     {
   919     {
   926     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::UpdateAvatarFieldDataL() begin") ); 
   920 	TRACER_AUTO;
   927   
   921   
   928     // local variable caz cant push member variable to cleanup stack
   922     // local variable caz cant push member variable to cleanup stack
   929     MVPbkContactLink* cloneLink = aContactLink.CloneLC();
   923     MVPbkContactLink* cloneLink = aContactLink.CloneLC();
   930     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::UpdateAvatarFieldDataL() iCommitOperationInProgress: %d"),iCommitOperationInProgress );  
   924     TRACE( "iCommitOperationInProgress: %d",iCommitOperationInProgress );  
   931     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::UpdateAvatarFieldDataL() iUnCommittedVPbkContacts: %d"),iUnCommittedVPbkContacts.Count() );
   925     TRACE( "iUnCommittedVPbkContacts: %d",iUnCommittedVPbkContacts.Count() );
   932     if(iCommitOperationInProgress || iUnCommittedVPbkContacts.Count() || iStoreEventType == EVPbkUpdatingAvatar )
   926     if(iCommitOperationInProgress || iUnCommittedVPbkContacts.Count() || iStoreEventType == EVPbkUpdatingAvatar )
   933         {
   927         {
   934         TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::UpdateAvatarFieldDataL()Inside if") ); 
   928         TRACE( "Inside if" ); 
   935         TVIMPSTAvatarData avatarData = {
   929         TVIMPSTAvatarData avatarData = {
   936                                        cloneLink,
   930                                        cloneLink,
   937                                        aAvatartData.AllocL()
   931                                        aAvatartData.AllocL()
   938                                       };
   932                                       };
   939         iPendingAvatars.Append( avatarData );
   933         iPendingAvatars.Append( avatarData );
   940         CleanupStack::Pop(); // cloneLink
   934         CleanupStack::Pop(); // cloneLink
   941         return KErrInUse;
   935         return KErrInUse;
   942         }
   936         }
   943     iCommitOperationInProgress = ETrue;
   937     iCommitOperationInProgress = ETrue;
   944     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::UpdateAvatarFieldDataL()Inside after if") ); 
   938     TRACE( "Inside after if" ); 
   945     delete iContactLink;
   939     delete iContactLink;
   946     iContactLink = NULL;
   940     iContactLink = NULL;
   947     iContactLink = cloneLink;
   941     iContactLink = cloneLink;
   948     CleanupStack::Pop(); // cloneLink
   942     CleanupStack::Pop(); // cloneLink
   949     
   943     
  1004 				CleanupStack::Pop(); // storeField  
   998 				CleanupStack::Pop(); // storeField  
  1005 				break;                   
   999 				break;                   
  1006 				}
  1000 				}
  1007 	        }
  1001 	        }
  1008 		}
  1002 		}
  1009 	TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::UpdateAvatarFieldDataL()Inside after if(avatardata.length)") ); 
  1003 	TRACE( "Inside after if(avatardata.length)" ); 
  1010 	iStoreEventType = EVPbkContactChanged;
  1004 	iStoreEventType = EVPbkContactChanged;
  1011 	TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::UpdateAvatarFieldDataL()Inside after if(avatardata.length ): %d"),iStoreEventType ); 
  1005 	TRACE( "Inside after if(avatardata.length ): %d",iStoreEventType ); 
  1012 	iStoreContact->CommitL(*this);
  1006 	iStoreContact->CommitL(*this);
  1013 	//wait for delete Avatar operation to complete.
  1007 	//wait for delete Avatar operation to complete.
  1014 	if(!iWait.IsStarted() ) 
  1008 	if(!iWait.IsStarted() ) 
  1015 		{
  1009 		{
  1016 		iWait.Start();	
  1010 		iWait.Start();	
  1017 		}
  1011 		}
  1018 	TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::UpdateAvatarFieldDataL() end") );   
  1012 	
  1019 	return iOperationError;
  1013 	return iOperationError;
  1020     }
  1014     }
  1021 
  1015 
  1022 // ---------------------------------------------------------------------------
  1016 // ---------------------------------------------------------------------------
  1023 // CVIMPSTStorageVPbkStoreHandler::RemoveAvatarFieldL()
  1017 // CVIMPSTStorageVPbkStoreHandler::RemoveAvatarFieldL()
  1024 // ---------------------------------------------------------------------------
  1018 // ---------------------------------------------------------------------------
  1025 //
  1019 //
  1026 TInt CVIMPSTStorageVPbkStoreHandler::RemoveAvatarFieldL(MVPbkStoreContact& aStoreContact)
  1020 TInt CVIMPSTStorageVPbkStoreHandler::RemoveAvatarFieldL(MVPbkStoreContact& aStoreContact)
  1027 	{
  1021 	{
  1028 	TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::RemoveAvatarFieldL() begin") );   
  1022 	TRACER_AUTO;
  1029 	aStoreContact.LockL(*this);
  1023 	aStoreContact.LockL(*this);
  1030     //wait till lock operation is succeded
  1024     //wait till lock operation is succeded
  1031     if(!iWait.IsStarted() ) 
  1025     if(!iWait.IsStarted() ) 
  1032 	    {
  1026 	    {
  1033 	    iWait.Start();	
  1027 	    iWait.Start();	
  1046 	//wait for delete Avatar operation to complete.
  1040 	//wait for delete Avatar operation to complete.
  1047 	if(!iWait.IsStarted() ) 
  1041 	if(!iWait.IsStarted() ) 
  1048 		{
  1042 		{
  1049 		iWait.Start();	
  1043 		iWait.Start();	
  1050 		}
  1044 		}
  1051 	TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::RemoveAvatarFieldL() iOperationError =%d"),iOperationError );   
  1045 	TRACE( "iOperationError =%d",iOperationError );   
  1052 	TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::RemoveAvatarFieldL() end") );   
  1046 	
  1053 	return iOperationError;	
  1047 	return iOperationError;	
  1054 	}
  1048 	}
  1055 
  1049 
  1056 // ---------------------------------------------------------------------------
  1050 // ---------------------------------------------------------------------------
  1057 // CVIMPSTStorageVPbkStoreHandler::GetContactFieldDataLC()
  1051 // CVIMPSTStorageVPbkStoreHandler::GetContactFieldDataLC()
  1058 // ---------------------------------------------------------------------------
  1052 // ---------------------------------------------------------------------------
  1059 // 
  1053 // 
  1060 HBufC* CVIMPSTStorageVPbkStoreHandler::GetContactFieldDataLC(const MVPbkStoreContact& aContact,
  1054 HBufC* CVIMPSTStorageVPbkStoreHandler::GetContactFieldDataLC(const MVPbkStoreContact& aContact,
  1061 												    		 TInt aFieldResId ) 
  1055 												    		 TInt aFieldResId ) 
  1062     {
  1056     {
  1063     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::GetContactFieldDataLC() begin") );   
  1057 	TRACER_AUTO;
  1064     HBufC* retValue = NULL;
  1058     HBufC* retValue = NULL;
  1065     const MVPbkStoreContactFieldCollection& fieldCollection = aContact.Fields();
  1059     const MVPbkStoreContactFieldCollection& fieldCollection = aContact.Fields();
  1066 	TInt fieldCount = fieldCollection.FieldCount();
  1060 	TInt fieldCount = fieldCollection.FieldCount();
  1067     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::GetContactFieldDataLC() fieldCount%d"),fieldCount );   
  1061     TRACE( " fieldCount%d",fieldCount );   
  1068 	for( TInt index = 0 ; index < fieldCount ;  index++ )
  1062 	for( TInt index = 0 ; index < fieldCount ;  index++ )
  1069 		{
  1063 		{
  1070 		const MVPbkStoreContactField& field = fieldCollection.FieldAt( index );
  1064 		const MVPbkStoreContactField& field = fieldCollection.FieldAt( index );
  1071 		const MVPbkFieldType* fieldType = field.BestMatchingFieldType();
  1065 		const MVPbkFieldType* fieldType = field.BestMatchingFieldType();
  1072 		//find the relevant xSP field
  1066 		//find the relevant xSP field
  1075 			const MVPbkContactFieldData& fieldData = field.FieldData();
  1069 			const MVPbkContactFieldData& fieldData = field.FieldData();
  1076 			switch( fieldData.DataType() )
  1070 			switch( fieldData.DataType() )
  1077 				{
  1071 				{
  1078 				case EVPbkFieldStorageTypeText:
  1072 				case EVPbkFieldStorageTypeText:
  1079 					{
  1073 					{
  1080 					TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::GetContactFieldDataLC() Text") );   
  1074 					TRACE(" Text" );   
  1081 					retValue = MVPbkContactFieldTextData::Cast(fieldData).Text().AllocLC();
  1075 					retValue = MVPbkContactFieldTextData::Cast(fieldData).Text().AllocLC();
  1082 					break;					
  1076 					break;					
  1083 					}
  1077 					}
  1084 				case EVPbkFieldStorageTypeUri:				
  1078 				case EVPbkFieldStorageTypeUri:				
  1085 					{
  1079 					{
  1086 					TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::GetContactFieldDataLC() Uri "));   
  1080 					TRACE(" Uri ");   
  1087 					retValue = MVPbkContactFieldUriData::Cast(fieldData).Text().AllocLC();
  1081 					retValue = MVPbkContactFieldUriData::Cast(fieldData).Text().AllocLC();
  1088 					break;	
  1082 					break;	
  1089 					}
  1083 					}
  1090 				
  1084 				
  1091 				}//End switch
  1085 				}//End switch
  1092 			if( aFieldResId == R_VPBK_FIELD_TYPE_IMPP && retValue )
  1086 			if( aFieldResId == R_VPBK_FIELD_TYPE_IMPP && retValue )
  1093 				{
  1087 				{
  1094 				TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::GetContactFieldDataLC() IMPP fild found"));   
  1088 				TRACE( " IMPP fild found");   
  1095 				// TODO RAMC : Nikhil/Mukesh
  1089 				// TODO RAMC : Nikhil/Mukesh
  1096 				// in case of srver contacts it also find the first valid xsp id
  1090 				// in case of srver contacts it also find the first valid xsp id
  1097 				// not valid through NULL
  1091 				// not valid through NULL
  1098 				// which can be clarified 
  1092 				// which can be clarified 
  1099 				// earlier it show selection query in UI which one to use
  1093 				// earlier it show selection query in UI which one to use
  1100 				TPtrC scheme = MVPbkContactFieldUriData::Cast(fieldData).Scheme();
  1094 				TPtrC scheme = MVPbkContactFieldUriData::Cast(fieldData).Scheme();
  1101 				if( scheme.Compare( *iServiceName ) == 0 )
  1095 				if( scheme.Compare( *iServiceName ) == 0 )
  1102 					{
  1096 					{
  1103 					TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::GetContactFieldDataLC() actual xsp Id found"));   
  1097 					TRACE( " actual xsp Id found");   
  1104 					// actual xsp id found break the loop and return 
  1098 					// actual xsp id found break the loop and return 
  1105 					break;	
  1099 					break;	
  1106 					}
  1100 					}
  1107 				else 
  1101 				else 
  1108 					{
  1102 					{
  1119 				}
  1113 				}
  1120 			}
  1114 			}
  1121 		}
  1115 		}
  1122 	if( !retValue )
  1116 	if( !retValue )
  1123 		{
  1117 		{
  1124 		TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::GetContactFieldDataLC() NULL value"));   
  1118 		TRACE( " NULL value");   
  1125 		// if NULL assign valid ptr
  1119 		// if NULL assign valid ptr
  1126 		retValue = KNullDesC().AllocLC();	
  1120 		retValue = KNullDesC().AllocLC();	
  1127 		}
  1121 		}
  1128 	TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::GetContactFieldDataLC() end"));   
  1122 	
  1129 	return retValue;// ownership is return to caller
  1123 	return retValue;// ownership is return to caller
  1130     }
  1124     }
  1131 
  1125 
  1132 // ---------------------------------------------------------------------------
  1126 // ---------------------------------------------------------------------------
  1133 // CVIMPSTStorageVPbkStoreHandler::GetContactBinaryFieldDataLC()
  1127 // CVIMPSTStorageVPbkStoreHandler::GetContactBinaryFieldDataLC()
  1134 // ---------------------------------------------------------------------------
  1128 // ---------------------------------------------------------------------------
  1135 // 
  1129 // 
  1136 HBufC8* CVIMPSTStorageVPbkStoreHandler::GetContactBinaryFieldDataLC(const MVPbkStoreContact& aContact,
  1130 HBufC8* CVIMPSTStorageVPbkStoreHandler::GetContactBinaryFieldDataLC(const MVPbkStoreContact& aContact,
  1137                                                              TInt aFieldResId ) 
  1131                                                              TInt aFieldResId ) 
  1138     {
  1132     {
  1139     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::GetContactBinaryFieldDataLC() begin") );   
  1133 	TRACER_AUTO;  
  1140     HBufC8* retValue = NULL;
  1134     HBufC8* retValue = NULL;
  1141     const MVPbkStoreContactFieldCollection& fieldCollection = aContact.Fields();
  1135     const MVPbkStoreContactFieldCollection& fieldCollection = aContact.Fields();
  1142     TInt fieldCount = fieldCollection.FieldCount();
  1136     TInt fieldCount = fieldCollection.FieldCount();
  1143     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::GetContactBinaryFieldDataLC() fieldCount%d"),fieldCount );   
  1137     TRACE( "fieldCount%d",fieldCount );   
  1144     for( TInt index = 0 ; index < fieldCount ;  index++ )
  1138     for( TInt index = 0 ; index < fieldCount ;  index++ )
  1145         {
  1139         {
  1146         const MVPbkStoreContactField& field = fieldCollection.FieldAt( index );
  1140         const MVPbkStoreContactField& field = fieldCollection.FieldAt( index );
  1147         const MVPbkFieldType* fieldType = field.BestMatchingFieldType();
  1141         const MVPbkFieldType* fieldType = field.BestMatchingFieldType();
  1148         //find the relevant xSP field
  1142         //find the relevant xSP field
  1151             const MVPbkContactFieldData& fieldData = field.FieldData();
  1145             const MVPbkContactFieldData& fieldData = field.FieldData();
  1152             switch( fieldData.DataType() )
  1146             switch( fieldData.DataType() )
  1153                 {
  1147                 {
  1154                 case EVPbkFieldStorageTypeBinary:
  1148                 case EVPbkFieldStorageTypeBinary:
  1155                     {
  1149                     {
  1156                     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::GetContactBinaryFieldDataLC() Text") );
  1150                     TRACE( " Text" );
  1157                     retValue = MVPbkContactFieldBinaryData::Cast(fieldData).BinaryData().AllocLC();
  1151                     retValue = MVPbkContactFieldBinaryData::Cast(fieldData).BinaryData().AllocLC();
  1158                     break;                  
  1152                     break;                  
  1159                     }
  1153                     }
  1160                 }//End switch
  1154                 }//End switch
  1161              if( retValue )
  1155              if( retValue )
  1166                 }
  1160                 }
  1167             }
  1161             }
  1168         }
  1162         }
  1169     if( !retValue )
  1163     if( !retValue )
  1170         {
  1164         {
  1171         TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::GetContactBinaryFieldDataLC() NULL value"));   
  1165         TRACE( " NULL value");   
  1172         // if NULL assign valid ptr
  1166         // if NULL assign valid ptr
  1173         retValue = KNullDesC8().AllocLC();   
  1167         retValue = KNullDesC8().AllocLC();   
  1174         }
  1168         }
  1175     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::GetContactBinaryFieldDataLC() end"));   
  1169    
  1176     return retValue;// ownership is return to caller
  1170     return retValue;// ownership is return to caller
  1177     }
  1171     }
  1178 
  1172 
  1179 
  1173 
  1180 // ---------------------------------------------------------
  1174 // ---------------------------------------------------------
  1181 // CVIMPSTStorageVPbkStoreHandler::RetriveFieldDataAndSendEventL
  1175 // CVIMPSTStorageVPbkStoreHandler::RetriveFieldDataAndSendEventL
  1182 // 
  1176 // 
  1183 // ---------------------------------------------------------		
  1177 // ---------------------------------------------------------		
  1184 void CVIMPSTStorageVPbkStoreHandler::RetriveFieldDataAndSendEventL(const MVPbkStoreContact& aContact ) 
  1178 void CVIMPSTStorageVPbkStoreHandler::RetriveFieldDataAndSendEventL(const MVPbkStoreContact& aContact ) 
  1185 	{
  1179 	{
  1186 	TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::RetriveFieldDataAndSendEventL() begin") );   
  1180 	TRACER_AUTO;  
  1187 	HBufC* retValue = NULL;
  1181 	HBufC* retValue = NULL;
  1188     const MVPbkStoreContactFieldCollection& fieldCollection = aContact.Fields();
  1182     const MVPbkStoreContactFieldCollection& fieldCollection = aContact.Fields();
  1189 	TInt fieldCount = fieldCollection.FieldCount();
  1183 	TInt fieldCount = fieldCollection.FieldCount();
  1190     for( TInt index = 0 ; index < fieldCount ;  index++ )
  1184     for( TInt index = 0 ; index < fieldCount ;  index++ )
  1191 		{
  1185 		{
  1208 			const MVPbkContactFieldData& fieldData = field.FieldData();
  1202 			const MVPbkContactFieldData& fieldData = field.FieldData();
  1209 			switch( fieldData.DataType() )
  1203 			switch( fieldData.DataType() )
  1210 				{
  1204 				{
  1211 			    case EVPbkFieldStorageTypeText:
  1205 			    case EVPbkFieldStorageTypeText:
  1212                     {
  1206                     {
  1213                     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::RetriveFieldDataAndSendEventL() Text") );   
  1207                     TRACE( "Text" );   
  1214                     retValue = MVPbkContactFieldTextData::Cast(fieldData).Text().AllocLC();
  1208                     retValue = MVPbkContactFieldTextData::Cast(fieldData).Text().AllocLC();
  1215                     break;                  
  1209                     break;                  
  1216                     }
  1210                     }
  1217 				case EVPbkFieldStorageTypeUri:				
  1211 				case EVPbkFieldStorageTypeUri:				
  1218 					{
  1212 					{
  1219 					TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::RetriveFieldDataAndSendEventL() begin") ) ;   
  1213 					TRACE( "begin" ) ;   
  1220 					retValue = MVPbkContactFieldUriData::Cast(fieldData).Text().AllocLC();
  1214 					retValue = MVPbkContactFieldUriData::Cast(fieldData).Text().AllocLC();
  1221 					break;	
  1215 					break;	
  1222 					}
  1216 					}
  1223 				
  1217 				
  1224 				}//End switch
  1218 				}//End switch
  1225 			if( retValue )
  1219 			if( retValue )
  1226 				{
  1220 				{
  1227 				TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::RetriveFieldDataAndSendEventL() begin") );   
  1221 				TRACE( " begin" );   
  1228 				TVIMPSTVPbkStoreEvent storeEvent(iStoreEventType,
  1222 				TVIMPSTVPbkStoreEvent storeEvent(iStoreEventType,
  1229 									NULL,
  1223 									NULL,
  1230 									NULL,
  1224 									NULL,
  1231 									*retValue,
  1225 									*retValue,
  1232 									KNullDesC );
  1226 									KNullDesC );
  1234 				CleanupStack::PopAndDestroy(); // retValue;
  1228 				CleanupStack::PopAndDestroy(); // retValue;
  1235 				retValue = NULL;
  1229 				retValue = NULL;
  1236 				}
  1230 				}
  1237 			}
  1231 			}
  1238 		}
  1232 		}
  1239 	TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::RetriveFieldDataAndSendEventL() begin") );   
  1233 	 
  1240 	}
  1234 	}
  1241 
  1235 
  1242 // ---------------------------------------------------------
  1236 // ---------------------------------------------------------
  1243 // CVIMPSTStorageVPbkStoreHandler::RemoveAllVPbkContactsL
  1237 // CVIMPSTStorageVPbkStoreHandler::RemoveAllVPbkContactsL
  1244 // 
  1238 // 
  1245 // ---------------------------------------------------------		
  1239 // ---------------------------------------------------------		
  1246 TInt CVIMPSTStorageVPbkStoreHandler::RemoveAllVPbkContactsL()
  1240 TInt CVIMPSTStorageVPbkStoreHandler::RemoveAllVPbkContactsL()
  1247 	{
  1241 	{
  1248 	TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::RemoveAllVPbkContactsL() begin") );   
  1242 	TRACER_AUTO; 
  1249 	TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::RemoveAllVPbkContactsL() before if") ); 
  1243 	TRACE( " before if" ); 
  1250 	if(iAddIdInProgress)
  1244 	if(iAddIdInProgress)
  1251 	    {
  1245 	    {
  1252 	    TPtr iAddIdInProgressPtr = iAddIdInProgress->Des();
  1246 	    TPtr iAddIdInProgressPtr = iAddIdInProgress->Des();
  1253 	    TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::RemoveAllVPbkContactsL() iAddIdInProgressPtr  = %S"), &iAddIdInProgressPtr ); 
  1247 	    TRACE( "iAddIdInProgressPtr  = %S", &iAddIdInProgressPtr ); 
  1254 	    delete iAddIdInProgress;
  1248 	    delete iAddIdInProgress;
  1255 	    iAddIdInProgress = NULL;
  1249 	    iAddIdInProgress = NULL;
  1256 	    }
  1250 	    }
  1257 	// intialize it to efalse as, somewhere it would have missed.
  1251 	// intialize it to efalse as, somewhere it would have missed.
  1258 	iCommitOperationInProgress = EFalse;
  1252 	iCommitOperationInProgress = EFalse;
  1259 	TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::RemoveAllVPbkContactsL() After if") ); 
  1253 	TRACE( " After if"); 
  1260 	TInt count = 0;
  1254 	TInt count = 0;
  1261 	if( iContactView )
  1255 	if( iContactView )
  1262 		{
  1256 		{
  1263 		count = iContactView->ContactCountL();	
  1257 		count = iContactView->ContactCountL();	
  1264 		}
  1258 		}
  1265 	TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::RemoveAllVPbkContactsL() count = %d"),count) ;   
  1259 	TRACE( "count = %d",count) ;   
  1266 	TPtr iStoreNamePtr(iStoreName->Des() );
  1260 	TPtr iStoreNamePtr(iStoreName->Des() );
  1267 	TInt index = iStoreNamePtr.Find(_L(":") );
  1261 	TInt index = iStoreNamePtr.Find(_L(":") );
  1268 	if( index >= 0 && count )
  1262 	if( index >= 0 && count )
  1269 		{
  1263 		{
  1270 		TPtrC store = iStoreNamePtr.Right( iStoreNamePtr.Length() - index -3 );	
  1264 		TPtrC store = iStoreNamePtr.Right( iStoreNamePtr.Length() - index -3 );	
  1279 			contactIds->Reset();
  1273 			contactIds->Reset();
  1280 			TContactIter iterator(*contactDb);
  1274 			TContactIter iterator(*contactDb);
  1281 			TContactItemId contactId = iterator.FirstL();	
  1275 			TContactItemId contactId = iterator.FirstL();	
  1282 			while(contactId != KNullContactId)
  1276 			while(contactId != KNullContactId)
  1283 				{
  1277 				{
  1284 				TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::RemoveAllVPbkContactsL() in side while") );   
  1278 				TRACE( "in side while" );   
  1285 				// store into iContactIds for later deletion of contacts
  1279 				// store into iContactIds for later deletion of contacts
  1286 				contactIds->AddL(contactId );
  1280 				contactIds->AddL(contactId );
  1287 				// get the next contactids
  1281 				// get the next contactids
  1288 				contactId = iterator.NextL();	
  1282 				contactId = iterator.NextL();	
  1289 				}
  1283 				}
  1292 			contactIds->Reset();
  1286 			contactIds->Reset();
  1293 			CleanupStack::PopAndDestroy( contactDb );
  1287 			CleanupStack::PopAndDestroy( contactDb );
  1294 			}
  1288 			}
  1295 		CleanupStack::PopAndDestroy( contactIds );
  1289 		CleanupStack::PopAndDestroy( contactIds );
  1296 		}
  1290 		}
  1297 	TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::RemoveAllVPbkContactsL() end") );   
  1291 	
  1298 	return count;	
  1292 	return count;	
  1299 	}
  1293 	}
  1300 
  1294 
  1301 // ---------------------------------------------------------------------------
  1295 // ---------------------------------------------------------------------------
  1302 // CVIMPSTStorageVPbkStoreHandler::ResetAndDestroyRArray
  1296 // CVIMPSTStorageVPbkStoreHandler::ResetAndDestroyRArray
  1303 // ---------------------------------------------------------------------------
  1297 // ---------------------------------------------------------------------------
  1304 //
  1298 //
  1305 void CVIMPSTStorageVPbkStoreHandler::ResetAndDestroyRArray()
  1299 void CVIMPSTStorageVPbkStoreHandler::ResetAndDestroyRArray()
  1306     {
  1300     {
  1307     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::ResetAndDestroyRArrayL() begin") );
  1301 	TRACER_AUTO;
  1308     TInt count = iPendingAvatars.Count();
  1302     TInt count = iPendingAvatars.Count();
  1309     while( count )
  1303     while( count )
  1310         {
  1304         {
  1311         TVIMPSTAvatarData contactInf = iPendingAvatars[ 0 ];
  1305         TVIMPSTAvatarData contactInf = iPendingAvatars[ 0 ];
  1312         iPendingAvatars.Remove(0 );
  1306         iPendingAvatars.Remove(0 );
  1317          // not exist need to add 
  1311          // not exist need to add 
  1318         iPendingAvatars.Compress(); 
  1312         iPendingAvatars.Compress(); 
  1319         count = iPendingAvatars.Count();
  1313         count = iPendingAvatars.Count();
  1320         }
  1314         }
  1321     iPendingAvatars.Reset();
  1315     iPendingAvatars.Reset();
  1322     TRACE( T_LIT("CVIMPSTStorageVPbkStoreHandler::ResetAndDestroyRArrayL() end") );
  1316    
  1323     }
  1317     }
  1324 // End of file
  1318 // End of file