satui/satplugin/aisatpluginsrc/caisatplugin.cpp
branchRCL_3
changeset 3 a4a774cb6ea7
parent 0 ff3b6d0fd310
equal deleted inserted replaced
0:ff3b6d0fd310 3:a4a774cb6ea7
     1 /*
     1 /*
     2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). 
     2 * Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). 
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    81     
    81     
    82     Release( iEvents );
    82     Release( iEvents );
    83     iEvents = NULL;
    83     iEvents = NULL;
    84 
    84 
    85     delete iEngine;
    85     delete iEngine;
    86     iEngine = NULL;
       
    87     
    86     
    88     iObservers.Close();
    87     iObservers.Close();
    89 
    88 
    90     TFLOGSTRING( "CAiSatPlugin::~CAiSatPlugin() exits" )
    89     TFLOGSTRING( "CAiSatPlugin::~CAiSatPlugin() exits" )
    91     }
    90     }
   181 // ---------------------------------------------------------------------------
   180 // ---------------------------------------------------------------------------
   182 //
   181 //
   183 void CAiSatPlugin::PublishSatL()
   182 void CAiSatPlugin::PublishSatL()
   184     {
   183     {
   185     TFLOGSTRING( "CAiSatPlugin::PublishSatL() starts" )
   184     TFLOGSTRING( "CAiSatPlugin::PublishSatL() starts" )
   186 
   185     
   187     TInt error( KErrNone );
   186     TInt error( KErrNone );
   188     TInt iconError( KErrNone );
   187     TInt iconError( KErrNone );
   189     TInt textError( KErrNone );
   188     TInt textError( KErrNone );
   190     TInt observers( iObservers.Count() );
   189     TInt observers( iObservers.Count() );
   191     TInt transactionId( KImplUidSatPlugin );
   190     TInt transactionId( KImplUidSatPlugin );
   284 
   283 
   285     TFLOGSTRING( "CAiSatPlugin::PublishSatL() exits" )
   284     TFLOGSTRING( "CAiSatPlugin::PublishSatL() exits" )
   286     }
   285     }
   287 
   286 
   288 // ---------------------------------------------------------------------------
   287 // ---------------------------------------------------------------------------
   289 // From class CAiContentPublisher
   288 // CAiSatPlugin::Start
   290 // Plug-in is requested to unload its engines due backup operation
   289 // 
   291 // ---------------------------------------------------------------------------
   290 // ---------------------------------------------------------------------------
   292 //
   291 //
   293 void CAiSatPlugin::Stop( TAiTransitionReason /* aReason */ )
   292 void CAiSatPlugin::Start( TStartReason /*aReason*/ )
   294     {
   293     {    
   295     TFLOGSTRING( "CAiSatPlugin::Stop starts - exits" )
   294     TFLOGSTRING( "CAiSatPlugin::Start() starts" )
   296     }
   295     
   297 
   296     iPublishRequired = ETrue;
   298 // ---------------------------------------------------------------------------
   297     
   299 // From class CAiContentPublisher
   298     TFLOGSTRING( "CAiSatPlugin::Start() exits" )
   300 // Plug-in is instructed that it is allowed to consume CPU resources
   299     }
   301 // ---------------------------------------------------------------------------
   300 
   302 //
   301 // ---------------------------------------------------------------------------
   303 void CAiSatPlugin::Resume( TAiTransitionReason aReason )
   302 // CAiSatPlugin::Stop
   304     {
   303 // 
   305     TFLOGSTRING2( "CAiSatPlugin::Resume reason %d", aReason )
   304 // ---------------------------------------------------------------------------
   306 
   305 //
   307     if ( EAiIdleForeground == aReason && !iEngine )
   306 void CAiSatPlugin::Stop( TStopReason /*aReason*/ )
   308         {
   307     {
   309         TRAP_IGNORE( iEngine = CAiSatEngine::NewL( *this ) )
   308     TFLOGSTRING( "CAiSatPlugin::Stop() starts - exits" )
   310         }
   309     }
   311         
   310 
   312     // If we change the Home Screen Theme we will got a EAiSystemStartup as 
   311 // ---------------------------------------------------------------------------
   313     // aReason.
   312 // CAiSatPlugin::Resume
   314     else if ( ( EAiGeneralThemeChanged == aReason || 
   313 // 
   315                 EAiSystemStartup == aReason ) &&
   314 // ---------------------------------------------------------------------------
   316                 iEngine )
   315 //
   317         {
   316 void CAiSatPlugin::Resume( TResumeReason aReason )
   318         TRAP_IGNORE( UpdateSatL() )
   317     {
   319         }
   318     TFLOGSTRING2( "CAiSatPlugin::Resume() reason %d", aReason )
   320         
   319 
       
   320     if ( aReason == EForeground )
       
   321         {
       
   322         if ( iPublishRequired )
       
   323             {
       
   324             iPublishRequired = EFalse;
       
   325             
       
   326             TRAP_IGNORE( UpdateSatL() )                       
       
   327             }
       
   328         }
       
   329             
   321     TFLOGSTRING( "CAiSatPlugin::Resume() exits" )
   330     TFLOGSTRING( "CAiSatPlugin::Resume() exits" )
   322     }
   331     }
   323 
   332 
   324 // ---------------------------------------------------------------------------
   333 // ---------------------------------------------------------------------------
   325 // From class CAiContentPublisher
   334 // CAiSatPlugin::Suspend
   326 // Plug-in is instructed that it is not allowed to consume CPU resources
   335 // 
   327 // ---------------------------------------------------------------------------
   336 // ---------------------------------------------------------------------------
   328 //
   337 //
   329 void CAiSatPlugin::Suspend( TAiTransitionReason /* aReason */ )
   338 void CAiSatPlugin::Suspend( TSuspendReason aReason )
   330     {
   339     {
   331     TFLOGSTRING( "CAiSatPlugin::Suspend starts - exits" )
   340     TFLOGSTRING( "CAiSatPlugin::Suspend() starts" )
   332     }
   341     
   333 
   342     if ( aReason == EGeneralThemeChange )
   334 // ---------------------------------------------------------------------------
   343         {
   335 // From class CAiContentPublisher
   344         iPublishRequired = ETrue;
   336 // The plug-in MUST maintain a registry of subscribers and send
   345         }
   337 // notification to all of them whenever the state changes or new content
   346     
   338 // is available
   347     TFLOGSTRING( "CAiSatPlugin::Suspend() exits" )
       
   348     }
       
   349 
       
   350 // ---------------------------------------------------------------------------
       
   351 // CAiSatPlugin::SubscribeL
       
   352 // 
   339 // ---------------------------------------------------------------------------
   353 // ---------------------------------------------------------------------------
   340 //
   354 //
   341 void CAiSatPlugin::SubscribeL( MAiContentObserver& aObserver )
   355 void CAiSatPlugin::SubscribeL( MAiContentObserver& aObserver )
   342     {
   356     {
   343     TFLOGSTRING( "CAiSatPlugin::SubscribeL() starts" )
   357     TFLOGSTRING( "CAiSatPlugin::SubscribeL() starts" )
   346 
   360 
   347     TFLOGSTRING( "CAiSatPlugin::SubscribeL() exits" )
   361     TFLOGSTRING( "CAiSatPlugin::SubscribeL() exits" )
   348     }
   362     }
   349 
   363 
   350 // ---------------------------------------------------------------------------
   364 // ---------------------------------------------------------------------------
   351 // From class CAiContentPublisher
   365 // CAiSatPlugin::ConfigureL
   352 // Plug-ins take ownership of the settings array, so it must either
   366 // 
   353 // store it in a member or free it.
       
   354 // ---------------------------------------------------------------------------
   367 // ---------------------------------------------------------------------------
   355 //
   368 //
   356 void CAiSatPlugin::ConfigureL( RAiSettingsItemArray& aSettings )
   369 void CAiSatPlugin::ConfigureL( RAiSettingsItemArray& aSettings )
   357     {
   370     {
   358     TFLOGSTRING( "CAiSatPlugin::ConfigureL() starts" )
   371     TFLOGSTRING( "CAiSatPlugin::ConfigureL() starts" )
   368             MAiPluginSettingsItem& item = settings->AiPluginSettingsItem();
   381             MAiPluginSettingsItem& item = settings->AiPluginSettingsItem();
   369             item.SetValueL( item.Value(), EFalse );
   382             item.SetValueL( item.Value(), EFalse );
   370             }
   383             }
   371         TFLOGSTRING2( "CAiSatPlugin::ConfigureL  i: %d", i )    
   384         TFLOGSTRING2( "CAiSatPlugin::ConfigureL  i: %d", i )    
   372         }
   385         }
   373 
   386 	
   374     TFLOGSTRING( "CAiSatPlugin::ConfigureL() exits" )
   387     TFLOGSTRING( "CAiSatPlugin::ConfigureL() exits" )
   375     }
   388     }
   376 
   389 
   377 // ---------------------------------------------------------------------------
   390 // ---------------------------------------------------------------------------
   378 // From class CAiContentPublisher
   391 // CAiSatPlugin::GetProperty
   379 // Returns the extension interface. Actual type depends on the passed
   392 // 
   380 // aUid argument.
   393 // ---------------------------------------------------------------------------
   381 // ---------------------------------------------------------------------------
   394 //
   382 //
   395 TAny* CAiSatPlugin::GetProperty( TProperty aProperty )
   383 TAny* CAiSatPlugin::Extension( TUid aUid )
   396     {
   384     {
   397     TFLOGSTRING( "CAiSatPlugin::GetProperty() starts" )
   385     TFLOGSTRING( "CAiSatPlugin::Extension() starts" )
   398     
   386 
   399     TAny* property( NULL );
   387     MAiPropertyExtension* extension = NULL;
   400     
   388 
   401     TFLOGSTRING2( "CAiSatPlugin::GetProperty aProperty: %d", aProperty )
   389     if ( KExtensionUidProperty == aUid )
   402 
   390         {
   403     if ( aProperty == EPublisherContent )
   391         extension = static_cast<MAiPropertyExtension*>( this );
   404         {            
   392         }
   405         property = iContent;            
   393 
   406         }
   394     TFLOGSTRING( "CAiSatPlugin::Extension() exits" )
   407     else if ( aProperty == EPublisherResources )
   395     return extension;
   408         {
   396     }
   409         property = iResources;
   397 
   410         }
   398 // ---------------------------------------------------------------------------
   411     else if ( aProperty == EPublisherEvents )
   399 // From class MAiPropertyExtension
   412         {
   400 // Read property of publisher plug-in.
   413         property = iEvents;
   401 // ---------------------------------------------------------------------------
   414         }
   402 //
   415 
   403 TAny* CAiSatPlugin::GetPropertyL( TInt aProperty )
   416     TFLOGSTRING( "CAiSatPlugin::GetProperty() exits" )
   404     {
       
   405     TFLOGSTRING( "CAiSatPlugin::GetPropertyL() starts" )
       
   406 
       
   407     TAny* property = NULL;
       
   408     TFLOGSTRING2( "CAiSatPlugin::GetPropertyL  aProperty: %d", aProperty )
       
   409     switch ( aProperty )
       
   410         {
       
   411         case EAiPublisherInfo:
       
   412             {
       
   413             property = static_cast<TAiPublisherInfo*>( &iInfo );
       
   414             break;
       
   415             }
       
   416 
       
   417         case EAiPublisherContent:
       
   418             {
       
   419             property = static_cast<MAiContentItemIterator*>( iContent );
       
   420             break;
       
   421             }
       
   422 
       
   423         case EAiPublisherResources:
       
   424             {
       
   425             property = static_cast<MAiContentItemIterator*>( iResources );
       
   426             break;
       
   427             }
       
   428 
       
   429         case EAiPublisherEvents:
       
   430             {
       
   431             property = static_cast<MAiContentItemIterator*>( iEvents );
       
   432             break;
       
   433             }
       
   434         default:
       
   435             break;
       
   436         }
       
   437 
       
   438     TFLOGSTRING( "CAiSatPlugin::GetPropertyL() exits" )
       
   439 
   417 
   440     return property;
   418     return property;
   441     }
       
   442 
       
   443 // ---------------------------------------------------------------------------
       
   444 // From class MAiPropertyExtension
       
   445 // Write property value to optimize the content model.
       
   446 // ---------------------------------------------------------------------------
       
   447 //
       
   448 void CAiSatPlugin::SetPropertyL( TInt aProperty, TAny* aValue )
       
   449     {
       
   450     TFLOGSTRING( "CAiSatPlugin::SetPropertyL() starts" )
       
   451 
       
   452     if ( EAiPublisherInfo == aProperty )
       
   453         {
       
   454         TFLOGSTRING( "CAiSatPlugin::SetPropertyL() EAiPublisherInfo" )
       
   455         const TAiPublisherInfo* info =
       
   456             static_cast<const TAiPublisherInfo*>( aValue );
       
   457         if ( info )
       
   458             {
       
   459             iInfo = *info;
       
   460             }
       
   461         }
       
   462 
       
   463     TFLOGSTRING( "CAiSatPlugin::SetPropertyL() exits" )
       
   464     }
   419     }
   465 
   420 
   466 // ---------------------------------------------------------
   421 // ---------------------------------------------------------
   467 // This method is called from the engine, when the P&S
   422 // This method is called from the engine, when the P&S
   468 // data content has been changed. Method call is made through
   423 // data content has been changed. Method call is made through
   503 //
   458 //
   504 void CAiSatPlugin::ConstructL()
   459 void CAiSatPlugin::ConstructL()
   505     {
   460     {
   506     TFLOGSTRING( "CAiSatPlugin::ConstructL() starts" )
   461     TFLOGSTRING( "CAiSatPlugin::ConstructL() starts" )
   507 
   462 
   508     _LIT(KSatName, "SAT");
       
   509 
       
   510     iInfo.iUid.iUid = AI_UID_ECOM_IMPLEMENTATION_CONTENTPUBLISHER_SATPLUGIN;
       
   511     iInfo.iName.Copy( KSatName );
       
   512 
       
   513     iContent = AiUtility::CreateContentItemArrayIteratorL( KSatContent );
   463     iContent = AiUtility::CreateContentItemArrayIteratorL( KSatContent );
   514     iResources = AiUtility::CreateContentItemArrayIteratorL( KSatResources );
   464     iResources = AiUtility::CreateContentItemArrayIteratorL( KSatResources );
   515     iEvents = AiUtility::CreateContentItemArrayIteratorL( KSatEvents );
   465     iEvents = AiUtility::CreateContentItemArrayIteratorL( KSatEvents );
   516 
   466 
   517     iEngine = CAiSatEngine::NewL( *this );
   467     iEngine = CAiSatEngine::NewL( *this );