emailuis/emailui/inc/FreestyleEmailUiCLSListsHandler.h
changeset 0 8466d47a6819
child 26 968773a0b6ef
equal deleted inserted replaced
-1:000000000000 0:8466d47a6819
       
     1 /*
       
     2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  CLS lists handler class definition
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef FREESTYLEEMAILUICLSLISTSHANDLER_H
       
    20 #define FREESTYLEEMAILUICLSLISTSHANDLER_H
       
    21 
       
    22 //  INCLUDES
       
    23 #include <CPcsDefs.h>
       
    24 
       
    25 // FORWARD DECLARATIONS
       
    26 class CPSRequestHandler;
       
    27 class CRepository;
       
    28 class CFSEmailUiClsMatchObserver;
       
    29 class MFSEmailUiClsListsObserver;
       
    30 class CFSEmailUiInputModeObserver;
       
    31 class CFSMailBox;
       
    32 class RFs;
       
    33 class CVPbkContactManager;
       
    34 class CFSEmailUiClsItem;
       
    35 class MDesCArray;
       
    36 
       
    37 _LIT(KDefaultMailBoxURI, "mailbox://");
       
    38 _LIT(KDefaultMailBoxURISeparator, "/");
       
    39 
       
    40 // CLASS DECLARATION
       
    41 /**
       
    42  * Freestyle email application cls lists handler
       
    43  *
       
    44  *
       
    45  */
       
    46  
       
    47 class CFSEmailUiClsListsHandler : public CBase
       
    48 	{
       
    49 
       
    50  public:
       
    51   	  
       
    52 
       
    53     /**
       
    54      * Two-phased constructor.
       
    55      * Creates a new instance of class
       
    56      *
       
    57 	 * @param aClsListObserver reference to lists observer object.
       
    58      * @param aMailBox reference to current mailbox item
       
    59 	 * @param aFs reference to file server session
       
    60      *
       
    61      * @returns CFSEmailUiClsListsHandler instance
       
    62      */
       
    63   	 static CFSEmailUiClsListsHandler* NewL( RFs& aFs, CVPbkContactManager* aContactManager );
       
    64   	
       
    65     /**
       
    66      * Two-phased constructor.
       
    67      * Creates a new instance of class
       
    68      *
       
    69 	 * @param aClsListObserver reference to lists observer object.
       
    70      * @param aMailBox reference to current mailbox item
       
    71 	 * @param aFs reference to file server session
       
    72 	 *
       
    73      * @returns CFSEmailUiClsListsHandler instance
       
    74      */
       
    75   	 static CFSEmailUiClsListsHandler* NewLC( RFs& aFs, CVPbkContactManager* aContactManager  );
       
    76 
       
    77     /**
       
    78      * Destructor.
       
    79      *
       
    80      */  
       
    81   	 virtual ~CFSEmailUiClsListsHandler();
       
    82 
       
    83 public:  // new methods 
       
    84 
       
    85 
       
    86    /**
       
    87     * Updates all the matching contact lists and informs the observer to update the view
       
    88 	* This method is for cls contact match observer to call.
       
    89     *
       
    90     * @param aMatches ids of all the matches so far.
       
    91     */
       
    92 	void UpdateContactMatchListsL( const RPointerArray<CFSEmailUiClsItem>& aMatches );
       
    93 
       
    94 
       
    95  	/**
       
    96  	 * This method is for input mode observer to call. Set new input mode to both matchers
       
    97  	 *
       
    98  	 * @param aInputMode EItut if new input mode is predictive. EQwerty if multitap
       
    99  	 *
       
   100  	 */
       
   101  	void InputModeChangedL( TKeyboardModes aInputMode );
       
   102  
       
   103  	/**
       
   104  	 * Returns the text we are currently matching
       
   105 	 *
       
   106 	 * @return TDesC& reference to current search string
       
   107 	 */
       
   108 	const TDesC& CurrentSearchText();
       
   109  
       
   110 	/**
       
   111  	 * Sets new search text and either starts a search or buffers the search 
       
   112  	 * request. 
       
   113 	 *
       
   114 	 * @param aText new search text.
       
   115 	 */
       
   116 	void SearchMatchesL( const TDesC& aText );
       
   117 	
       
   118 	/**
       
   119 	 * Check if the input language is supported by search engine
       
   120 	 */
       
   121 	TBool IsLanguageSupportedL();
       
   122 
       
   123 	void SetObserver( MFSEmailUiClsListsObserver* aClsListObserver );
       
   124 	void SetCurrentMailboxL( CFSMailBox* aMailBox );
       
   125 
       
   126 	void OperationErrorL( TInt aErrorCode );
       
   127 	
       
   128 protected:
       
   129 
       
   130     /**
       
   131      * C++ default constructor.
       
   132      *
       
   133 	 * @param aClsListObserver reference to lists observer object.
       
   134      * @param aMailBox reference to current mailbox item
       
   135 	 * @param aFs reference to file server session
       
   136      *
       
   137      */
       
   138   	 CFSEmailUiClsListsHandler( RFs& aFs, CVPbkContactManager* aContactManager );
       
   139 
       
   140 private:
       
   141 
       
   142     /**
       
   143      * ConstructL
       
   144      *
       
   145      */
       
   146 	void ConstructL();
       
   147 	
       
   148 
       
   149      /**
       
   150      * Reads display name & email address from current match item index from the aTextArray
       
   151      * and writes those informations to given clsitem
       
   152      *
       
   153 	 * @param aTextArray MRU list of display names and email addresses
       
   154 	 * @param aClsItem new clsitem where the information is written
       
   155 	 * @param aCurrentMatchIndex index of the display name or email address that matched the search
       
   156 	 * @param aPreviousMatchIndex index of the previous match. This is for checking that the item
       
   157 	 *								 has not been added to the match list yet
       
   158      *
       
   159      * @return TBool ETrue if current item was new match. EFalse if matched item was the same as previous match
       
   160      */
       
   161 	TBool ReadCLSInfoFromMRUListIndexL( MDesCArray& aTextArray,
       
   162 										CFSEmailUiClsItem& aClsItem,
       
   163 										const TInt aCurrentMatchIndex,
       
   164 										const TInt aPreviousMatchIndex );
       
   165 
       
   166     /**
       
   167      * Searches given cls item from the given list. If duplicate is found, it is returned.
       
   168      *
       
   169 	 * @param aClsItem cls item to be found from the list
       
   170 	 * @param aContacts list of contacts
       
   171      *
       
   172      * @return index of the item, KErrNotFound if it doesn't exist
       
   173      */
       
   174 	TInt FindDuplicate( const CFSEmailUiClsItem& aClsItem,
       
   175 								  RPointerArray<CFSEmailUiClsItem>& aContacts );
       
   176 
       
   177     /**
       
   178      * Appends all the matches item from contact db and mru list to one list, which is given to ui to draw.
       
   179      *
       
   180 	 * @param aContactMatchesWithEmail list of so far matched contacts with email address 
       
   181 	 * @param aMRUMatches list of so far matched MRU items
       
   182  	 * @param aContactMatchesWithoutEmail list of so far matched contacts without email address
       
   183      *
       
   184      */
       
   185 	RPointerArray<CFSEmailUiClsItem> ConstructOneListL( 
       
   186 									const RPointerArray<CFSEmailUiClsItem>& aContactMatchesWithEmail,
       
   187 									  const RPointerArray<CFSEmailUiClsItem>& aMRUMatches,
       
   188 									  const RPointerArray<CFSEmailUiClsItem>& aContactMatchesWithoutEmail );
       
   189 
       
   190  	
       
   191  	/**
       
   192  	 * Creates new cls item and copies all the data from given cls item to the new item.
       
   193  	 *
       
   194 	 * @param aClsItem old cls item where the data is been copied.
       
   195 	 *
       
   196 	 * @return CFSEmailUiClsItem* pointer to the newly created cls item. Pointer is leaved to the
       
   197 	 *								cleanupstack as well.
       
   198  	 */
       
   199  	CFSEmailUiClsItem* CopyClsItemLC( const CFSEmailUiClsItem& aClsItem );
       
   200  	
       
   201  	/**
       
   202  	 * Constructs MRU datastore Uri for Mailbox
       
   203  	 **/
       
   204  	void GetMruDatastoreUriFromMailbox( CFSMailBox& aMailbox, HBufC& aUri );
       
   205     
       
   206 private: //Functions
       
   207 	
       
   208 	void SetSearchSettingsForPcsMatchObserverL();
       
   209 	
       
   210 	
       
   211 private: // data
       
   212 
       
   213 	// Three pointer array's for different lists
       
   214 	RPointerArray<CFSEmailUiClsItem> 	iMatchingCompleteContacts;
       
   215 	RPointerArray<CFSEmailUiClsItem> 	iMatchingMRUContacts;
       
   216     RPointerArray<CFSEmailUiClsItem> 	iMatchingMissingEmailContacts;
       
   217 
       
   218 	MDesCArray*							iAllMRUContacts;	// owned
       
   219 
       
   220     // Pointer to the service instance
       
   221 	CPSRequestHandler* 					iRequestHandler; // owned
       
   222     
       
   223     // Pointer AknFep Central repository
       
   224     CRepository*						iAknFepCenRep; // owned
       
   225     
       
   226     CVPbkContactManager* 				iContactManager;
       
   227     // Pointer to input observer		
       
   228     CFSEmailUiInputModeObserver*		iInputObserver; // owned
       
   229     
       
   230     MFSEmailUiClsListsObserver* 		iClsListObserver;
       
   231     CFSEmailUiClsMatchObserver*			iPcsMatchObserver;// owned
       
   232     
       
   233     HBufC*								iSearchedText; // owned
       
   234     
       
   235     // Pointer to actual contact database.
       
   236     RFs&								iFs;			
       
   237     
       
   238     // Reference to current mailbox
       
   239     CFSMailBox* 						iMailBox;
       
   240 
       
   241     TBool                               iRemoteLookupSupported;
       
   242   
       
   243     };
       
   244 
       
   245 #endif  // FREESTYLEEMAILUICLSLISTSHANDLER_H
       
   246 
       
   247 // End of File