emailuis/emailui/src/FreestyleEmailUiCLSListsHandler.cpp
branchRCL_3
changeset 80 726fba06891a
parent 73 c8382f7b54ef
equal deleted inserted replaced
73:c8382f7b54ef 80:726fba06891a
    14 * Description:  CLS lists class implementation
    14 * Description:  CLS lists class implementation
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 #include "emailtrace.h"
    18 #include "emailtrace.h"
    19 #include <eikenv.h>
    19 #include <eikenv.h>									// CEikonEnv
    20 #include <centralrepository.h>
    20 #include <centralrepository.h>						// CRepository
    21 #include <AknFepInternalCRKeys.h>
    21 #include <AknFepInternalCRKeys.h>					// KCRUidAknFep
    22 #include "cfsmailbox.h"
    22 //<cmail>
       
    23 #include "cfsmailbox.h"								// cfsmailbox
       
    24 //</cmail>
    23 #include <CPsRequestHandler.h>
    25 #include <CPsRequestHandler.h>
    24 #include <CPsSettings.h>
    26 #include <CPsSettings.h>
    25 #include <VPbkEng.rsg>
    27 #include <VPbkEng.rsg>
    26 
    28 
    27 #include "FreestyleEmailUiCLSListsHandler.h"
    29 #include "FreestyleEmailUiCLSListsHandler.h"		// CFSEmailUiClsListsHandler
    28 #include "FreestyleEMailUiCLSMatchObserverInterface.h"
    30 #include "FreestyleEMailUiCLSMatchObserverInterface.h"// CFSEmailUiClsContactMatchObserver
    29 #include "FreestyleEmailUiInputModeObserver.h"
    31 #include "FreestyleEmailUiInputModeObserver.h"		// CFSEmailUiInputModeObserver
    30 #include "FreestyleEmailUiUtilities.h"
    32 #include "FreestyleEmailUiUtilities.h"
    31 #include "FreestyleEmailUiCLSItem.h"
    33 #include "FreestyleEmailUiCLSItem.h"
    32 
    34 
    33 // ================= MEMBER FUNCTIONS ==========================================
    35 // ================= MEMBER FUNCTIONS ==========================================
    34 // -----------------------------------------------------------------------------
    36 // -----------------------------------------------------------------------------
    35 // CFSEmailUiClsListsHandler::NewL
    37 // CFSEmailUiClsListsHandler::NewL
    36 // -----------------------------------------------------------------------------
    38 // -----------------------------------------------------------------------------
    37 CFSEmailUiClsListsHandler* CFSEmailUiClsListsHandler::NewL( RFs& aFs,
    39 CFSEmailUiClsListsHandler* CFSEmailUiClsListsHandler::NewL( RFs& aFs,
    38         CVPbkContactManager* aContactManager )
    40     CVPbkContactManager* aContactManager )
    39 	{
    41 	{
    40     FUNC_LOG;
    42     FUNC_LOG;
    41 	CFSEmailUiClsListsHandler* object = 
    43 	CFSEmailUiClsListsHandler* object = 
    42 	    CFSEmailUiClsListsHandler::NewLC( aFs, aContactManager );
    44 	    CFSEmailUiClsListsHandler::NewLC( aFs, aContactManager );
    43 	CleanupStack::Pop( object );
    45 	CleanupStack::Pop( object );
    45 	}
    47 	}
    46 
    48 
    47 // -----------------------------------------------------------------------------
    49 // -----------------------------------------------------------------------------
    48 // CFSEmailUiClsListsHandler::NewLC
    50 // CFSEmailUiClsListsHandler::NewLC
    49 // -----------------------------------------------------------------------------
    51 // -----------------------------------------------------------------------------
    50 CFSEmailUiClsListsHandler* CFSEmailUiClsListsHandler::NewLC( 
    52 CFSEmailUiClsListsHandler* CFSEmailUiClsListsHandler::NewLC( RFs& aFs, CVPbkContactManager* aContactManager )
    51         RFs& aFs, CVPbkContactManager* aContactManager )
    53 	{
    52 	{
    54     FUNC_LOG;
    53     FUNC_LOG;
    55 	CFSEmailUiClsListsHandler* object = new (ELeave) CFSEmailUiClsListsHandler( aFs, aContactManager );
    54 	CFSEmailUiClsListsHandler* object = 
       
    55 	        new (ELeave) CFSEmailUiClsListsHandler( aFs, aContactManager );
       
    56 	CleanupStack::PushL( object );
    56 	CleanupStack::PushL( object );
    57 	object->ConstructL();
    57 	object->ConstructL();
    58 	return object;
    58 	return object;
    59 	} 
    59 	} 
    60 
    60 
    83 // -----------------------------------------------------------------------------
    83 // -----------------------------------------------------------------------------
    84 void CFSEmailUiClsListsHandler::UpdateContactMatchListsL(
    84 void CFSEmailUiClsListsHandler::UpdateContactMatchListsL(
    85     const RPointerArray<CFSEmailUiClsItem>& aMatches )
    85     const RPointerArray<CFSEmailUiClsItem>& aMatches )
    86 	{
    86 	{
    87     FUNC_LOG;
    87     FUNC_LOG;
    88 
    88 	for( TInt i = 0 ; i < aMatches.Count() ; ++i )
    89     TInt matchCount = aMatches.Count();
    89 		{
    90 	for( TInt i = 0 ; i < matchCount ; ++i )
    90 		if( aMatches[i]->IsMruItem() )
    91 		{
    91 			{
    92         if( aMatches[i]->IsMruItem() )
    92 			// If this is MRU item, we need to check that it doesn't 
    93             {
    93 			// already exist in iMatchingCompleteContacts
    94             // MRU items are added to iMatchingMRUContacts and any already
    94 			TInt itemIndex = FindDuplicate( *aMatches[i], iMatchingCompleteContacts );
    95             // added duplicate is removed from iMatchingCompleteContacts
    95 			if( itemIndex == KErrNotFound )
    96             iMatchingMRUContacts.AppendL( aMatches[i] );
    96 				{
    97             TInt itemIndex = FindDuplicate( *aMatches[i], 
    97 				iMatchingMRUContacts.AppendL( aMatches[i] );
    98                     iMatchingCompleteContacts );
    98 				}
    99             if ( KErrNotFound != itemIndex )
    99 			
   100                 {
   100 			}
   101                 iMatchingCompleteContacts.Remove( itemIndex );
   101 		else if( aMatches[i]->EmailAddress().Length() > 0 )
   102                 }
   102 			{
   103             }
   103 			// If this is Phonebook item, we need to check that it doesn't 
   104         else if( aMatches[i]->EmailAddress().Length() > 0 )
   104 			// already exist in iMatchingMRUContacts
   105             {
   105 			TInt itemIndex = FindDuplicate( *aMatches[i], iMatchingMRUContacts );
   106             // For Phonebook items, it is checked that it there doesn't 
   106 			if( itemIndex != KErrNotFound )
   107             // already exist a duplicate in iMatchingMRUContacts
   107 				{
   108             if( KErrNotFound == 
   108 				// Found, this needs to be removed from the MRU list
   109                 FindDuplicate( *aMatches[i], iMatchingMRUContacts ) )
   109 				iMatchingMRUContacts.Remove( itemIndex );
   110                 {
   110 				}
   111                 // No duplicate in iMatchingMRUContacts, 
   111 
   112                 // this can be appended to iMatchingCompleteContacts
   112 			// Phonebook items are always added to the top of the list
   113                 iMatchingCompleteContacts.AppendL( aMatches[i] );
   113 			iMatchingCompleteContacts.AppendL( aMatches[i] );
   114                 }
   114 			}
   115             }
   115 		else
   116         else
   116 			{
   117             {
   117 			// No email, nothing to compare, so add this always to the end of the list
   118             // No email, add always to the end of the list
   118 			iMatchingMissingEmailContacts.AppendL( aMatches[i] );
   119             iMatchingMissingEmailContacts.AppendL( aMatches[i] );
   119 			}
   120             }
   120 		}
   121         }
   121 		
   122 	
   122     RPointerArray<CFSEmailUiClsItem> allMatches = ConstructOneListL( iMatchingCompleteContacts,
   123     RPointerArray<CFSEmailUiClsItem> allMatches = 
   123                                                                       iMatchingMRUContacts,
   124             ConstructOneListL( iMatchingCompleteContacts,
   124                                                                       iMatchingMissingEmailContacts );
   125                                iMatchingMRUContacts,
       
   126                                iMatchingMissingEmailContacts );
       
   127     CleanupResetAndDestroyClosePushL( allMatches ); // Ownership is taken
   125     CleanupResetAndDestroyClosePushL( allMatches ); // Ownership is taken
   128     iClsListObserver->ArrayUpdatedL( allMatches ); 
   126     iClsListObserver->ArrayUpdatedL( allMatches ); 
   129     CleanupStack::PopAndDestroy( &allMatches ); 
   127     CleanupStack::PopAndDestroy(&allMatches ); // Array is released, destructors are called 
   130     }
   128     }
   131 
   129 
   132 // -----------------------------------------------------------------------------
   130 // -----------------------------------------------------------------------------
   133 // CFSEmailUiClsListsHandler::InputModeChangedL
   131 // CFSEmailUiClsListsHandler::InputModeChangedL
   134 // -----------------------------------------------------------------------------
   132 // -----------------------------------------------------------------------------
   135 void CFSEmailUiClsListsHandler::InputModeChangedL( 
   133 void CFSEmailUiClsListsHandler::InputModeChangedL( TKeyboardModes aNewInputMode )
   136         TKeyboardModes aNewInputMode )
       
   137 	{
   134 	{
   138     FUNC_LOG;
   135     FUNC_LOG;
   139 	iPcsMatchObserver->SetInputMode( aNewInputMode );
   136 	iPcsMatchObserver->SetInputMode( aNewInputMode );
   140 	}
   137 	}
   141 
   138 
   169 
   166 
   170 
   167 
   171 // -----------------------------------------------------------------------------
   168 // -----------------------------------------------------------------------------
   172 // CFSEmailUiClsListsHandler::CFSEmailUiClsListsHandler
   169 // CFSEmailUiClsListsHandler::CFSEmailUiClsListsHandler
   173 // -----------------------------------------------------------------------------
   170 // -----------------------------------------------------------------------------
   174 CFSEmailUiClsListsHandler::CFSEmailUiClsListsHandler( 
   171 CFSEmailUiClsListsHandler::CFSEmailUiClsListsHandler( RFs& aFs, CVPbkContactManager* aContactManager ) :
   175         RFs& aFs, CVPbkContactManager* aContactManager ) :
       
   176 	iContactManager( aContactManager ),
   172 	iContactManager( aContactManager ),
   177 	iClsListObserver( NULL ), 
   173 	iClsListObserver( NULL ), 
   178 	iFs( aFs ),
   174 	iFs( aFs ),
   179 	iMailBox ( NULL ),
   175 	iMailBox ( NULL ),
   180 	iUseLastNameFirstOrder( EFalse )
   176 	iUseLastNameFirstOrder( EFalse )
   187 // CFSEmailUiClsListsHandler::ConstructL
   183 // CFSEmailUiClsListsHandler::ConstructL
   188 // -----------------------------------------------------------------------------
   184 // -----------------------------------------------------------------------------
   189 void CFSEmailUiClsListsHandler::ConstructL()
   185 void CFSEmailUiClsListsHandler::ConstructL()
   190 	{
   186 	{
   191     FUNC_LOG;
   187     FUNC_LOG;
   192 	iRequestHandler = CPSRequestHandler::NewL();  
   188 	iRequestHandler = CPSRequestHandler::NewL();
       
   189     
   193 	iAknFepCenRep = CRepository::NewL( KCRUidAknFep );
   190 	iAknFepCenRep = CRepository::NewL( KCRUidAknFep );
   194 	iPcsMatchObserver = CFSEmailUiClsMatchObserver::NewL( 
   191 	
   195 	        *iAknFepCenRep, *this, *iRequestHandler, iContactManager );
   192 	iPcsMatchObserver = CFSEmailUiClsMatchObserver::NewL( *iAknFepCenRep, *this, *iRequestHandler, iContactManager );
   196 	SetSearchSettingsForPcsMatchObserverL();
   193 	SetSearchSettingsForPcsMatchObserverL();
   197 	
   194 	
   198     // Monitors inputMode changes (predictive vs. non-predictive
   195     // Monitors inputMode changes (predictive vs. non-predictive
   199 	iInputObserver = CFSEmailUiInputModeObserver::NewL( *iAknFepCenRep, *this );
   196 	iInputObserver = CFSEmailUiInputModeObserver::NewL( *iAknFepCenRep, *this );
   200 
   197 
   201 	if( !iSearchedText )
   198 	if( !iSearchedText )
   202 	    {
       
   203 		iSearchedText = KNullDesC().AllocL();
   199 		iSearchedText = KNullDesC().AllocL();
   204 	    }
   200 	
       
   201     //iRemoteLookupSupported = TFsEmailUiUtility::IsRemoteLookupSupported( *iMailBox );
   205     }
   202     }
   206 
   203 
   207 // -----------------------------------------------------------------------------
   204 // -----------------------------------------------------------------------------
   208 // CFSEmailUiClsListsHandler::CopyClsItemL
   205 // CFSEmailUiClsListsHandler::CopyClsItemL
   209 // -----------------------------------------------------------------------------
   206 // -----------------------------------------------------------------------------
   216     }
   213     }
   217 
   214 
   218 // -----------------------------------------------------------------------------
   215 // -----------------------------------------------------------------------------
   219 // CFSEmailUiClsListsHandler::ReadCLSInfoFromMRUListIndexL
   216 // CFSEmailUiClsListsHandler::ReadCLSInfoFromMRUListIndexL
   220 // -----------------------------------------------------------------------------
   217 // -----------------------------------------------------------------------------
   221 TBool CFSEmailUiClsListsHandler::ReadCLSInfoFromMRUListIndexL( 
   218 TBool CFSEmailUiClsListsHandler::ReadCLSInfoFromMRUListIndexL( MDesCArray& aTextArray,
   222         MDesCArray& aTextArray,
   219 										CFSEmailUiClsItem& aClsItem,
   223         CFSEmailUiClsItem& aClsItem,
   220 										const TInt aCurrentMatchIndex, const TInt aPreviousMatchIndex )
   224         TInt aCurrentMatchIndex, 
       
   225         TInt aPreviousMatchIndex )
       
   226 	{
   221 	{
   227     FUNC_LOG;
   222     FUNC_LOG;
   228 	TBool retVal = EFalse;	
   223 	TBool retVal = EFalse;	
   229 	// This should be even number
   224 	// This should be even number
   230 	TInt currentRealItemIndex = 
   225 	TInt currentRealItemIndex = aCurrentMatchIndex - ( aCurrentMatchIndex % 2 );
   231 	        aCurrentMatchIndex - ( aCurrentMatchIndex % 2 );
       
   232 	// Here we need to check if match is found both from the display name and email address 
   226 	// Here we need to check if match is found both from the display name and email address 
   233 	if( currentRealItemIndex != aPreviousMatchIndex )
   227 	if( currentRealItemIndex != aPreviousMatchIndex )
   234 		{
   228 		{
   235 		aClsItem.SetDisplayNameL( 
   229 		aClsItem.SetDisplayNameL( aTextArray.MdcaPoint( currentRealItemIndex )  );
   236 		        aTextArray.MdcaPoint( currentRealItemIndex ) );
   230 		aClsItem.SetEmailAddressL( aTextArray.MdcaPoint( currentRealItemIndex + 1 )  );
   237 		aClsItem.SetEmailAddressL( 
       
   238 		        aTextArray.MdcaPoint( currentRealItemIndex + 1 ) );
       
   239 		retVal = ETrue;
   231 		retVal = ETrue;
   240 		}
   232 		}
   241 	return retVal;
   233 	return retVal;
   242 	}
   234 	}
   243 
   235 
   244 
   236 
   245 // -----------------------------------------------------------------------------
   237 // -----------------------------------------------------------------------------
   246 // CFSEmailUiClsListsHandler::FindAndDestroyDuplicate
   238 // CFSEmailUiClsListsHandler::FindAndDestroyDuplicate
   247 // -----------------------------------------------------------------------------
   239 // -----------------------------------------------------------------------------
   248 TInt CFSEmailUiClsListsHandler::FindDuplicate( 
   240 TInt CFSEmailUiClsListsHandler::FindDuplicate( const CFSEmailUiClsItem& aClsItem,
   249         const CFSEmailUiClsItem& aClsItem,
   241 		  RPointerArray<CFSEmailUiClsItem>& aContacts )
   250         RPointerArray<CFSEmailUiClsItem>& aContacts )
       
   251 	{
   242 	{
   252     FUNC_LOG;
   243     FUNC_LOG;
   253 	// find duplicate email addresses from aContacts
   244 	// find duplicate email addresses from aContacts
   254 	const TDesC& emailAddress = aClsItem.EmailAddress();
   245 	const TDesC& emailAddress = aClsItem.EmailAddress();
   255 
   246 
   268 
   259 
   269 // -----------------------------------------------------------------------------
   260 // -----------------------------------------------------------------------------
   270 // CFSEmailUiClsListsHandler::ConstructOneListL
   261 // CFSEmailUiClsListsHandler::ConstructOneListL
   271 // -----------------------------------------------------------------------------
   262 // -----------------------------------------------------------------------------
   272 RPointerArray<CFSEmailUiClsItem> CFSEmailUiClsListsHandler::ConstructOneListL( 
   263 RPointerArray<CFSEmailUiClsItem> CFSEmailUiClsListsHandler::ConstructOneListL( 
   273         const RPointerArray<CFSEmailUiClsItem>& aContactMatchesWithEmail,
   264 								const RPointerArray<CFSEmailUiClsItem>& aContactMatchesWithEmail,
   274         const RPointerArray<CFSEmailUiClsItem>& aMRUMatches,
   265 								const RPointerArray<CFSEmailUiClsItem>& aMRUMatches,
   275         const RPointerArray<CFSEmailUiClsItem>& aContactMatchesWithoutEmail )
   266 								const RPointerArray<CFSEmailUiClsItem>& aContactMatchesWithoutEmail )
   276 	{
   267 	{
   277     FUNC_LOG;
   268     FUNC_LOG;
   278 	RPointerArray<CFSEmailUiClsItem> allMatches;
   269 	RPointerArray<CFSEmailUiClsItem> allMatches;
   279 	CleanupResetAndDestroyClosePushL( allMatches );
   270 	CleanupResetAndDestroyClosePushL( allMatches );
   280 	
   271 	
   281 	// Copy all the objects from three other lists to the all matches list
   272 	// Copy all the objects from three other lists to the all matches list
   282    TInt matchingMRUItemsCount = aMRUMatches.Count();
       
   283     for ( TInt i = 0 ; i < matchingMRUItemsCount ; i++ )
       
   284         {
       
   285         CFSEmailUiClsItem* newClsItem = CopyClsItemLC( *aMRUMatches[i] );
       
   286         allMatches.AppendL( newClsItem );
       
   287         CleanupStack::Pop( newClsItem );
       
   288         }
       
   289 
       
   290 	TInt matchingComleteItemsCount = aContactMatchesWithEmail.Count();
   273 	TInt matchingComleteItemsCount = aContactMatchesWithEmail.Count();
   291 	for( TInt i = 0 ; i <  matchingComleteItemsCount; i++ )
   274 	for( TInt i = 0 ; i <  matchingComleteItemsCount; i++ )
   292 		{
   275 		{
   293 		CFSEmailUiClsItem* newClsItem = 
   276 		CFSEmailUiClsItem* newClsItem = CopyClsItemLC( *aContactMatchesWithEmail[i] );
   294 		        CopyClsItemLC( *aContactMatchesWithEmail[i] );
       
   295 		allMatches.AppendL( newClsItem );
   277 		allMatches.AppendL( newClsItem );
   296 		CleanupStack::Pop( newClsItem );
   278 		CleanupStack::Pop( newClsItem );
   297 		}
   279 		}
   298 
   280 
   299 	TInt mathingContactItemsWithoutEmailCount = 
   281 	TInt matchingMRUItemsCount = aMRUMatches.Count();
   300 	        aContactMatchesWithoutEmail.Count();
   282 	for ( TInt i = 0 ; i < matchingMRUItemsCount ; i++ )
   301 	for( TInt i = 0 ; i < mathingContactItemsWithoutEmailCount ; i++ )
   283 		{
   302 		{
   284 		CFSEmailUiClsItem* newClsItem = CopyClsItemLC( *aMRUMatches[i] );
   303 		CFSEmailUiClsItem* newClsItem = 
       
   304 		        CopyClsItemLC( *aContactMatchesWithoutEmail[i] );
       
   305 		allMatches.AppendL( newClsItem );
   285 		allMatches.AppendL( newClsItem );
   306 		CleanupStack::Pop( newClsItem );
   286 		CleanupStack::Pop( newClsItem );
   307 		}
   287 		}
   308 
   288 
       
   289 	TInt mathingContactItemsWithoutEmailCount = aContactMatchesWithoutEmail.Count();
       
   290 	for( TInt i = 0 ; i < mathingContactItemsWithoutEmailCount ; i++ )
       
   291 		{
       
   292 		CFSEmailUiClsItem* newClsItem = CopyClsItemLC( *aContactMatchesWithoutEmail[i] );
       
   293 		allMatches.AppendL( newClsItem );
       
   294 		CleanupStack::Pop( newClsItem );
       
   295 		}
       
   296 
   309 	CleanupStack::Pop( &allMatches );	
   297 	CleanupStack::Pop( &allMatches );	
   310 	return allMatches;
   298 	return allMatches;
   311 	}
   299 	}
   312 
   300 
   313 // -----------------------------------------------------------------------------
   301 // -----------------------------------------------------------------------------
   316 void CFSEmailUiClsListsHandler::SetSearchSettingsForPcsMatchObserverL()
   304 void CFSEmailUiClsListsHandler::SetSearchSettingsForPcsMatchObserverL()
   317     {
   305     {
   318     FUNC_LOG;
   306     FUNC_LOG;
   319     // Create predictive search settings
   307     // Create predictive search settings
   320     CPsSettings* searchSettings = CPsSettings::NewL();
   308     CPsSettings* searchSettings = CPsSettings::NewL();
   321     CleanupStack::PushL( searchSettings );
   309     CleanupStack::PushL(searchSettings);
   322 
   310 
   323     RPointerArray<TDesC> databases;
   311     RPointerArray<TDesC> databases;
   324     CleanupClosePushL( databases );
   312     CleanupClosePushL(databases);
   325 
   313 
   326     HBufC* store1 = HBufC::NewLC( 50 );
   314     HBufC* store1 = HBufC::NewLC(50);
   327     store1->Des().Copy( KVPbkDefaultCntDbURI ); // Phone contacts store
   315     store1->Des().Copy( KVPbkDefaultCntDbURI ); // To specify phone contacts store
   328     
   316     
   329     databases.AppendL( store1 );
   317     databases.AppendL(store1);
   330     HBufC* store2 = NULL;
   318     HBufC* store2 = NULL;
   331     if ( iMailBox )
   319     if ( iMailBox )
   332         {
   320         {
   333         store2 = HBufC::NewLC(50);
   321         store2 = HBufC::NewLC(50);
   334         GetMruDatastoreUriFromMailbox( *iMailBox, *store2 );
   322         GetMruDatastoreUriFromMailbox( *iMailBox, *store2 );
   335         databases.AppendL( store2 );
   323         databases.AppendL( store2 );
   336         }
   324         }
   337     searchSettings->SetSearchUrisL( databases );
   325     searchSettings->SetSearchUrisL(databases);
   338 
   326 
   339     // Set displayfields according to sort order
   327     // Set displayfields according to sort order
   340     RArray<TInt> sortOrder;
   328     RArray<TInt> sortOrder;
   341     CleanupClosePushL( sortOrder );
   329     CleanupClosePushL( sortOrder );
   342     iRequestHandler->GetSortOrderL( *store1, sortOrder );
   330     iRequestHandler->GetSortOrderL( *store1, sortOrder );
   343     if ( sortOrder.Count() )
   331     if ( sortOrder.Count() )
   344         {
   332         {
   345         iUseLastNameFirstOrder = 
   333         iUseLastNameFirstOrder = ( sortOrder[0] == R_VPBK_FIELD_TYPE_LASTNAME );
   346                 ( sortOrder[0] == R_VPBK_FIELD_TYPE_LASTNAME );
       
   347         }
   334         }
   348     else
   335     else
   349         {
   336         {
   350         iUseLastNameFirstOrder = EFalse; // default is not to change order
   337         iUseLastNameFirstOrder = EFalse; // default is not to change order
   351         }
   338         }
   352     RArray<TInt> displayFields( 6 );
   339     RArray<TInt> displayFields( 6 );
   353     CleanupClosePushL( displayFields );
   340     CleanupClosePushL( displayFields );
   354     if ( sortOrder.Count() ) 
   341     displayFields.AppendL( sortOrder[0] );
   355         {
   342     if ( sortOrder.Count() >= 1 ) displayFields.AppendL( sortOrder[1] );
   356         displayFields.AppendL( sortOrder[0] );
       
   357         }
       
   358     if ( sortOrder.Count() >= 1 ) 
       
   359         {
       
   360         displayFields.AppendL( sortOrder[1] );
       
   361         }
       
   362     displayFields.AppendL( R_VPBK_FIELD_TYPE_EMAILGEN );
   343     displayFields.AppendL( R_VPBK_FIELD_TYPE_EMAILGEN );
   363     displayFields.AppendL( R_VPBK_FIELD_TYPE_EMAILHOME );
   344     displayFields.AppendL( R_VPBK_FIELD_TYPE_EMAILHOME );
   364     displayFields.AppendL( R_VPBK_FIELD_TYPE_EMAILWORK );
   345     displayFields.AppendL( R_VPBK_FIELD_TYPE_EMAILWORK );
   365     searchSettings->SetDisplayFieldsL( displayFields );
   346     searchSettings->SetDisplayFieldsL( displayFields );
   366     CleanupStack::Pop( &displayFields );
   347     CleanupStack::Pop( &displayFields );
   367     CleanupStack::Pop( &sortOrder );
   348     CleanupStack::Pop( &sortOrder );
   368     displayFields.Close();
   349     displayFields.Close();
   369     sortOrder.Close();
   350     sortOrder.Close();
   370 
   351 
       
   352     // Set maximum for search results
       
   353     //How many results is shown on the screen??
       
   354     //searchSettings->SetMaxResults(const TInt aMaxResults);
       
   355 
   371     // Set the new search settings
   356     // Set the new search settings
   372     iRequestHandler->SetSearchSettingsL( *searchSettings );	
   357     iRequestHandler->SetSearchSettingsL(*searchSettings);	
   373 
   358 
   374     if ( store2 )
   359     if ( store2 )
   375         {
   360         {
   376         CleanupStack::PopAndDestroy( store2 );
   361         CleanupStack::PopAndDestroy(store2);
   377         }
   362         }
   378     CleanupStack::PopAndDestroy( store1 );
   363     CleanupStack::PopAndDestroy(store1);
   379     CleanupStack::Pop( &databases );
   364     CleanupStack::Pop(&databases);
   380     databases.Close();
   365     databases.Close();
   381     CleanupStack::PopAndDestroy( searchSettings );
   366     CleanupStack::PopAndDestroy(searchSettings);
   382 
   367 
   383 	}
   368 	}
   384 
   369 
   385 // -----------------------------------------------------------------------------
   370 // -----------------------------------------------------------------------------
   386 // CFSEmailUiClsListsHandler::IsLanguageSupported()
   371 // CFSEmailUiClsListsHandler::isLanguageSupported()
   387 // -----------------------------------------------------------------------------
   372 // -----------------------------------------------------------------------------
   388 TBool CFSEmailUiClsListsHandler::IsLanguageSupportedL()
   373 TBool CFSEmailUiClsListsHandler::IsLanguageSupportedL()
   389 	{
   374 	{
   390     FUNC_LOG;
   375     FUNC_LOG;
   391 	// Get the current language
   376 	// Get the current language
   392 	TLanguage lang = User::Language();
   377 	TLanguage lang = User::Language();
   393 
   378 
   394 	// Check for language support
   379 	// Check for language support
   395 	return iRequestHandler->IsLanguageSupportedL( lang );
   380 	return iRequestHandler->IsLanguageSupportedL(lang);
   396 	}
   381 	}
   397 
   382 
   398 // -----------------------------------------------------------------------------
   383 void CFSEmailUiClsListsHandler::GetMruDatastoreUriFromMailbox( CFSMailBox& aMailbox, HBufC& aUri )
   399 // CFSEmailUiClsListsHandler::GetMruDatastoreUriFromMailbox()
       
   400 // -----------------------------------------------------------------------------
       
   401 void CFSEmailUiClsListsHandler::GetMruDatastoreUriFromMailbox( 
       
   402         CFSMailBox& aMailbox, HBufC& aUri )
       
   403 	{
   384 	{
   404     FUNC_LOG;
   385     FUNC_LOG;
   405 	aUri.Des().Copy( KDefaultMailBoxURI );
   386 	aUri.Des().Copy( KDefaultMailBoxURI );
   406 	aUri.Des().AppendNum( aMailbox.GetId().PluginId().iUid );
   387 	aUri.Des().AppendNum( aMailbox.GetId().PluginId().iUid );
   407 	aUri.Des().Append( KDefaultMailBoxURISeparator );
   388 	aUri.Des().Append( KDefaultMailBoxURISeparator );
   408 	aUri.Des().AppendNum( aMailbox.GetId().Id() );
   389 	aUri.Des().AppendNum( aMailbox.GetId().Id() );
   409 	}
   390 	}
   410 
   391 
   411 // -----------------------------------------------------------------------------
   392 void CFSEmailUiClsListsHandler::SetObserver( MFSEmailUiClsListsObserver* aClsListObserver )
   412 // CFSEmailUiClsListsHandler::SetObserver()
       
   413 // -----------------------------------------------------------------------------
       
   414 void CFSEmailUiClsListsHandler::SetObserver( 
       
   415         MFSEmailUiClsListsObserver* aClsListObserver )
       
   416     {
   393     {
   417     FUNC_LOG;
   394     FUNC_LOG;
   418     iClsListObserver = aClsListObserver;
   395     iClsListObserver = aClsListObserver;
   419     }
   396     }
   420 
   397 
   421 // -----------------------------------------------------------------------------
       
   422 // CFSEmailUiClsListsHandler::SetCurrentMailboxL()
       
   423 // -----------------------------------------------------------------------------
       
   424 void CFSEmailUiClsListsHandler::SetCurrentMailboxL( CFSMailBox* aMailBox )
   398 void CFSEmailUiClsListsHandler::SetCurrentMailboxL( CFSMailBox* aMailBox )
   425     {
   399     {
   426     FUNC_LOG;
   400     FUNC_LOG;
   427     TFSMailMsgId currentMailboxId;
   401     TFSMailMsgId currentMailboxId;
   428     TFSMailMsgId newMailboxId;
   402     TFSMailMsgId newMailboxId;
   441         iMailBox = aMailBox;
   415         iMailBox = aMailBox;
   442     	SetSearchSettingsForPcsMatchObserverL();
   416     	SetSearchSettingsForPcsMatchObserverL();
   443     	}
   417     	}
   444     }
   418     }
   445 
   419 
   446 // -----------------------------------------------------------------------------
       
   447 // CFSEmailUiClsListsHandler::OperationErrorL()
       
   448 // -----------------------------------------------------------------------------
       
   449 void CFSEmailUiClsListsHandler::OperationErrorL( TInt aErrorCode )
   420 void CFSEmailUiClsListsHandler::OperationErrorL( TInt aErrorCode )
   450 	{
   421 	{
   451     FUNC_LOG;
   422     FUNC_LOG;
   452 	iClsListObserver->OperationErrorL( aErrorCode );
   423 	iClsListObserver->OperationErrorL( aErrorCode );
   453 	}
   424 	}
   454 
   425 
   455 // -----------------------------------------------------------------------------
       
   456 // CFSEmailUiClsListsHandler::UseLastNameFirstOrder()
       
   457 // -----------------------------------------------------------------------------
       
   458 TBool CFSEmailUiClsListsHandler::UseLastNameFirstOrder()
   426 TBool CFSEmailUiClsListsHandler::UseLastNameFirstOrder()
   459     {
   427     {
   460     FUNC_LOG;
   428     FUNC_LOG;
   461     return iUseLastNameFirstOrder;
   429     return iUseLastNameFirstOrder;
   462     }
   430     }