|
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 "nssvasbackupobserver.h" |
|
20 #include "rubydebug.h" |
|
21 |
|
22 #include <sbdefs.h> |
|
23 |
|
24 // --------------------------------------------------------- |
|
25 // CNssTag::NewL |
|
26 // NewL |
|
27 // --------------------------------------------------------- |
|
28 // |
|
29 CNssVasBackupObserver* CNssVasBackupObserver::NewL( CNssVasDb& aDb ) |
|
30 { |
|
31 CNssVasBackupObserver* self = new (ELeave) CNssVasBackupObserver( aDb ); |
|
32 CleanupStack::PushL( self ); |
|
33 self->ConstructL(); |
|
34 CleanupStack::Pop( self ); |
|
35 return self; |
|
36 } |
|
37 |
|
38 // --------------------------------------------------------- |
|
39 // CNssVasBackupObserver::CNssVasBackupObserver |
|
40 // C++ constructor can NOT contain any code, that might leave. |
|
41 // --------------------------------------------------------- |
|
42 // |
|
43 CNssVasBackupObserver::CNssVasBackupObserver( CNssVasDb& aDb ) : |
|
44 CActive( CActive::EPriorityHigh ), |
|
45 iDb( aDb ) |
|
46 { |
|
47 // Nothing |
|
48 } |
|
49 |
|
50 // --------------------------------------------------------- |
|
51 // CNssVasBackupObserver::ConstructL |
|
52 // C++ constructor can NOT contain any code, that might leave. |
|
53 // --------------------------------------------------------- |
|
54 // |
|
55 void CNssVasBackupObserver::ConstructL() |
|
56 { |
|
57 RUBY_DEBUG_BLOCK( "CNssVasBackupObserver::ConstructL" ); |
|
58 User::LeaveIfError( iProperty.Attach( KUidSystemCategory, conn::KUidBackupRestoreKey ) ); |
|
59 |
|
60 // initial subscription and process current property value |
|
61 iProperty.Subscribe( iStatus ); |
|
62 |
|
63 CActiveScheduler::Add( this ); |
|
64 SetActive(); |
|
65 } |
|
66 |
|
67 // --------------------------------------------------------- |
|
68 // CNssVasBackupObserver::~CNssVasBackupObserver |
|
69 // Destructor |
|
70 // --------------------------------------------------------- |
|
71 // |
|
72 CNssVasBackupObserver::~CNssVasBackupObserver() |
|
73 { |
|
74 Cancel(); |
|
75 iProperty.Close(); |
|
76 } |
|
77 // --------------------------------------------------------- |
|
78 // CNssVasBackupObserver::DoCancel |
|
79 // Cancel listening now |
|
80 // --------------------------------------------------------- |
|
81 // |
|
82 void CNssVasBackupObserver::DoCancel() |
|
83 { |
|
84 iProperty.Cancel(); |
|
85 } |
|
86 |
|
87 // --------------------------------------------------------- |
|
88 // CNssVasBackupObserver::RunL |
|
89 // Is called, when property changed |
|
90 // --------------------------------------------------------- |
|
91 // |
|
92 void CNssVasBackupObserver::RunL() |
|
93 { |
|
94 RUBY_DEBUG_BLOCK( "CNssVasBackupObserver::RunL" ); |
|
95 |
|
96 if( iStatus != KErrNone ) |
|
97 { |
|
98 // At least report the error |
|
99 RUBY_ERROR1( "CNssVasBackupObserver::RunL iStatus is [%d]", iStatus.Int() ); |
|
100 } |
|
101 |
|
102 // resubscribe before processing new value to prevent missing updates |
|
103 // even if some error happened |
|
104 iProperty.Subscribe( iStatus ); |
|
105 SetActive(); |
|
106 // property updated, get new value |
|
107 TInt backupFlag; |
|
108 User::LeaveIfError( iProperty.Get( backupFlag ) ); |
|
109 switch ( backupFlag & conn::KBURPartTypeMask ) |
|
110 { |
|
111 case conn::EBURNormal: |
|
112 // Database can be used again |
|
113 RUBY_DEBUG0( "CNssVasBackupObserver::RunL Unlock transactions" ); |
|
114 iDb.UnlockTransactionsL(); |
|
115 break; |
|
116 |
|
117 case conn::EBURBackupFull: |
|
118 case conn::EBURBackupPartial: |
|
119 case conn::EBURRestoreFull: |
|
120 case conn::EBURRestorePartial: |
|
121 // Lock the use of database |
|
122 RUBY_DEBUG0( "CNssVasBackupObserver::RunL Lock transactions" ); |
|
123 iDb.LockTransactionsL(); |
|
124 break; |
|
125 |
|
126 case conn::EBURUnset: |
|
127 default: |
|
128 RUBY_ERROR1( "CNssVasBackupObserver::RunL backup flag unknown %h ", backupFlag ); |
|
129 } |
|
130 } |
|
131 |
|
132 // End of File |