idlefw/plugins/mcsplugin/settings/src/mcspluginsettingsmodel.cpp
branchRCL_3
changeset 18 bd874ee5e5e2
parent 9 d0529222e3f0
child 19 502e5d91ad42
--- a/idlefw/plugins/mcsplugin/settings/src/mcspluginsettingsmodel.cpp	Fri Feb 19 23:07:29 2010 +0200
+++ b/idlefw/plugins/mcsplugin/settings/src/mcspluginsettingsmodel.cpp	Fri Mar 12 15:43:54 2010 +0200
@@ -52,8 +52,6 @@
 _LIT8( KProperValueBookmark, "bookmark" );
 _LIT8( KProperValueAppl, "application" );
 
-
-
 using namespace HSPluginSettingsIf;
 
 // -----------------------------------------------------------------------------
@@ -136,10 +134,12 @@
 {
     delete iAppList;
     delete iBkmList;
-    iSettings.Reset();
-    delete iPluginSettings;
+    iSettings.Reset();    
     delete iPluginId;
     delete iListBoxLine;
+    
+    CHomescreenSettings::UnInitialize();
+    iPluginSettings = NULL;
 }
 
 // ---------------------------------------------------------------------------
@@ -148,6 +148,14 @@
 //
 void CMCSPluginSettingsModel::ConstructL()
 {
+    CHomescreenSettings::InitializeL( KAppUid );
+    
+    iPluginSettings = CHomescreenSettings::Instance();
+    if( iPluginSettings == NULL )
+        {
+        User::Leave( KErrUnknown );
+        }
+    
     iAppList = CMCSPluginSettingsAppList::NewL();
     iAppList->StartL();
     iBkmList = CMCSPluginSettingsBkmList::NewL();
@@ -164,13 +172,46 @@
         {
         return;
         }
-    if( !iPluginSettings )
+    
+    if( iPluginId )
+        {
+        delete iPluginId;
+        iPluginId = NULL;
+        }
+    iPluginId = aPluginId.AllocL();    
+    
+    iSettings.Reset();
+    RPointerArray<CItemMap> settingItems;
+    CleanupClosePushL( settingItems );
+
+    iPluginSettings->GetSettingsL( *iPluginId, settingItems );
+
+    TInt count = settingItems.Count();
+    for ( TInt i = 0; i < count; i++ )
         {
-        // AILaunch uid in decimal format
-        iPluginSettings = CHomescreenSettings::NewL( KAppUid, aPluginId, this );
-        iPluginId = aPluginId.AllocL();
+        CItemMap* itemMap = settingItems[i];
+        RPointerArray<HSPluginSettingsIf::CPropertyMap> properties;
+        properties = itemMap->Properties();
+        TSettingItem item = ItemL( properties );
+        iSettings.AppendL( item );
         }
+    CleanupStack::Pop( &settingItems );
+    settingItems.ResetAndDestroy();
+    }
 
+// ---------------------------------------------------------------------------
+// Gets the latest settings from HSPS and updates
+// ---------------------------------------------------------------------------
+//
+void CMCSPluginSettingsModel::UpdateSettingModelL( const TDesC8& aPluginId )
+    {
+    if( iPluginId )
+        {
+        delete iPluginId;
+        iPluginId = NULL;
+        }
+    iPluginId = aPluginId.AllocL();
+    
     iSettings.Reset();
     RPointerArray<CItemMap> settingItems;
     CleanupClosePushL( settingItems );
@@ -274,12 +315,12 @@
 //
 void CMCSPluginSettingsModel::SaveSettingsL( const TInt& aIndex, 
                                              CMenuItem& aMenuItem )
-    {
-
-    if ( !iPluginSettings )
+    {    
+    if( !iPluginId )
         {
         return;
         }
+    
     RPointerArray<CItemMap> settingItems;
     CleanupClosePushL( settingItems );
     iPluginSettings->GetSettingsL( *iPluginId, settingItems );
@@ -426,18 +467,6 @@
 }
 
 // ---------------------------------------------------------------------------
-// From MHomeScreenSettingsObserver - handler for HSPS setting change
-// ---------------------------------------------------------------------------
-//
-TInt CMCSPluginSettingsModel::SettingsChangedL( const TDesC8& /*aEvent*/,  
-                                                const TDesC8& /*aPluginName*/,
-                                                const TDesC8& /*aPluginUid*/, 
-                                                const TDesC8& /*aPluginId*/ )
-    {
-    return KErrNone;
-    }
-
-// ---------------------------------------------------------------------------
 // From MDesCArray
 // Returns the number of descriptor elements in a descriptor array.
 // ---------------------------------------------------------------------------