|
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 plug-in engine class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CAISCUTENGINE_H |
|
20 #define CAISCUTENGINE_H |
|
21 |
|
22 #include <apgnotif.h> // For MApaAppListServObserver |
|
23 #include <msvapi.h> // For MMsvSessionObserver |
|
24 #include <FavouritesDb.h> // For RFavouritesDb |
|
25 #include <FavouritesDbObserver.h> // For MFavouritesDbObserver |
|
26 #include <ConeResLoader.h> |
|
27 #ifdef __WEB_WIDGETS |
|
28 #include <WidgetRegistryClient.h> |
|
29 #endif |
|
30 |
|
31 #include <aiutility.h> |
|
32 |
|
33 #include "aiscutdefs.h" |
|
34 #include "taiscutparser.h" |
|
35 #include "aicontentpublisher.h" |
|
36 |
|
37 class CCoeEnv; |
|
38 class CVwsSessionWrapper; |
|
39 class CActiveFavouritesDbNotifier; |
|
40 class CAiScutPlugin; |
|
41 class CAiScutShortcut; |
|
42 class CRepository; |
|
43 class CAiScutRepositoryWatcher; |
|
44 class CAiScutTargetShutter; |
|
45 class CKeyLockPolicyApi; |
|
46 |
|
47 /** |
|
48 * Defines the different scenarios of shortcut access checking. |
|
49 */ |
|
50 enum TScutAccessCheckType |
|
51 { |
|
52 EScutCheckMailbox, |
|
53 EScutCheckApp, |
|
54 EScutCheckBkm, |
|
55 EScutCheckAll |
|
56 }; |
|
57 |
|
58 /** |
|
59 * Defines which default can be used, when daulting is needed (uninstall/mem card removed) |
|
60 */ |
|
61 enum TScutDefault |
|
62 { |
|
63 EScutUserDefined = 0, |
|
64 EScutDefaultToPlatform, |
|
65 EScutDefaultToTheme |
|
66 }; |
|
67 |
|
68 enum TScutLockKey |
|
69 { |
|
70 EScutFirstLockKey, |
|
71 EScutSecondLockKey |
|
72 }; |
|
73 |
|
74 /** |
|
75 * Shortcut plug-in engine class. |
|
76 * |
|
77 * Handles most of plug-in activity. |
|
78 * |
|
79 * @since S60 v3.2 |
|
80 */ |
|
81 class CAiScutEngine : public CBase |
|
82 , public MMsvSessionObserver |
|
83 , public MApaAppListServObserver |
|
84 , public MFavouritesDbObserver |
|
85 { |
|
86 |
|
87 public: |
|
88 |
|
89 /** |
|
90 * First phase contructor. |
|
91 * |
|
92 * @since S60 v3.2 |
|
93 * @param aPlugin Reference to the main plug-in class |
|
94 */ |
|
95 static CAiScutEngine* NewL(CAiScutPlugin& aPlugin); |
|
96 |
|
97 virtual ~CAiScutEngine(); |
|
98 |
|
99 // from base class MMsvSessionObserver |
|
100 |
|
101 /** |
|
102 * Handles an event from the message server |
|
103 * |
|
104 * @since S60 v3.2 |
|
105 * @param aEvent Indicates the event type. |
|
106 * @param aArg1 Event type-specific argument value |
|
107 * @param aArg2 Event type-specific argument value |
|
108 * @param aArg3 Event type-specific argument value |
|
109 */ |
|
110 void HandleSessionEventL( |
|
111 TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3); |
|
112 |
|
113 // from base class MApaAppListServObserver |
|
114 |
|
115 /** |
|
116 * From MApaAppListServObserver. |
|
117 * Handles a change in the application list |
|
118 * |
|
119 * @since S60 v3.2 |
|
120 * @param aEvent Event id |
|
121 */ |
|
122 void HandleAppListEvent(TInt aEvent); |
|
123 |
|
124 /** |
|
125 * Resumes the engine |
|
126 * |
|
127 * @since S60 v3.2 |
|
128 */ |
|
129 virtual void ResumeL(TBool aPublishAll, TAiTransitionReason aReason); |
|
130 |
|
131 /** |
|
132 * Suspends the engine |
|
133 * |
|
134 * @since S60 v3.2 |
|
135 */ |
|
136 void Suspend(); |
|
137 |
|
138 /** |
|
139 * |
|
140 */ |
|
141 static TInt HandleShortcutsChanged(TAny* aPtr); |
|
142 |
|
143 /** |
|
144 * |
|
145 */ |
|
146 static TInt HandleHiddenAppsChanged(TAny* aPtr); |
|
147 |
|
148 /** |
|
149 * |
|
150 */ |
|
151 TBool IsHidden(const TUid& aAppUid) const; |
|
152 |
|
153 /** |
|
154 * Handles an event sent by the AI framework |
|
155 * |
|
156 * @since S60 v3.2 |
|
157 * @param aEvent Event (service) id |
|
158 * @param aParam Event parameter(s) |
|
159 */ |
|
160 virtual void HandleAiEventL(TInt aEvent, const TDesC& aParam); |
|
161 |
|
162 /** |
|
163 * Called by the timer. Retries the access check for shortcuts. |
|
164 * |
|
165 * @since S60 v3.2 |
|
166 */ |
|
167 void RetryAccessCheck(); |
|
168 |
|
169 /** |
|
170 * Checks if application is midlet or widget. |
|
171 * @param aUid Application uid |
|
172 * @since S60 v3.2 |
|
173 */ |
|
174 TBool IsNonNative(const TUid& aUid); |
|
175 |
|
176 TBool IsHiddenFromFSW( const TUid& aAppUid ); |
|
177 #ifdef __WEB_WIDGETS |
|
178 /** |
|
179 * Ask client session if given UID is widget. |
|
180 */ |
|
181 TBool IsWidget(const TUid& aUid); |
|
182 #endif |
|
183 |
|
184 /** |
|
185 * Handles call state changes (non-static version). |
|
186 * |
|
187 * @since S60 v3.2 |
|
188 */ |
|
189 void HandleCallStateChange(); |
|
190 |
|
191 /** |
|
192 * Merges the user defined shortcuts with the defaults. |
|
193 * @param aType shortcut type |
|
194 * @param aRecreateAll forces the recreation of shortcuts |
|
195 * @since S60 v3.2 |
|
196 */ |
|
197 void MergeShortcuts(TShortcutType aType, TBool aRecreateAll); |
|
198 |
|
199 /** |
|
200 *Get Application title |
|
201 */ |
|
202 TBool GetAppTitle( |
|
203 const TUid& aAppUid, |
|
204 const TUid& aViewId, |
|
205 TDes& aTitle, |
|
206 TAiScutAppTitleType aType); |
|
207 |
|
208 /** |
|
209 * Returns the application architecture server session owned by the engine |
|
210 * |
|
211 * @since S60 v3.2 |
|
212 * @return Reference to RApaLsSession |
|
213 */ |
|
214 inline RApaLsSession& ApaSession(); |
|
215 |
|
216 /** |
|
217 * Returns reference to the bookmark database owned by the engine |
|
218 * |
|
219 * @since S60 v3.2 |
|
220 * @return Reference to RFavouritesDb |
|
221 */ |
|
222 inline RFavouritesDb& FavouritesDb(); |
|
223 |
|
224 /** |
|
225 * Returns the message server session owned by the engine |
|
226 * |
|
227 * @since S60 v3.2 |
|
228 * @return Pointer to CMsvSession |
|
229 */ |
|
230 inline CMsvSession* MsvSession(); |
|
231 |
|
232 /** |
|
233 * Returns a pointer to view server session wrapper. |
|
234 * |
|
235 * @since S60 v3.2 |
|
236 * @return Pointer to view server session wrapper |
|
237 */ |
|
238 inline CVwsSessionWrapper* VwsSession(); |
|
239 |
|
240 /** |
|
241 * Returns a pointer to the coe environment |
|
242 * |
|
243 * @since S60 v3.2 |
|
244 * @return Pointer to coe environment |
|
245 */ |
|
246 inline CCoeEnv* Env(); |
|
247 |
|
248 /** |
|
249 * Creates the shortcuts merging the defaults with user defined ones. |
|
250 * |
|
251 * @since S60 v3.2 |
|
252 */ |
|
253 void CreateShortcutsL(); |
|
254 |
|
255 protected: |
|
256 |
|
257 |
|
258 /** |
|
259 * C++ constructor |
|
260 * |
|
261 * @since S60 v3.2 |
|
262 * @param aPlugin Reference to the main plug-in class |
|
263 */ |
|
264 CAiScutEngine(CAiScutPlugin& aPlugin); |
|
265 |
|
266 void ConstructL(); |
|
267 |
|
268 protected: |
|
269 |
|
270 /** |
|
271 * Merges the user defined shortcuts with the defaults. |
|
272 * Leaving version |
|
273 * @param aType shortcut type |
|
274 * @param aRecreateAll forces the recreation of shortcuts |
|
275 * @since S60 v3.2 |
|
276 */ |
|
277 void MergeShortcutsL(TShortcutType aType, TBool aRecreateAll); |
|
278 |
|
279 /** |
|
280 * Checks shortcut accessibility. If the AppArc server or message server |
|
281 * respond that they are not ready, a timer is launched to check later. |
|
282 * |
|
283 * @since S60 v3.2 |
|
284 * @param aCheckType Specifies which kind of shortcuts should check its access |
|
285 * @param aPublishAll All shortcuts are published |
|
286 */ |
|
287 void CheckAccessAndPublish(TInt aCheckType, TBool aPublishAll); |
|
288 |
|
289 /** |
|
290 * Tells each shortcut to check whether or not its target is accessible. |
|
291 * Shortcuts will revert to the default setting if the user setting is |
|
292 * not accessible. |
|
293 * |
|
294 * @since S60 v3.2 |
|
295 * @param aCheckType Specifies which kind of shortcuts should check its access |
|
296 * @param aPublishAll All shortcuts are published |
|
297 */ |
|
298 void CheckAccessAndPublishL(TInt aCheckType, TBool aPublishAll); |
|
299 |
|
300 /** |
|
301 * Finds the shortcut object with the given id |
|
302 * |
|
303 * @since S60 v3.2 |
|
304 * @param aId Shortcut id |
|
305 * @return Shortcut index or KErrNotFound |
|
306 */ |
|
307 TInt FindShortcutIndex(TInt32 aId); |
|
308 |
|
309 /** |
|
310 * Handles the shortcut launch by index. |
|
311 * |
|
312 * @since S60 v3.2 |
|
313 * @param aParam Index of the shortcut to launch |
|
314 */ |
|
315 void HandleLaunchByIndexL(const TDesC& aParam); |
|
316 |
|
317 /** |
|
318 * Handles the special launching of a shortcut. The |
|
319 * launching can be done based on the location of |
|
320 * the shortcut (sk, toolbar item etc) or based on the |
|
321 * application it points to. Currently when this function is |
|
322 * called to a shortcut that points to appshell the fastswap |
|
323 * window is opened |
|
324 * |
|
325 * @since s60 v5.0 |
|
326 * @param aParam Index of the shortcut to perform the special launch |
|
327 */ |
|
328 void HandleLaunchByIndexAlternateL(const TDesC& aParam); |
|
329 /** |
|
330 * Handles the shortcut launch by value |
|
331 * |
|
332 * @since S60 v3.2 |
|
333 * @param aParam Value of the shortcut to launch |
|
334 */ |
|
335 void HandleLaunchByValueL(const TDesC& aParam); |
|
336 |
|
337 /** |
|
338 * Shows the plug-in settings dialog. |
|
339 * |
|
340 * @since S60 v3.2 |
|
341 */ |
|
342 void ShowSettingsL(const TDesC& aParam); |
|
343 |
|
344 /** |
|
345 * Shows the plug-in setting. |
|
346 * |
|
347 * @since S60 v5.0 |
|
348 */ |
|
349 void ShowSettingL(const TDesC& aParam); |
|
350 |
|
351 /** |
|
352 * Opens the fast swap window |
|
353 * |
|
354 * @since S60 v5.0 |
|
355 */ |
|
356 void OpenFastSwap(); |
|
357 /** |
|
358 * Handles PS commands from WSPlugin. |
|
359 * |
|
360 * @since S60 v3.2 |
|
361 */ |
|
362 static TInt HandlePSCommand(TAny* aAny); |
|
363 |
|
364 /** |
|
365 * Handles call state changes. |
|
366 * |
|
367 * @since S60 v3.2 |
|
368 */ |
|
369 static TInt CallStateChangeCallback(TAny* aPtr); |
|
370 |
|
371 /** |
|
372 * Callback for delay timer |
|
373 */ |
|
374 static TInt DelayTimerCallBack(TAny *aSelf ); |
|
375 |
|
376 |
|
377 /** |
|
378 * Get soft key uid |
|
379 * |
|
380 * @since S60 v3.2 |
|
381 * @param aSoftkeyId shortcut index |
|
382 */ |
|
383 TUid SoftkeyUid(TUint32 aSoftkeyId); |
|
384 |
|
385 /** |
|
386 *Check softkey delay is required |
|
387 * |
|
388 * @since S60 v3.2 |
|
389 * @param AppUid application uid |
|
390 */ |
|
391 TBool IsDelayRequired(TUid aAppUid); |
|
392 |
|
393 /** |
|
394 * Handles PS commands from WSPlugin (leaving version). |
|
395 * |
|
396 * @since S60 v3.2 |
|
397 */ |
|
398 void DoHandlePSCommandL(); |
|
399 |
|
400 /** |
|
401 * Activates phone/video call application |
|
402 * |
|
403 * @since S60 v3.2 |
|
404 */ |
|
405 void ActivateTopMostApp(); |
|
406 |
|
407 /** |
|
408 * Check MsvSession is Needed |
|
409 */ |
|
410 TBool IsMsvSessionNeeded(); |
|
411 |
|
412 /** |
|
413 * Check Bookmark Observer is Needed |
|
414 */ |
|
415 TBool IsBookmarkObserverNeeded(); |
|
416 |
|
417 /** |
|
418 * Load application titles list |
|
419 */ |
|
420 void LoadAppTitleListL(); |
|
421 |
|
422 /** |
|
423 * Get hidden applications |
|
424 */ |
|
425 void GetHiddenAppsL(); |
|
426 |
|
427 void CheckForThemeDefaultReinstalledL(); |
|
428 |
|
429 TBool IsLockKey( TInt aScanCode, TScutLockKey aLockKey ) const; |
|
430 |
|
431 TInt AddOverrideIcon( TAiScutIcon &aIcon ); |
|
432 |
|
433 /** |
|
434 * Starts a delay timer that calls HandleLaunchByIndexL() after |
|
435 * a short delay. Delay is read from cenrep with the key KAIKeyLockTimeout |
|
436 * |
|
437 * @param aParam The parameter to pass to HandleLaunchByIndexL() |
|
438 * |
|
439 */ |
|
440 void DelayedLaunchByIndexL( const TDesC &aParam ); |
|
441 private: // From MFavouritesDbObserver |
|
442 |
|
443 /** |
|
444 * Handles database event. |
|
445 * @param aEvent Database event. |
|
446 */ |
|
447 void HandleFavouritesDbEventL(RDbNotifier::TEvent aEvent); |
|
448 |
|
449 protected: // data |
|
450 |
|
451 /** |
|
452 * Shortcut objects. |
|
453 * Own. |
|
454 */ |
|
455 RAiShortcutArray iShortcuts; |
|
456 |
|
457 /** |
|
458 * Shortcut objects for storing theme default scuts. |
|
459 * Own. |
|
460 */ |
|
461 RAiShortcutInfoArray iThemeShortcuts; |
|
462 |
|
463 /** |
|
464 * Flags for shortcuts to indicate whether platform or theme default is used. |
|
465 */ |
|
466 RArray<TScutDefault> iDefaultUsed; |
|
467 |
|
468 /** |
|
469 * Central Repository session. |
|
470 * Own. |
|
471 */ |
|
472 CRepository* iRepository; |
|
473 |
|
474 /** |
|
475 * Notifier for changes in the application list |
|
476 * (installations / uninstallations). |
|
477 * Own. |
|
478 */ |
|
479 CApaAppListNotifier* iAppNotifier; |
|
480 |
|
481 /** |
|
482 * Notifier for changes in the shortcut settings. |
|
483 * Own. |
|
484 */ |
|
485 CAiScutRepositoryWatcher* iSettingsNotifier; |
|
486 |
|
487 /** |
|
488 * Message server session. |
|
489 * Own. |
|
490 */ |
|
491 CMsvSession* iMsvSession; |
|
492 |
|
493 /** |
|
494 * Timer that performs the availability check after a given delay. |
|
495 * Own |
|
496 */ |
|
497 CPeriodic* iTimer; |
|
498 |
|
499 /** |
|
500 * Reference to the plug-in. |
|
501 * Not own. |
|
502 */ |
|
503 CAiScutPlugin& iPlugin; |
|
504 |
|
505 /** |
|
506 * Application architecture server session. |
|
507 */ |
|
508 RApaLsSession iApaSession; |
|
509 |
|
510 /** |
|
511 * Bookmark database session. |
|
512 * Own. |
|
513 */ |
|
514 RFavouritesSession iBookmarkSess; |
|
515 |
|
516 /** |
|
517 * Bookmark database. |
|
518 * Own. |
|
519 */ |
|
520 RFavouritesDb iBookmarkDb; |
|
521 |
|
522 /** |
|
523 * Bookmark database change observer. |
|
524 * Own. |
|
525 */ |
|
526 CActiveFavouritesDbNotifier* iBookmarkDbObserver; |
|
527 |
|
528 /** |
|
529 * View server session wrapper. |
|
530 * Own |
|
531 */ |
|
532 CVwsSessionWrapper* iVwsSession; |
|
533 |
|
534 /** |
|
535 * Flag to indicate that all shortcus are to be published. Used when resuming. |
|
536 */ |
|
537 TBool iPublishAll; |
|
538 |
|
539 /** |
|
540 *Call key event observer |
|
541 * Own |
|
542 */ |
|
543 MAiPSPropertyObserver* iKeyEventObserver; |
|
544 |
|
545 /** |
|
546 * Call state PS observer. |
|
547 * Own. |
|
548 */ |
|
549 MAiPSPropertyObserver* iCallStateObserver; |
|
550 |
|
551 /** |
|
552 * Call state |
|
553 */ |
|
554 TBool iActiveCall; |
|
555 |
|
556 /** |
|
557 * First keylock key |
|
558 */ |
|
559 TInt iFirstLockKey; |
|
560 |
|
561 /** |
|
562 * First keylock key pressed flag to ensure first lock has been |
|
563 * pressed when skipping key lock. Enabling the correct response to |
|
564 * skip command. |
|
565 */ |
|
566 TBool iFirstLockKeyPressed; |
|
567 |
|
568 /** |
|
569 * Second keylock key |
|
570 */ |
|
571 TInt iSecondLockKey; |
|
572 |
|
573 /** |
|
574 * Resource loader for common text resources. |
|
575 */ |
|
576 RConeResourceLoader iResourceLoaderTexts; |
|
577 |
|
578 /** |
|
579 * Resource loader for sendui text resources. |
|
580 */ |
|
581 RConeResourceLoader iResourceLoaderSendUi; |
|
582 |
|
583 /** |
|
584 * Coe environment. |
|
585 * Not own. |
|
586 */ |
|
587 CCoeEnv* iEnv; |
|
588 |
|
589 /** |
|
590 * Array of UIDs which are hidden from the TARM |
|
591 */ |
|
592 RArray<TUid> iHiddenApps; |
|
593 |
|
594 /** |
|
595 * Central repository object for Hidden Apps |
|
596 * Own |
|
597 */ |
|
598 CRepository* iHiddenAppsRepository; |
|
599 |
|
600 /** |
|
601 * Central repository change handler for Hidden Apps |
|
602 * Own |
|
603 */ |
|
604 CAiScutRepositoryWatcher* iHiddenAppsNotifier; |
|
605 |
|
606 /** |
|
607 * Application titles list |
|
608 */ |
|
609 RArray<TAiScutAppTitleEntry> iAppTitleList; |
|
610 |
|
611 /** |
|
612 * Own |
|
613 */ |
|
614 CAiScutTargetShutter* iScutShutter; |
|
615 |
|
616 /** |
|
617 * |
|
618 */ |
|
619 TBool iSoftkeyAppRunning; |
|
620 |
|
621 #ifdef __WEB_WIDGETS |
|
622 /** |
|
623 * Widget registry client session to check if UID means widget. |
|
624 */ |
|
625 RWidgetRegistryClientSession iWidgetRegistry; |
|
626 TBool iWidgetRegistryConnected; |
|
627 #endif |
|
628 /** |
|
629 * for parsing the icon overrides and softkeys |
|
630 */ |
|
631 TAiScutParser iParser; |
|
632 |
|
633 /** |
|
634 * Override icons and softkeyicons are held here |
|
635 */ |
|
636 RArray <TAiScutIcon> iIcons; |
|
637 |
|
638 /** |
|
639 * For checking keylock buttons |
|
640 * Own |
|
641 */ |
|
642 CKeyLockPolicyApi *iKeylockApi; |
|
643 /** |
|
644 * Timer user to delay the launching |
|
645 * of specific shortcuts. |
|
646 * Own |
|
647 */ |
|
648 CPeriodic *iDelayTimer; |
|
649 |
|
650 /** |
|
651 * Command passed to HandleLaunchByIndexL() |
|
652 * when delayed launching is used |
|
653 * Own |
|
654 */ |
|
655 HBufC *iDelayedLaunchCmd; |
|
656 |
|
657 /** |
|
658 * Delayed launching delay. Read from cenrep |
|
659 */ |
|
660 TInt iDelayTimerDelay; |
|
661 }; |
|
662 |
|
663 #include "caiscutengine.inl" |
|
664 |
|
665 #endif // CAISCUTENGINE_H |
|
666 |
|
667 // End of File. |