CTC++ Coverage Report - Execution Profile    #4/10

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


File: N:\myprogram\forrrelease1\oodmonitor\oodmonitor2\src\outofdisknotifyobserver.cpp
Instrumentation mode: function
TER: 100 % ( 10/ 10)

Start/ End/    
True False - Line Source

  1 /*
  2 * Copyright (c) 2007 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:  Implementation of COutOfDiskNotifyObserver class.
  15 *
  16 */
  17 
  18 
  19 // SYSTEM INCLUDES
  20 #include <driveinfo.h>
  21 
  22 // USER INCLUDES
  23 #include "outofdisknotifyobserver.h"
  24 #include "UiklafInternalCRKeys.h"
  25 #include "OodTraces.h"
  26 
  27 // CONSTANTS
  28 
  29 // ============================ MEMBER FUNCTIONS ===============================
  30 
  31 // ---------------------------------------------------------
  32 //
  33 // ---------------------------------------------------------
  34 //
Top
  35 COutOfDiskNotifyObserver* COutOfDiskNotifyObserver::NewL(COutOfDiskMonitor* aOutOfDiskMonitor, 
  36                                                          RFs& aFs)
  37     { // static
  38     TRACES("COutOfDiskNotifyObserver::NewL");
  39     COutOfDiskNotifyObserver* self = new(ELeave) COutOfDiskNotifyObserver(aOutOfDiskMonitor, aFs);
  40     CleanupStack::PushL(self);
  41     self->ConstructL();
  42     CleanupStack::Pop(self);
  43     return self;
  44     }
  45 
  46 // ---------------------------------------------------------
  47 //
  48 // ---------------------------------------------------------
  49 //
Top
  50 COutOfDiskNotifyObserver::~COutOfDiskNotifyObserver()
  51     {
  52     TRACES("COutOfDiskNotifyObserver::~COutOfDiskNotifyObserver");
  53     delete iWait;
  54     delete iDiskNotifyHandler;
  55     TRACES("COutOfDiskNotifyObserver::~COutOfDiskNotifyObserver: End");
  56     }
  57 
  58 // ---------------------------------------------------------
  59 //
  60 // ---------------------------------------------------------
  61 //
Top
  62 COutOfDiskNotifyObserver::COutOfDiskNotifyObserver(COutOfDiskMonitor* aOutOfDiskMonitor, 
  63                                                    RFs& aFs) :
  64     iFs(aFs),
  65     iOutOfDiskMonitor( aOutOfDiskMonitor ),
  66     iCritical2OK(EFalse)
  67     {
  68     TRACES("COutOfDiskNotifyObserver::COutOfDiskNotifyObserver");
  69     }
  70 
  71 // ---------------------------------------------------------
  72 //
  73 // ---------------------------------------------------------
  74 //
Top
  75 void COutOfDiskNotifyObserver::ConstructL()
  76     {
  77     TRACES("COutOfDiskNotifyObserver::ConstructL");
  78 
  79     TRACES("COutOfDiskNotifyObserver::ConstructL: Create ActiveScheduler");
  80     iWait = new ( ELeave )CActiveSchedulerWait;
  81     TRACES("COutOfDiskNotifyObserver::ConstructL: Create iDiskNotifyHandler");
  82     iDiskNotifyHandler = CDiskNotifyHandler::NewL( *this, iFs );
  83 
  84     // Start listening disk events first
  85     TInt status = iDiskNotifyHandler->NotifyDisk();
  86     TRACES1("COutOfDiskNotifyObserver::ConstructL: NotifyDisk status %d",status);
  87     
  88     TRACES("COutOfDiskNotifyObserver::ConstructL: Get list of already mounted drives");
  89     TDriveList driveListInt;
  90     TInt driveCountInt(0);
  91     User::LeaveIfError(DriveInfo::GetUserVisibleDrives(
  92            iFs, driveListInt, driveCountInt, KDriveAttInternal | KDriveAttRemovable )); // Get already inserted internal and removable drives
  93     for( TInt i = EDriveA; i <= EDriveZ; i++ )
  94         {
  95         if (driveListInt[i])
  96             {
  97             TRACES("COutOfDiskNotifyObserver::ConstructL: Add disk +++++++++++++++++++++++++++++");
  98             DiskAddedL(i);
  99             TRACES("COutOfDiskNotifyObserver::ConstructL: Disk added ---------------------------");
  100             }            
  101         }
  102 
  103 #ifndef FCC_UNIT_TEST
  104     iWait->Start();
  105 #endif
  106     
  107     TRACES("COutOfDiskNotifyObserver::ConstructL: End");
  108     }
  109 
  110 // ---------------------------------------------------------
  111 //
  112 // ---------------------------------------------------------
  113 //
