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: Java platform 2.0 javaapppreconverter process |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef MIDLETLIST_H |
|
20 #define MIDLETLIST_H |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <f32file.h> |
|
24 #include <s32strm.h> |
|
25 #include <s32file.h> |
|
26 |
|
27 _LIT(KMidletExportDataFileName, "omjconvertedapps.dat"); |
|
28 |
|
29 |
|
30 /*! |
|
31 @class CMidletInfo |
|
32 |
|
33 @discussion Contains necessary information about one MIDlet. |
|
34 Information enables reregistering the MIDlet to AppArc |
|
35 */ |
|
36 class CMidletInfo : public CBase |
|
37 { |
|
38 public: |
|
39 /*! |
|
40 @function CMidletInfo |
|
41 |
|
42 @discussion Construct object. Construction cannot leave so can be done in one phase. |
|
43 */ |
|
44 CMidletInfo(); |
|
45 |
|
46 /*! |
|
47 @function CMidletInfo |
|
48 |
|
49 @discussion Construct object and initialize all values to values read from |
|
50 aMidletInfo |
|
51 Construction cannot leave so can be done in one phase. |
|
52 @param aMidletInfo the contents of this midlet info will be copied to |
|
53 the new midlet info |
|
54 */ |
|
55 CMidletInfo(CMidletInfo* aMidletInfo); |
|
56 |
|
57 /*! |
|
58 @function CMidletInfo |
|
59 |
|
60 @discussion Destroy the object and release all memory objects |
|
61 */ |
|
62 ~CMidletInfo(); |
|
63 |
|
64 |
|
65 /*! |
|
66 @function GetMidletUid |
|
67 |
|
68 @discussion get midlet uid |
|
69 @result midlet uid |
|
70 */ |
|
71 TUid GetMidletUid() const; |
|
72 |
|
73 /*! |
|
74 @function GetMidletId |
|
75 |
|
76 @discussion get midlet id |
|
77 @result midlet id |
|
78 */ |
|
79 TUint32 GetMidletId() const; |
|
80 |
|
81 /*! |
|
82 @function GetSuiteId |
|
83 |
|
84 @discussion get suite id |
|
85 @result suite id |
|
86 */ |
|
87 TUint32 GetSuiteId() const; |
|
88 |
|
89 /*! |
|
90 @function GetMidletName |
|
91 |
|
92 @discussion get midlet name |
|
93 @result Midlet name |
|
94 */ |
|
95 const TDesC& GetMidletName(); |
|
96 |
|
97 /*! |
|
98 @function GetGroupName |
|
99 |
|
100 @discussion get midlet group name |
|
101 @result group name |
|
102 */ |
|
103 const TDesC& GetGroupName(); |
|
104 |
|
105 /*! |
|
106 @function GetDrive |
|
107 |
|
108 @discussion get drive |
|
109 @result drive |
|
110 */ |
|
111 TDriveNumber GetDrive(); |
|
112 |
|
113 /*! |
|
114 @function GetIconFileName |
|
115 |
|
116 @discussion get full path name of the icon file |
|
117 @result path name to icon file |
|
118 */ |
|
119 const TFileName& GetIconFileName(); |
|
120 |
|
121 |
|
122 |
|
123 |
|
124 /*! |
|
125 @function SetMidletUid |
|
126 |
|
127 @discussion set midlet uid |
|
128 @param midlet uid |
|
129 */ |
|
130 void SetMidletUid(const TUid aUid); |
|
131 |
|
132 /*! |
|
133 @function SetMidletId |
|
134 |
|
135 @discussion set midlet id |
|
136 @param midlet id |
|
137 */ |
|
138 void SetMidletId(const TUint32 aId); |
|
139 |
|
140 /*! |
|
141 @function SetSuiteId |
|
142 |
|
143 @discussion set suite id |
|
144 @param suite id |
|
145 */ |
|
146 void SetSuiteId(const TUint32 aId); |
|
147 |
|
148 /*! |
|
149 @function SetMidletName |
|
150 |
|
151 @discussion Set midlet name |
|
152 @param aName Midlet name |
|
153 */ |
|
154 void SetMidletName(const TDesC& aName); |
|
155 |
|
156 /*! |
|
157 @function SetGroupName |
|
158 |
|
159 @discussion Set group name |
|
160 @param aName Group name |
|
161 */ |
|
162 void SetGroupName(const TDesC& aName); |
|
163 |
|
164 /*! |
|
165 @function SetDrive |
|
166 |
|
167 @discussion Set drive where midlet suite is |
|
168 @param aDrive |
|
169 */ |
|
170 void SetDrive(const TDriveNumber aDrive); |
|
171 |
|
172 /*! |
|
173 @function SetIconFileName |
|
174 |
|
175 @discussion setIconFileName |
|
176 @param aIconFileName |
|
177 */ |
|
178 void SetIconFileName(HBufC16 *aIconFileName); |
|
179 |
|
180 /*! |
|
181 @function SetIconFileName |
|
182 |
|
183 @discussion setIconFileName |
|
184 @param aIconFileName |
|
185 */ |
|
186 void SetIconFileName(const TFileName &aIconFileName); |
|
187 |
|
188 /*! |
|
189 @function ExternalizeL |
|
190 |
|
191 @discussion ExternalizeL |
|
192 @param aStream |
|
193 */ |
|
194 void ExternalizeL(RWriteStream& aStream) const; |
|
195 |
|
196 /*! |
|
197 @function InternalizeL |
|
198 |
|
199 @discussion InternalizeL |
|
200 @param aStream |
|
201 */ |
|
202 void InternalizeL(RReadStream& aStream); |
|
203 |
|
204 /*! |
|
205 @function ToString8 |
|
206 |
|
207 @discussion Store the printable representation to aDescription |
|
208 @param aDescription the length of the descriptor should be at least 512 |
|
209 */ |
|
210 void ToString8(TDes8& aDescription); |
|
211 |
|
212 |
|
213 |
|
214 private: |
|
215 /*! @var iMidletUid Midlet Uid */ |
|
216 TUid iMidletUid; |
|
217 |
|
218 /*! @var iMidletId Midlet System AMS Id */ |
|
219 TUint32 iMidletId; |
|
220 |
|
221 /*! @var iSuiteId Midlet suite System AMS Id */ |
|
222 TUint32 iSuiteId; |
|
223 |
|
224 /*! |
|
225 @var iMidletName |
|
226 */ |
|
227 HBufC16 *iMidletName; |
|
228 |
|
229 /*! |
|
230 @var iGroupName |
|
231 */ |
|
232 HBufC16 *iGroupName; |
|
233 |
|
234 /*! |
|
235 @var iDrive the drive where the Midlet files are located, usually E: |
|
236 */ |
|
237 TDriveNumber iDrive; |
|
238 |
|
239 /*! |
|
240 @var iIconFileName full icon file path name |
|
241 */ |
|
242 TFileName iIconFileName; |
|
243 |
|
244 }; |
|
245 |
|
246 |
|
247 |
|
248 |
|
249 |
|
250 /* ---------------------------------------------------------------------------- */ |
|
251 |
|
252 |
|
253 |
|
254 |
|
255 |
|
256 |
|
257 /*! |
|
258 @class CMidletList |
|
259 |
|
260 @discussion List of MIDlets. Contains all MIDlets to be converted. |
|
261 */ |
|
262 class CMidletList : public CBase |
|
263 { |
|
264 public: |
|
265 |
|
266 /*! |
|
267 @function CMidletList |
|
268 |
|
269 @discussion Construct object. Construction cannot leave so can be done in one phase. |
|
270 */ |
|
271 CMidletList(); |
|
272 |
|
273 |
|
274 /*! |
|
275 @function ~CMidletList |
|
276 |
|
277 @discussion Destroy the object but do not destroy objects in list |
|
278 */ |
|
279 ~CMidletList(); |
|
280 |
|
281 |
|
282 /*! |
|
283 @function ResetAndDestroy |
|
284 |
|
285 @discussion Empty the list and destroy objects in it. |
|
286 */ |
|
287 void ResetAndDestroy(); |
|
288 |
|
289 /*! |
|
290 @function Append |
|
291 |
|
292 @discussion append midlet info object to list. Note that each midlet can be |
|
293 in list only once. Adding already existing midlet does nothing (return KErrNone). |
|
294 Midlets are identified by midlet Uids. |
|
295 @param aMidletInfo pointer to suite info to be added |
|
296 @result KErrNone, if the insertion is successful, otherwise one of the system wide error codes |
|
297 */ |
|
298 TInt Append(const CMidletInfo* aMidletInfo); |
|
299 |
|
300 /*! |
|
301 @function Remove |
|
302 |
|
303 @discussion remove midletInfo object from list if the object is there |
|
304 Note that the function does not delete the object whose pointer is removed. |
|
305 @param aSuiteInfo pointer to midlet info to be removed. |
|
306 */ |
|
307 void Remove(const CMidletInfo* aMidletInfo); |
|
308 |
|
309 /*! |
|
310 @function count |
|
311 |
|
312 @discussion count return the number of midlets in the list |
|
313 @result the number of midlets in the list |
|
314 */ |
|
315 TInt Count() const; |
|
316 |
|
317 /*! |
|
318 @function getFirst |
|
319 |
|
320 @discussion get the first midlet info in list |
|
321 @result pointer to the first object or NULL if list is empty |
|
322 */ |
|
323 CMidletInfo* GetFirst(); |
|
324 |
|
325 /*! |
|
326 @function GetNext |
|
327 |
|
328 @discussion get the next midlet info in list (works also when remove is called) |
|
329 @result pointer to the next object in list or NULL if no more objects |
|
330 */ |
|
331 CMidletInfo* GetNext(); |
|
332 |
|
333 /*! |
|
334 @function Find |
|
335 |
|
336 @discussion find midletInfo object in list based on midlet Uid |
|
337 @param aMidletUid the Uid of the midlet to be returned |
|
338 @result Pointer to the midlet with the specififed Uid or NULL if none was found |
|
339 */ |
|
340 CMidletInfo* Find(const TUid aMidletUid); |
|
341 |
|
342 /*! |
|
343 @function Find |
|
344 |
|
345 @discussion find midletInfo object in list based on midlet name |
|
346 @param aName the name of the midlet to be returned |
|
347 @result Pointer to the midlet with the specififed Uid or NULL if none was found |
|
348 */ |
|
349 CMidletInfo* Find(const TPtrC &aName); |
|
350 |
|
351 /*! |
|
352 @function SetIds |
|
353 |
|
354 @discussion If list contains midlet specified with aUid, sets the midlet suite id of |
|
355 midlet to aMidletSuiteId and midlet id to aMidletId. |
|
356 If the list does not contain midlet with specified Uid, does nothing. |
|
357 @param aUid the Uid (in TUint32 form) of the midlet |
|
358 @param aMidletSuiteId the System AMS id of midlet suite |
|
359 @param aMidletId the System AMS id of the midlet |
|
360 (== the ordinal of the midlet inside midlet suite) |
|
361 */ |
|
362 void SetIds(const TUint32 aUid, const TUint32 aMidletSuiteId, const TUint32 aMidletId); |
|
363 |
|
364 /*! |
|
365 @function SetIds |
|
366 |
|
367 @discussion If list contains midlet specified with aName, sets the midlet suite id of |
|
368 midlet to aMidletSuiteId and midlet id to aMidletId. |
|
369 If the list does not contain midlet with specified name, does nothing. |
|
370 @param aName the name of the midlet |
|
371 @param aMidletSuiteId the System AMS id of midlet suite |
|
372 @param aMidletId the System AMS id of the midlet |
|
373 (== the ordinal of the midlet inside midlet suite) |
|
374 */ |
|
375 void SetIds(const TPtrC &aName, const TUint32 aMidletSuiteId, const TUint32 aMidletId); |
|
376 |
|
377 /*! |
|
378 @function ExportList |
|
379 |
|
380 @discussion Stores all information in the list to the directory given in aDirectory. |
|
381 First copies all icon files specified in the midlet entries to aDirectory and |
|
382 changes each midlet entry so that midlet entry .iIconFileName points to the copy |
|
383 of the icon file in aDirectory. |
|
384 Then stores all midlet entries to aDirectory (serializes information to a file). |
|
385 In case of fatal error leaves with standard Symbian error code. |
|
386 @param aFs file server handle |
|
387 @param aDirectory full path name to an empty directory |
|
388 */ |
|
389 void ExportListL(RFs& aFs, const TFileName &aDirectory); |
|
390 |
|
391 |
|
392 /*! |
|
393 @function ImportList |
|
394 |
|
395 @discussion Read all information in the list from the directory given in aDirectory. |
|
396 The list should be empty when this function is called. |
|
397 Reads all midlet entries from a data file in aDirectory. |
|
398 The information to be read has been created earlier by calling ExportList(). |
|
399 In case of fatal error leaves with standard Symbian error code. |
|
400 @param aFs file server handle |
|
401 @param aDirectory full path name to a directory filled by calling ExportList(). |
|
402 */ |
|
403 void ImportListL(RFs& aFs, const TFileName &aDirectory); |
|
404 |
|
405 |
|
406 |
|
407 |
|
408 private: |
|
409 /*! @var iMidletArray dynamical array of midlets */ |
|
410 RPointerArray<CMidletInfo> iMidletArray; |
|
411 |
|
412 /*! @var iGetNextIndex index of the next object to be returned by getNext() */ |
|
413 TInt iGetNextIndex; |
|
414 |
|
415 /*! @var iMidletArrayDestroyed ETrue after resetAndDestroy has been called */ |
|
416 TBool iMidletArrayDestroyed; |
|
417 |
|
418 }; |
|
419 |
|
420 |
|
421 #endif // MIDLETLIST_H |
|
422 |
|