calendarui/customisationmanager/src/calencustomisationmanager.cpp
branchRCL_3
changeset 60 96907930389d
parent 36 9c5b1510919f
child 65 12af337248b1
--- a/calendarui/customisationmanager/src/calencustomisationmanager.cpp	Thu Jul 15 18:37:27 2010 +0300
+++ b/calendarui/customisationmanager/src/calencustomisationmanager.cpp	Thu Aug 19 09:53:43 2010 +0300
@@ -144,7 +144,6 @@
         iSetting->Release();
         }
     iHiddenViews.Reset();
-    iDefferedUnloadPluginList.Reset();
 
     TRACE_EXIT_POINT;
     }
@@ -429,7 +428,10 @@
              
             // Remove the plugin from the active plugin list
             TInt position = iActivePlugins.Find( aPluginUid );
-            ASSERT( position != KErrNotFound );
+            if(position == KErrNotFound ) // plugin has already been removed
+                { 
+                return ;
+                }
             
             iActivePlugins.Remove( position );
              
@@ -501,7 +503,7 @@
         if ( position != KErrNotFound ) 
 	        {
             TUid pluginUid = iPlugins[ position]->Uid();
-            if(!(iRomBasedPlugins.Find(pluginUid) != KErrNotFound))
+            if(!iPluginInfo[position]->RomBased())           
                 {
                     if((iInfoBarProviderUid != iPlugins[position]->Uid())
                         && (iPreviewPaneProviderUid != iPlugins[ position]->Uid()))
@@ -552,6 +554,15 @@
         iPluginsEnabledDisabled = ETrue;
         iServices.IssueNotificationL( ECalenNotifyPluginEnabledDisabled );
         }
+		else
+    	{
+		// Ensure plugin is enabled
+		if(iPlugins[index]->IsDisabled())
+			{
+			iPlugins[index]->Disable( EFalse );
+			iServices.IssueNotificationL( ECalenNotifyPluginEnabledDisabled );
+			}
+        }
     
     TRACE_EXIT_POINT;
     }
@@ -739,7 +750,7 @@
 // (other items were commented in a header).
 // ----------------------------------------------------------------------------
 //
-void CCalenCustomisationManager::DoImmediatePluginLoadingL(TBool aLoadViewbasedPulgins)
+void CCalenCustomisationManager::DoImmediatePluginLoadingL()
     {
     TRACE_ENTRY_POINT;
 
@@ -759,22 +770,9 @@
     for ( TInt index( 0 ); index < pluginCount; ++index )
         {
         TUid pluginUid = iPluginInfo[index]->ImplementationUid();
-        TBool loadPlugins(EFalse);
         
-        if(aLoadViewbasedPulgins)
-            {
-            if ( (iActivePlugins.Find( pluginUid ) != KErrNotFound) && 
-                 !(iRomBasedPlugins.Find( pluginUid ) != KErrNotFound) )
-                {
-                loadPlugins = ETrue;
-                }                
-            }
-        else if((iActivePlugins.Find( pluginUid ) != KErrNotFound))
-            {
-            loadPlugins = ETrue;
-            }       
+        if ( iActivePlugins.Find( pluginUid ) != KErrNotFound )        
         
-        if (loadPlugins)
             {
             TRAPD( error, LoadPluginL( pluginUid ) );
             if ( error )
@@ -1291,11 +1289,14 @@
         TRAPD( error,
             for (; index < count; ++index )
                 {
+                if ( !iPlugins[index]->IsDisabled() )
+                    {
                 iPlugins[index]->Plugin().CustomiseMenuPaneL( aResourceId,
                                                              aMenuPane );
                                                              
                 // The commands added should be checked to see that
                 // they match the expected command range for the plugin
+                    }
                 }
              );
          
@@ -1430,11 +1431,14 @@
                                              TUid aUid ) 
     {
     TRACE_ENTRY_POINT;
-
+    TInt index = iPlugins.Find( aUid, CPluginInfo::Identifier );
+    if ( index == KErrNotFound )
+        {
     CPluginInfo* newPlugin = new ( ELeave ) CPluginInfo( aPlugin, aUid);
     CleanupStack::PushL( newPlugin );
     iPlugins.AppendL( newPlugin );
     CleanupStack::Pop( newPlugin );
+        }
 
     TRACE_EXIT_POINT;
     }
@@ -1494,17 +1498,12 @@
     TRACE_ENTRY_POINT;
     // Reset and destroy the contents of the owned arrays    
     //iPlugins.ResetAndDestroy();
-
-    iPluginInfo.ResetAndDestroy();
-
-    iActivePlugins.Reset();
-
     iHiddenViews.Reset();
     iDefferedUnloadPluginList.Reset();
     // create active plugin list
     CreateActivePluginListL();
     
-    DoImmediatePluginLoadingL(ETrue);
+    DoImmediatePluginLoadingL();
     iSetting->LoadL();
     iSetting->UpdatePluginListL(*this);
     
@@ -1524,7 +1523,8 @@
     for(TInt index = 0;index<pluginCount;index++)
         {
         TUid pluginUid = iPluginInfo[index]->ImplementationUid();
-        if(iActivePlugins.Find(pluginUid)!=KErrNotFound)
+        if ((iActivePlugins.Find(pluginUid) != KErrNotFound)
+                && !(iRomBasedPlugins.Find(pluginUid) != KErrNotFound))
             {
             DisablePluginOnFakeExitL(pluginUid);
             }