|
1 /* |
|
2 * Copyright (c) 2005-2006 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: Watches changes of the PC-Suite data sync state |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "nsschbackupobserver.h" |
|
20 #include "rubydebug.h" |
|
21 |
|
22 #include <sbdefs.h> |
|
23 |
|
24 /** |
|
25 @todo generalize the common parts of this class and CNssVasBackupObserver from VAS API |
|
26 At the moment the code is copy-pasted and duplicated |
|
27 */ |
|
28 |
|
29 // --------------------------------------------------------- |
|
30 // CNssChBackupObserver::NewL |
|
31 // NewL |
|
32 // --------------------------------------------------------- |
|
33 // |
|
34 CNssChBackupObserver* CNssChBackupObserver::NewL( CNssContactHandlerImplementation& aHost ) |
|
35 { |
|
36 CNssChBackupObserver* self = new (ELeave) CNssChBackupObserver( aHost ); |
|
37 CleanupStack::PushL( self ); |
|
38 self->ConstructL(); |
|
39 CleanupStack::Pop( self ); |
|
40 return self; |
|
41 } |
|
42 |
|
43 // --------------------------------------------------------- |
|
44 // CNssChBackupObserver::CNssChBackupObserver |
|
45 // C++ constructor can NOT contain any code, that might leave. |
|
46 // --------------------------------------------------------- |
|
47 // |
|
48 CNssChBackupObserver::CNssChBackupObserver( CNssContactHandlerImplementation& aHost ) : |
|
49 CActive( CActive::EPriorityHigh ), |
|
50 iHost( aHost ) |
|
51 { |
|
52 // Nothing |
|
53 } |
|
54 |
|
55 // --------------------------------------------------------- |
|
56 // CNssChBackupObserver::ConstructL |
|
57 // C++ constructor can NOT contain any code, that might leave. |
|
58 // --------------------------------------------------------- |
|
59 // |
|
60 void CNssChBackupObserver::ConstructL() |
|
61 { |
|
62 RUBY_DEBUG_BLOCK( "CNssVasBackupObserver::ConstructL" ); |
|
63 User::LeaveIfError( iProperty.Attach( KUidSystemCategory, conn::KUidBackupRestoreKey ) ); |
|
64 |
|
65 // initial subscription and process current property value |
|
66 iProperty.Subscribe( iStatus ); |
|
67 |
|
68 CActiveScheduler::Add( this ); |
|
69 SetActive(); |
|
70 } |
|
71 |
|
72 // --------------------------------------------------------- |
|
73 // CNssChBackupObserver::~CNssChBackupObserver |
|
74 // Destructor |
|
75 // --------------------------------------------------------- |
|
76 // |
|
77 CNssChBackupObserver::~CNssChBackupObserver() |
|
78 { |
|
79 Cancel(); |
|
80 iProperty.Close(); |
|
81 } |
|
82 // --------------------------------------------------------- |
|
83 // CNssVasBackupObserver::DoCancel |
|
84 // Cancel listening now |
|
85 // --------------------------------------------------------- |
|
86 // |
|
87 void CNssChBackupObserver::DoCancel() |
|
88 { |
|
89 iProperty.Cancel(); |
|
90 } |
|
91 |
|
92 // --------------------------------------------------------- |
|
93 // CNssChBackupObserver::RunL |
|
94 // Is called, when property changed |
|
95 // --------------------------------------------------------- |
|
96 // |
|
97 void CNssChBackupObserver::RunL() |
|
98 { |
|
99 RUBY_DEBUG_BLOCK( "CNssChBackupObserver::RunL" ); |
|
100 if( iStatus != KErrNone ) |
|
101 { |
|
102 // At least report the error |
|
103 RUBY_ERROR1( "CNssChBackupObserver::RunL iStatus is [%d]", iStatus.Int() ); |
|
104 } |
|
105 |
|
106 // resubscribe before processing new value to prevent missing updates |
|
107 // even if some error happened |
|
108 iProperty.Subscribe( iStatus ); |
|
109 SetActive(); |
|
110 // property updated, get new value |
|
111 TInt backupFlag; |
|
112 User::LeaveIfError( iProperty.Get( backupFlag ) ); |
|
113 TBool restoreRelated = EFalse; |
|
114 switch ( backupFlag & conn::KBURPartTypeMask ) |
|
115 { |
|
116 case conn::EBURNormal: |
|
117 RUBY_DEBUG0( "CNssChBackupObserver::RunL backup/restore not in progress" ); |
|
118 iInProgress = EFalse; |
|
119 break; |
|
120 |
|
121 case conn::EBURBackupFull: |
|
122 case conn::EBURBackupPartial: |
|
123 restoreRelated = EFalse; |
|
124 iInProgress = ETrue; |
|
125 break; |
|
126 case conn::EBURRestoreFull: |
|
127 case conn::EBURRestorePartial: |
|
128 RUBY_DEBUG0( "CNssChBackupObserver::RunL backup/restore in progress" ); |
|
129 restoreRelated = ETrue; |
|
130 iInProgress = ETrue; |
|
131 break; |
|
132 |
|
133 case conn::EBURUnset: |
|
134 default: |
|
135 RUBY_ERROR1( "CNssChBackupObserver::RunL backup flag unknown %h ", backupFlag ); |
|
136 } |
|
137 iHost.BackupRestoreStateChanged( restoreRelated, InProgress() ); |
|
138 } |
|
139 |
|
140 // --------------------------------------------------------- |
|
141 // @return ETrue if some backup/restore action is in progress |
|
142 // EFalse otherwise |
|
143 // --------------------------------------------------------- |
|
144 TBool CNssChBackupObserver::InProgress() |
|
145 { |
|
146 return iInProgress; |
|
147 } |
|
148 |
|
149 // End of File |