musichomescreen_multiview/musiccontentpublisher/src/musiccontentpublisher.cpp
branchRCL_3
changeset 24 26a1709b9fec
parent 15 a1247965635c
equal deleted inserted replaced
23:455f89b7fcc5 24:26a1709b9fec
    49 
    49 
    50 _LIT8( KMyActive, "active" );
    50 _LIT8( KMyActive, "active" );
    51 _LIT8( KMyDeActive, "deactive");
    51 _LIT8( KMyDeActive, "deactive");
    52 _LIT8( KMySuspend, "suspend");
    52 _LIT8( KMySuspend, "suspend");
    53 _LIT8( KMyResume, "resume");
    53 _LIT8( KMyResume, "resume");
       
    54 _LIT8( KMyPluginshutdown, "pluginshutdown");
       
    55 _LIT8( KMySystemshutdown, "systemshutdown");
    54 _LIT8( KMyActionMap, "action_map" );
    56 _LIT8( KMyActionMap, "action_map" );
    55 _LIT8( KMyItem, "item" );
    57 _LIT8( KMyItem, "item" );
    56 _LIT8( KMyAdd, "Add" );
    58 _LIT8( KMyAdd, "Add" );
    57 _LIT8( KMyMusic, "music");
    59 _LIT8( KMyMusic, "music");
    58 _LIT8( KMyItemId, "item_id" );
    60 _LIT8( KMyItemId, "item_id" );
    66 _LIT8( KMessage, "message" );
    68 _LIT8( KMessage, "message" );
    67 
    69 
    68 //for application launcher AHPlugin
    70 //for application launcher AHPlugin
    69 const TInt KMmUid3AsTInt( 0x101f4cd2 );
    71 const TInt KMmUid3AsTInt( 0x101f4cd2 );
    70 const TInt KMSGUidAsTInt( 0x10003A39 );
    72 const TInt KMSGUidAsTInt( 0x10003A39 );
       
    73 const TInt KDelayTime( 6000000 ); // CPeriodic timer
    71 _LIT8( KAdditionalData, "additional_data" );
    74 _LIT8( KAdditionalData, "additional_data" );
    72 _LIT( KLaunchApp, "launch_application" );
    75 _LIT( KLaunchApp, "launch_application" );
    73 _LIT( KMessageWithTail, "message_with_tail" );
    76 _LIT( KMessageWithTail, "message_with_tail" );
    74 _LIT8( KMessageForMMOpenMusicSuiteWithHide, "mm://root/musicsuite?exit=hide");
    77 _LIT8( KMessageForMMOpenMusicSuiteWithHide, "mm://root/musicsuite?exit=hide");
    75 
    78 
   145     CleanupStack::PopAndDestroy(&resourceFile);
   148     CleanupStack::PopAndDestroy(&resourceFile);
   146     CleanupStack::PopAndDestroy(&fs);
   149     CleanupStack::PopAndDestroy(&fs);
   147     MPX_DEBUG1("CMusicContentPublisher::ConstructL resources loaded");
   150     MPX_DEBUG1("CMusicContentPublisher::ConstructL resources loaded");
   148     
   151     
   149     // connect to the skin server, to receive skin changed event.
   152     // connect to the skin server, to receive skin changed event.
   150     iAknsSrvSession.Connect(this);
   153     User::LeaveIfError(iAknsSrvSession.Connect(this));
   151     
   154     
   152     // enable skin.
   155     // enable skin.
   153     AknsUtils::InitSkinSupportL();
   156     AknsUtils::InitSkinSupportL();
   154     	
   157     	
   155     iDeferredPublish = new (ELeave) CAsyncCallBack(TCallBack(DoPublish, this), 
   158     iDeferredPublish = new (ELeave) CAsyncCallBack(TCallBack(DoPublish, this), 
   176             KAll, 
   179             KAll, 
   177             KAll );
   180             KAll );
   178     
   181     
   179     MPX_DEBUG1("CMusicContentPublisher::ConstructL initializing content");
   182     MPX_DEBUG1("CMusicContentPublisher::ConstructL initializing content");
   180     PublishDefaultL();
   183     PublishDefaultL();
       
   184     iUpdateIdle = CPeriodic::NewL(CActive::EPriorityStandard);
   181     
   185     
   182     MPX_DEBUG1("CMusicContentPublisher::ConstructL --->");
   186     MPX_DEBUG1("CMusicContentPublisher::ConstructL --->");
   183     }
   187     }
   184 
   188 
   185 // ---------------------------------------------------------------------------
   189 // ---------------------------------------------------------------------------
   227     MPX_DEBUG1("CMusicContentPublisher::~CMusicContentPublisher --->");
   231     MPX_DEBUG1("CMusicContentPublisher::~CMusicContentPublisher --->");
   228     if ( iInstanceId )
   232     if ( iInstanceId )
   229     	{
   233     	{
   230     	delete iInstanceId;
   234     	delete iInstanceId;
   231     	}
   235     	}
       
   236     
       
   237     if ( iUpdateIdle )
       
   238         {
       
   239         iUpdateIdle->Cancel();
       
   240         delete iUpdateIdle;
       
   241         }    
   232     }
   242     }
   233 
   243 
   234 // ---------------------------------------------------------------------------
   244 // ---------------------------------------------------------------------------
   235 // 
   245 // 
   236 // ---------------------------------------------------------------------------
   246 // ---------------------------------------------------------------------------
   799             iPublishingActionMap.Close();
   809             iPublishingActionMap.Close();
   800             }
   810             }
   801         iActivePlugin = aPlugin;
   811         iActivePlugin = aPlugin;
   802         }
   812         }
   803     }
   813     }
       
   814 
       
   815 // ---------------------------------------------------------------------------
       
   816 // Callback function for CPeriodic.
       
   817 // ---------------------------------------------------------------------------
       
   818 //   
       
   819 TInt CMusicContentPublisher::UpdateCallback(TAny* aContentPublisher)
       
   820     {
       
   821     MPX_FUNC("CMusicContentPublisher::UpdateCallback");
       
   822     
       
   823     CMusicContentPublisher* self = 
       
   824             reinterpret_cast<CMusicContentPublisher*> (aContentPublisher);
       
   825     self->DoUpdate();
       
   826     
       
   827     return EFalse;
       
   828     }
       
   829 
       
   830 // ---------------------------------------------------------------------------
       
   831 // Create plugin manager.
       
   832 // ---------------------------------------------------------------------------
       
   833 //   
       
   834 void CMusicContentPublisher::DoUpdate()
       
   835     {
       
   836     MPX_FUNC("CMusicContentPublisher::DoUpdate")
       
   837     
       
   838     TRAP_IGNORE( iPluginManager = CPluginManager::NewL(
       
   839             TUid::Uid( KMCPPluginUid ), 
       
   840             static_cast<MMCPPluginObserver*>( this ),
       
   841             this ));    
       
   842     iUpdateIdle->Cancel();
       
   843     }
       
   844 
   804 // ---------------------------------------------------------------------------
   845 // ---------------------------------------------------------------------------
   805 // From CContentHarvesterPlugin
   846 // From CContentHarvesterPlugin
   806 // This function updates information in CPS storage
   847 // This function updates information in CPS storage
   807 // ---------------------------------------------------------------------------
   848 // ---------------------------------------------------------------------------
   808 //    
   849 //    
   809 void CMusicContentPublisher::UpdateL() 
   850 void CMusicContentPublisher::UpdateL() 
   810     {
   851     {
   811     MPX_FUNC("CMusicContentPublisher::UpdateL");
   852     MPX_FUNC("CMusicContentPublisher::UpdateL");
   812     if ( !iPluginManager )
   853         
       
   854     // Construct plugin manager asynchronously for not to block the caller
       
   855     // thread
       
   856     if ( !iPluginManager && !iUpdateIdle->IsActive())
   813         {
   857         {
   814         MPX_DEBUG1("CMusicContentPublisher::UpdateL creating the plugin manager");
   858         MPX_DEBUG1("CMusicContentPublisher::UpdateL creating the plugin manager");
   815         iPluginManager = CPluginManager::NewL(
   859         
   816                 TUid::Uid( KMCPPluginUid ), 
   860         iUpdateIdle->Start(KDelayTime, KDelayTime, TCallBack(UpdateCallback,this));
   817                 static_cast<MMCPPluginObserver*>( this ),
       
   818                 this );
       
   819         }
   861         }
   820     }
   862     }
   821 
   863 
   822 // ---------------------------------------------------------------------------
   864 // ---------------------------------------------------------------------------
   823 // From MAknsSkinChangeObserver.
   865 // From MAknsSkinChangeObserver.
   847         iInstanceId = aContentId.AllocL();
   889         iInstanceId = aContentId.AllocL();
   848         DoPublishAllL();
   890         DoPublishAllL();
   849         }
   891         }
   850     else if ( aTrigger ==  KMyDeActive )
   892     else if ( aTrigger ==  KMyDeActive )
   851         {
   893         {
   852         DoPublishDeleteAllL();
   894         delete iInstanceId;  
   853         delete iInstanceId;
       
   854         iInstanceId = NULL;
   895         iInstanceId = NULL;
   855         }
   896         }
   856     else if ( aTrigger ==  KMySuspend && iWidgetForeground)
   897     else if ( aTrigger ==  KMySuspend && iWidgetForeground)
   857         {
   898         {
   858         iWidgetForeground = EFalse;
   899         iWidgetForeground = EFalse;
   860     else if ( aTrigger ==  KMyResume && !iWidgetForeground)
   901     else if ( aTrigger ==  KMyResume && !iWidgetForeground)
   861         {
   902         {
   862         iWidgetForeground = ETrue;
   903         iWidgetForeground = ETrue;
   863         DoPublishModifiedL();
   904         DoPublishModifiedL();
   864         }
   905         }
       
   906     else if ( aTrigger == KMyPluginshutdown || aTrigger == KMySystemshutdown )
       
   907         {
       
   908         DoPublishDeleteAllL();   // Delete the data only if widget is removed or Phone is shutting down.
       
   909 		}
       
   910 
   865     MPX_DEBUG1("<--CMusicContentPublisher::HandlePublisherNotificationL");
   911     MPX_DEBUG1("<--CMusicContentPublisher::HandlePublisherNotificationL");
   866     }
   912     }
   867 
   913 
   868 
   914 
   869 //  End of File
   915 //  End of File