49
|
1 |
/*
|
|
2 |
* Copyright (c) 2008-2009 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: Header file for CStorageBackupUtil class
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#ifndef JAVASTORAGEBACKUPUTIL_H
|
|
20 |
#define JAVASTORAGEBACKUPUTIL_H
|
|
21 |
|
|
22 |
#include <string>
|
|
23 |
#include <vector>
|
|
24 |
|
|
25 |
#include <e32base.h>
|
|
26 |
#include <wchar.h>
|
|
27 |
#include <s32strm.h>
|
|
28 |
|
|
29 |
#include "javastorageentry.h"
|
|
30 |
#include "javastorage.h"
|
|
31 |
#include "javastoragenames.h"
|
|
32 |
|
|
33 |
#define NUMBER_OF_TABLES 11
|
|
34 |
|
|
35 |
class RDesWriteStream;
|
|
36 |
class RDesReadStream;
|
|
37 |
|
|
38 |
namespace java
|
|
39 |
{
|
|
40 |
namespace backup
|
|
41 |
{
|
|
42 |
|
|
43 |
|
|
44 |
/**
|
|
45 |
--------------------------------------------------------------------------------
|
|
46 |
|
|
47 |
* CStorageBackupUtil class is handling backup and restore of Java Storage data
|
|
48 |
* This class is instantiated when a BUR operation is starting.
|
|
49 |
|
|
50 |
Example Data that could be present in JavaStorage which is backed up and restored by this class.
|
|
51 |
|
|
52 |
Application Package Data
|
|
53 |
ID | PACKAGE_NAME | VENDOR | VERSION | ROOT_PATH | MEDIA_ID | INITIAL_SIZE | JAD_PATH | JAR_PATH | JAD_URL | JAR_URL | ACCESS_POINT | CONTENT_INFO | CONTENT_ID
|
|
54 |
788463512 | HelloWorld? | Nokia | 1.1 | \C\Private\102033E6\MIDlets\[101e59d8] | 123456 | 200 | \C\Private\102033E6\MIDlets\[101e59d8]\HelloWorld.jad | \C\Private\102033E6\MIDlets\[101e59d8]\HelloWorld.jar | http://getjar.com/MyGreatApp.jad | http://getjar.com/MyGreatApp2.jar | IAP:2 | 0 | 78d78sd89f789
|
|
55 |
|
|
56 |
|
|
57 |
Application Data
|
|
58 |
ID | PACKAGE_ID | NAME | MAIN_CLASS | AUTORUN
|
|
59 |
788463616 | 788463512 | HelloWorld | HelloWorld | 0
|
|
60 |
|
|
61 |
|
|
62 |
Application Package Attributes Data
|
|
63 |
ID | NAME | VALUE | TRUSTED
|
|
64 |
788463512 | MIDlet-Name | HelloWorld | 00
|
|
65 |
788463512 | MIDlet-Version | 1.0 | 10
|
|
66 |
788463512 | MIDlet-Vendor | Nokia | 10
|
|
67 |
|
|
68 |
|
|
69 |
MIDP Application Package Data
|
|
70 |
ID | TYPE | SECURITY_DOMAIN | HASH | CERT_HASH | RMS | VALID_CERTS | ON_SCREEN_KEYPAD
|
|
71 |
788463512 | MIDletSuite? | Trusted | 123456789 | 123456789 | \C\Private\102033E6\MIDlets\[101e59d8]\RMSdata.bin | 1,3,5 | 0
|
|
72 |
|
|
73 |
|
|
74 |
MIDP Permissions Data
|
|
75 |
ID | CLASS | NAME | ACTION | FUNCTION_GROUP
|
|
76 |
788463616 | javax.microedition.io.HttpProtocolPermission | http://server/index.html | read | HTTP
|
|
77 |
|
|
78 |
|
|
79 |
MIDP Function Group Settings Data
|
|
80 |
ID | FUNCTION_GROUP | ALLOWED_SETTINGS | CURRENT_SETTING | BLANKET_PROMPT
|
|
81 |
788463616 | HTTP | 111 (e.g. BLANKET, SESSION, ONESHOT) | 001 (ONESHOT) | 0
|
|
82 |
|
|
83 |
The allowed settings could be a an encoded integer based on the binary representation of 3 bits (e.g. 100 if only BLANKET is allowed, 011 if SESSION and ONESHOT are allowed).
|
|
84 |
|
|
85 |
|
|
86 |
MIDP Push Registrations Data
|
|
87 |
ID | URL | NAME | FILTER | REGISTRATION_TYPE
|
|
88 |
788463616 | sip:*;type=""application/test"", SIPPushReceiver? | SIPPushReceiver? | * | 1
|
|
89 |
788463616 | btspp://localhost:99999999999999999999999999999999;*;authenticated;blacklist=00E001234567 | BTPushReceiver? | * | 0
|
|
90 |
|
|
91 |
|
|
92 |
MIDP Alarm Push Registrations Data
|
|
93 |
ID | ALARM_TIME
|
|
94 |
788463616 | 2008-09-13;15:20:30
|
|
95 |
|
|
96 |
|
|
97 |
MIDP Runtime Settings Data
|
|
98 |
EXTENSIONS
|
|
99 |
\C\Private\102033E6\Extenstions\12345678\Location.jar
|
|
100 |
|
|
101 |
|
|
102 |
Preinstall Data
|
|
103 |
NAME | VENDOR | VERSION | INSTALL_STATE
|
|
104 |
TestMIDletSuite | TestVendor | 1.2.3 | 2
|
|
105 |
|
|
106 |
|
|
107 |
MIDP OTA Status Data table
|
|
108 |
ID | CREATION_TIME | TYPE | OTA_CODE | URL | LATEST_RETRY_TIME | RETRY_COUNT
|
|
109 |
788463616 | 2008-09-13;12:20:30 | 1 | 900 | http://www.moo.com/MIDLETS.js | 2008-09-13;15:20:30 | 2
|
|
110 |
|
|
111 |
-----------------------------------------------------------------------------------------------------------------------------
|
|
112 |
*/
|
|
113 |
|
|
114 |
class CStorageBackupUtil : public CBase
|
|
115 |
{
|
|
116 |
public:
|
|
117 |
|
|
118 |
/**
|
|
119 |
* Instantiates an object of this type
|
|
120 |
*/
|
|
121 |
static CStorageBackupUtil* NewL();
|
|
122 |
|
|
123 |
~CStorageBackupUtil();
|
|
124 |
|
|
125 |
/**
|
|
126 |
* This method requests a section of Java Storage data.
|
|
127 |
* Called by the function GetBackupDataSectionL from midp2backupplugin
|
|
128 |
* The data is filled into the stream till it is full.
|
|
129 |
* The data returned may be base or incremental depending
|
|
130 |
* on the type of backup and the capability of the data owner.
|
|
131 |
*
|
|
132 |
* @param aBuffer a pointer to the base of the location where data
|
|
133 |
* can be copied.
|
|
134 |
* @param aBackupNotFinished on return EFalse if all data has
|
|
135 |
* been returned for this drive, else ETrue.
|
|
136 |
*/
|
|
137 |
void BackupStorageDataL(RDesWriteStream& aStream, TBool& aBackupNotFinished, TInt& aBufferSpaceLeft);
|
|
138 |
|
|
139 |
/**
|
|
140 |
* This method receives a section of base restore data.
|
|
141 |
* Stores the restore data in the vector so that it can be
|
|
142 |
* written to Java Storage when all data have come.
|
|
143 |
*
|
|
144 |
* @param stream holds the restore data
|
|
145 |
* @param aRestoreState EFirstBuffer if all data has been returned
|
|
146 |
* for this drive, else remains at EStorage.
|
|
147 |
* @param aBufferSpaceLeft the space left in the buffer
|
|
148 |
*/
|
|
149 |
void RestoreStorageDataL(RDesReadStream& aStream, TInt& aRestoreState, TInt& aBufferSpaceLeft);
|
|
150 |
|
|
151 |
private:
|
|
152 |
|
|
153 |
// Default constructor for the class
|
|
154 |
|
|
155 |
CStorageBackupUtil();
|
|
156 |
|
|
157 |
// Second phase constructor function
|
|
158 |
|
|
159 |
void ConstructL();
|
|
160 |
|
|
161 |
/**
|
|
162 |
* This method fills the vector with Java Storage data.
|
|
163 |
* Data is read from JavaStorage tables and put inside the vector
|
|
164 |
* which will later be put into the buffer stream.
|
|
165 |
* The reason for having vector to store the data is that connection to
|
|
166 |
* Java Storage cannot be open for a long period of time
|
|
167 |
* ie writing into buffer stream's time
|
|
168 |
*
|
|
169 |
* @return returns an integer value telling whether the operation
|
|
170 |
* was completed successfully or not.
|
|
171 |
*/
|
|
172 |
int FillVectorWithStorageData();
|
|
173 |
|
|
174 |
/**
|
|
175 |
* A utility function which converts a wstring into a TDesC
|
|
176 |
* and writes it into the stream.
|
|
177 |
*
|
|
178 |
* @param stream an RDesWriteStream into which the converted
|
|
179 |
* string is written
|
|
180 |
* @param tempString the wstring which is to be converted.
|
|
181 |
*/
|
|
182 |
void WriteStringtoStreamL(RDesWriteStream& aStream, std::wstring aTempString);
|
|
183 |
|
|
184 |
/**
|
|
185 |
* A utility function which reads a TDesC from the stream, converts it
|
|
186 |
* to a wstring and writes it into the vector.
|
|
187 |
*
|
|
188 |
* @param stream an RDesReadStream from which the TDesC data is read
|
|
189 |
*/
|
|
190 |
void ReadStringfromStreamL(RDesReadStream& aStream);
|
|
191 |
|
|
192 |
/**
|
|
193 |
* This method writes the data to storage.
|
|
194 |
* Gets called after FillVectorsWithStreamDataL() function is called.
|
|
195 |
* This function opens a transaction to Storage and writes
|
|
196 |
* the vector's data into storage row-by-row, and then commits
|
|
197 |
* the transaction.
|
|
198 |
*
|
|
199 |
* @return returns an integer specifying whether the operation
|
|
200 |
* has completed successfully or not.
|
|
201 |
*/
|
|
202 |
int WriteDataToStorage();
|
|
203 |
public:
|
|
204 |
/**
|
|
205 |
* Utility function which fills the vector with data got from storage.
|
|
206 |
* Handles data of only APPLICATION_PACKAGE_TABLE.
|
|
207 |
*
|
|
208 |
* @param afoundEntries the application entries which match
|
|
209 |
* the SQL query.
|
|
210 |
* @return an integer representing the number of rows written
|
|
211 |
* into the vector.
|
|
212 |
*/
|
|
213 |
int FillVectorwithAppPackageTableData(java::storage::JavaStorageApplicationList_t& afoundEntries);
|
|
214 |
|
|
215 |
/**
|
|
216 |
* Utility function which fills the vector with data got from storage.
|
|
217 |
* Handles data of only APPLICATION_TABLE.
|
|
218 |
*
|
|
219 |
* @param afoundEntries the application entries which match
|
|
220 |
* the SQL query.
|
|
221 |
* @return an integer representing the number of rows written
|
|
222 |
* into the vector.
|
|
223 |
*/
|
|
224 |
int FillVectorwithAppTableData(java::storage::JavaStorageApplicationList_t& afoundEntries);
|
|
225 |
|
|
226 |
/**
|
|
227 |
* Utility function which fills the vector with data got from storage.
|
|
228 |
* Handles data of only APPLICATION_PACKAGE_ATTRIBUTES_TABLE.
|
|
229 |
*
|
|
230 |
* @param afoundEntries the application entries which match
|
|
231 |
* the SQL query.
|
|
232 |
* @return an integer representing the number of rows written
|
|
233 |
* into the vector.
|
|
234 |
*/
|
|
235 |
int FillVectorwithAppPackageAttTableData(java::storage::JavaStorageApplicationList_t& afoundEntries);
|
|
236 |
|
|
237 |
/**
|
|
238 |
* Utility function which fills the vector with data got from storage.
|
|
239 |
* Handles data of only MIDP_PACKAGE_TABLE.
|
|
240 |
*
|
|
241 |
* @param afoundEntries the application entries which match
|
|
242 |
* the SQL query.
|
|
243 |
* @return an integer representing the number of rows written
|
|
244 |
* into the vector.
|
|
245 |
*/
|
|
246 |
int FillVectorwithMidpPackageTableData(java::storage::JavaStorageApplicationList_t& afoundEntries);
|
|
247 |
|
|
248 |
/**
|
|
249 |
* Utility function which fills the vector with data got from storage.
|
|
250 |
* Handles data of only MIDP_PERMISSIONS_TABLE.
|
|
251 |
*
|
|
252 |
* @param afoundEntries the application entries which match
|
|
253 |
* the SQL query.
|
|
254 |
* @return an integer representing the number of rows written
|
|
255 |
* into the vector.
|
|
256 |
*/
|
|
257 |
int FillVectorwithMidpPermTableData(java::storage::JavaStorageApplicationList_t& afoundEntries);
|
|
258 |
|
|
259 |
/**
|
|
260 |
* Utility function which fills the vector with data got from storage.
|
|
261 |
* Handles data of only MIDP_FUNCTION_GROUP_SETTINGS_TABLE.
|
|
262 |
*
|
|
263 |
* @param afoundEntries the application entries which match
|
|
264 |
* the SQL query.
|
|
265 |
* @return an integer representing the number of rows written
|
|
266 |
* into the vector.
|
|
267 |
*/
|
|
268 |
int FillVectorwithMidpFuncGrpSetTableData(java::storage::JavaStorageApplicationList_t& afoundEntries);
|
|
269 |
|
|
270 |
/**
|
|
271 |
* Utility function which fills the vector with data got from storage.
|
|
272 |
* Handles data of only PUSH_REGISTRATION_TABLE.
|
|
273 |
*
|
|
274 |
* @param afoundEntries the application entries which match
|
|
275 |
* the SQL query.
|
|
276 |
* @return an integer representing the number of rows written
|
|
277 |
* into the vector.
|
|
278 |
*/
|
|
279 |
int FillVectorwithPushRegTableData(java::storage::JavaStorageApplicationList_t& afoundEntries);
|
|
280 |
|
|
281 |
/**
|
|
282 |
* Utility function which fills the vector with data got from storage.
|
|
283 |
* Handles data of only ALARM_REGISTRATION_TABLE.
|
|
284 |
*
|
|
285 |
* @param afoundEntries the application entries which match
|
|
286 |
* the SQL query.
|
|
287 |
* @return an integer representing the number of rows written
|
|
288 |
* into the vector.
|
|
289 |
*/
|
|
290 |
int FillVectorwithAlarmRegTableData(java::storage::JavaStorageApplicationList_t& afoundEntries);
|
|
291 |
|
|
292 |
/**
|
|
293 |
* Utility function which fills the vector with data got from storage.
|
|
294 |
* Handles data of only RUNTIME_SETTINGS_TABLE.
|
|
295 |
*
|
|
296 |
* @param afoundEntries the application entries which match
|
|
297 |
* the SQL query.
|
|
298 |
* @return an integer representing the number of rows written
|
|
299 |
* into the vector.
|
|
300 |
*/
|
|
301 |
int FillVectorwithRuntimeSetTableData(java::storage::JavaStorageApplicationList_t& afoundEntries);
|
|
302 |
|
|
303 |
/**
|
|
304 |
* Utility function which fills the vector with data got from storage.
|
|
305 |
* Handles data of only PREINSTALL_TABLE.
|
|
306 |
*
|
|
307 |
* @param afoundEntries the application entries which match
|
|
308 |
* the SQL query.
|
|
309 |
* @return an integer representing the number of rows written
|
|
310 |
* into the vector.
|
|
311 |
*/
|
|
312 |
int FillVectorwithPreinstallTableData(java::storage::JavaStorageApplicationList_t& afoundEntries);
|
|
313 |
|
|
314 |
/**
|
|
315 |
* Utility function which fills the vector with data got from storage.
|
|
316 |
* Handles data of only OTA_STATUS_TABLE.
|
|
317 |
*
|
|
318 |
* @param afoundEntries the application entries which match
|
|
319 |
* the SQL query.
|
|
320 |
* @return an integer representing the number of rows written
|
|
321 |
* into the vector.
|
|
322 |
*/
|
|
323 |
int FillVectorwithOtaStatusTableData(java::storage::JavaStorageApplicationList_t& afoundEntries);
|
|
324 |
|
|
325 |
/**
|
|
326 |
* Prints the vectors
|
|
327 |
*/
|
|
328 |
void printVector();
|
|
329 |
|
|
330 |
private:
|
|
331 |
|
|
332 |
/**
|
|
333 |
* The actual wstring vector which holds the data during a B&R operation.
|
|
334 |
* During a backup, this vector is filled with storage data and then
|
|
335 |
* written to the stream.
|
|
336 |
* During a restore, this vector is filled with data from the stream
|
|
337 |
* before it is written to storage.
|
|
338 |
* Own
|
|
339 |
*/
|
|
340 |
std::vector< std::wstring > iStringVector;
|
|
341 |
|
|
342 |
/**
|
|
343 |
* An integer which holds the length of the string.
|
|
344 |
* When only half the data is read from the stream, this holds the
|
|
345 |
* length of the remaining data which is to be read.
|
|
346 |
* Own
|
|
347 |
*/
|
|
348 |
int iLenOfString;
|
|
349 |
|
|
350 |
/**
|
|
351 |
* An integer which holds the count of the number of strings
|
|
352 |
* in the vector. Used during a B&R operation.
|
|
353 |
* Own
|
|
354 |
*/
|
|
355 |
int iStrCount;
|
|
356 |
|
|
357 |
/**
|
|
358 |
* An integer array which holds the number of rows of each table
|
|
359 |
* present in storage.
|
|
360 |
* This information is written to stream and is used when the
|
|
361 |
* restored data is written back to storage.
|
|
362 |
* Own
|
|
363 |
*/
|
|
364 |
int iTableSize[NUMBER_OF_TABLES];
|
|
365 |
|
|
366 |
/**
|
|
367 |
* A Boolean value which says if a string was only
|
|
368 |
* half read during a previous iteration.
|
|
369 |
* Own
|
|
370 |
*/
|
|
371 |
TBool iRemainingString;
|
|
372 |
|
|
373 |
/**
|
|
374 |
* A wstring which holds the half read string so that the
|
|
375 |
* completed string can be appended to it during the next iteration
|
|
376 |
* before it is put into the vector.
|
|
377 |
* Own
|
|
378 |
*/
|
|
379 |
std::wstring iHalfReadString;
|
|
380 |
|
|
381 |
/**
|
|
382 |
* Shows if it's the fill call to backup storage data.
|
|
383 |
* Vectors filled only at the first call.
|
|
384 |
* Own
|
|
385 |
*/
|
|
386 |
TBool iFirstCalltoBackupStorageData;
|
|
387 |
|
|
388 |
/**
|
|
389 |
* Shows if it's the fill call to restore storage data.
|
|
390 |
* Own
|
|
391 |
*/
|
|
392 |
TBool iFirstCalltoRestoreStorageData;
|
|
393 |
|
|
394 |
/**
|
|
395 |
* Shows the remaining number of bytes available in the stream.
|
|
396 |
* Own
|
|
397 |
*/
|
|
398 |
int iBufferSpaceLeft;
|
|
399 |
};
|
|
400 |
|
|
401 |
} // namespace backup
|
|
402 |
} // namespace java
|
|
403 |
|
|
404 |
#endif // JAVASTORAGEBACKUPUTIL_H
|