messagingappbase/msgerrorwatcher/src/MsgErrorExtSmsDiskSpaceObserver.cpp
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     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: 
       
    15 *       CMsgErrorExtSmsDiskSpaceObserver implementation file
       
    16 *
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include <e32base.h>
       
    23 
       
    24 #include <e32property.h>
       
    25 
       
    26 #include <smsuaddr.h>
       
    27 #include "MsgErrorWatcher.h"
       
    28 #include "MsgErrorExtSmsDiskSpaceObserver.h"
       
    29 #include "MsgErrorWatcherLogging.h"
       
    30 // CONSTANTS
       
    31 
       
    32 // ================= MEMBER FUNCTIONS =======================
       
    33 
       
    34 // ---------------------------------------------------------
       
    35 // CMsgErrorExtSmsDiskSpaceObserver::CMsgErrorExtSmsDiskSpaceObserver
       
    36 //
       
    37 // C++ constructor can NOT contain any code, that
       
    38 // might leave.
       
    39 // ---------------------------------------------------------
       
    40 //
       
    41 CMsgErrorExtSmsDiskSpaceObserver::CMsgErrorExtSmsDiskSpaceObserver( CMsgErrorWatcher* aWatcher )
       
    42     : CActive( CActive::EPriorityStandard ),
       
    43     iWatcher( aWatcher )
       
    44     {
       
    45     CActiveScheduler::Add( this );
       
    46     }
       
    47 
       
    48 // ---------------------------------------------------------
       
    49 // CMsgErrorExtSmsDiskSpaceObserver::ConstructL()
       
    50 //
       
    51 // Symbian OS default constructor can leave.
       
    52 // ---------------------------------------------------------
       
    53 //
       
    54 void CMsgErrorExtSmsDiskSpaceObserver::ConstructL()
       
    55     {
       
    56     MEWLOGGER_WRITE( "CMsgErrorExtSmsDiskSpaceObserver::ConstructL: BEFORE ATTACH" );
       
    57             
       
    58     TInt success = iSmsDiskSpaceProperty.Attach( KUidSystemCategory, KUidPSDiskSpaceMonitorKeyType );
       
    59     MEWLOGGER_WRITEF( _L("iSmsDiskSpaceProperty.Attach: %d") ,success );
       
    60     User::LeaveIfError(success);    
       
    61         
       
    62     
       
    63     
       
    64     MEWLOGGER_WRITE( "CMsgErrorExtSmsDiskSpaceObserver::ConstructL: AFTER ATTACH" );
       
    65     
       
    66     iStatus = KRequestPending;
       
    67     iSmsDiskSpaceProperty.Subscribe( iStatus );
       
    68     SetActive();
       
    69     }
       
    70 
       
    71 // ---------------------------------------------------------
       
    72 // CMsgErrorExtSmsDiskSpaceObserver::NewL
       
    73 //
       
    74 // Two-phased constructor.
       
    75 // ---------------------------------------------------------
       
    76 //
       
    77 CMsgErrorExtSmsDiskSpaceObserver* CMsgErrorExtSmsDiskSpaceObserver::NewL( CMsgErrorWatcher* aWatcher)
       
    78     {
       
    79     CMsgErrorExtSmsDiskSpaceObserver* self = new ( ELeave )
       
    80         CMsgErrorExtSmsDiskSpaceObserver( aWatcher);
       
    81     
       
    82     CleanupStack::PushL( self );
       
    83     self->ConstructL();
       
    84     CleanupStack::Pop( self );
       
    85 
       
    86     return self;
       
    87     }
       
    88 
       
    89 // ---------------------------------------------------------
       
    90 // CMsgErrorExtSmsDiskSpaceObserver::~CMsgErrorExtSmsDiskSpaceObserver
       
    91 //
       
    92 // Destructor
       
    93 // ---------------------------------------------------------
       
    94 //
       
    95 CMsgErrorExtSmsDiskSpaceObserver::~CMsgErrorExtSmsDiskSpaceObserver()
       
    96     {
       
    97     Cancel();
       
    98     iSmsDiskSpaceProperty.Close();
       
    99     }
       
   100 
       
   101 // ---------------------------------------------------------
       
   102 // CMsgErrorExtSmsDiskSpaceObserver::DoCancel
       
   103 //
       
   104 // From active object framework
       
   105 // ---------------------------------------------------------
       
   106 //
       
   107 void CMsgErrorExtSmsDiskSpaceObserver::DoCancel()
       
   108     {
       
   109     iSmsDiskSpaceProperty.Cancel();
       
   110     }
       
   111 
       
   112 // ---------------------------------------------------------
       
   113 // CMsgErrorExtSmsDiskSpaceObserver::RunL
       
   114 //
       
   115 // From active object framework
       
   116 // ---------------------------------------------------------
       
   117 //
       
   118 void CMsgErrorExtSmsDiskSpaceObserver::RunL()
       
   119     {
       
   120     MEWLOGGER_WRITE( "CMsgErrorExtSmsDiskSpaceObserver::RunL" );
       
   121     TInt messagesComingInLowDiskSpace(ESmsDiskSpaceUnknown);
       
   122     TInt success = iSmsDiskSpaceProperty.Get( messagesComingInLowDiskSpace );
       
   123     
       
   124     MEWLOGGER_WRITEF( _L("iSmsDiskSpaceProperty.Get returns: %d") ,success );
       
   125     MEWLOGGER_WRITEF( _L("iSmsDiskSpaceProperty.Get( %d ) ") ,messagesComingInLowDiskSpace );
       
   126         
       
   127     
       
   128     if ( messagesComingInLowDiskSpace == ESmsDiskSpaceFull )
       
   129         {
       
   130         MEWLOGGER_WRITE( "CMsgErrorExtSmsDiskSpaceObserver::RunL: ESmsDiskSpaceFull" );
       
   131         TRAP_IGNORE( iWatcher->HandleDiskSpaceEvent2L() );
       
   132         }
       
   133 
       
   134     iStatus = KRequestPending;
       
   135     iSmsDiskSpaceProperty.Subscribe( iStatus );
       
   136     SetActive();
       
   137     }
       
   138 
       
   139 
       
   140 
       
   141 // ================= OTHER EXPORTED FUNCTIONS ==============
       
   142 
       
   143 //  End of File