meetingrequest/mrgui/mrfieldbuilderpluginextension/inc/cesmrclslistshandler.h
changeset 0 8466d47a6819
child 12 4ce476e64c59
equal deleted inserted replaced
-1:000000000000 0:8466d47a6819
       
     1 /*
       
     2 * Copyright (c) 2007-2009 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 #ifndef CESMRCLSLISTSHANDLER_H
       
    19 #define CESMRCLSLISTSHANDLER_H
       
    20 
       
    21 //  INCLUDES
       
    22 #include <e32base.h>
       
    23 #include <cntdef.h>                     // TContactItemId
       
    24 #include <bamdesca.h>                   // MDesCArray
       
    25 #include <CPbkContactItem.h>
       
    26 #include <CPcsDefs.h>
       
    27 
       
    28 #include "cesmrclsitem.h"
       
    29 #include "resmrstatic.h"
       
    30 
       
    31 // FORWARD DECLARATIONS
       
    32 class CPSRequestHandler;
       
    33 class CRepository;
       
    34 class CESMRClsMatchObserver;
       
    35 class CESMRInputModeObserver;
       
    36 class MESMRClsListsObserver;
       
    37 class CFSMailBox;
       
    38 class RFs;
       
    39 class CPsQuery;
       
    40 class CVPbkContactManager;
       
    41 
       
    42 // CLASS DECLARATION
       
    43 /**
       
    44  * Handler for cls lists. Heavy array operations are wrapped here.
       
    45  */
       
    46 NONSHARABLE_CLASS( CESMRClsListsHandler ) : public CBase
       
    47     {
       
    48 public:
       
    49     /**
       
    50      * Two-phased constructor.
       
    51      * Creates a new instance of class
       
    52      *
       
    53      * @param aClsListObserver reference to lists observer object.
       
    54      * @param aMailBox reference to current mailbox item
       
    55      * @param aFs reference to file server session
       
    56      *
       
    57      * @return CESMRClsListsHandler instance
       
    58      */
       
    59     static CESMRClsListsHandler* NewL( RFs& aFs, CVPbkContactManager* aContactManager );
       
    60 
       
    61     /**
       
    62      * Two-phased constructor.
       
    63      * Creates a new instance of class and leaves it on the cleanupstack
       
    64      *
       
    65      * @param aClsListObserver reference to lists observer object.
       
    66      * @param aMailBox reference to current mailbox item
       
    67      * @param aFs reference to file server session
       
    68      *
       
    69      * @return CESMRClsListsHandler instance
       
    70      */
       
    71     static CESMRClsListsHandler* NewLC( RFs& aFs, CVPbkContactManager* aContactManager  );
       
    72 
       
    73     /**
       
    74      * Destructor.
       
    75      */
       
    76     virtual ~CESMRClsListsHandler();
       
    77 
       
    78 public: // new methods
       
    79     /**
       
    80      * Updates all the matching contact lists and informs the observer to update the view
       
    81      * This method is for cls contact match observer to call.
       
    82      *
       
    83      * @param aMatches ids of all the matches so far.
       
    84      */
       
    85     void UpdateContactMatchListsL( const RPointerArray<CESMRClsItem>& aMatches );
       
    86 
       
    87     /**
       
    88      * This method is for input mode observer to call. Set new input mode to both matchers
       
    89      *
       
    90      * @param aInputMode EItut if new input mode is predictive. EQwerty if multitap
       
    91      */
       
    92     void InputModeChangedL( TKeyboardModes aNewInputMode );
       
    93 
       
    94     /**
       
    95      * Returns the text we are currently matching
       
    96      *
       
    97      * @return TDesC& reference to current search string
       
    98      */
       
    99     const TDesC& CurrentSearchText();
       
   100 
       
   101     /**
       
   102      * Sets new search text and either starts a search or buffers the search
       
   103      * request.
       
   104      *
       
   105      * @param aText new search text.
       
   106      */
       
   107     void SearchMatchesL( const TDesC& aText );
       
   108 
       
   109     /**
       
   110      * Check if the input language is supported by search engine
       
   111      */
       
   112     TBool IsLanguageSupportedL();
       
   113 
       
   114     /**
       
   115      * Sets a MESMRClsListsObserver
       
   116      */
       
   117     void SetObserver( MESMRClsListsObserver* aClsListObserver );
       
   118     
       
   119     /**
       
   120      * Sets mailbox to be used
       
   121      */
       
   122     void SetCurrentMailboxL( CFSMailBox* aMailBox );
       
   123     
       
   124     /**
       
   125      * handle operation errors
       
   126      */
       
   127     void OperationErrorL( TInt aErrorCode );
       
   128     
       
   129 protected:
       
   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     CESMRClsListsHandler( RFs& aFs, CVPbkContactManager* aContactManager );
       
   138 
       
   139 private:
       
   140     /**
       
   141      * ConstructL
       
   142      */
       
   143     void ConstructL();
       
   144 
       
   145     /**
       
   146      * Reads display name & email address from current match item index from the aTextArray
       
   147      * and writes those informations to given clsitem
       
   148      *
       
   149      * @param aTextArray MRU list of display names and email addresses
       
   150      * @param aClsItem new clsitem where the information is written
       
   151      * @param aCurrentMatchIndex index of the display name or email address that matched the search
       
   152      * @param aPreviousMatchIndex index of the previous match. This is for checking that the item
       
   153      *                            has not been added to the match list yet
       
   154      *
       
   155      * @return TBool ETrue if current item was new match. EFalse if matched item was the same as previous match
       
   156      */
       
   157     TBool ReadCLSInfoFromMRUListIndexL( MDesCArray& aTextArray,
       
   158             CESMRClsItem& aClsItem,
       
   159             const TInt aCurrentMatchIndex,
       
   160             const TInt aPreviousMatchIndex );
       
   161 
       
   162     /**
       
   163      * Searches given cls item from the given list. If duplicate is found, it is returned.
       
   164      *
       
   165      * @param aClsItem cls item to be found from the list
       
   166      * @param aContacts list of contacts
       
   167      *
       
   168      * @return index of the item, KErrNotFound if it doesn't exist
       
   169      */
       
   170     TInt FindDuplicate( const CESMRClsItem& aClsItem,
       
   171                                   RPointerArray<CESMRClsItem>& aContacts );
       
   172 
       
   173     /**
       
   174      * Appends all the matches item from contact db and mru list to one list, which is given to ui to draw.
       
   175      *
       
   176      * @param aContactMatchesWithEmail list of so far matched contacts with email address
       
   177      * @param aMRUMatches list of so far matched MRU items
       
   178      * @param aContactMatchesWithoutEmail list of so far matched contacts without email address
       
   179      */
       
   180     RPointerArray<CESMRClsItem> ConstructOneListL(
       
   181             const RPointerArray<CESMRClsItem>& aContactMatchesWithEmail,
       
   182             const RPointerArray<CESMRClsItem>& aMRUMatches,
       
   183             const RPointerArray<CESMRClsItem>& aContactMatchesWithoutEmail );
       
   184 
       
   185     /**
       
   186      * Creates new cls item and copies all the data from given cls item to the new item.
       
   187      *
       
   188      * @param aClsItem old cls item where the data is been copied.
       
   189      *
       
   190      * @return CESMRClsItem* pointer to the newly created cls item. Pointer is leaved to the
       
   191      *                       cleanupstack as well.
       
   192      */
       
   193     CESMRClsItem* CopyClsItemLC( const CESMRClsItem& aClsItem );
       
   194 
       
   195     /**
       
   196      * Constructs MRU datastore Uri for Mailbox
       
   197      **/
       
   198     void GetMruDatastoreUriFromMailbox( CFSMailBox& aMailbox, HBufC& aUri );
       
   199 
       
   200 private: // Implementation
       
   201     void SetSearchSettingsForPcsMatchObserverL();
       
   202 
       
   203 private: // data
       
   204     // Three pointer array's for different lists
       
   205     RPointerArray<CESMRClsItem>         iMatchingCompleteContacts;
       
   206     RPointerArray<CESMRClsItem>         iMatchingMRUContacts;
       
   207     RPointerArray<CESMRClsItem>         iMatchingMissingEmailContacts;
       
   208 
       
   209     // owned
       
   210     MDesCArray*                         iAllMRUContacts;    
       
   211 
       
   212     // Pointer to the service instance, owned
       
   213     CPSRequestHandler*                  iRequestHandler; 
       
   214 
       
   215     // Pointer AknFep Central repository,  owned
       
   216     CRepository*                        iAknFepCenRep; 
       
   217 
       
   218     //not owned
       
   219     CVPbkContactManager*                iContactManager;
       
   220     
       
   221     // Pointer to input observer,  owned
       
   222     CESMRInputModeObserver*             iInputObserver; 
       
   223 
       
   224     MESMRClsListsObserver*              iClsListObserver;
       
   225     //owned
       
   226     CESMRClsMatchObserver*              iPcsMatchObserver;
       
   227 
       
   228     // owned
       
   229     HBufC*                              iSearchedText; 
       
   230 
       
   231     // Pointer to actual contact database.
       
   232     RFs&                                iFs;
       
   233 
       
   234     // Reference to current mailbox
       
   235     CFSMailBox*                         iMailBox; 
       
   236 
       
   237     TBool                               iRemoteLookupSupported;
       
   238     };
       
   239 
       
   240 #endif  // CESMRCLSLISTSHANDLER_H
       
   241 
       
   242 // End of File