idlefw/plugins/wrtdataplugin/src/wrtdataplugin.cpp
branchRCL_3
changeset 19 edd621764147
parent 16 b276298d5729
child 23 ace62b58f4b2
equal deleted inserted replaced
16:b276298d5729 19:edd621764147
   136 //
   136 //
   137 // ----------------------------------------------------------------------------
   137 // ----------------------------------------------------------------------------
   138 //
   138 //
   139 void CWrtDataPlugin::Start( TStartReason aReason )
   139 void CWrtDataPlugin::Start( TStartReason aReason )
   140     {
   140     {
       
   141     iStopped = EFalse;
       
   142     
   141     if( aReason == ESystemStartup || 
   143     if( aReason == ESystemStartup || 
   142         aReason == EPluginStartup )
   144         aReason == EPluginStartup )
   143         {
   145         {
   144         // Publish the initial data
   146         // Publish the initial data
   145         TRAP_IGNORE( PublishInitialDataL() );
   147         TRAP_IGNORE( PublishInitialDataL() );
   156     if( aReason == EPluginShutdown ||
   158     if( aReason == EPluginShutdown ||
   157         aReason == ESystemShutdown )
   159         aReason == ESystemShutdown )
   158         {
   160         {
   159         TRAP_IGNORE(iData->NotifyPublisherL( KDeActive ));
   161         TRAP_IGNORE(iData->NotifyPublisherL( KDeActive ));
   160         }
   162         }
       
   163     
       
   164     iStopped = ETrue;
   161     }
   165     }
   162 
   166 
   163 // ----------------------------------------------------------------------------
   167 // ----------------------------------------------------------------------------
   164 // CWrtDataPlugin::Resume
   168 // CWrtDataPlugin::Resume
   165 //
   169 //
   166 // ----------------------------------------------------------------------------
   170 // ----------------------------------------------------------------------------
   167 //
   171 //
   168 void CWrtDataPlugin::Resume( TResumeReason aReason )
   172 void CWrtDataPlugin::Resume( TResumeReason aReason )
   169     {
   173     {
   170     if ( aReason == EForeground )
   174     if ( aReason == EForeground && !iStopped )
   171         {
   175         {
   172         iPluginState = EResume;
   176         iPluginState = EResume;
   173 
   177 
   174         TRAP_IGNORE( iData->NotifyPublisherL( KResume ));        
   178         TRAP_IGNORE( iData->NotifyPublisherL( KResume ));        
   175         }    
   179         }    
   180 //
   184 //
   181 // ----------------------------------------------------------------------------
   185 // ----------------------------------------------------------------------------
   182 //
   186 //
   183 void CWrtDataPlugin::Suspend( TSuspendReason aReason )
   187 void CWrtDataPlugin::Suspend( TSuspendReason aReason )
   184     {    
   188     {    
   185     if ( aReason == EBackground )
   189     if ( aReason == EBackground && !iStopped )
   186         {
   190         {
   187         iPluginState = ESuspend;
   191         iPluginState = ESuspend;
   188         
   192         
   189         TRAP_IGNORE ( iData->NotifyPublisherL( KSuspend ));        
   193         TRAP_IGNORE ( iData->NotifyPublisherL( KSuspend ));        
   190         }        
   194         }        
   195 //
   199 //
   196 // ----------------------------------------------------------------------------
   200 // ----------------------------------------------------------------------------
   197 //
   201 //
   198 void CWrtDataPlugin::SetOnline()
   202 void CWrtDataPlugin::SetOnline()
   199     {    
   203     {    
   200     iNetworkStatus = EOnline;
   204     if ( !iStopped )
   201     TRAP_IGNORE( iData->NotifyPublisherL( KOnLine ));            
   205         {
       
   206         iNetworkStatus = EOnline;
       
   207         TRAP_IGNORE( iData->NotifyPublisherL( KOnLine ));                
       
   208         }
   202     }
   209     }
   203 
   210 
   204 // ----------------------------------------------------------------------------
   211 // ----------------------------------------------------------------------------
   205 // CWrtDataPlugin::SetOffline
   212 // CWrtDataPlugin::SetOffline
   206 //
   213 //
   207 // ----------------------------------------------------------------------------
   214 // ----------------------------------------------------------------------------
   208 //
   215 //
   209 void CWrtDataPlugin::SetOffline()
   216 void CWrtDataPlugin::SetOffline()
   210     {
   217     {
   211     iNetworkStatus = EOffline;
   218     if ( !iStopped )
   212     TRAP_IGNORE( iData->NotifyPublisherL( KOffLine ));            
   219         {   
       
   220         iNetworkStatus = EOffline;
       
   221         TRAP_IGNORE( iData->NotifyPublisherL( KOffLine ));
       
   222         }
   213     }
   223     }
   214 
   224 
   215 // ----------------------------------------------------------------------------
   225 // ----------------------------------------------------------------------------
   216 // CWrtDataPlugin::SubscribeL
   226 // CWrtDataPlugin::SubscribeL
   217 //
   227 //
   363 //
   373 //
   364 // ----------------------------------------------------------------------------
   374 // ----------------------------------------------------------------------------
   365 //
   375 //
   366 TBool CWrtDataPlugin::IsActive() const
   376 TBool CWrtDataPlugin::IsActive() const
   367     {
   377     {
   368     return iPluginState == EResume;
   378     return iPluginState == EResume && !iStopped;
   369     }
   379     }
   370 
   380 
   371 // ----------------------------------------------------------------------------
   381 // ----------------------------------------------------------------------------
   372 // CWrtDataPlugin::Data
   382 // CWrtDataPlugin::Data
   373 //
   383 //
   808         if ( !iTimer )
   818         if ( !iTimer )
   809             {
   819             {
   810             iTimer = CPeriodic::NewL( CActive::EPriorityStandard );
   820             iTimer = CPeriodic::NewL( CActive::EPriorityStandard );
   811             }
   821             }
   812         
   822         
   813         if ( !iTimer->IsActive() )
   823         if ( iTimer && !iTimer->IsActive() )
   814             {
   824             {
   815             TTimeIntervalMicroSeconds32 delay( KTryAgainDelay );
   825             TTimeIntervalMicroSeconds32 delay( KTryAgainDelay );
   816             iTimer->Start( delay, delay, TCallBack( Timeout, this ) );
   826             iTimer->Start( delay, delay, TCallBack( Timeout, this ) );
   817             }
   827             }
   818         );
   828         );