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