emailuis/emailui/inc/ncsaifeditor.h
changeset 0 8466d47a6819
child 1 12c456ceeff2
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: This file defines class CNcsAifEntry.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef CNCSAIFEDITOR_H
       
    21 #define CNCSAIFEDITOR_H
       
    22 
       
    23 
       
    24 #include "ncseditor.h"
       
    25 
       
    26 
       
    27 class CNcsEmailAddressObject;
       
    28 class MNcsAddressPopupList;
       
    29 class CNcsAifEntry;
       
    30 
       
    31 
       
    32 /**
       
    33 *  CNcsAifEditor class.
       
    34 */
       
    35 class CNcsAifEditor: public CNcsEditor, public MEikEdwinObserver
       
    36     {
       
    37 public: // constructors/destructor
       
    38     
       
    39     CNcsAifEditor( MNcsFieldSizeObserver* aSizeObserver );
       
    40     	
       
    41     void ConstructL( const CCoeControl* aParent,
       
    42                      TInt aNumberOfLines,
       
    43                      TInt aTextLimit );    
       
    44 
       
    45     virtual ~CNcsAifEditor();
       
    46     
       
    47 public: // from CoeControl
       
    48     
       
    49     TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType );
       
    50 
       
    51 public: // from MEikEdwinObserver
       
    52     
       
    53     void HandleEdwinEventL(CEikEdwin* aEdwin, TEdwinEvent aEventType);
       
    54 
       
    55 public: // new functions
       
    56     
       
    57     virtual TInt LineCount() const;
       
    58         
       
    59     virtual TInt CursorLineNumber() const;
       
    60         
       
    61     void UpdateAddressListAllL();
       
    62 
       
    63     void CopyToStoreL(
       
    64         CStreamStore& aStore, 
       
    65         CStreamDictionary& aDict );
       
    66         
       
    67     void CheckAddressWhenFocusLostL();
       
    68 
       
    69     void ParseNewAddressL();
       
    70     
       
    71     TKeyResponse HandleContactDeletionL(const TKeyEvent& aKeyEvent, TEventCode aType);
       
    72     
       
    73     const CNcsEmailAddressObject* EmailAddressObjectBySelection() const;
       
    74 
       
    75     /**
       
    76     * Get the text to match in either the local address book
       
    77     * or the remote directory server
       
    78     */
       
    79     HBufC* GetLookupTextLC() const;
       
    80 
       
    81     void AddAddressL(
       
    82         const TDesC& aDN, 
       
    83         const TDesC& aEmail,
       
    84         TBool aDisplayFull = EFalse,
       
    85         TBool aUpdateEditorText = ETrue );
       
    86 		
       
    87     void AddAddressL( const CNcsEmailAddressObject& aAddress, TBool aUpdateEditorText = ETrue );
       
    88 
       
    89     void SetAddressesL( const RPointerArray<CNcsEmailAddressObject>& aAddress );
       
    90 
       
    91     void AppendAddressesL( const RPointerArray<CNcsEmailAddressObject>& aAddress );
       
    92 		
       
    93     const RPointerArray<CNcsEmailAddressObject>& GetAddressesL();
       
    94 		
       
    95     void RecalculateEntryPositions();
       
    96 
       
    97     inline void SetPopupList(MNcsAddressPopupList* aPopupList);
       
    98     
       
    99 private: // new functions
       
   100 
       
   101     enum TEntryDirection
       
   102         {
       
   103         EDirectionNone,
       
   104         EDirectionRight,
       
   105         EDirectionLeft
       
   106         };
       
   107 
       
   108     void UpdateAddressAutoCompletionL();
       
   109     void UpdateAddressAutoCompletionL( const TCursorSelection& aSelection );
       
   110 
       
   111     void DoCharChangeL();
       
   112 
       
   113     TChar CharAtPos( TInt aPos ) const;
       
   114 
       
   115     void AddAddressL( CNcsAifEntry* aEntry, TBool aUpdateEditorText );
       
   116 
       
   117     TKeyResponse SetEditorSelectionL( const TKeyEvent& aKeyEvent, TEventCode aType );
       
   118 
       
   119     TInt CalculateAddressListLength(
       
   120         RPointerArray<CNcsAifEntry>& aEntries,
       
   121         TBool aDisplayList = ETrue ) const;
       
   122 
       
   123     /**
       
   124     * Creates formatted address list of given entries.
       
   125     *
       
   126     * @param aEntries Entries from which list is constructed.
       
   127     * @param aDisplayList If ETrue, constructs list of display names
       
   128     *                     of the addresses. If EFalse, constructs list
       
   129     *                     of email addresses.
       
   130     */
       
   131     HBufC* GetFormattedAddressListLC( 
       
   132         RPointerArray<CNcsAifEntry>& aEntries,
       
   133         TBool aDisplayList = ETrue ) const;
       
   134 
       
   135     HBufC* GetFormattedAddressListL(
       
   136         RPointerArray<CNcsAifEntry>& aEntries,
       
   137         TBool aDisplayList = ETrue ) const;
       
   138 
       
   139     void RepositionEntriesL( const CNcsAifEntry* aEntry );
       
   140 
       
   141     void CheckAndRemoveInvalidEntriesL();
       
   142     
       
   143     CNcsAifEntry* GetEntryAt( 
       
   144         TInt aPos, 
       
   145         TEntryDirection aDirection = EDirectionNone ) const;
       
   146     
       
   147     /** Browse backwards from given position and return the first found entry */
       
   148     CNcsAifEntry* GetPreviousEntryFrom( TInt aPos ) const;
       
   149     
       
   150     HBufC* GetNonEntryTextLC() const;
       
   151 
       
   152     TKeyResponse CopyEntriesToClipboardL(
       
   153         const TKeyEvent& aKeyEvent, 
       
   154         TEventCode aType );
       
   155 
       
   156     void FindSelectedEntriesL( RPointerArray<CNcsAifEntry>& aEntries );
       
   157 
       
   158 	// <cmail> fixed CS high cat. finding
       
   159     void UpdateDuplicateEntryMarkingsL();
       
   160 
       
   161     void HandleTextUpdateDeferred();
       
   162     static TInt DoHandleTextUpdate( TAny* aSelf );
       
   163     
       
   164     void HandleTextUpdateL();
       
   165     /** 
       
   166      * Handle addition of complete address. May result in complete redraw of the field.
       
   167      * @return  ETrue   if terminated recipient entry was found and added to array. 
       
   168      */
       
   169     TBool HandleTextUpdateL( const TCursorSelection& aSelection );
       
   170     void HandleNavigationEventL();
       
   171     TCursorSelection NonEntryTextAtPos( TUint aPosition ) const;
       
   172     TCursorSelection NonEntryTextBeforePos( TUint aPosition ) const;
       
   173     TBool IsSentinel( TChar aCharacter ) const;
       
   174     TBool IsWhitespace( TChar aCharacter ) const;
       
   175     TBool IsNavigationKey( const TKeyEvent& aKeyEvent ) const;
       
   176     TBool IsCharacterKey( const TKeyEvent& aKeyEvent ) const;
       
   177     void GetMatchingEntryCountsL( 
       
   178             const CNcsAifEntry* aEntry,
       
   179             TInt& aNrOfMatchesInText,
       
   180             TInt& aNrOfMatchesInEntryArray );
       
   181     
       
   182 private: // data
       
   183 
       
   184     RPointerArray<CNcsAifEntry> iArray;
       
   185 
       
   186     RPointerArray<CNcsEmailAddressObject> iAddressArray;
       
   187 		
       
   188     MNcsAddressPopupList* iAddressPopupList;
       
   189 	
       
   190     CAsyncCallBack* iAsyncCallBack;
       
   191 
       
   192     TInt iLastTimeCursorPos;
       
   193     
       
   194     // Flag indicating whether add the leftover text to the end of the field
       
   195     TBool iAddLeftover;
       
   196 	};
       
   197 
       
   198 
       
   199 ///////////////////////////////////////////////////////////////////////
       
   200 // CNcsAifEntry
       
   201 // This class represents a full entry in the AIF field.
       
   202 // It is derived from TCursorSelection which helps in atomizing the
       
   203 // items when the cursor moves over them.
       
   204 // NOTES:
       
   205 //		iAnchorPosition is non-inclusive.  This position represents
       
   206 //		the anchor of a selection and is not included in the selection
       
   207 //		count.  So the selection would be iCursorPosition to iAnchorPosition
       
   208 //		- 1.  The SetSelection function will highlight anything left of the
       
   209 //		anchor up to and including the cursor.
       
   210 //		The idea is that if you were to use shift-cursor to select text,
       
   211 //		The anchor would be the cursor you started to hold down the shift.
       
   212 //		Since this location is not included in the selection, but rather
       
   213 //		the first position left or right of this poistion, the anchor is
       
   214 //		never included in the selection.
       
   215 class CNcsAifEntry : public CBase, public TCursorSelection
       
   216     {
       
   217 public:
       
   218 
       
   219     static CNcsAifEntry* CNcsAifEntry::NewL( const CNcsEmailAddressObject& aAddr );
       
   220 	
       
   221 	static CNcsAifEntry* CNcsAifEntry::NewL(
       
   222         const TDesC& aDn, 
       
   223         const TDesC& aEml,
       
   224         TBool aDisplayFull );
       
   225 		
       
   226 	CNcsAifEntry::~CNcsAifEntry();
       
   227 	
       
   228 private:
       
   229 
       
   230 	CNcsAifEntry();
       
   231 		
       
   232 	void ConstructL( const TDesC& aDn, const TDesC& aEml, TBool aDisplayFull );
       
   233 		
       
   234 	void ConstructL( const CNcsEmailAddressObject& aAddress );
       
   235 		
       
   236 	void ConstructL() ;
       
   237 		
       
   238 	void SetDisplayStringL(); 
       
   239 		
       
   240 public:
       
   241 
       
   242 	inline TInt DisplayLength() const;
       
   243 		
       
   244 	inline const TDesC& DisplayString() const;
       
   245 		
       
   246 	inline TInt SetPos(TInt aPos);
       
   247 	
       
   248 	inline TBool Includes(TInt aPos) const;
       
   249 	
       
   250 	inline TInt Start() const;
       
   251 		
       
   252 	inline TInt End() const;
       
   253 		
       
   254 	inline const CNcsEmailAddressObject& Address() const;
       
   255 		
       
   256 	inline TBool IsDup() const; 
       
   257 	
       
   258 	void SetDupL( TBool aDup = ETrue );
       
   259 		
       
   260     TBool IsSameDN(const CNcsAifEntry& aEntry) const;
       
   261 		
       
   262 private:
       
   263 
       
   264 	CNcsEmailAddressObject* iAddress;
       
   265 	HBufC* iDisplayString;
       
   266 	
       
   267     TBool iIsDup;
       
   268     };
       
   269 
       
   270 #include "ncsaifeditor.inl"
       
   271 
       
   272 #endif // CNCSSUBJECTFIELD_H
       
   273 
       
   274 
       
   275 // End of File