homescreenapp/runtimeplugins/hsdefaultruntimeplugin/src/hsbackuprestoreactivecallback.cpp
branchGCC_SURGE
changeset 68 4c11ecddf6b2
parent 53 f75922b9e380
parent 61 2b1b11a301d2
equal deleted inserted replaced
53:f75922b9e380 68:4c11ecddf6b2
     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 the License "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:  Widget's active callback in WidgetBackupRestore.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <bautils.h>
       
    21 
       
    22 #include "hsbackuprestoreactivecallback.h"
       
    23 #include "hsdatabase.h"
       
    24 
       
    25 //  CONSTANTS
       
    26 
       
    27 // ======== MEMBER FUNCTIONS ========
       
    28 
       
    29 // ---------------------------------------------------------------------------
       
    30 // 
       
    31 // ---------------------------------------------------------------------------
       
    32 //
       
    33 CHsBRActiveCallback* CHsBRActiveCallback::NewL()
       
    34 {
       
    35     CHsBRActiveCallback* self =
       
    36         new( ELeave ) CHsBRActiveCallback();
       
    37     CleanupStack::PushL( self );
       
    38     self->ConstructL();
       
    39     CleanupStack::Pop( self );
       
    40 
       
    41     return self;
       
    42 }
       
    43 
       
    44 // ---------------------------------------------------------------------------
       
    45 // Destructor
       
    46 // ---------------------------------------------------------------------------
       
    47 //
       
    48 CHsBRActiveCallback::~CHsBRActiveCallback()
       
    49 {
       
    50 }
       
    51 
       
    52 // ---------------------------------------------------------------------------
       
    53 // Backup or restore has been finished.
       
    54 // ---------------------------------------------------------------------------
       
    55 //
       
    56 void CHsBRActiveCallback::FinishBackupRestore()
       
    57 {
       
    58 	// allow database usage
       
    59 	OpenDataBaseConnection();
       
    60 	// TODO: Load widgets
       
    61 }
       
    62 
       
    63 // ---------------------------------------------------------------------------
       
    64 // Backup or restore has been started.
       
    65 // ---------------------------------------------------------------------------
       
    66 //
       
    67 void CHsBRActiveCallback::StartRestore()
       
    68 {
       
    69 	// allow database usage
       
    70 	CloseDataBaseConnection();
       
    71 	// TODO: Load widgets
       
    72 }
       
    73 
       
    74 // ---------------------------------------------------------------------------
       
    75 // Inform that all data has been backed up or restored.
       
    76 // ---------------------------------------------------------------------------
       
    77 //
       
    78 void CHsBRActiveCallback::AllSnapshotsSuppliedL()
       
    79 {
       
    80     // No implementation needed. Must not leave    
       
    81 }
       
    82 
       
    83 // ---------------------------------------------------------------------------
       
    84 // Not supported.
       
    85 // ---------------------------------------------------------------------------
       
    86 //
       
    87 void CHsBRActiveCallback::ReceiveSnapshotDataL(
       
    88     TDriveNumber /*aDrive*/, TDesC8& /*aBuffer*/, TBool /*aLastSection*/)
       
    89 {
       
    90 	// No implementation needed
       
    91     User::Leave( KErrNotSupported );
       
    92 }
       
    93 
       
    94 // ---------------------------------------------------------------------------
       
    95 // Make a guess about data size.
       
    96 // ---------------------------------------------------------------------------
       
    97 //
       
    98 TUint CHsBRActiveCallback::GetExpectedDataSize(
       
    99     TDriveNumber /*aDrive*/)
       
   100 {
       
   101     // No implementation needed
       
   102     return 0;
       
   103 }
       
   104 
       
   105 // ---------------------------------------------------------------------------
       
   106 // Not supported.
       
   107 // ---------------------------------------------------------------------------
       
   108 //
       
   109 void CHsBRActiveCallback::GetSnapshotDataL(
       
   110     TDriveNumber /*aDrive*/, TPtr8& /*aBuffer*/, TBool& /*aFinished*/)
       
   111 {
       
   112     // No implementation needed
       
   113     User::Leave( KErrNotSupported );
       
   114 }
       
   115 
       
   116 // ---------------------------------------------------------------------------
       
   117 // Initialize for backup.
       
   118 // ---------------------------------------------------------------------------
       
   119 //
       
   120 void CHsBRActiveCallback::InitialiseGetBackupDataL(
       
   121     TDriveNumber /*aDrive*/)
       
   122 {
       
   123     // Prevent database usage
       
   124     CloseDataBaseConnection();
       
   125     // TODO: Unload widgets
       
   126 }
       
   127 
       
   128 // ---------------------------------------------------------------------------
       
   129 // ---------------------------------------------------------------------------
       
   130 //
       
   131 void CHsBRActiveCallback::GetBackupDataSectionL(
       
   132     TPtr8& /*aBuffer*/, TBool& aFinished)
       
   133 {
       
   134     // No data for active backup
       
   135     aFinished = ETrue;
       
   136 }
       
   137 
       
   138 // ---------------------------------------------------------------------------
       
   139 // Initialize restore.
       
   140 // ---------------------------------------------------------------------------
       
   141 //
       
   142 void CHsBRActiveCallback::InitialiseRestoreBaseDataL(
       
   143     TDriveNumber /*aDrive*/ )
       
   144 {
       
   145     // No implementation needed
       
   146     //User::Leave( KErrNotSupported );
       
   147     CloseDataBaseConnection();
       
   148 }
       
   149 
       
   150 // ---------------------------------------------------------------------------
       
   151 // Run state machine for restore. Receive stream from BUR engine and turn it
       
   152 // to file(s).
       
   153 // ---------------------------------------------------------------------------
       
   154 //
       
   155 void CHsBRActiveCallback::RestoreBaseDataSectionL(
       
   156     TDesC8& /*aBuffer*/, TBool /*aFinished*/ )
       
   157 {
       
   158     // No implementation needed
       
   159     CloseDataBaseConnection();
       
   160 }
       
   161 
       
   162 // ---------------------------------------------------------------------------
       
   163 // Incremental restoration is not supported.
       
   164 // ---------------------------------------------------------------------------
       
   165 //
       
   166 void CHsBRActiveCallback::InitialiseRestoreIncrementDataL(
       
   167     TDriveNumber /*aDrive*/)
       
   168 {
       
   169     // No implementation needed
       
   170     User::Leave( KErrNotSupported );
       
   171 }
       
   172 
       
   173 // ---------------------------------------------------------------------------
       
   174 // Incremental restoration is not supported.
       
   175 // ---------------------------------------------------------------------------
       
   176 //
       
   177 void CHsBRActiveCallback::RestoreIncrementDataSectionL(
       
   178     TDesC8& /*aBuffer*/, TBool /*aFinished*/)
       
   179 {
       
   180     // No implementation needed
       
   181     User::Leave( KErrNotSupported );
       
   182 }
       
   183 
       
   184 // ---------------------------------------------------------------------------
       
   185 // Called when restore is complete - sets data back to initial state.
       
   186 // ---------------------------------------------------------------------------
       
   187 //
       
   188 void CHsBRActiveCallback::RestoreComplete(TDriveNumber /*aDrive*/)
       
   189 {
       
   190     // No implementation needed
       
   191 }
       
   192 
       
   193 // ---------------------------------------------------------------------------
       
   194 // Tidy up when operation is over.
       
   195 // ---------------------------------------------------------------------------
       
   196 //
       
   197 void CHsBRActiveCallback::TerminateMultiStageOperation()
       
   198 {
       
   199     // No implementation needed
       
   200 }
       
   201 
       
   202 // ---------------------------------------------------------------------------
       
   203 //
       
   204 // ---------------------------------------------------------------------------
       
   205 //
       
   206 TUint CHsBRActiveCallback::GetDataChecksum(TDriveNumber /*aDrive*/)
       
   207 {
       
   208     // No implementation needed
       
   209     return 0;
       
   210 }
       
   211 
       
   212 // ---------------------------------------------------------------------------
       
   213 // C++ constructor.
       
   214 // ---------------------------------------------------------------------------
       
   215 //
       
   216 CHsBRActiveCallback::CHsBRActiveCallback()
       
   217 {
       
   218 }
       
   219 
       
   220 // ---------------------------------------------------------------------------
       
   221 // 2nd phase constructor.
       
   222 // ---------------------------------------------------------------------------
       
   223 //
       
   224 void CHsBRActiveCallback::ConstructL()
       
   225 {
       
   226 }
       
   227 
       
   228 // ---------------------------------------------------------------------------
       
   229 // CHsBRActiveCallback::CloseDataBaseConnection()
       
   230 //
       
   231 // Close database connection.
       
   232 // ---------------------------------------------------------------------------
       
   233 //
       
   234 void CHsBRActiveCallback::CloseDataBaseConnection()
       
   235 {
       
   236     HsDatabase *db = HsDatabase::instance();
       
   237     db->setDataBaseBlocked(true);
       
   238     db->close();
       
   239 }
       
   240 
       
   241 // ---------------------------------------------------------------------------
       
   242 // CHsBRActiveCallback::OpenDataBaseConnection()
       
   243 //
       
   244 // Open database connection.
       
   245 // ---------------------------------------------------------------------------
       
   246 //
       
   247 void CHsBRActiveCallback::OpenDataBaseConnection()
       
   248 {
       
   249     HsDatabase *db = HsDatabase::instance();
       
   250     db->setDataBaseBlocked(false);
       
   251     db->open();
       
   252 }   
       
   253 // End of file