|
1 /* |
|
2 * Copyright (c) 2008-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: Observes Backup & Restore's state key and status -* |
|
15 */ |
|
16 |
|
17 |
|
18 // SYSTEM INCLUDE |
|
19 #include <e32property.h> |
|
20 #include <sbdefs.h> |
|
21 |
|
22 //USER INCLUDE |
|
23 #include "backupsubscriber.h" |
|
24 #include "harvesterlog.h" |
|
25 #include "mdsactivescheduler.h" |
|
26 #include "propertywatcher.h" |
|
27 |
|
28 // --------------------------------------------------------------------------- |
|
29 // CBackupSubscriber::CBackupSubscriber |
|
30 // Default constructor. |
|
31 // --------------------------------------------------------------------------- |
|
32 // |
|
33 CBackupSubscriber::CBackupSubscriber( MBackupRestoreObserver& aObserver ) |
|
34 : iPropertyWatcher( NULL ), iObserver( aObserver ) |
|
35 { |
|
36 // No implementation required. |
|
37 } |
|
38 |
|
39 // --------------------------------------------------------------------------- |
|
40 // CBackupSubscriber::NewL |
|
41 // Standard NewL for first phase construction. |
|
42 // --------------------------------------------------------------------------- |
|
43 // |
|
44 CBackupSubscriber* CBackupSubscriber::NewL( MBackupRestoreObserver& aObserver ) |
|
45 { |
|
46 WRITELOG( "CBackupSubscriber::NewL - begin" ); |
|
47 |
|
48 CBackupSubscriber* self = new ( ELeave ) CBackupSubscriber( aObserver ); |
|
49 CleanupStack::PushL( self ); |
|
50 self->ConstructL(); |
|
51 CleanupStack::Pop( self ); |
|
52 |
|
53 WRITELOG( "CBackupSubscriber::NewL - end" ); |
|
54 return self; |
|
55 } |
|
56 |
|
57 // --------------------------------------------------------------------------- |
|
58 // CBackupSubscriber::ConstructL |
|
59 // 2nd phase construction. |
|
60 // --------------------------------------------------------------------------- |
|
61 // |
|
62 void CBackupSubscriber::ConstructL() |
|
63 { |
|
64 WRITELOG( "CBackupSubscriber::ConstructL - begin" ); |
|
65 |
|
66 iPropertyWatcher = CPropertyWatcher::GetInstanceL(); |
|
67 |
|
68 // Want to listen when backup/restore starts. |
|
69 // Calls NotifyKeyL when key's state has changed. |
|
70 iPropertyWatcher->ListenKeyAndStatusChangesL( |
|
71 KUidSystemCategory, |
|
72 conn::KUidBackupRestoreKey, |
|
73 this |
|
74 ); |
|
75 |
|
76 WRITELOG( "CBackupSubscriber::ConstructL - end" ); |
|
77 } |
|
78 |
|
79 // --------------------------------------------------------------------------- |
|
80 // CBackupSubscriber::~CBackupSubscriber |
|
81 // Destructor. |
|
82 // --------------------------------------------------------------------------- |
|
83 // |
|
84 CBackupSubscriber::~CBackupSubscriber() |
|
85 { |
|
86 WRITELOG( "CBackupSubscriber::~CBackupSubscriber - begin" ); |
|
87 |
|
88 if( iPropertyWatcher ) |
|
89 { |
|
90 iPropertyWatcher->StopListeningKeyAndStatusChanges( |
|
91 KUidSystemCategory, |
|
92 conn::KUidBackupRestoreKey, this ); |
|
93 |
|
94 iPropertyWatcher->Delete(); // Release connection to TLS object. |
|
95 } |
|
96 |
|
97 WRITELOG( "CBackupSubscriber::~CBackupSubscriber - end" ); |
|
98 } |
|
99 |
|
100 // ----------------------------------------------------------------------------- |
|
101 // CBackupSubscriber::NotifyKeyAndStatusL |
|
102 // CPropertyWatcher's callback. |
|
103 // ----------------------------------------------------------------------------- |
|
104 // |
|
105 void CBackupSubscriber::NotifyKeyAndStatusL( |
|
106 const TInt aKeyValue, |
|
107 TRequestStatus& aStatus, |
|
108 const TUid aPropertyCategory, |
|
109 const TUint aKey ) |
|
110 { |
|
111 WRITELOG("CBackupSubscriber::NotifyKeyAndStatusL() - begin"); |
|
112 |
|
113 if( aPropertyCategory == KUidSystemCategory && |
|
114 aKey == conn::KUidBackupRestoreKey ) |
|
115 { |
|
116 CheckBackupState( aKeyValue, aStatus ); |
|
117 } |
|
118 |
|
119 WRITELOG("CBackupSubscriber::NotifyKeyAndStatusL() - end"); |
|
120 } |
|
121 |
|
122 |
|
123 // --------------------------------------------------------------------------- |
|
124 // CBackupSubscriber::CheckBackupState |
|
125 // Check Backup & Restore's state key status and act accordingly. |
|
126 // --------------------------------------------------------------------------- |
|
127 // |
|
128 void CBackupSubscriber::CheckBackupState( |
|
129 const TInt aKeyValue, |
|
130 TRequestStatus& aStatus ) |
|
131 { |
|
132 WRITELOG( "CBackupSubscriber::CheckBackupState, begin" ); |
|
133 |
|
134 TInt backupStateValue = aKeyValue; |
|
135 backupStateValue &= conn::KBURPartTypeMask; |
|
136 WRITELOG1( "CBackupSubscriber::CheckBackupState(), backupStateValue = %d", backupStateValue ); |
|
137 |
|
138 switch ( backupStateValue ) |
|
139 { |
|
140 case conn::EBURBackupFull: |
|
141 case conn::EBURBackupPartial: |
|
142 case conn::EBURRestoreFull: |
|
143 case conn::EBURRestorePartial: |
|
144 { |
|
145 iObserver.BackupRestoreStart(); |
|
146 CMdsActiveScheduler* mdsScheduler = static_cast<CMdsActiveScheduler*> (CActiveScheduler::Current()); |
|
147 mdsScheduler->SetAllowedAOStatus( aStatus ); |
|
148 break; |
|
149 } |
|
150 case conn::EBURNormal: |
|
151 case conn::EBURUnset: |
|
152 default: |
|
153 { |
|
154 // backup or restore is completed, so resume normal operation. |
|
155 iObserver.BackupRestoreReady(); |
|
156 CMdsActiveScheduler* mdsScheduler = static_cast<CMdsActiveScheduler*> (CActiveScheduler::Current()); |
|
157 mdsScheduler->RemoveAllowedAOStatus(); |
|
158 } |
|
159 } |
|
160 |
|
161 WRITELOG( "CBackupSubscriber::CheckBackupState, end" ); |
|
162 } |
|
163 |
|
164 // End of file. |