satui/satplugin/aisatpluginsrc/caisatplugin.cpp
branchRCL_3
changeset 3 a4a774cb6ea7
parent 0 ff3b6d0fd310
--- a/satui/satplugin/aisatpluginsrc/caisatplugin.cpp	Tue Feb 02 01:11:09 2010 +0200
+++ b/satui/satplugin/aisatpluginsrc/caisatplugin.cpp	Fri Feb 19 23:21:58 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). 
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -83,7 +83,6 @@
     iEvents = NULL;
 
     delete iEngine;
-    iEngine = NULL;
     
     iObservers.Close();
 
@@ -183,7 +182,7 @@
 void CAiSatPlugin::PublishSatL()
     {
     TFLOGSTRING( "CAiSatPlugin::PublishSatL() starts" )
-
+    
     TInt error( KErrNone );
     TInt iconError( KErrNone );
     TInt textError( KErrNone );
@@ -286,56 +285,71 @@
     }
 
 // ---------------------------------------------------------------------------
-// From class CAiContentPublisher
-// Plug-in is requested to unload its engines due backup operation
+// CAiSatPlugin::Start
+// 
 // ---------------------------------------------------------------------------
 //
-void CAiSatPlugin::Stop( TAiTransitionReason /* aReason */ )
-    {
-    TFLOGSTRING( "CAiSatPlugin::Stop starts - exits" )
+void CAiSatPlugin::Start( TStartReason /*aReason*/ )
+    {    
+    TFLOGSTRING( "CAiSatPlugin::Start() starts" )
+    
+    iPublishRequired = ETrue;
+    
+    TFLOGSTRING( "CAiSatPlugin::Start() exits" )
     }
 
 // ---------------------------------------------------------------------------
-// From class CAiContentPublisher
-// Plug-in is instructed that it is allowed to consume CPU resources
+// CAiSatPlugin::Stop
+// 
+// ---------------------------------------------------------------------------
+//
+void CAiSatPlugin::Stop( TStopReason /*aReason*/ )
+    {
+    TFLOGSTRING( "CAiSatPlugin::Stop() starts - exits" )
+    }
+
+// ---------------------------------------------------------------------------
+// CAiSatPlugin::Resume
+// 
 // ---------------------------------------------------------------------------
 //
-void CAiSatPlugin::Resume( TAiTransitionReason aReason )
+void CAiSatPlugin::Resume( TResumeReason aReason )
     {
-    TFLOGSTRING2( "CAiSatPlugin::Resume reason %d", aReason )
+    TFLOGSTRING2( "CAiSatPlugin::Resume() reason %d", aReason )
 
-    if ( EAiIdleForeground == aReason && !iEngine )
+    if ( aReason == EForeground )
         {
-        TRAP_IGNORE( iEngine = CAiSatEngine::NewL( *this ) )
+        if ( iPublishRequired )
+            {
+            iPublishRequired = EFalse;
+            
+            TRAP_IGNORE( UpdateSatL() )                       
+            }
         }
-        
-    // If we change the Home Screen Theme we will got a EAiSystemStartup as 
-    // aReason.
-    else if ( ( EAiGeneralThemeChanged == aReason || 
-                EAiSystemStartup == aReason ) &&
-                iEngine )
-        {
-        TRAP_IGNORE( UpdateSatL() )
-        }
-        
+            
     TFLOGSTRING( "CAiSatPlugin::Resume() exits" )
     }
 
 // ---------------------------------------------------------------------------
-// From class CAiContentPublisher
-// Plug-in is instructed that it is not allowed to consume CPU resources
+// CAiSatPlugin::Suspend
+// 
 // ---------------------------------------------------------------------------
 //
-void CAiSatPlugin::Suspend( TAiTransitionReason /* aReason */ )
+void CAiSatPlugin::Suspend( TSuspendReason aReason )
     {
-    TFLOGSTRING( "CAiSatPlugin::Suspend starts - exits" )
+    TFLOGSTRING( "CAiSatPlugin::Suspend() starts" )
+    
+    if ( aReason == EGeneralThemeChange )
+        {
+        iPublishRequired = ETrue;
+        }
+    
+    TFLOGSTRING( "CAiSatPlugin::Suspend() exits" )
     }
 
 // ---------------------------------------------------------------------------
-// From class CAiContentPublisher
-// The plug-in MUST maintain a registry of subscribers and send
-// notification to all of them whenever the state changes or new content
-// is available
+// CAiSatPlugin::SubscribeL
+// 
 // ---------------------------------------------------------------------------
 //
 void CAiSatPlugin::SubscribeL( MAiContentObserver& aObserver )
@@ -348,9 +362,8 @@
     }
 
 // ---------------------------------------------------------------------------
