|
1 /* |
|
2 * Copyright (c) 2007-2008 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: Calendar controller |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef CALENCONTROLLER_H |
|
21 #define CALENCONTROLLER_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> // CAsyncCallBack |
|
25 #include <vwsdef.h> // TVwsViewId |
|
26 #include <apadef.h> // TApaCommand |
|
27 #include <calencommands.hrh> // Calendar commands |
|
28 #include <caleninstanceid.h> // TCalenInstanceId |
|
29 #include <calennotificationhandler.h> // TCalenNotification |
|
30 #include <calenservices.h> |
|
31 class MCalenPreview; |
|
32 #include "calenglobaldata.h" // TCalenContext |
|
33 #include "calenservicesfactory.h" // MCalenServicesFactory |
|
34 |
|
35 // FORWARD DECLARATIONS |
|
36 class CCalenActionUi; |
|
37 class CCalenNotifier; |
|
38 class CCalenViewManager; |
|
39 class CCalenAlarmManager; |
|
40 class CCalenView; |
|
41 class CAknViewAppUi; |
|
42 class CCalenStateMachine; |
|
43 class CCalenCmdLineLauncher; |
|
44 class CCalenCustomisationManager; |
|
45 class CEikMenuPane; |
|
46 class CCoeControl; |
|
47 class CCalenViewInfo; |
|
48 class CCalenSetting; |
|
49 class CCalenServicesImpl; |
|
50 class MCalenCommandHandler; |
|
51 class TCalenCommand; |
|
52 class CMissedAlarmStore; |
|
53 class CCalenMultipleDbManager; |
|
54 class CCalenInfo; |
|
55 class CCalenAttachmentModel; |
|
56 |
|
57 // CLASS DEFINITIONS |
|
58 |
|
59 /** |
|
60 * The controller handles events from the rest of Calendar and delegates |
|
61 * them to the appropriate place (i.e. the action ui classes). |
|
62 */ |
|
63 class CCalenController : public CBase, |
|
64 public MCalenServicesFactory |
|
65 { |
|
66 public: // Construction and destruction |
|
67 /** |
|
68 * Symbian 1st phase constructor |
|
69 * @param aAppUi A reference to the CAknViewAppUi |
|
70 * @return self pointer to CCalenController |
|
71 */ |
|
72 IMPORT_C static CCalenController* NewL( CAknViewAppUi& aAppUi ); |
|
73 |
|
74 /** |
|
75 * Constructs CCalenController with existing CAknViewAppUi. If the |
|
76 * controller has been previously initialized with the same CAknViewAppUi, |
|
77 * the existing instance will be returned. |
|
78 * @param aAppUi Reference to CAknViewAppUi |
|
79 * @return CCalenController pointer |
|
80 */ |
|
81 IMPORT_C static CCalenController* InstanceL(); |
|
82 |
|
83 /** |
|
84 * CCalenController is a reference counting singleton. Call Release() |
|
85 * when you are done with it, it will clean itself when it needs to |
|
86 */ |
|
87 IMPORT_C void Release(); |
|
88 |
|
89 public: // New functions |
|
90 /** |
|
91 * Adds the passed command to the command queue. Command are handled |
|
92 * asynchronously in HandleCommandL |
|
93 * @param aCommand Command that is passed in. |
|
94 * @return EFalse if the passed command is not in the issuers command range |
|
95 * ETrue otherwise |
|
96 */ |
|
97 IMPORT_C TBool IssueCommandL( TInt aCommand ); |
|
98 |
|
99 /** |
|
100 * Passes the notification to the calendar notifier. The notification will be |
|
101 * broadcast to all observers |
|
102 * @param aNotification Notification to be broadcast |
|
103 */ |
|
104 IMPORT_C void BroadcastNotification( TCalenNotification aNotification ); |
|
105 |
|
106 /** |
|
107 * Register the passed notification handler with the calendar notifier |
|
108 * @param aHandler Notification handler |
|
109 * @param aNotification Notification that handler wants to be notified |
|
110 */ |
|
111 IMPORT_C void RegisterForNotificationsL( MCalenNotificationHandler* aHandler, |
|
112 TCalenNotification aNotification ); |
|
113 |
|
114 |
|
115 /** |
|
116 * Register the passed notification handler with the calendar notifier |
|
117 * @param aHandler Notification handler |
|
118 * @param aNotifications Array of Notifications that handler wants to be notified |
|
119 */ |
|
120 IMPORT_C void RegisterForNotificationsL( MCalenNotificationHandler* aHandler, |
|
121 RArray<TCalenNotification>& aNotifications ); |
|
122 |
|
123 /** |
|
124 * Unregister the passed handler with the notifier |
|
125 * @param aHandler Notification handler |
|
126 */ |
|
127 IMPORT_C void CancelNotifications( MCalenNotificationHandler* aHandler ); |
|
128 |
|
129 /** |
|
130 * Process comamndline parameters |
|
131 * @param aCommand Not in use in this case |
|
132 * @param aDocumentName Not in use in this case |
|
133 * @param aTail Descriptor contains the command |
|
134 */ |
|
135 IMPORT_C void ProcessCommandParametersL( TApaCommand aCommand, |
|
136 TFileName& aDocumentName, |
|
137 const TDesC8& aTail ); |
|
138 /** |
|
139 * Offer the menu pane to Plugins to customisation |
|
140 * @param aMenuPane Where the customisation apply to |
|
141 */ |
|
142 IMPORT_C void OfferMenuPaneL( TInt aResourceId, |
|
143 CEikMenuPane* aMenuPane ); |
|
144 |
|
145 /** |
|
146 * Get infobar based on the available area for infobar |
|
147 * @param aRect The available area for Infobar |
|
148 * @return pointer to a Infobar control |
|
149 */ |
|
150 IMPORT_C CCoeControl* Infobar( const TRect& aRect ); |
|
151 |
|
152 /** |
|
153 * Get infobar based on the available area for infobar |
|
154 * @param aRect The available area for Infobar |
|
155 * @return pointer to a Infobar control |
|
156 */ |
|
157 IMPORT_C const TDesC& Infobar(); |
|
158 |
|
159 /** |
|
160 * Get preview pane based on the available area |
|
161 * @param aRect The available area for preview pane |
|
162 * @return pointer to a preview pane control |
|
163 */ |
|
164 IMPORT_C CCoeControl* PreviewPane( TRect& aRect ); |
|
165 |
|
166 /** |
|
167 * Releases all plugins, should only be called when |
|
168 * the application is exiting. |
|
169 */ |
|
170 IMPORT_C void ReleaseCustomisations(); |
|
171 |
|
172 /** |
|
173 * From MCalenServicesFactory |
|
174 */ |
|
175 IMPORT_C MCalenServices* NewServicesL(); |
|
176 |
|
177 /* |
|
178 * Get custom preview pane to replace the native one. |
|
179 * @param aRect TRect of preview pane area. |
|
180 * @return MCalenPreview* pointer to MCalenPreview class |
|
181 */ |
|
182 IMPORT_C MCalenPreview* CustomPreviewPaneL( TRect& aRect ); |
|
183 |
|
184 public: // public but not exported |
|
185 /** |
|
186 * Get reference to the CCalenNotiffier |
|
187 */ |
|
188 CCalenNotifier& Notifier(); |
|
189 |
|
190 /** |
|
191 * Get a command handler for a specific command |
|
192 * @param aCommand Command to find a command handler for |
|
193 */ |
|
194 MCalenCommandHandler* GetCommandHandlerL( TInt aCommand ); |
|
195 |
|
196 /** |
|
197 * Request activation of a specific view |
|
198 * @param aViewId View id |
|
199 */ |
|
200 void RequestActivationL( const TVwsViewId& aViewId ); |
|
201 |
|
202 /** |
|
203 * Get customisationmanager |
|
204 * @return reference to CCalenCustomisationManager |
|
205 */ |
|
206 CCalenCustomisationManager& CustomisationManager(); |
|
207 |
|
208 /** |
|
209 * Get viewmanager |
|
210 * @return reference to CCalenViewManager |
|
211 */ |
|
212 CCalenViewManager& ViewManager(); |
|
213 |
|
214 /** |
|
215 * Get services |
|
216 * @return reference to controller's services object |
|
217 */ |
|
218 MCalenServices& Services(); |
|
219 |
|
220 /** |
|
221 * Checks to see if the system time was changed while Calendar was |
|
222 * not running, potentially causing alarms to be missed |
|
223 */ |
|
224 void HandleSystemTimeChangeL(); |
|
225 |
|
226 /** |
|
227 * Check for faster app flag |
|
228 */ |
|
229 TBool IsFasterAppFlagEnabled(); |
|
230 |
|
231 /** |
|
232 * Set faster app flag |
|
233 */ |
|
234 void SetFasterAppFlag( TBool aFlag ); |
|
235 |
|
236 /** |
|
237 * Get Missed alarm store |
|
238 * @return reference to Missed alarm store |
|
239 */ |
|
240 CMissedAlarmStore* MissedAlarmStore(); |
|
241 |
|
242 /** |
|
243 * Get missed alarms list |
|
244 * @return list of missed alarms |
|
245 */ |
|
246 void GetMissedAlarmsList(RArray<TCalenInstanceId>& aMissedAlarmList); |
|
247 |
|
248 /** |
|
249 * returns a reference to the calendar settings |
|
250 */ |
|
251 CCalenSetting& Settings(); |
|
252 |
|
253 /** |
|
254 * Get calendar icon of specific type |
|
255 * @return CGulIcon* |
|
256 */ |
|
257 CGulIcon* GetIconL(MCalenServices::TCalenIcons aIndex); |
|
258 |
|
259 /* Get multipledb manager |
|
260 * @return reference to CCalenMultipleDbManager |
|
261 */ |
|
262 CCalenMultipleDbManager& MultipleDbManager(); |
|
263 |
|
264 /* |
|
265 * Get all active collection id |
|
266 * @param aCollectionIds array for collection on return |
|
267 * @return void |
|
268 */ |
|
269 void GetActiveCollectionidsL(RArray<TInt>& aCollectionIds); |
|
270 |
|
271 /* |
|
272 * Form calendar name based dbid for eg:for |
|
273 * c:Calendar append dbid 1 as c:Calendar1 |
|
274 * @return HBufC* calendar name ownership return to caller. |
|
275 * @param TInt aDbId db id for which calendar name should be formed. |
|
276 */ |
|
277 HBufC* GetCalendarNameFromDbIdL(const TInt aDbId); |
|
278 |
|
279 |
|
280 /** |
|
281 * Get State Machine |
|
282 * @return reference to CCalenStateMachine |
|
283 */ |
|
284 CCalenStateMachine& StateMachine(); |
|
285 |
|
286 /** |
|
287 * Get action ui |
|
288 * |
|
289 * @return reference to CCalenActionUi |
|
290 */ |
|
291 CCalenAttachmentModel& AttachmentData(); |
|
292 |
|
293 /** |
|
294 * Function to tell whether editor is active or not |
|
295 * @return ETrue if editor is active else EFalse |
|
296 */ |
|
297 TBool IsEditorActive(); |
|
298 |
|
299 /** |
|
300 * @brief adds a new calendar info to the calendar file |
|
301 * |
|
302 * @param aCalendarInfo meatadata to be set to calendar file |
|
303 */ |
|
304 void AddCalendarL(CCalCalendarInfo* aCalendarInfo); |
|
305 |
|
306 /** |
|
307 * @brief removes a calendar |
|
308 * |
|
309 * @param aCalendarFileName name of the calendar file to be deleted |
|
310 */ |
|
311 void RemoveCalendarL(const TDesC& aCalendarFileName); |
|
312 |
|
313 /** |
|
314 * @brief removes all dead calendars from the file system. |
|
315 */ |
|
316 void RemoveDeadCalendarsL(); |
|
317 |
|
318 /** |
|
319 * @brief updates a calendar file with new metadata |
|
320 * |
|
321 * @param aCalendarInfo updated metadata to be set to calendar file |
|
322 */ |
|
323 void UpdateCalendarL(CCalCalendarInfo* aCalendarInfo); |
|
324 |
|
325 /** |
|
326 * @brief get all available calendar info |
|
327 * |
|
328 * @param aCalendarInfoList reference to the calendar info list |
|
329 */ |
|
330 void GetAllCalendarInfoL( |
|
331 RPointerArray<CCalCalendarInfo>& aCalendarInfoList ); |
|
332 |
|
333 private: // Construction and destruction |
|
334 /** |
|
335 * C++ constructor |
|
336 */ |
|
337 CCalenController( CAknViewAppUi& aAppUi ); |
|
338 |
|
339 /** |
|
340 * Symbian 2nd phase constructor |
|
341 */ |
|
342 void ConstructL(); |
|
343 |
|
344 /** |
|
345 * destructor |
|
346 */ |
|
347 ~CCalenController(); |
|
348 |
|
349 private: // New functions |
|
350 /** |
|
351 * Leaving form of HandleCommandL |
|
352 * @param aCommand Command to be handled |
|
353 */ |
|
354 void HandleCommandL( TCalenCommand& aCommand ); |
|
355 |
|
356 /** |
|
357 * Displays an information note if the system time changed |
|
358 * while Calendar was inactive |
|
359 * @param aResourceId resource id for information note |
|
360 */ |
|
361 void ShowSystemChangeInfoNoteL( TInt aResourceId ); |
|
362 |
|
363 /** |
|
364 * This function is called when a System time is changed. |
|
365 * only at the startup |
|
366 * @param aThisPtr Specified to be TCallBack() |
|
367 * @return EFalse |
|
368 */ |
|
369 static TInt SystemTimeChangeCallback(TAny* aThisPtr); |
|
370 |
|
371 public: |
|
372 /** |
|
373 * Check system time change at startup |
|
374 */ |
|
375 void CheckSystemTimeAtStartUpL(); |
|
376 |
|
377 /** |
|
378 * Returns a reference to the appui |
|
379 */ |
|
380 CAknViewAppUi& AppUi(); |
|
381 |
|
382 /** |
|
383 * Set the iIsExitOnDialogClose flag status from command line launcher. |
|
384 * @param aFlag , Sets the status |
|
385 */ |
|
386 void SetExitOnDialogFlag( TBool aFlag ); //updateflag |
|
387 |
|
388 /** |
|
389 * Get the iIsExitOnDialogClose flag status from command line launcher. |
|
390 * @return TBool, Status of the flag. |
|
391 */ |
|
392 TBool GetExitOnDialogFlag(); // getflagstatus |
|
393 |
|
394 private: // Data |
|
395 CAknViewAppUi& iAppUi; // Calendar AppUi |
|
396 CCalenActionUi* iActionUi; // Default internal command handling |
|
397 CCalenNotifier* iNotifier; // Broadcasts calendar events |
|
398 CCalenViewManager* iViewManager;// Activate / deactivate views |
|
399 CCalenGlobalData* iGlobalData; // Calendar Global Data |
|
400 CCalenSetting* iSetting; // Calendar settings |
|
401 CCalenServicesImpl* iServices; // Services. |
|
402 CCalenAlarmManager* iAlarmManager; //Alarm Manager. |
|
403 CCalenMultipleDbManager* iMultipleDbmanager; //Multiple calendar |
|
404 CCalenAttachmentModel* iAttachmentData; |
|
405 TInt iRefCount; // Reference counting singleton |
|
406 |
|
407 // Handles the cmd line launching of calendar |
|
408 CCalenCmdLineLauncher* iCmdLineLauncher; |
|
409 // Manages any customisation plugins |
|
410 CCalenCustomisationManager* iCustomisationManager; |
|
411 CCalenStateMachine* iStateMachine; |
|
412 |
|
413 // Start point of the next command range |
|
414 // to be assigned to a services instance. |
|
415 TInt iNextServicesCommandBase; |
|
416 TInt iResourceFileOffset; |
|
417 CAsyncCallBack* iSystemTimeChangedMsgDelayer; |
|
418 TBool iFasterApp; |
|
419 }; |
|
420 |
|
421 #endif // CALENCONTROLLER_H |
|
422 |
|
423 // End of file |