idlefw/plugins/sapidataplugin/src/sapidataplugin.cpp
branchRCL_3
changeset 19 edd621764147
parent 15 a0713522ab97
child 23 ace62b58f4b2
equal deleted inserted replaced
16:b276298d5729 19:edd621764147
    77 // ---------------------------------------------------------------------------
    77 // ---------------------------------------------------------------------------
    78 // Default constructor
    78 // Default constructor
    79 // ---------------------------------------------------------------------------
    79 // ---------------------------------------------------------------------------
    80 //
    80 //
    81 CSapiDataPlugin::CSapiDataPlugin()
    81 CSapiDataPlugin::CSapiDataPlugin()
    82     : iNetworkStatus( EUnknown ), iPluginState( ENone )
    82     : iNetworkStatus( EUnknown ), iPluginState( EStopped )
    83     {
    83     {
    84     }
    84     }
    85     
    85     
    86 // ---------------------------------------------------------------------------
    86 // ---------------------------------------------------------------------------
    87 // Symbian 2nd phase constructor can leave
    87 // Symbian 2nd phase constructor can leave
   118         }
   118         }
   119     
   119     
   120     iIconArray.Reset();
   120     iIconArray.Reset();
   121     iRfs.Close();
   121     iRfs.Close();
   122     }
   122     }
   123 
       
   124 
   123 
   125 // ---------------------------------------------------------------------------
   124 // ---------------------------------------------------------------------------
   126 // Publishes widget's texts and images
   125 // Publishes widget's texts and images
   127 // ---------------------------------------------------------------------------
   126 // ---------------------------------------------------------------------------
   128 //
   127 //
   323 			 }
   322 			 }
   324 		}
   323 		}
   325 	return id;
   324 	return id;
   326 	}
   325 	}
   327  
   326  
   328 
       
   329 // ---------------------------------------------------------------------------
   327 // ---------------------------------------------------------------------------
   330 // Gets type of a content
   328 // Gets type of a content
   331 // ---------------------------------------------------------------------------
   329 // ---------------------------------------------------------------------------
   332 //
   330 //
   333 const TDesC& CSapiDataPlugin::GetTypeL(TDesC& aObjectId )
   331 const TDesC& CSapiDataPlugin::GetTypeL(TDesC& aObjectId )
   417 //
   415 //
   418 // ----------------------------------------------------------------------------
   416 // ----------------------------------------------------------------------------
   419 //
   417 //
   420 void CSapiDataPlugin::Start( TStartReason aReason )
   418 void CSapiDataPlugin::Start( TStartReason aReason )
   421     {
   419     {
   422     if( aReason == ESystemStartup )
   420     iPluginState = EStarted;
   423         {
   421     
   424         TRAP_IGNORE( PublishL() );
   422     TRAP_IGNORE( StartL( aReason ) );
   425         TRAP_IGNORE( iData->SetStartupReasonL( KSystemStartup ));
   423     }
   426         }
   424 
   427     else if( aReason == EPageStartup )
   425 // ----------------------------------------------------------------------------
   428         {
   426 // CSapiDataPlugin::StartL
   429         TRAP_IGNORE( iData->SetStartupReasonL( KPageStartup ));
   427 //
   430         }
   428 // ----------------------------------------------------------------------------
   431     else if( aReason == EPluginStartup )
   429 //
   432         {
   430 void CSapiDataPlugin::StartL( TStartReason aReason )
   433         TRAP_IGNORE( PublishL() );
   431     {       
   434         TRAP_IGNORE( iData->SetStartupReasonL( KPluginStartup));
   432     // Activate the publisher
   435         }
   433     iData->ChangePublisherStatusL( KActive );
   436 
   434     
   437     // Listen for publisher registration to resend the events 
   435     if ( aReason == ESystemStartup )
   438     TRAP_IGNORE( iData->RegisterPublisherObserverL() );
   436         {
       
   437         PublishL();
       
   438         iData->SetStartupReasonL( KSystemStartup );
       
   439         }
       
   440     else if ( aReason == EPageStartup )
       
   441         {
       
   442         iData->SetStartupReasonL( KPageStartup );
       
   443         }
       
   444     else if ( aReason == EPluginStartup )
       
   445         {
       
   446         PublishL();
       
   447         iData->SetStartupReasonL( KPluginStartup );
       
   448         }
       
   449 
       
   450     if ( !iPubObsRegistered )
       
   451         {
       
   452         // Listen for publisher registration to resend the events 
       
   453         iData->RegisterPublisherObserverL() ;
       
   454 
       
   455         // Execute the active trigger 
       
   456         iData->TriggerActiveL();    
       
   457         
       
   458         iPubObsRegistered = ETrue;
       
   459         }    
   439     }
   460     }
   440 
   461 
   441 // ----------------------------------------------------------------------------
   462 // ----------------------------------------------------------------------------
   442 // CSapiDataPlugin::Stop
   463 // CSapiDataPlugin::Stop
   443 //
   464 //
   444 // ----------------------------------------------------------------------------
   465 // ----------------------------------------------------------------------------
   445 //
   466 //
   446 void CSapiDataPlugin::Stop( TStopReason aReason )
   467 void CSapiDataPlugin::Stop( TStopReason aReason )
   447     {
   468     {
   448     if( aReason == ESystemShutdown )
   469     TRAP_IGNORE( StopL( aReason ) );
   449         {
   470     
   450         TRAP_IGNORE( iData->ChangePublisherStatusL( KSystemShutdown ));
   471     iPluginState = EStopped;
   451         }
   472     }
   452     else if( aReason == EPageShutdown )
   473 
   453         {
   474 // ----------------------------------------------------------------------------
   454         TRAP_IGNORE( iData->ChangePublisherStatusL( KPageShutdown ));
   475 // CSapiDataPlugin::StopL
   455         }
   476 //
   456     else if( aReason == EPluginShutdown )
   477 // ----------------------------------------------------------------------------
   457         {
   478 //
   458         TRAP_IGNORE( iData->ChangePublisherStatusL( KPluginShutdown ));
   479 void CSapiDataPlugin::StopL( TStopReason aReason )
       
   480     {
       
   481     if ( aReason == ESystemShutdown )
       
   482         {
       
   483         iData->ChangePublisherStatusL( KSystemShutdown );
       
   484         }
       
   485     else if ( aReason == EPageShutdown )
       
   486         {
       
   487         iData->ChangePublisherStatusL( KPageShutdown );
       
   488         }
       
   489     else if ( aReason == EPluginShutdown )
       
   490         {
       
   491         iData->ChangePublisherStatusL( KPluginShutdown );
   459         }
   492         }
   460 
   493 
   461     if ( iData )
   494     if ( iData )
   462         {
   495         {
   463         TRAP_IGNORE( iData->ChangePublisherStatusL( KDeActive ));
   496         iData->ChangePublisherStatusL( KDeActive );
   464         }
   497         }          
   465     }
   498     }
   466 
   499 
   467 // ----------------------------------------------------------------------------
   500 // ----------------------------------------------------------------------------
   468 // CSapiDataPlugin::Resume
   501 // CSapiDataPlugin::Resume
   469 //
   502 //
   470 // ----------------------------------------------------------------------------
   503 // ----------------------------------------------------------------------------
   471 //
   504 //
   472 void CSapiDataPlugin::Resume( TResumeReason aReason )
   505 void CSapiDataPlugin::Resume( TResumeReason aReason )
   473     {
   506     {
   474     if ( aReason == EForeground )
   507     if ( aReason == EForeground && iPluginState != EStopped )
   475         {
   508         {
   476         iPluginState = EResume;
   509         iPluginState = EResume;
   477         TRAP_IGNORE( iData->ChangePublisherStatusL( KResume ));
   510         TRAP_IGNORE( iData->ChangePublisherStatusL( KResume ));
   478         }
   511         }
   479     }
   512     }
   483 //
   516 //
   484 // ----------------------------------------------------------------------------
   517 // ----------------------------------------------------------------------------
   485 //
   518 //
   486 void CSapiDataPlugin::Suspend( TSuspendReason aReason )
   519 void CSapiDataPlugin::Suspend( TSuspendReason aReason )
   487     {
   520     {
   488     if ( aReason == EBackground )
   521     if ( aReason == EBackground && iPluginState != EStopped )
   489         {
   522         {
   490         iPluginState = ESuspend;
   523         iPluginState = ESuspend;
   491         TRAP_IGNORE( iData->ChangePublisherStatusL( KSuspend ));
   524         TRAP_IGNORE( iData->ChangePublisherStatusL( KSuspend ));
   492         }    
   525         }    
   493     }
   526     }
   497 //
   530 //
   498 // ----------------------------------------------------------------------------
   531 // ----------------------------------------------------------------------------
   499 //
   532 //
   500 void CSapiDataPlugin::SetOnline()
   533 void CSapiDataPlugin::SetOnline()
   501     {
   534     {
   502     if ( iNetworkStatus != EOnline )
   535     if ( iNetworkStatus != EOnline && iPluginState != EStopped )
   503         {
   536         {
   504         iNetworkStatus = EOnline;
   537         iNetworkStatus = EOnline;
   505         TRAP_IGNORE( iData->ChangePublisherStatusL( KOnLine ));
   538         TRAP_IGNORE( iData->ChangePublisherStatusL( KOnLine ));
   506         }
   539         }
   507     }
   540     }
   511 //
   544 //
   512 // ----------------------------------------------------------------------------
   545 // ----------------------------------------------------------------------------
   513 //
   546 //
   514 void CSapiDataPlugin::SetOffline()
   547 void CSapiDataPlugin::SetOffline()
   515     {
   548     {
   516     if ( iNetworkStatus != EOffline )
   549     if ( iNetworkStatus != EOffline && iPluginState != EStopped )
   517         {
   550         {
   518         iNetworkStatus = EOffline;
   551         iNetworkStatus = EOffline;
   519         TRAP_IGNORE( iData->ChangePublisherStatusL( KOffLine ));
   552         TRAP_IGNORE( iData->ChangePublisherStatusL( KOffLine ));
   520         }
   553         }
   521     }
   554     }
   615     
   648     
   616         iData->SetContentIdL( PublisherInfo().Namespace() );
   649         iData->SetContentIdL( PublisherInfo().Namespace() );
   617         
   650         
   618         // Configurations 
   651         // Configurations 
   619         iData->ConfigureL( configurationItemsArr );
   652         iData->ConfigureL( configurationItemsArr );
   620         
       
   621         iPluginState = ESuspend;
       
   622 
   653 
   623         // Listen the publisher content update
   654         // Listen the publisher content update
   624         iData->RegisterContentObserverL();
   655         iData->RegisterContentObserverL();              
   625         
       
   626         // Activate the publisher
       
   627         iData->ChangePublisherStatusL( KActive );
       
   628         // Execute the active trigger 
       
   629         iData->TriggerActiveL();
       
   630         
       
   631         }
   656         }
   632     
   657     
   633     contentItemsArr.Reset();
   658     contentItemsArr.Reset();
   634     configurationItemsArr.Reset();
   659     configurationItemsArr.Reset();
   635    
   660    
   642 //
   667 //
   643 // ----------------------------------------------------------------------------
   668 // ----------------------------------------------------------------------------
   644 //
   669 //
   645 void CSapiDataPlugin::SetProperty( TProperty aProperty, TAny* aAny )
   670 void CSapiDataPlugin::SetProperty( TProperty aProperty, TAny* aAny )
   646     {
   671     {
   647     if (aProperty == ECpsCmdBuffer )
   672     if ( aProperty == ECpsCmdBuffer )
   648         {
   673         {
   649         iData->SetCommandBuffer( aAny );
   674         iData->SetCommandBuffer( aAny );
   650         }
   675         }
   651     }
   676     }
   652 // ----------------------------------------------------------------------------
   677 // ----------------------------------------------------------------------------