|
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: Calendar notifier |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef CALENNOTIFIER_H |
|
21 #define CALENNOTIFIER_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32hashtab.h> // RHashSet |
|
25 #include <cenrepnotifyhandler.h> // MCenRepNotifyHandlerCallback |
|
26 #include <calennotificationhandler.h> // MCalenNotificationHandler |
|
27 #include <calprogresscallback.h> // MCalProgressCallBack |
|
28 #include <calfilechangenotification.h> // MCalFileChangeObserver |
|
29 |
|
30 #include "calendbchangenotifier.h" // MCalenDBChangeObserver |
|
31 #include "calencontextchangeobserver.h" // MCalenContextChangeObserver |
|
32 #include "calenecomchangeobserver.h" // MCalenEComChangeObserver |
|
33 |
|
34 // FORWARD DECLARATIONS |
|
35 class CCalenGlobalData; // Calendar global data singleton |
|
36 class CEnvironmentChangeNotifier; // Receive system event notifications |
|
37 class CCalenDbChangeNotifier; // Receive database change notifications |
|
38 class CCalenEComWatcher; // Receives Ecom registry change notifications |
|
39 class CCalenSetting; // Calendar settings |
|
40 class CCalenController; |
|
41 class CCalFileChangeInfo; |
|
42 |
|
43 /** |
|
44 * CCalenNotifier observes various system events relevent to Calendar |
|
45 * MCalenNotificationHandlers can register for notifications of specific |
|
46 * events. This minimises the number of event observers required |
|
47 * throughout the Calendar application. |
|
48 */ |
|
49 class CCalenNotifier : public CBase, |
|
50 public MCenRepNotifyHandlerCallback, |
|
51 public MCalenDBChangeObserver, |
|
52 public MCalProgressCallBack, |
|
53 public MCalenContextChangeObserver, |
|
54 public MCalenEComChangeObserver, |
|
55 public MCalFileChangeObserver |
|
56 |
|
57 { |
|
58 public: |
|
59 /** |
|
60 * C++ default Constructor |
|
61 */ |
|
62 CCalenNotifier( CCalenController& aController ); |
|
63 |
|
64 /** |
|
65 * 2nd phase of construction. |
|
66 */ |
|
67 void ConstructL(); |
|
68 |
|
69 /** |
|
70 * Destructor |
|
71 */ |
|
72 virtual ~CCalenNotifier(); |
|
73 |
|
74 public: |
|
75 /** |
|
76 * Allows MCalenNotificationHandlers to register for system event |
|
77 * notifications |
|
78 * @param aHandler Handler to register |
|
79 * @param aFlag Notification of events to notify aHandler about |
|
80 */ |
|
81 void RegisterForNotificationsL( MCalenNotificationHandler* aHandler, |
|
82 TCalenNotification aNotification ); |
|
83 |
|
84 /** |
|
85 * Allows MCalenNotificationHandlers to register for system event |
|
86 * notifications |
|
87 * @param aHandler Handler to register |
|
88 * @param aFlags Array of notifications to notify aHandler about |
|
89 */ |
|
90 void RegisterForNotificationsL( MCalenNotificationHandler* aHandler, |
|
91 RArray<TCalenNotification>& aNotifications ); |
|
92 |
|
93 /** |
|
94 * Allows MCalenNotificationHandlers to cancel system event |
|
95 * notifications |
|
96 * @param aHandler Handler to deregister |
|
97 */ |
|
98 void CancelNotifications( MCalenNotificationHandler* aHandler ); |
|
99 |
|
100 /** |
|
101 * Notify all interested handlers about an event |
|
102 * @param aNotification Notification to broadcast |
|
103 */ |
|
104 void BroadcastNotification( TCalenNotification aNotification ); |
|
105 |
|
106 /** |
|
107 * Notify all interested handlers about an event |
|
108 * @param aNotification Notification to broadcast |
|
109 */ |
|
110 void BroadcastApprovedNotification( TCalenNotification aNotification ); |
|
111 |
|
112 /** |
|
113 * Check if the system time changed since Calendar was |
|
114 * last launched |
|
115 */ |
|
116 TInt SystemTimeChangedL(); |
|
117 |
|
118 /** |
|
119 * After calling this function, any settings changed notifications |
|
120 * will not be broadcast until after ResumeSettingsNotifications |
|
121 * has been called. |
|
122 */ |
|
123 void DeferSettingsNotifications(); |
|
124 |
|
125 /** |
|
126 * Resumes settings notifications after they have been paused |
|
127 * with DeferSettingsNotifications. |
|
128 */ |
|
129 void ResumeSettingsNotifications(); |
|
130 |
|
131 /** |
|
132 * Update the cenrep with latest system time change information |
|
133 */ |
|
134 void UpdateSytemTimeChangeInfoL(); |
|
135 |
|
136 public: |
|
137 /** |
|
138 * From MCenRepNotifyHandlerCallback. |
|
139 * Notification of any change to the Calendar central repository |
|
140 * where the main Calendar settings are stored |
|
141 * @param aId Id of the cenrep key that changed |
|
142 */ |
|
143 void HandleNotifyGeneric( TUint32 aId ); |
|
144 |
|
145 /** |
|
146 * From MCenRepNotifyHandlerCallback. |
|
147 * Notification of central repository observer failure. |
|
148 */ |
|
149 void HandleNotifyError( TUint32 aId, |
|
150 TInt aError, |
|
151 CCenRepNotifyHandler* aHandler ); |
|
152 |
|
153 /** |
|
154 * From MCalenDBChangeObserver. |
|
155 * Notification of any change to the Calendar database through an |
|
156 * external CCalSession. |
|
157 * Notifications are limited to a maximum of one per second |
|
158 */ |
|
159 void HandleDBChangeL(); |
|
160 |
|
161 /** |
|
162 * From MCalenContextChangeObserver. |
|
163 * Called when the context changes. |
|
164 */ |
|
165 void ContextChanged(); |
|
166 |
|
167 /** |
|
168 * From MCalenEComChangeObserver |
|
169 * Called by when the ecom registry gets changed. |
|
170 */ |
|
171 void EComChanged(); |
|
172 |
|
173 /** |
|
174 * @brief From MCalFileChangeObserver |
|
175 * The callback that will recieve 1 or more file change notifications |
|
176 * |
|
177 * @param aCalendarInfoChangeEntries Holds the information about the |
|
178 * calendar info changes |
|
179 */ |
|
180 void CalendarInfoChangeNotificationL( |
|
181 RPointerArray<CCalFileChangeInfo>& aCalendarInfoChangeEntries); |
|
182 |
|
183 public: |
|
184 /** |
|
185 * From MCallProgressCallBack |
|
186 * Called when CCalEntryView creation is complete. |
|
187 * @param aStatus completion status |
|
188 */ |
|
189 void Completed( TInt aStatus ); |
|
190 |
|
191 /** |
|
192 * From MCallProgressCallBack |
|
193 * Not used by this class |
|
194 */ |
|
195 void Progress( TInt aPercentageCompleted ); |
|
196 |
|
197 /** |
|
198 * From MCallProgressCallBack |
|
199 * Returns EFalse to disable progress notifications |
|
200 */ |
|
201 TBool NotifyProgress(); |
|
202 |
|
203 private: // Callback functions from observers |
|
204 /** |
|
205 * Called from CEnvironmentChangeNotifier when the |
|
206 * system environment changes |
|
207 * @param aThisPtr self pointer |
|
208 * @return EFalse |
|
209 */ |
|
210 static TInt EnvChangeCallbackL( TAny* aThisPtr ); |
|
211 |
|
212 /** |
|
213 * Broadcasts the given notification. |
|
214 * @param aNotification Notification id to be broadcasted |
|
215 */ |
|
216 void DoBroadcast( TCalenNotification aNotification ); |
|
217 |
|
218 TInt DoEnvChange(); |
|
219 |
|
220 static TInt AsyncRemoveCalendarL(TAny* aThisPtr); |
|
221 |
|
222 void AsyncRemoveCalendarL(); |
|
223 |
|
224 private: // Data |
|
225 // Array of handlers to notify |
|
226 class TNotificationHandler |
|
227 { |
|
228 public: |
|
229 TNotificationHandler(); |
|
230 |
|
231 RHashSet<TCalenNotification> iHashSet; |
|
232 MCalenNotificationHandler* iHandler; |
|
233 }; |
|
234 |
|
235 RArray<TNotificationHandler> iHandlers; |
|
236 |
|
237 // Notifications about locale and time changes |
|
238 CEnvironmentChangeNotifier* iEnvChangeNotifier; |
|
239 |
|
240 // Notifications about Calendar settings changes |
|
241 CRepository* iRepository; |
|
242 CCenRepNotifyHandler* iCenRepChangeNotifier; |
|
243 |
|
244 // Calendar Global Data singleton |
|
245 CCalenGlobalData* iGlobalData; |
|
246 |
|
247 // Notifications about changes to the ECom registry |
|
248 CCalenEComWatcher* iEComWatcher; |
|
249 // CCalenEComWatcher* iEComWatcher1; |
|
250 |
|
251 RArray<TCalenNotification> iBroadcastQueue; |
|
252 TBool iBroadcastActive; |
|
253 |
|
254 CCalenDbChangeNotifier* iDbChangeNotifier; |
|
255 CCalenSetting* iSetting; |
|
256 TBool iIsSettingsBroadcastDeferred; |
|
257 TBool iSettingsNeedsBroadcast; |
|
258 TBool iLocaleNeedsBroadcast; |
|
259 CCalenController& iController; |
|
260 TBool iIgnoreFirstLocaleChange; |
|
261 |
|
262 // latest time change from agenda server |
|
263 TReal iTimeOfChangeUtcReal; |
|
264 |
|
265 CAsyncCallBack* iAsyncCallback; |
|
266 HBufC* iFilnameDeleted; |
|
267 }; |
|
268 |
|
269 #endif // CALENNOTIFIER_H |
|
270 |
|
271 // End of file |