|
1 /* |
|
2 * Copyright (c) 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: An missed alarm handler class, CCalenSvrMissedAlarmManager. |
|
15 * This class takes care of handling the UI and cenrep updation |
|
16 * for missed alarms. |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 |
|
22 #include <avkon.rsg> |
|
23 #include <AknSmallIndicator.h> |
|
24 #include <centralrepository.h> |
|
25 #include <missedalarmstorecrkeys.h> |
|
26 #include <CalendarInternalCRKeys.h> |
|
27 #include <calensvrmissedalarmmanagerresource.rsg> |
|
28 |
|
29 #include "calendarui_debug.h" |
|
30 #include "calensvrmissedalarmmanager.h" |
|
31 #include "calenmissedalarmconstants.h" |
|
32 |
|
33 // ----------------------------------------------------------------------------- |
|
34 // CCalenSvrMissedAlarmManager::NewL |
|
35 // First phase construction |
|
36 // ----------------------------------------------------------------------------- |
|
37 // |
|
38 CCalenSvrMissedAlarmManager* CCalenSvrMissedAlarmManager::NewL() |
|
39 { |
|
40 TRACE_ENTRY_POINT; |
|
41 CCalenSvrMissedAlarmManager* self = new( ELeave )CCalenSvrMissedAlarmManager(); |
|
42 CleanupStack::PushL( self ); |
|
43 self->ConstructL(); |
|
44 CleanupStack::Pop( self ); |
|
45 TRACE_EXIT_POINT; |
|
46 return self; |
|
47 } |
|
48 |
|
49 // ----------------------------------------------------------------------------- |
|
50 // CCalenSvrMissedAlarmManager::CCalenSvrMissedAlarmManager |
|
51 // Default constructor |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 CCalenSvrMissedAlarmManager::CCalenSvrMissedAlarmManager() : |
|
55 CActive(CActive::EPriorityLow), |
|
56 iNumOfMissedAlarms( KNoMissedAlarms ), |
|
57 iShowSoftNotification( EFalse ) |
|
58 { |
|
59 TRACE_ENTRY_POINT; |
|
60 |
|
61 CActiveScheduler::Add(this); |
|
62 |
|
63 TRACE_EXIT_POINT; |
|
64 } |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // CCalenSvrMissedAlarmManager::CCalenSvrMissedAlarmManager |
|
68 // Second phase construction |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 void CCalenSvrMissedAlarmManager::ConstructL() |
|
72 { |
|
73 TRACE_ENTRY_POINT; |
|
74 |
|
75 iSoftNotifier = CAknSoftNotifier::NewL(); |
|
76 |
|
77 iMissedAlarmStoreRepository = CRepository::NewL( KCRUidMissedAlarmStore ); |
|
78 |
|
79 // Create missed alarm store |
|
80 iMissedAlarmStore = CMissedAlarmStore::NewL(*iMissedAlarmStoreRepository); |
|
81 |
|
82 iCenRepChangeNotifier = CCenRepNotifyHandler::NewL( *this, *iMissedAlarmStoreRepository ); |
|
83 iCenRepChangeNotifier->StartListeningL(); |
|
84 |
|
85 Start(); |
|
86 |
|
87 TRACE_EXIT_POINT; |
|
88 } |
|
89 |
|
90 // ----------------------------------------------------------------------------- |
|
91 // CCalenSvrMissedAlarmManager::~CCalenSvrMissedAlarmManager |
|
92 // Destructor |
|
93 // ----------------------------------------------------------------------------- |
|
94 // |
|
95 CCalenSvrMissedAlarmManager::~CCalenSvrMissedAlarmManager() |
|
96 { |
|
97 TRACE_ENTRY_POINT; |
|
98 |
|
99 Cancel(); |
|
100 |
|
101 delete iSoftNotifier; |
|
102 iSoftNotifier = NULL; |
|
103 |
|
104 if(iCenRepChangeNotifier) |
|
105 { |
|
106 iCenRepChangeNotifier->StopListening(); |
|
107 delete iCenRepChangeNotifier; |
|
108 } |
|
109 |
|
110 delete iMissedAlarmStore; |
|
111 iMissedAlarmStore = NULL; |
|
112 |
|
113 TRACE_EXIT_POINT; |
|
114 } |
|
115 |
|
116 // ----------------------------------------------------------------------------- |
|
117 // CCalenSvrMissedAlarmManager::Start |
|
118 // Start the scheduler |
|
119 // ----------------------------------------------------------------------------- |
|
120 // |
|
121 void CCalenSvrMissedAlarmManager::Start() |
|
122 { |
|
123 TRACE_ENTRY_POINT; |
|
124 |
|
125 __ASSERT_ALWAYS(!IsActive(), User::Invariant()); |
|
126 TRequestStatus* pStat = &iStatus; |
|
127 User::RequestComplete(pStat, KErrNone); |
|
128 SetActive(); |
|
129 |
|
130 TRACE_EXIT_POINT; |
|
131 } |
|
132 |
|
133 // ---------------------------------------------------------------------------- |
|
134 // CCalenSvrMissedAlarmManager::HandleNotifyGeneric |
|
135 // From MCenRepNotifyHandlerCallback |
|
136 // Generic notification that one of our central repository keys has changed |
|
137 // If any keys change we broadcast a settings changed notification |
|
138 // (other items were commented in a header). |
|
139 // ---------------------------------------------------------------------------- |
|
140 // |
|
141 void CCalenSvrMissedAlarmManager::HandleNotifyGeneric( TUint32 aCenrepKeyId ) |
|
142 { |
|
143 TRACE_ENTRY_POINT; |
|
144 |
|
145 if(aCenrepKeyId <= KMissedAlarmsMaxValue) |
|
146 { |
|
147 TRAP_IGNORE(HandleMissedAlarmL()); |
|
148 } |
|
149 |
|
150 TRACE_EXIT_POINT; |
|
151 } |
|
152 |
|
153 // ----------------------------------------------------------------------------- |
|
154 // CCalenSvrMissedAlarmManager::HandleMissedAlarmL |
|
155 // Handles the change in missed alarm store. |
|
156 // updates soft notification and indicator plugins |
|
157 // ----------------------------------------------------------------------------- |
|
158 // |
|
159 void CCalenSvrMissedAlarmManager::HandleMissedAlarmL() |
|
160 { |
|
161 TRACE_ENTRY_POINT; |
|
162 //If the value of supressnotification is 1 then supress the missed alarm soft notification |
|
163 //If the value of supressnotification is 0 then show the missed alarm soft notification |
|
164 CRepository* repository = CRepository::NewL( KCRUidCalendar ); |
|
165 TBool supressnotification = EFalse; |
|
166 repository->Get( KCalendarSupressMissedAlarmSoftNotification, supressnotification ); |
|
167 |
|
168 if( supressnotification ) |
|
169 { |
|
170 TRACE_EXIT_POINT; |
|
171 return; |
|
172 } |
|
173 //Update with the count from the metadata |
|
174 GetCountOfMissedAlarmsL(); |
|
175 |
|
176 // Update Soft Notifications |
|
177 HandleMissedAlarmSoftNotificationL(); |
|
178 |
|
179 TRACE_EXIT_POINT; |
|
180 } |
|
181 |
|
182 // ----------------------------------------------------------------------------- |
|
183 // CCalenSvrMissedAlarmManager::DoCancel |
|
184 // For cancel |
|
185 // ----------------------------------------------------------------------------- |
|
186 // |
|
187 void CCalenSvrMissedAlarmManager::DoCancel() |
|
188 { |
|
189 TRACE_ENTRY_POINT; |
|
190 TRACE_EXIT_POINT; |
|
191 } |
|
192 |
|
193 // ----------------------------------------------------------------------------- |
|
194 // CCalenSvrMissedAlarmManager::RunError |
|
195 // ?implementation_description |
|
196 // (other items were commented in a header). |
|
197 // ----------------------------------------------------------------------------- |
|
198 // |
|
199 TInt CCalenSvrMissedAlarmManager::RunError(TInt /*aError*/) |
|
200 { |
|
201 TRACE_ENTRY_POINT; |
|
202 TRACE_EXIT_POINT; |
|
203 |
|
204 return 0; |
|
205 } |
|
206 |
|
207 // ----------------------------------------------------------------------------- |
|
208 // CCalenSvrMissedAlarmManager::RunL |
|
209 // Handle missed alarms on RunL |
|
210 // ----------------------------------------------------------------------------- |
|
211 // |
|
212 void CCalenSvrMissedAlarmManager::RunL() |
|
213 { |
|
214 TRACE_ENTRY_POINT; |
|
215 |
|
216 HandleMissedAlarmL(); |
|
217 |
|
218 TRACE_EXIT_POINT; |
|
219 } |
|
220 |
|
221 // ----------------------------------------------------------------------------- |
|
222 // CCalenSvrMissedAlarmManager::GetCountOfMissedAlarms |
|
223 // Get count of missed alarms from cenrep |
|
224 // ----------------------------------------------------------------------------- |
|
225 // |
|
226 void CCalenSvrMissedAlarmManager::GetCountOfMissedAlarmsL() |
|
227 { |
|
228 TRACE_ENTRY_POINT; |
|
229 |
|
230 TUint32 newCount = 0; |
|
231 iMissedAlarmStore->CountL(newCount); |
|
232 |
|
233 if(TInt(newCount) <= KNoMissedAlarms) |
|
234 { |
|
235 iNumOfMissedAlarms = KNoMissedAlarms; |
|
236 iShowSoftNotification = EFalse; |
|
237 } |
|
238 else |
|
239 { |
|
240 if(iNumOfMissedAlarms > TInt(newCount)) |
|
241 { |
|
242 iShowSoftNotification = EFalse; |
|
243 } |
|
244 else |
|
245 { |
|
246 iShowSoftNotification = ETrue; |
|
247 } |
|
248 |
|
249 iNumOfMissedAlarms = TInt(newCount); |
|
250 } |
|
251 |
|
252 TRACE_EXIT_POINT; |
|
253 } |
|
254 |
|
255 // ----------------------------------------------------------------------------- |
|
256 // CCalenSvrMissedAlarmManager::HandleMissedAlarmSoftNotificationL |
|
257 // Update soft notification/status pane indicator |
|
258 // ----------------------------------------------------------------------------- |
|
259 // |
|
260 void CCalenSvrMissedAlarmManager::HandleMissedAlarmSoftNotificationL() |
|
261 { |
|
262 TRACE_ENTRY_POINT; |
|
263 |
|
264 //Update indicator |
|
265 HandleMissedAlarmSmallIndicatorL( |
|
266 (iNumOfMissedAlarms > KNoMissedAlarms ? ETrue : EFalse)); |
|
267 |
|
268 CAknSoftNotificationParameters* softNotificationParameters = |
|
269 CreateNotificationParametersLC( aNotificationType ); |
|
270 |
|
271 if(!iShowSoftNotification ) |
|
272 { |
|
273 iSoftNotifier->CancelCustomSoftNotificationL( *softNotificationParameters ); |
|
274 } |
|
275 else |
|
276 { |
|
277 if(iNumOfMissedAlarms > KNoMissedAlarms) //check for -ve |
|
278 { |
|
279 iSoftNotifier->SetCustomNotificationCountL( |
|
280 *softNotificationParameters, iNumOfMissedAlarms ); |
|
281 } |
|
282 } |
|
283 |
|
284 CleanupStack::PopAndDestroy( softNotificationParameters ); |
|
285 |
|
286 TRACE_EXIT_POINT; |
|
287 } |
|
288 |
|
289 // ----------------------------------------------------------------------------- |
|
290 // CCalenSvrMissedAlarmManager::HandleMissedAlarmCoverUISoftNotificationL |
|
291 // ?implementation_description |
|
292 // (other items were commented in a header). |
|
293 // ----------------------------------------------------------------------------- |
|
294 // |
|
295 void CCalenSvrMissedAlarmManager::HandleMissedAlarmCoverUISoftNotificationL() |
|
296 { |
|
297 TRACE_ENTRY_POINT; |
|
298 TRACE_EXIT_POINT; |
|
299 } |
|
300 |
|
301 // ----------------------------------------------------------------------------- |
|
302 // CCalenSvrMissedAlarmManager::CreateNotificationParametersLC |
|
303 // Initialise soft notification parameters. |
|
304 // ----------------------------------------------------------------------------- |
|
305 // |
|
306 CAknSoftNotificationParameters* CCalenSvrMissedAlarmManager:: |
|
307 CreateNotificationParametersLC( |
|
308 const TAknSoftNotificationType aNotificationType ) |
|
309 { |
|
310 TRACE_ENTRY_POINT; |
|
311 |
|
312 // instantiate parameters |
|
313 CAknSoftNotificationParameters* softNotificationParameters = NULL; |
|
314 |
|
315 switch( aNotificationType ) |
|
316 { |
|
317 case ECustomSoftNotification: //Notification for missed alarm message |
|
318 { |
|
319 TUint32 newCount = 0; |
|
320 iMissedAlarmStore->CountL(newCount); |
|
321 |
|
322 if(newCount>1) |
|
323 { |
|
324 // if count is more than one,launch missed alarms view |
|
325 const TDesC8& viewActivationMsg = _L8("MAV"); |
|
326 softNotificationParameters = CAknSoftNotificationParameters::NewL( |
|
327 KMissedAlarmResourceFile, |
|
328 R_MISSED_ALARM_SOFT_NOTIFICATION , |
|
329 KMissedAlarmNotificationPriority, |
|
330 R_AVKON_SOFTKEYS_SHOW_EXIT, |
|
331 CAknNoteDialog::ENoTone, |
|
332 KMissedAlarmsViewId, |
|
333 KCommandUid, |
|
334 EAknSoftkeyShow, |
|
335 viewActivationMsg); |
|
336 |
|
337 softNotificationParameters->SetGroupedTexts( R_MISSED_ALARM_UI_GROUPED ); |
|
338 } |
|
339 else |
|
340 { |
|
341 // if count is one,launch missed event view |
|
342 const TDesC8& viewActivationMsg = _L8("MEV"); |
|
343 softNotificationParameters = CAknSoftNotificationParameters::NewL( |
|
344 KMissedAlarmResourceFile, |
|
345 R_MISSED_ALARM_SOFT_NOTIFICATION , |
|
346 KMissedAlarmNotificationPriority, |
|
347 R_AVKON_SOFTKEYS_SHOW_EXIT, |
|
348 CAknNoteDialog::ENoTone, |
|
349 KMissedEventViewId, |
|
350 KCommandUid, |
|
351 EAknSoftkeyShow, |
|
352 viewActivationMsg); |
|
353 softNotificationParameters->SetGroupedTexts( R_MISSED_ALARM_UI_GROUPED ); |
|
354 } |
|
355 break; |
|
356 } |
|
357 default: |
|
358 { |
|
359 // No other notification type is supported for now. |
|
360 User::Leave( KErrNotFound ); |
|
361 break; |
|
362 } |
|
363 } |
|
364 CleanupStack::PushL( softNotificationParameters ); |
|
365 |
|
366 TRACE_EXIT_POINT; |
|
367 return softNotificationParameters; |
|
368 } |
|
369 |
|
370 // ----------------------------------------------------------------------------- |
|
371 // CCalenSvrMissedAlarmManager::HandleMissedAlarmSmallIndicatorL |
|
372 // For Handling calendar's status pane indicator |
|
373 // ----------------------------------------------------------------------------- |
|
374 // |
|
375 void CCalenSvrMissedAlarmManager::HandleMissedAlarmSmallIndicatorL(TBool aArg) |
|
376 { |
|
377 TRACE_ENTRY_POINT; |
|
378 CAknSmallIndicator* indicator = CAknSmallIndicator::NewL( |
|
379 TUid::Uid( EAknIndicatorMissedCalendarAlarm ) ); |
|
380 CleanupStack::PushL(indicator); |
|
381 indicator->SetIndicatorStateL( aArg ); |
|
382 CleanupStack::PopAndDestroy(); // indicator |
|
383 TRACE_EXIT_POINT; |
|
384 } |
|
385 |
|
386 // End of file |