|
1 /* |
|
2 * Copyright (c) 2007-2008 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: Skin server's active data owner in backup/restore. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <connect/abclient.h> |
|
20 #include <connect/sbdefs.h> |
|
21 #include <e32property.h> |
|
22 |
|
23 #include "aknssrvactivedataowner.h" |
|
24 #include "aknssrvactivebackupdataclient.h" |
|
25 |
|
26 #include "AknsDebug.h" |
|
27 |
|
28 // ======== MEMBER FUNCTIONS ======== |
|
29 // --------------------------------------------------------------------------- |
|
30 // Constructor. |
|
31 // --------------------------------------------------------------------------- |
|
32 // |
|
33 CAknsSrvActiveDataOwner* CAknsSrvActiveDataOwner::NewL( RFs& aFsSession ) |
|
34 { |
|
35 AKNS_TRACE_DEBUG("CAknsSrvActiveDataOwner::NewL"); |
|
36 CAknsSrvActiveDataOwner* self = |
|
37 new ( ELeave ) CAknsSrvActiveDataOwner( aFsSession ); |
|
38 |
|
39 return self; |
|
40 } |
|
41 |
|
42 // --------------------------------------------------------------------------- |
|
43 // Destructor |
|
44 // --------------------------------------------------------------------------- |
|
45 // |
|
46 CAknsSrvActiveDataOwner::~CAknsSrvActiveDataOwner() |
|
47 { |
|
48 AKNS_TRACE_DEBUG("CAknsSrvActiveDataOwner::destructor"); |
|
49 DoCancel(); |
|
50 iBackupProperty.Close(); |
|
51 delete iCallBack; |
|
52 delete iActiveBackupClient; |
|
53 } |
|
54 |
|
55 // --------------------------------------------------------------------------- |
|
56 // Active object's request handling. |
|
57 // --------------------------------------------------------------------------- |
|
58 // |
|
59 void CAknsSrvActiveDataOwner::RunL() |
|
60 { |
|
61 AKNS_TRACE_DEBUG("CAknsSrvActiveDataOwner::RunL"); |
|
62 if ( iStatus.Int() == KErrNone ) |
|
63 { |
|
64 TInt currentValue = KErrNone; |
|
65 iBackupProperty.Get( currentValue ); |
|
66 |
|
67 HandleBackupStateL( currentValue ); |
|
68 } |
|
69 // Re-subscribe notifications. |
|
70 SubscribePSKey(); |
|
71 } |
|
72 |
|
73 // --------------------------------------------------------------------------- |
|
74 // Active object's request error handling. |
|
75 // --------------------------------------------------------------------------- |
|
76 // |
|
77 TInt CAknsSrvActiveDataOwner::RunError( TInt /*aError*/ ) |
|
78 { |
|
79 return KErrNone; |
|
80 } |
|
81 |
|
82 // --------------------------------------------------------------------------- |
|
83 // Cancel the request. |
|
84 // --------------------------------------------------------------------------- |
|
85 // |
|
86 void CAknsSrvActiveDataOwner::DoCancel() |
|
87 { |
|
88 AKNS_TRACE_DEBUG("CAknsSrvActiveDataOwner::DoCancel"); |
|
89 if ( IsActive() ) |
|
90 { |
|
91 iBackupProperty.Cancel(); |
|
92 } |
|
93 } |
|
94 |
|
95 // --------------------------------------------------------------------------- |
|
96 // C++ constructor. |
|
97 // --------------------------------------------------------------------------- |
|
98 // |
|
99 CAknsSrvActiveDataOwner::CAknsSrvActiveDataOwner( RFs& aFsSession ) : |
|
100 CActive( EPriorityNormal ), iFsSession( aFsSession ) |
|
101 { |
|
102 AKNS_TRACE_DEBUG("CAknsSrvActiveDataOwner::ConstructL"); |
|
103 |
|
104 // Attach to backup key. |
|
105 iBackupProperty.Attach( KUidSystemCategory, conn::KUidBackupRestoreKey ); |
|
106 |
|
107 // Add to active scheduler. |
|
108 CActiveScheduler::Add( this ); |
|
109 |
|
110 // Start listening for changes in backup/restore p&s-key. |
|
111 SubscribePSKey(); |
|
112 } |
|
113 |
|
114 // --------------------------------------------------------------------------- |
|
115 // Handles changes in backup state. |
|
116 // --------------------------------------------------------------------------- |
|
117 // |
|
118 void CAknsSrvActiveDataOwner::HandleBackupStateL( const TInt aValue ) |
|
119 { |
|
120 AKNS_TRACE_DEBUG1("CAknsSrvActiveDataOwner::HandleBackupStateL %d", aValue ); |
|
121 TInt type = aValue & conn::KBURPartTypeMask; |
|
122 // Test if the device is going into backup or restore mode, and we are |
|
123 // required to participate. |
|
124 if ( ( type == conn::EBURBackupFull || type == conn::EBURRestoreFull ) || |
|
125 ( type == conn::EBURBackupPartial || type == conn::EBURRestorePartial ) ) |
|
126 { |
|
127 if ( !iCallBack ) |
|
128 { |
|
129 iCallBack = CAknsSrvActiveBackupDataClient::NewL( iFsSession ); |
|
130 } |
|
131 if ( !iActiveBackupClient ) |
|
132 { |
|
133 iActiveBackupClient = conn::CActiveBackupClient::NewL( iCallBack ); |
|
134 |
|
135 if ( ( type == conn::EBURBackupPartial || |
|
136 type == conn::EBURRestorePartial ) && |
|
137 !iActiveBackupClient->DoesPartialBURAffectMeL() ) |
|
138 { |
|
139 delete iCallBack; |
|
140 iCallBack = NULL; |
|
141 delete iActiveBackupClient; |
|
142 iActiveBackupClient = NULL; |
|
143 return; |
|
144 } |
|
145 } |
|
146 |
|
147 iCallBack->PrepareForBURL( type ); |
|
148 iActiveBackupClient->ConfirmReadyForBURL( KErrNone ); |
|
149 } |
|
150 else |
|
151 { |
|
152 if ( type == conn::EBURNormal ) |
|
153 { |
|
154 // delete once back to normal. |
|
155 delete iCallBack; |
|
156 iCallBack = NULL; |
|
157 delete iActiveBackupClient; |
|
158 iActiveBackupClient = NULL; |
|
159 } |
|
160 } |
|
161 } |
|
162 |
|
163 // --------------------------------------------------------------------------- |
|
164 // Subsribes notifications of backup/restore p&s key. |
|
165 // --------------------------------------------------------------------------- |
|
166 // |
|
167 void CAknsSrvActiveDataOwner::SubscribePSKey() |
|
168 { |
|
169 AKNS_TRACE_DEBUG("CAknsSrvActiveDataOwner::SubscribePSKey" ); |
|
170 Cancel(); |
|
171 if ( !IsActive() ) |
|
172 { |
|
173 iStatus = KRequestPending; |
|
174 iBackupProperty.Subscribe( iStatus ); |
|
175 SetActive(); |
|
176 } |
|
177 } |
|
178 |
|
179 // End of file |