13 * |
13 * |
14 * Description: The engine class of MCS plugin. |
14 * Description: The engine class of MCS plugin. |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 |
|
19 // System includes |
18 // System includes |
20 #include <gulicon.h> |
19 #include <gulicon.h> |
21 #include <AknsItemID.h> |
|
22 #include <gslauncher.h> |
20 #include <gslauncher.h> |
23 #include <mcsmenuitem.h> |
|
24 #include <mcsmenufilter.h> |
21 #include <mcsmenufilter.h> |
25 #include <mcsmenuoperation.h> |
22 #include <mcsmenuoperation.h> |
26 #include <mcsmenuiconutility.h> |
23 #include <mcsmenuiconutility.h> |
27 #include <activefavouritesdbnotifier.h> |
|
28 #include <favouritesitemlist.h> |
|
29 #include <bautils.h> |
24 #include <bautils.h> |
30 #include <StringLoader.h> |
25 #include <StringLoader.h> |
31 #include <aknnotedialog.h> |
26 #include <aknnotedialog.h> |
32 #include <AknsConstants.h> |
|
33 #include <avkon.rsg> |
|
34 #include <mcspluginres.rsg> |
27 #include <mcspluginres.rsg> |
35 #include <apgtask.h> |
|
36 #include <apgcli.h> |
28 #include <apgcli.h> |
37 #include <apacmdln.h> |
29 #include <apacmdln.h> |
38 #include <gfxtranseffect/gfxtranseffect.h> |
30 #include <gfxtranseffect/gfxtranseffect.h> |
39 #include <akntranseffect.h> |
31 #include <akntranseffect.h> |
|
32 #include <schemehandler.h> |
|
33 #include <viewcli.h> // For CVwsSessionWrapper |
|
34 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
35 #include <viewclipartner.h> |
|
36 #endif |
|
37 #include <aisystemuids.hrh> |
40 |
38 |
41 // User includes |
39 // User includes |
42 #include <aisystemuids.hrh> |
|
43 #include "mcspluginengine.h" |
40 #include "mcspluginengine.h" |
44 #include "mcsplugin.h" |
41 #include "mcsplugin.h" |
45 #include "mcsplugindata.h" |
42 #include "mcsplugindata.h" |
46 #include "mcspluginuids.hrh" |
43 #include "mcspluginuids.hrh" |
47 |
44 |
50 _LIT( KSkin, "skin" ); |
47 _LIT( KSkin, "skin" ); |
51 _LIT( KMif, "mif" ); |
48 _LIT( KMif, "mif" ); |
52 _LIT( KResourceDrive, "Z:" ); |
49 _LIT( KResourceDrive, "Z:" ); |
53 _LIT( KResourceFile, "mcspluginres.rsc" ); |
50 _LIT( KResourceFile, "mcspluginres.rsc" ); |
54 _LIT( KResPath, "\\resource\\" ); |
51 _LIT( KResPath, "\\resource\\" ); |
55 _LIT( KMenuAttrRefcount, "ref_count" ); |
|
56 _LIT( KMMApplication, "mm://" ); |
52 _LIT( KMMApplication, "mm://" ); |
57 _LIT( KHideExit2, "&exit=hide" ); |
53 _LIT( KHideExit2, "&exit=hide" ); |
58 _LIT( KSetFocusString, "!setfocus?applicationgroup_name=" ); |
54 _LIT( KSetFocusString, "!setfocus?applicationgroup_name=" ); |
59 _LIT( KApplicationGroupName, "applicationgroup_name" ); |
55 _LIT( KApplicationGroupName, "applicationgroup_name" ); |
60 _LIT( KIcon, "icon" ); |
56 _LIT( KIcon, "icon" ); |
61 _LIT( KMenuAttrUndefUid, "0x99999991" ); |
57 _LIT( KMenuAttrUndefUid, "0x99999991" ); |
|
58 _LIT( KMenuIconFile, "aimcsplugin.mif" ); |
|
59 _LIT( KMenuBookmarkIconId, "16386" ); |
|
60 _LIT( KMenuBookmarkMaskId, "16387" ); |
|
61 _LIT( KMenuMailboxIconId, "16388" ); |
|
62 _LIT( KMenuMailboxMaskId, "16389" ); |
|
63 _LIT( KMenuTypeMailbox, "menu:mailbox" ); |
|
64 _LIT( KPrefix, "0x" ); |
62 |
65 |
63 const TUid KHomescreenUid = { AI_UID3_AIFW_COMMON }; |
66 const TUid KHomescreenUid = { AI_UID3_AIFW_COMMON }; |
64 const TUid KMMUid = { 0x101F4CD2 }; |
67 const TUid KMMUid = { 0x101F4CD2 }; |
|
68 const TUid KMCSCmailUidValue = { 0x2001E277 }; |
|
69 const TUid KMCSCmailMailboxViewIdValue = { 0x2 }; |
|
70 const TUid KBrowserUid = { 0x10008D39 }; |
65 |
71 |
66 // ======== LOCAL FUNCTIONS ======== |
72 // ======== LOCAL FUNCTIONS ======== |
67 // ---------------------------------------------------------------------------- |
73 // ---------------------------------------------------------------------------- |
68 // NextIdToken |
74 // NextIdToken |
69 // |
|
70 // ---------------------------------------------------------------------------- |
75 // ---------------------------------------------------------------------------- |
71 // |
76 // |
72 static TPtrC NextIdToken( TLex& aLexer ) |
77 static TPtrC NextIdToken( TLex& aLexer ) |
73 { |
78 { |
74 aLexer.SkipSpace(); |
79 aLexer.SkipSpace(); |
80 } |
85 } |
81 |
86 |
82 return aLexer.MarkedToken(); |
87 return aLexer.MarkedToken(); |
83 } |
88 } |
84 |
89 |
|
90 // ---------------------------------------------------------------------------- |
|
91 // Shows note dailog, with the given resource. |
|
92 // ---------------------------------------------------------------------------- |
|
93 // |
|
94 static void ShowNoteDlgL( TInt aResource ) |
|
95 { |
|
96 HBufC* temp = StringLoader::LoadLC( aResource ); |
|
97 |
|
98 CAknNoteDialog* dialog = new (ELeave) CAknNoteDialog( |
|
99 CAknNoteDialog::EConfirmationTone, |
|
100 CAknNoteDialog::ENoTimeout ); |
|
101 CleanupStack::PushL( dialog ); |
|
102 dialog->SetTextL( temp->Des() ); |
|
103 dialog->ExecuteDlgLD( R_MCS_DISABLE_OPEN_ITEM_DLG ); |
|
104 CleanupStack::Pop( dialog ); |
|
105 CleanupStack::PopAndDestroy( temp ); |
|
106 } |
|
107 |
|
108 // ---------------------------------------------------------------------------- |
|
109 // Parses uid in Hexadecimal format from the given string. |
|
110 // ---------------------------------------------------------------------------- |
|
111 // |
|
112 TUid ParseHexUidFromString(const TDesC& aUidString ) |
|
113 { |
|
114 TUid uid( KNullUid ); |
|
115 const TInt pos( aUidString.FindF( KPrefix ) ); |
|
116 |
|
117 if ( pos != KErrNotFound ) |
|
118 { |
|
119 TLex lex( aUidString.Mid( pos + KPrefix().Length() ) ); |
|
120 |
|
121 // Hex parsing needs unsigned int |
|
122 TUint32 value( 0 ); |
|
123 const TInt parseResult( lex.Val( value, EHex ) ); |
|
124 |
|
125 if ( parseResult == KErrNone ) |
|
126 { |
|
127 TInt32 value32( value ); |
|
128 uid.iUid = value32; |
|
129 } |
|
130 } |
|
131 return uid; |
|
132 } |
|
133 |
|
134 // ---------------------------------------------------------------------------- |
|
135 // Start transition effect. User has launched the application with the given uid. |
|
136 // ---------------------------------------------------------------------------- |
|
137 // |
|
138 void StartEffect( TUid aUid ) |
|
139 { |
|
140 //start a full screen effect |
|
141 GfxTransEffect::BeginFullScreen( |
|
142 AknTransEffect::EApplicationStart, |
|
143 TRect(), |
|
144 AknTransEffect::EParameterType, |
|
145 AknTransEffect::GfxTransParam( aUid, |
|
146 AknTransEffect::TParameter::EActivateExplicitContinue )); |
|
147 } |
|
148 |
85 // ============================ MEMBER FUNCTIONS =============================== |
149 // ============================ MEMBER FUNCTIONS =============================== |
86 // ---------------------------------------------------------------------------- |
150 // ---------------------------------------------------------------------------- |
87 // CMCSPluginEngine::CMCSPluginEngine |
151 // CMCSPluginEngine::CMCSPluginEngine |
88 // |
152 // |
89 // ---------------------------------------------------------------------------- |
153 // ---------------------------------------------------------------------------- |
261 // --------------------------------------------------------------------------- |
316 // --------------------------------------------------------------------------- |
262 // CMCSPluginEngine::FetchMenuItemL |
317 // CMCSPluginEngine::FetchMenuItemL |
263 // Returns the actual menu item for the given header. |
318 // Returns the actual menu item for the given header. |
264 // --------------------------------------------------------------------------- |
319 // --------------------------------------------------------------------------- |
265 // |
320 // |
266 CMenuItem* CMCSPluginEngine::FetchMenuItemL( const TMenuItem& aMenuItem ) |
321 CMenuItem* CMCSPluginEngine::FetchMenuItemL( CMCSData& aData ) |
267 { |
322 { |
268 return CMenuItem::OpenL( iMenu, aMenuItem ); |
323 if( aData.MenuItem().Type() == KMenuTypeUrl ) |
|
324 { |
|
325 return CreateBkmItemL( aData ); |
|
326 } |
|
327 else if( aData.MenuItem().Type() == KMenuTypeMailbox ) |
|
328 { |
|
329 return CreateMailboxItemL( aData); |
|
330 } |
|
331 else |
|
332 { |
|
333 CMenuItem* item = NULL; |
|
334 TRAP_IGNORE( item = CMenuItem::OpenL( iMenu, aData.MenuItem().Id() ) ); |
|
335 return item; |
|
336 } |
|
337 } |
|
338 |
|
339 // --------------------------------------------------------------------------- |
|
340 // |
|
341 // --------------------------------------------------------------------------- |
|
342 // |
|
343 CMenuItem* CMCSPluginEngine::CreateBkmItemL( CMCSData& aData ) |
|
344 { |
|
345 CMenuItem* item( NULL ); |
|
346 if( aData.MenuItem().Id() != KErrNotFound ) |
|
347 { |
|
348 item = CMenuItem::CreateL( iMenu, KMenuTypeUrl, 0, 0 ); |
|
349 CleanupStack::PushL( item ); |
|
350 item->SetAttributeL( KMenuAttrLongName, aData.Name() ); |
|
351 item->SetAttributeL( KMenuAttrIconFile, KMenuIconFile ); |
|
352 item->SetAttributeL( KMenuAttrIconId, KMenuBookmarkIconId ); |
|
353 item->SetAttributeL( KMenuAttrMaskId, KMenuBookmarkMaskId ); |
|
354 CleanupStack::Pop( item ); |
|
355 } |
|
356 return item; |
|
357 } |
|
358 |
|
359 // --------------------------------------------------------------------------- |
|
360 // |
|
361 // --------------------------------------------------------------------------- |
|
362 // |
|
363 CMenuItem* CMCSPluginEngine::CreateMailboxItemL( CMCSData& aData ) |
|
364 { |
|
365 CMenuItem* item( NULL ); |
|
366 if( aData.MenuItem().Id() != KErrNotFound ) |
|
367 { |
|
368 item = CMenuItem::CreateL( iMenu, KMenuTypeMailbox, 0, 0 ); |
|
369 CleanupStack::PushL( item ); |
|
370 item->SetAttributeL( KMenuAttrLongName, aData.Name() ); |
|
371 item->SetAttributeL( KMenuAttrIconFile, KMenuIconFile ); |
|
372 item->SetAttributeL( KMenuAttrIconId, KMenuMailboxIconId ); |
|
373 item->SetAttributeL( KMenuAttrMaskId, KMenuMailboxMaskId ); |
|
374 CleanupStack::Pop( item ); |
|
375 } |
|
376 return item; |
269 } |
377 } |
270 |
378 |
271 // --------------------------------------------------------------------------- |
379 // --------------------------------------------------------------------------- |
272 // CMCSPluginEngine::ItemIconL |
380 // CMCSPluginEngine::ItemIconL |
273 // Returns MCS default icon if attribute is 'icon' else parses the |
381 // Returns MCS default icon if attribute is 'icon' else parses the |
405 // |
499 // |
406 void CMCSPluginEngine::LaunchItemL( const TInt& aIndex ) |
500 void CMCSPluginEngine::LaunchItemL( const TInt& aIndex ) |
407 { |
501 { |
408 if ( iBackupRestore ) |
502 if ( iBackupRestore ) |
409 { |
503 { |
410 HBufC* temp = StringLoader::LoadLC( R_MCS_DISABLE_OPEN_ITEM ); |
504 ShowNoteDlgL( R_MCS_DISABLE_OPEN_ITEM ); |
411 |
|
412 CAknNoteDialog* dialog = new (ELeave) CAknNoteDialog( |
|
413 CAknNoteDialog::EConfirmationTone, |
|
414 CAknNoteDialog::ENoTimeout ); |
|
415 CleanupStack::PushL( dialog ); |
|
416 dialog->SetTextL( temp->Des() ); |
|
417 dialog->ExecuteDlgLD( R_MCS_DISABLE_OPEN_ITEM_DLG ); |
|
418 CleanupStack::Pop( dialog ); |
|
419 CleanupStack::PopAndDestroy( temp ); |
|
420 return; |
505 return; |
421 } |
506 } |
422 |
507 |
423 if( iWatcher->IsActive()) |
508 CMCSData& dataItem( iPluginData->DataItemL( aIndex ) ); |
424 { |
509 // run item based on its type |
425 return; |
510 TPtrC type( dataItem.MenuItem().Type()); |
426 } |
511 |
427 |
512 // run folder |
428 TMCSData& dataItem( iPluginData->DataItemL( aIndex ) ); |
513 if ( type == KMenuTypeFolder ) |
429 |
514 { |
|
515 LaunchFolderItemL( dataItem ); |
|
516 } |
|
517 else if( type == KMenuTypeUrl ) |
|
518 { |
|
519 LaunchBookmarkItemL( dataItem ); |
|
520 } |
|
521 else if( type == KMenuTypeMailbox ) |
|
522 { |
|
523 LaunchMailboxItemL( dataItem ); |
|
524 } |
|
525 else |
|
526 { |
|
527 LaunchMCSItemL( dataItem ); |
|
528 } |
|
529 } |
|
530 |
|
531 // --------------------------------------------------------------------------- |
|
532 // |
|
533 // --------------------------------------------------------------------------- |
|
534 // |
|
535 void CMCSPluginEngine::LaunchFolderItemL( CMCSData& aData ) |
|
536 { |
430 CMenuItem* item = NULL; |
537 CMenuItem* item = NULL; |
431 TRAP_IGNORE( item = CMenuItem::OpenL( iMenu, dataItem.MenuItem().Id() ) ); |
538 TRAP_IGNORE( item = CMenuItem::OpenL( iMenu, aData.MenuItem().Id() ) ); |
432 |
539 |
433 // item does not exist at all in MCS |
540 // item does not exist at all in MCS |
434 if ( item == NULL ) |
541 if ( item == NULL ) |
435 { |
542 { |
436 HBufC* temp = StringLoader::LoadLC( R_MCS_DISABLE_OPEN_ITEM_MISSING ); |
543 ShowNoteDlgL( R_MCS_DISABLE_OPEN_ITEM_MISSING ); |
437 |
|
438 CAknNoteDialog* dialog = new (ELeave) CAknNoteDialog( |
|
439 CAknNoteDialog::EConfirmationTone, |
|
440 CAknNoteDialog::ENoTimeout ); |
|
441 CleanupStack::PushL( dialog ); |
|
442 dialog->SetTextL( temp->Des() ); |
|
443 dialog->ExecuteDlgLD( R_MCS_DISABLE_OPEN_ITEM_DLG ); |
|
444 CleanupStack::Pop( dialog ); |
|
445 CleanupStack::PopAndDestroy( temp ); |
|
446 temp = NULL; |
|
447 |
|
448 return; |
544 return; |
449 } |
545 } |
450 |
546 |
451 CleanupStack::PushL( item ); |
547 CleanupStack::PushL( item ); |
452 |
548 |
|
549 StartEffect( KMMUid ); |
|
550 |
|
551 // message for MM application |
|
552 HBufC8* message; |
|
553 |
|
554 // prepare message for launching folder |
|
555 TBool hasApplicationGroupName( EFalse ); |
|
556 |
|
557 TPtrC applicationGroupName( item->GetAttributeL( |
|
558 KApplicationGroupName, hasApplicationGroupName ) ); |
|
559 |
|
560 if ( !hasApplicationGroupName ) |
|
561 { |
|
562 return; |
|
563 } |
|
564 |
|
565 message = HBufC8::NewLC( KMMApplication().Length() + |
|
566 KSetFocusString().Length() + |
|
567 applicationGroupName.Length() + |
|
568 KHideExit2().Length() ); |
|
569 |
|
570 message->Des().Copy( KMMApplication ); |
|
571 message->Des().Append( KSetFocusString ); |
|
572 message->Des().Append( applicationGroupName ); |
|
573 message->Des().Append( KHideExit2 ); |
|
574 |
|
575 // find MM application |
|
576 TApaTaskList taskList( CCoeEnv::Static()->WsSession() ); |
|
577 TApaTask task( taskList.FindApp( KMMUid ) ); |
|
578 |
|
579 if ( task.Exists() ) |
|
580 { |
|
581 // MM is already running in background - send APA Message |
|
582 task.SendMessage( |
|
583 TUid::Uid( KUidApaMessageSwitchOpenFileValue ), *message ); |
|
584 } |
|
585 else |
|
586 { |
|
587 // MM not running yet - use Command Line Tail |
|
588 RApaLsSession appArcSession; |
|
589 CleanupClosePushL( appArcSession ); |
|
590 |
|
591 User::LeaveIfError( appArcSession.Connect() ); |
|
592 |
|
593 TApaAppInfo appInfo; |
|
594 TInt err( appArcSession.GetAppInfo( appInfo, KMMUid ) ); |
|
595 |
|
596 if ( err == KErrNone ) |
|
597 { |
|
598 CApaCommandLine* cmdLine = CApaCommandLine::NewLC(); |
|
599 cmdLine->SetExecutableNameL( appInfo.iFullName ); |
|
600 cmdLine->SetCommandL( EApaCommandRun ); |
|
601 cmdLine->SetTailEndL( *message ); |
|
602 appArcSession.StartApp( *cmdLine ); |
|
603 CleanupStack::PopAndDestroy( cmdLine ); |
|
604 } |
|
605 CleanupStack::PopAndDestroy( &appArcSession ); |
|
606 } |
|
607 CleanupStack::PopAndDestroy( message ); |
|
608 CleanupStack::PopAndDestroy( item ); |
|
609 } |
|
610 |
|
611 // --------------------------------------------------------------------------- |
|
612 // |
|
613 // --------------------------------------------------------------------------- |
|
614 // |
|
615 void CMCSPluginEngine::LaunchBookmarkItemL( CMCSData& aData ) |
|
616 { |
|
617 StartEffect( KBrowserUid ); |
|
618 |
|
619 CSchemeHandler* urlHandler = CSchemeHandler::NewL( aData.Value()); |
|
620 CleanupStack::PushL( urlHandler ); |
|
621 urlHandler->HandleUrlStandaloneL(); |
|
622 CleanupStack::PopAndDestroy( urlHandler ); |
|
623 } |
|
624 |
|
625 // --------------------------------------------------------------------------- |
|
626 // |
|
627 // --------------------------------------------------------------------------- |
|
628 // |
|
629 void CMCSPluginEngine::LaunchMailboxItemL( CMCSData& aData ) |
|
630 { |
|
631 TInt id( aData.MenuItem().Id()); |
|
632 if ( id == KErrNotFound ) |
|
633 { |
|
634 ShowNoteDlgL( R_MCS_DISABLE_OPEN_ITEM_MISSING ); |
|
635 return; |
|
636 } |
|
637 |
|
638 StartEffect( KMCSCmailUidValue ); |
|
639 |
|
640 TUid uId = TUid::Uid( id ); |
|
641 const TVwsViewId viewId( KMCSCmailUidValue, KMCSCmailMailboxViewIdValue ); |
|
642 CVwsSessionWrapper* vwsSession = CVwsSessionWrapper::NewL(); |
|
643 vwsSession->CreateActivateViewEvent( viewId, uId, KNullDesC8() ); |
|
644 delete vwsSession; |
|
645 } |
|
646 |
|
647 // --------------------------------------------------------------------------- |
|
648 // |
|
649 // --------------------------------------------------------------------------- |
|
650 // |
|
651 void CMCSPluginEngine::LaunchMCSItemL( CMCSData& aData ) |
|
652 { |
|
653 if( iWatcher->IsActive()) |
|
654 { |
|
655 return; |
|
656 } |
|
657 CMenuItem* item = NULL; |
|
658 TRAP_IGNORE( item = CMenuItem::OpenL( iMenu, aData.MenuItem().Id() ) ); |
|
659 |
|
660 // item does not exist at all in MCS |
|
661 if ( item == NULL ) |
|
662 { |
|
663 ShowNoteDlgL( R_MCS_DISABLE_OPEN_ITEM_MISSING ); |
|
664 return; |
|
665 } |
|
666 |
|
667 CleanupStack::PushL( item ); |
|
668 |
453 TBool attrExists = ETrue; |
669 TBool attrExists = ETrue; |
454 |
|
455 TPtrC uid = item->GetAttributeL( KMenuAttrUid, attrExists ); |
670 TPtrC uid = item->GetAttributeL( KMenuAttrUid, attrExists ); |
456 |
671 |
457 // trying to run hidden or missing application (e.g. unistalled app |
672 // trying to run hidden or missing application (e.g. unistalled app |
458 // or app on MMC which was removed ) |
673 // or app on MMC which was removed ) |
459 // -> We display a note for a user that this is not possible¨ |
674 // -> We display a note for a user that this is not possible¨ |
461 TUint32 isMissing = item->Flags() & TMenuItem::EMissing; |
676 TUint32 isMissing = item->Flags() & TMenuItem::EMissing; |
462 |
677 |
463 if ( ( attrExists && uid == KMenuAttrUndefUid ) || isHidden || isMissing ) |
678 if ( ( attrExists && uid == KMenuAttrUndefUid ) || isHidden || isMissing ) |
464 { |
679 { |
465 CleanupStack::PopAndDestroy( item ); |
680 CleanupStack::PopAndDestroy( item ); |
466 |
681 ShowNoteDlgL( R_MCS_DISABLE_OPEN_ITEM_MISSING ); |
467 HBufC* temp = StringLoader::LoadLC( R_MCS_DISABLE_OPEN_ITEM_MISSING ); |
|
468 |
|
469 CAknNoteDialog* dialog = new (ELeave) CAknNoteDialog( |
|
470 CAknNoteDialog::EConfirmationTone, |
|
471 CAknNoteDialog::ENoTimeout ); |
|
472 CleanupStack::PushL( dialog ); |
|
473 dialog->SetTextL( temp->Des() ); |
|
474 dialog->ExecuteDlgLD( R_MCS_DISABLE_OPEN_ITEM_DLG ); |
|
475 CleanupStack::Pop( dialog ); |
|
476 CleanupStack::PopAndDestroy( temp ); |
|
477 temp = NULL; |
|
478 |
|
479 return; |
682 return; |
480 } |
683 } |
481 |
684 |
482 // run item based on its type |
685 if ( attrExists ) |
483 TPtrC type( item->Type() ); |
686 { |
484 |
687 StartEffect( ParseHexUidFromString( uid )); |
485 // run folder |
688 } |
486 if ( type == KMenuTypeFolder ) |
689 |
487 { |
690 // run application/shortcut |
488 // message for MM application |
691 CMenuOperation* operation( item->HandleCommandL( |
489 HBufC8* message; |
692 KMenuCmdOpen, KNullDesC8, iWatcher->iStatus ) ); |
490 |
693 iWatcher->Watch( operation ); |
491 // prepare message for launching folder |
|
492 TBool hasApplicationGroupName( EFalse ); |
|
493 |
|
494 TPtrC applicationGroupName( item->GetAttributeL( |
|
495 KApplicationGroupName, hasApplicationGroupName ) ); |
|
496 |
|
497 if ( !hasApplicationGroupName ) |
|
498 { |
|
499 CleanupStack::PopAndDestroy( item ); |
|
500 return; |
|
501 } |
|
502 |
|
503 message = HBufC8::NewLC( KMMApplication().Length() + |
|
504 KSetFocusString().Length() + |
|
505 applicationGroupName.Length() + |
|
506 KHideExit2().Length() ); |
|
507 |
|
508 message->Des().Copy( KMMApplication ); |
|
509 message->Des().Append( KSetFocusString ); |
|
510 message->Des().Append( applicationGroupName ); |
|
511 message->Des().Append( KHideExit2 ); |
|
512 |
|
513 // find MM application |
|
514 TApaTaskList taskList( CCoeEnv::Static()->WsSession() ); |
|
515 TApaTask task( taskList.FindApp( KMMUid ) ); |
|
516 |
|
517 if ( task.Exists() ) |
|
518 { |
|
519 // MM is already running in background - send APA Message |
|
520 task.SendMessage( |
|
521 TUid::Uid( KUidApaMessageSwitchOpenFileValue ), *message ); |
|
522 } |
|
523 else |
|
524 { |
|
525 // MM not running yet - use Command Line Tail |
|
526 RApaLsSession appArcSession; |
|
527 CleanupClosePushL( appArcSession ); |
|
528 |
|
529 User::LeaveIfError( appArcSession.Connect() ); |
|
530 |
|
531 TApaAppInfo appInfo; |
|
532 TInt err( appArcSession.GetAppInfo( appInfo, KMMUid ) ); |
|
533 |
|
534 if ( err == KErrNone ) |
|
535 { |
|
536 CApaCommandLine* cmdLine = CApaCommandLine::NewLC(); |
|
537 cmdLine->SetExecutableNameL( appInfo.iFullName ); |
|
538 cmdLine->SetCommandL( EApaCommandRun ); |
|
539 cmdLine->SetTailEndL( *message ); |
|
540 appArcSession.StartApp( *cmdLine ); |
|
541 CleanupStack::PopAndDestroy( cmdLine ); |
|
542 } |
|
543 |
|
544 CleanupStack::PopAndDestroy( &appArcSession ); |
|
545 } |
|
546 |
|
547 CleanupStack::PopAndDestroy( message ); |
|
548 } |
|
549 else |
|
550 { |
|
551 TBool exists( EFalse ); |
|
552 |
|
553 TPtrC desc( item->GetAttributeL( KMenuAttrUid, exists ) ); |
|
554 |
|
555 if ( exists ) |
|
556 { |
|
557 _LIT( KPrefix, "0x" ); |
|
558 |
|
559 const TInt pos( desc.FindF( KPrefix ) ); |
|
560 |
|
561 if ( pos != KErrNotFound ) |
|
562 { |
|
563 TLex lex( desc.Mid( pos + KPrefix().Length() ) ); |
|
564 |
|
565 // Hex parsing needs unsigned int |
|
566 TUint32 value( 0 ); |
|
567 const TInt parseResult( lex.Val( value, EHex ) ); |
|
568 |
|
569 if ( parseResult == KErrNone ) |
|
570 { |
|
571 TUid uid( KNullUid ); |
|
572 TInt32 value32( value ); |
|
573 uid.iUid = value32; |
|
574 |
|
575 if ( uid != KNullUid ) |
|
576 { |
|
577 //start a full screen effect |
|
578 GfxTransEffect::BeginFullScreen( |
|
579 AknTransEffect::EApplicationStart, |
|
580 TRect(), |
|
581 AknTransEffect::EParameterType, |
|
582 AknTransEffect::GfxTransParam( uid, |
|
583 AknTransEffect::TParameter::EActivateExplicitContinue ) ); |
|
584 } |
|
585 } |
|
586 } |
|
587 } |
|
588 |
|
589 // run application/shortcut/bookmark |
|
590 CMenuOperation* operation( item->HandleCommandL( |
|
591 KMenuCmdOpen, KNullDesC8, iWatcher->iStatus ) ); |
|
592 |
|
593 iWatcher->Watch( operation ); |
|
594 } |
|
595 |
|
596 CleanupStack::PopAndDestroy( item ); |
694 CleanupStack::PopAndDestroy( item ); |
597 } |
695 } |
598 |
696 |
599 // --------------------------------------------------------------------------- |
697 // --------------------------------------------------------------------------- |
600 // CMCSPluginEngine::HandleNotifyL |
698 // CMCSPluginEngine::HandleNotifyL |
605 { |
703 { |
606 TInt count( iPluginData->DataCount() ); |
704 TInt count( iPluginData->DataCount() ); |
607 |
705 |
608 for ( TInt i = 0; i < count; i++ ) |
706 for ( TInt i = 0; i < count; i++ ) |
609 { |
707 { |
610 TMCSData& data( iPluginData->DataItemL( i ) ); |
708 CMCSData& data( iPluginData->DataItemL( i ) ); |
611 data.SetDirty( ETrue ); |
709 data.SetDirty( ETrue ); |
612 } |
710 } |
613 |
|
614 // Notification must be activated again |
711 // Notification must be activated again |
615 iNotifyWatcher->Cancel(); |
712 iNotifyWatcher->Cancel(); |
616 |
|
617 iNotifier.Notify( 0, |
713 iNotifier.Notify( 0, |
618 RMenuNotifier::EItemsAddedRemoved | |
714 RMenuNotifier::EItemsAddedRemoved, |
619 RMenuNotifier::EItemsReordered | |
|
620 RMenuNotifier::EItemAttributeChanged, |
|
621 iNotifyWatcher->iStatus ); |
715 iNotifyWatcher->iStatus ); |
622 |
716 |
623 iNotifyWatcher->WatchNotify( this ); |
717 iNotifyWatcher->WatchNotify( this ); |
624 |
|
625 // Publish changed data |
|
626 iPlugin.PublishL(); |
|
627 } |
718 } |
628 |
719 |
629 // --------------------------------------------------------------------------- |
720 // --------------------------------------------------------------------------- |
630 // CMCSPluginEngine::HandleSessionEventL |
721 // CMCSPluginEngine::HandleSessionEventL |
631 // Handles an event from the message server. |
722 // Handles an event from the message server. |
632 // --------------------------------------------------------------------------- |
723 // --------------------------------------------------------------------------- |
633 // |
724 // |
634 void CMCSPluginEngine::HandleSessionEventL( TMsvSessionEvent aEvent, |
725 void CMCSPluginEngine::HandleSessionEventL( TMsvSessionEvent aEvent, |
635 TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/) |
726 TAny* aArg1, TAny* /*aArg2*/, TAny* /*aArg3*/) |
636 { |
727 { |
637 switch ( aEvent ) |
728 switch ( aEvent ) |
638 { |
729 { |
639 case EMsvEntriesDeleted: |
730 case EMsvEntriesDeleted: |
640 // fall-through intended here |
|
641 case EMsvEntriesChanged: |
|
642 { |
731 { |
|
732 CMsvEntrySelection* sel = static_cast<CMsvEntrySelection*>( aArg1 ); |
|
733 TInt count( sel->Count()); |
|
734 for( TInt i = 0; i < count; i++ ) |
|
735 { |
|
736 iPluginData->RemoveDataL( sel->At( i ) ); |
|
737 } |
643 } |
738 } |
644 break; |
739 break; |
645 default: |
740 default: |
646 break; |
741 break; |
647 } |
742 } |
680 // |
773 // |
681 TBool CMCSPluginEngine::ConstructMenuItemForIconL( const TDesC& aPath, |
774 TBool CMCSPluginEngine::ConstructMenuItemForIconL( const TDesC& aPath, |
682 CMenuItem& aMenuItem ) |
775 CMenuItem& aMenuItem ) |
683 { |
776 { |
684 TInt pos( aPath.Locate( ':' ) ); |
777 TInt pos( aPath.Locate( ':' ) ); |
685 |
|
686 if ( pos == KErrNotFound ) |
778 if ( pos == KErrNotFound ) |
687 { |
779 { |
688 pos = aPath.Length(); |
780 pos = aPath.Length(); |
689 } |
781 } |
690 |
|
691 TPtrC skin( aPath.Left( pos ) ); |
782 TPtrC skin( aPath.Left( pos ) ); |
692 TInt sf( skin.FindF( KSkin ) ); |
783 TInt sf( skin.FindF( KSkin ) ); |
693 |
784 |
694 if ( sf == KErrNotFound ) |
785 if ( sf == KErrNotFound ) |
695 { |
786 { |
696 return EFalse; |
787 return EFalse; |
697 } |
788 } |
698 |
789 |
699 TPtrC temp( skin.Mid( sf + KSkin().Length() ) ); |
790 TPtrC temp( skin.Mid( sf + KSkin().Length() ) ); |
700 |
|
701 TLex input( temp ); |
791 TLex input( temp ); |
702 input.SkipSpace(); |
792 input.SkipSpace(); |
703 |
793 |
704 if ( !input.Eos() && input.Peek() == '(' ) |
794 if ( !input.Eos() && input.Peek() == '(' ) |
705 { |
795 { |
706 input.Inc(); |
796 input.Inc(); |
707 } |
797 } |
708 |
|
709 TPtrC majorId( NextIdToken( input ) ); |
798 TPtrC majorId( NextIdToken( input ) ); |
710 TPtrC minorId( NextIdToken( input ) ); |
799 TPtrC minorId( NextIdToken( input ) ); |
711 |
800 |
712 aMenuItem.SetAttributeL( KMenuAttrIconSkinMajorId, majorId ); |
801 aMenuItem.SetAttributeL( KMenuAttrIconSkinMajorId, majorId ); |
713 aMenuItem.SetAttributeL( KMenuAttrIconSkinMinorId, minorId ); |
802 aMenuItem.SetAttributeL( KMenuAttrIconSkinMinorId, minorId ); |
714 |
|
715 //TPtrC mif = aPath.Mid( pos + 1 ); |
|
716 //TInt mf = mif.FindF( KMif ); |
|
717 |
803 |
718 if ( aPath.Length() > pos && |
804 if ( aPath.Length() > pos && |
719 ( aPath.Mid( pos + 1 ).FindF( KMif ) != KErrNotFound ) ) |
805 ( aPath.Mid( pos + 1 ).FindF( KMif ) != KErrNotFound ) ) |
720 { |
806 { |
721 TPtrC mif( aPath.Mid( pos + 1 ) ); |
807 TPtrC mif( aPath.Mid( pos + 1 ) ); |
722 TInt mf( mif.FindF( KMif ) ); |
808 TInt mf( mif.FindF( KMif ) ); |
723 |
|
724 //TPtrC temp1 = mif.Mid( mf+ KMif().Length()); |
|
725 |
809 |
726 TLex input1( mif.Mid( mf + KMif().Length() ) ); |
810 TLex input1( mif.Mid( mf + KMif().Length() ) ); |
727 input1.SkipSpace(); |
811 input1.SkipSpace(); |
728 |
812 |
729 if ( !input1.Eos() && input1.Peek() == '(' ) |
813 if ( !input1.Eos() && input1.Peek() == '(' ) |
741 } |
825 } |
742 |
826 |
743 return ETrue; |
827 return ETrue; |
744 } |
828 } |
745 |
829 |
746 // --------------------------------------------------------------------------- |
|
747 // CMCSPluginEngine::CleanMCSItemsL |
|
748 // Called during plugin desctruction |
|
749 // Decrements reference counters of all run-time generated items |
|
750 // and deletes those which have reference counter == 0 |
|
751 // --------------------------------------------------------------------------- |
|
752 // |
|
753 void CMCSPluginEngine::CleanMCSItemsL() |
|
754 { |
|
755 iNotifier.Close(); |
|
756 delete iNotifyWatcher; |
|
757 iNotifyWatcher = NULL; |
|
758 |
|
759 const TInt count( iPluginData->DataCount() ); |
|
760 |
|
761 for( TInt i = 0; i < count; i++ ) |
|
762 { |
|
763 TMCSData& data( iPluginData->DataItemL(i) ); |
|
764 |
|
765 CMenuItem* menuItem = CMenuItem::OpenL( iMenu, data.MenuItem().Id() ); |
|
766 |
|
767 if ( !menuItem ) |
|
768 { |
|
769 continue; |
|
770 } |
|
771 |
|
772 CleanupStack::PushL( menuItem ); |
|
773 |
|
774 // check if ref_count attribute exists |
|
775 TBool exists( EFalse ); |
|
776 |
|
777 TPtrC param( menuItem->GetAttributeL( KMenuAttrRefcount, exists ) ); |
|
778 |
|
779 if( exists ) |
|
780 { |
|
781 const TInt references( UpdateMenuItemsRefCountL( menuItem, -1 ) ); |
|
782 |
|
783 // Create a nested loop inside CActiveScheduler. |
|
784 CActiveSchedulerWait* wait = |
|
785 new ( ELeave ) CActiveSchedulerWait; |
|
786 CleanupStack::PushL( wait ); |
|
787 |
|
788 if( references > 0 ) |
|
789 { |
|
790 // if counter is still > 0, update its value in MCS |
|
791 CMenuOperation* op = menuItem->SaveL( iWatcher->iStatus ); |
|
792 iWatcher->StopAndWatch( op, wait ); |
|
793 |
|
794 // Start the nested scheduler loop. |
|
795 wait->Start(); |
|
796 } |
|
797 else |
|
798 { |
|
799 // counter reached 0 -> item is not referenced by any shortcut |
|
800 // so remove it from MCS |
|
801 if( !iWatcher->IsActive() ) |
|
802 { |
|
803 CMenuOperation* op = |
|
804 iMenu.RemoveL( menuItem->Id(), iWatcher->iStatus ); |
|
805 iWatcher->StopAndWatch( op, wait ); |
|
806 |
|
807 // Start the nested scheduler loop. |
|
808 wait->Start(); |
|
809 } |
|
810 } |
|
811 |
|
812 CleanupStack::PopAndDestroy( wait ); |
|
813 wait = NULL; |
|
814 } |
|
815 |
|
816 CleanupStack::PopAndDestroy( menuItem ); |
|
817 menuItem = NULL; |
|
818 } |
|
819 } |
|
820 |
|
821 |
|
822 // --------------------------------------------------------------------------- |
|
823 // CMCSPluginEngine::UpdateMenuItemsRefCountL |
|
824 // Adds a given constant to a value of reference counter |
|
825 // --------------------------------------------------------------------------- |
|
826 // |
|
827 TInt CMCSPluginEngine::UpdateMenuItemsRefCountL( CMenuItem* aItem, |
|
828 const TInt aValueToAdd ) |
|
829 { |
|
830 TBool exists( EFalse ); |
|
831 CleanupStack::PushL( aItem ); |
|
832 TPtrC param( aItem->GetAttributeL( KMenuAttrRefcount, exists ) ); |
|
833 CleanupStack::Pop( aItem ); |
|
834 |
|
835 if ( exists ) |
|
836 { |
|
837 TInt references; |
|
838 TLex16 lextmp( param ); |
|
839 lextmp.Val( references ); |
|
840 references += aValueToAdd; |
|
841 TBuf<128> buf; |
|
842 buf.NumUC( references ); |
|
843 |
|
844 // set new ref_count |
|
845 CleanupStack::PushL( aItem ); |
|
846 aItem->SetAttributeL( KMenuAttrRefcount, buf); |
|
847 CleanupStack::Pop( aItem ); |
|
848 |
|
849 // return new ref_count |
|
850 return references; |
|
851 } |
|
852 |
|
853 return -1; |
|
854 } |
|
855 |
|
856 // --------------------------------------------------------------------------- |
|
857 // Creates bookmark menu item if it does not exist |
|
858 // --------------------------------------------------------------------------- |
|
859 // |
|
860 void CMCSPluginEngine::CreateRuntimeMenuItemsL() |
|
861 { |
|
862 iPluginData->CreateRuntimeMenuItemsL(); |
|
863 } |
|
864 |
|
865 // End of file |
830 // End of file |
866 |
|