commonservices/commonengine/diskspacereservationplugin/src/diskspacereservationplugin.cpp
changeset 0 4e1aa6a622a0
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 /*
       
     2 * Copyright (c) 2006 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 CDiskSpaceReservationPlugIn class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "diskspacereservationplugin.h"
       
    20 
       
    21 // Parameters
       
    22 _LIT( KReserve, "reserve" );
       
    23 _LIT( KFree, "free" );
       
    24 
       
    25 // Free disk space requested for boot
       
    26 const TInt KRequestedDiskSpaceForBoot = 0x23000; // 140 kB
       
    27 
       
    28 // Debug macros
       
    29 #ifdef _DEBUG
       
    30     #include <e32debug.h>
       
    31     #define TRACE_0( _s ) RDebug::Print( _L( _s ) );
       
    32     #define TRACE_1( _s, _t ) RDebug::Print( _L( _s ), _t );
       
    33     #define TRACE_IF_ERROR( _s, _e ) if ( _e != KErrNone ) RDebug::Print( _L( _s ), _e );
       
    34 #else // _DEBUG
       
    35     #define TRACE_0( _s );
       
    36     #define TRACE_1( _s, _t );
       
    37     #define TRACE_IF_ERROR( _s, _e )
       
    38 #endif // _DEBUG
       
    39 
       
    40 // ======== MEMBER FUNCTIONS ========
       
    41 
       
    42 // ---------------------------------------------------------------------------
       
    43 // Constructor
       
    44 //
       
    45 // ---------------------------------------------------------------------------
       
    46 //
       
    47 CDiskSpaceReservationPlugIn* CDiskSpaceReservationPlugIn::NewL(
       
    48     TAny* aConstructionParameters )
       
    49     {
       
    50     CDiskSpaceReservationPlugIn* self =
       
    51         new( ELeave ) CDiskSpaceReservationPlugIn( aConstructionParameters );
       
    52     CleanupStack::PushL( self );
       
    53     self->ConstructL();
       
    54     CleanupStack::Pop( self );
       
    55     return self;
       
    56     }
       
    57 
       
    58 
       
    59 // ---------------------------------------------------------------------------
       
    60 // Destructor
       
    61 //
       
    62 // ---------------------------------------------------------------------------
       
    63 //
       
    64 CDiskSpaceReservationPlugIn::~CDiskSpaceReservationPlugIn()
       
    65     {
       
    66     TRACE_0( "CDiskSpaceReservationPlugIn::~CDiskSpaceReservationPlugIn" );
       
    67 
       
    68     iSharedData.Close();
       
    69 
       
    70     TRACE_0( "CDiskSpaceReservationPlugIn::~CDiskSpaceReservationPlugIn finished" );
       
    71     }
       
    72 
       
    73 
       
    74 // ---------------------------------------------------------------------------
       
    75 // CDiskSpaceReservationPlugIn::ExecuteL
       
    76 //
       
    77 // ---------------------------------------------------------------------------
       
    78 //
       
    79 void CDiskSpaceReservationPlugIn::ExecuteL(
       
    80     TRequestStatus& aStatus,
       
    81     const TDesC& aParams )
       
    82     {
       
    83     TRACE_1( "CDiskSpaceReservationPlugIn::ExecuteL( %S )", &aParams );
       
    84 
       
    85     aStatus = KRequestPending;
       
    86     TRequestStatus* status = &aStatus;
       
    87 
       
    88     if ( aParams == KReserve )
       
    89         {
       
    90         iSharedData.RequestFreeDiskSpace( KRequestedDiskSpaceForBoot );
       
    91         }
       
    92     else if ( aParams == KFree )
       
    93         {
       
    94         iSharedData.CancelFreeDiskSpaceRequest();
       
    95         }
       
    96 
       
    97     User::RequestComplete( status, KErrNone );
       
    98 
       
    99     TRACE_0( "CDiskSpaceReservationPlugIn::ExecuteL finished" );
       
   100     }
       
   101 
       
   102 
       
   103 // ---------------------------------------------------------------------------
       
   104 // CDiskSpaceReservationPlugIn::Cancel
       
   105 //
       
   106 // ---------------------------------------------------------------------------
       
   107 //
       
   108 void CDiskSpaceReservationPlugIn::Cancel()
       
   109     {
       
   110     // Nothing to do.
       
   111     }
       
   112 
       
   113 // ---------------------------------------------------------------------------
       
   114 // First phase constructor
       
   115 //
       
   116 // ---------------------------------------------------------------------------
       
   117 //
       
   118 CDiskSpaceReservationPlugIn::CDiskSpaceReservationPlugIn(
       
   119     TAny* aConstructionParameters )
       
   120   : CSystemStartupExtension( aConstructionParameters )
       
   121     {
       
   122     }
       
   123 
       
   124 
       
   125 // ---------------------------------------------------------------------------
       
   126 // Second phase constructor
       
   127 //
       
   128 // ---------------------------------------------------------------------------
       
   129 //
       
   130 void CDiskSpaceReservationPlugIn::ConstructL()
       
   131     {
       
   132     TInt errorCode = iSharedData.Connect();
       
   133     TRACE_IF_ERROR( "Failed to connect to SharedData", errorCode );
       
   134     User::LeaveIfError( errorCode );
       
   135     }