1 /* |
|
2 * Copyright (c) 2007 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: Backup and restore events listener. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <connect/sbdefs.h> |
|
20 |
|
21 #include "cpserverburlistener.h" |
|
22 #include "cpdebug.h" |
|
23 // conn - "Declaration of Types and Constants for Secure Backup and Restore" namespace, see sbdefs.h |
|
24 using namespace conn; |
|
25 |
|
26 // ============================ MEMBER FUNCTIONS ============================= |
|
27 |
|
28 // ----------------------------------------------------------------------------- |
|
29 // CSpaceDataStorageBURListener::CSpaceDataStorageBURListener |
|
30 // C++ default constructor |
|
31 // ----------------------------------------------------------------------------- |
|
32 // |
|
33 CCPServerBURListener::CCPServerBURListener( MBURListenerCallback* aCallback ) : |
|
34 CActive(EPriorityNormal) |
|
35 { |
|
36 CActiveScheduler::Add( this ); |
|
37 iCallback = aCallback; |
|
38 |
|
39 // Prepare automatically |
|
40 iProperty.Attach( KUidSystemCategory, KUidBackupRestoreKey ); |
|
41 SetActive( ); |
|
42 iProperty.Subscribe( iStatus ); |
|
43 } |
|
44 |
|
45 // ----------------------------------------------------------------------------- |
|
46 // CSpaceDataStorageBURListener::ConstructL |
|
47 // S2nd phase constructor. |
|
48 // ----------------------------------------------------------------------------- |
|
49 // |
|
50 void CCPServerBURListener::ConstructL() |
|
51 { |
|
52 |
|
53 } |
|
54 |
|
55 // --------------------------------------------------------------------------- |
|
56 // CSpaceDataStorageBURListener::NewL |
|
57 // --------------------------------------------------------------------------- |
|
58 // |
|
59 CCPServerBURListener* CCPServerBURListener::NewL( |
|
60 MBURListenerCallback* aCallback ) |
|
61 { |
|
62 CCPServerBURListener* self = new (ELeave) |
|
63 CCPServerBURListener( aCallback ); |
|
64 CleanupStack::PushL( self ); |
|
65 self->ConstructL( ); |
|
66 CleanupStack::Pop( self ); |
|
67 |
|
68 return self; |
|
69 } |
|
70 |
|
71 // --------------------------------------------------------------------------- |
|
72 // CSpaceDataStorageBURListener::~CSpaceDataStorageBURListener |
|
73 // --------------------------------------------------------------------------- |
|
74 // |
|
75 CCPServerBURListener::~CCPServerBURListener() |
|
76 { |
|
77 Cancel( ); |
|
78 iProperty.Close( ); |
|
79 } |
|
80 |
|
81 // --------------------------------------------------------------------------- |
|
82 // CSpaceDataStorageBURListener::DoCancel |
|
83 // --------------------------------------------------------------------------- |
|
84 // |
|
85 void CCPServerBURListener::DoCancel() |
|
86 { |
|
87 iProperty.Cancel( ); |
|
88 } |
|
89 |
|
90 // --------------------------------------------------------------------------- |
|
91 // CSpaceDataStorageBURListener::RunError |
|
92 // --------------------------------------------------------------------------- |
|
93 // |
|
94 TInt CCPServerBURListener::RunError( TInt /*aError*/) |
|
95 { |
|
96 // No need to do anything |
|
97 return KErrNone; |
|
98 } |
|
99 |
|
100 // --------------------------------------------------------------------------- |
|
101 // CCPServerBURListener::CheckStatus |
|
102 // --------------------------------------------------------------------------- |
|
103 // |
|
104 TBool CCPServerBURListener::CheckBUR() |
|
105 { |
|
106 TInt pnsStatus; |
|
107 TInt err; |
|
108 err = iProperty.Get( KUidSystemCategory, KUidBackupRestoreKey, pnsStatus ); |
|
109 if ( pnsStatus < EBURBackupFull && err >= KErrNone ) |
|
110 { |
|
111 return EFalse; |
|
112 } |
|
113 else |
|
114 { |
|
115 return ETrue; |
|
116 } |
|
117 } |
|
118 |
|
119 // --------------------------------------------------------------------------- |
|
120 // CSpaceDataStorageBURListener::RunL |
|
121 // --------------------------------------------------------------------------- |
|
122 // |
|
123 void CCPServerBURListener::RunL() |
|
124 { |
|
125 CP_DEBUG( _L8("CCPServerBURListener::RunL()") ); |
|
126 // Re-issue request before notifying |
|
127 SetActive( ); |
|
128 iProperty.Subscribe( iStatus ); |
|
129 |
|
130 TInt pnsStatus; |
|
131 User::LeaveIfError( iProperty.Get( KUidSystemCategory, |
|
132 KUidBackupRestoreKey, pnsStatus ) ); |
|
133 |
|
134 MBURListenerCallback::TBURStatus |
|
135 burStatus(MBURListenerCallback::EBURStatusNone); |
|
136 if ( pnsStatus & (EBURBackupFull | EBURBackupPartial ) ) |
|
137 { |
|
138 burStatus = MBURListenerCallback::EBURStatusBackup; |
|
139 } |
|
140 else if ( pnsStatus & (EBURRestoreFull | EBURRestorePartial ) ) |
|
141 { |
|
142 burStatus = MBURListenerCallback::EBURStatusRestore; |
|
143 } |
|
144 |
|
145 iCallback->HandleBUREventL( burStatus ); |
|
146 } |
|
147 |
|
148 // End of File |
|