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