|
1 /* |
|
2 * Copyright (c) 2008 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: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CMIDEDWINUTILS_H |
|
20 #define CMIDEDWINUTILS_H |
|
21 |
|
22 #include <coecntrl.h> |
|
23 #include <lcdui.h> |
|
24 #include <eikedwin.h> |
|
25 #include <coemain.h> |
|
26 |
|
27 #include <AknQueryDialog.h> // CAknQueryDialog |
|
28 #include <txtglobl.h> // CGlobalText |
|
29 #include <ConeResLoader.h> // RConeResourceLoader |
|
30 |
|
31 //phonebook2 |
|
32 #include <MVPbkContactStore.h> |
|
33 #include <MVPbkContactStoreListObserver.h> |
|
34 #include <MVPbkSingleContactOperationObserver.h> |
|
35 |
|
36 //aiw api for phonebook2 |
|
37 #include <AiwServiceHandler.h> |
|
38 |
|
39 #include "CMIDUtils.h" |
|
40 |
|
41 // FORWARD DECLARATIONS |
|
42 class CMIDAiwPbk2Client; |
|
43 class CVPbkContactManager; |
|
44 |
|
45 |
|
46 /** The character displayed in password editors */ |
|
47 #define KPasswordEchoChar '*' |
|
48 #define KInputModesRequiringFeedbackWithSingleChar (EAknEditorTextInputMode | EAknEditorKatakanaInputMode | EAknEditorFullWidthTextInputMode | EAknEditorFullWidthKatakanaInputMode | EAknEditorHiraganaKanjiInputMode | EAknEditorHiraganaInputMode | EAknEditorHalfWidthTextInputMode) |
|
49 #define KInputModesRequiringFeedbackWithString (EAknEditorHiraganaInputMode | EAknEditorHiraganaKanjiInputMode) |
|
50 |
|
51 /** Special keys definition */ |
|
52 const TInt KKeyQwerty0 = 0x30; |
|
53 const TInt KKeyQwerty9 = 0x39; |
|
54 const TInt KMidpKeyNkpAsteriskHW = 0x2A; |
|
55 |
|
56 /** In multi-tap mode, show character before hiding it with KPasswordEchoChar |
|
57 for this amount of time */ |
|
58 const TInt KPasswordCharTimeout = 700000; // 700 msecs |
|
59 // used in numeric mode |
|
60 _LIT(KMinusChar, "-"); |
|
61 // used in decimal mode |
|
62 _LIT(KFullStopChar, "."); |
|
63 |
|
64 // New line character |
|
65 _LIT(KLineSeparator, "\x2029"); |
|
66 |
|
67 // Null title character, because setting null title to query dialog does nothing. |
|
68 _LIT(KNullTitle, " "); |
|
69 |
|
70 // character subsets for SetInitialInputModeL |
|
71 _LIT(KUcbBasicLatin, "UCB_BASIC_LATIN"); |
|
72 _LIT(KIsLatin, "IS_LATIN"); |
|
73 _LIT(KIsLatinDigits, "IS_LATIN_DIGITS"); |
|
74 _LIT(KMidpUppercaseLatin, "MIDP_UPPERCASE_LATIN"); |
|
75 _LIT(KMidpLowercaseLatin, "MIDP_LOWERCASE_LATIN"); |
|
76 |
|
77 _LIT(KUcbArabic, "UCB_ARABIC"); |
|
78 _LIT(KUcbHebrew, "UCB_HEBREW"); |
|
79 _LIT(KUcbGreek, "UCB_GREEK"); |
|
80 _LIT(KUcbCyrillic, "UCB_CYRILLIC"); // Russian etc. |
|
81 _LIT(KUcbThai, "UCB_THAI"); |
|
82 _LIT(KUcbDevanagari, "UCB_DEVANAGARI"); // Hindi and Marathi |
|
83 _LIT(KIsSimplifiedHanzi, "IS_SIMPLIFIED_HANZI"); // Simplified Chinese |
|
84 _LIT(KIsTraditionalHanzi, "IS_TRADITIONAL_HANZI"); // Traditional Chinese (Taiwan, Hongkong) |
|
85 |
|
86 _LIT(KUcbHiragana, "UCB_HIRAGANA"); |
|
87 _LIT(KUcbKatakana, "UCB_KATAKANA"); |
|
88 _LIT(KIsHalfwidthKatakana, "IS_HALFWIDTH_KATAKANA"); |
|
89 _LIT(KIsKanji, "IS_KANJI"); |
|
90 _LIT(KIsFullwidthDigits, "IS_FULLWIDTH_DIGITS"); |
|
91 _LIT(KIsFullwidthLatin, "IS_FULLWIDTH_LATIN"); |
|
92 |
|
93 _LIT(KXNokiaVietnamese, "X_NOKIA_VIETNAMESE"); |
|
94 _LIT(KXNokiaUrdu, "X_NOKIA_URDU"); |
|
95 _LIT(KXNokiaFarsi, "X_NOKIA_FARSI"); |
|
96 |
|
97 // Character subsets that contain more than one S60 language |
|
98 enum |
|
99 { |
|
100 EMidpCharSubsetNone= 0, |
|
101 EMidpIsLatin, // "IS_LATIN" |
|
102 EMidpUcbCyrillic, // "UCB_CYRILLIC" |
|
103 EMidpUcbArabic, // "UCB_ARABIC" |
|
104 EMidpUcbDevanagari, // "UCB_DEVANAGARI" |
|
105 EMidpIsTraditionalHanzi // "IS_TRADITIONAL_HANZI" |
|
106 }; |
|
107 |
|
108 // TextBox and TextField utils |
|
109 // |
|
110 |
|
111 NONSHARABLE_CLASS(CMIDEdwinUtils) : public CBase |
|
112 { |
|
113 public: |
|
114 |
|
115 /** IDs for non-midlet commands of the TextBox/Field |
|
116 It is important that these are negative and unique. |
|
117 Therefore if another control needs to add non-midlet cmds |
|
118 the ids should be different than these. |
|
119 */ |
|
120 enum |
|
121 { |
|
122 EMenuCommandFetchPhoneNumber = -1, |
|
123 EMenuCommandFetchEmailAddress = -2, |
|
124 EMenuCommandCreatePhoneCall = -3 |
|
125 }; |
|
126 |
|
127 static CMIDEdwinUtils* NewL(MMIDTextBox* aTextBox, const TChar aDecimalSeparator); |
|
128 |
|
129 private: |
|
130 CMIDEdwinUtils(MMIDTextBox* aTextBox, const TChar aDecimalSeparator); |
|
131 void ConstructL(); |
|
132 |
|
133 public: |
|
134 TBool ConstraintsValidForText(const TDesC& aText, TUint aConstraints, TBool aStrict); |
|
135 TBool ConstraintsValidForInsertedTextL(const TDesC& aText, const TDesC& aTextToInsert, |
|
136 TInt aPos, TUint aConstraints, TBool aStrict); |
|
137 void RemoveNonPhoneNumberChars(HBufC* buf); |
|
138 |
|
139 TBool IsHotKeyL(const TKeyEvent& aKeyEvent, CCoeEnv* aCoeEnv); |
|
140 TBool IsNavigationKey(const TKeyEvent& aKeyEvent); |
|
141 TBool IsPhoneNumber(const TDesC& aText); |
|
142 TBool IsNumeric(const TDesC& aText); |
|
143 TBool IsNumeric(const TChar& aChar); |
|
144 TBool IsJavaInteger(const TDesC& aText); |
|
145 TBool IsTextValid(const TDesC& aText); |
|
146 TBool IsValidChar(TInt aChar) const; |
|
147 TBool IsDecimal(const TDesC& aText, const TChar aDecimalSeparator); |
|
148 TBool IsJavaFloatingPointLiteral(const TDesC& aText); |
|
149 HBufC* ConvertToLocalizedLC(const TDesC& aText, TUint aConstraints); |
|
150 HBufC* ConvertToLocalizedDecimalLC(const TDesC& aText); |
|
151 void ConvertFromLocalizedDecimal(HBufC* buf); |
|
152 TLanguage SelectLanguage(TInt aCharSubset, TLanguage aDefaultLanguage); |
|
153 TBool IsLanguageInCharSubset(TLanguage aLanguage, TInt aCharSubset); |
|
154 |
|
155 /** |
|
156 * Determines if languge conversion for numbers is needed based |
|
157 * on constraints, language settings, display language setting |
|
158 * and general setting. |
|
159 * @returns ETrue to indicate whether digit conversions need to be used. |
|
160 * @returns EFalse to indicate that no conversion is needed. |
|
161 */ |
|
162 TBool IsNumberConversionNeeded(TInt aConstraints); |
|
163 |
|
164 /** |
|
165 * Opens phone call dialog |
|
166 */ |
|
167 void CreatePhoneCallL(TInt aTextLength, RWsSession aWsSession, CEikEdwin* aEdwin); |
|
168 |
|
169 void SetInitialInputModeL(const TDesC& aCharacterSubset, TUint iConstraints, TInt& aInitialCurrentCase, |
|
170 TInt& aInitialCurrentInputMode, TLanguage& aInitialCurrentLanguage); |
|
171 |
|
172 void SetFEPModeAndCharFormat(TUint aConstraints, CEikEdwin* aEdwin); |
|
173 |
|
174 /** |
|
175 * Removes line and paragraph breaks from the text. |
|
176 * |
|
177 * @param aText The text to be checked. |
|
178 * @since S60 5.0 |
|
179 */ |
|
180 void CropToSingleLine(TDes& aText); |
|
181 |
|
182 /** |
|
183 * Converts the line breaks in the given text to |
|
184 * unicode breaks. |
|
185 * |
|
186 * @param aText The text to be converted. |
|
187 * @since S60 5.0 |
|
188 */ |
|
189 void ConvertToUnicodeBreaks(TDes& aText); |
|
190 |
|
191 private: |
|
192 MMIDTextBox* iTextBox; |
|
193 TChar iDecimalSeparator; |
|
194 }; |
|
195 |
|
196 /** class CPasswordBoxGlobalText |
|
197 The purpose of this class is to implement a secret editor by |
|
198 replacing the text with '*'. The clear text is stored in this |
|
199 class instead. It would have been nicer to user CEikSecretEditor |
|
200 but the design of CMIDEdwin (which is a CEikEdwin) does not |
|
201 allow this option. |
|
202 |
|
203 We override CGlobalText methods dealing with text insertion |
|
204 and deletion to make sure our clear text, stored in iClearText, |
|
205 is always in sync with what the user types. We insert '*' in the |
|
206 edwin by using the CGlobalText methods appropriately. We use a timer |
|
207 to show a temporary clear character when in alpha input mode. |
|
208 |
|
209 */ |
|
210 NONSHARABLE_CLASS(CPasswordBoxGlobalText) : public CGlobalText |
|
211 { |
|
212 public: |
|
213 CPasswordBoxGlobalText(const CParaFormatLayer* aGlobalParaLayer, |
|
214 const CCharFormatLayer* aGlobalCharLayer,CEikEdwin& aTextComponent); |
|
215 void ConstructL(); |
|
216 ~CPasswordBoxGlobalText(); |
|
217 |
|
218 public: // Methods overwritten from CGlobalText |
|
219 void Reset(); |
|
220 void InsertL(TInt aPos,const TChar& aChar); |
|
221 void InsertL(TInt aPos,const TDesC& aBuf); |
|
222 TBool DeleteL(TInt aPos,TInt aLength); |
|
223 TInt PasteFromStoreL(const CStreamStore& aStore,const CStreamDictionary& aDictionary,TInt aPos); |
|
224 |
|
225 void Extract(TDes& aBuf,TInt aPos=0) const; |
|
226 void Extract(TDes& aBuf,TInt aPos,TInt aLength) const; |
|
227 |
|
228 public: //Public API to text box |
|
229 TPtrC ClearText() const |
|
230 { |
|
231 return *iClearText; |
|
232 } |
|
233 void RejectNextKey(TBool aReject) |
|
234 { |
|
235 iRejectNextKey = aReject; |
|
236 } |
|
237 |
|
238 private: // Implementation helpers |
|
239 void SaveClearTextL(TInt aPos,const TDesC& aBuf); |
|
240 |
|
241 static TInt TimerCallback(TAny* aThis); |
|
242 void DoTimerCallbackL(TBool aNotifyFormat); |
|
243 |
|
244 |
|
245 private: |
|
246 /** A reference to the text editor that owns us*/ |
|
247 CEikEdwin& iTextComponent; |
|
248 |
|
249 /** The position of the temporary clear character */ |
|
250 TInt iClearCharPos; |
|
251 |
|
252 /** The clear text */ |
|
253 HBufC* iClearText; |
|
254 |
|
255 /** The timer used to show the temporary clear character */ |
|
256 CPeriodic* iTimer; |
|
257 |
|
258 /** This flag is set to true when the editor will reject the next key, e.g. Enter key */ |
|
259 TBool iRejectNextKey; |
|
260 }; |
|
261 |
|
262 |
|
263 // class CCallConfirmationDialog |
|
264 |
|
265 NONSHARABLE_CLASS(CCallConfirmationDialog) : public CAknQueryDialog |
|
266 { |
|
267 public: |
|
268 static CCallConfirmationDialog* NewL(const TDesC& aNumber, |
|
269 const TTone& aTone = ENoTone); |
|
270 ~CCallConfirmationDialog(); |
|
271 protected: // from CAknQueryDialog |
|
272 TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType); |
|
273 TBool OkToExitL(TInt aButtonId); |
|
274 TInt MappedCommandId(TInt aButtonId); |
|
275 private: |
|
276 CCallConfirmationDialog(const TTone aTone); |
|
277 void ConstructL(const TDesC& aNumber); |
|
278 private: |
|
279 RConeResourceLoader iResources; |
|
280 }; |
|
281 |
|
282 /** |
|
283 * class CMIDAiwPbk2Client |
|
284 * This class allows fetching of email/phonenumber into Edwin. |
|
285 * It's needed for textbox/field when constraints are set to EMAILADDR/PHONENUMBER |
|
286 */ |
|
287 NONSHARABLE_CLASS(CMIDAiwPbk2Client) : public CBase, public MVPbkContactStoreListObserver, |
|
288 public MAiwNotifyCallback, public MVPbkSingleContactOperationObserver |
|
289 { |
|
290 public: |
|
291 static CMIDAiwPbk2Client* NewL(MMIDTextBox& aEdwin); |
|
292 ~CMIDAiwPbk2Client(); |
|
293 void FetchFromPhoneBookL(TInt aCmdId); |
|
294 |
|
295 private: |
|
296 void ConstructL(); |
|
297 CMIDAiwPbk2Client(MMIDTextBox& aEdwin); |
|
298 |
|
299 void OpenCompleteL(); |
|
300 |
|
301 //from ContactStoreListObserver |
|
302 void StoreReady(MVPbkContactStore&); |
|
303 void StoreUnavailable(MVPbkContactStore& , TInt); |
|
304 void HandleStoreEventL(MVPbkContactStore&, TVPbkContactStoreEvent); |
|
305 void OpenComplete(); |
|
306 |
|
307 //from AiwNotifyCallback |
|
308 TInt HandleNotifyL(TInt aCmdId, TInt aEventId, |
|
309 CAiwGenericParamList& aEventParamList, |
|
310 const CAiwGenericParamList&); |
|
311 |
|
312 //from SingleContactOperationObserver |
|
313 void VPbkSingleContactOperationComplete( |
|
314 MVPbkContactOperationBase& aOperation, |
|
315 MVPbkStoreContact* aContact); |
|
316 void VPbkSingleContactOperationFailed( |
|
317 MVPbkContactOperationBase& aOperation, |
|
318 TInt aError); |
|
319 |
|
320 |
|
321 // current contact manager |
|
322 CVPbkContactManager* iContactManager; |
|
323 |
|
324 // contact link to fetched data |
|
325 const MVPbkContactLink* iCurrentLink; |
|
326 |
|
327 // service handler for invoking phonebook dialog |
|
328 CAiwServiceHandler* iServiceHandler; |
|
329 |
|
330 // array of fetched links |
|
331 MVPbkContactLinkArray* iFetchedLinks; |
|
332 |
|
333 // data to fetch, ie. phonenumber or email |
|
334 TInt iCmdId; |
|
335 |
|
336 // a reference to text editor |
|
337 MMIDTextBox& iEdwin; |
|
338 |
|
339 // SingleContactOperation handle |
|
340 MVPbkContactOperationBase* iRetrieveOperation; |
|
341 }; |
|
342 |
|
343 #endif // CMIDEDWINUTILS_H |