|
1 /* |
|
2 * Copyright (c) 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: This file defines classes MESMRNcsAddressPopupList, CESMRNcsAifEditor, CESMRNcsAifEntry |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CESMRNCSAIFEDITOR_H |
|
20 #define CESMRNCSAIFEDITOR_H |
|
21 |
|
22 #include "cesmrncseditor.h" |
|
23 |
|
24 class CESMRNcsEmailAddressObject; |
|
25 class CESMRNcsAifEntry; |
|
26 class CESMRContactHandler; |
|
27 |
|
28 /** |
|
29 * MESMRNcsAddressPopupList observer to the contact search pop up list box |
|
30 */ |
|
31 class MESMRNcsAddressPopupList |
|
32 { |
|
33 public: |
|
34 /** |
|
35 * Handle and update serach strings events of the list box |
|
36 * @param aMatchString string to send to the search engines |
|
37 * @param iListAll update all or single entry |
|
38 */ |
|
39 virtual void UpdatePopupContactListL( const TDesC& aMatchString, TBool iListAll ) = 0; |
|
40 |
|
41 /** |
|
42 * Handle closing of popup search box |
|
43 */ |
|
44 virtual void ClosePopupContactListL() = 0; |
|
45 }; |
|
46 |
|
47 /** |
|
48 * CNcsAifEditor handles the editor and arrays of the email address lists for attendee field. |
|
49 */ |
|
50 NONSHARABLE_CLASS( CESMRNcsAifEditor ) : public CESMRNcsEditor, public MEikEdwinObserver |
|
51 { |
|
52 public: // constructors/destructor |
|
53 /** |
|
54 * Two-phased constructor. |
|
55 * Creates a new instance of class |
|
56 * @param aContactHandler reference to contact handler class |
|
57 * @param default text of the editor |
|
58 * @returns CESMRClsItem instance |
|
59 */ |
|
60 CESMRNcsAifEditor( CESMRContactHandler& aContactHandler, HBufC* aDefaultText ); |
|
61 |
|
62 /** |
|
63 * C++ Virtual Destructor. |
|
64 */ |
|
65 virtual ~CESMRNcsAifEditor(); |
|
66 |
|
67 public: // new functions |
|
68 /** |
|
69 * Count number of lines of the editor |
|
70 * @return number of lines of the editor |
|
71 */ |
|
72 virtual TInt LineCount() const; |
|
73 |
|
74 /** |
|
75 * Get number of the current line of the editor |
|
76 * @return current line number of the editor |
|
77 */ |
|
78 virtual TInt CursorLineNumber() const; |
|
79 |
|
80 public: // from CoeControl |
|
81 TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType ); |
|
82 |
|
83 public: // Interface |
|
84 /** |
|
85 * Parse new address when focus is lost |
|
86 */ |
|
87 void CheckAddressWhenFocusLostL(); |
|
88 |
|
89 /** |
|
90 * Parse new address |
|
91 * @return ETrue if there was any text available |
|
92 */ |
|
93 TBool ParseNewAddressL(); |
|
94 |
|
95 /** |
|
96 * Handle the key event to delete a contact in the editor |
|
97 * @param aKeyEvent key event to be handled |
|
98 * @param aType TKeyEvent TEventCode type to be handled |
|
99 */ |
|
100 TKeyResponse HandleContactDeletionL(const TKeyEvent& aKeyEvent, TEventCode aType); |
|
101 |
|
102 const CESMRNcsEmailAddressObject* EmailAddressObjectBySelection() const; |
|
103 |
|
104 /** |
|
105 * Add address to the editor the editor |
|
106 * @param aDN Descriptor of the address |
|
107 * @param aEmail email descriptor (address) |
|
108 * @param aDisplayFull choose to display the description fully |
|
109 */ |
|
110 void AddAddressL( const TDesC& aDN, const TDesC& aEmail, TBool aDisplayFull = EFalse ); |
|
111 |
|
112 /** |
|
113 * Add address to the editor the editor |
|
114 * @param email address object to display in thye editor |
|
115 */ |
|
116 void AddAddressL(const CESMRNcsEmailAddressObject& aAddress); |
|
117 |
|
118 /** |
|
119 * Get the text to match in either the local address book |
|
120 * or the remote directory server |
|
121 * @param descriptor of the current search text |
|
122 */ |
|
123 HBufC* GetLookupTextLC() const; |
|
124 |
|
125 /** |
|
126 * Reset and fill the editor with CESMRNcsEmailAddressObjects |
|
127 * @param aAddress array of CESMRNcsEmailAddressObjects |
|
128 */ |
|
129 void SetAddressesL( const RPointerArray<CESMRNcsEmailAddressObject>& aAddress ); |
|
130 |
|
131 /** |
|
132 * Append the editor with CESMRNcsEmailAddressObjects |
|
133 * @param aAddress array of CESMRNcsEmailAddressObjects |
|
134 */ |
|
135 void AppendAddressesL( const RPointerArray<CESMRNcsEmailAddressObject>& aAddress ); |
|
136 |
|
137 /** |
|
138 * Get currently available array of CESMRNcsEmailAddressObjects |
|
139 * @return currently available array of CESMRNcsEmailAddressObjects |
|
140 */ |
|
141 const RPointerArray<CESMRNcsEmailAddressObject>& GetAddressesL(); |
|
142 |
|
143 /** |
|
144 * Find out where address objects can be added |
|
145 */ |
|
146 void RecalculateEntryPositions(); |
|
147 |
|
148 /** |
|
149 * Update all editors address list arrays |
|
150 */ |
|
151 void UpdateAddressListAllL(); |
|
152 |
|
153 /** |
|
154 * Set array of the popup list |
|
155 * @param aPopupList array of the aPopupList |
|
156 */ |
|
157 inline void SetPopupList(MESMRNcsAddressPopupList* aPopupList); |
|
158 |
|
159 public: // From MEikEdwinObserver |
|
160 void HandleEdwinEventL(CEikEdwin* aEdwin, TEdwinEvent aEventType); |
|
161 |
|
162 private: // Implementation |
|
163 enum TEntryDirection |
|
164 { |
|
165 EDirectionNone, |
|
166 EDirectionRight, |
|
167 EDirectionLeft |
|
168 }; |
|
169 |
|
170 /** |
|
171 * Creates formatted address list of given entries. |
|
172 * and leave it on the cleanupstack |
|
173 * |
|
174 * @param aEntries Entries from which list is constructed. |
|
175 * @param aDisplayList If ETrue, constructs list of display names |
|
176 * of the addresses. If EFalse, constructs list |
|
177 * of email addresses. |
|
178 */ |
|
179 HBufC* GetFormattedAddressListLC( |
|
180 RPointerArray<CESMRNcsAifEntry>& aEntries, |
|
181 TBool aDisplayList = ETrue ) const; |
|
182 |
|
183 /** |
|
184 * Creates formatted address list of given entries. |
|
185 * |
|
186 * @param aEntries Entries from which list is constructed. |
|
187 * @param aDisplayList If ETrue, constructs list of display names |
|
188 * of the addresses. If EFalse, constructs list |
|
189 * of email addresses. |
|
190 */ |
|
191 HBufC* GetFormattedAddressListL( |
|
192 RPointerArray<CESMRNcsAifEntry>& aEntries, |
|
193 TBool aDisplayList = ETrue ) const; |
|
194 |
|
195 TInt CalculateAddressListLength( |
|
196 RPointerArray<CESMRNcsAifEntry>& aEntries, |
|
197 TBool aDisplayList = ETrue ) const; |
|
198 |
|
199 void RepositionEntriesL( const CESMRNcsAifEntry* aEntry ); |
|
200 CESMRNcsAifEntry* GetEntryAt( TInt aPos, TEntryDirection aDirection = EDirectionNone ) const; |
|
201 HBufC* GetNonEntryTextLC() const; |
|
202 void UpdateAddressAutoCompletionL(); |
|
203 void UpdateAddressAutoCompletionL(const TCursorSelection& aSelection ); |
|
204 void UpdateDuplicateEntryMarkings(); |
|
205 void DoCharChangeL(); |
|
206 TChar CharAtPos( TInt aPos ) const; |
|
207 void AddAddressL( CESMRNcsAifEntry* aEntry ); |
|
208 TKeyResponse SetEditorSelectionL( const TKeyEvent& aKeyEvent, TEventCode aType ); |
|
209 TKeyResponse CopyEntriesToClipboardL( const TKeyEvent& aKeyEvent, TEventCode aType ); |
|
210 void FindSelectedEntriesL( RPointerArray<CESMRNcsAifEntry>& aEntries ); |
|
211 void CopyToClipboardL( const TDesC &aBuf ); |
|
212 void HandleContactDeletionL(); |
|
213 void HandleTextUpdateL(); |
|
214 void HandleTextUpdateL( TCursorSelection& aSelection ); |
|
215 void HandleNavigationEventL(); |
|
216 TCursorSelection NonEntryTextAtPos( TUint aPosition ) const; |
|
217 TCursorSelection NonEntryTextBeforePos( TUint aPosition ) const; |
|
218 TBool IsSentinel( TChar aCharacter ) const; |
|
219 TBool IsNavigationKey( const TKeyEvent& aKeyEvent ) const; |
|
220 void AddEntryL( TInt aFirstCharacter, TInt aLastCharacter ); |
|
221 |
|
222 private: // data |
|
223 RPointerArray<CESMRNcsAifEntry> iArray; |
|
224 RPointerArray<CESMRNcsEmailAddressObject> iAddressArray; |
|
225 MESMRNcsAddressPopupList* iAddressPopupList; |
|
226 CESMRContactHandler& iContactHandler; |
|
227 }; |
|
228 |
|
229 /////////////////////////////////////////////////////////////////////// |
|
230 // CESMRNcsAifEntry |
|
231 // This class represents a full entry in the AIF field. |
|
232 // It is derived from TCursorSelection which helps in atomizing the |
|
233 // items when the cursor moves over them. |
|
234 // NOTES: |
|
235 // iAnchorPosition is non-inclusive. This position represents |
|
236 // the anchor of a selection and is not included in the selection |
|
237 // count. So the selection would be iCursorPosition to iAnchorPosition |
|
238 // - 1. The SetSelection function will highlight anything left of the |
|
239 // anchor up to and including the cursor. |
|
240 // The idea is that if you were to use shift-cursor to select text, |
|
241 // The anchor would be the cursor you started to hold down the shift. |
|
242 // Since this location is not included in the selection, but rather |
|
243 // the first position left or right of this poistion, the anchor is |
|
244 // never included in the selection. |
|
245 class CESMRNcsAifEntry : public CBase, public TCursorSelection |
|
246 { |
|
247 public: |
|
248 /** |
|
249 * Two-phased constructor. |
|
250 * Creates a new instance of class CESMRNcsAifEntry |
|
251 * @addr aContactHandler reference to contact handler class |
|
252 * @aDisplayFull default text of the editor |
|
253 * @returns Pointer to CESMRNcsAifEntry |
|
254 */ |
|
255 static CESMRNcsAifEntry* CESMRNcsAifEntry::NewL( |
|
256 const CESMRNcsEmailAddressObject& addr, |
|
257 TBool aDisplayFull ); |
|
258 |
|
259 static CESMRNcsAifEntry* CESMRNcsAifEntry::NewL( |
|
260 const TDesC& dn, |
|
261 const TDesC& eml, |
|
262 TBool aDisplayFull ); |
|
263 |
|
264 /** |
|
265 * C++ Virtual Destructor. |
|
266 */ |
|
267 CESMRNcsAifEntry::~CESMRNcsAifEntry(); |
|
268 |
|
269 public: |
|
270 /** |
|
271 * Count number of characters of the entry |
|
272 * @return number of characters of the entry |
|
273 */ |
|
274 inline TInt DisplayLength() const; |
|
275 |
|
276 /** |
|
277 * Get the entry display string |
|
278 * @return descriptor containing the display string |
|
279 */ |
|
280 inline const TDesC& DisplayString() const; |
|
281 |
|
282 /** |
|
283 * Setters and getters of the intry |
|
284 */ |
|
285 inline TInt SetPos(int pos); |
|
286 inline TBool Includes(int pos) const; |
|
287 inline TInt Start() const; |
|
288 inline TInt End() const; |
|
289 |
|
290 /** |
|
291 * Get the CESMRNcsEmailAddressObject of this entry |
|
292 * @return the CESMRNcsEmailAddressObject of the entry |
|
293 */ |
|
294 inline const CESMRNcsEmailAddressObject& Address() const; |
|
295 |
|
296 /** |
|
297 * Test if entry has the same description |
|
298 */ |
|
299 inline TBool IsSameDN(const CESMRNcsAifEntry& entry) const; |
|
300 |
|
301 /** |
|
302 * Test for duplicates |
|
303 */ |
|
304 inline TBool IsDup() const; |
|
305 |
|
306 /** |
|
307 * Set entry as a duplicate |
|
308 */ |
|
309 inline void SetDup( TBool aDup = ETrue ); |
|
310 |
|
311 private: // Implementation |
|
312 CESMRNcsAifEntry( TBool aDisplayFull = EFalse ); |
|
313 void ConstructL( const TDesC& dn, const TDesC& eml ); |
|
314 void ConstructL( const CESMRNcsEmailAddressObject& aAddress ); |
|
315 void ConstructL() ; |
|
316 void SetDisplayStringL(); |
|
317 |
|
318 private: // data |
|
319 CESMRNcsEmailAddressObject* iAddress; //own |
|
320 HBufC* iDisplayString; //own |
|
321 // flag indicating that both name and email address should be shown |
|
322 // there is many reasons why this is wanted, for example when |
|
323 // contact has multiple email addresses |
|
324 TBool iDisplayFull; |
|
325 TBool iIsDup; |
|
326 }; |
|
327 |
|
328 #include "cesmrncsaifeditor.inl" |
|
329 |
|
330 #endif // CESMRNCSAIFEDITOR_H |
|
331 |
|
332 // End of File |