-// From class CAiContentPublisher
-// Plug-ins take ownership of the settings array, so it must either
-// store it in a member or free it.
+// CAiSatPlugin::ConfigureL
+// 
 // ---------------------------------------------------------------------------
 //
 void CAiSatPlugin::ConfigureL( RAiSettingsItemArray& aSettings )
@@ -370,99 +383,41 @@
             }
         TFLOGSTRING2( "CAiSatPlugin::ConfigureL  i: %d", i )    
         }
-
+	
     TFLOGSTRING( "CAiSatPlugin::ConfigureL() exits" )
     }
 
 // ---------------------------------------------------------------------------
-// From class CAiContentPublisher
-// Returns the extension interface. Actual type depends on the passed
-// aUid argument.
-// ---------------------------------------------------------------------------
-//
-TAny* CAiSatPlugin::Extension( TUid aUid )
-    {
-    TFLOGSTRING( "CAiSatPlugin::Extension() starts" )
-
-    MAiPropertyExtension* extension = NULL;
-
-    if ( KExtensionUidProperty == aUid )
-        {
-        extension = static_cast<MAiPropertyExtension*>( this );
-        }
-
-    TFLOGSTRING( "CAiSatPlugin::Extension() exits" )
-    return extension;
-    }
-
-// ---------------------------------------------------------------------------
-// From class MAiPropertyExtension
-// Read property of publisher plug-in.
+// CAiSatPlugin::GetProperty
+// 
 // ---------------------------------------------------------------------------
 //
-TAny* CAiSatPlugin::GetPropertyL( TInt aProperty )
+TAny* CAiSatPlugin::GetProperty( TProperty aProperty )
     {
-    TFLOGSTRING( "CAiSatPlugin::GetPropertyL() starts" )
-
-    TAny* property = NULL;
-    TFLOGSTRING2( "CAiSatPlugin::GetPropertyL  aProperty: %d", aProperty )
-    switch ( aProperty )
-        {
-        case EAiPublisherInfo:
-            {
-            property = static_cast<TAiPublisherInfo*>( &iInfo );
-            break;
-            }
+    TFLOGSTRING( "CAiSatPlugin::GetProperty() starts" )
+    
+    TAny* property( NULL );
+    
+    TFLOGSTRING2( "CAiSatPlugin::GetProperty aProperty: %d", aProperty )
 
-        case EAiPublisherContent:
-            {
-            property = static_cast<MAiContentItemIterator*>( iContent );
-            break;
-            }
-
-        case EAiPublisherResources:
-            {
-            property = static_cast<MAiContentItemIterator*>( iResources );
-            break;
-            }
-
-        case EAiPublisherEvents:
-            {
-            property = static_cast<MAiContentItemIterator*>( iEvents );
-            break;
-            }
-        default:
-            break;
+    if ( aProperty == EPublisherContent )
+        {            
+        property = iContent;            
+        }
+    else if ( aProperty == EPublisherResources )
+        {
+        property = iResources;
+        }
+    else if ( aProperty == EPublisherEvents )
+        {
+        property = iEvents;
         }
 
-    TFLOGSTRING( "CAiSatPlugin::GetPropertyL() exits" )
+    TFLOGSTRING( "CAiSatPlugin::GetProperty() exits" )
 
     return property;
     }
 
-// ---------------------------------------------------------------------------
-// From class MAiPropertyExtension
-// Write property value to optimize the content model.
-// ---------------------------------------------------------------------------
-//
-void CAiSatPlugin::SetPropertyL( TInt aProperty, TAny* aValue )
-    {
-    TFLOGSTRING( "CAiSatPlugin::SetPropertyL() starts" )
-
-    if ( EAiPublisherInfo == aProperty )
-        {
-        TFLOGSTRING( "CAiSatPlugin::SetPropertyL() EAiPublisherInfo" )
-        const TAiPublisherInfo* info =
-            static_cast<const TAiPublisherInfo*>( aValue );
-        if ( info )
-            {
-            iInfo = *info;
-            }
-        }
-
-    TFLOGSTRING( "CAiSatPlugin::SetPropertyL() exits" )
-    }
-
 // ---------------------------------------------------------
 // This method is called from the engine, when the P&S
 // data content has been changed. Method call is made through
@@ -505,11 +460,6 @@
     {
     TFLOGSTRING( "CAiSatPlugin::ConstructL() starts" )
 
-    _LIT(KSatName, "SAT");
-
-    iInfo.iUid.iUid = AI_UID_ECOM_IMPLEMENTATION_CONTENTPUBLISHER_SATPLUGIN;
-    iInfo.iName.Copy( KSatName );
-
     iContent = AiUtility::CreateContentItemArrayIteratorL( KSatContent );
     iResources = AiUtility::CreateContentItemArrayIteratorL( KSatResources );
     iEvents = AiUtility::CreateContentItemArrayIteratorL( KSatEvents );