|
1 /* |
|
2 * Copyright (c) 2002-2005 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: Global Data for Calendar application |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CALENGLOBALDATA_H |
|
20 #define CALENGLOBALDATA_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 #include <w32std.h> |
|
25 #include <CMRUtils.h> // MMRUtilsObserver |
|
26 #include <cmrmailboxutils.h> |
|
27 #include <calennotificationhandler.h> // MCalenNotificationHandler |
|
28 #include <calsession.h> // Calendar database session |
|
29 #include <calinstanceview.h> // Calendar Instance view |
|
30 #include <calentryview.h> // Calendar Entry view |
|
31 #include <e32hashtab.h> //RHashSet |
|
32 |
|
33 #include <calenmulticaluids.hrh> |
|
34 |
|
35 |
|
36 // FORWARD DECLARATIONS |
|
37 class CMRMailboxUtils; // Mailbox utilities |
|
38 class CCalSession; // Calendar session |
|
39 class CCalEntryView; // Calendar entry view |
|
40 class CCalInstanceView; // Calendar instance view |
|
41 class CCalenInterimUtils2; // Provides helper functions to CalInterimApi |
|
42 class CCalenSend; // Sending interface |
|
43 class CCalenDbChangeNotifier; // Issues notifications of database changes |
|
44 class MCalenContextChangeObserver; // Context changes |
|
45 struct TKeyEvent; |
|
46 class CCalenContextImpl; // context implementation |
|
47 class MCalenContext; |
|
48 class CCalenFileMapping; |
|
49 class CCalenInfo; |
|
50 class CCalCalendarInfo; |
|
51 |
|
52 // CLASS DECLARATION |
|
53 |
|
54 /** |
|
55 * CCalenGlobalData is a singleton using Thread local storage |
|
56 * It provides easy access to instances of the following classes: |
|
57 * CMRMailboxUtils |
|
58 * CMRUtils |
|
59 * CCalSession |
|
60 * CCalInstanceView |
|
61 * CCalEntryView |
|
62 * CCalenInterimUtils2 |
|
63 * CCalenSend |
|
64 * CCalenDbChangeNotifier |
|
65 * CCalenContext |
|
66 */ |
|
67 NONSHARABLE_CLASS(CCalenGlobalData) : public CBase, |
|
68 public MMRUtilsObserver, |
|
69 public MCalenNotificationHandler |
|
70 { |
|
71 public: // Constructors and destructor |
|
72 /** |
|
73 * The only classes that should call NewL are the controller |
|
74 * and server classes. Otherwise use InstanceL. |
|
75 * Doesn't take ownership of aNotifier. |
|
76 */ |
|
77 IMPORT_C static CCalenGlobalData* |
|
78 NewL( MCalProgressCallBack& aCalCallBack, |
|
79 MCalenContextChangeObserver* aNotifier=NULL ); |
|
80 |
|
81 /** |
|
82 * Constructor. Returns a new instance of CCalenGlobalData if |
|
83 * none exists, or returns the existing instance. |
|
84 * @return CCalenGlobalData pointer |
|
85 */ |
|
86 IMPORT_C static CCalenGlobalData* InstanceL(); |
|
87 |
|
88 /** |
|
89 * Constructs CCalenGlobalData with an existing CCalSession. It |
|
90 * is the responsibility of the caller to ensure that the session |
|
91 * remains open until ALL references to the CCalenGlobalData have been |
|
92 * released. If the CCalenGlobalData already has created a different |
|
93 * CCalSessionthis call will leave with KErrAlreadyExists. If the |
|
94 * CCalenGlobalData has previously been initialised with the same |
|
95 * external CCalSession, the existing instance will be returned. |
|
96 * @param aSession initialised calendar session |
|
97 * @return CCalenGlobalData pointer |
|
98 */ |
|
99 IMPORT_C static CCalenGlobalData* InstanceL(CCalSession& aSession); |
|
100 |
|
101 /** |
|
102 * Non-leaving version of constructor. Returns an instance of |
|
103 * CCalenGlobalData if one exists or NULL otherwise |
|
104 */ |
|
105 IMPORT_C static CCalenGlobalData* Instance(); |
|
106 |
|
107 /** |
|
108 * CCalenGlobalData is a reference counting singleton. Call Release() |
|
109 * when you are done with it, it will clean itself up when it needs to |
|
110 */ |
|
111 IMPORT_C void Release(); |
|
112 |
|
113 public: // New functions |
|
114 |
|
115 /** |
|
116 * Returns a reference to the mailbox utils |
|
117 * @return reference to a CMRMailboxUtils |
|
118 */ |
|
119 IMPORT_C CMRMailboxUtils& MRMailboxUtilsL(); |
|
120 |
|
121 /** |
|
122 * Returns a reference to the mr utils |
|
123 * @return reference to a CMRUtils |
|
124 */ |
|
125 IMPORT_C CMRUtils& MeetingRequestUtilsL(); |
|
126 |
|
127 /** |
|
128 * Returns a reference to the calendar session |
|
129 * @return reference to a CCalSession |
|
130 */ |
|
131 IMPORT_C CCalSession& CalSessionL(); |
|
132 |
|
133 /** |
|
134 * Returns a reference to the calendar session |
|
135 * @param aCalendar filename for which session to be returned |
|
136 * @return reference to a CCalSession from array of sessions |
|
137 */ |
|
138 IMPORT_C CCalSession& CalSessionL(const TDesC& aCalendar); |
|
139 |
|
140 /** |
|
141 * Returns a pointer to the calendar instance view |
|
142 * if it has been constructed otherwise it |
|
143 * returns NULL and constructs the instance view |
|
144 * asynchronously. |
|
145 * @return pointer to a CCalInstanceView |
|
146 */ |
|
147 IMPORT_C CCalInstanceView* InstanceViewL(); |
|
148 |
|
149 /** |
|
150 * Returns a pointer to the calendar instance view |
|
151 * if it has been constructed otherwise it |
|
152 * returns NULL and constructs the instance view |
|
153 * asynchronously. |
|
154 * @param aCollectionIds array of collection ids for which we need to |
|
155 * create the instanceview |
|
156 * @return pointer to a CCalInstanceView |
|
157 */ |
|
158 IMPORT_C CCalInstanceView* InstanceViewL( |
|
159 const RArray<TInt>& aCollectionIds ); |
|
160 |
|
161 /** |
|
162 * Returns a pointer to the calendar entry view |
|
163 * if it has been constructed otherwise it |
|
164 * returns NULL and constructs the entry view |
|
165 * asynchronously. |
|
166 * @return pointer to a CCalEntryView |
|
167 */ |
|
168 IMPORT_C CCalEntryView* EntryViewL(); |
|
169 |
|
170 /** |
|
171 * Returns a pointer to the calendar entry view |
|
172 * if it has been constructed otherwise it |
|
173 * returns NULL and constructs the entry view |
|
174 * asynchronously. |
|
175 * @param aCollectionId collection id to which we need to create entryview |
|
176 * @return pointer to a CCalEntryView |
|
177 */ |
|
178 IMPORT_C CCalEntryView* EntryViewL(const TCalCollectionId aCollectionId ); |
|
179 |
|
180 |
|
181 /** |
|
182 * Returns information does complete entry view exist |
|
183 * @return ETrue if exists EFalse if does not exist. |
|
184 */ |
|
185 IMPORT_C TBool EntryViewExists(); |
|
186 |
|
187 /** |
|
188 * Returns a reference to the interim utils |
|
189 * @return reference to a CCalenInterimUtils2 |
|
190 */ |
|
191 IMPORT_C CCalenInterimUtils2& InterimUtilsL(); |
|
192 |
|
193 /** |
|
194 * Returns a reference to the CCalenSend |
|
195 * @return reference to a CCalenSend |
|
196 */ |
|
197 IMPORT_C CCalenSend& CalenSendL(); |
|
198 |
|
199 /** |
|
200 * Returns information whether the default mailbox if retrieved |
|
201 * @return ETrue if successful EFalse if not |
|
202 */ |
|
203 IMPORT_C TBool AttemptToRetrieveDefaultMailboxL( CMRMailboxUtils::TMailboxInfo& aDefaultMailbox); |
|
204 |
|
205 /** |
|
206 * Returns information whether events if queued successfully |
|
207 * @return ETrue if event is queued EFalse if it doesn't |
|
208 */ |
|
209 IMPORT_C TBool QueueKeyEvent(const TKeyEvent& aEvent, TEventCode aType); |
|
210 |
|
211 /** |
|
212 * Returns information whether a keyevent is fetched successfully |
|
213 * @return ETrue if a keyevent is retieved EFalse if no more queued events |
|
214 */ |
|
215 IMPORT_C TBool GetQueuedKeyEvent(TKeyEvent& aEvent, TEventCode& aType); |
|
216 |
|
217 /** |
|
218 * Reset events queue |
|
219 * @return void |
|
220 */ |
|
221 IMPORT_C void ResetKeyEventQueue(); |
|
222 |
|
223 /** |
|
224 * Returns a reference to the calendar context |
|
225 * @return reference to a CCalenContext |
|
226 */ |
|
227 IMPORT_C MCalenContext& Context(); |
|
228 |
|
229 |
|
230 /* |
|
231 * Initializes multiple db related objects |
|
232 * @return void |
|
233 */ |
|
234 IMPORT_C void InitializeGlobalDataL(); |
|
235 |
|
236 /* |
|
237 * Gets meta db id from collection id |
|
238 * @param cColId collection id for which db id has to be returned |
|
239 * @return TInt Db id for callection id |
|
240 */ |
|
241 IMPORT_C TInt GetDbIdFromCollectionIdL(const TCalCollectionId aColId ); |
|
242 |
|
243 /** |
|
244 * @brief adds new calendar file and sets calendar info to it |
|
245 * |
|
246 * @param aCalendarInfo pointer to the calendar info which is being |
|
247 * set to calsession |
|
248 */ |
|
249 IMPORT_C void AddCalendarL(CCalCalendarInfo* aCalendarInfo); |
|
250 |
|
251 /** |
|
252 * @brief removes dead calendar files from the file system |
|
253 */ |
|
254 IMPORT_C void RemoveDeadCalendarsL(); |
|
255 |
|
256 /** |
|
257 * @brief removes calendar file from the file system |
|
258 * |
|
259 * @param aCalendarFileName Name of the calendar file to be deleted. |
|
260 */ |
|
261 IMPORT_C void RemoveCalendarL(const TDesC& aCalendarFileName); |
|
262 |
|
263 /** |
|
264 * @brief updated calendar info for the calendar file |
|
265 * |
|
266 * @param aCalendarInfo pointer to the calendar info which is being |
|
267 * set to calsession |
|
268 */ |
|
269 IMPORT_C void UpdateCalendarL(CCalCalendarInfo* aCalendarInfo); |
|
270 |
|
271 /** |
|
272 * @brief Get Calendar file name for the given collectionid |
|
273 * |
|
274 * @param cColId collection id for which db id has to be returned |
|
275 * @param aCalendarFileName calendar file name |
|
276 */ |
|
277 IMPORT_C const TDesC& GetCalFileNameForCollectionId( |
|
278 const TCalCollectionId aColId); |
|
279 |
|
280 /** |
|
281 * @brief Get all available calendar info |
|
282 * |
|
283 * @param returns the list of available calendar info iterating |
|
284 * through all calendars |
|
285 */ |
|
286 IMPORT_C void GetAllCalendarInfoL(RPointerArray<CCalCalendarInfo>& aCalendarInfoList); |
|
287 |
|
288 public: // from MMRUtilsObserver |
|
289 void HandleCalEngStatus( TMRUtilsCalEngStatus aStatus ); |
|
290 |
|
291 public: // MCalenNotificationHandler |
|
292 void HandleNotification( const TCalenNotification aNotification ); |
|
293 |
|
294 |
|
295 private: // methods |
|
296 /** |
|
297 * Prompt the user to select their default meeting request mailbox. If the user cancels, |
|
298 * the function returns KErrCancel, otherwise it returns the index of the newly |
|
299 * selected mailbox. This function does not set the default mailbox, but rather returns |
|
300 * the index of the given array to which the default should be set. |
|
301 * @param aMailboxes array of all the mailboxes currently available. |
|
302 * @return KErrCancel if the user declined to set a default, otherwise the index |
|
303 * in aMailboxes to which the default should be set |
|
304 */ |
|
305 TInt PromptToSelectDefaultMailboxL(RArray<CMRMailboxUtils::TMailboxInfo>& aMailboxes); |
|
306 |
|
307 private: |
|
308 /** |
|
309 * C++ constructor. |
|
310 * |
|
311 */ |
|
312 CCalenGlobalData( MCalProgressCallBack& aCalCallBack); |
|
313 |
|
314 /** |
|
315 * By default Symbian 2nd phase constructor is private. |
|
316 * Doesn't take ownership of aNotifier. |
|
317 */ |
|
318 void ConstructL( MCalenContextChangeObserver* aNotifier ); |
|
319 |
|
320 /** |
|
321 * Private Destructor. Users of this class should call Release() instead |
|
322 */ |
|
323 ~CCalenGlobalData(); |
|
324 |
|
325 /** |
|
326 * Sets the CCalenGlobalData to use an externally created CCalSession. |
|
327 * Leaves with KErrAlreadyExists if a different session has already been |
|
328 * created by the CCalenGlobalData |
|
329 */ |
|
330 void SetSessionL(CCalSession* aSession); |
|
331 |
|
332 /** |
|
333 * Create entr yview |
|
334 * @return void |
|
335 */ |
|
336 void CreateEntryViewL(); |
|
337 |
|
338 /** |
|
339 * Create instanceview |
|
340 * @return void |
|
341 */ |
|
342 void CreateInstanceViewL(); |
|
343 |
|
344 /** |
|
345 * Create instanceview |
|
346 * @param aCollectionIds array of collection ids instance view |
|
347 * @return void |
|
348 */ |
|
349 void CreateInstanceViewL(const RArray<TInt>& aCollectionIds); |
|
350 |
|
351 /** |
|
352 * Handle clean up after entryview/ instanceview being created |
|
353 * @param aSuccess status of completion of instamce/entry view |
|
354 * @return void |
|
355 */ |
|
356 void ViewCreationCompleted( TBool aSuccess ); |
|
357 |
|
358 /* |
|
359 * Create new session for calendar name |
|
360 * @param aCalendar calendar filename |
|
361 * @return referance to CCalSession |
|
362 */ |
|
363 CCalSession& CreateNewSessionL( const TDesC& aCalendar ); |
|
364 |
|
365 /* |
|
366 * Create entry view for session |
|
367 * @param session referance to CCalSession |
|
368 * @return void |
|
369 */ |
|
370 void CreateEntryViewL(CCalSession& session); |
|
371 |
|
372 /* |
|
373 * Constructs mapping between symbian calendar file and metabd info |
|
374 * @return TBool status of construction |
|
375 */ |
|
376 TBool ConstructFileMappingL(); |
|
377 |
|
378 /* |
|
379 * Find filemapping object based on calendar name |
|
380 * @param aName calendar filename |
|
381 * @param aFileMapping referance for RPointerArray find method. |
|
382 * @return TBool find status |
|
383 */ |
|
384 static TBool CalenInfoIdentifierL( const HBufC* aName, |
|
385 const CCalenFileMapping& aFileMapping); |
|
386 |
|
387 |
|
388 /* |
|
389 * Find CCalCalendarInfo object based on calendar filename |
|
390 * @param aFileName pointer to filename. |
|
391 * @param CCalCalendarInfo referance for RPointerArray find method. |
|
392 * @return TBool find status |
|
393 */ |
|
394 static TBool CalenCalendarInfoIdentiferL(const HBufC* aFileName, |
|
395 const CCalCalendarInfo& aCalendarInfo); |
|
396 |
|
397 /* |
|
398 * @brief create new session for calendar name |
|
399 * |
|
400 * @param aCalendar calendar filename |
|
401 * @return referance to CCalSession |
|
402 */ |
|
403 CCalSession& CreateNewSessionL( const TDesC& aCalendar, |
|
404 const CCalCalendarInfo& aCalendarInfo ); |
|
405 |
|
406 /* |
|
407 * @brief Find filemapping object based on collection id |
|
408 * |
|
409 * @param aCollectionId collection id |
|
410 * @param aFileMapping referance for RPointerArray find method. |
|
411 * @return TBool find status |
|
412 */ |
|
413 static TBool CalenFileMapIdentifierForColId(const TCalCollectionId* aId, |
|
414 const CCalenFileMapping& aFileMapping ); |
|
415 |
|
416 /** |
|
417 * @brief Construct calendarlist using calendar iterator |
|
418 */ |
|
419 void ConstructCalendarsListL(); |
|
420 |
|
421 /** |
|
422 * @brief gets default calendar information |
|
423 * |
|
424 * @return CCalCalendarInfo returns pointer to default calendar info |
|
425 */ |
|
426 CCalCalendarInfo* GetDefaultCalendarInfoL(); |
|
427 |
|
428 /** |
|
429 * @brief Handles the notification ECalenNotifyCalendarInfoCreated |
|
430 * Adds a new calendar to the available calendar list in calendar app |
|
431 */ |
|
432 void HandleCalendarInfoCreatedL(); |
|
433 |
|
434 /** |
|
435 * @brief Handles the notification ECalenNotifyCalendarInfoUpdated |
|
436 * Updates a new calendar in the available calendar list in calendar app |
|
437 */ |
|
438 void HandleCalendarInfoUpdatedL(); |
|
439 |
|
440 /** |
|
441 * @brief Handles the notification ECalenNotifyCalendarFileDeleted |
|
442 * Deletes a calendar from the calendar list |
|
443 */ |
|
444 void HandleCalendarFileDeletedL(); |
|
445 |
|
446 private: |
|
447 // Member data owned by this class. Member data is only initialised on first use |
|
448 CActiveSchedulerWait* iUtilsAs; |
|
449 CCalSession* iCalSession; |
|
450 CCalEntryView* iEntryView; |
|
451 CCalEntryView* iEntryViewCreation; |
|
452 CCalInstanceView* iInstanceView; |
|
453 CCalInstanceView* iInstanceViewCreation; |
|
454 CCalSession* iNewCalSession; |
|
455 CCalEntryView* iNewEntryView; |
|
456 CCalEntryView* iNewEntryViewCreation; |
|
457 CCalInstanceView* iNewInstanceView; |
|
458 CCalInstanceView* iNewInstanceViewCreation; |
|
459 CCalenInterimUtils2* iInterimUtils; |
|
460 CCalenSend* iSend; |
|
461 CCalenContextImpl* iContext; |
|
462 CMRUtils* iMRUtils; |
|
463 TInt iRefCount; |
|
464 TInt iCreateError; |
|
465 TBool iGlobalDataOwnsCalSession; |
|
466 TBool iGlobalDataOwnsEntryView; |
|
467 RPointerArray<CCalenFileMapping > iFileMappingArray; |
|
468 RHashMap<TInt, TInt> iHashDbidIndexMap; |
|
469 |
|
470 //Only used if meeting request solution exists on device, otherwise NULL |
|
471 CMRMailboxUtils* iMailboxUtils; |
|
472 |
|
473 struct TQueuedKeyEvent { |
|
474 TKeyEvent iEvent; |
|
475 TEventCode iType; |
|
476 }; |
|
477 |
|
478 typedef void (CCalenGlobalData::*QueuedFunction)(); |
|
479 QueuedFunction iQueued; |
|
480 |
|
481 // Not owned by class. Needed for entry and instance view |
|
482 // creation. |
|
483 MCalProgressCallBack& iCalCallBack; |
|
484 RArray< TQueuedKeyEvent > iKeyQueue; |
|
485 TBool iCalendarForcedExit; |
|
486 CCalSession* iCalendarsSession; |
|
487 RPointerArray<CCalCalendarInfo> iCalendarInfoList; |
|
488 }; |
|
489 |
|
490 #endif // CALENGLOBALDATA_H |
|
491 |
|
492 // End of File |