calendarui/customisationmanager/src/calencustomisationmanager.cpp
branchRCL_3
changeset 66 bd7edf625bdd
parent 65 12af337248b1
child 74 97232defd20e
equal deleted inserted replaced
65:12af337248b1 66:bd7edf625bdd
    14 * Description:  Handles loading of Calendar customisation plugins
    14 * Description:  Handles loading of Calendar customisation plugins
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 
    19 #include <eikmenup.h>
    20 #include <vwsdef.h>                     // TVwsViewId
    20 #include <ecom/ecom.h>
    21 #include <apadef.h>                     // TApaCommand
    21 #include <Calendar.rsg>
       
    22 #include <aknsettingitemlist.h>          // CAknSettingItem
       
    23 #include <calencommandhandler.h>
       
    24 #include <calencustomisation.h>
       
    25 #include <calenservices.h>
       
    26 #include <mcalenpreview.h>
       
    27 
       
    28 #include "calensend.h"
       
    29 #include "calenviewinfo.h"
    22 #include "calendarui_debug.h"
    30 #include "calendarui_debug.h"
    23 #include <hbwidget.h>
       
    24 #include <hblabel.h>
       
    25 #include "calencustomisationmanager.h"
    31 #include "calencustomisationmanager.h"
    26 #include "calencommandhandler.h"
    32 #include "calencontroller.h"
    27 #include "calenservices.h"
    33 #include "calensetting.h"
    28 #include "calencustomisation.h"
       
    29 #include <ecom/ecom.h>
       
    30 #include <e32lang.h>
       
    31 #include "calenservices.h"
       
    32 #include "calenservicesfactory.h"
       
    33 #include "CalenUid.h"
    34 #include "CalenUid.h"
    34 #include "OstTraceDefinitions.h"
       
    35 #ifdef OST_TRACE_COMPILER_IN_USE
       
    36 #include "calencustomisationmanagerTraces.h"
       
    37 #endif
       
    38 
       
    39 
       
    40 
       
    41 
    35 
    42 
    36 
    43 // ----------------------------------------------------------------------------
    37 // ----------------------------------------------------------------------------
    44 // CCalenCustomisationManager::NewL
    38 // CCalenCustomisationManager::NewL
    45 // Two phased constructor
    39 // Two phased constructor
    46 // (other items were commented in a header).
    40 // (other items were commented in a header).
    47 // ----------------------------------------------------------------------------
    41 // ----------------------------------------------------------------------------
    48 //
    42 //
    49  CCalenCustomisationManager* CCalenCustomisationManager::NewL( 
    43 EXPORT_C CCalenCustomisationManager* CCalenCustomisationManager::NewL( 
    50                                     MCalenServicesFactory& aFactory,
    44                                     MCalenServicesFactory& aFactory,
    51                                     MCalenServices& aServices
    45                                     CCalenPluginStatusArray& aPluginSettingsStatus,
    52                                     )
    46                                     MCalenServices& aServices,
    53     {
    47                                     RPointerArray<CCalenViewInfo>& aViewArray )
    54     OstTraceFunctionEntry0( CCALENCUSTOMISATIONMANAGER_NEWL_ENTRY );
    48     {
       
    49     TRACE_ENTRY_POINT;
       
    50 
    55     CCalenCustomisationManager* self = new( ELeave ) CCalenCustomisationManager(
    51     CCalenCustomisationManager* self = new( ELeave ) CCalenCustomisationManager(
    56                                                                  aFactory,
    52                                                                  aFactory,
    57                                                                  aServices );
    53                                                                  aServices,
       
    54                                                                  aViewArray,
       
    55                                                                  aPluginSettingsStatus );
    58     CleanupStack::PushL( self );
    56     CleanupStack::PushL( self );
    59     self->ConstructL();
    57     self->ConstructL();
    60     CleanupStack::Pop( self );
    58     CleanupStack::Pop( self );
    61 
    59 
    62     OstTraceFunctionExit0( CCALENCUSTOMISATIONMANAGER_NEWL_EXIT );
    60     TRACE_EXIT_POINT;
    63     return self;
    61     return self;
    64     }
    62     }
    65 
    63 
    66 // ----------------------------------------------------------------------------
    64 // ----------------------------------------------------------------------------
    67 // CCalenCustomisationManager::CCalenCustomisationManager
    65 // CCalenCustomisationManager::CCalenCustomisationManager
    68 // C++ constructor
    66 // C++ constructor
    69 // (other items were commented in a header).
    67 // (other items were commented in a header).
    70 // ----------------------------------------------------------------------------
    68 // ----------------------------------------------------------------------------
    71 //
    69 //
    72 CCalenCustomisationManager::CCalenCustomisationManager( MCalenServicesFactory& aFactory,
    70 CCalenCustomisationManager::CCalenCustomisationManager( MCalenServicesFactory& aFactory,
    73                                                         MCalenServices& aServices )
    71                                                         MCalenServices& aServices,
    74     : iServicesFactory( aFactory ),       
    72                                                         RPointerArray<CCalenViewInfo>& aViewArray,
    75       iServices( aServices )
    73                                                         CCalenPluginStatusArray& aPluginSettingsStatus )
    76     {
    74     : iServicesFactory( aFactory ),
    77     OstTraceFunctionEntry0( CCALENCUSTOMISATIONMANAGER_CCALENCUSTOMISATIONMANAGER_ENTRY );
    75       iViewInfoArray( aViewArray ),
    78     OstTraceFunctionExit0( CCALENCUSTOMISATIONMANAGER_CCALENCUSTOMISATIONMANAGER_EXIT );
    76       iSortOrder( CCalenViewInfo::CyclePositionComparison ), 
       
    77       iServices( aServices ),
       
    78       iPluginSettingsStatus( aPluginSettingsStatus )
       
    79     {
       
    80     TRACE_ENTRY_POINT;
       
    81     TRACE_EXIT_POINT;
    79     }
    82     }
    80 
    83 
    81 // ----------------------------------------------------------------------------
    84 // ----------------------------------------------------------------------------
    82 // CCalenCustomisationManager::ConstructL
    85 // CCalenCustomisationManager::ConstructL
    83 // Second stage constructor
    86 // Second stage constructor
    84 // (other items were commented in a header).
    87 // (other items were commented in a header).
    85 // ----------------------------------------------------------------------------
    88 // ----------------------------------------------------------------------------
    86 //
    89 //
    87 void CCalenCustomisationManager::ConstructL()
    90 void CCalenCustomisationManager::ConstructL()
    88     {
    91     {
    89 	OstTraceFunctionEntry0( CCALENCUSTOMISATIONMANAGER_CONSTRUCTL_ENTRY );
    92     TRACE_ENTRY_POINT;
    90 
    93     iInfoBarProviderUid = TUid::Uid(0);
       
    94     iPreviewPaneProviderUid = TUid::Uid(0);
       
    95     
       
    96     // Get a pointer to the global data and controller
       
    97     iGlobalData = CCalenGlobalData::InstanceL();
       
    98     
       
    99     // Get the setting singleton. We update it when settings change.
       
   100     iSetting = CCalenSetting::InstanceL();
       
   101     
    91     CreateActivePluginListL();
   102     CreateActivePluginListL();
    92 
   103 
    93     // Load any enabled plugins
   104     // Load any enabled plugins
    94     DoImmediatePluginLoadingL();
   105     DoImmediatePluginLoadingL();
    95 
   106 
    96     OstTraceFunctionExit0( CCALENCUSTOMISATIONMANAGER_CONSTRUCTL_EXIT );
   107     TRACE_EXIT_POINT;
    97     }
   108     }
    98 
   109 
    99 // ----------------------------------------------------------------------------
   110 // ----------------------------------------------------------------------------
   100 // CCalenCustomisationManager::~CCalenCustomisationManager
   111 // CCalenCustomisationManager::~CCalenCustomisationManager
   101 // Destructor
   112 // Destructor
   102 // (other items were commented in a header).
   113 // (other items were commented in a header).
   103 // ----------------------------------------------------------------------------
   114 // ----------------------------------------------------------------------------
   104 //
   115 //
   105  CCalenCustomisationManager::~CCalenCustomisationManager()
   116 EXPORT_C CCalenCustomisationManager::~CCalenCustomisationManager()
   106     {
   117     {
   107 	OstTraceFunctionEntry0( DUP1_CCALENCUSTOMISATIONMANAGER_CCALENCUSTOMISATIONMANAGER_ENTRY );
   118     TRACE_ENTRY_POINT;
   108 
   119 
   109     // Reset and destroy the contents of the owned arrays,
   120     // Reset and destroy the contents of the owned arrays,
   110     // this will delete the plugins.
   121     // this will delete the plugins.
   111     iPlugins.ResetAndDestroy();
   122     iPlugins.ResetAndDestroy();
   112 
   123 
   113     iPluginInfo.ResetAndDestroy();
   124     iPluginInfo.ResetAndDestroy();
   114 
   125 
   115     iActivePlugins.Reset();
   126     iActivePlugins.Reset();
   116     iRomBasedPlugins.Reset();
   127     iRomBasedPlugins.Reset();
   117 
   128 
       
   129     // reset deferred unload plugins list
       
   130     iDefferedUnloadPluginList.Reset();
       
   131 	
       
   132 	
   118     // Close the ECOM interface
   133     // Close the ECOM interface
   119     REComSession::FinalClose();
   134     REComSession::FinalClose();
   120     
   135 
   121     iDefferedUnloadPluginList.Reset();
   136     // Release the global data and controller
   122 
   137     if ( iGlobalData )
   123     OstTraceFunctionExit0( DUP1_CCALENCUSTOMISATIONMANAGER_CCALENCUSTOMISATIONMANAGER_EXIT );
   138         {
   124     }
   139         iGlobalData->Release();
   125  // ----------------------------------------------------------------------------
   140         }
   126  // CCalenCustomisationManager::GetCommandHandlerL
   141     
   127  // Get a command handler for a specific command.  Ownership remains with the
   142     if(iSetting)
   128  // plugin
   143         {
   129  // ----------------------------------------------------------------------------
   144         iSetting->Release();
   130  MCalenCommandHandler* CCalenCustomisationManager::GetCommandHandlerL( TInt aCommand )
   145         }
   131      {
   146     iHiddenViews.Reset();
   132 	OstTraceFunctionEntry0( CCALENCUSTOMISATIONMANAGER_GETCOMMANDHANDLERL_ENTRY );
   147 
   133 
   148     TRACE_EXIT_POINT;
   134      MCalenCommandHandler* handler( NULL );
   149     }
   135      
   150 
   136      // Loop though all the enabled plugins asking for a command handler
   151 // ----------------------------------------------------------------------------
   137      // to handle this command with.  Returns NULL if no plugin wants to 
   152 // CCalenCustomisationManager::GetCommandHandlerL
   138      // handle the command.
   153 // Get a command handler for a specific command.  Ownership remains with the
   139      
   154 // plugin
   140      TInt count = iPlugins.Count();
   155 // ----------------------------------------------------------------------------
   141      for ( TInt index = 0; index < count && !handler; ++index )
   156 EXPORT_C MCalenCommandHandler* CCalenCustomisationManager::GetCommandHandlerL( TInt aCommand )
   142          {
   157     {
   143          TRAPD( error,
   158     TRACE_ENTRY_POINT;
   144              // Loop though until a command handler is found
   159 
   145              for (; index < count && !handler; ++index )
   160     MCalenCommandHandler* handler( NULL );
   146                  {
   161     
   147                  //if ( !iPlugins[index]->IsDisabled() )
   162     // Loop though all the enabled plugins asking for a command handler
   148                      {
   163     // to handle this command with.  Returns NULL if no plugin wants to 
   149                      handler = iPlugins[index]->Plugin().CommandHandlerL( aCommand );
   164     // handle the command.
   150                      }
   165     
   151                  }
   166     TInt count = iPlugins.Count();
   152               );
   167     for ( TInt index = 0; index < count && !handler; ++index )
   153 
   168         {
   154          if ( error )
   169         TRAPD( error,
   155              {
   170             // Loop though until a command handler is found
   156              // Report a problem with plugin.
   171             for (; index < count && !handler; ++index )
   157              }
   172                 {
   158          }
   173                 if ( !iPlugins[index]->IsDisabled() )
   159      
   174                     {
   160      OstTraceFunctionExit0( CCALENCUSTOMISATIONMANAGER_GETCOMMANDHANDLERL_EXIT );
   175                     handler = iPlugins[index]->Plugin().CommandHandlerL( aCommand );
   161      return handler;
   176                     }
   162      }
   177                 }
   163 
   178              );
   164 
   179 
       
   180         if ( error )
       
   181             {
       
   182             // Report a problem with plugin.
       
   183             }
       
   184         }
       
   185     
       
   186     TRACE_EXIT_POINT;
       
   187     return handler;
       
   188     }
       
   189 
       
   190 // ----------------------------------------------------------------------------
       
   191 // CCalenCustomisationManager::GetPluginSettingsL
       
   192 // Gets custom settings from the specified plugin
       
   193 // ----------------------------------------------------------------------------
       
   194 //
       
   195 EXPORT_C void CCalenCustomisationManager::GetPluginSettingsL( TUid aPluginUid,
       
   196                                                               RPointerArray<CAknSettingItem>& aSettingArray )
       
   197     {
       
   198     TRACE_ENTRY_POINT;
       
   199 
       
   200     CCalenCustomisation* plugin = FindPluginL( aPluginUid );
       
   201     User::LeaveIfNull( plugin );
       
   202 
       
   203     TRAPD( error, plugin->GetCustomSettingsL( aSettingArray ));
       
   204     if ( error )
       
   205             {
       
   206             // Report a problem with plugin.
       
   207             }
       
   208     
       
   209     TRACE_EXIT_POINT;
       
   210     }
   165 
   211 
   166 // ----------------------------------------------------------------------------
   212 // ----------------------------------------------------------------------------
   167 // CCalenCustomisationManager::ActivePlugins
   213 // CCalenCustomisationManager::ActivePlugins
   168 // Returns a reference to an array of active plugins uids
   214 // Returns a reference to an array of active plugins uids
   169 // ----------------------------------------------------------------------------
   215 // ----------------------------------------------------------------------------
   170 //
   216 //
   171  const RArray<TUid>& CCalenCustomisationManager::ActivePlugins() const
   217 EXPORT_C const RArray<TUid>& CCalenCustomisationManager::ActivePlugins() const
   172     {
   218     {
   173     OstTraceFunctionEntry0( CCALENCUSTOMISATIONMANAGER_ACTIVEPLUGINS_ENTRY );
   219     TRACE_ENTRY_POINT;
   174     OstTraceFunctionExit0( CCALENCUSTOMISATIONMANAGER_ACTIVEPLUGINS_EXIT );
   220     TRACE_EXIT_POINT;
       
   221 
   175     return iActivePlugins;
   222     return iActivePlugins;
   176     }
   223     }
   177 
   224 
   178 // ----------------------------------------------------------------------------
   225 // ----------------------------------------------------------------------------
   179 // CCalenCustomisationManager::CreateActivePluginListL
   226 // CCalenCustomisationManager::CreateActivePluginListL
   180 // Generates the list of active plugins
   227 // Generates the list of active plugins
   181 // ----------------------------------------------------------------------------
   228 // ----------------------------------------------------------------------------
   182 //
   229 //
   183 void CCalenCustomisationManager::CreateActivePluginListL()
   230 void CCalenCustomisationManager::CreateActivePluginListL()
   184     {
   231     {
   185     OstTraceFunctionEntry0( CCALENCUSTOMISATIONMANAGER_CREATEACTIVEPLUGINLISTL_ENTRY );
   232     TRACE_ENTRY_POINT;
       
   233     
   186     iPluginInfo.ResetAndDestroy();
   234     iPluginInfo.ResetAndDestroy();
   187     iActivePlugins.Reset();
   235     iActivePlugins.Reset();
   188     iRomBasedPlugins.Reset();
   236     iRomBasedPlugins.Reset();
   189 
   237     
   190     REComSession::ListImplementationsL( KCalenCustomisationInterfaceUid, iPluginInfo );
   238     //Added resolver for corolla release
       
   239     // Set resolver params
       
   240     /*TLanguage lang = User::Language();
       
   241     TBuf8<40> langStr;
       
   242     langStr.Format( _L8("language(%d)"), lang );
       
   243 
       
   244     TEComResolverParams resolverParams;
       
   245     resolverParams.SetDataType( langStr );
       
   246     resolverParams.SetGenericMatch( ETrue );*/
       
   247     
       
   248     REComSession::ListImplementationsL( KCalenCustomisationInterfaceUid,/* resolverParams,*/ iPluginInfo );
   191     
   249     
   192     LoadPluginsBasedOnVariantL();
   250     LoadPluginsBasedOnVariantL();
   193     
   251     
   194     TInt pluginCount = iPluginInfo.Count();
   252     TInt pluginCount = iPluginInfo.Count();
   195     
   253     
   196     if(pluginCount) 
   254     for ( TInt pluginIndex(0); pluginIndex < pluginCount; ++pluginIndex )
   197 		{
   255         {
   198     	for ( TInt pluginIndex(0); pluginIndex < pluginCount; ++pluginIndex )
   256         TUid pluginUid = iPluginInfo[pluginIndex]->ImplementationUid();
   199 			{
   257         
   200     		TUid pluginUid = iPluginInfo[pluginIndex]->ImplementationUid();
   258         // Find the plugin in the list of known plugins 
   201 
   259         TInt position = iPluginSettingsStatus.Find( pluginUid, PluginAvailabilityFinder );
   202     		// If the plugin can not be found or if it is enabled
   260         if ( ( position == KErrNotFound ) || ( iPluginSettingsStatus[position].iEnabled ) )
   203     		// add it to the list of active plugins
   261             {
   204     		iActivePlugins.AppendL( pluginUid );
   262             // If the plugin can not be found or if it is enabled
   205 
   263             // add it to the list of active plugins
   206     		// If the plugin is rom-based, store its uid
   264             iActivePlugins.AppendL( pluginUid );
   207     		if ( iPluginInfo[pluginIndex]->RomBased() )
   265             
   208 				{
   266             // If the plugin is rom-based, store its uid
   209     			iRomBasedPlugins.AppendL( pluginUid );
   267             if ( iPluginInfo[pluginIndex]->RomBased() )
   210 				}
   268                 {
   211 
   269                 iRomBasedPlugins.AppendL( pluginUid );
   212 			}
   270                 }
   213 		}
   271             }
   214 
   272         }
   215     OstTraceFunctionExit0( CCALENCUSTOMISATIONMANAGER_CREATEACTIVEPLUGINLISTL_EXIT );
   273 
   216     }
   274     TRACE_EXIT_POINT;
   217 
   275     }
   218 // ----------------------------------------------------------------------------
   276 
   219 // CCalenCustomisationManager::LoadPluginsBasedOnVariantL
   277 // ----------------------------------------------------------------------------
   220 // Loads the plugin based on the language variant
   278 // CCalenCustomisationManager::GetCustomViewsL
   221 // ----------------------------------------------------------------------------
   279 // GetCustomViews returns custom views info in an array for a given
   222 //
   280 // plugin. 
   223 void CCalenCustomisationManager::LoadPluginsBasedOnVariantL()
   281 // NOTE: The contents of the array are owned by the caller - caller
   224 {
   282 // must guarantee to call ResetAndDestroy on the array in all cases.
   225 	OstTraceFunctionEntry0( CCALENCUSTOMISATIONMANAGER_LOADPLUGINSBASEDONVARIANTL_ENTRY );
   283 // ----------------------------------------------------------------------------
   226 	TLanguage languge = User::Language();
   284 //
   227 	RArray<TUid> needsToBeRemoved;
   285 EXPORT_C void CCalenCustomisationManager::GetCustomViewsL( TUid aPluginUid, 
   228 	
   286                                                            RPointerArray<CCalenView>& aViews )
   229 	switch(languge) 
   287     {
   230 		{
   288     TRACE_ENTRY_POINT;
   231 		case ELangTaiwanChinese:
   289 
   232 		case ELangPrcChinese:
   290     CCalenCustomisation* plugin = FindPluginL( aPluginUid );
   233 		case ELangHongKongChinese:
   291     User::LeaveIfNull( plugin );
   234 			// TODO: Remove the other regional plugins Thai, Vietnamese etc.
   292     
   235 			break;
   293     TRAPD( error, plugin->GetCustomViewsL( aViews ));
   236 		case ELangThai:
   294     if ( error )
   237 		case ELangEnglish_Thailand:
   295         {
   238 			needsToBeRemoved.Append(KCalenChineseImplUid);
   296         // Report a problem with plugin.
   239 			// TODO: Remove the other regional plugin Vietnamese.
   297         }
   240 			break;
   298 
   241 		case ELangVietnamese:
   299     TInt numViews = aViews.Count();
   242 			needsToBeRemoved.Append(KCalenChineseImplUid);
   300     for ( TInt index( 0 ); index < numViews; ++index )
   243 			// TODO: Remove the other regional plugin Thai.
   301         {
   244 			break;
   302         CCalenView* customView = aViews[index];
   245 
   303 
   246 		default:
   304         // Add to view info array
   247 			needsToBeRemoved.Append(KCalenChineseImplUid);
   305         const TUid viewId = customView->Id();
   248 			// TODO: Remove the other regional plugins Thai, Vietnamese etc.
   306         
   249 			break;
   307          // Check for duplicate view ids. 
   250 		}
   308         TInt position = iViewInfoArray.Find( viewId , 
   251 	TInt count = needsToBeRemoved.Count();
   309                                      CCalenViewInfo::ViewInfoIdentifier );
   252 	if(count) 
   310                                      
   253 		{
   311         if ( position == KErrNotFound )
   254 		for(TInt i=0; i< count; i++) 
   312             {
   255 			{
   313             const TDesC& menuName = customView->LocalisedViewNameL( CCalenView::EMenuName );
   256 			TInt index = iPluginInfo.Find(needsToBeRemoved[i],
   314             const TDesC& settingsName = customView->LocalisedViewNameL( CCalenView::ESettingsName );
   257 								CCalenCustomisationManager::PluginInfoFinder);
   315             const CCalenView::TCyclePosition cyclePos = customView->CyclePosition();
   258 			if( index != KErrNotFound ) 
   316 
   259 				{
   317             CCalenViewInfo* viewInfo = CCalenViewInfo::NewL( viewId,
   260 				CImplementationInformation* impl = iPluginInfo[index];
   318                                                              aPluginUid, 
   261 				iPluginInfo.Remove(index);
   319                                                              menuName,
   262 				delete impl;
   320                                                              settingsName,
   263 				}
   321                                                              cyclePos );
   264 			}
   322                                                              
   265 		}
   323             // Check if the view has already been hidden.
   266 	needsToBeRemoved.Close();
   324             TBool hidden = ( iHiddenViews.Find( viewId.iUid ) != KErrNotFound );
   267 	OstTraceFunctionExit0( CCALENCUSTOMISATIONMANAGER_LOADPLUGINSBASEDONVARIANTL_EXIT );
   325             viewInfo->Hide( hidden );                     
   268 }
   326                                                              
   269 
   327             ViewInfoArray().InsertInOrderAllowRepeatsL( viewInfo, iSortOrder );
   270 // ----------------------------------------------------------------------------
   328             }
   271 // CCalenCustomisationManager::PluginInfoFinder(
   329          else
   272 // Matches an uid in pluginInfo.
   330             {
   273 // ----------------------------------------------------------------------------
   331             // A plugin with the same id already exists. ( It could be a replacement
   274 //
   332             // view provided by a rom plugin, as currently preventing rom plugins from
   275 TBool CCalenCustomisationManager::PluginInfoFinder( const TUid* aUid,
   333             // being disabled if required is not implemented, it needs to be handled)
   276 								const CImplementationInformation&  aArrayItem )
   334             delete customView;
   277 {
   335             aViews.Remove( index );
   278 	OstTraceFunctionEntry0( CCALENCUSTOMISATIONMANAGER_PLUGININFOFINDER_ENTRY );
   336             index--; 
   279 	return (*aUid  == aArrayItem.ImplementationUid() );
   337             numViews--;
   280 }
   338             
       
   339             // Report a problem with plugin.
       
   340             }
       
   341          }
       
   342 	RArray<TInt> hiddenViews;
       
   343     CleanupClosePushL( hiddenViews );
       
   344     plugin->RemoveViewsFromCycle( hiddenViews );
       
   345     TInt hiddenViewCount = hiddenViews.Count();
       
   346     if ( hiddenViewCount )
       
   347        {
       
   348        // Get the default view form the settings to check if it is going to be hidden
       
   349        // by the installed plugin
       
   350        TUid defaultView = iSetting->DefaultView();
       
   351        for ( TInt index(0); index < hiddenViewCount; ++index )
       
   352            {
       
   353            TInt hiddenViewId = hiddenViews[index];
       
   354           // iHiddenViews.InsertInOrderAllowRepeatsL( hiddenViewId );
       
   355                        
       
   356            // If this view is already on the view cycle list it needs
       
   357            // to be hidden.
       
   358            TUid hiddenViewUid = TUid::Uid( hiddenViewId );
       
   359                        
       
   360            // If the current default view is hidden, then set the newly
       
   361            // installed plugin view as default view
       
   362            if(defaultView == hiddenViewUid)
       
   363                {
       
   364                TInt position = iViewInfoArray.Find( aPluginUid, 
       
   365                                                     CCalenViewInfo::ViewPluginIdentifier );
       
   366                if(position != -1)
       
   367                    {
       
   368                    for(TInt i = position; i < iViewInfoArray.Count(); i++)
       
   369                        {
       
   370                        if((iViewInfoArray[i]->PluginUid() == aPluginUid) &&
       
   371                                (iViewInfoArray[i]->CyclePosition() != CCalenView::ENoCyclePosition))
       
   372                            {
       
   373                            iSetting->SetDefaultView(iViewInfoArray[i]->ViewUid());
       
   374                            break;
       
   375                            }
       
   376                        }
       
   377                    }
       
   378                }
       
   379            }
       
   380        }
       
   381    CleanupStack::PopAndDestroy(); // removedViews
       
   382 
       
   383     TRACE_EXIT_POINT;
       
   384     }
   281 
   385 
   282 // ----------------------------------------------------------------------------
   386 // ----------------------------------------------------------------------------
   283 // CCalenCustomisationManager::SetPluginAvailabilityL
   387 // CCalenCustomisationManager::SetPluginAvailabilityL
   284 // Enables or disables the given plugin.
   388 // Enables or disables the given plugin.
   285 // ----------------------------------------------------------------------------
   389 // ----------------------------------------------------------------------------
   286 //
   390 //
   287  void CCalenCustomisationManager::SetPluginAvailabilityL( TUid aPluginUid,
   391 EXPORT_C void CCalenCustomisationManager::SetPluginAvailabilityL( TUid aPluginUid,
   288                                                                   TBool aEnabled )
   392                                                                   TBool aEnabled )
   289     {
   393     {
   290     OstTraceFunctionEntry0( CCALENCUSTOMISATIONMANAGER_SETPLUGINAVAILABILITYL_ENTRY );
   394     TRACE_ENTRY_POINT;
       
   395     
   291     if ( aEnabled )
   396     if ( aEnabled )
   292         {
   397         {
   293         EnablePluginL( aPluginUid );
   398         EnablePluginL( aPluginUid );
   294         }
   399         }
   295     else
   400     else
   296         {
   401         {
   297         DisablePluginL( aPluginUid );
   402         DisablePluginL( aPluginUid );
   298         }
   403         }
   299     
   404     
   300     OstTraceFunctionExit0( CCALENCUSTOMISATIONMANAGER_SETPLUGINAVAILABILITYL_EXIT );
   405     TRACE_EXIT_POINT;
   301     }
   406     }
   302 
   407 
   303 // ----------------------------------------------------------------------------
   408 // ----------------------------------------------------------------------------
   304 // CCalenCustomisationManager::DisablePluginL
   409 // CCalenCustomisationManager::DisablePluginL
   305 // Disables the given plugin.
   410 // Disables the given plugin.
   306 // ----------------------------------------------------------------------------
   411 // ----------------------------------------------------------------------------
   307 //  
   412 //  
   308  void CCalenCustomisationManager::DisablePluginL( TUid aPluginUid )
   413  void CCalenCustomisationManager::DisablePluginL( TUid aPluginUid )
   309     {
   414     {
   310     OstTraceFunctionEntry0( CCALENCUSTOMISATIONMANAGER_DISABLEPLUGINL_ENTRY );
   415     TRACE_ENTRY_POINT;
       
   416 
   311     // Find the plugins
   417     // Find the plugins
   312     TInt index = iPlugins.Find( aPluginUid, CPluginInfo::Identifier );
   418     TInt index = iPlugins.Find( aPluginUid, CPluginInfo::Identifier );
   313     if ( index != KErrNotFound )
   419     if ( index != KErrNotFound )
   314         {
   420         {
   315         CPluginInfo* pluginInfo = iPlugins[index];
   421         CPluginInfo* pluginInfo = iPlugins[index];
   320             // Mark the plugin as being disabled
   426             // Mark the plugin as being disabled
   321             pluginInfo->Disable( ETrue );
   427             pluginInfo->Disable( ETrue );
   322              
   428              
   323             // Remove the plugin from the active plugin list
   429             // Remove the plugin from the active plugin list
   324             TInt position = iActivePlugins.Find( aPluginUid );
   430             TInt position = iActivePlugins.Find( aPluginUid );
   325             ASSERT( position != KErrNotFound );
   431             if(position == KErrNotFound ) // plugin has already been removed
       
   432                 { 
       
   433                 return ;
       
   434                 }
   326             
   435             
   327             iActivePlugins.Remove( position );         
   436             iActivePlugins.Remove( position );
   328 
   437              
       
   438             // Does this plugin hide any views
       
   439             RArray<TInt> removedViews;
       
   440             CleanupClosePushL( removedViews );
       
   441             CCalenCustomisation& plugin = pluginInfo->Plugin();
       
   442             plugin.RemoveViewsFromCycle( removedViews );
       
   443             TInt hiddenViewsCount = removedViews.Count();
       
   444             if ( hiddenViewsCount )
       
   445                 {
       
   446                 // Need to recalculate which views have been hidden, as 
       
   447                 // more than one plugin might have hidden the same view.
       
   448                 for ( TInt index( 0 ); index < hiddenViewsCount; ++index )
       
   449                     {
       
   450                     TUid viewUid = TUid::Uid( removedViews[index] );
       
   451                     CheckHiddenViewL( viewUid, aPluginUid );
       
   452                     }
       
   453                 }
       
   454 
       
   455             // If the plugin does not offer any views, or the current
       
   456             // info or preview bar it can be deleted immediately,
       
   457             // otherwise the customisation needs to wait until it
       
   458             // is told it is safe to do so.
       
   459 
       
   460             // Does this plugin does not offer any views and the plugin
       
   461             // doesn't offer the current infobar or preview pane
       
   462             // bar it can be deleted immediately
       
   463             TInt offerViews = iViewInfoArray.Find( aPluginUid, 
       
   464                                        CCalenViewInfo::ViewPluginIdentifier );
       
   465                                               
       
   466             if ( offerViews == KErrNotFound &&
       
   467                  iInfoBarProviderUid != aPluginUid
       
   468                  && iPreviewPaneProviderUid != aPluginUid )
       
   469                 {
       
   470                 RArray<TUid> pluginArray;
       
   471                 CleanupClosePushL( pluginArray );
       
   472                 pluginArray.AppendL( aPluginUid );
       
   473                 UnloadPluginsL( pluginArray );
       
   474                 CleanupStack::PopAndDestroy(); // pluginArray
       
   475                 }
   329 
   476 
   330             // Issue notification of plugin been disabled
   477             // Issue notification of plugin been disabled
   331             iPluginsEnabledDisabled = ETrue;            
   478             iPluginsEnabledDisabled = ETrue;
   332             
   479             iServices.IssueNotificationL( ECalenNotifyPluginEnabledDisabled );
   333             }
   480             CleanupStack::PopAndDestroy(); // removedViews
   334             }
   481             }
       
   482         }
   335         
   483         
   336 
   484 
   337     OstTraceFunctionExit0( CCALENCUSTOMISATIONMANAGER_DISABLEPLUGINL_EXIT );
   485     TRACE_EXIT_POINT;
   338     }
   486     }
   339 
   487 
   340 // ----------------------------------------------------------------------------
   488 // ----------------------------------------------------------------------------
   341 // CCalenCustomisationManager::UnloadPluginsL
   489 // CCalenCustomisationManager::UnloadPluginsL
   342 // When a plugin is disabled it can not be unloaded until
   490 // When a plugin is disabled it can not be unloaded until
   343 // any views etc it has provided have been deleted. This function
   491 // any views etc it has provided have been deleted. This function
   344 // is called when it is safe to unload the plugin.
   492 // is called when it is safe to unload the plugin.
   345 // ----------------------------------------------------------------------------
   493 // ----------------------------------------------------------------------------
   346 //
   494 //
   347  void CCalenCustomisationManager::UnloadPluginsL( const RArray<TUid>& aPlugins )
   495 EXPORT_C void CCalenCustomisationManager::UnloadPluginsL( const RArray<TUid>& aPlugins )
   348     {
   496     {
   349     OstTraceFunctionEntry0( CCALENCUSTOMISATIONMANAGER_UNLOADPLUGINSL_ENTRY );
   497     TRACE_ENTRY_POINT;
   350     // Check plugin isn't already enabled
   498     // Check plugin isn't already enabled
   351     TInt count = aPlugins.Count();
   499     TInt count = aPlugins.Count();
   352     for (TInt index = 0; index < count; ++index )
   500     for (TInt index = 0; index < count; ++index )
   353         {
   501         {
   354         TInt position = iPlugins.Find( aPlugins[index], CPluginInfo::Identifier );
   502         TInt position = iPlugins.Find( aPlugins[index], CPluginInfo::Identifier );
   355         if ( position != KErrNotFound ) 
   503         if ( position != KErrNotFound ) 
   356 	        {
   504 	        {
   357 	        	if((iInfoBarProviderUid != iPlugins[position]->Uid()))
   505             TUid pluginUid = iPlugins[ position]->Uid();
   358 		            {
   506             if(!iPluginInfo[position]->RomBased())           
   359 		            CPluginInfo* removedPlugin = iPlugins[ position ];
   507                 {
   360 		            iPlugins.Remove( position );
   508                     if((iInfoBarProviderUid != iPlugins[position]->Uid())
   361 		            delete removedPlugin;
   509                         && (iPreviewPaneProviderUid != iPlugins[ position]->Uid()))
   362 		            }
   510                         {
   363 	        	else 
   511                         CPluginInfo* removedPlugin = iPlugins[ position ];                   
   364 		        	{
   512                         iPlugins.Remove( position );
   365 		        	iPlugins[position]->Disable(ETrue);
   513                         delete removedPlugin;
   366 					iDefferedUnloadPluginList.AppendL(iPlugins[position]->Uid());
   514                         }
   367 		        	}
   515                     else 
       
   516                         {
       
   517                         iPlugins[position]->Disable(ETrue);
       
   518                         iDefferedUnloadPluginList.AppendL(iPlugins[position]->Uid());
       
   519                         iInfoBarProviderUid = KNullUid;
       
   520                         iPreviewPaneProviderUid = KNullUid;
       
   521                         }
       
   522                 }     
   368 		   }
   523 		   }
   369         }
   524         }
   370     OstTraceFunctionExit0( CCALENCUSTOMISATIONMANAGER_UNLOADPLUGINSL_EXIT );
   525     TRACE_EXIT_POINT;
   371     }
   526     }
   372 
   527 
   373 // ----------------------------------------------------------------------------
   528 // ----------------------------------------------------------------------------
   374 // CCalenCustomisationManager::EnablePluginL
   529 // CCalenCustomisationManager::EnablePluginL
   375 // Enables the given plugin. Returns KErrNotFound if
   530 // Enables the given plugin. Returns KErrNotFound if
   376 // the plugin can't be found, KErrNone otherwise.
   531 // the plugin can't be found, KErrNone otherwise.
   377 // ----------------------------------------------------------------------------
   532 // ----------------------------------------------------------------------------
   378 //
   533 //
   379 void CCalenCustomisationManager::EnablePluginL( TUid aPluginUid )
   534 void CCalenCustomisationManager::EnablePluginL( TUid aPluginUid )
   380     {
   535     {
   381     OstTraceFunctionEntry0( CCALENCUSTOMISATIONMANAGER_ENABLEPLUGINL_ENTRY );
   536     TRACE_ENTRY_POINT;
       
   537     
   382     // Check plugin isn't already enabled
   538     // Check plugin isn't already enabled
   383     TInt index = iPlugins.Find( aPluginUid, CPluginInfo::Identifier);
   539     TInt index = iPlugins.Find( aPluginUid, CPluginInfo::Identifier);
   384     
   540     
   385     if ( index == KErrNotFound )
   541     if ( index == KErrNotFound )
   386         {
   542         {
   396     
   552     
   397         // Issue notification of plugin been added
   553         // Issue notification of plugin been added
   398         iPluginsEnabledDisabled = ETrue;
   554         iPluginsEnabledDisabled = ETrue;
   399         iServices.IssueNotificationL( ECalenNotifyPluginEnabledDisabled );
   555         iServices.IssueNotificationL( ECalenNotifyPluginEnabledDisabled );
   400         }
   556         }
   401     
   557 		else
   402     OstTraceFunctionExit0( CCALENCUSTOMISATIONMANAGER_ENABLEPLUGINL_EXIT );
   558     	{
   403     }
   559 		// Ensure plugin is enabled
   404     
   560 		if(iPlugins[index]->IsDisabled())
       
   561 			{
       
   562 			iPlugins[index]->Disable( EFalse );
       
   563 			iServices.IssueNotificationL( ECalenNotifyPluginEnabledDisabled );
       
   564 			}
       
   565         }
       
   566     
       
   567     TRACE_EXIT_POINT;
       
   568     }
       
   569 	
       
   570 	
       
   571 // ----------------------------------------------------------------------------
       
   572 // CCalenCustomisationManager::LoadPluginsBasedOnVariant
       
   573 // From MCalenNotificationHandler. Handles notifications.
       
   574 // (other items were commented in a header).
       
   575 // ----------------------------------------------------------------------------
       
   576 //
       
   577 void CCalenCustomisationManager::LoadPluginsBasedOnVariantL()
       
   578     {
       
   579     TRACE_ENTRY_POINT
       
   580     
       
   581     TLanguage lang = User::Language();
       
   582     
       
   583     // Based on the variant the plugins will be loaded
       
   584     // Eg. for 01 Euro regional plugins are not needed so all regional plugins will be removed 
       
   585     // other than non regional plugins.
       
   586     // for Chinese variant Thai and vietnamese plugins will be removed 
       
   587     // leaving chinese plugin and other non regional plugins.
       
   588     RArray<TUid> needsToBeRemoved;  
       
   589     
       
   590     switch(lang)
       
   591         {
       
   592         case ELangThai:
       
   593         case ELangEnglish_Thailand:
       
   594             needsToBeRemoved.Append(KCalenChineseImplUid);
       
   595             needsToBeRemoved.Append(KCalenVietnameseImplUid);
       
   596             break;
       
   597         case ELangTaiwanChinese:
       
   598         case ELangHongKongChinese:
       
   599         case ELangPrcChinese:
       
   600             needsToBeRemoved.Append(KCalenThaiImplUid);
       
   601             needsToBeRemoved.Append(KCalenVietnameseImplUid);
       
   602             break;
       
   603         case ELangVietnamese:
       
   604             needsToBeRemoved.Append(KCalenThaiImplUid);
       
   605             needsToBeRemoved.Append(KCalenChineseImplUid);
       
   606             break;
       
   607         default:
       
   608             needsToBeRemoved.Append(KCalenThaiImplUid);
       
   609             needsToBeRemoved.Append(KCalenChineseImplUid);
       
   610             needsToBeRemoved.Append(KCalenVietnameseImplUid);
       
   611             break;
       
   612         }
       
   613     
       
   614     if(needsToBeRemoved.Count())
       
   615         {
       
   616         for(TInt i = 0 ; i < needsToBeRemoved.Count() ; i++)
       
   617             {
       
   618             TInt index = iPluginInfo.Find(needsToBeRemoved[i],CCalenCustomisationManager::PluginInfoFinder);
       
   619             if( index != KErrNotFound )
       
   620                 {
       
   621                 CImplementationInformation* impl = iPluginInfo[index];
       
   622                 iPluginInfo.Remove(index);
       
   623                 delete impl;
       
   624                 }
       
   625             }
       
   626         }
       
   627     
       
   628     needsToBeRemoved.Close();
       
   629     
       
   630     TRACE_EXIT_POINT
       
   631     }
       
   632 
       
   633 // ----------------------------------------------------------------------------
       
   634 // CCalenCustomisationManager::PluginInfoFinder(
       
   635 // Matches an uid in pluginInfo.
       
   636 // (other items were commented in a header).
       
   637 // ----------------------------------------------------------------------------
       
   638 //
       
   639 TBool CCalenCustomisationManager::PluginInfoFinder( const TUid* aUid  , const CImplementationInformation&  aArrayItem)
       
   640     {
       
   641     TRACE_ENTRY_POINT; 
       
   642     TRACE_EXIT_POINT;
       
   643     return (*aUid  == aArrayItem.ImplementationUid() );
       
   644     }
       
   645 
   405 // ----------------------------------------------------------------------------
   646 // ----------------------------------------------------------------------------
   406 // CCalenCustomisationManager::HandleNotificationL
   647 // CCalenCustomisationManager::HandleNotificationL
   407 // From MCalenNotificationHandler. Handles notifications.
   648 // From MCalenNotificationHandler. Handles notifications.
   408 // (other items were commented in a header).
   649 // (other items were commented in a header).
   409 // ----------------------------------------------------------------------------
   650 // ----------------------------------------------------------------------------
   410 //
   651 //
   411 void CCalenCustomisationManager::HandleNotification(const TCalenNotification aNotification )
   652 void CCalenCustomisationManager::HandleNotification(const TCalenNotification aNotification )
   412     {
   653     {
   413     OstTraceFunctionEntry0( CCALENCUSTOMISATIONMANAGER_HANDLENOTIFICATION_ENTRY );
   654     TRACE_ENTRY_POINT;
       
   655     
   414     PIM_TRAPD_HANDLE( HandleNotificationL(aNotification) );
   656     PIM_TRAPD_HANDLE( HandleNotificationL(aNotification) );
   415     OstTraceFunctionExit0( CCALENCUSTOMISATIONMANAGER_HANDLENOTIFICATION_EXIT );
   657     
       
   658     TRACE_EXIT_POINT;
   416     }
   659     }
   417     
   660     
   418 // ----------------------------------------------------------------------------
   661 // ----------------------------------------------------------------------------
   419 // CCalenCustomisationManager::HandleNotificationL
   662 // CCalenCustomisationManager::HandleNotificationL
   420 // Handles notifications that the list of available plugins had been changed,
   663 // Handles notifications that the list of available plugins had been changed,
   424 // made.
   667 // made.
   425 // (other items were commented in a header).
   668 // (other items were commented in a header).
   426 // ----------------------------------------------------------------------------
   669 // ----------------------------------------------------------------------------
   427 //
   670 //
   428 void CCalenCustomisationManager::HandleNotificationL(TCalenNotification aNotification)
   671 void CCalenCustomisationManager::HandleNotificationL(TCalenNotification aNotification)
   429 	{
   672     {
   430 	OstTraceFunctionEntry0( CCALENCUSTOMISATIONMANAGER_HANDLENOTIFICATIONL_ENTRY );
   673     TRACE_ENTRY_POINT;
   431 	switch( aNotification )
   674     
   432 		{
   675      switch( aNotification )
   433 		case ECalenNotifySystemLanguageChanged:
   676         {
   434 			{
   677         case ECalenNotifyCheckPluginUnloading:
   435 			CreateActivePluginListL();
   678         	{
   436 			DoImmediatePluginLoadingL();
   679         	if(iDefferedUnloadPluginList.Count() > 0)
   437 			}
   680 	        	{
   438 			break;
   681 	        	UnloadPluginsL(iDefferedUnloadPluginList);
   439 	}
   682 	        	}
   440     OstTraceFunctionExit0( CCALENCUSTOMISATIONMANAGER_HANDLENOTIFICATIONL_EXIT );
   683         	}
       
   684         	break;
       
   685         case ECalenNotifySettingsChanged:
       
   686 	        {
       
   687 		    // Make sure that any plugins marked as enabled are enabled, and
       
   688 		    // any plugins marked as disabled are disabled.
       
   689 		    iPluginsEnabledDisabled = EFalse;
       
   690 		    TInt pluginCount = iPluginSettingsStatus.Count();
       
   691 		    for ( TInt pluginIndex(0); pluginIndex < pluginCount; ++pluginIndex )
       
   692 		        {
       
   693 		        TUid pluginUid = iPluginSettingsStatus[pluginIndex].iUid;
       
   694 		        TBool enabled = iPluginSettingsStatus[pluginIndex].iEnabled;
       
   695 		 
       
   696 		        SetPluginAvailabilityL( pluginUid, enabled );
       
   697 		        }
       
   698 		        
       
   699 		    if ( iPluginsEnabledDisabled )
       
   700 		        {
       
   701 		        iServices.IssueNotificationL( ECalenNotifySettingsChanged );
       
   702 		        }
       
   703 	        }
       
   704 	        break;
       
   705         case ECalenNotifyEComRegistryChanged:
       
   706             {
       
   707             CreateActivePluginListL();
       
   708             iSetting->UpdatePluginListL(*this);
       
   709             DoImmediatePluginLoadingL();
       
   710             iServices.IssueNotificationL(ECalenNotifyPluginEnabledDisabled);
       
   711             iServices.IssueNotificationL(ECalenNotifySettingsChanged );
       
   712             }
       
   713 	  default:
       
   714             break; 
       
   715         }
       
   716 
       
   717 	  TRACE_EXIT_POINT;
   441     }  
   718     }  
   442 
       
   443 
   719 
   444 // ----------------------------------------------------------------------------
   720 // ----------------------------------------------------------------------------
   445 // CCalenCustomisationManager::PluginInfoArray
   721 // CCalenCustomisationManager::PluginInfoArray
   446 // Returns a const reference to the plugin information array.
   722 // Returns a const reference to the plugin information array.
   447 // (other items were commented in a header).
   723 // (other items were commented in a header).
   448 // ----------------------------------------------------------------------------
   724 // ----------------------------------------------------------------------------
   449 //
   725 //
   450  const RImplInfoPtrArray& CCalenCustomisationManager::PluginInfoArray() const
   726 EXPORT_C const RImplInfoPtrArray& CCalenCustomisationManager::PluginInfoArray() const
   451     {
   727     {
   452     OstTraceFunctionEntry0( CCALENCUSTOMISATIONMANAGER_PLUGININFOARRAY_ENTRY );
   728     TRACE_ENTRY_POINT;
   453     OstTraceFunctionExit0( CCALENCUSTOMISATIONMANAGER_PLUGININFOARRAY_EXIT );
   729     TRACE_EXIT_POINT;
   454     return iPluginInfo;
   730     return iPluginInfo;
   455     }
   731     }
   456 
   732 
   457 
   733 // ----------------------------------------------------------------------------
       
   734 // CCalenCustomisationManager::Views
       
   735 // Returns a const reference to the views array.
       
   736 // (other items were commented in a header).
       
   737 // ----------------------------------------------------------------------------
       
   738 //
       
   739 EXPORT_C const RPointerArray<CCalenViewInfo>& CCalenCustomisationManager::Views() const
       
   740     {
       
   741     TRACE_ENTRY_POINT;
       
   742     TRACE_EXIT_POINT;
       
   743     return iViewInfoArray;
       
   744     }
   458 
   745 
   459 // ----------------------------------------------------------------------------
   746 // ----------------------------------------------------------------------------
   460 // CCalenCustomisationManager::DoImmediatePluginLoadingL
   747 // CCalenCustomisationManager::DoImmediatePluginLoadingL
   461 // Examines the properties of the plugin list and
   748 // Examines the properties of the plugin list and
   462 // loads those that need to loaded on start-up
   749 // loads those that need to loaded on start-up
   463 // (other items were commented in a header).
   750 // (other items were commented in a header).
   464 // ----------------------------------------------------------------------------
   751 // ----------------------------------------------------------------------------
   465 //
   752 //
   466 void CCalenCustomisationManager::DoImmediatePluginLoadingL()
   753 void CCalenCustomisationManager::DoImmediatePluginLoadingL()
   467     {
   754     {
   468     OstTraceFunctionEntry0( CCALENCUSTOMISATIONMANAGER_DOIMMEDIATEPLUGINLOADINGL_ENTRY );
   755     TRACE_ENTRY_POINT;
       
   756 
       
   757     
   469     for(TInt i = 0 ; i < iPlugins.Count() ; i++)
   758     for(TInt i = 0 ; i < iPlugins.Count() ; i++)
   470         {
   759         {
   471         RArray<TUid> pluginArray;
   760         RArray<TUid> pluginArray;
   472         CleanupClosePushL( pluginArray );
   761         CleanupClosePushL( pluginArray );
   473         pluginArray.AppendL( iPlugins[i]->Uid() );
   762         pluginArray.AppendL( iPlugins[i]->Uid() );
   479     TInt pluginCount = iPluginInfo.Count();
   768     TInt pluginCount = iPluginInfo.Count();
   480 
   769 
   481     for ( TInt index( 0 ); index < pluginCount; ++index )
   770     for ( TInt index( 0 ); index < pluginCount; ++index )
   482         {
   771         {
   483         TUid pluginUid = iPluginInfo[index]->ImplementationUid();
   772         TUid pluginUid = iPluginInfo[index]->ImplementationUid();
   484         if ( iActivePlugins.Find( pluginUid ) != KErrNotFound )
   773         
       
   774         if ( iActivePlugins.Find( pluginUid ) != KErrNotFound )        
       
   775         
   485             {
   776             {
   486             TRAPD( error, LoadPluginL( pluginUid ) );
   777             TRAPD( error, LoadPluginL( pluginUid ) );
   487             if ( error )
   778             if ( error )
   488                 {
   779                 {
   489                 // report a problem loading the plugin
   780                 // report a problem loading the plugin
   490                 
   781                 
   491                 }
   782                 }
   492             }
   783             }
   493         }
   784         }
   494 
   785    
   495     OstTraceFunctionExit0( CCALENCUSTOMISATIONMANAGER_DOIMMEDIATEPLUGINLOADINGL_EXIT );
   786     TRACE_EXIT_POINT;
   496     }
   787     }
   497 
   788 
   498 // ----------------------------------------------------------------------------
   789 // ----------------------------------------------------------------------------
   499 // CCalenCustomisationManager::LoadPluginL
   790 // CCalenCustomisationManager::LoadPluginL
   500 // Loads a plugin
   791 // Loads a plugin
   501 // (other items were commented in a header).
   792 // (other items were commented in a header).
   502 // ----------------------------------------------------------------------------
   793 // ----------------------------------------------------------------------------
   503 //
   794 //
   504 void CCalenCustomisationManager::LoadPluginL( TUid aPluginUid )
   795 void CCalenCustomisationManager::LoadPluginL( TUid aPluginUid )
   505     {
   796     {
   506     OstTraceFunctionEntry0( CCALENCUSTOMISATIONMANAGER_LOADPLUGINL_ENTRY );
   797     TRACE_ENTRY_POINT;
       
   798 
   507     // Get a new services object from global data
   799     // Get a new services object from global data
   508     MCalenServices* services = iServicesFactory.NewServicesL();
   800     MCalenServices* services = iServicesFactory.NewServicesL();
   509     CleanupStack::PushL( services );
   801     
   510     // Creates the plugin and transfers ownership of the services
   802     // Creates the plugin and transfers ownership of the services
   511     // object to the plugin.
   803     // object to the plugin.
   512     CCalenCustomisation* plugin = 
   804     CCalenCustomisation* plugin = 
   513         CCalenCustomisation::CreateImplementationL( aPluginUid, services );
   805         CCalenCustomisation::CreateImplementationL( aPluginUid, services );
   514     CleanupStack::PushL( plugin );
   806     
       
   807    CleanupStack::PushL( plugin );
   515 
   808 
   516     // the plugin array takes ownership of the plugin
   809     // the plugin array takes ownership of the plugin
   517     AddPluginL( plugin, aPluginUid  );
   810     AddPluginL( plugin, aPluginUid  );
   518     
       
   519     // Cleanup
       
   520     CleanupStack::Pop( plugin );
   811     CleanupStack::Pop( plugin );
   521     CleanupStack::Pop( services );
   812 
   522 
   813         
   523 
   814     RArray<TInt> hiddenViews;
   524     OstTraceFunctionExit0( CCALENCUSTOMISATIONMANAGER_LOADPLUGINL_EXIT );
   815     CleanupClosePushL( hiddenViews );
   525     }
   816     plugin->RemoveViewsFromCycle( hiddenViews );
   526 
   817     TInt hiddenViewCount = hiddenViews.Count();
   527  
   818     if ( hiddenViewCount )
   528 
   819         {
       
   820         // Get the default view form the settings to check if it is going to be hidden
       
   821         // by the installed plugin
       
   822         TUid defaultView = iSetting->DefaultView();
       
   823         for ( TInt index(0); index < hiddenViewCount; ++index )
       
   824             {
       
   825             TInt hiddenViewId = hiddenViews[index];
       
   826             iHiddenViews.InsertInOrderAllowRepeatsL( hiddenViewId );
       
   827             
       
   828             // If this view is already on the view cycle list it needs
       
   829             // to be hidden.
       
   830             TUid hiddenViewUid = TUid::Uid( hiddenViewId );
       
   831             
       
   832             // If the current default view is hidden, then set the newly
       
   833             // installed plugin view as default view
       
   834             if(defaultView == hiddenViewUid)
       
   835             	iSetting->SetDefaultView(aPluginUid);
       
   836             
       
   837             TInt position = iViewInfoArray.Find( hiddenViewUid, 
       
   838                                      CCalenViewInfo::ViewInfoIdentifier );
       
   839                                      
       
   840             if ( position != KErrNotFound )
       
   841                 {
       
   842                 CCalenViewInfo* viewInfo = iViewInfoArray[position];
       
   843                 viewInfo->Hide( ETrue );
       
   844                 
       
   845                 // By hiding the view, the cycleposition order may be changed
       
   846                 // so the view info array needs to be resorted.
       
   847                 iViewInfoArray.Sort( iSortOrder );
       
   848                 }
       
   849             }
       
   850         }
       
   851     CleanupStack::PopAndDestroy(); // removedViews
       
   852 
       
   853     TRACE_EXIT_POINT;
       
   854     }
       
   855 
       
   856  // ----------------------------------------------------------------------------
       
   857 // CCalenCustomisationManager::OfferMenuPaneL
       
   858 // Offers a menupane for customisation by plugins
       
   859 // and the controller.
       
   860 // (other items were commented in a header).
       
   861 // ----------------------------------------------------------------------------
       
   862 //
       
   863 EXPORT_C void CCalenCustomisationManager::OfferMenuPaneL( TInt aResourceId,
       
   864                                                           CEikMenuPane* aMenuPane )
       
   865     {
       
   866     TRACE_ENTRY_POINT;
       
   867 
       
   868     // Offer the menu to registered plugins
       
   869     OfferMenuPaneToPluginsL( aResourceId, aMenuPane );
       
   870 
       
   871     // If the menupane is a main menu, a check needs to be made that the
       
   872     // exit and switch view commands exist
       
   873 
       
   874     // Replace the send menu if it exists
       
   875     TInt position( 0 );
       
   876     if ( aMenuPane->MenuItemExists( ECalenSend, position) )
       
   877         {
       
   878         // Delete the existing send menu option
       
   879         aMenuPane->DeleteMenuItem(ECalenSend);
       
   880 
       
   881         // Insert the calensend menu item
       
   882         iGlobalData->CalenSendL().DisplaySendMenuItemL( *aMenuPane, position );
       
   883         } 
       
   884 
       
   885     // If the menu has a view switch menu item, it is up to the 
       
   886     // customisation manager to decide if the menu should be 
       
   887     // cascading or a selection list box. 
       
   888     if ( aMenuPane->MenuItemExists( ECalenSwitchView, position) )
       
   889         {
       
   890         CEikMenuPaneItem::SData& switchItem =  aMenuPane->ItemData( ECalenSwitchView );
       
   891         if ( iActivePlugins.Count() == 0 )
       
   892             {
       
   893             // Create a cascading menu
       
   894             switchItem.iCascadeId = R_CALENDAR_CHANGE_VIEW_MENUPANE;
       
   895             }
       
   896         else
       
   897             {
       
   898             switchItem.iCascadeId = 0;
       
   899             }
       
   900         }
       
   901 
       
   902     TRACE_EXIT_POINT;
       
   903     }
       
   904     
       
   905 // ----------------------------------------------------------------------------
       
   906 // CCalenCustomisationManager::CheckHiddenViewL(
       
   907 // A check needs to be made to see if any other plugins hide the same view.
       
   908 // ----------------------------------------------------------------------------
       
   909 //
       
   910 void CCalenCustomisationManager::CheckHiddenViewL( TUid aViewUid, TUid aPluginUid )
       
   911     {
       
   912     TRACE_ENTRY_POINT;
       
   913     
       
   914     // Find the viewId in the hidden view list, and remove it
       
   915     TInt viewId = aViewUid.iUid;
       
   916     TInt position = iHiddenViews.Find( viewId );
       
   917     if ( position != KErrNotFound )
       
   918         {
       
   919         iHiddenViews.Remove( position );
       
   920         
       
   921         // Try to find the view again, in case it is hidden by another view
       
   922         position = iHiddenViews.Find( viewId );
       
   923         if ( position == KErrNotFound )
       
   924             {
       
   925             // If it can't be found in the hidden view list,
       
   926             // it can be unhidden. 
       
   927             TInt viewInfoPos = iViewInfoArray.Find( aViewUid , 
       
   928                                      CCalenViewInfo::ViewInfoIdentifier );
       
   929                                      
       
   930             if ( viewInfoPos != KErrNotFound )
       
   931                 {
       
   932                 // Unhide the view
       
   933                 CCalenViewInfo* viewInfo = iViewInfoArray[viewInfoPos];
       
   934                 viewInfo->Hide( EFalse );
       
   935                 
       
   936                 // Set hidden view as default view if the currently disabled plugin
       
   937                 // is the default view
       
   938                 TInt position = iViewInfoArray.Find( aPluginUid, 
       
   939                                                            CCalenViewInfo::ViewPluginIdentifier );
       
   940                 if(position != -1)
       
   941                   {
       
   942                   for(TInt i = position; i < iViewInfoArray.Count(); i++)
       
   943                       {
       
   944                       if((iViewInfoArray[i]->PluginUid() == aPluginUid) &&
       
   945                               iViewInfoArray[i]->ViewUid() == iSetting->DefaultView())
       
   946                           {
       
   947                           iSetting->SetDefaultView(aViewUid);
       
   948                           break;
       
   949                           }
       
   950                       }
       
   951                   }
       
   952                                 
       
   953                 // By unhiding the view, the cycleposition order may be changed
       
   954                 // so the view info array needs to be resorted.
       
   955                 iViewInfoArray.Sort( iSortOrder );
       
   956                 }
       
   957             }
       
   958         }
       
   959     TRACE_EXIT_POINT;
       
   960     }
       
   961 
       
   962 // ----------------------------------------------------------------------------
       
   963 // CCalenCustomisationManager::GetReplacePluginViewIdL
       
   964 // Returns the view ID of the plugin that hides a particular view
       
   965 // ----------------------------------------------------------------------------
       
   966 //
       
   967 EXPORT_C TUid CCalenCustomisationManager::GetReplacePluginViewIdL( TUid aHiddenViewId )
       
   968 	{
       
   969 	TRACE_ENTRY_POINT;
       
   970 	
       
   971 	RArray<TInt> removedViews;
       
   972 	CCalenCustomisation* plugin = NULL;
       
   973 	TInt i = 0;
       
   974 	for( ;i < iActivePlugins.Count(); i++)
       
   975 	{
       
   976         plugin = FindPluginL(iActivePlugins[i]);
       
   977 		plugin->RemoveViewsFromCycle(removedViews);
       
   978 		if(removedViews.Count())
       
   979 		{
       
   980 			TInt position = removedViews.Find(aHiddenViewId.iUid);
       
   981 			if(position != KErrNotFound)
       
   982 			    break;
       
   983 			else
       
   984 				continue;
       
   985 		    }
       
   986 		else
       
   987 		    {
       
   988 			continue;
       
   989 		    }	
       
   990 	    }
       
   991 	removedViews.Reset();
       
   992 	
       
   993 	// Get all the views provided by the plugin
       
   994 	//plugin->GetCustomViewsL()
       
   995 	TInt position = iViewInfoArray.Find( iActivePlugins[i], 
       
   996 	                                       CCalenViewInfo::ViewPluginIdentifier );
       
   997 	while((position < iViewInfoArray.Count()) && ((iViewInfoArray[position]->CyclePosition() == CCalenView::ENoCyclePosition) ||
       
   998 	        (iActivePlugins[i] != (iViewInfoArray[position]->PluginUid()))))
       
   999 	    {
       
  1000 	    // go to the next view position
       
  1001 	    position++;
       
  1002 	    }
       
  1003     TRACE_EXIT_POINT;   
       
  1004 
       
  1005     return (iViewInfoArray[position]->ViewUid());
       
  1006 	}
       
  1007 
       
  1008 // ----------------------------------------------------------------------------
       
  1009 // CCalenCustomisationManager::GetReplacePluginViewIdL
       
  1010 // Returns the hidden views list 
       
  1011 // ----------------------------------------------------------------------------
       
  1012 //
       
  1013 EXPORT_C void CCalenCustomisationManager::GetHiddenViewIdL( TUid aPluginUid, RArray<TInt>& aHiddenViews )
       
  1014 	{
       
  1015 	TRACE_ENTRY_POINT;
       
  1016 	
       
  1017 	// Get the plugin instance
       
  1018 	CCalenCustomisation* plugin = FindPluginL(aPluginUid);
       
  1019 	
       
  1020 	plugin->RemoveViewsFromCycle(aHiddenViews);
       
  1021 	
       
  1022 	TRACE_EXIT_POINT;	
       
  1023 	}
       
  1024 
       
  1025 // ----------------------------------------------------------------------------
       
  1026 // CCalenCustomisationManager::CustomPreviewPaneL
       
  1027 // Returns the preview pane
       
  1028 // (other items were commented in a header).
       
  1029 // ----------------------------------------------------------------------------
       
  1030 EXPORT_C MCalenPreview* CCalenCustomisationManager::CustomPreviewPaneL( TRect& aRect )
       
  1031 	{
       
  1032 	MCalenPreview* previewPane = NULL;
       
  1033    
       
  1034    
       
  1035     // Loop though all the command handlers, within two interlinked
       
  1036     // for loops. If PreviewPaneL leaves for one plugin, a plugin
       
  1037     // error message will be displayed and the loop will continue with
       
  1038     // the next command handler. If none of the plugins leave, there will
       
  1039     // be only one TRAP used.
       
  1040     TInt count = iPlugins.Count();
       
  1041     for ( TInt index = 0; index < count && !previewPane; ++index )
       
  1042         {
       
  1043         TRAPD( error,
       
  1044                 {
       
  1045                  // Loop though until an infobar is found
       
  1046                 for (; index < count && !previewPane; ++index )
       
  1047                     {
       
  1048                     if ( !iPlugins[index]->IsDisabled() )
       
  1049                         {
       
  1050                         previewPane = iPlugins[index]->Plugin().CustomPreviewPaneL( aRect );
       
  1051                         }
       
  1052                     }
       
  1053                 }
       
  1054              );
       
  1055         if ( error )
       
  1056             {
       
  1057             // Report a problem with plugin.
       
  1058             }
       
  1059         }
       
  1060     
       
  1061     TRACE_EXIT_POINT;
       
  1062     return previewPane;
       
  1063 	}
       
  1064 // ----------------------------------------------------------------------------
       
  1065 // CCalenCustomisationManager::PreviewPane
       
  1066 // Returns the preview pane
       
  1067 // (other items were commented in a header).
       
  1068 // ----------------------------------------------------------------------------
       
  1069 EXPORT_C CCoeControl* CCalenCustomisationManager::PreviewPane(   TRect& aRect  )
       
  1070     {
       
  1071     TRACE_ENTRY_POINT;
       
  1072 	
       
  1073     iInfoBarProviderUid = TUid::Uid(0);;		
       
  1074     iPreviewPaneProviderUid = TUid::Uid(0);
       
  1075     
       
  1076     CCoeControl* previewPane = NULL;
       
  1077    
       
  1078     // Loop though all the command handlers, within two interlinked
       
  1079     // for loops. If PreviewPaneL leaves for one plugin, a plugin
       
  1080     // error message will be displayed and the loop will continue with
       
  1081     // the next command handler. If none of the plugins leave, there will
       
  1082     // be only one TRAP used.
       
  1083     TInt count = iPlugins.Count();
       
  1084     for ( TInt index = 0; index < count && !previewPane; ++index )
       
  1085         {
       
  1086         TRAPD( error,
       
  1087             // Loop though until an infobar is found
       
  1088             for (; index < count && !previewPane; ++index )
       
  1089                 {
       
  1090                 
       
  1091                 if ( !iPlugins[index]->IsDisabled() )
       
  1092                     {
       
  1093                     previewPane = iPlugins[index]->Plugin().PreviewPaneL( aRect );
       
  1094                     if(previewPane)
       
  1095 						{
       
  1096                     	iPreviewPaneProviderUid = iPlugins[index]->Uid();
       
  1097 						}
       
  1098                     }
       
  1099                 
       
  1100                 }
       
  1101              );
       
  1102 
       
  1103         if ( error )
       
  1104             {
       
  1105             // Report a problem with plugin.
       
  1106             }
       
  1107         }
       
  1108     
       
  1109     TRACE_EXIT_POINT;
       
  1110     return previewPane;
       
  1111     }
   529 
  1112 
   530 // ----------------------------------------------------------------------------
  1113 // ----------------------------------------------------------------------------
   531 // CCalenCustomisationManager::Infobar
  1114 // CCalenCustomisationManager::Infobar
   532 // Returns the infobar.
  1115 // Returns the infobar.
   533 // (other items were commented in a header).
  1116 // (other items were commented in a header).
   534 // ----------------------------------------------------------------------------
  1117 // ----------------------------------------------------------------------------
   535  HbWidget* CCalenCustomisationManager::Infobar( )
  1118 EXPORT_C CCoeControl* CCalenCustomisationManager::Infobar(const  TRect& aRect )
   536     {
  1119     {
   537     OstTraceFunctionEntry0( CCALENCUSTOMISATIONMANAGER_INFOBAR_ENTRY );
  1120     TRACE_ENTRY_POINT;
       
  1121 
   538     iInfoBarProviderUid = TUid::Uid(0);
  1122     iInfoBarProviderUid = TUid::Uid(0);
   539        
  1123     iPreviewPaneProviderUid = TUid::Uid(0);
   540     HbWidget* infoBar =NULL;
  1124     
       
  1125     CCoeControl* infoBar = NULL;
   541     // Loop though all the command handlers, within two interlinked
  1126     // Loop though all the command handlers, within two interlinked
   542     // for loops. If GetInfoBarL leaves for one plugin, a plugin
  1127     // for loops. If GetInfoBarL leaves for one plugin, a plugin
   543     // error message will be displayed and the loop will continue with
  1128     // error message will be displayed and the loop will continue with
   544     // the next command handler. If none of the plugins leave, there will
  1129     // the next command handler. If none of the plugins leave, there will
   545     // be only one TRAP used.
  1130     // be only one TRAP used.
   546     TInt count = iPlugins.Count();
  1131     TInt count = iPlugins.Count();
   547     /*if(count > 0)
       
   548         {
       
   549         infoBar = iPlugins[0]->Plugin().InfobarL();
       
   550         iInfoBarProviderUid = iPlugins[0]->Uid();
       
   551         }*/
       
   552     
       
   553     for ( TInt index = 0; index < count && !infoBar; ++index )
  1132     for ( TInt index = 0; index < count && !infoBar; ++index )
   554         {
  1133         {
   555         TRAPD( error,
  1134         TRAPD( error,
   556             // Loop though until an infobar is found
  1135             // Loop though until an infobar is found
   557             for (; index < count && !infoBar; ++index )
  1136             for (; index < count && !infoBar; ++index )
   558                 {
  1137                 {
   559                 //if ( !iPlugins[index]->IsDisabled() )
  1138                 if ( !iPlugins[index]->IsDisabled() )
   560                     {
  1139                     {
   561                     infoBar = iPlugins[index]->Plugin().InfobarL();
  1140                     infoBar = iPlugins[index]->Plugin().InfobarL( aRect  );
   562                     iInfoBarProviderUid = iPlugins[index]->Uid();
  1141                     iInfoBarProviderUid = iPlugins[index]->Uid();
   563                     }
  1142                     }
   564                 }
  1143                 }
   565              );
  1144              );
   566         if(error)
  1145 
   567         	{
  1146         if ( error )
   568         		// Need to handle the error case
  1147             {
   569         	}
  1148             // Report a problem with plugin.
       
  1149             }
   570         }
  1150         }
   571         
  1151         
   572     OstTraceFunctionExit0( CCALENCUSTOMISATIONMANAGER_INFOBAR_EXIT );
  1152     TRACE_EXIT_POINT;   
   573     return infoBar;
  1153     return infoBar;
   574     }
  1154     }
   575 
  1155     
   576  // ----------------------------------------------------------------------------
  1156 // ----------------------------------------------------------------------------
   577  // CCalenCustomisationManager::InfobarTextL
  1157 // CCalenCustomisationManager::Infobar
   578  // @returns info bar text
  1158 // Returns the infobar.
   579  // (other items were commented in a header).
  1159 // (other items were commented in a header).
   580  // ----------------------------------------------------------------------------
  1160 // ----------------------------------------------------------------------------
   581  //
  1161 EXPORT_C const TDesC& CCalenCustomisationManager::Infobar()
   582  QString* CCalenCustomisationManager::InfobarTextL()
  1162     {
   583     {
  1163     TRACE_ENTRY_POINT;
   584 	OstTraceFunctionEntry0( CCALENCUSTOMISATIONMANAGER_INFOBARTEXTL_ENTRY );
  1164 
   585 	iInfoBarProviderUid = TUid::Uid(0);
  1165     iInfoBarProviderUid = TUid::Uid(0);
   586 		
  1166     iPreviewPaneProviderUid = TUid::Uid(0);
   587 	QString* infoBarText =NULL;
  1167     
   588 	// Loop though all the command handlers, within two interlinked
  1168     iInfoBarStr.Set(KNullDesC);
   589 	// for loops. If GetInfoBarL leaves for one plugin, a plugin
  1169     // Loop though all the command handlers, within two interlinked
   590 	// error message will be displayed and the loop will continue with
  1170     // for loops. If GetInfoBarL leaves for one plugin, a plugin
   591 	// the next command handler. If none of the plugins leave, there will
  1171     // error message will be displayed and the loop will continue with
   592 	// be only one TRAP used.
  1172     // the next command handler. If none of the plugins leave, there will
   593 	TInt count = iPlugins.Count();
  1173     // be only one TRAP used.
   594 	/*if(count > 0)
  1174     TBool infoBarFound = EFalse;
       
  1175     TInt count = iPlugins.Count();
       
  1176     for ( TInt index = 0; index < count && !infoBarFound; ++index )
       
  1177         {
       
  1178         TRAPD( error,
       
  1179             // Loop though until an infobar is found
       
  1180             for (; index < count && !infoBarFound; ++index )
       
  1181                 {
       
  1182                 if ( !iPlugins[index]->IsDisabled() )
       
  1183                     {
       
  1184                     iInfoBarStr.Set( iPlugins[index]->Plugin().InfobarL() );
       
  1185                     if(iInfoBarStr.Length())
       
  1186                         {
       
  1187                         infoBarFound = ETrue;
       
  1188                         }
       
  1189                     iInfoBarProviderUid = iPlugins[index]->Uid();
       
  1190                     }
       
  1191                 }
       
  1192              );
       
  1193 
       
  1194         if ( error )
       
  1195             {
       
  1196             // Report a problem with plugin.
       
  1197             }
       
  1198         }
       
  1199         
       
  1200     TRACE_EXIT_POINT;   
       
  1201     return iInfoBarStr;
       
  1202     }
       
  1203     
       
  1204 // ----------------------------------------------------------------------------
       
  1205 // CCalenCustomisationManager::HiddenView
       
  1206 // Return ETrue if a view has been hidden by a plugin
       
  1207 // (other items were commented in a header).
       
  1208 // ----------------------------------------------------------------------------
       
  1209 //         
       
  1210 EXPORT_C TBool CCalenCustomisationManager::HiddenView( TUid aHiddenView) const
       
  1211     {
       
  1212     TRACE_ENTRY_POINT;
       
  1213     TRACE_EXIT_POINT;
       
  1214     return ( iHiddenViews.Find( aHiddenView.iUid ) != KErrNotFound );
       
  1215     }
       
  1216     
       
  1217     
       
  1218 // ----------------------------------------------------------------------------
       
  1219 // CCalenCustomisationManager::RomBased(
       
  1220 // Return ETrue if a view has been provided by a rom-based plugin
       
  1221 // (other items were commented in a header).
       
  1222 // ----------------------------------------------------------------------------
       
  1223 //  
       
  1224 EXPORT_C TBool CCalenCustomisationManager::IsViewRomBased( TUid aViewUid ) const
       
  1225     {
       
  1226     TRACE_ENTRY_POINT;
       
  1227     
       
  1228     TBool isRomBased = EFalse;
       
  1229     
       
  1230     TInt viewInfoPos = iViewInfoArray.Find( aViewUid , 
       
  1231                                      CCalenViewInfo::ViewInfoIdentifier );
       
  1232     if ( viewInfoPos != KErrNotFound )
       
  1233         {
       
  1234         TUid plugUid = iViewInfoArray[viewInfoPos]->PluginUid();
       
  1235         TInt position = iRomBasedPlugins.Find( plugUid );
       
  1236         if ( position != KErrNotFound )
       
  1237             {
       
  1238             isRomBased = ETrue;
       
  1239             }
       
  1240         }
       
  1241     
       
  1242     TRACE_EXIT_POINT;
       
  1243     return isRomBased;
       
  1244     }
       
  1245 
       
  1246 // ----------------------------------------------------------------------------
       
  1247 // CCalenCustomisationManager::CanBeEnabledDisabled(
       
  1248 // Return ETrue if plugins can be enabled/disabled from settings
       
  1249 // (other items were commented in a header).
       
  1250 // ----------------------------------------------------------------------------
       
  1251 //
       
  1252 EXPORT_C TBool CCalenCustomisationManager::CanBeEnabledDisabledL(TUid aPluginUid)
       
  1253     {
       
  1254     TRACE_ENTRY_POINT;
       
  1255     TBool enabledDisabled = EFalse;
       
  1256     
       
  1257     CCalenCustomisation* plugin = FindPluginL(aPluginUid);
       
  1258     if(plugin)
   595 		{
  1259 		{
   596 		infoBar = iPlugins[0]->Plugin().InfobarL();
  1260         enabledDisabled = plugin->CanBeEnabledDisabled();
   597 		iInfoBarProviderUid = iPlugins[0]->Uid();
  1261 		}
   598 		}*/
  1262     
   599 	
  1263     TRACE_EXIT_POINT;
   600 	for ( TInt index = 0; index < count && !infoBarText; ++index )
  1264     return enabledDisabled;
   601 		 {
  1265     }
   602 		 TRAPD( error,
  1266 
   603 			 // Loop though until an infobar is found
  1267 // ----------------------------------------------------------------------------
   604 			 for (; index < count && !infoBarText; ++index )
  1268 // CCalenCustomisationManager::OfferMenuPaneL
   605 				 {
  1269 // Offers a menupane to all interested plugins
   606 				 //if ( !iPlugins[index]->IsDisabled() )
  1270 // (other items were commented in a header).
   607 					 {
  1271 // ----------------------------------------------------------------------------
   608 					 infoBarText = iPlugins[index]->Plugin().InfobarTextL();
  1272 //
   609 					 iInfoBarProviderUid = iPlugins[index]->Uid();
  1273 void CCalenCustomisationManager::OfferMenuPaneToPluginsL( TInt aResourceId,
   610 					 }
  1274                                                           CEikMenuPane* aMenuPane )
   611 				 }
  1275     {
   612 			  );
  1276     TRACE_ENTRY_POINT;
   613 		 if(error)
  1277 
   614 				{
       
   615 					// Need to handle the error case
       
   616 				}
       
   617 		 
       
   618 		 }
       
   619 		 
       
   620 	OstTraceFunctionExit0( CCALENCUSTOMISATIONMANAGER_INFOBARTEXTL_EXIT );
       
   621 	return infoBarText;
       
   622     }
       
   623 
       
   624 // ----------------------------------------------------------------------------
       
   625 // CCalenCustomisationManager::FindPluginL
       
   626 // Finds a plugin and returns a plugin with a given uid, returns NULL
       
   627 // if the uid can not be found.
       
   628 // (other items were commented in a header).
       
   629 // ----------------------------------------------------------------------------
       
   630 //
       
   631 CCalenCustomisation* CCalenCustomisationManager::FindPluginL( TUid aUid )
       
   632     {
       
   633     OstTraceFunctionEntry0( CCALENCUSTOMISATIONMANAGER_FINDPLUGINL_ENTRY );
       
   634     TInt index = iPlugins.Find( aUid, CPluginInfo::Identifier );
       
   635     
       
   636     CCalenCustomisation* plugin = NULL;
       
   637     if ( index != KErrNotFound )
       
   638         {
       
   639         plugin = &( iPlugins[index]->Plugin() );
       
   640         }
       
   641 
       
   642     OstTraceFunctionExit0( CCALENCUSTOMISATIONMANAGER_FINDPLUGINL_EXIT );
       
   643     return plugin;
       
   644     }
       
   645 
       
   646 // ----------------------------------------------------------------------------
       
   647 // CCalenCustomisationManager::CPluginInfo::CPluginInfo(
       
   648 // C++ constructor
       
   649 // (other items were commented in a header).
       
   650 // ----------------------------------------------------------------------------
       
   651 //
       
   652 CCalenCustomisationManager::CPluginInfo::CPluginInfo( 
       
   653                                     CCalenCustomisation* aPlugin,
       
   654                                     TUid aUid )
       
   655     : iPlugin( aPlugin ),
       
   656       iUid( aUid )
       
   657     {
       
   658     OstTraceFunctionEntry0( CPLUGININFO_CPLUGININFO_ENTRY );
       
   659     OstTraceFunctionExit0( CPLUGININFO_CPLUGININFO_EXIT );
       
   660     }
       
   661 
       
   662 // ----------------------------------------------------------------------------
       
   663 // CCalenCustomisationManager::CPluginInfo::~CPluginInfo(
       
   664 // C++ destructor
       
   665 // (other items were commented in a header).
       
   666 // ----------------------------------------------------------------------------
       
   667 //
       
   668 CCalenCustomisationManager::CPluginInfo::~CPluginInfo() 
       
   669     {
       
   670     OstTraceFunctionEntry0( DUP1_CPLUGININFO_CPLUGININFO_ENTRY );
       
   671     delete iPlugin;
       
   672 
       
   673     OstTraceFunctionExit0( DUP1_CPLUGININFO_CPLUGININFO_EXIT );
       
   674     }
       
   675     
       
   676 // ----------------------------------------------------------------------------
       
   677 // CCalenCustomisationManager::CPluginInfo::Plugin
       
   678 // returns a reference to the plugin
       
   679 // (other items were commented in a header).
       
   680 // ----------------------------------------------------------------------------
       
   681 //
       
   682 CCalenCustomisation& CCalenCustomisationManager::CPluginInfo::Plugin()
       
   683     {
       
   684 OstTraceFunctionEntry0( CPLUGININFO_PLUGIN_ENTRY );
       
   685 
       
   686     OstTraceFunctionExit0( CPLUGININFO_PLUGIN_EXIT );
       
   687     return *iPlugin;
       
   688     }
       
   689 
       
   690 // ----------------------------------------------------------------------------
       
   691 // CCalenCustomisationManager::CPluginInfo::Uid
       
   692 // returns the plugin uid
       
   693 // (other items were commented in a header).
       
   694 // ----------------------------------------------------------------------------
       
   695 // 
       
   696 TUid CCalenCustomisationManager::CPluginInfo::Uid() const 
       
   697     {
       
   698     OstTraceFunctionEntry0( CPLUGININFO_UID_ENTRY );
       
   699     OstTraceFunctionExit0( CPLUGININFO_UID_EXIT );
       
   700     return iUid;
       
   701     }
       
   702    
       
   703 // ----------------------------------------------------------------------------
       
   704 // CCalenCustomisationManager::CPluginInfo::Disable
       
   705 // Marks the plugin as being disabled
       
   706 // (other items were commented in a header).
       
   707 // ----------------------------------------------------------------------------
       
   708 //  
       
   709 void CCalenCustomisationManager::CPluginInfo::Disable( TBool aDisable)
       
   710     {
       
   711     OstTraceFunctionEntry0( CPLUGININFO_DISABLE_ENTRY );
       
   712     iDisabled = aDisable;
       
   713      
       
   714     OstTraceFunctionExit0( CPLUGININFO_DISABLE_EXIT );
       
   715     }
       
   716     
       
   717 // ----------------------------------------------------------------------------
       
   718 // CCalenCustomisationManager::CPluginInfo::IsDisabled
       
   719 // Returns if the plugin has been marked as being disabled
       
   720 // (other items were commented in a header).
       
   721 // ----------------------------------------------------------------------------
       
   722 //  
       
   723 TBool CCalenCustomisationManager::CPluginInfo::IsDisabled()
       
   724     {
       
   725     OstTraceFunctionEntry0( CPLUGININFO_ISDISABLED_ENTRY );
       
   726     OstTraceFunctionExit0( CPLUGININFO_ISDISABLED_EXIT );
       
   727     return iDisabled;
       
   728     }
       
   729     
       
   730   
       
   731 
       
   732 // ----------------------------------------------------------------------------
       
   733 // CCalenCustomisationManager::AddPluginL
       
   734 // Adds a plugin to the array of plugins
       
   735 // (other items were commented in a header).
       
   736 // ----------------------------------------------------------------------------
       
   737 //           
       
   738 void CCalenCustomisationManager::AddPluginL( CCalenCustomisation* aPlugin,
       
   739                                              TUid aUid ) 
       
   740     {
       
   741     OstTraceFunctionEntry0( CCALENCUSTOMISATIONMANAGER_ADDPLUGINL_ENTRY );
       
   742     CPluginInfo* newPlugin = new ( ELeave ) CPluginInfo( aPlugin, aUid);
       
   743     CleanupStack::PushL( newPlugin );
       
   744     iPlugins.AppendL( newPlugin );
       
   745     CleanupStack::Pop( newPlugin );
       
   746     OstTraceFunctionExit0( CCALENCUSTOMISATIONMANAGER_ADDPLUGINL_EXIT );
       
   747     }
       
   748 
       
   749 // ----------------------------------------------------------------------------
       
   750 // CCalenCustomisationManager::CPluginInfo::Identifier(
       
   751 // Matches an uid and a plugin uid. Used by FindPluginL to
       
   752 // find a plugin with a given uid. 
       
   753 // (other items were commented in a header).
       
   754 // ----------------------------------------------------------------------------
       
   755 //
       
   756 TBool CCalenCustomisationManager::CPluginInfo::Identifier( const TUid* aUid,
       
   757                                                            const CPluginInfo& aArray )
       
   758     {
       
   759     OstTraceFunctionEntry0( CPLUGININFO_IDENTIFIER_ENTRY );
       
   760     return ( *aUid == aArray.Uid() ); 
       
   761     }
       
   762 
       
   763 
       
   764     
       
   765 // ----------------------------------------------------------------------------
       
   766 // CCalenCustomisationManager::Identifier(
       
   767 // Matches an uid and a plugin uid. Used by when finding the disabled plugins
       
   768 // (other items were commented in a header).
       
   769 // ----------------------------------------------------------------------------
       
   770 //  
       
   771 TBool CCalenCustomisationManager::PluginAvailabilityFinder( const TUid* aUid, 
       
   772                                  const TCalenPluginAvailability& aArrayItem )
       
   773     {
       
   774     OstTraceFunctionEntry0( CCALENCUSTOMISATIONMANAGER_PLUGINAVAILABILITYFINDER_ENTRY );
       
   775     
       
   776     OstTraceFunctionExit0( CCALENCUSTOMISATIONMANAGER_PLUGINAVAILABILITYFINDER_EXIT );
       
   777     return ( *aUid == aArrayItem.iUid); 
       
   778     }   
       
   779 
       
   780 // ----------------------------------------------------------------------------
       
   781 // CCalenCustomisationManager::OfferMenu
       
   782 // Offers a menupane for customisation by plugins
       
   783 // and the controller.
       
   784 // (other items were commented in a header).
       
   785 // ----------------------------------------------------------------------------
       
   786 //
       
   787 void CCalenCustomisationManager::OfferMenu(HbMenu* aHbMenu )
       
   788     {
       
   789     OstTraceFunctionEntry0( CCALENCUSTOMISATIONMANAGER_OFFERMENU_ENTRY );
       
   790     // Get the number of command handlers
  1278     // Get the number of command handlers
   791     //   TInt count = iCommandHandlers.Count();
  1279  //   TInt count = iCommandHandlers.Count();
   792     const TInt count = iPlugins.Count();
  1280     const TInt count = iPlugins.Count();
   793 
  1281 
   794     // Loop though all the command handlers, within two interlinked
  1282     // Loop though all the command handlers, within two interlinked
   795     // for loops. If customiseMenuPane leaves for one plugin, a plugin
  1283     // for loops. If customiseMenuPane leaves for one plugin, a plugin
   796     // error message will be displayed and the loop will continue with
  1284     // error message will be displayed and the loop will continue with
   799     for ( TInt index = 0; index < count; ++index )
  1287     for ( TInt index = 0; index < count; ++index )
   800         {
  1288         {
   801         TRAPD( error,
  1289         TRAPD( error,
   802             for (; index < count; ++index )
  1290             for (; index < count; ++index )
   803                 {
  1291                 {
   804                 iPlugins[index]->Plugin().CustomiseMenu(aHbMenu );
  1292                 if ( !iPlugins[index]->IsDisabled() )
       
  1293                     {
       
  1294                 iPlugins[index]->Plugin().CustomiseMenuPaneL( aResourceId,
       
  1295                                                              aMenuPane );
   805                                                              
  1296                                                              
   806                 // The commands added should be checked to see that
  1297                 // The commands added should be checked to see that
   807                 // they match the expected command range for the plugin
  1298                 // they match the expected command range for the plugin
       
  1299                     }
   808                 }
  1300                 }
   809              );
  1301              );
   810          
  1302          
   811         if ( error )
  1303         if ( error )
   812             {
  1304             {
   813             // Report a problem with plugin.
  1305             // Report a problem with plugin.
   814             }
  1306             }
   815         }
  1307         }
   816 
  1308 
   817     OstTraceFunctionExit0( CCALENCUSTOMISATIONMANAGER_OFFERMENU_EXIT );
  1309     TRACE_EXIT_POINT;
       
  1310     }
       
  1311 
       
  1312 // ----------------------------------------------------------------------------
       
  1313 // CCalenCustomisationManager::FindPluginL
       
  1314 // Finds a plugin and returns a plugin with a given uid, returns NULL
       
  1315 // if the uid can not be found.
       
  1316 // (other items were commented in a header).
       
  1317 // ----------------------------------------------------------------------------
       
  1318 //
       
  1319 CCalenCustomisation* CCalenCustomisationManager::FindPluginL( TUid aUid )
       
  1320     {
       
  1321     TRACE_ENTRY_POINT;
       
  1322 
       
  1323     TInt index = iPlugins.Find( aUid, CPluginInfo::Identifier );
       
  1324     
       
  1325     CCalenCustomisation* plugin = NULL;
       
  1326     if ( index != KErrNotFound )
       
  1327         {
       
  1328         plugin = &( iPlugins[index]->Plugin() );
       
  1329         }
       
  1330 
       
  1331     TRACE_EXIT_POINT; 
       
  1332     return plugin;
       
  1333     }
       
  1334 
       
  1335 // ----------------------------------------------------------------------------
       
  1336 // CCalenCustomisationManager::CPluginInfo::CPluginInfo(
       
  1337 // C++ constructor
       
  1338 // (other items were commented in a header).
       
  1339 // ----------------------------------------------------------------------------
       
  1340 //
       
  1341 CCalenCustomisationManager::CPluginInfo::CPluginInfo( 
       
  1342                                     CCalenCustomisation* aPlugin,
       
  1343                                     TUid aUid )
       
  1344     : iPlugin( aPlugin ),
       
  1345       iUid( aUid )
       
  1346     {
       
  1347     TRACE_ENTRY_POINT;
       
  1348     TRACE_EXIT_POINT;
       
  1349     }
       
  1350 
       
  1351 // ----------------------------------------------------------------------------
       
  1352 // CCalenCustomisationManager::CPluginInfo::~CPluginInfo(
       
  1353 // C++ destructor
       
  1354 // (other items were commented in a header).
       
  1355 // ----------------------------------------------------------------------------
       
  1356 //
       
  1357 CCalenCustomisationManager::CPluginInfo::~CPluginInfo() 
       
  1358     {
       
  1359     TRACE_ENTRY_POINT;
       
  1360 
       
  1361     delete iPlugin;
       
  1362 
       
  1363     TRACE_EXIT_POINT;
       
  1364     }
       
  1365     
       
  1366 // ----------------------------------------------------------------------------
       
  1367 // CCalenCustomisationManager::CPluginInfo::Plugin
       
  1368 // returns a reference to the plugin
       
  1369 // (other items were commented in a header).
       
  1370 // ----------------------------------------------------------------------------
       
  1371 //
       
  1372 CCalenCustomisation& CCalenCustomisationManager::CPluginInfo::Plugin()
       
  1373     {
       
  1374     TRACE_ENTRY_POINT;
       
  1375     TRACE_EXIT_POINT;
       
  1376 
       
  1377     return *iPlugin;
       
  1378     }
       
  1379 
       
  1380 // ----------------------------------------------------------------------------
       
  1381 // CCalenCustomisationManager::CPluginInfo::Uid
       
  1382 // returns the plugin uid
       
  1383 // (other items were commented in a header).
       
  1384 // ----------------------------------------------------------------------------
       
  1385 // 
       
  1386 TUid CCalenCustomisationManager::CPluginInfo::Uid() const 
       
  1387     {
       
  1388     TRACE_ENTRY_POINT; 
       
  1389     TRACE_EXIT_POINT;
       
  1390 
       
  1391     return iUid;
       
  1392     }
       
  1393    
       
  1394 // ----------------------------------------------------------------------------
       
  1395 // CCalenCustomisationManager::CPluginInfo::Disable
       
  1396 // Marks the plugin as being disabled
       
  1397 // (other items were commented in a header).
       
  1398 // ----------------------------------------------------------------------------
       
  1399 //  
       
  1400 void CCalenCustomisationManager::CPluginInfo::Disable( TBool aDisable)
       
  1401     {
       
  1402     TRACE_ENTRY_POINT;
       
  1403     
       
  1404     iDisabled = aDisable;
       
  1405      
       
  1406     TRACE_EXIT_POINT;
       
  1407     }
       
  1408     
       
  1409 // ----------------------------------------------------------------------------
       
  1410 // CCalenCustomisationManager::CPluginInfo::IsDisabled
       
  1411 // Returns if the plugin has been marked as being disabled
       
  1412 // (other items were commented in a header).
       
  1413 // ----------------------------------------------------------------------------
       
  1414 //  
       
  1415 TBool CCalenCustomisationManager::CPluginInfo::IsDisabled()
       
  1416     {
       
  1417     TRACE_ENTRY_POINT;
       
  1418     
       
  1419     return iDisabled;
       
  1420      
       
  1421     TRACE_EXIT_POINT;
       
  1422     }
       
  1423 
       
  1424 // ----------------------------------------------------------------------------
       
  1425 // CCalenCustomisationManager::AddPluginL
       
  1426 // Adds a plugin to the array of plugins
       
  1427 // (other items were commented in a header).
       
  1428 // ----------------------------------------------------------------------------
       
  1429 //           
       
  1430 void CCalenCustomisationManager::AddPluginL( CCalenCustomisation* aPlugin,
       
  1431                                              TUid aUid ) 
       
  1432     {
       
  1433     TRACE_ENTRY_POINT;
       
  1434     TInt index = iPlugins.Find( aUid, CPluginInfo::Identifier );
       
  1435     if ( index == KErrNotFound )
       
  1436         {
       
  1437     CPluginInfo* newPlugin = new ( ELeave ) CPluginInfo( aPlugin, aUid);
       
  1438     CleanupStack::PushL( newPlugin );
       
  1439     iPlugins.AppendL( newPlugin );
       
  1440     CleanupStack::Pop( newPlugin );
       
  1441         }
       
  1442 
       
  1443     TRACE_EXIT_POINT;
       
  1444     }
       
  1445 
       
  1446 // ----------------------------------------------------------------------------
       
  1447 // CCalenCustomisationManager::CPluginInfo::Identifier(
       
  1448 // Matches an uid and a plugin uid. Used by FindPluginL to
       
  1449 // find a plugin with a given uid. 
       
  1450 // (other items were commented in a header).
       
  1451 // ----------------------------------------------------------------------------
       
  1452 //
       
  1453 TBool CCalenCustomisationManager::CPluginInfo::Identifier( const TUid* aUid,
       
  1454                                                            const CPluginInfo& aArray )
       
  1455     {
       
  1456     TRACE_ENTRY_POINT; 
       
  1457     TRACE_EXIT_POINT;
       
  1458 
       
  1459     return ( *aUid == aArray.Uid() ); 
       
  1460     }
       
  1461 
       
  1462 // ----------------------------------------------------------------------------
       
  1463 // CCalenCustomisationManager::ViewInfoArray
       
  1464 // returns a reference to the view info array.
       
  1465 // (other items were commented in a header).
       
  1466 // ----------------------------------------------------------------------------      
       
  1467 //
       
  1468 RPointerArray<CCalenViewInfo>& CCalenCustomisationManager::ViewInfoArray()
       
  1469     {
       
  1470     TRACE_ENTRY_POINT;
       
  1471 
       
  1472     TRACE_EXIT_POINT;
       
  1473     return iViewInfoArray;
       
  1474     }    
       
  1475     
       
  1476 // ----------------------------------------------------------------------------
       
  1477 // CCalenCustomisationManager::PluginAvailabilityFinder
       
  1478 // Matches an uid and a plugin uid. Used by when finding the disabled plugins
       
  1479 // (other items were commented in a header).
       
  1480 // ----------------------------------------------------------------------------
       
  1481 //  
       
  1482 TBool CCalenCustomisationManager::PluginAvailabilityFinder( const TUid* aUid, 
       
  1483                                  const TCalenPluginAvailability& aArrayItem )
       
  1484     {
       
  1485     TRACE_ENTRY_POINT; 
       
  1486     TRACE_EXIT_POINT;
       
  1487     
       
  1488     return ( *aUid == aArrayItem.iUid); 
       
  1489     }    
       
  1490 
       
  1491 // ----------------------------------------------------------------------------
       
  1492 // CCalenCustomisationManager::DoPluginLoadingL
       
  1493 // Load all plugins 
       
  1494 // ----------------------------------------------------------------------------
       
  1495 //
       
  1496 EXPORT_C void CCalenCustomisationManager::DoPluginLoadingL()
       
  1497     {
       
  1498     TRACE_ENTRY_POINT;
       
  1499     // Reset and destroy the contents of the owned arrays    
       
  1500     //iPlugins.ResetAndDestroy();
       
  1501     iHiddenViews.Reset();
       
  1502     iDefferedUnloadPluginList.Reset();
       
  1503     // create active plugin list
       
  1504     CreateActivePluginListL();
       
  1505     
       
  1506     DoImmediatePluginLoadingL();
       
  1507     iSetting->LoadL();
       
  1508     iSetting->UpdatePluginListL(*this);
       
  1509     
       
  1510     TRACE_EXIT_POINT;
       
  1511     }
       
  1512 
       
  1513 // ----------------------------------------------------------------------------
       
  1514 // CCalenCustomisationManager::DisableAllPluginsL
       
  1515 // Disable all plugins 
       
  1516 // ----------------------------------------------------------------------------
       
  1517 //
       
  1518 EXPORT_C void CCalenCustomisationManager::DisableAllPluginsL()
       
  1519     {
       
  1520     TRACE_ENTRY_POINT;
       
  1521     
       
  1522     TInt pluginCount = iPluginInfo.Count();
       
  1523     for(TInt index = 0;index<pluginCount;index++)
       
  1524         {
       
  1525         TUid pluginUid = iPluginInfo[index]->ImplementationUid();
       
  1526         if ((iActivePlugins.Find(pluginUid) != KErrNotFound)
       
  1527                 && !(iRomBasedPlugins.Find(pluginUid) != KErrNotFound))
       
  1528             {
       
  1529             DisablePluginOnFakeExitL(pluginUid);
       
  1530             }
       
  1531         }
       
  1532     
       
  1533     TRACE_EXIT_POINT;
       
  1534     }
       
  1535 
       
  1536 // ----------------------------------------------------------------------------
       
  1537 // CCalenCustomisationManager::DisablePluginOnFakeExitL
       
  1538 // Disable plugin on fake exit
       
  1539 // ----------------------------------------------------------------------------
       
  1540 //
       
  1541 void CCalenCustomisationManager::DisablePluginOnFakeExitL(TUid aPluginUid)
       
  1542     {
       
  1543     TRACE_ENTRY_POINT;
       
  1544     
       
  1545     TInt index = iPlugins.Find( aPluginUid, CPluginInfo::Identifier );
       
  1546     if ( index != KErrNotFound )
       
  1547         {
       
  1548         CPluginInfo* pluginInfo = iPlugins[index];
       
  1549     
       
  1550         // Remove the plugin from the active plugin list
       
  1551         TInt position = iActivePlugins.Find( aPluginUid );
       
  1552         ASSERT( position != KErrNotFound );
       
  1553     
       
  1554         if(iActivePlugins.Count())
       
  1555             {
       
  1556             iActivePlugins.Remove( position );            
       
  1557             }
       
  1558 
       
  1559         // Does this plugin hide any views
       
  1560         RArray<TInt> removedViews;
       
  1561         CleanupClosePushL( removedViews );
       
  1562         CCalenCustomisation& plugin = pluginInfo->Plugin();
       
  1563         plugin.RemoveViewsFromCycle( removedViews );
       
  1564         TInt hiddenViewsCount = removedViews.Count();
       
  1565         if ( hiddenViewsCount )
       
  1566             {
       
  1567             // Need to recalculate which views have been hidden, as 
       
  1568             // more than one plugin might have hidden the same view.
       
  1569             for ( TInt index( 0 ); index < hiddenViewsCount; ++index )
       
  1570                 {
       
  1571                 TUid viewUid = TUid::Uid( removedViews[index] );
       
  1572                 CheckHiddenViewL( viewUid, aPluginUid );
       
  1573                 }
       
  1574             }
       
  1575     
       
  1576         // If the plugin does not offer any views, or the current
       
  1577         // info or preview bar it can be deleted immediately,
       
  1578         // otherwise the customisation needs to wait until it
       
  1579         // is told it is safe to do so.
       
  1580     
       
  1581         // Does this plugin does not offer any views and the plugin
       
  1582         // doesn't offer the current infobar or preview pane
       
  1583         // bar it can be deleted immediately
       
  1584         TInt offerViews = iViewInfoArray.Find( aPluginUid, 
       
  1585                                    CCalenViewInfo::ViewPluginIdentifier );
       
  1586                                       
       
  1587         if ( offerViews == KErrNotFound &&
       
  1588              iInfoBarProviderUid != aPluginUid
       
  1589              && iPreviewPaneProviderUid != aPluginUid )
       
  1590             {
       
  1591             RArray<TUid> pluginArray;
       
  1592             CleanupClosePushL( pluginArray );
       
  1593             pluginArray.AppendL( aPluginUid );
       
  1594             UnloadPluginsL( pluginArray );
       
  1595             CleanupStack::PopAndDestroy(); // pluginArray
       
  1596             }
       
  1597     
       
  1598         // Issue notification of plugin been disabled
       
  1599         iPluginsEnabledDisabled = ETrue;
       
  1600         iServices.IssueNotificationL( ECalenNotifyPluginEnabledDisabled );
       
  1601         CleanupStack::PopAndDestroy(); // removedViews
       
  1602         }
       
  1603     TRACE_EXIT_POINT;
   818     }
  1604     }
   819 
  1605 
   820 // End of File
  1606 // End of File
       
  1607