messagingapp/msgnotifications/msgerrorwatcher/src/msgerrorsmsdiskspaceobserver.cpp
author hgs
Tue, 31 Aug 2010 18:53:38 +0530
changeset 56 f42d9a78f435
permissions -rw-r--r--
201033_02
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
56
f42d9a78f435 201033_02
hgs
parents:
diff changeset
     1
/*
f42d9a78f435 201033_02
hgs
parents:
diff changeset
     2
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
f42d9a78f435 201033_02
hgs
parents:
diff changeset
     3
* All rights reserved.
f42d9a78f435 201033_02
hgs
parents:
diff changeset
     4
* This component and the accompanying materials are made available
f42d9a78f435 201033_02
hgs
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
f42d9a78f435 201033_02
hgs
parents:
diff changeset
     6
* which accompanies this distribution, and is available
f42d9a78f435 201033_02
hgs
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
f42d9a78f435 201033_02
hgs
parents:
diff changeset
     8
*
f42d9a78f435 201033_02
hgs
parents:
diff changeset
     9
* Initial Contributors:
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    11
*
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    12
* Contributors:
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    13
*
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    14
* Description:  
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    15
*       CMsgErrorSmsDiskSpaceObserver implementation file
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    16
*
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    17
*/
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    18
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    19
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    20
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    21
// INCLUDE FILES
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    22
#include <e32base.h>
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    23
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    24
#include <e32property.h>
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    25
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    26
#include <smsuaddr.h>
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    27
#include  "msgerrorwatcher_p.h"
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    28
#include "msgerrorsmsdiskspaceobserver.h"
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    29
#include "debugtraces.h"
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    30
// CONSTANTS
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    31
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    32
// ================= MEMBER FUNCTIONS =======================
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    33
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    34
// ---------------------------------------------------------
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    35
// CMsgErrorSmsDiskSpaceObserver::CMsgErrorSmsDiskSpaceObserver
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    36
//
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    37
// C++ constructor can NOT contain any code, that
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    38
// might leave.
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    39
// ---------------------------------------------------------
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    40
//
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    41
CMsgErrorSmsDiskSpaceObserver::CMsgErrorSmsDiskSpaceObserver( CMsgErrorWatcherPrivate&  aWatcher )
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    42
    : CActive( CActive::EPriorityStandard ),
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    43
    iWatcher( aWatcher )
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    44
    {
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    45
    QDEBUG_WRITE("CMsgErrorSmsDiskSpaceObserver:CMsgErrorSmsDiskSpaceObserver : Enter");
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    46
    CActiveScheduler::Add( this );
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    47
    QDEBUG_WRITE("CMsgErrorSmsDiskSpaceObserver:CMsgErrorSmsDiskSpaceObserver : Exit");
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    48
    }
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    49
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    50
// ---------------------------------------------------------
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    51
// CMsgErrorSmsDiskSpaceObserver::ConstructL()
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    52
//
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    53
// Symbian OS default constructor can leave.
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    54
// ---------------------------------------------------------
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    55
//
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    56
void CMsgErrorSmsDiskSpaceObserver::ConstructL()
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    57
    {
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    58
    QDEBUG_WRITE("CMsgErrorSmsDiskSpaceObserver:ConstructL : Enter");
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    59
    
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    60
    TInt success = iSmsDiskSpaceProperty.Attach( KUidPSSMSStackCategory, KUidPSSMSStackDiskSpaceMonitorKey );
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    61
    QDEBUG_WRITE_FORMAT("iSmsDiskSpaceProperty.Attach: " ,success );
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    62
    User::LeaveIfError(success);            
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    63
    iStatus = KRequestPending;
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    64
    iSmsDiskSpaceProperty.Subscribe( iStatus );
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    65
    SetActive();
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    66
    QDEBUG_WRITE("CMsgErrorSmsDiskSpaceObserver:ConstructL : Exit");
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    67
    }
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    68
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    69
// ---------------------------------------------------------
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    70
// CMsgErrorSmsDiskSpaceObserver::NewL
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    71
//
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    72
// Two-phased constructor.
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    73
// ---------------------------------------------------------
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    74
//
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    75
CMsgErrorSmsDiskSpaceObserver* CMsgErrorSmsDiskSpaceObserver::NewL( CMsgErrorWatcherPrivate&  aWatcher)
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    76
    {
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    77
    QDEBUG_WRITE("CMsgErrorSmsDiskSpaceObserver:NewL : Enter");
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    78
    CMsgErrorSmsDiskSpaceObserver* self = new ( ELeave )
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    79
        CMsgErrorSmsDiskSpaceObserver( aWatcher);
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    80
    
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    81
    CleanupStack::PushL( self );
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    82
    self->ConstructL();
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    83
    CleanupStack::Pop( self );
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    84
    QDEBUG_WRITE("CMsgErrorSmsDiskSpaceObserver:NewL : Exit");
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    85
    return self;
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    86
    }
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    87
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    88
// ---------------------------------------------------------
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    89
// CMsgErrorSmsDiskSpaceObserver::~CMsgErrorSmsDiskSpaceObserver
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    90
//
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    91
// Destructor
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    92
// ---------------------------------------------------------
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    93
//
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    94
CMsgErrorSmsDiskSpaceObserver::~CMsgErrorSmsDiskSpaceObserver()
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    95
    {
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    96
    QDEBUG_WRITE("CMsgErrorSmsDiskSpaceObserver:~CMsgErrorSmsDiskSpaceObserver : Enter");
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    97
    Cancel();
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    98
    iSmsDiskSpaceProperty.Close();
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    99
    QDEBUG_WRITE("CMsgErrorSmsDiskSpaceObserver:~CMsgErrorSmsDiskSpaceObserver : Exit");
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   100
    }
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   101
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   102
// ---------------------------------------------------------
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   103
// CMsgErrorSmsDiskSpaceObserver::DoCancel
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   104
//
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   105
// From active object framework
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   106
// ---------------------------------------------------------
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   107
//
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   108
void CMsgErrorSmsDiskSpaceObserver::DoCancel()
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   109
    {
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   110
    QDEBUG_WRITE("CMsgErrorSmsDiskSpaceObserver:DoCancel : Enter");
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   111
    iSmsDiskSpaceProperty.Cancel();
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   112
    QDEBUG_WRITE("CMsgErrorSmsDiskSpaceObserver:DoCancel : Exit");
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   113
    }
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   114
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   115
// ---------------------------------------------------------
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   116
// CMsgErrorSmsDiskSpaceObserver::RunL
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   117
//
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   118
// From active object framework
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   119
// ---------------------------------------------------------
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   120
//
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   121
void CMsgErrorSmsDiskSpaceObserver::RunL()
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   122
    {
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   123
    QDEBUG_WRITE("CMsgErrorSmsDiskSpaceObserver:RunL : Enter");    
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   124
    TInt messagesComingInLowDiskSpace(ESmsDiskSpaceUnknown);
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   125
    TInt success = iSmsDiskSpaceProperty.Get( messagesComingInLowDiskSpace );
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   126
    
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   127
   QDEBUG_WRITE_FORMAT("iSmsDiskSpaceProperty.Get returns: " ,success );
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   128
   QDEBUG_WRITE_FORMAT("iSmsDiskSpaceProperty.Get: " ,messagesComingInLowDiskSpace );
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   129
        
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   130
    
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   131
    if ( messagesComingInLowDiskSpace == ESmsDiskSpaceFull )
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   132
        {
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   133
        QDEBUG_WRITE( "CMsgErrorSmsDiskSpaceObserver::RunL: ESmsDiskSpaceFull" );
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   134
        TRAP_IGNORE( iWatcher.HandleDiskSpaceEvent2L() );
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   135
        }
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   136
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   137
    iStatus = KRequestPending;
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   138
    iSmsDiskSpaceProperty.Subscribe( iStatus );
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   139
    SetActive();
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   140
    QDEBUG_WRITE("CMsgErrorSmsDiskSpaceObserver:RunL : Exit");
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   141
    }
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   142
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   143
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   144
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   145
// ================= OTHER EXPORTED FUNCTIONS ==============
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   146
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   147
//  End of File