uiservicetab/vimpstdetailsviewplugin/src/cvimpstdetailscontacthandler.cpp
branchRCL_3
changeset 14 9fdee5e1da30
parent 10 78867dafe7eb
equal deleted inserted replaced
13:796276a1bdcc 14:9fdee5e1da30
    48 #include <imconnectionproviderconsts.h>
    48 #include <imconnectionproviderconsts.h>
    49 #include <MVPbkContactFieldTextData.h>
    49 #include <MVPbkContactFieldTextData.h>
    50 // system include
    50 // system include
    51 #include <e32property.h>
    51 #include <e32property.h>
    52 #include <s32mem.h>
    52 #include <s32mem.h>
    53 #include "vimpstdebugtrace.h"
    53 
       
    54 
       
    55 #include "uiservicetabtracer.h"
    54 #include "vimpstutils.h"
    56 #include "vimpstutils.h"
    55 
    57 
    56 // ======== LOCAL FUNCTIONS ========
    58 // ======== LOCAL FUNCTIONS ========
    57 
    59 
    58 // ======== MEMBER FUNCTIONS ========
    60 // ======== MEMBER FUNCTIONS ========
    66 																 const TDesC& aServiceStoreUri,
    68 																 const TDesC& aServiceStoreUri,
    67 																 const TDesC& aServiceName,
    69 																 const TDesC& aServiceName,
    68 																 TUint aserviceId
    70 																 TUint aserviceId
    69 																 )
    71 																 )
    70 	{
    72 	{
       
    73 	TRACER_AUTO;
    71 	CVIMPSTDetailsContactHandler* self =
    74 	CVIMPSTDetailsContactHandler* self =
    72 	    new(ELeave) CVIMPSTDetailsContactHandler( aObserver, aserviceId );
    75 	    new(ELeave) CVIMPSTDetailsContactHandler( aObserver, aserviceId );
    73 	CleanupStack::PushL(self);
    76 	CleanupStack::PushL(self);
    74 	self->ConstructL( aParameter, aServiceStoreUri, aServiceName );
    77 	self->ConstructL( aParameter, aServiceStoreUri, aServiceName );
    75 	CleanupStack::Pop(self);
    78 	CleanupStack::Pop(self);
    80 // CVIMPSTDetailsContactHandler::~CVIMPSTDetailsContactHandler
    83 // CVIMPSTDetailsContactHandler::~CVIMPSTDetailsContactHandler
    81 // ---------------------------------------------------------------------------
    84 // ---------------------------------------------------------------------------
    82 //
    85 //
    83 CVIMPSTDetailsContactHandler::~CVIMPSTDetailsContactHandler()
    86 CVIMPSTDetailsContactHandler::~CVIMPSTDetailsContactHandler()
    84 	{
    87 	{
    85 	TRACED( T_LIT("CVIMPSTDetailsContactHandler:: ~CVIMPSTDetailsContactHandler() start") );
    88 
       
    89 	TRACER_AUTO;
    86 	Cancel();
    90 	Cancel();
    87 	if (iWait.IsStarted())
    91 	if (iWait.IsStarted())
    88 	    {
    92 	    {
    89 	    iWait.AsyncStop();
    93 	    iWait.AsyncStop();
    90 	    }
    94 	    }
    92 	delete iRetrieveOperation;
    96 	delete iRetrieveOperation;
    93 	delete iXSPUserId;
    97 	delete iXSPUserId;
    94 	delete iStoreContact;
    98 	delete iStoreContact;
    95 	if (iStoreList)
    99 	if (iStoreList)
    96 		{
   100 		{
    97 		TRACED( T_LIT("CVIMPSTDetailsContactHandler:: ~CVIMPSTDetailsContactHandler() calling store close") );
   101 	
       
   102 	    TRACE("calling store close");
    98 		iStoreList->CloseAll(*this);
   103 		iStoreList->CloseAll(*this);
    99 		iStoreList = NULL;
   104 		iStoreList = NULL;
   100 		}
   105 		}
   101 	TRACED( T_LIT("CVIMPSTDetailsContactHandler:: ~CVIMPSTDetailsContactHandler() iStoreList deleted") );
   106 	TRACE("iStoreList deleted");
   102 	delete iServiceStoreUri;
   107 	delete iServiceStoreUri;
   103 	TRACED( T_LIT("CVIMPSTDetailsContactHandler:: ~CVIMPSTDetailsContactHandler() iServiceStoreUri deleted") );
   108 	TRACE("iServiceStoreUri deleted");
   104 	delete iContactManager;
   109 	delete iContactManager;
   105 	TRACED( T_LIT("CVIMPSTDetailsContactHandler:: ~CVIMPSTDetailsContactHandler() iContactManager deleted") );
   110 	TRACE("iContactManager deleted");
   106 	delete iServiceName;
   111 	delete iServiceName;
   107 	TRACED( T_LIT("CVIMPSTDetailsContactHandler:: ~CVIMPSTDetailsContactHandler() iServiceName deleted") );
   112 	TRACE("iServiceName deleted");
   108 	delete iIdConverter;
   113 	delete iIdConverter;
   109 	TRACED( T_LIT("CVIMPSTDetailsContactHandler:: ~CVIMPSTDetailsContactHandler() end") );
   114 
       
   115 	
   110 	}
   116 	}
   111 
   117 
   112 // ---------------------------------------------------------------------------
   118 // ---------------------------------------------------------------------------
   113 // CVIMPSTDetailsContactHandler::CVIMPSTDetailsContactHandler
   119 // CVIMPSTDetailsContactHandler::CVIMPSTDetailsContactHandler
   114 // ---------------------------------------------------------------------------
   120 // ---------------------------------------------------------------------------
   127 // CVIMPSTDetailsContactHandler::ConstructL
   133 // CVIMPSTDetailsContactHandler::ConstructL
   128 // ---------------------------------------------------------------------------
   134 // ---------------------------------------------------------------------------
   129 //
   135 //
   130 void CVIMPSTDetailsContactHandler::ConstructL( MCCAParameter& aParameter ,const TDesC& aServiceStoreUri,const TDesC& aServiceName )
   136 void CVIMPSTDetailsContactHandler::ConstructL( MCCAParameter& aParameter ,const TDesC& aServiceStoreUri,const TDesC& aServiceName )
   131 	{
   137 	{
   132 	TRACED( T_LIT("CVIMPSTDetailsContactHandler::ConstructL start") );
   138 
       
   139 	TRACER_AUTO;
   133 	CVPbkContactStoreUriArray* uriArray = CVPbkContactStoreUriArray::NewLC();
   140 	CVPbkContactStoreUriArray* uriArray = CVPbkContactStoreUriArray::NewLC();
   134 	TUid launchUid = TUid::Null() ;	
   141 	TUid launchUid = TUid::Null() ;	
   135 	iServiceStoreUri = aServiceStoreUri.AllocL();
   142 	iServiceStoreUri = aServiceStoreUri.AllocL();
   136 	iServiceName = aServiceName.AllocL();
   143 	iServiceName = aServiceName.AllocL();
   137 	 //find whether its a local store or xsp store
   144 	 //find whether its a local store or xsp store
   153 		// need to open service store
   160 		// need to open service store
   154 		 if ( iServiceStoreUri )
   161 		 if ( iServiceStoreUri )
   155             {
   162             {
   156             TPtr serviceStoreNamePtr = iServiceStoreUri->Des(); 
   163             TPtr serviceStoreNamePtr = iServiceStoreUri->Des(); 
   157             uriArray->AppendL( TVPbkContactStoreUriPtr( serviceStoreNamePtr ) );
   164             uriArray->AppendL( TVPbkContactStoreUriPtr( serviceStoreNamePtr ) );
   158             TRACED( T_LIT("ServiceStoreUriL() - storename3: %S"), &serviceStoreNamePtr );
   165 	    TRACE("ServiceStoreUriL() - storename3: %S", &serviceStoreNamePtr);
   159             }
   166             }
   160 		}
   167 		}
   161 
   168 
   162 	HBufC& contactData = aParameter.ContactDataL();
   169 	HBufC& contactData = aParameter.ContactDataL();
   163 
   170 
   169 	readStream.PushL();
   176 	readStream.PushL();
   170 
   177 
   171 	const TInt versionNumber = readStream.ReadUint8L();
   178 	const TInt versionNumber = readStream.ReadUint8L();
   172 
   179 
   173 	TInt uriCount = readStream.ReadUint16L();
   180 	TInt uriCount = readStream.ReadUint16L();
   174 	TRACED( T_LIT("ServiceStoreUriL() - uriCount = %d"),uriCount );
   181 	TRACE("ServiceStoreUriL() - uriCount = %d", uriCount);
   175 	// Read URIs
   182 	// Read URIs
   176 	for ( TInt i = 0; i < uriCount; ++i )
   183 	for ( TInt i = 0; i < uriCount; ++i )
   177 	    {
   184 	    {
   178 	    const TInt uriLength = readStream.ReadUint16L();
   185 	    const TInt uriLength = readStream.ReadUint16L();
   179 	    HBufC* uriBuffer = HBufC::NewLC(uriLength);
   186 	    HBufC* uriBuffer = HBufC::NewLC(uriLength);
   180 	    TPtr uriPtr = uriBuffer->Des();
   187 	    TPtr uriPtr = uriBuffer->Des();
   181 	    readStream.ReadL( uriPtr, uriLength );
   188 	    readStream.ReadL( uriPtr, uriLength );
   182 	    if( uriPtr.Length() > 0 )
   189 	    if( uriPtr.Length() > 0 )
   183 	        {
   190 	        {
   184 	        uriArray->AppendL( TVPbkContactStoreUriPtr( uriPtr ) );
   191 	        uriArray->AppendL( TVPbkContactStoreUriPtr( uriPtr ) );
   185 	        TRACED( T_LIT("ServiceStoreUriL() - storename4: %S"), &uriPtr );
   192 	        TRACE("ServiceStoreUriL() - storename4: %S", &uriPtr);
   186 	        }
   193 	        }
   187 	    CleanupStack::PopAndDestroy( uriBuffer );
   194 	    CleanupStack::PopAndDestroy( uriBuffer );
   188 	    }
   195 	    }
   189 	CleanupStack::PopAndDestroy(); // readStream
   196 	CleanupStack::PopAndDestroy(); // readStream
   190 	CleanupStack::PopAndDestroy(); // buf
   197 	CleanupStack::PopAndDestroy(); // buf
   204         {
   211         {
   205         const TDesC& contactdb = VPbkContactStoreUris::DefaultCntDbUri();
   212         const TDesC& contactdb = VPbkContactStoreUris::DefaultCntDbUri();
   206         MVPbkContactStore* contactStore =  iStoreList->Find(TVPbkContactStoreUriPtr(contactdb));
   213         MVPbkContactStore* contactStore =  iStoreList->Find(TVPbkContactStoreUriPtr(contactdb));
   207         iIdConverter = CVPbkContactIdConverter::NewL(*contactStore);
   214         iIdConverter = CVPbkContactIdConverter::NewL(*contactStore);
   208         }
   215         }
   209     TRACED( T_LIT("CVIMPSTDetailsContactHandler::ConstructL end") );
   216   
   210 	}
   217 	}
   211 
   218 
   212 
   219 
   213 // ---------------------------------------------------------------------------
   220 // ---------------------------------------------------------------------------
   214 // CVIMPSTDetailsContactHandler::GetDisplayNameLC
   221 // CVIMPSTDetailsContactHandler::GetDisplayNameLC
   215 // ---------------------------------------------------------------------------
   222 // ---------------------------------------------------------------------------
   216 //
   223 //
   217 HBufC* CVIMPSTDetailsContactHandler::GetDisplayNameLC()
   224 HBufC* CVIMPSTDetailsContactHandler::GetDisplayNameLC()
   218     {
   225     {
       
   226 	TRACER_AUTO;
   219     HBufC* firstName = KNullDesC().AllocL();
   227     HBufC* firstName = KNullDesC().AllocL();
   220     HBufC* lastName = KNullDesC().AllocL();
   228     HBufC* lastName = KNullDesC().AllocL();
   221     HBufC* retValue = NULL;   
   229     HBufC* retValue = NULL;   
   222     if( iStoreContact )
   230     if( iStoreContact )
   223         {		
   231         {		
   283 // ---------------------------------------------------------------------------
   291 // ---------------------------------------------------------------------------
   284 //
   292 //
   285 void CVIMPSTDetailsContactHandler::SetLinks(
   293 void CVIMPSTDetailsContactHandler::SetLinks(
   286     		MVPbkContactLinkArray* aLinks, TBool aReadXspId )
   294     		MVPbkContactLinkArray* aLinks, TBool aReadXspId )
   287 	{
   295 	{
   288     TRACED( T_LIT("CVIMPSTDetailsContactHandler::SetLinks start") );
   296    
       
   297 	TRACER_AUTO;
   289     delete iLinks;
   298     delete iLinks;
   290 	iLinks = NULL; 
   299 	iLinks = NULL; 
   291 	iLinks = aLinks;
   300 	iLinks = aLinks;
   292 	TRACED( T_LIT("CVIMPSTDetailsContactHandler::SetLinks iLinks deleted ") );
   301 	TRACE("iLinks deleted");
   293 	iCurrentLink = NULL;
   302 	iCurrentLink = NULL;
   294 	
   303 	
   295 	iReadXspId = aReadXspId;	
   304 	iReadXspId = aReadXspId;	
   296 	if( iRetrieveOperation )
   305 	if( iRetrieveOperation )
   297     	{
   306     	{
   298         delete iRetrieveOperation;
   307         delete iRetrieveOperation;
   299         iRetrieveOperation = NULL;
   308         iRetrieveOperation = NULL;
   300         TRACED( T_LIT("CVIMPSTDetailsContactHandler::SetLinks iRetrieveOperation deleted ") );
   309         TRACE("iRetrieveOperation deleted");
   301     	}
   310     	}
   302 	TRACED( T_LIT("CVIMPSTDetailsContactHandler::SetLinks calling issue request") );
   311 	TRACE("calling issue request");
   303 	IssueRequest();
   312 	IssueRequest();
   304 	TRACED( T_LIT("CVIMPSTDetailsContactHandler::SetLinks end") );
   313 
   305 	}
   314 	}
   306 
   315 
   307 // ---------------------------------------------------------------------------
   316 // ---------------------------------------------------------------------------
   308 // CVIMPSTDetailsContactHandler::Links
   317 // CVIMPSTDetailsContactHandler::Links
   309 // ---------------------------------------------------------------------------
   318 // ---------------------------------------------------------------------------
   347 // CVIMPSTDetailsContactHandler::CancelOngoingRequest
   356 // CVIMPSTDetailsContactHandler::CancelOngoingRequest
   348 // --------------------------------------------------------------------------
   357 // --------------------------------------------------------------------------
   349 //
   358 //
   350 void CVIMPSTDetailsContactHandler::CancelOngoingRequest()
   359 void CVIMPSTDetailsContactHandler::CancelOngoingRequest()
   351 	{
   360 	{
   352 	TRACED( T_LIT("CVIMPSTDetailsContactHandler:: CancelOngoingRequest() start ") );
   361 	TRACER_AUTO;
   353 	delete iRetrieveOperation;
   362 	delete iRetrieveOperation;
   354 	iRetrieveOperation = NULL;
   363 	iRetrieveOperation = NULL;
   355 	TRACED( T_LIT("CVIMPSTDetailsContactHandler:: CancelOngoingRequest() iRetrieveOperation deleted ") );
   364 	TRACE("iRetrieveOperation deleted");
   356 	delete iXSPUserId;
   365 	delete iXSPUserId;
   357 	iXSPUserId = NULL;
   366 	iXSPUserId = NULL;
   358 	TRACED( T_LIT("CVIMPSTDetailsContactHandler:: CancelOngoingRequest() iXSPUserId deleted ") );
   367 	TRACE("iXSPUserId deleted");
   359 	delete iStoreContact;
   368 	delete iStoreContact;
   360 	iStoreContact = NULL;
   369 	iStoreContact = NULL;
   361 	TRACED( T_LIT("CVIMPSTDetailsContactHandler:: CancelOngoingRequest() iStoreContact deleted ") );
   370 	TRACE("iStoreContact deleted");
   362 	delete iLinks;
   371 	delete iLinks;
   363 	iLinks = NULL;
   372 	iLinks = NULL;
   364 	TRACED( T_LIT("CVIMPSTDetailsContactHandler:: CancelOngoingRequest() end ") );
   373 
   365 	}
   374 	}
   366 // ---------------------------------------------------------------------------
   375 // ---------------------------------------------------------------------------
   367 // CVIMPSTDetailsContactHandler::RunL
   376 // CVIMPSTDetailsContactHandler::RunL
   368 // ---------------------------------------------------------------------------
   377 // ---------------------------------------------------------------------------
   369 //
   378 //
   370 void CVIMPSTDetailsContactHandler::RunL()
   379 void CVIMPSTDetailsContactHandler::RunL()
   371     {
   380     {
   372     TRACED( T_LIT("CVIMPSTDetailsContactHandler:: RunL() start ") );
   381    
       
   382 	TRACER_AUTO;
   373     TInt index = 0;
   383     TInt index = 0;
   374     if (iLinks && iCurrentLink )
   384     if (iLinks && iCurrentLink )
   375         {
   385         {
   376         TRACED( T_LIT("CVIMPSTDetailsContactHandler:: RunL() next link ") );
   386 		TRACE("next link");
   377         index = iLinks->Find(*iCurrentLink) + 1;
   387         index = iLinks->Find(*iCurrentLink) + 1;
   378         }
   388         }
   379     if ( iLinks && index < iLinks->Count() )
   389     if ( iLinks && index < iLinks->Count() )
   380         {
   390         {
   381         TRACED( T_LIT("CVIMPSTDetailsContactHandler:: RunL() calling retrive ") );
   391 		  TRACE("calling retrive"); 
   382         // will get called until the index become equal to count
   392         // will get called until the index become equal to count
   383         iCurrentLink = &iLinks->At(index);            
   393         iCurrentLink = &iLinks->At(index);            
   384         TRAPD( err, iRetrieveOperation = iContactManager->RetrieveContactL(*iCurrentLink, *this) );       
   394         TRAPD( err, iRetrieveOperation = iContactManager->RetrieveContactL(*iCurrentLink, *this) );       
   385         TRACED( T_LIT("CVIMPSTDetailsContactHandler:: RunL() retrive called  err = %d"),err );
   395         TRACE("retrive called  err = %d", err);
   386         }
   396         }
   387     else
   397     else
   388         {
   398         {
   389         TRACED( T_LIT("CVIMPSTDetailsContactHandler:: RunL() job finished ") );
   399 		TRACE("job finished");
   390         iCurrentLink = NULL;
   400         iCurrentLink = NULL;
   391         }
   401         }
   392     TRACED( T_LIT("CVIMPSTDetailsContactHandler:: RunL() end ") );
   402   
   393     }
   403     }
   394 
   404 
   395 // ---------------------------------------------------------------------------
   405 // ---------------------------------------------------------------------------
   396 // CVIMPSTDetailsContactHandler::RunError
   406 // CVIMPSTDetailsContactHandler::RunError
   397 // ---------------------------------------------------------------------------
   407 // ---------------------------------------------------------------------------
   416 //
   426 //
   417 void CVIMPSTDetailsContactHandler::VPbkSingleContactOperationComplete(
   427 void CVIMPSTDetailsContactHandler::VPbkSingleContactOperationComplete(
   418     MVPbkContactOperationBase& /*aOperation*/,
   428     MVPbkContactOperationBase& /*aOperation*/,
   419     MVPbkStoreContact* aContact)
   429     MVPbkStoreContact* aContact)
   420     {
   430     {
   421     TRACED( T_LIT("CVIMPSTDetailsContactHandler:: VPbkSingleContactOperationComplete start ") );
   431 	TRACER_AUTO; 
   422     TBool isIssueReguest = ETrue;
   432     TBool isIssueReguest = ETrue;
   423     
   433     
   424     delete iRetrieveOperation;
   434     delete iRetrieveOperation;
   425     iRetrieveOperation = NULL;
   435     iRetrieveOperation = NULL;
   426 
   436 
   444                 if( fieldData.DataType() == EVPbkFieldStorageTypeUri  )
   454                 if( fieldData.DataType() == EVPbkFieldStorageTypeUri  )
   445                     {
   455                     {
   446                     TPtrC scheme = MVPbkContactFieldUriData::Cast(fieldData).Scheme();
   456                     TPtrC scheme = MVPbkContactFieldUriData::Cast(fieldData).Scheme();
   447                     if(iServiceName->Compare(scheme) == 0)
   457                     if(iServiceName->Compare(scheme) == 0)
   448                         {
   458                         {
   449                         TRACED( T_LIT("CVIMPSTDetailsContactHandler:: EVPbkFieldStorageTypeUri called ") );
   459 						TRACE("EVPbkFieldStorageTypeUri called");
   450                         const MVPbkContactFieldUriData& uri = MVPbkContactFieldUriData::Cast(fieldData);
   460                         const MVPbkContactFieldUriData& uri = MVPbkContactFieldUriData::Cast(fieldData);
   451                         HBufC* user = NULL;
   461                         HBufC* user = NULL;
   452                         delete iXSPUserId;
   462                         delete iXSPUserId;
   453                         iXSPUserId = NULL;
   463                         iXSPUserId = NULL;
   454                         // call back api is not leaving function
   464                         // call back api is not leaving function
   463                                 TInt length = userPtr.Length();
   473                                 TInt length = userPtr.Length();
   464                                 iXSPUserId = userPtr.Right( length - index - 1 ).AllocL() ;
   474                                 iXSPUserId = userPtr.Right( length - index - 1 ).AllocL() ;
   465                                 }
   475                                 }
   466                             CleanupStack::PopAndDestroy();// user
   476                             CleanupStack::PopAndDestroy();// user
   467                             }
   477                             }
   468                         TRACED( T_LIT("CVIMPSTDetailsContactHandler:: EVPbkFieldStorageTypeUri end  ") );
   478                         TRACE("EVPbkFieldStorageTypeUri end");
   469                         );
   479                         );
   470                         break;
   480                         break;
   471                         }
   481                         }
   472                     }
   482                     }
   473                 }
   483                 }
   474             }
   484             }
   475         if( iXSPUserId && iContactManager  )
   485         if( iXSPUserId && iContactManager  )
   476             {
   486             {
   477             TRACED( T_LIT("CVIMPSTDetailsContactHandler:: search is called ") );
   487        
       
   488               TRACE("search is called");
   478             // call back api is not leaving function
   489             // call back api is not leaving function
   479             TRAP_IGNORE( iRetrieveOperation = iContactManager->FindL(*iXSPUserId, iContactManager->FieldTypes(),*this) );	
   490             TRAP_IGNORE( iRetrieveOperation = iContactManager->FindL(*iXSPUserId, iContactManager->FieldTypes(),*this) );	
   480             isIssueReguest = EFalse;
   491             isIssueReguest = EFalse;
   481             }
   492             }
   482         else
   493         else
   485             TRAP_IGNORE( iObserver.HandleContactUnavailableL() );             
   496             TRAP_IGNORE( iObserver.HandleContactUnavailableL() );             
   486             }		
   497             }		
   487         }	
   498         }	
   488     else if( iStoreContact  )
   499     else if( iStoreContact  )
   489         {
   500         {
   490         TRACED( T_LIT("CVIMPSTDetailsContactHandler:: VPbkSingleContactOperationComplete iStoreContact Valid ") );
   501      
       
   502          TRACE("iStoreContact Valid");
   491         TBool validLink = ETrue;
   503         TBool validLink = ETrue;
   492         if( iStoreType == EStoreLocal && iCurrentLink )
   504         if( iStoreType == EStoreLocal && iCurrentLink )
   493             {
   505             {
   494             //Local Store
   506             //Local Store
   495             // to check whether this contact has been added to the ServiceTab. with the help of db file          
   507             // to check whether this contact has been added to the ServiceTab. with the help of db file          
   496             validLink = CheckWhetherValidLocalLinkL( *iCurrentLink);            
   508             validLink = CheckWhetherValidLocalLinkL( *iCurrentLink);            
   497             }
   509             }
   498         if( validLink )
   510         if( validLink )
   499             {
   511             {
   500             TRACED( T_LIT("CVIMPSTDetailsContactHandler::HandleContactReadyL ") );
   512       
       
   513 			TRACE("HandleContactReadyL ");
   501             TRAP_IGNORE( iObserver.HandleContactReadyL( *iStoreContact ) ); 
   514             TRAP_IGNORE( iObserver.HandleContactReadyL( *iStoreContact ) ); 
   502             }
   515             }
   503         else
   516         else
   504             {
   517             {
   505             TRACED( T_LIT("CVIMPSTDetailsContactHandler:: VPbkSingleContactOperationComplete No data") );
   518         
       
   519 			TRACE("No data ");
   506             TRAP_IGNORE( iObserver.HandleContactUnavailableL() ); 
   520             TRAP_IGNORE( iObserver.HandleContactUnavailableL() ); 
   507             }
   521             }
   508         }
   522         }
   509     if( isIssueReguest )
   523     if( isIssueReguest )
   510         {
   524         {
   511         IssueRequest();
   525         IssueRequest();
   512         }
   526         }
   513     TRACED( T_LIT("CVIMPSTDetailsContactHandler:: VPbkSingleContactOperationComplete end ") );
   527   
   514     }
   528     }
   515 
   529 
   516 // ---------------------------------------------------------------------------
   530 // ---------------------------------------------------------------------------
   517 // CVIMPSTDetailsContactHandler::VPbkSingleContactOperationFailed
   531 // CVIMPSTDetailsContactHandler::VPbkSingleContactOperationFailed
   518 // ---------------------------------------------------------------------------
   532 // ---------------------------------------------------------------------------
   519 //
   533 //
   520 void CVIMPSTDetailsContactHandler::VPbkSingleContactOperationFailed(
   534 void CVIMPSTDetailsContactHandler::VPbkSingleContactOperationFailed(
   521     MVPbkContactOperationBase& /*aOperation*/,
   535     MVPbkContactOperationBase& /*aOperation*/,
   522     TInt /*aError*/)
   536     TInt /*aError*/)
   523 	{
   537 	{
   524 	TRACED( T_LIT("CVIMPSTDetailsContactHandler:: VPbkSingleContactOperationFailed satrt ") );
   538 
       
   539 	TRACER_AUTO;
   525 	delete iRetrieveOperation;
   540 	delete iRetrieveOperation;
   526 	iRetrieveOperation = NULL;
   541 	iRetrieveOperation = NULL;
   527 	
   542 	
   528 	TInt index = 0;
   543 	TInt index = 0;
   529 	if (iLinks && iCurrentLink)
   544 	if (iLinks && iCurrentLink)
   530 		{
   545 		{
   531 		index = iLinks->Find(*iCurrentLink) + 1;
   546 		index = iLinks->Find(*iCurrentLink) + 1;
   532 		
   547 		
   533 		if ( index >= iLinks->Count() )
   548 		if ( index >= iLinks->Count() )
   534 			{
   549 			{
   535 			TRACED( T_LIT("CVIMPSTDetailsContactHandler:: VPbkSingleContactOperationFailed calling HandleContactUnavailableL start") );
   550 	
       
   551 	    TRACE("calling HandleContactUnavailableL start ");
   536 			TRAP_IGNORE( iObserver.HandleContactUnavailableL() );
   552 			TRAP_IGNORE( iObserver.HandleContactUnavailableL() );
   537 			TRACED( T_LIT("CVIMPSTDetailsContactHandler:: VPbkSingleContactOperationFailed calling HandleContactUnavailableL end ") );
   553 	
       
   554 		TRACE("calling HandleContactUnavailableL end");
   538 			return;
   555 			return;
   539 			}
   556 			}
   540 	  }
   557 	  }
   541 	IssueRequest();
   558 	IssueRequest();
   542 	TRACED( T_LIT("CVIMPSTDetailsContactHandler:: VPbkSingleContactOperationFailed end ") );
   559 
   543 	}
   560 	}
   544 
   561 
   545 // ---------------------------------------------------------------------------
   562 // ---------------------------------------------------------------------------
   546 // CVIMPSTDetailsContactHandler::FindCompleteL
   563 // CVIMPSTDetailsContactHandler::FindCompleteL
   547 // ---------------------------------------------------------------------------
   564 // ---------------------------------------------------------------------------
   548 //
   565 //
   549 void CVIMPSTDetailsContactHandler::FindCompleteL( MVPbkContactLinkArray* aResults )
   566 void CVIMPSTDetailsContactHandler::FindCompleteL( MVPbkContactLinkArray* aResults )
   550 	{
   567 	{
   551 	TRACED( T_LIT("CVIMPSTDetailsContactHandler:: FindCompleteL satrt ") );
   568 
       
   569 	TRACER_AUTO;
   552 	CVPbkContactLinkArray* linkArray = NULL;	
   570 	CVPbkContactLinkArray* linkArray = NULL;	
   553 	delete iRetrieveOperation;
   571 	delete iRetrieveOperation;
   554 	iRetrieveOperation = NULL;	
   572 	iRetrieveOperation = NULL;	
   555 	if( aResults && iServiceStoreUri )
   573 	if( aResults && iServiceStoreUri )
   556 		{
   574 		{
   560 			const MVPbkContactLink& link = aResults->At( a ) ;
   578 			const MVPbkContactLink& link = aResults->At( a ) ;
   561 			MVPbkContactStore& store = link.ContactStore();	
   579 			MVPbkContactStore& store = link.ContactStore();	
   562 			const MVPbkContactStoreProperties& storeProperty = store.StoreProperties();
   580 			const MVPbkContactStoreProperties& storeProperty = store.StoreProperties();
   563 			if( storeProperty.Uri().UriDes().Compare( *iServiceStoreUri  ) == 0 )
   581 			if( storeProperty.Uri().UriDes().Compare( *iServiceStoreUri  ) == 0 )
   564 				{
   582 				{
   565 				TRACED( T_LIT("CVIMPSTDetailsContactHandler:: FindCompleteL one result found ") );
   583 			
       
   584 				TRACE("one result found ");
   566 			    linkArray = CVPbkContactLinkArray::NewLC();
   585 			    linkArray = CVPbkContactLinkArray::NewLC();
   567 			    MVPbkContactLink* clone = link.CloneLC();
   586 			    MVPbkContactLink* clone = link.CloneLC();
   568 			    // take ownership clone
   587 			    // take ownership clone
   569 			    linkArray->AppendL(clone);
   588 			    linkArray->AppendL(clone);
   570 			    CleanupStack::Pop(2); // clone, linkArray
   589 			    CleanupStack::Pop(2); // clone, linkArray			
   571 			    TRACED( T_LIT("CVIMPSTDetailsContactHandler:: FindCompleteL come out of loop ") );
   590 			    TRACE("come out of loop ");
   572 			    break;
   591 			    break;
   573 				}
   592 				}
   574 			}		
   593 			}		
   575 		}	
   594 		}	
   576 	delete aResults;
   595 	delete aResults;
   577 	aResults = NULL;
   596 	aResults = NULL;
   578 	TRACED( T_LIT("CVIMPSTDetailsContactHandler:: FindCompleteL aResults deleted ") );
   597 	TRACE("aResults deleted ");
   579 	if( linkArray )
   598 	if( linkArray )
   580 		{
   599 		{
   581 		// take ownership linkArray
   600 		// take ownership linkArray
   582 		SetLinks( linkArray, EFalse );	
   601 		SetLinks( linkArray, EFalse );	
   583 		}
   602 		}
   584 	else
   603 	else
   585 		{
   604 		{
   586 		iObserver.HandleContactUnavailableL();
   605 		iObserver.HandleContactUnavailableL();
   587 		}
   606 		}
   588 	TRACED( T_LIT("CVIMPSTDetailsContactHandler:: FindCompleteL end ") );
   607 
   589 	}
   608 	}
   590 // ---------------------------------------------------------------------------
   609 // ---------------------------------------------------------------------------
   591 // CVIMPSTDetailsContactHandler::
   610 // CVIMPSTDetailsContactHandler::
   592 // ---------------------------------------------------------------------------
   611 // ---------------------------------------------------------------------------
   593 //
   612 //
   594 void CVIMPSTDetailsContactHandler::FindFailed( TInt /*aError*/ )
   613 void CVIMPSTDetailsContactHandler::FindFailed( TInt /*aError*/ )
   595 	{
   614 	{
       
   615 	TRACER_AUTO;
   596 	TRAP_IGNORE( iObserver.HandleContactUnavailableL() ); // takes ownership of contacts.	
   616 	TRAP_IGNORE( iObserver.HandleContactUnavailableL() ); // takes ownership of contacts.	
   597 	}
   617 	}
   598 
   618 
   599 // ---------------------------------------------------------------------------
   619 // ---------------------------------------------------------------------------
   600 // CVIMPSTDetailsContactHandler::
   620 // CVIMPSTDetailsContactHandler::
   614 // CVIMPSTDetailsContactHandler::OpenComplete
   634 // CVIMPSTDetailsContactHandler::OpenComplete
   615 // --------------------------------------------------------------------------
   635 // --------------------------------------------------------------------------
   616 //
   636 //
   617 void CVIMPSTDetailsContactHandler::OpenComplete()
   637 void CVIMPSTDetailsContactHandler::OpenComplete()
   618     {
   638     {
   619     TRACED( T_LIT("CVIMPSTDetailsContactHandler::OpenComplete start") );
   639   
       
   640 	TRACER_AUTO;
   620     if (iWait.IsStarted())
   641     if (iWait.IsStarted())
   621         {
   642         {
   622         iWait.AsyncStop();
   643         iWait.AsyncStop();
   623         }
   644         }
   624     TRACED( T_LIT("CVIMPSTDetailsContactHandler::OpenComplete end") );
   645   
   625     }
   646     }
   626 
   647 
   627 // --------------------------------------------------------------------------
   648 // --------------------------------------------------------------------------
   628 // CVIMPSTDetailsContactHandler::StoreReady
   649 // CVIMPSTDetailsContactHandler::StoreReady
   629 // --------------------------------------------------------------------------
   650 // --------------------------------------------------------------------------
   630 //
   651 //
   631 void CVIMPSTDetailsContactHandler::StoreReady(MVPbkContactStore& /*aContactStore*/ )
   652 void CVIMPSTDetailsContactHandler::StoreReady(MVPbkContactStore& /*aContactStore*/ )
   632 	{
   653 	{
   633 	TRACED( T_LIT("CVIMPSTDetailsContactHandler::StoreReady") );
   654 
       
   655 	TRACER_AUTO;
   634 	}
   656 	}
   635 
   657 
   636 // --------------------------------------------------------------------------
   658 // --------------------------------------------------------------------------
   637 // CVIMPSTDetailsContactHandler::StoreUnavailable
   659 // CVIMPSTDetailsContactHandler::StoreUnavailable
   638 // --------------------------------------------------------------------------
   660 // --------------------------------------------------------------------------
   639 //
   661 //
   640 void CVIMPSTDetailsContactHandler::StoreUnavailable(
   662 void CVIMPSTDetailsContactHandler::StoreUnavailable(
   641 	MVPbkContactStore& /*aContactStore*/,
   663 	MVPbkContactStore& /*aContactStore*/,
   642 	TInt /*aReason*/)
   664 	TInt /*aReason*/)
   643 	{
   665 	{
   644 	TRACED( T_LIT("CVIMPSTDetailsContactHandler::StoreUnavailable start") );
   666 
       
   667 	TRACER_AUTO;
   645 	if (iWait.IsStarted())
   668 	if (iWait.IsStarted())
   646 		{
   669 		{
   647 		iWait.AsyncStop();
   670 		iWait.AsyncStop();
   648 		}
   671 		}
   649 	TRACED( T_LIT("CVIMPSTDetailsContactHandler::StoreUnavailable end") );
   672 
   650 	}
   673 	}
   651 
   674 
   652 // -------------------------------------------------------------------------
   675 // -------------------------------------------------------------------------
   653 // CVIMPSTDetailsContactHandler::HandleStoreEventL
   676 // CVIMPSTDetailsContactHandler::HandleStoreEventL
   654 // --------------------------------------------------------------------------
   677 // --------------------------------------------------------------------------
   665 // -----------------------------------------------------------
   688 // -----------------------------------------------------------
   666 //
   689 //
   667 
   690 
   668 TBool CVIMPSTDetailsContactHandler::CheckWhetherValidLocalLinkL(
   691 TBool CVIMPSTDetailsContactHandler::CheckWhetherValidLocalLinkL(
   669         const MVPbkContactLink& aCurrentLink )
   692         const MVPbkContactLink& aCurrentLink )
   670     {   
   693     { 
       
   694 	TRACER_AUTO;
   671     TBool validLocalLink = EFalse;
   695     TBool validLocalLink = EFalse;
   672     User::LeaveIfError( iFs.Connect() );
   696     User::LeaveIfError( iFs.Connect() );
   673     // Open existing or create new database.
   697     // Open existing or create new database.
   674     if ( DbExists() )
   698     if ( DbExists() )
   675         {
   699         {
   690 // CVIMPSTDetailsContactHandler::DbExists
   714 // CVIMPSTDetailsContactHandler::DbExists
   691 // -----------------------------------------------------------
   715 // -----------------------------------------------------------
   692 //
   716 //
   693 TBool CVIMPSTDetailsContactHandler::DbExists()
   717 TBool CVIMPSTDetailsContactHandler::DbExists()
   694     {
   718     {
       
   719 	TRACER_AUTO;
   695     TBuf<512> dbName;    
   720     TBuf<512> dbName;    
   696     RFile temp;
   721     RFile temp;
   697     TBuf< KMaxPath > storagePath;
   722     TBuf< KMaxPath > storagePath;
   698     
   723     
   699     dbName.Append( iServiceName->Des() );
   724     dbName.Append( iServiceName->Des() );
   725 // -----------------------------------------------------------
   750 // -----------------------------------------------------------
   726 // CVIMPSTDetailsContactHandler::OpenDbL
   751 // CVIMPSTDetailsContactHandler::OpenDbL
   727 // -----------------------------------------------------------
   752 // -----------------------------------------------------------
   728 //
   753 //
   729 void CVIMPSTDetailsContactHandler::OpenDbL()
   754 void CVIMPSTDetailsContactHandler::OpenDbL()
   730     {    
   755     {  
       
   756 	TRACER_AUTO;
   731     TBuf< KMaxPath > storagePath;
   757     TBuf< KMaxPath > storagePath;
   732     TBuf<512> dbName;    
   758     TBuf<512> dbName;    
   733     dbName.Append( iServiceName->Des() );
   759     dbName.Append( iServiceName->Des() );
   734     dbName.Append( KStorageExtn );
   760     dbName.Append( KStorageExtn );
   735     
   761     
   758 // ----------------------------------------------------------
   784 // ----------------------------------------------------------
   759 // CVIMPSTDetailsContactHandler::SeekRowL
   785 // CVIMPSTDetailsContactHandler::SeekRowL
   760 // ----------------------------------------------------------
   786 // ----------------------------------------------------------
   761 //
   787 //
   762 TBool CVIMPSTDetailsContactHandler::SeekRowL( TDbColNo aColNo, TInt32& aIdentifier )
   788 TBool CVIMPSTDetailsContactHandler::SeekRowL( TDbColNo aColNo, TInt32& aIdentifier )
   763     {    
   789     {  
       
   790 	TRACER_AUTO;
   764     TBool ret = EFalse;
   791     TBool ret = EFalse;
   765     iTable.BeginningL();
   792     iTable.BeginningL();
   766     while ( iTable.NextL() )
   793     while ( iTable.NextL() )
   767         {
   794         {
   768         iTable.GetL();
   795         iTable.GetL();
   778 // ----------------------------------------------------------
   805 // ----------------------------------------------------------
   779 // CVIMPSTDetailsContactHandler::OpenTableL
   806 // CVIMPSTDetailsContactHandler::OpenTableL
   780 // ----------------------------------------------------------
   807 // ----------------------------------------------------------
   781 //
   808 //
   782 void CVIMPSTDetailsContactHandler::OpenTableL()
   809 void CVIMPSTDetailsContactHandler::OpenTableL()
   783     {    
   810     {  
       
   811 	TRACER_AUTO;
   784     TInt err( iTable.Open( iDb, KContactTable ) );
   812     TInt err( iTable.Open( iDb, KContactTable ) );
   785     if ( err != KErrNone )
   813     if ( err != KErrNone )
   786         {
   814         {
   787         iTable.Close();        
   815         iTable.Close();        
   788         User::Leave( err );
   816         User::Leave( err );