66
|
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 |
// changes done for missing popup in idle screen when alarm expires in editor mode
|
|
250 |
iNumOfMissedAlarms = TInt(newCount);
|
|
251 |
iShowSoftNotification = ETrue;
|
|
252 |
}
|
|
253 |
|
|
254 |
TRACE_EXIT_POINT;
|
|
255 |
}
|
|
256 |
|
|
257 |
// -----------------------------------------------------------------------------
|
|
258 |
// CCalenSvrMissedAlarmManager::HandleMissedAlarmSoftNotificationL
|
|
259 |
// Update soft notification/status pane indicator
|
|
260 |
// -----------------------------------------------------------------------------
|
|
261 |
//
|
|
262 |
void CCalenSvrMissedAlarmManager::HandleMissedAlarmSoftNotificationL()
|
|
263 |
{
|
|
264 |
TRACE_ENTRY_POINT;
|
|
265 |
|
|
266 |
//Update indicator
|
|
267 |
HandleMissedAlarmSmallIndicatorL(
|
|
268 |
(iNumOfMissedAlarms > KNoMissedAlarms ? ETrue : EFalse));
|
|
269 |
|
|
270 |
CAknSoftNotificationParameters* softNotificationParameters =
|
|
271 |
CreateNotificationParametersLC( aNotificationType );
|
|
272 |
|
|
273 |
if(!iShowSoftNotification )
|
|
274 |
{
|
|
275 |
iSoftNotifier->CancelCustomSoftNotificationL( *softNotificationParameters );
|
|
276 |
}
|
|
277 |
else
|
|
278 |
{
|
|
279 |
if(iNumOfMissedAlarms > KNoMissedAlarms) //check for -ve
|
|
280 |
{
|
|
281 |
iSoftNotifier->SetCustomNotificationCountL(
|
|
282 |
*softNotificationParameters, iNumOfMissedAlarms );
|
|
283 |
}
|
|
284 |
}
|
|
285 |
|
|
286 |
CleanupStack::PopAndDestroy( softNotificationParameters );
|
|
287 |
|
|
288 |
TRACE_EXIT_POINT;
|
|
289 |
}
|
|
290 |
|
|
291 |
// -----------------------------------------------------------------------------
|
|
292 |
// CCalenSvrMissedAlarmManager::HandleMissedAlarmCoverUISoftNotificationL
|
|
293 |
// ?implementation_description
|
|
294 |
// (other items were commented in a header).
|
|
295 |
// -----------------------------------------------------------------------------
|
|
296 |
//
|
|
297 |
void CCalenSvrMissedAlarmManager::HandleMissedAlarmCoverUISoftNotificationL()
|
|
298 |
{
|
|
299 |
TRACE_ENTRY_POINT;
|
|
300 |
TRACE_EXIT_POINT;
|
|
301 |
}
|
|
302 |
|
|
303 |
// -----------------------------------------------------------------------------
|
|
304 |
// CCalenSvrMissedAlarmManager::CreateNotificationParametersLC
|
|
305 |
// Initialise soft notification parameters.
|
|
306 |
// -----------------------------------------------------------------------------
|
|
307 |
//
|
|
308 |
CAknSoftNotificationParameters* CCalenSvrMissedAlarmManager::
|
|
309 |
CreateNotificationParametersLC(
|
|
310 |
const TAknSoftNotificationType aNotificationType )
|
|
311 |
{
|
|
312 |
TRACE_ENTRY_POINT;
|
|
313 |
|
|
314 |
// instantiate parameters
|
|
315 |
CAknSoftNotificationParameters* softNotificationParameters = NULL;
|
|
316 |
|
|
317 |
switch( aNotificationType )
|
|
318 |
{
|
|
319 |
case ECustomSoftNotification: //Notification for missed alarm message
|
|
320 |
{
|
|
321 |
TUint32 newCount = 0;
|
|
322 |
iMissedAlarmStore->CountL(newCount);
|
|
323 |
|
|
324 |
if(newCount>1)
|
|
325 |
{
|
|
326 |
// if count is more than one,launch missed alarms view
|
|
327 |
const TDesC8& viewActivationMsg = _L8("MAV");
|
|
328 |
softNotificationParameters = CAknSoftNotificationParameters::NewL(
|
|
329 |
KMissedAlarmResourceFile,
|
|
330 |
R_MISSED_ALARM_SOFT_NOTIFICATION ,
|
|
331 |
KMissedAlarmNotificationPriority,
|
|
332 |
R_AVKON_SOFTKEYS_SHOW_EXIT,
|
|
333 |
CAknNoteDialog::ENoTone,
|
|
334 |
KMissedAlarmsViewId,
|
|
335 |
KCommandUid,
|
|
336 |
EAknSoftkeyShow,
|
|
337 |
viewActivationMsg);
|
|
338 |
|
|
339 |
softNotificationParameters->SetGroupedTexts( R_MISSED_ALARM_UI_GROUPED );
|
|
340 |
}
|
|
341 |
else
|
|
342 |
{
|
|
343 |
// if count is one,launch missed event view
|
|
344 |
const TDesC8& viewActivationMsg = _L8("MEV");
|
|
345 |
softNotificationParameters = CAknSoftNotificationParameters::NewL(
|
|
346 |
KMissedAlarmResourceFile,
|
|
347 |
R_MISSED_ALARM_SOFT_NOTIFICATION ,
|
|
348 |
KMissedAlarmNotificationPriority,
|
|
349 |
R_AVKON_SOFTKEYS_SHOW_EXIT,
|
|
350 |
CAknNoteDialog::ENoTone,
|
|
351 |
KMissedEventViewId,
|
|
352 |
KCommandUid,
|
|
353 |
EAknSoftkeyShow,
|
|
354 |
viewActivationMsg);
|
|
355 |
softNotificationParameters->SetGroupedTexts( R_MISSED_ALARM_UI_GROUPED );
|
|
356 |
}
|
|
357 |
break;
|
|
358 |
}
|
|
359 |
default:
|
|
360 |
{
|
|
361 |
// No other notification type is supported for now.
|
|
362 |
User::Leave( KErrNotFound );
|
|
363 |
break;
|
|
364 |
}
|
|
365 |
}
|
|
366 |
CleanupStack::PushL( softNotificationParameters );
|
|
367 |
|
|
368 |
TRACE_EXIT_POINT;
|
|
369 |
return softNotificationParameters;
|
|
370 |
}
|
|
371 |
|
|
372 |
// -----------------------------------------------------------------------------
|
|
373 |
// CCalenSvrMissedAlarmManager::HandleMissedAlarmSmallIndicatorL
|
|
374 |
// For Handling calendar's status pane indicator
|
|
375 |
// -----------------------------------------------------------------------------
|
|
376 |
//
|
|
377 |
void CCalenSvrMissedAlarmManager::HandleMissedAlarmSmallIndicatorL(TBool aArg)
|
|
378 |
{
|
|
379 |
TRACE_ENTRY_POINT;
|
|
380 |
CAknSmallIndicator* indicator = CAknSmallIndicator::NewL(
|
|
381 |
TUid::Uid( EAknIndicatorMissedCalendarAlarm ) );
|
|
382 |
CleanupStack::PushL(indicator);
|
|
383 |
indicator->SetIndicatorStateL( aArg );
|
|
384 |
CleanupStack::PopAndDestroy(); // indicator
|
|
385 |
TRACE_EXIT_POINT;
|
|
386 |
}
|
|
387 |
|
|
388 |
// End of file
|