|
1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 |
|
19 ABTester is both a client of the SBEngine and ABServer only for test purposes |
|
20 */ |
|
21 |
|
22 #ifndef __ABDATAOWNER_H__ |
|
23 #define __ABDATAOWNER_H__ |
|
24 |
|
25 #include <connect/abclient.h> |
|
26 #include <e32std.h> |
|
27 #include <e32property.h> |
|
28 |
|
29 void RunActiveBackupClientL(); |
|
30 |
|
31 namespace conn |
|
32 { |
|
33 //TUid KSBEngineUid = TUid::Uid(0x10202D56); |
|
34 |
|
35 class CABTester; |
|
36 |
|
37 // The simulated file that this test DO will backup/have restored |
|
38 _LIT8(KABTestData, "Active Backup Test Base Data"); |
|
39 |
|
40 // The simulated file that this test DO will backup/have restored |
|
41 _LIT8(KABTestProxyData, "Active Backup Test Proxy Data"); |
|
42 |
|
43 // The simulated file that this test DO will backup/have restored |
|
44 _LIT8(KABTestDataIncrement, ":Active Backup Test Increment Data"); |
|
45 |
|
46 // The simulated snapshot that this tets DO will backup/use to restore |
|
47 _LIT8(KABTestSnapshot, "Active Backup Test Snapshot"); |
|
48 |
|
49 // Simulated time for initialisation of the ABDO |
|
50 const TInt KABInitTime = 5000; |
|
51 |
|
52 class CABData : public CBase |
|
53 { |
|
54 public: |
|
55 static CABData* NewL(TDriveNumber aDriveNum) |
|
56 { |
|
57 CABData* self = new (ELeave) CABData(aDriveNum); |
|
58 return self; |
|
59 } |
|
60 |
|
61 void AddDataL(TDesC8& aData) |
|
62 { |
|
63 if (!iData) |
|
64 { |
|
65 iData = HBufC8::NewL(aData.Size()); |
|
66 } |
|
67 else |
|
68 { |
|
69 // Add the data to the existing buffer |
|
70 iData = iData->ReAllocL(iData->Size() + aData.Size()); |
|
71 } |
|
72 |
|
73 iData->Des().Append(aData); |
|
74 } |
|
75 |
|
76 TDesC8& operator()() |
|
77 { |
|
78 return *iData; |
|
79 } |
|
80 |
|
81 ~CABData() |
|
82 { |
|
83 delete iData; |
|
84 } |
|
85 |
|
86 private: |
|
87 CABData(TDriveNumber aDriveNum) : iDriveNum(aDriveNum) {} |
|
88 |
|
89 private: |
|
90 HBufC8* iData; |
|
91 TDriveNumber iDriveNum; |
|
92 }; |
|
93 |
|
94 |
|
95 |
|
96 /** |
|
97 This class implements the callbacks defined by MActiveBackupDataClient which are used by the SBEngine |
|
98 to request information about the backup or restore operation for this data owner |
|
99 */ |
|
100 class CABDataOwnerCallbackImplementation : public CBase, public MActiveBackupDataClient |
|
101 { |
|
102 public: |
|
103 static CABDataOwnerCallbackImplementation* NewL(TSecureId aID); |
|
104 ~CABDataOwnerCallbackImplementation(); |
|
105 TBool ValidateRestoredData(); |
|
106 TBool ValidateRestoredSnapshot(); |
|
107 |
|
108 // MActiveBackupDataClient implementation |
|
109 void AllSnapshotsSuppliedL(); |
|
110 void ReceiveSnapshotDataL(TDriveNumber aDrive, TDesC8& aBuffer, TBool aLastSection); |
|
111 TUint GetExpectedDataSize(TDriveNumber aDrive); |
|
112 void GetSnapshotDataL(TDriveNumber aDrive, TPtr8& aBuffer, TBool& aFinished); |
|
113 void InitialiseGetBackupDataL(TDriveNumber aDrive); |
|
114 void GetBackupDataSectionL(TPtr8& aBuffer, TBool& aFinished); |
|
115 void InitialiseRestoreBaseDataL(TDriveNumber aDrive); |
|
116 void RestoreBaseDataSectionL(TDesC8& aBuffer, TBool aFinished); |
|
117 void InitialiseRestoreIncrementDataL(TDriveNumber aDrive); |
|
118 void RestoreIncrementDataSectionL(TDesC8& aBuffer, TBool aFinished); |
|
119 void RestoreComplete(TDriveNumber aDrive); |
|
120 void TerminateMultiStageOperation(); |
|
121 TUint GetDataChecksum(TDriveNumber aDrive); |
|
122 void SetABClient(CActiveBackupClient* aABClient); |
|
123 void InitialiseGetProxyBackupDataL(TSecureId aSID, TDriveNumber aDrive); |
|
124 void InitialiseRestoreProxyBaseDataL(TSecureId aSID, TDriveNumber aDrive); |
|
125 |
|
126 private: |
|
127 CABDataOwnerCallbackImplementation(TSecureId aID); |
|
128 |
|
129 void WaitForMillisecondsL(TInt aMilliseconds); |
|
130 void FillBuffer(TDes8& aDes, TBool& aFinished); |
|
131 |
|
132 private: |
|
133 CActiveBackupClient* iABClient; |
|
134 TBackupIncType iBackupIncType; |
|
135 TVersion iVersion; |
|
136 CABData* iSnapshot; |
|
137 CABData* iData; |
|
138 TBool iProxy; |
|
139 TInt iOffset; |
|
140 TInt iSourceSize; |
|
141 TUint iFillChar; |
|
142 TSecureId iID; |
|
143 }; |
|
144 |
|
145 |
|
146 /** |
|
147 This class is the actual data owner that prepares data to send to the sbengine. It owns the CABClient |
|
148 and passes in the callback interface implementation object |
|
149 */ |
|
150 class CABDataOwner : public CActive |
|
151 { |
|
152 |
|
153 public: |
|
154 static CABDataOwner* NewL(); |
|
155 void StartL(); |
|
156 void RunL(); |
|
157 TInt RunError(TInt aError); |
|
158 void DoCancel(); |
|
159 ~CABDataOwner(); |
|
160 |
|
161 private: |
|
162 void CheckStatusL(); |
|
163 CABDataOwner() : CActive(EPriorityNormal) {} |
|
164 |
|
165 void ConstructL(); |
|
166 void Subscribe(); |
|
167 |
|
168 private: |
|
169 /** P&S */ |
|
170 RProperty iProperty; |
|
171 |
|
172 /** Callback implementation */ |
|
173 CActiveBackupClient* iABClient; |
|
174 |
|
175 /** Callback implementation */ |
|
176 CABDataOwnerCallbackImplementation* iCallback; |
|
177 |
|
178 /** Secure ID of the process */ |
|
179 TSecureId iID; |
|
180 }; |
|
181 |
|
182 } |
|
183 |
|
184 #endif //__ABDATAOWNER_H__ |