|
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: |
|
15 * |
|
16 */ |
|
17 #include "mdebackuprestorewatcher.h" |
|
18 |
|
19 #ifdef _DEBUG |
|
20 #include <e32debug.h> |
|
21 #endif |
|
22 |
|
23 #include <e32property.h> |
|
24 #include <sbdefs.h> |
|
25 |
|
26 CMdEBackupRestoreWatcherAO* CMdEBackupRestoreWatcherAO::NewL(MMdEBackupRestoreObserver& aObserver) |
|
27 { |
|
28 CMdEBackupRestoreWatcherAO* self = CMdEBackupRestoreWatcherAO::NewLC( aObserver ); |
|
29 CleanupStack::Pop( self ); |
|
30 return self; |
|
31 } |
|
32 |
|
33 CMdEBackupRestoreWatcherAO* CMdEBackupRestoreWatcherAO::NewLC(MMdEBackupRestoreObserver& aObserver) |
|
34 { |
|
35 CMdEBackupRestoreWatcherAO* self = new(ELeave) CMdEBackupRestoreWatcherAO( aObserver ); |
|
36 CleanupStack::PushL( self ); |
|
37 self->ConstructL(); |
|
38 return self; |
|
39 } |
|
40 |
|
41 |
|
42 CMdEBackupRestoreWatcherAO::CMdEBackupRestoreWatcherAO(MMdEBackupRestoreObserver& aObserver) |
|
43 : CActive(CActive::EPriorityStandard), iObserver( aObserver ) |
|
44 { |
|
45 } |
|
46 |
|
47 void CMdEBackupRestoreWatcherAO::ConstructL() |
|
48 { |
|
49 #ifdef _DEBUG |
|
50 RDebug::Print(_L("CMdEBackupRestoreWatcherAO::ConstructL()")); |
|
51 #endif |
|
52 |
|
53 CActiveScheduler::Add( this ); |
|
54 |
|
55 iStatus = KRequestPending; |
|
56 iProperty.Attach( KUidSystemCategory, conn::KUidBackupRestoreKey ); |
|
57 iProperty.Subscribe( iStatus ); |
|
58 SetActive(); |
|
59 } |
|
60 |
|
61 CMdEBackupRestoreWatcherAO::~CMdEBackupRestoreWatcherAO() |
|
62 { |
|
63 #ifdef _DEBUG |
|
64 RDebug::Print(_L("CMdEBackupRestoreWatcherAO::~CMdEBackupRestoreWatcherAO()")); |
|
65 #endif |
|
66 |
|
67 Cancel(); |
|
68 |
|
69 iProperty.Close(); |
|
70 } |
|
71 |
|
72 void CMdEBackupRestoreWatcherAO::RunL() |
|
73 { |
|
74 #ifdef _DEBUG |
|
75 RDebug::Print(_L("CMdEBackupRestoreWatcherAO::RunL")); |
|
76 #endif |
|
77 |
|
78 iProperty.Subscribe( iStatus ); |
|
79 SetActive(); |
|
80 |
|
81 TInt backupStateValue = conn::EBURUnset; |
|
82 iProperty.Get( backupStateValue ); |
|
83 |
|
84 backupStateValue &= conn::KBURPartTypeMask; |
|
85 |
|
86 switch ( backupStateValue ) |
|
87 { |
|
88 case conn::EBURBackupFull: |
|
89 case conn::EBURBackupPartial: |
|
90 { |
|
91 #ifdef _DEBUG |
|
92 RDebug::Print(_L("CMdEBackupRestoreWatcherAO::RunL - BackupFull/BackupPartial")); |
|
93 #endif |
|
94 |
|
95 // Notify all observers about backup. |
|
96 iObserver.HandleBackup(); |
|
97 break; |
|
98 } |
|
99 case conn::EBURRestoreFull: |
|
100 case conn::EBURRestorePartial: |
|
101 { |
|
102 #ifdef _DEBUG |
|
103 RDebug::Print(_L("CMdEBackupRestoreWatcherAO::RunL - RestoreFull/RestorePartial")); |
|
104 #endif |
|
105 |
|
106 // Notify all observers about restore. |
|
107 iObserver.HandleRestore(); |
|
108 break; |
|
109 } |
|
110 case conn::EBURNormal: |
|
111 case conn::EBURUnset: |
|
112 default: |
|
113 { |
|
114 #ifdef _DEBUG |
|
115 RDebug::Print(_L("CMdEBackupRestoreWatcherAO::RunL - Normal")); |
|
116 #endif |
|
117 |
|
118 // Backup or restore is completed. Resume normal operation. |
|
119 iObserver.ResumeOperation(); |
|
120 } |
|
121 } |
|
122 } |
|
123 |
|
124 void CMdEBackupRestoreWatcherAO::DoCancel() |
|
125 { |
|
126 #ifdef _DEBUG |
|
127 RDebug::Print(_L("CMdEBackupRestoreWatcherAO::DoCancel")); |
|
128 #endif |
|
129 |
|
130 iProperty.Cancel(); |
|
131 } |
|
132 |
|
133 #ifdef _DEBUG |
|
134 TInt CMdEBackupRestoreWatcherAO::RunError(TInt aError) |
|
135 #else |
|
136 TInt CMdEBackupRestoreWatcherAO::RunError(TInt /*aError*/) |
|
137 #endif |
|
138 { |
|
139 #ifdef _DEBUG |
|
140 RDebug::Print(_L("CMdEBackupRestoreWatcherAO::RunError() - error %d"), aError); |
|
141 #endif |
|
142 |
|
143 // start again? |
|
144 return KErrNone; |
|
145 } |