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