1 /* |
|
2 * Copyright (c) 2005-2006 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: Shortcut definition parser. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef TAISCUTPARSER_H |
|
20 #define TAISCUTPARSER_H |
|
21 #include <uri16.h> // For TUriParser16 |
|
22 #include <AknsItemID.h> |
|
23 |
|
24 // ============================================================================= |
|
25 // ========================= Supported URI schemes ============================= |
|
26 /** URI scheme for local application shortcuts */ |
|
27 _LIT( KScutURISchemeLocalApp, "localapp" ); |
|
28 |
|
29 /** URI sheme for normal web addresses */ |
|
30 _LIT( KScutURISchemeHttp, "http" ); |
|
31 /** URI sheme for secure web addresses */ |
|
32 _LIT( KScutURISchemeHttps, "https" ); |
|
33 // ============================================================================= |
|
34 |
|
35 // ============================================================================= |
|
36 // ============= Application shortcut formatting literals ====================== |
|
37 |
|
38 /** Literal to format an application shortcut without parameters */ |
|
39 _LIT( KScutFormatApplication, "localapp:0x%x" ); |
|
40 |
|
41 /** Literal to format an application shortcut with parameter name and value */ |
|
42 _LIT( KScutFormatApplicationWithParams, "localapp:0x%x?%S=%S" ); |
|
43 |
|
44 /** Literal to format an application shortcut with a single parameter string */ |
|
45 _LIT( KScutFormatApplicationWithParamString, "localapp:0x%x?%S" ); |
|
46 |
|
47 // ============================================================================= |
|
48 |
|
49 // ============================================================================= |
|
50 // ============ Shortcut parameter name and value literals ===================== |
|
51 |
|
52 /** Parameter name for view ids */ |
|
53 _LIT( KScutParamNameView, "view" ); |
|
54 |
|
55 /** Parameter name for remote mailboxes. Specific to messaging shortcuts */ |
|
56 _LIT( KScutParamNameMailbox, "mailbox" ); |
|
57 |
|
58 /** Parameter name for new message and new email. Specific to messaging shortcuts */ |
|
59 _LIT( KScutParamNameNew, "new" ); |
|
60 |
|
61 /** Parameter value for new message shortcuts. */ |
|
62 _LIT( KScutParamValueMsg, "msg" ); |
|
63 |
|
64 /** Parameter value for new email shortcuts */ |
|
65 _LIT( KScutParamValueEmail, "email" ); |
|
66 |
|
67 /** Parameter value for new syncml mail shortcuts */ |
|
68 _LIT( KScutParamValueSyncMLMail, "syncmlmail" ); |
|
69 |
|
70 /** Parameter value for new postcard shortcuts */ |
|
71 _LIT( KScutParamValuePostcard, "postcard" ); |
|
72 |
|
73 /** Parameter value for new audio message shortcuts */ |
|
74 _LIT( KScutParamValueAudioMsg, "audiomsg" ); |
|
75 |
|
76 /** Parameter value for the connectivity status view shortcut */ |
|
77 const TUid KScutParamValueConnectivityView = { 0x10207250 }; |
|
78 |
|
79 /** Parameter name for enable keylock */ |
|
80 _LIT( KScutParamNameOn, "on" ); |
|
81 |
|
82 /** Parameter name for missed calls view */ |
|
83 _LIT( KScutParamValueMissedCalls, "missed" ); |
|
84 |
|
85 /** Parameter name for dialled calls view */ |
|
86 _LIT( KScutParamValueDialledCalls, "dialled" ); |
|
87 |
|
88 /** Parameter name for received calls view */ |
|
89 _LIT( KScutParamValueReceivedCalls, "received" ); |
|
90 |
|
91 /** Parameter name for logs main view */ |
|
92 _LIT( KScutParamValueMainView, "counters" ); |
|
93 |
|
94 /** Parameter name for bookmark ids */ |
|
95 _LIT( KScutParamNameBookmark, "bkm" ); |
|
96 |
|
97 /** Parameter name for icon id in skin |
|
98 Format localapp:0xUID?iconid=majorid;minorid;optionalColourGroup */ |
|
99 _LIT( KScutParamNameIconSkinId, "iconid" ); |
|
100 |
|
101 /** Parameter name for icon path. Left here for backward |
|
102 compatibility. |
|
103 Format localapp:0xUID?iconmifpath=mif_file.mif;index */ |
|
104 _LIT( KScutParamNameIconMifPath, "iconmifpath" ); |
|
105 |
|
106 /** Parameter name for icon path. MBM and MIF supported |
|
107 Format localapp:0xUID?iconmifpath=mif_file.mif;index */ |
|
108 _LIT( KScutParamNameIconPath, "iconpath" ); |
|
109 /** Parameter name for custom URL title. |
|
110 Format http://www.url.com?customtitle=Here is my great title */ |
|
111 _LIT( KScutParamNameCustomTitle, "customtitle" ); |
|
112 /** Parameter name for CBA icon |
|
113 Format localapp:0xUID?iconid=majorid;minorid;optionalColourGroup&cba=1 */ |
|
114 _LIT( KScutParamNameCBAIcon, "cba" ); |
|
115 |
|
116 /** Parameter name for toolbar icon */ |
|
117 _LIT( KScutParamNameToolbarIcon, "toolbar" ); |
|
118 |
|
119 /** Shortcut definition parameter for "no effect" */ |
|
120 _LIT( KScutParamNoEffect, "noeffect" ); |
|
121 |
|
122 // ============================================================================= |
|
123 // ============================================================================= |
|
124 // ============ Shortcut parameter name and value literals ===================== |
|
125 |
|
126 /** Alias for messaging shortcuts */ |
|
127 _LIT( KScutTargetAliasMessaging, "msg" ); |
|
128 |
|
129 /** Alias for keylock shortcuts */ |
|
130 _LIT( KScutTargetAliasKeylock, "keylock" ); |
|
131 |
|
132 /** Alias for logs shortcuts */ |
|
133 _LIT( KScutTargetAliasLogs, "logs" ); |
|
134 |
|
135 /** Alias for voice dialer shortcuts */ |
|
136 _LIT( KScutTargetAliasVoiceDial, "voicedial" ); |
|
137 |
|
138 // ============================================================================= |
|
139 /** Maximum length of shortcut definition. Used when composing a definition */ |
|
140 const TInt KMaxDefinitionLength = 100; |
|
141 |
|
142 /** Shortcut parameter value separator character */ |
|
143 const TText KParamValueSeparator = '='; |
|
144 |
|
145 /** Shortcut parameter next param separator */ |
|
146 const TText KParamNextSeparator = '&'; |
|
147 |
|
148 _LIT( KScutMIFExtension, ".mif" ); |
|
149 _LIT( KScutMBMExtension, ".mbm" ); |
|
150 _LIT( KScutSkinItemSeparator, ";" ); |
|
151 |
|
152 /** |
|
153 * Shortcut definition components |
|
154 */ |
|
155 enum TScutDefComponent |
|
156 { |
|
157 EScutDefScheme, |
|
158 EScutDefTarget, |
|
159 EScutDefParamName, |
|
160 EScutDefParamValue, |
|
161 EScutDefParamNameAndValue, |
|
162 EScutDefComplete |
|
163 }; |
|
164 |
|
165 /** |
|
166 * Shortcut types |
|
167 */ |
|
168 enum TShortcutType |
|
169 { |
|
170 EScutUnknown, |
|
171 EScutAnyType = 0, |
|
172 EScutNoEffect, |
|
173 EScutApplication, |
|
174 EScutApplicationView, |
|
175 EScutApplicationWithParams, |
|
176 EScutNewMessage, |
|
177 EScutNewEmail, |
|
178 EScutNewSyncMLMail, |
|
179 EScutNewPostcard, |
|
180 EScutNewAudioMsg, |
|
181 EScutNewMsgType, |
|
182 EScutMailbox, |
|
183 EScutChangeTheme, |
|
184 EScutWebAddress, |
|
185 EScutBookmark, |
|
186 EScutKeylock, |
|
187 EScutLogsMissedCallsView, |
|
188 EScutLogsDialledCallsView, |
|
189 EScutLogsReceivedCallsView, |
|
190 EScutLogsMainView, |
|
191 EScutConnectivityStatusView, |
|
192 EScutApplicationManagerView |
|
193 }; |
|
194 |
|
195 /** |
|
196 * Icon type |
|
197 */ |
|
198 enum TShortcutIconType |
|
199 { |
|
200 EScutIconNone, |
|
201 EScutIconSkin, |
|
202 EScutIconMif, |
|
203 EScutIconMbm |
|
204 }; |
|
205 |
|
206 enum TShortcutIconDestination |
|
207 { |
|
208 EScutDestinationNormal, |
|
209 EScutDestinationSoftkey, |
|
210 EScutDestinationToolbar |
|
211 }; |
|
212 |
|
213 class TAiScutIcon |
|
214 { |
|
215 public: |
|
216 /** |
|
217 * Index of the icon in icon file |
|
218 */ |
|
219 TInt iIconId; |
|
220 |
|
221 /** |
|
222 * Path to the icon file |
|
223 */ |
|
224 TFileName iPath; |
|
225 |
|
226 /** |
|
227 * Skin item id of the icon |
|
228 */ |
|
229 TAknsItemID iSkinId; |
|
230 |
|
231 /** |
|
232 * Colour groups id in skin |
|
233 */ |
|
234 TInt iColourGroup; |
|
235 |
|
236 /** |
|
237 * Type of the icon. From skin or from mif |
|
238 */ |
|
239 TShortcutIconType iType; |
|
240 |
|
241 /** |
|
242 * AppUid that this icon belongs to |
|
243 */ |
|
244 TUid iAppUid; |
|
245 |
|
246 /** |
|
247 * Possible view id |
|
248 */ |
|
249 TUid iViewId; |
|
250 |
|
251 /** |
|
252 * Type of the shortcut |
|
253 */ |
|
254 TShortcutType iShortcutType; |
|
255 |
|
256 /** |
|
257 * Is this CBA specific icon |
|
258 */ |
|
259 TShortcutIconDestination iDestination; |
|
260 |
|
261 }; |
|
262 |
|
263 /** |
|
264 * Shortcuf definition parser |
|
265 * |
|
266 * @since S60 v3.2 |
|
267 */ |
|
268 class TAiScutParser |
|
269 { |
|
270 |
|
271 public: |
|
272 TAiScutParser(); |
|
273 |
|
274 /** |
|
275 * Static utility function to parse an uid from the given descriptor |
|
276 * |
|
277 * @since S60 v3.2 |
|
278 * @param aString The String to parse |
|
279 * @return Parsed application uid |
|
280 */ |
|
281 static TUid ParseUid( const TDesC& aDesC ); |
|
282 |
|
283 /** |
|
284 * Parses a shortcut definition |
|
285 * |
|
286 * @since S60 v3.2 |
|
287 * @param aDefinition Shortcut definition |
|
288 * @return System wide error code. KErrCorrupt if not recognized |
|
289 */ |
|
290 TInt Parse( const TDesC& aDefinition ); |
|
291 |
|
292 /** |
|
293 * Checks if the shortcut definition was valid |
|
294 * |
|
295 * @since S60 v3.2 |
|
296 * @return ETrue if valid, EFalse if not |
|
297 */ |
|
298 TBool IsValid() const; |
|
299 |
|
300 /** |
|
301 * Returns the shortcut target type |
|
302 * |
|
303 * @since S60 v3.2 |
|
304 * @return Shortcut target type |
|
305 */ |
|
306 TShortcutType Type() const; |
|
307 |
|
308 /** |
|
309 * Returns the possible shortcut overriding icon |
|
310 * that has been defined in the URL either with the format |
|
311 * localapp:0xUID?iconid=majorid;minorid;colourgroup |
|
312 * or |
|
313 * localapp:0xUID?iconmifpath=mif_file.mif;index |
|
314 * |
|
315 * @since S60 v3.2 |
|
316 * @return Shortcut icon override |
|
317 */ |
|
318 TAiScutIcon Icon() const; |
|
319 |
|
320 /** |
|
321 * Returns the shortcut target uid. Used for application shortcuts |
|
322 * |
|
323 * @since S60 v3.2 |
|
324 * @return Shortcut target uid |
|
325 */ |
|
326 TUid Uid() const; |
|
327 |
|
328 /** |
|
329 * Returns a shortcut definition component value |
|
330 * |
|
331 * @since S60 v3.2 |
|
332 * @param aComponent Shortcut definition component |
|
333 * @return Pointer descriptor to component value |
|
334 */ |
|
335 TPtrC Get( TScutDefComponent aComponent ) const; |
|
336 |
|
337 /** |
|
338 * Composes a shortcut definition string from given parameters |
|
339 * |
|
340 * @since S60 v3.2 |
|
341 * @param aDes On return, the shortcut definition. Transfers ownership |
|
342 * @param aUid Application uid |
|
343 * @param aParamName Parameter name |
|
344 * @param aParamValue Parameter value |
|
345 */ |
|
346 void ComposeL( HBufC*& aDes, const TUid aUid, |
|
347 const TDesC& aParamName, const TDesC& aParamValue ); |
|
348 |
|
349 /** |
|
350 * Composes a shortcut definition string from given parameters |
|
351 * |
|
352 * @since S60 v3.2 |
|
353 * @param aDes On return, the shortcut definition. Transfers ownership |
|
354 * @param aUid Application uid |
|
355 * @param aParamString Parameter string |
|
356 */ |
|
357 void ComposeL( HBufC*& aDes, const TUid aUid, |
|
358 const TDesC& aParamString ); |
|
359 |
|
360 /** |
|
361 * Creates a checksum for the given aDefinition. This is used |
|
362 * in URL matching so that no string need to be stored. Checksum is |
|
363 * done checksum = positionInString * charValue |
|
364 * |
|
365 * @since S60 v3.2 |
|
366 * @param aDefinition The definition to calculate the checksum from |
|
367 * @return TInt The checksum |
|
368 */ |
|
369 TInt ChecksumForString( const TDesC& aDefinition) const; |
|
370 |
|
371 /** |
|
372 * Removes icon definitions from the given string. Icon definitions are |
|
373 * KScutParamNameIconSkinId, KScutParamNameIconSkinPath, KScutParamNameCBAIcon |
|
374 * KScutParamNameCustomTitle |
|
375 * |
|
376 * @since S60 v3.2 |
|
377 */ |
|
378 void RemoveExtraDefinitionsL( TDes &aString ) const; |
|
379 /** |
|
380 * Parses the custom title from the current definition. |
|
381 * Returns ETrue on success and places the extracted |
|
382 * custom title to the aTarget |
|
383 * |
|
384 * @param aTarget Where to place the custom title. It is callers responsibility |
|
385 * to provide a descriptor with enough room for the custom title. |
|
386 * |
|
387 * @return KErrNone if everything is fine, KErrNotFound |
|
388 * if there is no custom title in the definition, KErrNoMemory in |
|
389 * case there is not enough room to place the result (low memory situations |
|
390 * or too small descriptor provided) |
|
391 */ |
|
392 TInt CustomTitle( TDes& aTarget ) const; |
|
393 |
|
394 protected: |
|
395 private: |
|
396 |
|
397 /** |
|
398 * Checks if an alias was used in shortcut definition and parses an uid from it |
|
399 * |
|
400 * @since S60 v3.2 |
|
401 * @return ETrue if alias was found and parsed, EFalse if not |
|
402 */ |
|
403 TBool ParseAlias(); |
|
404 |
|
405 /** |
|
406 * Parses the possible application shortcut parameters |
|
407 * |
|
408 * @since S60 v3.2 |
|
409 */ |
|
410 void ParseParams(); |
|
411 |
|
412 private: // data |
|
413 /** |
|
414 * URI Parser |
|
415 */ |
|
416 TUriParser iUriParser; |
|
417 |
|
418 /** |
|
419 * Pointer to the full shortcut definition |
|
420 */ |
|
421 TPtrC iDefinition; |
|
422 |
|
423 /** |
|
424 * Shortcut target type |
|
425 */ |
|
426 TShortcutType iType; |
|
427 |
|
428 /** |
|
429 * Shortcut application uid |
|
430 */ |
|
431 TUid iUid; |
|
432 |
|
433 /** |
|
434 * Pointer to shortcut parameter name |
|
435 */ |
|
436 TPtrC iParamName; |
|
437 |
|
438 /** |
|
439 * Pointer to shortcut parameter value |
|
440 */ |
|
441 TPtrC iParamValue; |
|
442 /** |
|
443 * Shortcut icon that has been given with the |
|
444 * URL-string |
|
445 */ |
|
446 TAiScutIcon iIcon; |
|
447 }; |
|
448 |
|
449 #endif // TAISCUTPARSER_H |
|
450 |
|
451 // End of File. |
|