|
1 /* |
|
2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Customisation manager. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef CALENCUSTOMISATIONMANAGER_H |
|
21 #define CALENCUSTOMISATIONMANAGER_H |
|
22 |
|
23 #include <aknsettingitemlist.h> // CAknSettingItem |
|
24 #include <e32base.h> // CBase |
|
25 #include <calennotificationhandler.h> // MCalenNotificationHandler |
|
26 #include <ecom/ecom.h> // RImplInfoPtrArray |
|
27 #include <calenview.h> // TCyclePosition |
|
28 |
|
29 // forward declarations |
|
30 class CEikMenuPane; |
|
31 class CCalenView; |
|
32 class CCalenCustomisation; |
|
33 class MCalenCommandHandler; |
|
34 class CCalenGlobalData; |
|
35 class CCoeControl; |
|
36 class CCalenViewInfo; |
|
37 class CAknSettingItem; |
|
38 class MCalenServicesFactory; |
|
39 class MCalenServices; |
|
40 class CCalenSetting; |
|
41 class MCalenPreview; |
|
42 |
|
43 /** |
|
44 * CCalenCustomisationManager manages customisations for calendar. |
|
45 * |
|
46 */ |
|
47 class CCalenCustomisationManager : public CBase, |
|
48 public MCalenNotificationHandler |
|
49 { |
|
50 public: // Types |
|
51 /** |
|
52 * Struct showing the uid and availaibility of known plugins. |
|
53 */ |
|
54 struct TCalenPluginAvailability |
|
55 { |
|
56 public: |
|
57 TUid iUid; |
|
58 TBool iEnabled; |
|
59 }; |
|
60 |
|
61 // Array of plugin availabilities. |
|
62 typedef RArray<CCalenCustomisationManager::TCalenPluginAvailability> CCalenPluginStatusArray; |
|
63 |
|
64 public: // Construction and destruction |
|
65 /** |
|
66 * Returns a new CCalenCustomisationManager object. |
|
67 */ |
|
68 IMPORT_C static CCalenCustomisationManager* NewL( |
|
69 MCalenServicesFactory& aFactory, |
|
70 CCalenPluginStatusArray& aPluginSettingsStatus, |
|
71 MCalenServices& aServices, |
|
72 RPointerArray<CCalenViewInfo>& aViewArray ); |
|
73 |
|
74 /** |
|
75 * Destructor. |
|
76 */ |
|
77 ~CCalenCustomisationManager(); |
|
78 |
|
79 public: // New functions |
|
80 /** |
|
81 * Get a command handler for a specific command |
|
82 * @param aCommand Command to find a command handler for |
|
83 */ |
|
84 IMPORT_C MCalenCommandHandler* GetCommandHandlerL( TInt aCommand ); |
|
85 |
|
86 /** |
|
87 * Offers the menu pane to customisations for modification. |
|
88 */ |
|
89 IMPORT_C void OfferMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane ); |
|
90 |
|
91 /** |
|
92 * Gets a custom preview pane from the appropriate customisation. |
|
93 */ |
|
94 IMPORT_C MCalenPreview* CustomPreviewPaneL( TRect& aRect ); |
|
95 |
|
96 /** |
|
97 * Gets a preview pane from the appropriate customisation. |
|
98 */ |
|
99 IMPORT_C CCoeControl* PreviewPane( TRect& aRect ); |
|
100 |
|
101 /** |
|
102 * Gets a info bar from the appropriate customisation. |
|
103 */ |
|
104 IMPORT_C CCoeControl* Infobar( const TRect& aRect ); |
|
105 |
|
106 /** |
|
107 * Gets a info bar from the appropriate customisation. |
|
108 */ |
|
109 IMPORT_C const TDesC& Infobar(); |
|
110 |
|
111 /** |
|
112 * Gets settings from the given plugin. |
|
113 * NOTE: The contents of the array are owned by the caller - caller |
|
114 * must guarantee to call ResetAndDestroy on the array in all cases. |
|
115 */ |
|
116 IMPORT_C void GetPluginSettingsL( TUid aPluginUid, |
|
117 RPointerArray<CAknSettingItem>& aSettingArray ); |
|
118 |
|
119 /** |
|
120 * Returns a reference to an array of active plugins uids |
|
121 */ |
|
122 IMPORT_C const RArray<TUid>& ActivePlugins() const; |
|
123 |
|
124 /** |
|
125 * GetCustomViews returns custom views info in an array for a given |
|
126 * plugin. |
|
127 * NOTE: The contents of the array are owned by the caller - caller |
|
128 * must guarantee to call ResetAndDestroy on the array in all cases. |
|
129 */ |
|
130 IMPORT_C void GetCustomViewsL( TUid aPluginUid, |
|
131 RPointerArray<CCalenView>& aViews ); |
|
132 |
|
133 /** |
|
134 * Disables the given plugin. Does nothing if the plugin can't be found. |
|
135 */ |
|
136 IMPORT_C void SetPluginAvailabilityL( TUid aPluginUid, TBool aEnabled ); |
|
137 |
|
138 /** |
|
139 * Returns a const reference to the plugin information array. |
|
140 */ |
|
141 IMPORT_C const RImplInfoPtrArray& PluginInfoArray() const; |
|
142 |
|
143 /** |
|
144 * Returns a const reference to the views array. |
|
145 */ |
|
146 IMPORT_C const RPointerArray<CCalenViewInfo>& Views() const; |
|
147 |
|
148 /** |
|
149 * When a plugin is disabled it can not be unloaded until |
|
150 * any views etc it has provided have been deleted. This function |
|
151 * is called when it is safe to unload the plugin. |
|
152 */ |
|
153 IMPORT_C void UnloadPluginsL( const RArray<TUid>& aPlugins); |
|
154 |
|
155 /** |
|
156 * Returns ETrue if a view has been hidden by a plugin, |
|
157 */ |
|
158 IMPORT_C TBool HiddenView( TUid aHiddenView) const; |
|
159 |
|
160 /** |
|
161 * Returns if a view is provided by a rom based plugin |
|
162 */ |
|
163 IMPORT_C TBool IsViewRomBased( TUid aViewUid ) const; |
|
164 |
|
165 /** |
|
166 * Fills the list of views hidden by a particular plugin |
|
167 */ |
|
168 IMPORT_C void GetHiddenViewIdL( TUid aPluginUid, RArray<TInt>& aHiddenViews ); |
|
169 |
|
170 /** |
|
171 * Returns plugin view uid that is hidking the input view |
|
172 */ |
|
173 IMPORT_C TUid GetReplacePluginViewIdL( TUid aHiddenViewId ); |
|
174 /** |
|
175 * Returns if plugin can be enabled/disabled from settings |
|
176 */ |
|
177 IMPORT_C TBool CanBeEnabledDisabledL(TUid aPluginUid); |
|
178 |
|
179 /** |
|
180 * Disable all plugins |
|
181 */ |
|
182 IMPORT_C void DisableAllPluginsL(); |
|
183 |
|
184 /** |
|
185 * Reload all plugins |
|
186 */ |
|
187 IMPORT_C void DoPluginLoadingL(); |
|
188 |
|
189 public: // from MCalenNotificationHandler |
|
190 void HandleNotification(const TCalenNotification aNotification ); |
|
191 |
|
192 private: // Constructors |
|
193 CCalenCustomisationManager( MCalenServicesFactory& aFactory, |
|
194 MCalenServices& aServices, |
|
195 RPointerArray<CCalenViewInfo>& aViewArray, |
|
196 CCalenPluginStatusArray& aPluginSettingsStatus ); |
|
197 |
|
198 void ConstructL(); |
|
199 |
|
200 private: // New functions |
|
201 void LoadPluginL( TUid aPluginUid ); |
|
202 |
|
203 void DoImmediatePluginLoadingL(); |
|
204 |
|
205 void OfferMenuPaneToPluginsL( TInt aResourceId, CEikMenuPane* aMenuPane ); |
|
206 |
|
207 CCalenCustomisation* FindPluginL( TUid aUid ); |
|
208 |
|
209 static TBool PluginAvailabilityFinder( const TUid* aUid, |
|
210 const TCalenPluginAvailability& aArrayItem ); |
|
211 |
|
212 static TBool PluginInfoFinder( const TUid* aUid , |
|
213 const CImplementationInformation& aArrayItem); |
|
214 |
|
215 void AddPluginL( CCalenCustomisation* aPlugin, TUid aUid ); |
|
216 RPointerArray<CCalenViewInfo>& ViewInfoArray(); |
|
217 |
|
218 void CreateActivePluginListL(); |
|
219 |
|
220 void EnablePluginL( TUid aPluginUid ); |
|
221 |
|
222 void DisablePluginL( TUid aPluginUid ); |
|
223 |
|
224 void CheckHiddenViewL( TUid aViewUid, TUid aPluginUid ); |
|
225 |
|
226 void HandleNotificationL(TCalenNotification aNotification); |
|
227 |
|
228 |
|
229 |
|
230 /** |
|
231 * Disable plugin on fake exit |
|
232 */ |
|
233 void DisablePluginOnFakeExitL(TUid aPluginUid); |
|
234 |
|
235 /* |
|
236 * Load custom plugins based on the variant |
|
237 */ |
|
238 void LoadPluginsBasedOnVariantL(); |
|
239 |
|
240 |
|
241 private: |
|
242 /** |
|
243 * Internal class used as a wrapper around a plugin |
|
244 * and its uid. |
|
245 */ |
|
246 class CPluginInfo : public CBase |
|
247 { |
|
248 public: // Constructor & Destructor |
|
249 CPluginInfo( CCalenCustomisation* aPlugin, TUid aUid ); |
|
250 ~CPluginInfo(); |
|
251 |
|
252 public: // New functions |
|
253 static TBool Identifier( const TUid* aUid, |
|
254 const CPluginInfo& aArray ); |
|
255 CCalenCustomisation& Plugin(); |
|
256 TUid Uid() const; |
|
257 void Disable( TBool aDisabled ); |
|
258 TBool IsDisabled(); |
|
259 |
|
260 private: // Data |
|
261 CCalenCustomisation* iPlugin; |
|
262 TUid iUid; |
|
263 TBool iDisabled; |
|
264 }; |
|
265 |
|
266 private: // Data |
|
267 RImplInfoPtrArray iPluginInfo; |
|
268 |
|
269 MCalenServicesFactory& iServicesFactory; |
|
270 |
|
271 // takes ownership of the plugins |
|
272 RPointerArray<CPluginInfo> iPlugins; |
|
273 |
|
274 // Array of views. Neither the array nor the contents are owned here at any time. |
|
275 RPointerArray<CCalenViewInfo>& iViewInfoArray; |
|
276 |
|
277 RArray<TUid> iActivePlugins; |
|
278 RArray<TUid> iRomBasedPlugins; |
|
279 |
|
280 CCalenGlobalData* iGlobalData; |
|
281 |
|
282 TLinearOrder<CCalenViewInfo> iSortOrder; |
|
283 |
|
284 MCalenServices& iServices; |
|
285 |
|
286 TUid iInfoBarProviderUid; |
|
287 TUid iPreviewPaneProviderUid; |
|
288 |
|
289 RArray<TInt> iHiddenViews; |
|
290 |
|
291 CCalenPluginStatusArray& iPluginSettingsStatus; |
|
292 |
|
293 TBool iPluginsEnabledDisabled; |
|
294 RArray<TUid> iDefferedUnloadPluginList; |
|
295 CCalenSetting* iSetting; |
|
296 TPtrC iInfoBarStr; |
|
297 }; |
|
298 |
|
299 #endif // CALENCUSTOMISATIONMANAGER_H |
|
300 |
|
301 // End of File |