|
1 /* |
|
2 * Copyright (c) 2008 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: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <e32base.h> |
|
19 #include <sacls.h> |
|
20 #include <connect/sbdefs.h> |
|
21 |
|
22 #include "cabackupnotifier.h" |
|
23 #include "castorageproxy.h" |
|
24 |
|
25 // --------------------------------------------------------------------------- |
|
26 // |
|
27 // --------------------------------------------------------------------------- |
|
28 // |
|
29 CCaBackupNotifier* CCaBackupNotifier::NewL( CCaStorageProxy* aStorageProxy ) |
|
30 { |
|
31 CCaBackupNotifier* self = new ( ELeave ) CCaBackupNotifier( aStorageProxy ); |
|
32 CleanupStack::PushL( self ); |
|
33 self->ConstructL( ); |
|
34 CleanupStack::Pop( self ); |
|
35 return self; |
|
36 } |
|
37 |
|
38 // --------------------------------------------------------------------------- |
|
39 // |
|
40 // --------------------------------------------------------------------------- |
|
41 // |
|
42 CCaBackupNotifier::~CCaBackupNotifier() |
|
43 { |
|
44 Cancel(); |
|
45 iProperty.Close(); |
|
46 } |
|
47 |
|
48 // --------------------------------------------------------------------------- |
|
49 // |
|
50 // --------------------------------------------------------------------------- |
|
51 // |
|
52 CCaBackupNotifier::CCaBackupNotifier( CCaStorageProxy* aStorageProxy ) : |
|
53 CActive( EPriorityNormal ), |
|
54 iStorageProxy( aStorageProxy ), |
|
55 iLastState(0) |
|
56 { |
|
57 iProperty.Attach( KUidSystemCategory, KUidBackupRestoreKey ); |
|
58 CActiveScheduler::Add( this ); |
|
59 iStatus = KRequestPending; |
|
60 iProperty.Subscribe( iStatus ); |
|
61 SetActive(); |
|
62 } |
|
63 |
|
64 // --------------------------------------------------------------------------- |
|
65 // |
|
66 // --------------------------------------------------------------------------- |
|
67 // |
|
68 void CCaBackupNotifier::ConstructL( ) |
|
69 { |
|
70 |
|
71 } |
|
72 |
|
73 // --------------------------------------------------------------------------- |
|
74 // |
|
75 // --------------------------------------------------------------------------- |
|
76 // |
|
77 #ifdef COVERAGE_MEASUREMENT |
|
78 #pragma CTC SKIP |
|
79 #endif //COVERAGE_MEASUREMENT (calls another method) |
|
80 void CCaBackupNotifier::DoCancel() |
|
81 { |
|
82 iProperty.Cancel(); |
|
83 } |
|
84 #ifdef COVERAGE_MEASUREMENT |
|
85 #pragma CTC ENDSKIP |
|
86 #endif //COVERAGE_MEASUREMENT |
|
87 |
|
88 // --------------------------------------------------------------------------- |
|
89 // |
|
90 // --------------------------------------------------------------------------- |
|
91 // |
|
92 void CCaBackupNotifier::RunL() |
|
93 { |
|
94 TInt backupStateValue = 0; |
|
95 iProperty.Get(backupStateValue); |
|
96 // Resubscribe before dealing with the current notification |
|
97 iProperty.Subscribe(iStatus); |
|
98 SetActive(); |
|
99 |
|
100 conn::TBURPartType type = static_cast< conn::TBURPartType > |
|
101 ( backupStateValue & conn::KBURPartTypeMask ); |
|
102 |
|
103 if( type == conn::EBURRestoreFull || type == conn::EBURRestorePartial ) |
|
104 { |
|
105 // restore starting |
|
106 iLastState = ECaRestore; |
|
107 } |
|
108 else if( type == conn::EBURBackupFull || type == conn::EBURBackupPartial ) |
|
109 { |
|
110 // backup starting |
|
111 iStorageProxy->SaveDatabaseL(); |
|
112 iLastState = ECaBackup; |
|
113 } |
|
114 else if( ( type == conn::EBURNormal || type == conn::EBURUnset ) && iLastState == ECaRestore ) |
|
115 { // restore ends |
|
116 iStorageProxy->RestoreDatabaseL(); |
|
117 } |
|
118 else if( ( type == conn::EBURNormal || type == conn::EBURUnset ) && iLastState == ECaBackup ) |
|
119 { // backup ends |
|
120 // do nothing |
|
121 } |
|
122 } |
|
123 |
|
124 |
|
125 #ifdef COVERAGE_MEASUREMENT |
|
126 #pragma CTC SKIP |
|
127 #endif //COVERAGE_MEASUREMENT (calls another method) |
|
128 TInt CCaBackupNotifier::RunError( TInt /*aError*/) |
|
129 { |
|
130 // No need to do anything |
|
131 return KErrNone; |
|
132 } |
|
133 #ifdef COVERAGE_MEASUREMENT |
|
134 #pragma CTC ENDSKIP |
|
135 #endif //COVERAGE_MEASUREMENT |