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