locationsystemui/locationsysui/locutils/src/locrequestorutilsresolverimpl2.cpp
changeset 18 3825cf2dc8c2
parent 0 667063e416a2
equal deleted inserted replaced
1:788b770ce3ae 18:3825cf2dc8c2
    19 // INCLUDE FILES
    19 // INCLUDE FILES
    20 
    20 
    21 #include <e32base.h>
    21 #include <e32base.h>
    22 #include <barsread.h>
    22 #include <barsread.h>
    23 
    23 
       
    24 
    24 #include <lbs/epos_cposrequestor.h>
    25 #include <lbs/epos_cposrequestor.h>
    25 #include <lbs/epos_cposservicerequestor.h>
    26 #include <lbs/epos_cposservicerequestor.h>
    26 #include <lbs/epos_cposcontactrequestor.h>
    27 #include <lbs/epos_cposcontactrequestor.h>
    27 
    28 
    28 // Virtual Phonebook Engine API
       
    29 #include <CVPbkContactManager.h>
       
    30 #include <VPbkContactStoreUris.h>
       
    31 #include <CVPbkContactStoreUriArray.h>
       
    32 #include <TVPbkContactStoreUriPtr.h>
       
    33 #include <MVPbkContactLinkArray.h>
       
    34 #include <MVPbkContactOperationBase.h>
       
    35 #include <MVPbkContactLink.h>
       
    36 #include <MVPbkStoreContact.h>
       
    37 #include <TVPbkFieldVersitProperty.h>
       
    38 #include <VPbkFieldType.hrh>
       
    39 #include <MVPbkContactStoreList.h>
       
    40 #include <MVPbkContactStore.h>
       
    41 #include <TVPbkFieldTypeMapping.h>
       
    42 #include <CVPbkFieldTypeSelector.h>
       
    43 
       
    44 // Virtual Phonebook Presentation API
       
    45 #include <CPbk2StoreConfiguration.h>
       
    46 #include <Pbk2ContactNameFormatterFactory.h>
       
    47 #include <CPbk2SortOrderManager.h>
       
    48 #include <MPbk2ContactNameFormatter.h>
       
    49 #include <CVPbkFieldTypeRefsList.h>
       
    50 #include <MVPbkContactFieldData.h>
       
    51 
       
    52 #include <cntdef.h>
       
    53 
    29 
    54 #include "locrequestorutilsresolverimpl2.h"
    30 #include "locrequestorutilsresolverimpl2.h"
    55 #include "locutilsdebug.h"
    31 #include "locutilsdebug.h"
    56 #include "locfileutils.h"
    32 #include "locfileutils.h"
    57 #include <locutils.rsg>
       
    58 
    33 
    59 // This is a non localisable resource file hence we can directly refer to the
       
    60 // file as .rsc and we don't need to use the BaflUtils to load this resource
       
    61 // file.
       
    62 _LIT(KLocUtilsRscFile, "\\resource\\locutils.rsc");
       
    63 // ============= CLocRequestorUtilsResolver MEMBER FUNCTIONS =================
    34 // ============= CLocRequestorUtilsResolver MEMBER FUNCTIONS =================
    64 
    35 
    65 // ---------------------------------------------------------------------------
    36 // ---------------------------------------------------------------------------
    66 // CLocRequestorUtilsResolver::NewL
    37 // CLocRequestorUtilsResolver::NewL
    67 // 2 Phase Constructor
    38 // 2 Phase Constructor
    81 // destructor
    52 // destructor
    82 // ---------------------------------------------------------------------------
    53 // ---------------------------------------------------------------------------
    83 //
    54 //
    84 CLocRequestorUtilsResolver::~CLocRequestorUtilsResolver()
    55 CLocRequestorUtilsResolver::~CLocRequestorUtilsResolver()
    85 	{
    56 	{
    86     delete iCntsOperation;
       
    87     delete iCntLinkArray;
       
    88     delete iContact;
       
    89     delete iPbkContactEngine;
       
    90     delete iPbkSortManager;
       
    91     delete iPbkCntFormatter;
       
    92 
       
    93     iEnv->DeleteResourceFile( iResourceOffset );
       
    94 	}
    57 	}
    95 
    58 
    96 // ---------------------------------------------------------------------------
    59 // ---------------------------------------------------------------------------
    97 // The method resolves requestors with the contact database
    60 // The method resolves requestors with the contact database
    98 // ---------------------------------------------------------------------------
    61 // ---------------------------------------------------------------------------
    99 //
    62 //
   100 EXPORT_C void CLocRequestorUtilsResolver::ProcessRequestorsL( 
    63 EXPORT_C void CLocRequestorUtilsResolver::ProcessRequestorsL( 
   101 	RPointerArray<CPosRequestor>& aRequestors )
    64 	RPointerArray<CPosRequestor>& /*aRequestors*/ )
   102 	{
    65 	{
   103     // The Contact Stores are all opened and setup for Search Operation
    66     // Removed this functionality to avoid App layer dependency
   104     // Let us start with the first requestor now.
       
   105 	// The iCount member denotes the current requestor being processed.
       
   106 	// Initialise the value to zero.
       
   107     iCount = 0;
       
   108 
       
   109 	iRequestors = &aRequestors;
       
   110 	// Initialize the state machine.
       
   111 	iState = KNoProcessing;
       
   112 	// Start the Active Object.
       
   113 	ScheduleAORun();
       
   114 	
       
   115 	iWait.Start();
       
   116 	}
    67 	}
   117 	
    68 	
   118 // -----------------------------------------------------------------------------
    69 // -----------------------------------------------------------------------------
   119 // CLocRequestorUtilsResolver::PhoneNumberAsName
    70 // CLocRequestorUtilsResolver::PhoneNumberAsName
   120 // (other items were commented in a header).
    71 // (other items were commented in a header).
   159     const CPosRequestor& aRequestor )
   110     const CPosRequestor& aRequestor )
   160     {
   111     {
   161 	return aRequestor.RequestorIdString().AllocL();
   112 	return aRequestor.RequestorIdString().AllocL();
   162     }
   113     }
   163 
   114 
   164 
       
   165 // ---------------------------------------------------------------------------
       
   166 // This is the callback method triggered when contacts matching succeeds.
       
   167 // ---------------------------------------------------------------------------
       
   168 //
       
   169 void CLocRequestorUtilsResolver::FindCompleteL(MVPbkContactLinkArray* aResults)
       
   170     {
       
   171     iCntLinkArray = aResults;
       
   172     // Set State to process the matched contacts
       
   173    	iState = KMatchedContacts;
       
   174     // Schedule to run the Active Object again.
       
   175     ScheduleAORun();
       
   176     }
       
   177 
       
   178 
       
   179 // ---------------------------------------------------------------------------
       
   180 // This is the callback method triggered when contacts matching fails
       
   181 // ---------------------------------------------------------------------------
       
   182 //
       
   183 void CLocRequestorUtilsResolver::FindFailed(TInt /*aError*/)
       
   184     {
       
   185     // Search in one of the contact stores failed.
       
   186     // No operation to be done in this phase.
       
   187     // All actions are done after the find is completed fully in 
       
   188     // FindCompleteL
       
   189     }
       
   190 
       
   191 // ---------------------------------------------------------------------------
       
   192 // This is the callback method triggered when retrieving contact details
       
   193 // from a Contact Link
       
   194 // ---------------------------------------------------------------------------
       
   195 //
       
   196 void CLocRequestorUtilsResolver::VPbkSingleContactOperationComplete(
       
   197     MVPbkContactOperationBase& /*aOperation*/,
       
   198     MVPbkStoreContact* aContact)
       
   199     {
       
   200     iContact = aContact;
       
   201     // Set State to process the retrieved contacts Information.
       
   202     iState = KRetrievedContactInfo;
       
   203     // Schedule to run the Active Object again.
       
   204     ScheduleAORun();
       
   205     }
       
   206 
       
   207 
       
   208 // ---------------------------------------------------------------------------
       
   209 // This is the callback method triggered when there is an error in 
       
   210 // retrieving contact details from a Contact Link
       
   211 // ---------------------------------------------------------------------------
       
   212 //
       
   213 void CLocRequestorUtilsResolver::VPbkSingleContactOperationFailed(
       
   214     MVPbkContactOperationBase& /*aOperation*/, 
       
   215     TInt /*aError*/)
       
   216     {
       
   217     // In this case we cannot get the Contact card name.
       
   218     // Hence the requestor detail cannot be updated.
       
   219     // So let us move to the next state.
       
   220     // The state machine takes care of *not* updating the requestor
       
   221     // information.
       
   222     // Set State to process the retrieved contacts Information.
       
   223     iState = KRetrievedContactInfo;
       
   224     // Schedule to run the Active Object again.
       
   225     ScheduleAORun();
       
   226     }
       
   227 
       
   228 
       
   229 // ---------------------------------------------------------------------------
       
   230 // This is the callback method triggered when closing / opening the
       
   231 // contacts stores.
       
   232 // ---------------------------------------------------------------------------
       
   233 //
       
   234 void CLocRequestorUtilsResolver::OpenComplete()
       
   235     {
       
   236     // Set State to Start Requestor resolving.
       
   237     iState = KResolveRequestor;
       
   238     // Schedule to run the Active Object again.
       
   239     ScheduleAORun();
       
   240     }
       
   241 
       
   242 
       
   243 // ---------------------------------------------------------------------------
       
   244 // This is the callback method triggered when closing / opening one
       
   245 // contact store.
       
   246 // ---------------------------------------------------------------------------
       
   247 //
       
   248 void CLocRequestorUtilsResolver::StoreReady(
       
   249     MVPbkContactStore& /*aContactStore*/)
       
   250     {
       
   251     //Nothing to do here
       
   252     }
       
   253 
       
   254 
       
   255 // ---------------------------------------------------------------------------
       
   256 // This is the callback method triggered when an opened contact store becomes
       
   257 // unavailable.
       
   258 // ---------------------------------------------------------------------------
       
   259 //
       
   260 void CLocRequestorUtilsResolver::StoreUnavailable(
       
   261     MVPbkContactStore& /*aContactStore*/,
       
   262     TInt /*aReason*/)
       
   263     {
       
   264     //Nothing to do here
       
   265     }
       
   266 
       
   267 
       
   268 // ---------------------------------------------------------------------------
       
   269 // This is the callback method triggered when any event happens with the
       
   270 // opened contact stores.
       
   271 // ---------------------------------------------------------------------------
       
   272 //
       
   273 void CLocRequestorUtilsResolver::HandleStoreEventL(
       
   274     MVPbkContactStore& /*aContactStore*/, 
       
   275     TVPbkContactStoreEvent /*aStoreEvent*/)
       
   276     {
       
   277     // We don't worry about contact , group events with any contact store.
       
   278     // Also backup / restore is taken care of in the verifier dialogs and
       
   279     // so we don't need to worry about backup / restore events with this store
       
   280     // as well.
       
   281     // Hence no processing is needed here.
       
   282     // Just overriden since the base class method is pure virtual.
       
   283     }
       
   284 
       
   285 
       
   286 // -----------------------------------------------------------------------------
       
   287 // CLocRequestorUtilsResolver::RunL
       
   288 // RunL runs the full state machine operations
       
   289 // -----------------------------------------------------------------------------
       
   290 //
       
   291 void CLocRequestorUtilsResolver::RunL()
       
   292     {
       
   293     // No need to check iStatus since this is a dummy Active Object and the
       
   294     // asynchronous operation was completed locally.
       
   295     switch( iState )
       
   296         {
       
   297         case KNoProcessing:
       
   298             {
       
   299             MVPbkContactStoreList& cntStoreList = 
       
   300                             iPbkContactEngine->ContactStoresL();
       
   301             cntStoreList.OpenAllL(*this);
       
   302             }
       
   303             break;
       
   304 
       
   305         case KResolveRequestor:
       
   306             {
       
   307             TInt count = iRequestors->Count();
       
   308             if ( iCount < count )
       
   309                 {
       
   310                 // Till there are more requestors to resolve continue this
       
   311                 // operation.
       
   312                	ResolveRequestorNameL( *(*iRequestors)[iCount] );
       
   313                 }
       
   314             else
       
   315                 {
       
   316                 // Set State to complete requestors resolving process.
       
   317                 iState = KResolvingCompleted;
       
   318                 ScheduleAORun();
       
   319                 }
       
   320             }
       
   321             break;
       
   322 
       
   323         case KMatchedContacts:
       
   324             {
       
   325             // Once the Find operation is completed the control reaches here
       
   326             // and the result is stored in iCntLinkArray
       
   327             if ( iCntLinkArray && iCntLinkArray->Count() == 1 )
       
   328                 {
       
   329                 delete iCntsOperation;
       
   330                 iCntsOperation = NULL;
       
   331 
       
   332                 SetContactNameToRequestorL(0);
       
   333                 }
       
   334             else
       
   335                 {
       
   336                 delete iCntsOperation;
       
   337                 delete iCntLinkArray;
       
   338 
       
   339                 iCntLinkArray = NULL;
       
   340                 iCntsOperation = NULL;
       
   341 
       
   342                 // There is no match or more than 1 match in contact stores.
       
   343                 // So no more operation to be done on this requestor.
       
   344                 // Move onto the next requestor and start resolving process again.
       
   345                 iCount++;
       
   346                 // Set State to Start Requestor resolving.
       
   347             	iState = KResolveRequestor;
       
   348                 // Schedule to run the Active Object again.
       
   349             	ScheduleAORun();
       
   350                 }
       
   351             }
       
   352             break;
       
   353             
       
   354         case KRetrievedContactInfo:
       
   355             {
       
   356             if ( iContact )
       
   357                 {
       
   358                 HBufC* name = 
       
   359                     iPbkCntFormatter->GetContactTitleOrNullL(
       
   360                         iContact->Fields(),
       
   361                         MPbk2ContactNameFormatter::EUseSeparator);
       
   362                 if ( name )
       
   363                     {
       
   364                 	CleanupStack::PushL(name);
       
   365                 	// Set the requestor Type as Generic Name otherwise clipping
       
   366                 	// would be done as if this is a number.
       
   367                 	// Number clipping is done from beginning while text clipping
       
   368                 	// is done from the end. Hence this is not trivial.
       
   369                 	(*iRequestors)[iCount]->SetRequestorIdL( 
       
   370                 	    CPosRequestor::EIdFormatGenericName,
       
   371                 		*name );
       
   372                 	CleanupStack::PopAndDestroy( name );
       
   373                     }
       
   374                 }
       
   375 
       
   376             // Delete all information related to the current requestor resolving 
       
   377             // operation
       
   378 
       
   379             delete iContact;
       
   380             delete iCntLinkArray;
       
   381             delete iCntsOperation;
       
   382 
       
   383             iContact = NULL;
       
   384             iCntLinkArray = NULL;
       
   385             iCntsOperation = NULL;
       
   386 
       
   387             // Start next requestor resolving operation.
       
   388             iCount++;
       
   389             iState = KResolveRequestor;
       
   390             ScheduleAORun();
       
   391             }
       
   392             break;
       
   393             
       
   394         case KResolvingCompleted:
       
   395             {
       
   396             // All the handles regarding the requestor resolving namely iContact,
       
   397             // iCntLinkArray and iCntsOperation have already been cleaned up.
       
   398             // The only remaining item is the Contact Sotre handle.
       
   399             MVPbkContactStoreList& cntStoreList = 
       
   400                             iPbkContactEngine->ContactStoresL();
       
   401             // Although CloseAll takes a handle to the observer of type 
       
   402             // MVPbkContactStoreListObserver does not provide any callback mechanism.
       
   403             // It merely uses it to match in the observer array and remove it from the
       
   404             // array.
       
   405             cntStoreList.CloseAll(*this);
       
   406             CompleteRequest();
       
   407             }
       
   408             break;
       
   409         }
       
   410 
       
   411     }
       
   412 
       
   413 
       
   414 // -----------------------------------------------------------------------------
       
   415 // CLocRequestorUtilsResolver::RunError
       
   416 // Handle RunL error cases.
       
   417 // -----------------------------------------------------------------------------
       
   418 //
       
   419 TInt CLocRequestorUtilsResolver::RunError(TInt /*aError*/)
       
   420     {
       
   421     switch ( iState )
       
   422         {
       
   423         case KNoProcessing:
       
   424             // Leave occured while opening Contact Stores. Just complete the
       
   425             // resolving request.
       
   426             CompleteRequest();
       
   427             break;
       
   428         case KResolveRequestor:
       
   429             // ResolvRequestorNameL caused the leave. So current requestor 
       
   430             // cannot be resolved. 
       
   431         case KMatchedContacts:
       
   432             // RetrieveContactL caused a leave. Contact Name cannot be retrieved
       
   433         case KRetrievedContactInfo:
       
   434             // Settings the Requestor Id name failed.
       
   435             delete iContact;
       
   436             delete iCntLinkArray;
       
   437             delete iCntsOperation;
       
   438 
       
   439             iContact = NULL;
       
   440             iCntLinkArray = NULL;
       
   441             iCntsOperation = NULL;
       
   442             //So just set requestor count to next and trigger
       
   443             // the AO in the same state.
       
   444             iCount++;
       
   445             iState = KResolveRequestor;
       
   446             ScheduleAORun();
       
   447             break;
       
   448         case KResolvingCompleted:
       
   449             // Leave occured while opening Contact Stores. Just complete the
       
   450             // resolving request.
       
   451             CompleteRequest();
       
   452             break;        
       
   453         }
       
   454     return KErrNone;
       
   455     }
       
   456 
       
   457 
       
   458 // -----------------------------------------------------------------------------
       
   459 // CLocRequestorUtilsResolver::DoCancel
       
   460 // Handle Cancel operation.
       
   461 // -----------------------------------------------------------------------------
       
   462 //
       
   463 void CLocRequestorUtilsResolver::DoCancel()
       
   464     {
       
   465     //Nothing to be done here.
       
   466     }
       
   467 
       
   468 // ---------------------------------------------------------------------------
   115 // ---------------------------------------------------------------------------
   469 // CLocRequestorUtilsResolver::CLocRequestorUtilsResolver
   116 // CLocRequestorUtilsResolver::CLocRequestorUtilsResolver
   470 // C++ default constructor can NOT contain any code, that
   117 // C++ default constructor can NOT contain any code, that
   471 // might leave.
   118 // might leave.
   472 // ---------------------------------------------------------------------------
   119 // ---------------------------------------------------------------------------
   473 //
   120 //
   474 CLocRequestorUtilsResolver::CLocRequestorUtilsResolver()
   121 CLocRequestorUtilsResolver::CLocRequestorUtilsResolver()
   475     :CActive(EPriorityStandard)
       
   476 	{
   122 	{
   477 	CActiveScheduler::Add(this);
   123 	// Nothing to do.
   478 	}
   124 	}
   479 
   125 
   480 // ---------------------------------------------------------------------------
   126 // ---------------------------------------------------------------------------
   481 // CLocRequestorUtilsResolver::ConstructL
   127 // CLocRequestorUtilsResolver::ConstructL
   482 // Symbian Second Phase COnstructor
   128 // Symbian Second Phase COnstructor
   483 // ---------------------------------------------------------------------------
   129 // ---------------------------------------------------------------------------
   484 //
   130 //
   485 void CLocRequestorUtilsResolver::ConstructL()
   131 void CLocRequestorUtilsResolver::ConstructL()
   486 	{
   132 	{
   487     iEnv = CEikonEnv::Static();
   133 	// Nothing to do.
   488     
       
   489     // Retrieve the URI list of contact stores to be used for searching
       
   490     CPbk2StoreConfiguration* cntStoreCfg = CPbk2StoreConfiguration::NewL();
       
   491     CleanupStack::PushL(cntStoreCfg);
       
   492 
       
   493     CVPbkContactStoreUriArray* uriArray = 
       
   494         cntStoreCfg->SearchStoreConfigurationL();
       
   495 
       
   496     CleanupStack::PushL(uriArray);
       
   497 
       
   498     // Create the Virtual Phonebook Contact Manager class.
       
   499     // This class provides Search functionality.
       
   500 	iPbkContactEngine = CVPbkContactManager::NewL(*uriArray);
       
   501 
       
   502     // Contact Store Configuration and URI Array classes are not
       
   503     // needed anymore.
       
   504 	CleanupStack::PopAndDestroy(2, cntStoreCfg);
       
   505 
       
   506     // The Sort Manager is a parameter to the Contact Formatter Constructor
       
   507     iPbkSortManager = 
       
   508         CPbk2SortOrderManager::NewL(iPbkContactEngine->FieldTypes());
       
   509     
       
   510     // The Phonebook Formatter is a paramter to the Search method in the
       
   511     // contact manager.
       
   512     iPbkCntFormatter = 
       
   513         Pbk2ContactNameFormatterFactory::CreateL(
       
   514             iPbkContactEngine->FieldTypes(),
       
   515             *iPbkSortManager);
       
   516 
       
   517     TFileName* resourceFile = new( ELeave ) TFileName;
       
   518     CleanupStack::PushL( resourceFile );
       
   519 
       
   520     resourceFile->Append( KLocUtilsRscFile );
       
   521 
       
   522     TFileName* dllDrive = new( ELeave ) TFileName;
       
   523     CleanupStack::PushL( dllDrive );
       
   524     Dll::FileName( *dllDrive );    
       
   525 
       
   526     LocFileUtils::GetFileWithCorrectDriveL( *dllDrive, *resourceFile );
       
   527     iResourceOffset = iEnv->AddResourceFileL( *resourceFile );
       
   528     
       
   529     CleanupStack::PopAndDestroy( 2, resourceFile );
       
   530 	}
   134 	}
   531 
   135 
   532 
       
   533 // ---------------------------------------------------------------------------
       
   534 // CLocRequestorUtilsResolver::ResolveRequestorNameL
       
   535 // ---------------------------------------------------------------------------
       
   536 //
       
   537 void CLocRequestorUtilsResolver::ResolveRequestorNameL(
       
   538 	CPosRequestor& aRequestor )
       
   539 	{
       
   540     // There are 2 types of Requestors
       
   541     // 1. Contact
       
   542     // 2. Service and
       
   543     // There are 9 types of Requestor id Formats
       
   544     // 1. Generic Name
       
   545     // 2. Phone Number
       
   546     // 3. URL
       
   547     // 4. E-mail
       
   548     // 5. SIP URL
       
   549     // 6. IMS Public Identity
       
   550     // 7. MIN
       
   551     // 8. MDN
       
   552     // 9. Unknown
       
   553     // The following are the different cases for resolving.
       
   554 
       
   555     switch(aRequestor.RequestorIdFormat())
       
   556     	{
       
   557     	case CPosRequestor::EIdFormatGenericName:
       
   558 			// The requestor is identified by name.
       
   559 			// Hence there is no need to change the requestor String.
       
   560 			// So complete the resolving operation for this requestor.
       
   561 			iState = KResolveRequestor;
       
   562 			// Increment the count of resolved requestors.
       
   563 			iCount++;
       
   564 			ScheduleAORun();
       
   565     		break;
       
   566 
       
   567     	case CPosRequestor::EIdFormatPhoneNumber:
       
   568     		ResolveRequestorByPhoneNumberL(aRequestor);
       
   569     		break;
       
   570 
       
   571     	case CPosRequestor::EIdFormatUrl:
       
   572     	    {
       
   573 			// The requestor is identified by URL.
       
   574 			CVPbkFieldTypeRefsList* fieldTypeList = 
       
   575 			                        CVPbkFieldTypeRefsList::NewL();
       
   576 			CleanupStack::PushL(fieldTypeList);
       
   577 
       
   578             const MVPbkFieldTypeList& fieldTypes =
       
   579                 iPbkContactEngine->FieldTypes();
       
   580 
       
   581             // create last name field to the contact
       
   582             TResourceReader reader;
       
   583             iEnv->CreateResourceReaderLC(reader,
       
   584                 R_VPBK_URL_SELECTOR);
       
   585             CVPbkFieldTypeSelector* urlSelector = 
       
   586                 CVPbkFieldTypeSelector::NewL(reader, fieldTypes);
       
   587             CleanupStack::PushL(urlSelector);
       
   588 
       
   589             for (TInt i = 0; i < fieldTypes.FieldTypeCount(); ++i)
       
   590                 {
       
   591                 const MVPbkFieldType& fieldType = fieldTypes.FieldTypeAt(i);
       
   592                 if (urlSelector->IsFieldTypeIncluded(fieldType))
       
   593                     {
       
   594         			fieldTypeList->AppendL(fieldType);
       
   595                     break;
       
   596                     }
       
   597                 }
       
   598 
       
   599             // urlSelector, R_VPBK_URL_SELECTOR buffer 
       
   600             CleanupStack::PopAndDestroy(2); 
       
   601 
       
   602 			ResolveRequestorByOtherFieldsL( aRequestor, fieldTypeList );
       
   603 			CleanupStack::PopAndDestroy(fieldTypeList);
       
   604     	    }
       
   605     		break;
       
   606 
       
   607     	case CPosRequestor::EIdFormatEmail:
       
   608             {
       
   609 			CVPbkFieldTypeRefsList* fieldTypeList = 
       
   610 			                        CVPbkFieldTypeRefsList::NewL();
       
   611 			CleanupStack::PushL(fieldTypeList);
       
   612 
       
   613             const MVPbkFieldTypeList& fieldTypes =
       
   614                 iPbkContactEngine->FieldTypes();
       
   615 
       
   616             // create last name field to the contact
       
   617             TResourceReader reader;
       
   618             iEnv->CreateResourceReaderLC(reader,
       
   619                 R_VPBK_EMAIL_SELECTOR);
       
   620             CVPbkFieldTypeSelector* emailSelector = 
       
   621                 CVPbkFieldTypeSelector::NewL(reader, fieldTypes);
       
   622             CleanupStack::PushL(emailSelector);
       
   623 
       
   624             for (TInt i = 0; i < fieldTypes.FieldTypeCount(); ++i)
       
   625                 {
       
   626                 const MVPbkFieldType& fieldType = fieldTypes.FieldTypeAt(i);
       
   627                 if (emailSelector->IsFieldTypeIncluded(fieldType))
       
   628                     {
       
   629         			fieldTypeList->AppendL(fieldType);
       
   630                     break;
       
   631                     }
       
   632                 }
       
   633 
       
   634             // emailSelector, R_VPBK_EMAIL_SELECTOR buffer 
       
   635             CleanupStack::PopAndDestroy(2); 
       
   636 
       
   637 			ResolveRequestorByOtherFieldsL( aRequestor, fieldTypeList );
       
   638 			CleanupStack::PopAndDestroy(fieldTypeList);
       
   639     	    }
       
   640     		break;
       
   641 
       
   642     	case CPosRequestor::EIdFormatSIPUrl:
       
   643     	    {
       
   644 			CVPbkFieldTypeRefsList* fieldTypeList = 
       
   645 			                        CVPbkFieldTypeRefsList::NewL();
       
   646 			CleanupStack::PushL(fieldTypeList);
       
   647 
       
   648             const MVPbkFieldTypeList& fieldTypes =
       
   649                 iPbkContactEngine->FieldTypes();
       
   650 
       
   651             // create last name field to the contact
       
   652             TResourceReader reader;
       
   653             iEnv->CreateResourceReaderLC(reader,
       
   654                 R_VPBK_SIPURL_SELECTOR);
       
   655             CVPbkFieldTypeSelector* sipUrlSelector = 
       
   656                 CVPbkFieldTypeSelector::NewL(reader, fieldTypes);
       
   657             CleanupStack::PushL(sipUrlSelector);
       
   658 
       
   659             for (TInt i = 0; i < fieldTypes.FieldTypeCount(); ++i)
       
   660                 {
       
   661                 const MVPbkFieldType& fieldType = fieldTypes.FieldTypeAt(i);
       
   662                 if (sipUrlSelector->IsFieldTypeIncluded(fieldType))
       
   663                     {
       
   664         			fieldTypeList->AppendL(fieldType);
       
   665                     break;
       
   666                     }
       
   667                 }
       
   668 
       
   669             // sipUrlSelector, R_VPBK_SIPURL_SELECTOR buffer 
       
   670             CleanupStack::PopAndDestroy(2); 
       
   671 
       
   672 			ResolveRequestorByOtherFieldsL( aRequestor, fieldTypeList );
       
   673 			CleanupStack::PopAndDestroy(fieldTypeList);
       
   674     	    }
       
   675     		break;
       
   676 
       
   677     	case CPosRequestor::EIdFormatIMSPublicIdentity:
       
   678     	case CPosRequestor::EIdFormatMIN:
       
   679     	case CPosRequestor::EIdFormatMDN:
       
   680     	// In this case we match by any field in the Contacts
       
   681     	    {
       
   682 			const MVPbkFieldTypeList& gblFieldTypeList = 
       
   683 			                        iPbkContactEngine->FieldTypes();
       
   684 			
       
   685 			ResolveRequestorByOtherFieldsL( aRequestor, 
       
   686 			    const_cast<MVPbkFieldTypeList *>(&gblFieldTypeList) );
       
   687     	    }
       
   688     		break;
       
   689     	
       
   690     	default:
       
   691 			// If the requestor format is unknown then it won't be resolved.
       
   692 			// This case is for any future additions to the format types.
       
   693     		// Nothing to do here as of now.
       
   694 			// So complete the resolving operation for this requestor.
       
   695 			iState = KResolveRequestor;
       
   696 			// Increment the count of resolved requestors.
       
   697 			iCount++;
       
   698 			ScheduleAORun();
       
   699     		break;
       
   700     	}
       
   701 	}
       
   702 
       
   703 
       
   704 // ---------------------------------------------------------------------------
       
   705 // CLocRequestorUtilsResolver::ResolveRequestorByPhoneNumberL
       
   706 // ---------------------------------------------------------------------------
       
   707 //
       
   708 void CLocRequestorUtilsResolver::ResolveRequestorByPhoneNumberL(
       
   709 	CPosRequestor& aRequestor )
       
   710 	{
       
   711 	
       
   712 	// The requestor is identified by Phone Number.
       
   713     // Use the MatchPhoneNumberL of CPbkPhoneEngine
       
   714 	iCntsOperation = iPbkContactEngine->MatchPhoneNumberL(
       
   715                             				aRequestor.RequestorIdString(),
       
   716                             				KMaxPhoneMatchLength,
       
   717                             				*this);
       
   718 	}
       
   719 
       
   720 	
       
   721 // ---------------------------------------------------------------------------
       
   722 // CLocRequestorUtilsResolver::ResolveRequestorByOtherFieldsL
       
   723 // Searches the Contacts Database Synchronously using the field and
       
   724 // information specified in the requestor.
       
   725 // ---------------------------------------------------------------------------
       
   726 //
       
   727 void CLocRequestorUtilsResolver::ResolveRequestorByOtherFieldsL(
       
   728 	CPosRequestor& aRequestor,
       
   729 	MVPbkFieldTypeList* aFieldTypeList)
       
   730 	{
       
   731     // If the format is URL or E-mail etc then use FindL of CVPbkContactManager
       
   732 	iCntsOperation = iPbkContactEngine->FindL(aRequestor.RequestorIdString(),
       
   733 				                              *aFieldTypeList,
       
   734 				                              *this);
       
   735 	}
       
   736 
       
   737 
       
   738 // ---------------------------------------------------------------------------
       
   739 // CLocRequestorUtilsResolver::SetContactNameToRequestor
       
   740 // ---------------------------------------------------------------------------
       
   741 //
       
   742 
       
   743 void CLocRequestorUtilsResolver::SetContactNameToRequestorL(
       
   744 	TInt aCntLinkArrayIndex)
       
   745 	{
       
   746     iCntsOperation = iPbkContactEngine->RetrieveContactL(
       
   747                         iCntLinkArray->At(aCntLinkArrayIndex),
       
   748                         *this);
       
   749 	}
       
   750 
       
   751 
       
   752 // ---------------------------------------------------------------------------
       
   753 // CLocRequestorUtilsResolver::ScheduleAORun
       
   754 // Schedule to Run this dummy Active Object once again.
       
   755 // ---------------------------------------------------------------------------
       
   756 //
       
   757 void CLocRequestorUtilsResolver::ScheduleAORun()
       
   758     {
       
   759     // This results in the RunL getting called.
       
   760     if ( !IsActive() )
       
   761         {
       
   762         SetActive();
       
   763         TRequestStatus* status = &iStatus;
       
   764         User::RequestComplete(status, KErrNone);
       
   765         }
       
   766     }
       
   767 
       
   768 
       
   769 // ---------------------------------------------------------------------------
       
   770 // CLocRequestorUtilsResolver::ScheduleAORun
       
   771 // Schedule to Run this dummy Active Object once again.
       
   772 // ---------------------------------------------------------------------------
       
   773 //
       
   774 void CLocRequestorUtilsResolver::CompleteRequest()
       
   775     {
       
   776     // Stop the ActiveScheduler Wait Loop to complete the requestor resolving
       
   777     // operation.
       
   778 	iWait.AsyncStop();
       
   779     }
       
   780 
       
   781 
       
   782 //  End of File
   136 //  End of File