Top
13 13   114 void COutOfDiskNotifyObserver::NotifyDiskSpace(TInt64 aWarningThreshold, TInt64 aCriticalThreshold,
  115                                                TInt aDrive)
  116     {
  117     TRACES("COutOfDiskNotifyObserver::NotifyDiskSpace");
  118     TRACES1("COutOfDiskNotifyObserver::NotifyDiskSpace: Drive %c",aDrive+'A');
  119 
  120     TRACES1("COutOfDiskNotifyObserver::NotifyDiskSpace: WarningThreshold            %ld",aWarningThreshold);
  121     TRACES1("COutOfDiskNotifyObserver::NotifyDiskSpace: CriticalThreshold           %ld",aCriticalThreshold);
  122     
  123     iDiskNotifyHandler->NotifyDiskSpace(aWarningThreshold, aDrive);
  124     iDiskNotifyHandler->NotifyDiskSpace(aCriticalThreshold, aDrive);
  125     TRACES("COutOfDiskNotifyObserver::NotifyDiskSpace: End");
  126     }
  127 
  128 // ---------------------------------------------------------
  129 //
  130 // ---------------------------------------------------------
  131 //
Top
17 12   132 void COutOfDiskNotifyObserver::DiskAddedL(TInt aDrive)
  133     {
  134     TRACES1("COutOfDiskNotifyObserver::DiskAddedL: Drive %c",aDrive+'A');
  135 
  136     TUint driveStatus(0);
  137     if ( DriveInfo::GetDriveStatus( iFs, aDrive, driveStatus ) == KErrNone )
  138         {
  139         if (driveStatus & DriveInfo::EDriveRemote)
  140             {
  141             TRACES("COutOfDiskNotifyObserver::DiskAddedL: Do not monitor remote drives");
  142             return;
  143             }
  144         }
  145 
  146    TInt64 warningThreshold = iOutOfDiskMonitor->GetThreshold(DISK_SPACE_WARNING, aDrive);
  147    TInt64 criticalThreshold = iOutOfDiskMonitor->GetThreshold(DISK_SPACE_CRITICAL, aDrive);
  148    TRACES1("COutOfDiskNotifyObserver::DiskAddedL: Warning Threshold: %ld",warningThreshold);
  149    TRACES1("COutOfDiskNotifyObserver::DiskAddedL: Critical Threshold: %ld",criticalThreshold);
  150    
  151    if (warningThreshold <= 0 || criticalThreshold <= 0)
  152       {
  153         TRACES("COutOfDiskNotifyObserver::DiskAddedL: Cannot get threshold of the drive");
  154        return;      
  155       }
  156    
  157     TInt status = iOutOfDiskMonitor->GetDriveStatus(aDrive);
  158     iOutOfDiskMonitor->SaveDriveStatus(aDrive, status, ETrue);
  159     iOutOfDiskMonitor->ShowGlobalQueryIfNeededL();
  160     NotifyDiskSpace(warningThreshold, 
  161                     criticalThreshold, 
  162                     aDrive);
  163     TRACES("COutOfDiskNotifyObserver::DiskAddedL: End");
  164     }
  165 
  166 // ---------------------------------------------------------
  167 //
  168 // ---------------------------------------------------------
  169 //
