htiui/HtiServicePlugins/HtiFtpBackupFake/src/HtiFtpBackupFake.cpp
changeset 0 d6fe6244b863
equal deleted inserted replaced
-1:000000000000 0:d6fe6244b863
       
     1 /*
       
     2 * Copyright (c) 2009 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:  CHtiFtpBackupFake implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "HtiFtpBackupFake.h"
       
    21 #include <HtiLogging.h>
       
    22 
       
    23 // CONSTANTS
       
    24 
       
    25 // LOCAL CONSTANTS AND MACROS
       
    26 
       
    27 // MODULE DATA STRUCTURES
       
    28 
       
    29 // LOCAL FUNCTION PROTOTYPES
       
    30 
       
    31 // FORWARD DECLARATIONS
       
    32 
       
    33 
       
    34 // ============================= LOCAL FUNCTIONS ===============================
       
    35 
       
    36 // -----------------------------------------------------------------------------
       
    37 // CHtiFtpBackupFake* NewHtiFtpBackupFake()
       
    38 // Function to construct the CHtiFtpBackupFakeBase derived object.
       
    39 // Exported at ordinal 1 and not a member of the class.
       
    40 // -----------------------------------------------------------------------------
       
    41 EXPORT_C CHtiFtpBackupFake* NewHtiFtpBackupFake()
       
    42     {
       
    43     return new ( ELeave ) CHtiFtpBackupFake();
       
    44     }
       
    45 
       
    46 // ============================ MEMBER FUNCTIONS ===============================
       
    47 
       
    48 // -----------------------------------------------------------------------------
       
    49 // CHtiFtpBackupFake::ConstructL
       
    50 // -----------------------------------------------------------------------------
       
    51 void CHtiFtpBackupFake::ConstructL( RFs* aFs )
       
    52     {
       
    53     HTI_LOG_FUNC_IN( "CHtiFtpBackupFake::ConstructL" );
       
    54     iFs = aFs;
       
    55     iSBEClient = NULL;
       
    56     HTI_LOG_FUNC_OUT( "CHtiFtpBackupFake::ConstructL" );
       
    57     }
       
    58 
       
    59 // -----------------------------------------------------------------------------
       
    60 // CHtiFtpBackupFake::~CHtiFtpBackupFake()
       
    61 // -----------------------------------------------------------------------------
       
    62 CHtiFtpBackupFake::~CHtiFtpBackupFake()
       
    63     {
       
    64     HTI_LOG_FUNC_IN( "CHtiFtpBackupFake::~CHtiFtpBackupFake" );
       
    65     if ( iSBEClient )
       
    66         {
       
    67         DeactivateBackup(); // will delete iSBEClient
       
    68         }
       
    69     delete iSBEClient;  // just to be sure
       
    70     iSBEClient = NULL;
       
    71     iFs = NULL; // iFs is not owned
       
    72     HTI_LOG_FUNC_OUT( "CHtiFtpBackupFake::~CHtiFtpBackupFake" );
       
    73     }
       
    74 
       
    75 // -----------------------------------------------------------------------------
       
    76 // CHtiFtpBackupFake::ActivateBackup()
       
    77 // Activates the backup operation if isn't already active.
       
    78 // -----------------------------------------------------------------------------
       
    79 TInt CHtiFtpBackupFake::ActivateBackup()
       
    80     {
       
    81     HTI_LOG_FUNC_IN( "CHtiFtpBackupFake::ActivateBackup" );
       
    82     TInt err = KErrNone;
       
    83     if ( iSBEClient )
       
    84         {
       
    85         err = KErrAlreadyExists; // Backup already active
       
    86         }
       
    87     else
       
    88         {
       
    89         HTI_LOG_TEXT( "Activating backup" );
       
    90         TDriveList drives;
       
    91         err = iFs->DriveList( drives );
       
    92         if ( !err )
       
    93             {
       
    94             TRAP( err, iSBEClient = CSBEClient::NewL() );
       
    95             if ( !err )
       
    96                 {
       
    97                 TRAP( err, iSBEClient->SetBURModeL(
       
    98                     drives, EBURBackupFull, EBackupBase ) );
       
    99                 HTI_LOG_FORMAT( "CSBEClient::SetBURModeL returned %d", err );
       
   100                 if ( !err )
       
   101                     {
       
   102                     User::After( 1000000 ); // wait for the backup to activate
       
   103                     }
       
   104                 }
       
   105             }
       
   106         }
       
   107     HTI_LOG_FUNC_OUT( "CHtiFtpBackupFake::ActivateBackup" );
       
   108     return err;
       
   109     }
       
   110 
       
   111 // -----------------------------------------------------------------------------
       
   112 // CHtiFtpBackupFake::DeactivateBackup()
       
   113 // Deactivates the backup operation if it's active.
       
   114 // -----------------------------------------------------------------------------
       
   115 TInt CHtiFtpBackupFake::DeactivateBackup()
       
   116     {
       
   117     HTI_LOG_FUNC_IN( "CHtiFtpBackupFake::DeactivateBackup" );
       
   118     TInt err = KErrNone;
       
   119 
       
   120     if ( !iSBEClient )
       
   121         {
       
   122         err = KErrNotReady; // Backup not active
       
   123         }
       
   124     else
       
   125         {
       
   126         HTI_LOG_TEXT( "Deactivating Backup" );
       
   127         TDriveList drives;
       
   128         err = iFs->DriveList( drives );
       
   129         if ( !err )
       
   130             {
       
   131             TRAP( err, iSBEClient->SetBURModeL(
       
   132                 drives, EBURNormal, ENoBackup ) );
       
   133             HTI_LOG_FORMAT( "CSBEClient::SetBURModeL returned %d", err );
       
   134             }
       
   135         delete iSBEClient;
       
   136         iSBEClient = NULL;
       
   137         }
       
   138 
       
   139     HTI_LOG_FUNC_OUT( "CHtiFtpBackupFake::DeactivateBackup" );
       
   140     return err;
       
   141     }
       
   142 
       
   143 // End of File