comparison src/ui3/mfw/mfw_ffs.c @ 420:e8ddbb0837ed

src/ui3: initial import of TCS3/LoCosto BMI & MFW code
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 21 Jan 2018 03:09:00 +0000
parents
children
comparison
equal deleted inserted replaced
419:59143cd42ec7 420:e8ddbb0837ed
1 /*
2 +--------------------------------------------------------------------+
3 | PROJECT: MMI-Framework (8417) $Workfile:: mfw_ffs.c $|
4 | $Author:: $Revision:: 1 $|
5 | CREATED: $Modtime:: $|
6 | STATE : code |
7 +--------------------------------------------------------------------+
8
9 MODULE : mfw_ffs
10
11 PURPOSE : This module contains FFS Interface functions.
12
13 HISTORY:
14
15 Feb 19 2007, x0061088(Prachi) LOCOSTO-DRT-OMAPS00112518
16 Description:Can't access Fileviewer when too many pictures has been taken
17 (no space in FFS). After taking maximum snapshot(up to out of memory) cant access
18 ETM . ETM shows error "Maximum open file reached"
19 Solution: As the relience flag is enabled, to solve this issue, function Flash_formatted()
20 is now checking the return value of ffs_opendir() to close the mmi/ directory properly.
21 Also MMI is calling mfw_close_dir() to close mmi/jpeg/ directory while exiting from camera
22 application.
23
24
25 Jan 10, 2007 DR: OMAPS00110568 x0039928
26 Description: Remove duplication of FFS.Flashdata from GDI
27 Solution: Added two new functions get_ffs_tty_status() and get_ffs_ttypftype()
28
29 Nov 07, 2006 ER: OMAPS00102732 x0pleela
30 Description: FFS Support for Intel Sibley Flash - Intel 256+64 non-ADMUX (PF38F4050M0Y0C0Q)
31 Solution: Closing the opened directory if readdir is not successful and the new code
32 is under the compilation flag FF_MMI_RELIANCE_FFS
33
34 Sep 08, 2006 DR: OMAPS00091250 x0pleela
35 Description:The phone resets if no MEPD data is presented
36 Solution: Added new function ffs_flash_write() which writes a string into FFS
37
38 xrashmic 22 Aug, 2004 MMI-SPR-32798
39 Adding the support for screen capture using a dynamically assigned key.
40
41 Apr 14, 2005 REF: CRR 29991 xpradipg
42 Description: Optimisation 5: Remove the static allocation and use dynamic
43 allocation/ deallocation for pb_list and black_list
44 Solution: The static definition is removed and replaced with the dynamic
45 allocation
46
47 Oct 19, 2004 REF: CRR MMI-SPR-26002 xkundadu
48 Issue description: Golite booting problem.
49 Solution: If the FFS is not formatted, prevent writing into FFS.
50
51 Aug 25, 2004 REF: CRR 20655 xnkulkar
52 Description: Voice Memo functionality not working
53 Solution: The voice recording functionality was failing because
54 " mmi" folder is not present. As a solution, we create the
55 "mmi" folder and then proceed with recording.
56 */
57
58 #define ENTITY_MFW
59
60 #include <stdio.h>
61 #include <string.h>
62 #include <stdlib.h>
63
64 #if defined (NEW_FRAME)
65
66 #include "typedefs.h"
67 #include "vsi.h"
68 #include "pei.h"
69 #include "custom.h"
70 #include "gsm.h"
71
72 #else
73
74 #include "STDDEFS.H"
75 #include "custom.h"
76 #include "gsm.h"
77 #include "vsi.h"
78
79 #endif
80
81 #include "prim.h"
82
83 #include "custom.h"
84 #include "gsm.h"
85 #include "vsi.h"
86
87 #include "mfw_sys.h"
88 #include "prim.h"
89
90 #include "vsi.h"
91
92 #include "mfw_mfw.h"
93 #include "mfw_win.h"
94
95 #include "mfw_kbd.h"
96 /* SPR#1428 - SH - New Editor changes */
97 #ifndef NEW_EDITOR
98 #include "mfw_edt.h"
99 #endif
100 //TISH modified for MSIM
101 //#ifdef WIN32
102 //#include "MmiMain.h"
103 //#endif
104 #include "mfw_lng.h"
105 #include "mfw_tim.h"
106 #include "mfw_icn.h"
107 #include "mfw_mnu.h"
108 #include "mfw_phb.h"
109 #include "mfw_cm.h"
110 #include "mfw_sim.h"
111 #include "mfw_nm.h"
112 #include "mfw_phb.h"
113 #include "ksd.h"
114 #include "psa.h"
115 #include "mfw_sms.h"
116 #include "mfw_sat.h"
117
118 #include "mfw_ffs.h"
119
120 #include "dspl.h"
121
122 #include "gdi.h" //ES!!
123 #ifdef NEPTUNE_BOARD
124 #include "ffs.h"
125 #endif
126 #define hCommACI _ENTITY_PREFIXED(hCommACI)
127
128 #if( BOARD == 61 )
129 #ifdef PCM_2_FFS
130 #define T_PSPDF_SMS 20
131 #define MAX_NO_SMS 20
132 #endif
133 #endif
134
135 // Apr 14, 2005 REF: CRR 29991 xpradipg
136 // New file added for the blacklist. The total length along with the path aand
137 // file name should not exceed 20 characters
138 #ifdef FF_MMI_OPTIM
139 #define BLACK_LIST_PATH_AND_FILE "/mmi/blacklist"
140 #endif
141
142 #if defined (NEW_FRAME)
143 EXTERN T_HANDLE hCommACI;
144 #else
145 EXTERN T_VSI_CHANDLE hCommACI;
146 #endif
147 #ifdef TI_PS_HCOMM_CHANGE
148 #define _hCommMMI hCommACI
149 #else
150 #define hCommMMI hCommACI
151 #endif
152
153 typedef enum
154 {
155 DATA,
156 NO_DATA
157 } WriteFlag;
158
159
160 FlashData FFS_flashData;
161
162 static WriteFlag write_flag;
163
164 int flash_formatted(void); /* SPR#2487 - DS - Function to check if FFS is formatted */
165
166 //TISH, patch for call control CLIR
167 //start
168 UBYTE getCLIRState(void)
169 {
170 if (FFS_flashData.CLIR)
171 TRACE_EVENT("FFS_flashData.CLIR EQ true");
172 else
173 TRACE_EVENT("FFS_flashData.CLIR EQ false");
174 return FFS_flashData.CLIR;
175 }
176 //end
177 /*
178 +--------------------------------------------------------------------+
179 | PROJECT : MMI-Framework (8417) MODULE : MFW_FFS |
180 | STATE : code ROUTINE : mfw_flash_write |
181 +--------------------------------------------------------------------+
182
183 PURPOSE : To write a string into FFS.
184
185 */
186 //x0pleela 08 Sep, 2006 DR: OMAPS00091250
187 void mfw_flash_write(char *Msg,...)
188 {
189 fd_t fd= -1;
190 char log_ffs_buf[256];
191 va_list varpars;
192 va_start (varpars, Msg);
193 vsprintf(log_ffs_buf,Msg,varpars);
194 va_end (varpars);
195
196 fd = ffs_open((const char*)"/mmiMEPD", FFS_O_APPEND | FFS_O_WRONLY );
197 if(fd < 0)
198 fd=ffs_open((const char*)"/mmiMEPD", FFS_O_CREATE |FFS_O_WRONLY );
199 if(fd > 0)
200 {
201 ffs_write(fd, log_ffs_buf, strlen(log_ffs_buf));
202 ffs_close(fd);
203 }
204 }
205
206 effs_t flash_write(void)
207 {
208
209 // Oct 19, 2004 REF: CRR MMI-SPR-26002 xkundadu
210 // Issue description: Golite booting problem.
211 // Solution: If the FFS is not formatted, dont write into the FFS.
212
213 if ( flash_formatted() == TRUE)
214 {
215 return (flash_data_write("/mmi","mmidata", &FFS_flashData, sizeof(FFS_flashData)));
216 }
217 else
218 {
219 TRACE_EVENT("ERROR flash_data_write(): NOT FORMATTED!");
220 // Return NOT formatted message.
221 return EFFS_NOFORMAT;
222 }
223 }
224
225 effs_t flash_update(void)
226 {
227 if (write_flag == DATA)
228 { write_flag = NO_DATA;
229 return (flash_write());
230 }
231 else
232 return EFFS_OK;
233 }
234 //TISH modified for MSIM
235 #ifndef _WIN32_
236 // EF 22/10/02 for WIN32 simulation, set anykeyanswer on, and keylock off
237 /* Marcus: Issue 1719: 11/02/2003: Changed return value from effs_t to int */
238 int flash_read(void)
239 {
240
241 #ifdef PCM_2_FFS
242 int val = ffs_fread("/mmi/mmidata", &FFS_flashData, sizeof(FFS_flashData));
243 #else
244 int val = FFS_fread("/mmi/mmidata", &FFS_flashData, sizeof(FFS_flashData));
245 #endif
246
247 if (val == sizeof(FFS_flashData))
248 {
249 val = EFFS_OK; /* Successful, return Zero as no data_size as in flash_data_read*/
250 }
251 else
252 {
253 TRACE_ERROR("The FFS data could not be read!");
254 TRACE_EVENT_P1("val = %d", val);
255 /* Error, presumably -ve as in FFS_ERRORS, or the actual number of bytes read */
256 }
257 return val;
258 }
259 #else
260 int flash_read()
261 {FFS_flashData.settings_status|= SettingsAnyKeyAnswerOn;
262 FFS_flashData.settings_status &= ~SettingsKeyPadLockOn;
263 #ifdef TI_PS_FF_CONC_SMS
264 FFS_flashData.ConcatenateStatus = TRUE;
265 #else
266 FFS_flashData.ConcatenateStatus = FALSE;
267 #endif /*TI_PS_FF_CONC_SMS*/
268
269 }
270 #endif
271
272 effs_t flash_data_write(const char* dir_name, const char* file_name, void* data_pointer, int data_size)
273 {
274 T_FFS_DIR dir;
275 int val;
276 char file[200];
277
278 /* SPR#2487 - DS - If FFS is not formatted, return from function */
279 if (flash_formatted() == FALSE)
280 {
281 TRACE_EVENT("ERROR flash_data_write(): NOT FORMATTED!");
282 return EFFS_NOFORMAT;
283 }
284
285 #ifndef PCM_2_FFS
286 val = FFS_opendir(dir_name, &dir);
287 #else
288 val = ffs_opendir((const signed char *)dir_name, &dir);
289 #endif
290
291 if(val < 0)
292 {
293
294 #ifndef PCM_2_FFS
295 val = FFS_mkdir(dir_name);
296 #else
297 val = ffs_mkdir(dir_name);
298 #endif
299
300 switch(val)
301 {
302 case EFFS_OK:
303 case EFFS_EXISTS:
304 break;
305 default:
306 TRACE_ERROR("The FFS directory could not be created!");
307 TRACE_EVENT_P2("val = %d dir name = %s", val, dir_name);
308 return (effs_t)val;
309 }
310 }
311
312 sprintf(file, "%s/%s", dir_name, file_name);
313
314 #ifdef PCM_2_FFS
315 val = ffs_fwrite( (const S8 *) file, data_pointer, data_size);
316 #else
317 val = FFS_fwrite( file, data_pointer, data_size);
318 #endif
319
320 if(val NEQ EFFS_OK)
321 {
322 TRACE_ERROR("The FFS file could not be created");
323 TRACE_EVENT_P2("val = %d file name = %s", val, file);
324 }
325
326
327 //x0pleela 07 Nov, 2006 DVT: OMAPS00102732
328 //Adding the MMI compilation flag FF_MMI_RELIANCE_FFS
329 #if defined ( PCM_2_FFS ) || defined( FF_MMI_RELIANCE_FFS)
330 ffs_closedir( &dir );
331 #endif
332
333 return (effs_t)val;
334 }
335
336 /* Marcus: Issue 1719: 11/02/2003: Changed return value from effs_t to int */
337 int flash_data_read(const char* dir_name, const char* file_name, void* data_pointer, int data_size)
338 {
339 int val;
340 char file[200];
341
342 sprintf(file, "%s/%s", dir_name, file_name);
343
344 #ifdef PCM_2_FFS
345 val = ffs_fread((const S8 *) file, data_pointer, data_size);
346 #else
347 val = FFS_fread( file, data_pointer, data_size);
348 #endif
349
350 if (val NEQ data_size)
351 {
352 TRACE_ERROR("The FFS data could not be read!");
353 TRACE_EVENT_P1("val = %d", val);
354 /* Error, presumably -ve as in FFS_ERRORS, or the actual number of bytes read */
355 }
356 return val;
357 }
358
359 /* SPR#2487 - DS - Function to check if FFS is formatted */
360 int flash_formatted(void)
361 {
362 T_FFS_DIR dir;
363 int val;
364 char sFileName[100];
365
366 /* Attempt to open "/mmi" directory */
367 #ifndef PCM_2_FFS
368 val = FFS_opendir("/mmi", &dir);
369 #else
370 val = ffs_opendir("/mmi", &dir);
371 #endif
372
373
374 /* If return val is not EFFS_NOFORMAT then
375 * assume that FFS is formatted.
376 */
377 if (val == EFFS_NOFORMAT)
378 return FALSE;
379 else
380 {
381 //Feb 19 2007, x0061088(Prachi) LOCOSTO-DRT-OMAPS00112518
382 if (val >= 0)
383 {
384 while (ffs_readdir (&dir, sFileName, 100) > 0x0 );
385
386 //x0pleela 07 Nov, 2006 DVT: OMAPS00102732
387 //Adding the MMI compilation flag FF_MMI_RELIANCE_FFS
388 //x0pleela 31 Oct, 2006
389 //Closing the directory aa per the new FFS logic
390 #ifdef FF_MMI_RELIANCE_FFS
391 ffs_closedir(&dir);
392 #endif
393 return TRUE;
394
395 }
396 else if (EFFS_NOTFOUND == val)
397 {
398 /* if the mmi directory was not found, but the FFS was formatted, */
399 /* create the mmi dir.*/
400
401 #ifndef PCM_2_FFS
402 val = FFS_mkdir("/mmi");
403 #else
404 val = ffs_mkdir("/mmi");
405 #endif
406 switch(val)
407 {
408 case EFFS_OK:
409 case EFFS_EXISTS:
410 break;
411 default:
412 TRACE_ERROR("The /mmi directory could not be created!");
413 return FALSE;
414 }
415 }
416 }
417 return TRUE;
418 }
419
420 /*
421 Aug 25, 2004 REF: CRR 20655 xnkulkar
422
423 +--------------------------------------------------------------------+
424 | PROJECT: MMI-Framework (8417) MODULE: MFW_FFS |
425 | STATE : code ROUTINE: flash_makedir |
426 +--------------------------------------------------------------------+
427
428 PURPOSE : Creates a directory if not present
429 */
430 void flash_makedir(char * dir_name)
431 {
432 T_FFS_DIR dir;
433 #ifndef PCM_2_FFS
434 int val = FFS_opendir(dir_name , &dir);
435 #else
436 int val = ffs_opendir(dir_name , &dir);
437 #endif
438
439
440 if(val < 0)
441 {
442
443 #ifndef PCM_2_FFS
444 val = FFS_mkdir(dir_name);
445 #else
446 val = ffs_mkdir(dir_name);
447 #endif
448 switch(val)
449 {
450 case EFFS_OK:
451 case EFFS_EXISTS:
452 break;
453 default:
454 TRACE_ERROR("The FFS directory could not be created!");
455 TRACE_EVENT_P2("val = %d dir name = %s", val, dir_name);
456 return;
457 }
458 }
459
460 //x0pleela 07 Nov, 2006 DVT: OMAPS00102732
461 //Adding the MMI compilation flag FF_MMI_RELIANCE_FFS
462 #if defined( PCM_2_FFS) || defined (FF_MMI_RELIANCE_FFS)
463 ffs_closedir( &dir );
464 #endif
465
466 }
467
468 #ifdef MMI_EM_ENABLED
469 #ifndef NEPTUNE_BOARD
470 /* This portion is not valid for Neptune, hence excluding it.*/
471 U32 get_screen_size(void);
472 void get_screen_capture(U8 *dest_data);
473 U32 screen_capture_index=0;
474 /*******************************************************************************
475
476 $Function: screen_capture_write
477
478 $Description: Implemented By Manju. Write the file into FFS
479 xrashmic 22 Aug, 2004 MMI-SPR-32798
480 $Returns: none
481
482 $Arguments: none
483
484 *******************************************************************************/
485 void screen_capture_write(U8 *filename, U8 *buffer, S32 size)
486 {
487 fd_t fd= -1;
488 fd = ffs_open((const char*)filename, FFS_O_CREATE | FFS_O_WRONLY);
489 ffs_write(fd, buffer, size);
490 ffs_close(fd);
491 }
492
493 /*******************************************************************************
494
495 $Function: screen_capture
496
497 $Description: Implemented By Manju. Writes the LCD buffer into a file in FFS.
498 xrashmic 22 Aug, 2004 MMI-SPR-32798
499 $Returns: none
500
501 $Arguments: none
502
503 *******************************************************************************/
504 void screen_capture(void)
505 {
506 U8 *dest_data;
507 U8 filename[16];
508 U32 dest_size;
509 dest_size=get_screen_size();
510 dest_data=(U8*)mfwAlloc(dest_size);
511 get_screen_capture(dest_data);
512 sprintf((char*)filename,(const char*)"/sc%04d",screen_capture_index);
513 screen_capture_write(filename, dest_data, dest_size);
514 mfwFree(dest_data, dest_size);
515 screen_capture_index++;
516 }
517 #endif /* ifndef NEPTUNE_BOARD*/
518 #endif
519
520
521 // Apr 14, 2005 REF: CRR 29991 xpradipg
522 #ifdef FF_MMI_OPTIM
523 /*******************************************************************************
524
525 $Function: flash_MMI_blackList_open
526
527 $Description: This opens the blacklist file
528
529 $Returns: value of the open result
530
531 $Arguments: none
532
533 *******************************************************************************/
534 int8 flash_MMI_blackList_open( )
535 {
536 T_FFS_FD file=EFFS_NOFORMAT;
537 /*a0393213 compiler warnings removal - variable status removed*/
538 if(flash_formatted())
539 {
540 file = FFS_open(BLACK_LIST_PATH_AND_FILE, FFS_O_RDWR);
541 if(file == EFFS_NOTFOUND)
542 {
543 TRACE_FUNCTION("the file does not exist and is created");
544 file = FFS_open(BLACK_LIST_PATH_AND_FILE, FFS_O_RDWR | FFS_O_CREATE);
545 if(file < 0 )
546 {
547 TRACE_FUNCTION("file creation failed");
548 return file;
549 }
550 return file;
551 }
552 }
553 return file;
554 }
555 /*******************************************************************************
556
557 $Function: flash_MMI_blackList_close
558
559 $Description: This closes the file opened for read operation
560
561 $Returns: zero for success and -1 for failure
562
563 $Arguments: handle - handle of the file to be closed
564
565 *******************************************************************************/
566 void flash_MMI_blackList_close(int8 handle)
567 {
568 FFS_close((T_FFS_FD)handle);
569 }
570
571 /*******************************************************************************
572
573 $Function: flash_MMI_blackList_write
574
575 $Description: This writes the blacklisted numbers onto the blacklist file
576 if the file does not exist it creates and writes the data
577 $Returns: zero for success and -1 for failure
578
579 $Arguments: data - to be written into the file
580 len - length of the data to be written
581
582 *******************************************************************************/
583 int flash_MMI_blackList_write(U8 *data, SHORT len, SHORT offset)
584 {
585
586 T_FFS_FD file;
587 /*a0393213 compiler warnings removal - variable status removed*/
588 TRACE_FUNCTION("flash_MMI_blackList_write()");
589 if(flash_formatted())
590 {
591 file = FFS_open(BLACK_LIST_PATH_AND_FILE, FFS_O_RDWR);
592
593 if(file == EFFS_NOTFOUND)
594 {
595 TRACE_FUNCTION("the file does not exist and is created");
596 file = FFS_open(BLACK_LIST_PATH_AND_FILE, FFS_O_RDWR | FFS_O_CREATE);
597 if(file < 0 )
598 {
599 TRACE_FUNCTION("file creation failed");
600 return file;
601 }
602 }
603 TRACE_FUNCTION("the file exist and is opened");
604 #ifdef PCM_2_FFS
605 ffs_seek(file, offset, FFS_SEEK_SET);
606 ffs_write(file, (void*)data, len);
607 ffs_close(file);
608 #else
609 FFS_seek(file, offset, FFS_SEEK_SET);
610 FFS_write(file, (void*)data, len);
611 FFS_close(file);
612 #endif
613
614 return 0;
615 }
616 else
617 return -1;
618
619 }
620 /*******************************************************************************
621
622 $Function: flash_MMI_blackList_read
623
624 $Description: This reads the blacklisted numbers onto the data buffer
625
626 $Returns: zero for success and -1 for failure
627
628 $Arguments: data - buffer into which data is retrieved from the file
629 len - length of the data to be retrieved from the file
630
631 *******************************************************************************/
632 int flash_MMI_blackList_read(int8 file, U8* data, SHORT len,SHORT offset)
633 {
634 int status;
635 TRACE_FUNCTION("file is opened and being read");
636 TRACE_EVENT_P1("the file is seekded at %d",offset);
637 FFS_seek(file, offset, FFS_SEEK_SET);
638 status = FFS_read(file, (void *)data, len);
639 return status;
640 }
641
642
643 #endif
644
645 #if( BOARD == 61 )
646 #ifdef PCM_2_FFS
647 T_FFS_SIZE ffs_ReadRecord(const char *name, void * addr, int size, int index, int recsize)
648 {
649 int n;
650 S32 result=0;
651 T_FFS_STAT stat;
652 char buf[T_PSPDF_SMS*MAX_NO_SMS];
653
654 ffs_stat((const signed char *)name, &stat);
655 n = stat.size / recsize;
656
657 if (index > n)
658 return EFFS_NOTFOUND;
659
660 if (stat.size <= (T_PSPDF_SMS*MAX_NO_SMS))
661 {
662 result = ffs_file_read((const signed char *)name, &buf, stat.size);
663 if (result == stat.size)
664 {
665 memcpy(addr, &buf[(index-1)*recsize], recsize);
666 result = recsize;
667 }
668 }
669
670 return result;
671 }
672
673 T_FFS_RET ffs_WriteRecord(const char *name, void * addr, int size, int index, int recsize)
674 {
675 int n;
676 int result =0;
677 T_FFS_STAT stat;
678 char buf[T_PSPDF_SMS*MAX_NO_SMS];
679
680 ffs_stat((const signed char *)name, &stat);
681 n = stat.size / recsize;
682
683 if (index > n)
684 return EFFS_NOTFOUND;
685
686 if (stat.size <= (T_PSPDF_SMS*MAX_NO_SMS))
687 {
688 result = ffs_file_read((const signed char *)name, &buf, stat.size);
689 if (result == stat.size)
690 {
691 memcpy(&buf[(index-1)*recsize], addr, recsize);
692 result = ffs_file_write((const signed char *)name, &buf, stat.size, (FFS_O_CREATE|FFS_O_TRUNC));
693 }
694 }
695
696 return result;
697 }
698 #endif
699
700 #endif
701
702 #ifdef FF_TTY_HCO_VCO
703 /*******************************************************************************
704
705 $Function: get_ffs_tty_status
706
707 $Description: Gives the status of tty in Flash
708
709 $Returns: tty status
710
711 $Arguments: None
712
713 *******************************************************************************/
714 uint8 get_ffs_tty_status(void)
715 {
716 return FFS_flashData.ttyAlwaysOn;
717 }
718
719 /*******************************************************************************
720
721 $Function: get_ffs_tty_pftype
722
723 $Description: This gives the tty profile type to be loaded
724
725 $Returns: tty profile type
726
727 $Arguments: None
728
729 *******************************************************************************/
730 uint8 get_ffs_tty_pftype(void)
731 {
732 return FFS_flashData.ttyPfType;
733 }
734 #endif