richcallsettingsengine/rcse2/src/rcsebackupobserver.cpp
changeset 0 a4daefaec16c
equal deleted inserted replaced
-1:000000000000 0:a4daefaec16c
       
     1 /*
       
     2 * Copyright (c) 2004-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 "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:  Implements observer class for backup events
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <connect/sbdefs.h>
       
    20 
       
    21 #include "rcsebackupobserver.h"
       
    22 #include "mrcsebackupobserver.h"
       
    23 #include "rcselogger.h"
       
    24 
       
    25 // ======== MEMBER FUNCTIONS ========
       
    26 
       
    27 // ---------------------------------------------------------------------------
       
    28 // Constructor
       
    29 // ---------------------------------------------------------------------------
       
    30 //
       
    31 CRCSEBackupObserver::CRCSEBackupObserver( MRCSEBackupObserver& aObserver )
       
    32     : CActive( CActive::EPriorityStandard ),
       
    33       iObserver( aObserver )
       
    34     {
       
    35     CActiveScheduler::Add(this);
       
    36     }
       
    37 
       
    38 
       
    39 // ---------------------------------------------------------------------------
       
    40 // ConstructL
       
    41 // ---------------------------------------------------------------------------
       
    42 //
       
    43 void CRCSEBackupObserver::ConstructL()
       
    44     {
       
    45     RCSELOGSTRING( "CRCSEBackupObserver::ConstructL() - IN" );
       
    46     User::LeaveIfError( iBackupStatus.Attach( KUidSystemCategory, 
       
    47                                               conn::KUidBackupRestoreKey ) );
       
    48     //iStatus = KRequestPending;
       
    49     iBackupStatus.Subscribe( iStatus );
       
    50     SetActive();
       
    51     RCSELOGSTRING( "CRCSEBackupObserver::ConstructL() - OUT" );
       
    52     }
       
    53 
       
    54 
       
    55 // ---------------------------------------------------------------------------
       
    56 // NewL
       
    57 // ---------------------------------------------------------------------------
       
    58 //
       
    59 CRCSEBackupObserver* CRCSEBackupObserver::NewL( MRCSEBackupObserver& aObserver )
       
    60     {
       
    61     CRCSEBackupObserver* self = new (ELeave) CRCSEBackupObserver( aObserver );
       
    62     CleanupStack::PushL( self );
       
    63     self->ConstructL();
       
    64     CleanupStack::Pop( self );
       
    65     return self;
       
    66     }
       
    67 
       
    68 
       
    69 // ---------------------------------------------------------------------------
       
    70 // Destructor
       
    71 // ---------------------------------------------------------------------------
       
    72 //
       
    73 CRCSEBackupObserver::~CRCSEBackupObserver()
       
    74     {
       
    75     RCSELOGSTRING( "CRCSEBackupObserver::~CRCSEBackupObserver() - IN" );
       
    76     Cancel();
       
    77     iBackupStatus.Close();
       
    78     RCSELOGSTRING( "CRCSEBackupObserver::~CRCSEBackupObserver() - OUT" );
       
    79     }
       
    80 
       
    81 // ---------------------------------------------------------------------------
       
    82 // From class CActive.
       
    83 // Cancel backup/restore event subscription
       
    84 // ---------------------------------------------------------------------------
       
    85 //
       
    86 void CRCSEBackupObserver::DoCancel()
       
    87     {
       
    88     iBackupStatus.Cancel();
       
    89     }
       
    90 
       
    91 
       
    92 // ---------------------------------------------------------------------------
       
    93 // From class CActive.
       
    94 // Handle backup/restore event
       
    95 // ---------------------------------------------------------------------------
       
    96 //
       
    97 void CRCSEBackupObserver::RunL()
       
    98     {
       
    99     RCSELOGSTRING( "CRCSEBackupObserver::RunL() - IN" );
       
   100     User::LeaveIfError( iStatus.Int() );
       
   101     iBackupStatus.Subscribe( iStatus );
       
   102     SetActive();
       
   103 
       
   104     iObserver.HandleBackupOperationEventL();
       
   105     RCSELOGSTRING( "CRCSEBackupObserver::RunL() - OUT" );
       
   106     }
       
   107 
       
   108 
       
   109 // ---------------------------------------------------------------------------
       
   110 // Return backup / restore status
       
   111 // ---------------------------------------------------------------------------
       
   112 //
       
   113 TBool CRCSEBackupObserver::IsBackupOperationRunning()
       
   114     {
       
   115     TInt backupRestoreStatus;
       
   116     TInt err = RProperty::Get( KUidSystemCategory, 
       
   117                                conn::KUidBackupRestoreKey,
       
   118                                backupRestoreStatus );
       
   119 
       
   120     if ( KErrNone != err )
       
   121         {
       
   122         RCSELOGSTRING( 
       
   123             "CRCSEBackupObserver::IsBackupOperationRunning() - FALSE" );
       
   124         return EFalse;
       
   125         }
       
   126 
       
   127     if( backupRestoreStatus == conn::EBURUnset || 
       
   128         backupRestoreStatus & conn::EBURNormal ||
       
   129         (backupRestoreStatus & conn::KBackupIncTypeMask) == conn::ENoBackup)
       
   130         {
       
   131         RCSELOGSTRING( 
       
   132             "CRCSEBackupObserver::IsBackupOperationRunning() - FALSE" );
       
   133         return EFalse;
       
   134         }
       
   135     else
       
   136         {
       
   137         RCSELOGSTRING( "CRCSEBackupObserver::IsBackupOperationRunning() - TRUE" );
       
   138         return ETrue;
       
   139         }
       
   140     }
       
   141