|
1 /* |
|
2 * Copyright (c) 2006-2009 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // SYSTEM INCLUDES |
|
20 #include <uiklaf/private/lafshut.h> |
|
21 #include <w32std.h> |
|
22 #include <coemain.h> |
|
23 #include <lafmemorywatcher.rsg> |
|
24 #include <bautils.h> |
|
25 #include <e32property.h> |
|
26 #include <UikonInternalPSKeys.h> |
|
27 #include <aknglobalnote.h> |
|
28 #include <secondarydisplay/aknsecondarydisplaydefs.h> |
|
29 #include <aknsddata.h> |
|
30 #include <avkon.rsg> |
|
31 #include <data_caging_path_literals.hrh> |
|
32 #include <coreapplicationuisdomainpskeys.h> |
|
33 |
|
34 // USER INCLUDES |
|
35 #include "UiklafInternalCRKeys.h" |
|
36 #include "OodTraces.h" |
|
37 #include "Ood.h" |
|
38 |
|
39 // CONSTANTS |
|
40 |
|
41 // --------------------------------------------------------- |
|
42 // |
|
43 // --------------------------------------------------------- |
|
44 // |
|
45 EXPORT_C CLafShutdownManagerBase* LafShutdown::CreateShutdownManager( |
|
46 MShutdownEventObserver& aObserver) |
|
47 { // static |
|
48 TRACES("LafShutdown::CreateShutdownManager"); |
|
49 CLafShutdownManagerBase* lafShutdownManager(NULL); |
|
50 TInt err(KErrNone); |
|
51 TRAP(err, lafShutdownManager = CLafShutdownManager::NewL(aObserver)); |
|
52 return lafShutdownManager; |
|
53 } |
|
54 |
|
55 // --------------------------------------------------------- |
|
56 // |
|
57 // --------------------------------------------------------- |
|
58 // |
|
59 EXPORT_C MSaveObserver::TSaveType LafShutdown::SaveFromViewSwitch() |
|
60 { // static |
|
61 TRACES("LafShutdown::SaveFromViewSwitch"); |
|
62 return MSaveObserver::ESaveNone; |
|
63 } |
|
64 |
|
65 // --------------------------------------------------------- |
|
66 // |
|
67 // --------------------------------------------------------- |
|
68 // |
|
69 EXPORT_C MSaveObserver::TSaveType LafShutdown::SaveFromAppSwitch() |
|
70 { // static |
|
71 TRACES("LafShutdown::SaveFromAppSwitch"); |
|
72 return MSaveObserver::ESaveNone; |
|
73 } |
|
74 |
|
75 |
|
76 // ====================================================================== |
|
77 // class CLafShutdownManager |
|
78 // ====================================================================== |
|
79 |
|
80 // --------------------------------------------------------- |
|
81 // |
|
82 // --------------------------------------------------------- |
|
83 // |
|
84 CLafShutdownManager* CLafShutdownManager::NewL(MShutdownEventObserver& aObserver) |
|
85 { // static |
|
86 TRACES("LafShutdown::NewL"); |
|
87 CLafShutdownManager* self = new(ELeave) CLafShutdownManager(aObserver); |
|
88 CleanupStack::PushL(self); |
|
89 self->ConstructL(); |
|
90 CleanupStack::Pop(self); |
|
91 return self; |
|
92 } |
|
93 |
|
94 // --------------------------------------------------------- |
|
95 // |
|
96 // --------------------------------------------------------- |
|
97 // |
|
98 CLafShutdownManager::~CLafShutdownManager() |
|
99 { |
|
100 TRACES("LafShutdown::~CLafShutdownManager"); |
|
101 delete iOODWarningWatcher; |
|
102 delete iOODCriticalWatcher; |
|
103 |
|
104 iDiskStatusProperty.Close(); |
|
105 iMMCStatusProperty.Close(); |
|
106 |
|
107 if (iDisplayNotesSubscriber) |
|
108 { |
|
109 iDisplayNotesSubscriber->StopSubscribe(); |
|
110 } |
|
111 iCanDisplayNotesProperty.Close(); |
|
112 delete iDisplayNotesSubscriber; |
|
113 |
|
114 if (iAutolockStatusSubscriber) |
|
115 { |
|
116 iAutolockStatusSubscriber->StopSubscribe(); |
|
117 } |
|
118 iAutolockStatusProperty.Close(); |
|
119 delete iAutolockStatusSubscriber; |
|
120 |
|
121 if (iMMCWatchSubscriber) |
|
122 { |
|
123 iMMCWatchSubscriber->StopSubscribe(); |
|
124 } |
|
125 iEnableMMCWatchProperty.Close(); |
|
126 delete iMMCWatchSubscriber; |
|
127 |
|
128 delete iOOMMCWarningWatcher; |
|
129 delete iOOMMCCriticalWatcher; |
|
130 |
|
131 delete iGlobalQueryActive; |
|
132 |
|
133 iWs.Close(); |
|
134 iFs.Close(); |
|
135 TRACES("LafShutdown::~CLafShutdownManager: End"); |
|
136 } |
|
137 |
|
138 // --------------------------------------------------------- |
|
139 // |
|
140 // --------------------------------------------------------- |
|
141 // |
|
142 CLafShutdownManager::CLafShutdownManager(MShutdownEventObserver& aObserver) |
|
143 : CLafShutdownManagerBase(aObserver) |
|
144 { |
|
145 TRACES("CLafShutdownManager::CLafShutdownManager"); |
|
146 } |
|
147 |
|
148 // --------------------------------------------------------- |
|
149 // |
|
150 // --------------------------------------------------------- |
|
151 // |
|
152 void CLafShutdownManager::ConstructL() |
|
153 { |
|
154 TRACES("CLafShutdownManager::ConstructL"); |
|
155 User::LeaveIfError(iWs.Connect()); |
|
156 |
|
157 User::LeaveIfError(iFs.Connect()); |
|
158 |
|
159 RResourceFile resFile; |
|
160 TFileName filename(KDriveZ); |
|
161 filename.Append(KDC_RESOURCE_FILES_DIR); |
|
162 filename.Append(KOOMWatcherResourceFileName); |
|
163 BaflUtils::NearestLanguageFile(iFs, filename); |
|
164 resFile.OpenL(iFs, filename); |
|
165 CleanupClosePushL(resFile); |
|
166 |
|
167 TResourceReader theReader; |
|
168 |
|
169 HBufC8* thresholds = resFile.AllocReadLC(R_APP_OOD_THRESHOLDS); |
|
170 |
|
171 theReader.SetBuffer(thresholds); |
|
172 iOODWarningThreshold = theReader.ReadInt32(); |
|
173 iOODCriticalThreshold = theReader.ReadInt32(); |
|
174 CleanupStack::PopAndDestroy(thresholds); |
|
175 // Global Query |
|
176 iGlobalQueryActive = CGlobalQueryActive::NewL(resFile,theReader); |
|
177 |
|
178 CleanupStack::PopAndDestroy(); // resFile.Close() |
|
179 |
|
180 TVolumeInfo volInfo; |
|
181 |
|
182 User::LeaveIfError(iDiskStatusProperty.Attach(KPSUidUikon, KUikFFSFreeLevel)); |
|
183 User::LeaveIfError(iMMCStatusProperty.Attach (KPSUidUikon, KUikMmcFFSFreeLevel)); |
|
184 |
|
185 iDiskStatusProperty.Set(GetDiskStatusL(volInfo, EDriveC)); |
|
186 iMMCStatusProperty.Set(DISK_SPACE_OK); |
|
187 |
|
188 User::LeaveIfError(iCanDisplayNotesProperty.Attach (KPSUidUikon, KUikGlobalNotesAllowed)); |
|
189 iDisplayNotesSubscriber = new (ELeave) CSubscriber(TCallBack(DisplayNotesCallBackL, this), |
|
190 iCanDisplayNotesProperty); |
|
191 iDisplayNotesSubscriber->SubscribeL(); |
|
192 |
|
193 |
|
194 User::LeaveIfError(iAutolockStatusProperty.Attach (KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus)); |
|
195 iAutolockStatusSubscriber = new (ELeave) CSubscriber(TCallBack(AutolockStatusCallBackL, this), |
|
196 iAutolockStatusProperty); |
|
197 iAutolockStatusProperty.Get(iAutolockStatus); |
|
198 |
|
199 iAutolockStatusSubscriber->SubscribeL(); |
|
200 |
|
201 // Start OOD watchers. |
|
202 iOODWarningWatcher = CLafShutdownManager::COutOfDiskWatcher::NewL(*this, |
|
203 iOODWarningThreshold, |
|
204 EDriveC, |
|
205 iFs); |
|
206 iOODWarningWatcher->Start(); |
|
207 |
|
208 iOODCriticalWatcher = CLafShutdownManager::COutOfDiskWatcher::NewL(*this, |
|
209 iOODCriticalThreshold, |
|
210 EDriveC, |
|
211 iFs); |
|
212 iOODCriticalWatcher->Start(); |
|
213 |
|
214 User::LeaveIfError(iEnableMMCWatchProperty.Attach (KPSUidUikon, KUikMMCInserted)); |
|
215 iMMCWatchSubscriber = new (ELeave) CSubscriber(TCallBack(MMCStatusChanged, this), |
|
216 iEnableMMCWatchProperty); |
|
217 iMMCWatchSubscriber->SubscribeL(); |
|
218 TRACES("CLafShutdownManager::ConstructL: End"); |
|
219 } |
|
220 |
|
221 // --------------------------------------------------------- |
|
222 // |
|
223 // --------------------------------------------------------- |
|
224 // |
|
225 TInt CLafShutdownManager::MMCStatusChanged(TAny* aPtr) |
|
226 { |
|
227 TRACES("CLafShutdownManager::MMCStatusChanged"); |
|
228 CLafShutdownManager* self = STATIC_CAST(CLafShutdownManager*,aPtr); |
|
229 if (self) |
|
230 { |
|
231 TInt err(KErrNone); |
|
232 TRAP(err, self->HandleMMCCallBackL()); |
|
233 } |
|
234 TRACES("CLafShutdownManager::MMCStatusChanged: End"); |
|
235 return KErrNone; |
|
236 } |
|
237 |
|
238 // --------------------------------------------------------- |
|
239 // |
|
240 // --------------------------------------------------------- |
|
241 // |
|
242 void CLafShutdownManager::HandleMMCCallBackL() |
|
243 { |
|
244 TRACES("CLafShutdownManager::HandleMMCCallBackL"); |
|
245 TInt value = 0; |
|
246 iEnableMMCWatchProperty.Get(value); |
|
247 if (value) |
|
248 { |
|
249 if (!iOOMMCWarningWatcher) |
|
250 { |
|
251 iOOMMCWarningWatcher = COutOfDiskWatcher::NewL(*this,iOODWarningThreshold,EDriveE,iFs); |
|
252 } |
|
253 if (!iOOMMCCriticalWatcher) |
|
254 { |
|
255 iOOMMCCriticalWatcher = COutOfDiskWatcher::NewL(*this, |
|
256 iOODCriticalThreshold, |
|
257 EDriveE, |
|
258 iFs); |
|
259 } |
|
260 |
|
261 iOOMMCWarningWatcher->Start(); |
|
262 iOOMMCCriticalWatcher->Start(); |
|
263 |
|
264 #ifdef _DEBUG |
|
265 RDebug::Print(_L("OOD WATCHER: Started MMC watch")); |
|
266 #endif |
|
267 |
|
268 } |
|
269 else |
|
270 { |
|
271 iMMCStatusProperty.Set( DISK_SPACE_OK ); |
|
272 if (iOOMMCWarningWatcher) |
|
273 { |
|
274 iOOMMCWarningWatcher->Cancel(); |
|
275 } |
|
276 if (iOOMMCCriticalWatcher) |
|
277 { |
|
278 iOOMMCCriticalWatcher->Cancel(); |
|
279 } |
|
280 #ifdef _DEBUG |
|
281 RDebug::Print(_L("OOD WATCHER: Cancelled MMC watch")); |
|
282 #endif |
|
283 } |
|
284 TRACES("CLafShutdownManager::HandleMMCCallBackL: End"); |
|
285 } |
|
286 |
|
287 // --------------------------------------------------------- |
|
288 // |
|
289 // --------------------------------------------------------- |
|
290 // |
|
291 TInt CLafShutdownManager::DisplayNotesCallBackL(TAny* aPtr) |
|
292 { |
|
293 TRACES("CLafShutdownManager::DisplayNotesCallBackL"); |
|
294 CLafShutdownManager* self = STATIC_CAST(CLafShutdownManager*,aPtr); |
|
295 if (self) |
|
296 self->HandleDisplayNotesCallBackL(); |
|
297 TRACES("CLafShutdownManager::DisplayNotesCallBackL: End"); |
|
298 return KErrNone; |
|
299 } |
|
300 |
|
301 // --------------------------------------------------------- |
|
302 // |
|
303 // --------------------------------------------------------- |
|
304 // |
|
305 void CLafShutdownManager::HandleDisplayNotesCallBackL() |
|
306 { |
|
307 TRACES("CLafShutdownManager::HandleDisplayNotesCallBackL"); |
|
308 TInt value(0); |
|
309 iCanDisplayNotesProperty.Get(value); |
|
310 if (value == 1) |
|
311 { |
|
312 TRACES("CLafShutdownManager::HandleAutolockStatusCallBack: Can display notes"); |
|
313 FreeDiskThresholdCrossedL(EDriveC, ETrue); |
|
314 iEnableMMCWatchProperty.Get(value); |
|
315 if (value) |
|
316 { |
|
317 TRACES("CLafShutdownManager::HandleAutolockStatusCallBack: Memory card inserted"); |
|
318 FreeDiskThresholdCrossedL(EDriveE, ETrue); |
|
319 } |
|
320 } |
|
321 TRACES("CLafShutdownManager::HandleDisplayNotesCallBackL: End"); |
|
322 } |
|
323 |
|
324 // --------------------------------------------------------- |
|
325 // |
|
326 // --------------------------------------------------------- |
|
327 // |
|
328 TInt CLafShutdownManager::AutolockStatusCallBackL(TAny* aPtr) |
|
329 { |
|
330 TRACES("CLafShutdownManager::AutolockStatusCallBackL"); |
|
331 CLafShutdownManager* self = STATIC_CAST(CLafShutdownManager*,aPtr); |
|
332 if (self) |
|
333 self->HandleAutolockStatusCallBackL(); |
|
334 TRACES("CLafShutdownManager::DisplayNotesCallBackL: End"); |
|
335 return KErrNone; |
|
336 } |
|
337 |
|
338 // --------------------------------------------------------- |
|
339 // |
|
340 // --------------------------------------------------------- |
|
341 // |
|
342 void CLafShutdownManager::HandleAutolockStatusCallBackL() |
|
343 { |
|
344 TRACES("CLafShutdownManager::HandleAutolockStatusCallBackL"); |
|
345 |
|
346 TInt autolockStatus(0); |
|
347 iAutolockStatusProperty.Get(autolockStatus); |
|
348 |
|
349 if (autolockStatus == EAutolockOff && |
|
350 iAutolockStatus != EAutolockStatusUninitialized && |
|
351 iAutolockStatus != EAutolockOff ) |
|
352 { |
|
353 TRACES("CLafShutdownManager::HandleAutolockStatusCallBack: Autolock off"); |
|
354 TInt value(0); |
|
355 iCanDisplayNotesProperty.Get(value); |
|
356 if (value == 1) |
|
357 { |
|
358 TRACES("CLafShutdownManager::HandleAutolockStatusCallBack: Can display notes"); |
|
359 FreeDiskThresholdCrossedL(EDriveC, ETrue, ETrue); |
|
360 iEnableMMCWatchProperty.Get(value); |
|
361 if (value) |
|
362 { |
|
363 TRACES("CLafShutdownManager::HandleAutolockStatusCallBack: Memory card inserted"); |
|
364 FreeDiskThresholdCrossedL(EDriveE, ETrue, ETrue); |
|
365 } |
|
366 } |
|
367 } |
|
368 iAutolockStatus = autolockStatus; |
|
369 TRACES("CLafShutdownManager::HandleAutolockStatusCallBackL: End"); |
|
370 } |
|
371 |
|
372 // --------------------------------------------------------- |
|
373 // |
|
374 // --------------------------------------------------------- |
|
375 // |
|
376 void CLafShutdownManager::ReportEventL(MSaveObserver::TSaveType aAction,TBool aPowerOff) |
|
377 { |
|
378 TRACES("CLafShutdownManager::ReportEventL"); |
|
379 iObserver.HandleShutdownEventL(aAction,aPowerOff); |
|
380 TRACES("CLafShutdownManager::ReportEventL: End"); |
|
381 } |
|
382 |
|
383 // --------------------------------------------------------- |
|
384 // |
|
385 // --------------------------------------------------------- |
|
386 // |
|
387 void CLafShutdownManager::GetShutdownState(TBool& aPowerOff, TBool& aAllSessionsHavePendingRequest) |
|
388 { |
|
389 TRACES("CLafShutdownManager::GetShutdownState"); |
|
390 iObserver.GetShutdownState(aPowerOff, aAllSessionsHavePendingRequest); |
|
391 TRACES("CLafShutdownManager::GetShutdownState: End"); |
|
392 } |
|
393 // --------------------------------------------------------- |
|
394 // |
|
395 // --------------------------------------------------------- |
|
396 // |
|
397 void CLafShutdownManager::FreeDiskThresholdCrossedL(TDriveNumber aDrive, TBool aIsCallBack, TBool aForcedNote) |
|
398 { |
|
399 TRACES("CLafShutdownManager::FreeDiskThresholdCrossedL"); |
|
400 TVolumeInfo volInfo; |
|
401 TInt oldDiskStatus; |
|
402 TInt oldMmcStatus; |
|
403 |
|
404 iDiskStatusProperty.Get(oldDiskStatus); |
|
405 iMMCStatusProperty.Get(oldMmcStatus); |
|
406 TInt status = GetDiskStatusL(volInfo, aDrive); |
|
407 if (aDrive == EDriveC) |
|
408 { |
|
409 iDiskStatusProperty.Set(status); |
|
410 } |
|
411 else |
|
412 { |
|
413 iMMCStatusProperty.Set(status); |
|
414 } |
|
415 |
|
416 #ifdef _DEBUG |
|
417 RDebug::Print(_L("OOD WATCHER: Notified on drive %c, Free: 0x%X%X"),aDrive+KAlphaStartPoint,I64HIGH(volInfo.iFree),I64LOW(volInfo.iFree)); |
|
418 #endif |
|
419 |
|
420 TInt diskStatus = DISK_SPACE_OK; |
|
421 TInt mmcStatus = DISK_SPACE_OK; |
|
422 |
|
423 iDiskStatusProperty.Get(diskStatus); |
|
424 iMMCStatusProperty.Get (mmcStatus); |
|
425 switch (((aDrive == EDriveC) ? diskStatus : mmcStatus)) |
|
426 { |
|
427 case DISK_SPACE_CRITICAL: |
|
428 { |
|
429 if (aDrive == EDriveC) |
|
430 { |
|
431 if (aIsCallBack || oldDiskStatus != DISK_SPACE_CRITICAL) |
|
432 { |
|
433 ShowGlobalQueryL(CGlobalQueryActive::ECritical, aForcedNote); |
|
434 } |
|
435 } |
|
436 else |
|
437 { |
|
438 if (aIsCallBack || oldMmcStatus != DISK_SPACE_CRITICAL) |
|
439 { |
|
440 ShowGlobalQueryL(CGlobalQueryActive::ECriticalMMC, aForcedNote); |
|
441 } |
|
442 } |
|
443 #ifdef _DEBUG |
|
444 TBuf<KMaxMsgSize> msg; |
|
445 msg.AppendFormat( KCriticalMode, aDrive+KAlphaStartPoint ); |
|
446 RDebug::Print(_L("OOD WATCHER: Entering critical mode on drive %c"),aDrive+KAlphaStartPoint); |
|
447 User::InfoPrint(msg); |
|
448 #endif |
|
449 break; |
|
450 } |
|
451 case DISK_SPACE_WARNING: |
|
452 { |
|
453 // this is bit awkward but necessary: |
|
454 ShowGlobalQueryL( aDrive!=EDriveC ? |
|
455 CGlobalQueryActive::EClearNotesMMC : |
|
456 CGlobalQueryActive::EClearNotesC, aForcedNote ); |
|
457 // Display note only if disk is getting more full. |
|
458 if (oldDiskStatus != DISK_SPACE_CRITICAL||aDrive != EDriveC) |
|
459 { |
|
460 if (aDrive == EDriveC) |
|
461 { |
|
462 if (aIsCallBack || oldDiskStatus != DISK_SPACE_WARNING) |
|
463 { |
|
464 ShowGlobalQueryL(CGlobalQueryActive::EWarning, aForcedNote); |
|
465 } |
|
466 } |
|
467 else if (oldMmcStatus != DISK_SPACE_CRITICAL) |
|
468 { |
|
469 if (aIsCallBack || oldMmcStatus != DISK_SPACE_WARNING) |
|
470 { |
|
471 ShowGlobalQueryL(CGlobalQueryActive::EWarningMMC, aForcedNote); |
|
472 } |
|
473 } |
|
474 } |
|
475 #ifdef _DEBUG |
|
476 TBuf<KMaxMsgSize> msg; |
|
477 msg.AppendFormat( KWarningMode, aDrive+KAlphaStartPoint ); |
|
478 RDebug::Print(_L("OOD WATCHER: Entering warning mode on drive %c"),aDrive+KAlphaStartPoint); |
|
479 User::InfoPrint(msg); |
|
480 #endif |
|
481 break; |
|
482 } |
|
483 case DISK_SPACE_OK: |
|
484 default: |
|
485 { |
|
486 #ifdef _DEBUG |
|
487 TBuf<KMaxMsgSize> msg; |
|
488 msg.AppendFormat( KNormalMode, aDrive+KAlphaStartPoint ); |
|
489 RDebug::Print(_L("OOD WATCHER: Entering normal mode on drive %c"),aDrive+KAlphaStartPoint); |
|
490 User::InfoPrint(msg); |
|
491 #endif |
|
492 |
|
493 if (aDrive == EDriveC) |
|
494 { |
|
495 ShowGlobalQueryL(CGlobalQueryActive::EClearNotesC, aForcedNote); |
|
496 } |
|
497 else |
|
498 { |
|
499 ShowGlobalQueryL(CGlobalQueryActive::EClearNotesMMC, aForcedNote); |
|
500 } |
|
501 break; |
|
502 } |
|
503 |
|
504 } // end of switch |
|
505 TRACES("CLafShutdownManager::FreeDiskThresholdCrossedL: End"); |
|
506 } |
|
507 |
|
508 // --------------------------------------------------------- |
|
509 // Use a global query to display the message but make sure that eiksrv is |
|
510 // there (state must not be initialising (AVKON + UIKON) |
|
511 // --------------------------------------------------------- |
|
512 // |
|
513 void CLafShutdownManager::ShowGlobalQueryL(const CGlobalQueryActive::TMessageType& aMessageType, TBool aForcedNote) |
|
514 { |
|
515 TRACES("CLafShutdownManager::ShowGlobalQueryL"); |
|
516 TInt value = 0; |
|
517 iCanDisplayNotesProperty.Get(value); |
|
518 if (value == 1) |
|
519 { |
|
520 iGlobalQueryActive->DisplayL(aMessageType, aForcedNote); |
|
521 } |
|
522 TRACES("CLafShutdownManager::ShowGlobalQueryL: End"); |
|
523 } |
|
524 |
|
525 // --------------------------------------------------------- |
|
526 // |
|
527 // --------------------------------------------------------- |
|
528 // |
|
529 TInt CLafShutdownManager::GetDiskStatusL(TVolumeInfo& aVolInfo, TDriveNumber aDrive) |
|
530 { |
|
531 TRACES("CLafShutdownManager::GetDiskStatusL"); |
|
532 // MMC not always present: By returning disk space ok, we won't trigger any alarms. |
|
533 TDriveInfo info; |
|
534 if ( aDrive != EDriveC && |
|
535 (iFs.Drive(info,aDrive) != KErrNone || |
|
536 iFs.Volume(aVolInfo,aDrive) != KErrNone) ) |
|
537 { |
|
538 TRACES("CLafShutdownManager::GetDiskStatusL: End(1): return DISK_SPACE_OK"); |
|
539 return DISK_SPACE_OK; |
|
540 } |
|
541 |
|
542 if (aDrive == EDriveC) // For other drives we already have valid data. |
|
543 { |
|
544 User::LeaveIfError(iFs.Volume(aVolInfo,aDrive)); |
|
545 } |
|
546 |
|
547 if (I64HIGH(aVolInfo.iFree) != 0) |
|
548 { // If the high bytes are non zero, by definition we are OK (thresholds are 32bit). |
|
549 TRACES("CLafShutdownManager::GetDiskStatusL: End(2): return DISK_SPACE_OK"); |
|
550 return DISK_SPACE_OK; |
|
551 } |
|
552 TUint freeSpace32 = I64LOW(aVolInfo.iFree); |
|
553 if (freeSpace32 < iOODCriticalThreshold) |
|
554 { |
|
555 TRACES("CLafShutdownManager::GetDiskStatusL: End: return DISK_SPACE_CRITICAL"); |
|
556 return DISK_SPACE_CRITICAL; |
|
557 } |
|
558 else if (freeSpace32 < iOODWarningThreshold) |
|
559 { |
|
560 TRACES("CLafShutdownManager::GetDiskStatusL: End: return DISK_SPACE_WARNING"); |
|
561 return DISK_SPACE_WARNING; |
|
562 } |
|
563 else |
|
564 { |
|
565 TRACES("CLafShutdownManager::GetDiskStatusL: End(3): return DISK_SPACE_OK"); |
|
566 return DISK_SPACE_OK; |
|
567 } |
|
568 } |
|
569 |
|
570 |
|
571 // ====================================================================== |
|
572 // class CLafShutdownManager::COutOfDiskWatcher |
|
573 // - notifies when free disk crosses preset threshold |
|
574 // ====================================================================== |
|
575 |
|
576 // --------------------------------------------------------- |
|
577 // |
|
578 // --------------------------------------------------------- |
|
579 // |
|
580 CLafShutdownManager::COutOfDiskWatcher* CLafShutdownManager::COutOfDiskWatcher::NewL( |
|
581 CLafShutdownManager& aLafShutdown, |
|
582 TInt64 aThreshold, |
|
583 TDriveNumber aDrive, |
|
584 RFs& aFs) |
|
585 { |
|
586 TRACES("CLafShutdownManager::COutOfDiskWatcher::NewL"); |
|
587 COutOfDiskWatcher* self = new (ELeave) COutOfDiskWatcher(aLafShutdown,aThreshold,aDrive,aFs); |
|
588 CleanupStack::PushL(self); |
|
589 self->ConstructL(); |
|
590 CleanupStack::Pop(self); |
|
591 TRACES("CLafShutdownManager::COutOfDiskWatcher::NewL: End"); |
|
592 return self; |
|
593 } |
|
594 |
|
595 // --------------------------------------------------------- |
|
596 // |
|
597 // --------------------------------------------------------- |
|
598 // |
|
599 CLafShutdownManager::COutOfDiskWatcher::~COutOfDiskWatcher() |
|
600 { |
|
601 TRACES("CLafShutdownManager::COutOfDiskWatcher::~COutOfDiskWatcher"); |
|
602 Cancel(); |
|
603 TRACES("CLafShutdownManager::COutOfDiskWatcher::~COutOfDiskWatcher: End"); |
|
604 } |
|
605 |
|
606 // --------------------------------------------------------- |
|
607 // |
|
608 // --------------------------------------------------------- |
|
609 // |
|
610 CLafShutdownManager::COutOfDiskWatcher::COutOfDiskWatcher(CLafShutdownManager& aLafShutdown, |
|
611 TInt64 aThreshold, |
|
612 TDriveNumber aDrive, |
|
613 RFs& aFs) |
|
614 : CActive(CActive::EPriorityStandard), |
|
615 iFs(aFs), |
|
616 iLafShutdown(aLafShutdown), |
|
617 iThreshold(aThreshold), |
|
618 iDrive(aDrive) |
|
619 { |
|
620 TRACES("CLafShutdownManager::COutOfDiskWatcher::COutOfDiskWatcher"); |
|
621 CActiveScheduler::Add(this); |
|
622 TRACES("CLafShutdownManager::COutOfDiskWatcher::COutOfDiskWatcher: End"); |
|
623 } |
|
624 |
|
625 /** |
|
626 * Monitor startup |
|
627 * states vis SD so that as soon as we've completed started up we display |
|
628 * a note if needed |
|
629 */ |
|
630 |
|
631 // --------------------------------------------------------- |
|
632 // |
|
633 // --------------------------------------------------------- |
|
634 // |
|
635 void CLafShutdownManager::COutOfDiskWatcher::ConstructL() |
|
636 { |
|
637 TRACES("CLafShutdownManager::COutOfDiskWatcher::ConstructL"); |
|
638 iLafShutdown.FreeDiskThresholdCrossedL(iDrive); |
|
639 TRACES("CLafShutdownManager::COutOfDiskWatcher::ConstructL: End"); |
|
640 } |
|
641 |
|
642 // --------------------------------------------------------- |
|
643 // |
|
644 // --------------------------------------------------------- |
|
645 // |
|
646 void CLafShutdownManager::COutOfDiskWatcher::Start() |
|
647 { |
|
648 TRACES("CLafShutdownManager::COutOfDiskWatcher::Start"); |
|
649 if (!IsActive()) |
|
650 { |
|
651 if ( iDrive == EDriveE ) |
|
652 { |
|
653 TInt err(KErrNone); |
|
654 TRAP(err, iLafShutdown.FreeDiskThresholdCrossedL(iDrive)); |
|
655 } |
|
656 iFs.NotifyDiskSpace(iThreshold,iDrive,iStatus); |
|
657 SetActive(); |
|
658 } |
|
659 TRACES("CLafShutdownManager::COutOfDiskWatcher::Start: End"); |
|
660 } |
|
661 |
|
662 // --------------------------------------------------------- |
|
663 // |
|
664 // --------------------------------------------------------- |
|
665 // |
|
666 void CLafShutdownManager::COutOfDiskWatcher::DoCancel() |
|
667 { |
|
668 TRACES("CLafShutdownManager::COutOfDiskWatcher::DoCancel"); |
|
669 iFs.NotifyDiskSpaceCancel(iStatus); |
|
670 TRACES("CLafShutdownManager::COutOfDiskWatcher::DoCancel: End"); |
|
671 } |
|
672 |
|
673 // --------------------------------------------------------- |
|
674 // |
|
675 // --------------------------------------------------------- |
|
676 // |
|
677 void CLafShutdownManager::COutOfDiskWatcher::RunL() |
|
678 { |
|
679 TRACES("CLafShutdownManager::COutOfDiskWatcher::RunL"); |
|
680 TInt status = iStatus.Int(); |
|
681 if (status < 0) |
|
682 { |
|
683 User::After(KBreatheTime); // just breathe 5 seconds |
|
684 #ifdef _DEBUG |
|
685 RDebug::Print(_L("#####NotifyDiskSpace returned error %D"),status); |
|
686 #endif |
|
687 } |
|
688 |
|
689 Start(); |
|
690 if (status >= 0) |
|
691 { |
|
692 #ifdef _DEBUG |
|
693 TRAPD(err, iLafShutdown.FreeDiskThresholdCrossedL(iDrive)); |
|
694 RDebug::Print(_L("#####FreeDiskThresholdCrossedL returned error %D"),err); |
|
695 #else |
|
696 TRAP_IGNORE(iLafShutdown.FreeDiskThresholdCrossedL(iDrive)); |
|
697 #endif |
|
698 } |
|
699 TRACES("CLafShutdownManager::COutOfDiskWatcher::RunL: End"); |
|
700 } |
|
701 |
|
702 // ====================================================================== |
|
703 // class CLafShutdownManager::CGlobalQueryActive |
|
704 // ====================================================================== |
|
705 |
|
706 // --------------------------------------------------------- |
|
707 // |
|
708 // --------------------------------------------------------- |
|
709 // |
|
710 CLafShutdownManager::CGlobalQueryActive* CLafShutdownManager::CGlobalQueryActive::NewL |
|
711 (RResourceFile& aResFile, TResourceReader& aResReader) |
|
712 { |
|
713 TRACES("CLafShutdownManager::CGlobalQueryActive::NewL"); |
|
714 CGlobalQueryActive* self = new (ELeave) CGlobalQueryActive; |
|
715 CleanupStack::PushL(self); |
|
716 self->ConstructL(aResFile,aResReader); |
|
717 CleanupStack::Pop(self); |
|
718 TRACES("CLafShutdownManager::CGlobalQueryActive::NewL: End"); |
|
719 return self; |
|
720 } |
|
721 |
|
722 // --------------------------------------------------------- |
|
723 // |
|
724 // --------------------------------------------------------- |
|
725 // |
|
726 CLafShutdownManager::CGlobalQueryActive::~CGlobalQueryActive() |
|
727 { |
|
728 TRACES("CLafShutdownManager::CGlobalQueryActive::~CGlobalQueryActive"); |
|
729 delete iQuery; |
|
730 delete iMessageInfo[ECritical]; |
|
731 delete iMessageInfo[EWarning]; |
|
732 delete iMessageInfo[EWarningMMC]; |
|
733 delete iMessageInfo[ECriticalMMC]; |
|
734 TRACES("CLafShutdownManager::CGlobalQueryActive::~CGlobalQueryActive: End"); |
|
735 } |
|
736 |
|
737 // --------------------------------------------------------- |
|
738 // |
|
739 // --------------------------------------------------------- |
|
740 // |
|
741 CLafShutdownManager::CGlobalQueryActive::CGlobalQueryActive() |
|
742 :iMessageType(ENone) |
|
743 { |
|
744 TRACES("CLafShutdownManager::CGlobalQueryActive::CGlobalQueryActive"); |
|
745 } |
|
746 |
|
747 // --------------------------------------------------------- |
|
748 // |
|
749 // --------------------------------------------------------- |
|
750 // |
|
751 void CLafShutdownManager::CGlobalQueryActive::ConstructL(RResourceFile& aResFile, |
|
752 TResourceReader& aResReader) |
|
753 { |
|
754 TRACES("CLafShutdownManager::CGlobalQueryActive::ConstructL"); |
|
755 HBufC8* message = aResFile.AllocReadLC(R_QTN_MEMLO_MEMORY_FULL); |
|
756 aResReader.SetBuffer(message); |
|
757 |
|
758 iMessageInfo[ECritical] = new (ELeave) CMessageInfo(aResReader.ReadHBufCL()); |
|
759 |
|
760 CleanupStack::PopAndDestroy(message); |
|
761 message = NULL; |
|
762 |
|
763 message = aResFile.AllocReadLC(R_QTN_MEMLO_MEMORY_RUNNING_OUT); |
|
764 aResReader.SetBuffer(message); |
|
765 |
|
766 iMessageInfo[EWarning] = new (ELeave) CMessageInfo(aResReader.ReadHBufCL()); |
|
767 |
|
768 CleanupStack::PopAndDestroy(message); |
|
769 |
|
770 // MMC strings. |
|
771 message = aResFile.AllocReadLC(R_QTN_MEMLO_MMC_MEMORY_RUNNING_OUT); |
|
772 aResReader.SetBuffer(message); |
|
773 |
|
774 iMessageInfo[EWarningMMC] = new (ELeave) CMessageInfo(aResReader.ReadHBufCL()); |
|
775 |
|
776 CleanupStack::PopAndDestroy(message); |
|
777 |
|
778 message = aResFile.AllocReadLC(R_QTN_MEMLO_MMC_MEMORY_FULL); |
|
779 aResReader.SetBuffer(message); |
|
780 |
|
781 iMessageInfo[ECriticalMMC] = new (ELeave) CMessageInfo(aResReader.ReadHBufCL()); |
|
782 |
|
783 CleanupStack::PopAndDestroy(message); |
|
784 TRACES("CLafShutdownManager::CGlobalQueryActive::ConstructL: End"); |
|
785 } |
|
786 |
|
787 // --------------------------------------------------------- |
|
788 // |
|
789 // --------------------------------------------------------- |
|
790 // |
|
791 void CLafShutdownManager::CGlobalQueryActive::DisplayL(TMessageType aType, TBool aForcedNote) |
|
792 { |
|
793 TRACES("CLafShutdownManager::CGlobalQueryActive::DisplayL"); |
|
794 if (aType == EClearNotesC || aType == EClearNotesMMC) |
|
795 { |
|
796 TInt index = (aType == EClearNotesC)?EWarning:ECriticalMMC; |
|
797 for (TInt ii = 0; ii < 2; ii++) |
|
798 { |
|
799 iMessageInfo[index-ii]->iNoteId = KErrNotFound; |
|
800 } |
|
801 return; |
|
802 } |
|
803 |
|
804 if (!iQuery) |
|
805 { |
|
806 iQuery = CAknGlobalNote::NewL(); |
|
807 iQuery->SetSoftkeys(R_AVKON_SOFTKEYS_OK_EMPTY); |
|
808 } |
|
809 |
|
810 if (aType != ECallBack) |
|
811 { |
|
812 iMessageType = aType; |
|
813 } |
|
814 |
|
815 CleanupL(); |
|
816 |
|
817 if (iMessageType != ENone && (iMessageInfo[iMessageType]->iNoteId == KErrNotFound || aForcedNote)) |
|
818 { |
|
819 TInt dialogId = 0; |
|
820 switch(iMessageType) |
|
821 { |
|
822 case EWarning: |
|
823 dialogId = EAknDiskWarnignNote; |
|
824 break; |
|
825 case ECritical: |
|
826 dialogId = EAknDiskFullNote; |
|
827 break; |
|
828 case ECriticalMMC: |
|
829 dialogId = EAknMMCFullNote; |
|
830 break; |
|
831 default: |
|
832 dialogId = EAknMMCWarningNote; |
|
833 break; |
|
834 } |
|
835 |
|
836 CAknSDData* sd = CAknSDData::NewL(KAknSecondaryDisplayCategory, dialogId, KNullDesC8); |
|
837 iQuery->SetSecondaryDisplayData(sd); |
|
838 |
|
839 TInt noteid = iQuery->ShowNoteL(EAknGlobalWarningNote, |
|
840 (iMessageInfo[iMessageType]->iMessage)->Des()); |
|
841 |
|
842 if (noteid != KErrNotFound) // Note was added to queue successfully. |
|
843 { |
|
844 iMessageInfo[iMessageType]->iNoteId = noteid; |
|
845 } |
|
846 } |
|
847 |
|
848 iMessageType = ENone; |
|
849 TRACES("CLafShutdownManager::CGlobalQueryActive::DisplayL: End"); |
|
850 } |
|
851 |
|
852 // --------------------------------------------------------- |
|
853 // |
|
854 // --------------------------------------------------------- |
|
855 // |
|
856 void CLafShutdownManager::CGlobalQueryActive::CleanupL(TBool aCancel) |
|
857 { |
|
858 TRACES("CLafShutdownManager::CGlobalQueryActive::CleanupL"); |
|
859 if (iMessageType != ENone) |
|
860 { |
|
861 TInt cancelNoteId = KErrNotFound; |
|
862 switch (iMessageType) |
|
863 { |
|
864 case ECritical: |
|
865 { |
|
866 cancelNoteId = iMessageInfo[EWarning]->iNoteId; |
|
867 iMessageInfo[EWarning]->iNoteId = KErrNotFound; |
|
868 break; |
|
869 } |
|
870 case ECriticalMMC: |
|
871 { |
|
872 cancelNoteId = iMessageInfo[EWarningMMC]->iNoteId; |
|
873 iMessageInfo[EWarningMMC]->iNoteId = KErrNotFound; |
|
874 break; |
|
875 } |
|
876 default: |
|
877 break; |
|
878 } |
|
879 |
|
880 if (cancelNoteId != KErrNotFound && aCancel) |
|
881 { |
|
882 iQuery->CancelNoteL(cancelNoteId); |
|
883 } |
|
884 } |
|
885 TRACES("CLafShutdownManager::CGlobalQueryActive::CleanupL: End"); |
|
886 } |
|
887 |
|
888 // --------------------------------------------------------- |
|
889 // |
|
890 // --------------------------------------------------------- |
|
891 // |
|
892 CLafShutdownManager::CSubscriber::CSubscriber(TCallBack aCallBack, RProperty& aProperty) |
|
893 : CActive(EPriorityNormal), iCallBack(aCallBack), iProperty(aProperty) |
|
894 { |
|
895 TRACES("CLafShutdownManager::CSubscriber::CSubscriber"); |
|
896 CActiveScheduler::Add(this); |
|
897 TRACES("CLafShutdownManager::CSubscriber::CSubscriber: End"); |
|
898 } |
|
899 |
|
900 // --------------------------------------------------------- |
|
901 // |
|
902 // --------------------------------------------------------- |
|
903 // |
|
904 CLafShutdownManager::CSubscriber::~CSubscriber() |
|
905 { |
|
906 TRACES("CLafShutdownManager::CSubscriber::~CSubscriber"); |
|
907 Cancel(); |
|
908 TRACES("CLafShutdownManager::CSubscriber::~CSubscriber: End"); |
|
909 } |
|
910 |
|
911 // --------------------------------------------------------- |
|
912 // |
|
913 // --------------------------------------------------------- |
|
914 // |
|
915 void CLafShutdownManager::CSubscriber::SubscribeL() |
|
916 { |
|
917 TRACES("CLafShutdownManager::CSubscriber::SubscribeL"); |
|
918 if (!IsActive()) |
|
919 { |
|
920 iProperty.Subscribe(iStatus); |
|
921 SetActive(); |
|
922 } |
|
923 TRACES("CLafShutdownManager::CSubscriber::SubscribeL: End"); |
|
924 } |
|
925 |
|
926 // --------------------------------------------------------- |
|
927 // |
|
928 // --------------------------------------------------------- |
|
929 // |
|
930 void CLafShutdownManager::CSubscriber::StopSubscribe() |
|
931 { |
|
932 TRACES("CLafShutdownManager::CSubscriber::StopSubscribe"); |
|
933 Cancel(); |
|
934 TRACES("CLafShutdownManager::CSubscriber::StopSubscribe: End"); |
|
935 } |
|
936 |
|
937 // --------------------------------------------------------- |
|
938 // |
|
939 // --------------------------------------------------------- |
|
940 // |
|
941 void CLafShutdownManager::CSubscriber::RunL() |
|
942 { |
|
943 TRACES("CLafShutdownManager::CSubscriber::RunL"); |
|
944 if (iStatus.Int() == KErrNone) |
|
945 { |
|
946 iCallBack.CallBack(); |
|
947 SubscribeL(); |
|
948 } |
|
949 TRACES("CLafShutdownManager::CSubscriber::RunL: End"); |
|
950 } |
|
951 |
|
952 // --------------------------------------------------------- |
|
953 // |
|
954 // --------------------------------------------------------- |
|
955 // |
|
956 void CLafShutdownManager::CSubscriber::DoCancel() |
|
957 { |
|
958 TRACES("CLafShutdownManager::CSubscriber::DoCancel"); |
|
959 iProperty.Cancel(); |
|
960 TRACES("CLafShutdownManager::CSubscriber::DoCancel: End"); |
|
961 } |
|
962 |
|
963 // End of file. |