FreeCalypso > hg > fc-magnetite
comparison src/aci2/bmi/MmiWapFfs.c @ 3:93999a60b835
src/aci2, src/condat2: import of g23m/condat source pieces from TCS211
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 26 Sep 2016 00:29:36 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
2:c41a534f33c6 | 3:93999a60b835 |
---|---|
1 /******************************************************************************* | |
2 | |
3 CONDAT (UK) | |
4 | |
5 ******************************************************************************** | |
6 | |
7 This software product is the property of Condat (UK) Ltd and may not be | |
8 disclosed to any third party without the express permission of the owner. | |
9 | |
10 ******************************************************************************** | |
11 | |
12 $Project name: | |
13 $Project code: | |
14 $Module: | |
15 $File: MmiWapFfs.c | |
16 $Revision: | |
17 | |
18 $Author: Condat(UK) | |
19 $Date: | |
20 | |
21 ******************************************************************************** | |
22 | |
23 Description: | |
24 Flash handling for WAP. | |
25 | |
26 ******************************************************************************** | |
27 | |
28 $History: MmiWapFfs.c | |
29 | |
30 May 11 2005 REF: MMI-SPR-29887 x0012849 | |
31 To Implement the deferred MMS retrieval. | |
32 15/05/2003 - SPR#1983 - SH - Updated to latest from 1.6.3 version. | |
33 | |
34 $End | |
35 | |
36 *******************************************************************************/ | |
37 | |
38 #define ENTITY_MFW | |
39 | |
40 #include <stdio.h> | |
41 #include <string.h> | |
42 #include <stdlib.h> | |
43 | |
44 #if defined (NEW_FRAME) | |
45 | |
46 #include "typedefs.h" | |
47 #include "vsi.h" | |
48 #include "pei.h" | |
49 #include "custom.h" | |
50 #include "gsm.h" | |
51 | |
52 #else | |
53 | |
54 #include "STDDEFS.H" | |
55 #include "custom.h" | |
56 #include "gsm.h" | |
57 #include "vsi.h" | |
58 | |
59 #endif | |
60 | |
61 | |
62 #include "custom.h" | |
63 #include "gsm.h" | |
64 #include "vsi.h" | |
65 | |
66 #include "mfw_sys.h" | |
67 #include "prim.h" | |
68 | |
69 #include "vsi.h" | |
70 | |
71 #include "mfw_mfw.h" | |
72 #include "mfw_win.h" | |
73 | |
74 #include "mfw_kbd.h" | |
75 #ifndef NEW_EDITOR | |
76 #include "mfw_edt.h" | |
77 #endif | |
78 #include "mfw_lng.h" | |
79 #include "mfw_tim.h" | |
80 #include "mfw_icn.h" | |
81 #include "mfw_mnu.h" | |
82 #include "mfw_phb.h" | |
83 #include "mfw_cm.h" | |
84 #include "mfw_sim.h" | |
85 #include "mfw_nm.h" | |
86 #include "mfw_phb.h" | |
87 #include "ksd.h" | |
88 #include "psa.h" | |
89 #include "mfw_sms.h" | |
90 #include "mfw_sat.h" | |
91 | |
92 #include "mfw_ffs.h" | |
93 | |
94 #include "dspl.h" | |
95 | |
96 #include "gdi.h" | |
97 | |
98 #include "MmiMmi.h" | |
99 #include "MmiDummy.h" | |
100 #include "MmiDialogs.h" | |
101 #include "MmiLists.h" | |
102 | |
103 #include "MmiSoftKeys.h" | |
104 #include "Mmiicons.h" | |
105 #include "MmiMenu.h" | |
106 #include "MmiMain.h" | |
107 #include "MmiIdle.h" | |
108 #include "MmiStart.h" | |
109 #include "MmiPins.h" | |
110 #include "MmiSounds.h" | |
111 #include "audio.h" | |
112 #include "cus_aci.h" | |
113 | |
114 #include "MmiWapFfs.h" | |
115 | |
116 #ifndef PCm_2_FFS | |
117 #include "ffs_coat.h" | |
118 #endif | |
119 | |
120 #define hCommACI _ENTITY_PREFIXED(hCommACI) | |
121 | |
122 #if defined (NEW_FRAME) | |
123 EXTERN T_HANDLE hCommACI; | |
124 #else | |
125 EXTERN T_VSI_CHANDLE hCommACI; | |
126 #endif | |
127 #define hCommMMI hCommACI | |
128 | |
129 | |
130 /* WAP data stored in two files */ | |
131 | |
132 FlashDataWap *WapData; | |
133 FlashDataWapProfiles *WapProfilesData; | |
134 #ifdef FF_MMI_MMS | |
135 FlashDataMmsProfiles *MmsProfilesData; | |
136 // May 11 2005 REF: MMI-SPR-29887 x0012849 | |
137 // MmsRetrievalType is used while Reading or writing Data from flash regarding retrieval type. | |
138 FlashDataMmsRetrievalType *MmsRetrievalType; | |
139 #endif | |
140 | |
141 | |
142 /************************************************************************* | |
143 * flash_wap_init() | |
144 * | |
145 * Init function for WAP flash file. | |
146 * If the 'tmp' directory does not exist, create it. | |
147 * If it does exist, and there is a copy of wapdata in 'tmp' directory, it is removed. | |
148 * | |
149 *************************************************************************/ | |
150 | |
151 T_FFS_RET flash_wap_init() | |
152 { | |
153 T_FFS_RET result; | |
154 T_FFS_STAT stat; | |
155 | |
156 TRACE_FUNCTION("flash_wap_init()"); | |
157 | |
158 /* Check if wapdata file exists and is correct size | |
159 * If the size of the WAP data changes or it is corrupted, it is deleted | |
160 * so a new file can be written in its place later. */ | |
161 | |
162 result = ffs_stat("/mmi/wapdata", &stat); | |
163 | |
164 TRACE_EVENT_P1("ffs_stat wapdata, result = %d", result); | |
165 | |
166 if (result==EFFS_OK) | |
167 { | |
168 if (stat.size==sizeof(FlashDataWap)) | |
169 { | |
170 TRACE_EVENT("wapdata found OK & is correct size"); | |
171 } | |
172 } | |
173 | |
174 /* Try to reconstruct intact file, in case of interrupted | |
175 * save operation */ | |
176 | |
177 else | |
178 { | |
179 result = ffs_stat("/mmi/wapdata.zzz",&stat); | |
180 TRACE_EVENT_P1("ffs_stat wapdata.zzz', result = %d", result); | |
181 | |
182 if (result==EFFS_OK) | |
183 { | |
184 if (stat.size==sizeof(FlashDataWap)) | |
185 { | |
186 TRACE_EVENT("wapdata.zzz found OK & is correct size"); | |
187 result = ffs_rename("/mmi/wapdata", "/mmi/wapdata.zzz"); | |
188 TRACE_EVENT_P1("rename '/mmi/wapdata' to '/mmi/wapdata.zzz': result %d", result); | |
189 } | |
190 else | |
191 { | |
192 TRACE_EVENT("wapdata.zzz found, but size is incorrect"); | |
193 } | |
194 } | |
195 else | |
196 { | |
197 TRACE_EVENT("wapdata.zzz not found."); | |
198 } | |
199 } | |
200 | |
201 /* WAP PROFILES */ | |
202 | |
203 /* Check if wapprof file exists and is correct size */ | |
204 | |
205 result = ffs_stat("/mmi/wapprof", &stat); | |
206 | |
207 TRACE_EVENT_P1("ffs_stat wapprof, result = %d", result); | |
208 | |
209 if (result==EFFS_OK) | |
210 { | |
211 if (stat.size==sizeof(FlashDataWapProfiles)) | |
212 { | |
213 TRACE_EVENT("wapprof found OK & is correct size"); | |
214 } | |
215 } | |
216 | |
217 /* Try to reconstruct intact file, in case of interrupted | |
218 * save operation */ | |
219 | |
220 else | |
221 { | |
222 result = ffs_stat("/mmi/wapprof.zzz",&stat); | |
223 TRACE_EVENT_P1("ffs_stat wapprof.zzz', result = %d", result); | |
224 | |
225 if (result==EFFS_OK) | |
226 { | |
227 if (stat.size==sizeof(FlashDataWapProfiles)) | |
228 { | |
229 TRACE_EVENT("waprof.zzz found OK & is correct size"); | |
230 result = ffs_rename("/mmi/wapprof", "/mmi/wapprof.zzz"); | |
231 TRACE_EVENT_P1("rename '/mmi/wapprof' to '/mmi/wapprof.zzz': result %d", result); | |
232 } | |
233 else | |
234 { | |
235 TRACE_EVENT("wapprof.zzz found, but size is incorrect"); | |
236 } | |
237 } | |
238 else | |
239 { | |
240 TRACE_EVENT("wapprof.zzz not found."); | |
241 } | |
242 } | |
243 | |
244 return result; | |
245 } | |
246 | |
247 | |
248 /************************************************************************* | |
249 * flash_wap_write() | |
250 * | |
251 * Write WAP data to file. | |
252 * | |
253 *************************************************************************/ | |
254 | |
255 T_FFS_RET flash_wap_write() | |
256 { | |
257 T_FFS_RET result; | |
258 | |
259 /* Procedure to minimise data corruption */ | |
260 | |
261 /* WAP Data File */ | |
262 | |
263 result = ffs_file_write("/mmi/wapdata.zzz", WapData, sizeof(FlashDataWap), FFS_O_TRUNC | FFS_O_CREATE); | |
264 TRACE_EVENT_P1("write '/mmi/wapdata.zzz': result %d", result); | |
265 | |
266 if (result!=EFFS_OK) | |
267 { | |
268 TRACE_EVENT("** ERROR WRITING FILE **"); | |
269 return; | |
270 } | |
271 | |
272 result = ffs_remove("/mmi/wapdata"); | |
273 TRACE_EVENT_P1("remove '/mmi/wapdata': result %d", result); | |
274 | |
275 if (result!=EFFS_OK) | |
276 { | |
277 TRACE_EVENT("/mmi/wapdata does not exist yet"); | |
278 } | |
279 | |
280 result = ffs_rename("/mmi/wapdata.zzz", "/mmi/wapdata"); | |
281 TRACE_EVENT_P1("rename '/mmi/wapdata.zzz' to '/mmi/wapdata': result %d", result); | |
282 | |
283 if (result!=EFFS_OK) | |
284 { | |
285 if (result==EFFS_NOTFOUND) | |
286 { | |
287 TRACE_EVENT("mmi/wapdata.zzz doesn't exist"); | |
288 } | |
289 else | |
290 { | |
291 TRACE_EVENT("** ERROR RENAMING FILE **"); | |
292 } | |
293 } | |
294 | |
295 /* WAP Profiles File */ | |
296 | |
297 result = ffs_file_write("/mmi/wapprof.zzz", WapProfilesData, sizeof(FlashDataWapProfiles), FFS_O_TRUNC | FFS_O_CREATE); | |
298 TRACE_EVENT_P1("write '/mmi/wapprof.zzz': result %d", result); | |
299 | |
300 if (result!=EFFS_OK) | |
301 { | |
302 TRACE_EVENT("** ERROR WRITING FILE **"); | |
303 return; | |
304 } | |
305 | |
306 result = ffs_remove("/mmi/wapprof"); | |
307 TRACE_EVENT_P1("remove '/mmi/wapprof': result %d", result); | |
308 | |
309 if (result!=EFFS_OK) | |
310 { | |
311 TRACE_EVENT("/mmi/wapprof does not exist yet"); | |
312 } | |
313 | |
314 result = ffs_rename("/mmi/wapprof.zzz", "/mmi/wapprof"); | |
315 TRACE_EVENT_P1("rename '/mmi/wapprof.zzz' to '/mmi/wapprof': result %d", result); | |
316 | |
317 if (result!=EFFS_OK) | |
318 { | |
319 if (result==EFFS_NOTFOUND) | |
320 { | |
321 TRACE_EVENT("mmi/wapprof doesn't exist"); | |
322 } | |
323 else | |
324 { | |
325 TRACE_EVENT("** ERROR RENAMING FILE **"); | |
326 } | |
327 } | |
328 | |
329 return; | |
330 } | |
331 | |
332 /************************************************************************* | |
333 * flash_wap_read() | |
334 * | |
335 * Read WAP data from file. | |
336 * | |
337 *************************************************************************/ | |
338 | |
339 T_FFS_SIZE flash_wap_read() | |
340 { | |
341 T_FFS_RET result; | |
342 T_FFS_STAT stat; | |
343 T_FFS_SIZE size; | |
344 | |
345 /* Read two files. If either file is of the wrong size, return 0 */ | |
346 | |
347 /* WAP Data File */ | |
348 | |
349 /* Check if wapdata file exists and is correct size */ | |
350 | |
351 result = ffs_stat("/mmi/wapdata", &stat); | |
352 | |
353 if (result!=EFFS_OK || stat.size!=sizeof(FlashDataWap)) | |
354 { | |
355 TRACE_EVENT("mmi/wapdata does not exist or is not correct size"); | |
356 return 0; | |
357 } | |
358 | |
359 /* Read the file */ | |
360 | |
361 size = ffs_file_read("/mmi/wapdata", WapData, sizeof(FlashDataWap)); | |
362 TRACE_EVENT_P1("Read 'mmi/wapdata': result %d", size); | |
363 | |
364 /* WAP Profiles File */ | |
365 | |
366 /* Check if wapprof file exists and is correct size */ | |
367 | |
368 result = ffs_stat("/mmi/wapprof", &stat); | |
369 | |
370 if (result!=EFFS_OK || stat.size!=sizeof(FlashDataWapProfiles)) | |
371 { | |
372 TRACE_EVENT("mmi/wapprof does not exist or is not correct size"); | |
373 return 0; | |
374 } | |
375 | |
376 /* Read the file */ | |
377 | |
378 size = ffs_file_read("/mmi/wapprof", WapProfilesData, sizeof(FlashDataWapProfiles)); | |
379 TRACE_EVENT_P1("Read 'mmi/wapprof': result %d", size); | |
380 | |
381 return size; | |
382 } | |
383 | |
384 #ifdef FF_MMI_MMS | |
385 //TISHMMS Project begin | |
386 | |
387 // May 11 2005 REF: MMI-SPR-29887 x0012849 | |
388 /******************************************************************************* | |
389 $Function: flash_mms_retrieval_type_read | |
390 $Description: This function is called when user wants to know the status of the Retrieval Type | |
391 and each a time MMS is recieved . | |
392 $Returns: Result of the rename file operation | |
393 $Arguments: RetrievalType - 0- For Immediate & 1 for Deferred | |
394 *******************************************************************************/ | |
395 | |
396 T_FFS_SIZE flash_mms_retrieval_type_read(BOOL *RetrievalType) | |
397 { | |
398 | |
399 T_FFS_RET result; | |
400 T_FFS_STAT stat; | |
401 T_FFS_SIZE size; | |
402 | |
403 /* Check if mmsretieval file exists and is correct size */ | |
404 | |
405 result = ffs_stat("/mmi/mmsretrieval", &stat); | |
406 | |
407 if (result!=EFFS_OK || stat.size!=sizeof(FlashDataMmsRetrievalType)) | |
408 { | |
409 TRACE_EVENT("mmi/mmsretrieval does not exist or is not correct size"); | |
410 return 0; | |
411 } | |
412 | |
413 /* Read the file */ | |
414 size = ffs_file_read("/mmi/mmsretrieval", MmsRetrievalType, sizeof(FlashDataMmsRetrievalType)); | |
415 *RetrievalType = MmsRetrievalType ->retrieval_type; | |
416 TRACE_EVENT_P1("Read 'mmi/mmsretrieval ': result %d", size); | |
417 | |
418 return size; | |
419 }/* end of flash_mms_retrieval_type_read*/ | |
420 | |
421 // May 11 2005 REF: MMI-SPR-29887 x0012849 | |
422 /******************************************************************************* | |
423 $Function: flash_mms_retrieval_type_write | |
424 | |
425 $Description: This function is called when user wants to set the Retrieval condition of MMS. | |
426 $Returns: Result of the rename file operation | |
427 $Arguments: RetrievalType - 0- For Immediate & 1 for Deferred | |
428 *******************************************************************************/ | |
429 | |
430 T_FFS_RET flash_mms_retrieval_type_write(BOOL RetrievalType) | |
431 { | |
432 T_FFS_RET result; | |
433 | |
434 MmsRetrievalType->retrieval_type=RetrievalType; | |
435 result = ffs_file_write("/mmi/mmsretrieval.zzz", MmsRetrievalType, sizeof(FlashDataMmsRetrievalType), FFS_O_TRUNC | FFS_O_CREATE); | |
436 TRACE_EVENT_P1("write '/mmi/mmsretrieval.zzz': result %d", result); | |
437 | |
438 if (result!=EFFS_OK) | |
439 { | |
440 TRACE_EVENT("** ERROR WRITING FILE **"); | |
441 return result; | |
442 } | |
443 | |
444 result = ffs_remove("/mmi/mmsretrieval"); | |
445 TRACE_EVENT_P1("remove '/mmi/mmsretrieval': result %d", result); | |
446 | |
447 if (result!=EFFS_OK) | |
448 { | |
449 TRACE_EVENT("/mmi/mmsretrieval does not exist yet"); | |
450 } | |
451 | |
452 result = ffs_rename("/mmi/mmsretrieval.zzz", "/mmi/mmsretrieval"); | |
453 TRACE_EVENT_P1("rename '/mmi/mmsretrieval.zzz' to '/mmi/mmsretrieval': result %d", result); | |
454 | |
455 if (result!=EFFS_OK) | |
456 { | |
457 if (EFFS_NOTFOUND == result) | |
458 { | |
459 TRACE_EVENT("mmi/mmsretrieval doesn't exist"); | |
460 } | |
461 else | |
462 { | |
463 TRACE_EVENT("** ERROR RENAMING FILE **"); | |
464 } | |
465 } | |
466 | |
467 return result; | |
468 }/* end of flash_mms_retrieval_type_write */ | |
469 | |
470 T_FFS_SIZE flash_mms_read() | |
471 { | |
472 | |
473 T_FFS_RET result; | |
474 T_FFS_STAT stat; | |
475 T_FFS_SIZE size; | |
476 | |
477 /* Check if mmsprof file exists and is correct size */ | |
478 | |
479 result = ffs_stat("/mmi/mmsprof", &stat); | |
480 | |
481 if (result!=EFFS_OK || stat.size!=sizeof(FlashDataMmsProfiles)) | |
482 { | |
483 TRACE_EVENT("mmi/mmsprof does not exist or is not correct size"); | |
484 return 0; | |
485 } | |
486 | |
487 /* Read the file */ | |
488 size = ffs_file_read("/mmi/mmsprof", MmsProfilesData, sizeof(FlashDataMmsProfiles)); | |
489 TRACE_EVENT_P1("Read 'mmi/mmsprof': result %d", size); | |
490 | |
491 return size; | |
492 }/* end of flash_mms_read */ | |
493 | |
494 T_FFS_RET flash_mms_write() | |
495 { | |
496 T_FFS_RET result; | |
497 | |
498 /* MMS Profiles File */ | |
499 | |
500 result = ffs_file_write("/mmi/mmsprof.zzz", MmsProfilesData, sizeof(FlashDataMmsProfiles), FFS_O_TRUNC | FFS_O_CREATE); | |
501 TRACE_EVENT_P1("write '/mmi/mmsprof.zzz': result %d", result); | |
502 | |
503 if (result!=EFFS_OK) | |
504 { | |
505 TRACE_EVENT("** ERROR WRITING FILE **"); | |
506 return; | |
507 } | |
508 | |
509 result = ffs_remove("/mmi/mmsprof"); | |
510 TRACE_EVENT_P1("remove '/mmi/mmsprof': result %d", result); | |
511 | |
512 if (result!=EFFS_OK) | |
513 { | |
514 TRACE_EVENT("/mmi/mmsprof does not exist yet"); | |
515 } | |
516 | |
517 result = ffs_rename("/mmi/mmsprof.zzz", "/mmi/mmsprof"); | |
518 TRACE_EVENT_P1("rename '/mmi/mmsprof.zzz' to '/mmi/mmsprof': result %d", result); | |
519 | |
520 if (result!=EFFS_OK) | |
521 { | |
522 if (result==EFFS_NOTFOUND) | |
523 { | |
524 TRACE_EVENT("mmi/mmsprof doesn't exist"); | |
525 } | |
526 else | |
527 { | |
528 TRACE_EVENT("** ERROR RENAMING FILE **"); | |
529 } | |
530 } | |
531 | |
532 return; | |
533 }/* end of flash_mms_write */ | |
534 //TISHMMS Project | |
535 //modification end | |
536 #endif |