CTC++ Coverage Report - Execution Profile    #1/6

Directory Summary | Files Summary | Functions Summary | Execution Profile
To files: First | Previous | Next | Last | Index | No Index


File: N:\myprogram\forrrelease1\oodmonitor\src\lafshut.cpp
Instrumentation mode: function
TER: 100 % ( 37/ 37)

Start/ End/    
True False - Line Source

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

Directory Summary | Files Summary | Functions Summary | Execution Profile
To files: First | Previous | Next | Last | Top | Index | No Index