Top
  170 void COutOfDiskNotifyObserver::HandleNotifyDisk(
  171         TInt /*aError*/, const TDiskEvent& aEvent )
  172     {
  173     TRACES("COutOfDiskNotifyObserver::HandleNotifyDisk +++++++++++++++++++++++++++++");
  174     TRACES1("COutOfDiskNotifyObserver::HandleNotifyDisk: Drive %c:",aEvent.iDrive+'A');
  175 
  176     switch(aEvent.iType)
  177         {
  178         case EDiskAdded:
  179             TRACES("COutOfDiskNotifyObserver::HandleNotifyDisk: EDiskAdded");
  180             TRAP_IGNORE( DiskAddedL(aEvent.iDrive) );
  181             break;
  182         case EDiskError:
  183         case EDiskRemoved:
  184             TRACES("COutOfDiskNotifyObserver::HandleNotifyDisk: EDiskRemoved");
  185             iDiskNotifyHandler->CancelNotifyDiskSpace(aEvent.iDrive);
  186             break;
  187         case EDiskStatusChanged:
  188             TRACES("COutOfDiskNotifyObserver::HandleNotifyDisk: EDiskStatusChanged");
  189             TVolumeInfo volInfo;
  190             TInt ret( iFs.Volume( volInfo, aEvent.iDrive ) );
  191             TRACES1("COutOfDiskMonitor::HandleNotifyDisk: Free space: %d",volInfo.iFree);
  192             if (volInfo.iFree >= 0)
  193                 {
  194                 TRACES("COutOfDiskNotifyObserver::HandleNotifyDisk: Added");
  195                 TRAP_IGNORE( DiskAddedL(aEvent.iDrive) );
  196                 }
  197             else
  198                 {
  199                 TRACES("COutOfDiskNotifyObserver::HandleNotifyDisk: Removed");
  200                 iDiskNotifyHandler->CancelNotifyDiskSpace(aEvent.iDrive);
  201                 iOutOfDiskMonitor->SaveDriveStatus(aEvent.iDrive, DISK_SPACE_OK, ETrue);
  202                 TRAP_IGNORE( iOutOfDiskMonitor->ShowGlobalQueryIfNeededL() );
  203                 }
  204             break;
  205         }
  206     TRACES("COutOfDiskNotifyObserver::HandleNotifyDisk: End ------------------------------ ");
  207     }
  208 
  209 // ---------------------------------------------------------
  210 //
  211 // ---------------------------------------------------------
  212 //
Top
  213 void COutOfDiskNotifyObserver::HandleNotifyDismount(
  214         TInt /*aError*/, const TDismountEvent& aEvent )
  215     {
  216     TRACES("COutOfDiskNotifyObserver::HandleNotifyDismount +++++++++++++++++++++++++++++");
  217     iDiskNotifyHandler->CancelNotifyDiskSpace(aEvent.iDrive);
  218     TRACES("COutOfDiskNotifyObserver::HandleNotifyDismount: End ------------------------------ ");
  219     }
  220 
  221 // ---------------------------------------------------------
  222 //
  223 // ---------------------------------------------------------
  224 //
Top
  225 void COutOfDiskNotifyObserver::HandleNotifyDiskSpace(
  226         TInt /*aError*/, const TDiskSpaceEvent& aEvent )
  227     {
  228     TRACES("COutOfDiskNotifyObserver::HandleNotifyDiskSpace +++++++++++++++++++++++++++++");
  229     TRACES1("COutOfDiskNotifyObserver::HandleNotifyDiskSpace: Drive %c:",aEvent.iDrive+'A');
  230     TRACES1("COutOfDiskNotifyObserver::HandleNotifyDiskSpace: Threshold: %ld",aEvent.iThreshold);
  231 
  232     iOutOfDiskMonitor->SaveDriveStatus(aEvent.iDrive, 
  233             iOutOfDiskMonitor->GetDriveStatus(aEvent.iDrive));
  234     TRAP_IGNORE( iOutOfDiskMonitor->ShowGlobalQueryIfNeededL() );
  235     
  236     TRACES("COutOfDiskNotifyObserver::HandleNotifyDismount: End ------------------------------ ");
  237     }
  238 
  239 // ---------------------------------------------------------
  240 //
  241 // ---------------------------------------------------------
  242 //
Top
  243 void COutOfDiskNotifyObserver::HandleNotifyEntry(
  244         TInt /*aError*/, const TEntryEvent& /*aEvent*/ )
  245     {
  246     TRACES("COutOfDiskNotifyObserver::HandleNotifyEntry");
  247     }
  248 // End of file.
***TER 100% (10/10) of SOURCE FILE outofdisknotifyobserver.cpp

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