📄 mmiwapffs.c
字号:
/*******************************************************************************
CONDAT (UK)
********************************************************************************
This software product is the property of Condat (UK) Ltd and may not be
disclosed to any third party without the express permission of the owner.
********************************************************************************
$Project name:
$Project code:
$Module:
$File: MmiWapFfs.c
$Revision:
$Author: Condat(UK)
$Date:
********************************************************************************
Description:
Flash handling for WAP.
********************************************************************************
$History: MmiWapFfs.c
15/05/2003 - SPR#1983 - SH - Updated to latest from 1.6.3 version.
$End
*******************************************************************************/
#define ENTITY_MFW
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#if defined (NEW_FRAME)
#include "typedefs.h"
#include "vsi.h"
#include "pei.h"
#include "custom.h"
#include "gsm.h"
#else
#include "stddefs.h"
#include "custom.h"
#include "gsm.h"
#include "vsi.h"
#endif
#include "custom.h"
#include "gsm.h"
#include "vsi.h"
#include "mfw_sys.h"
#include "p_sim.h"
#include "vsi.h"
#include "mfw_mfw.h"
#include "mfw_win.h"
#include "mfw_kbd.h"
#ifndef NEW_EDITOR
#include "mfw_edt.h"
#endif
#include "mfw_lng.h"
#include "mfw_tim.h"
#include "mfw_icn.h"
#include "mfw_mnu.h"
#include "mfw_phb.h"
#include "mfw_cm.h"
#include "mfw_sim.h"
#include "mfw_nm.h"
#include "mfw_phb.h"
#include "ksd.h"
#include "psa.h"
#include "mfw_sms.h"
#include "mfw_sat.h"
#include "mfw_ffs.h"
#include "dspl.h"
#include "gdi.h"
#include "MmiMmi.h"
#include "MmiDummy.h"
#include "MmiDialogs.h"
#include "MmiLists.h"
#include "MmiSoftkeys.h"
#include "MmiIcons.h"
#include "MmiMenu.h"
#include "MmiMain.h"
#include "MmiIdle.h"
#include "MmiStart.h"
#include "MmiPins.h"
#include "MmiSounds.h"
#include "audio.h"
#include "cus_aci.h"
#include "p_sim.h"
#include "MmiWapFfs.h"
#include "ffs_coat.h"
#define hCommACI _ENTITY_PREFIXED(hCommACI)
#if defined (NEW_FRAME)
EXTERN T_HANDLE hCommACI;
#else
EXTERN T_VSI_CHANDLE hCommACI;
#endif
#define hCommMMI hCommACI
/* WAP data stored in two files */
FlashDataWap *WapData;
FlashDataWapProfiles *WapProfilesData;
/*************************************************************************
* flash_wap_init()
*
* Init function for WAP flash file.
* If the 'tmp' directory does not exist, create it.
* If it does exist, and there is a copy of wapdata in 'tmp' directory, it is removed.
*
*************************************************************************/
T_FFS_RET flash_wap_init()
{
T_FFS_RET result;
T_FFS_STAT stat;
TRACE_FUNCTION("flash_wap_init()");
/* Check if wapdata file exists and is correct size
* If the size of the WAP data changes or it is corrupted, it is deleted
* so a new file can be written in its place later. */
result = ffs_stat("/mmi/wapdata", &stat);
TRACE_EVENT_P1("ffs_stat wapdata, result = %d", result);
if (result==EFFS_OK)
{
if (stat.size==sizeof(FlashDataWap))
{
TRACE_EVENT("wapdata found OK & is correct size");
}
}
/* Try to reconstruct intact file, in case of interrupted
* save operation */
else
{
result = ffs_stat("/mmi/wapdata.zzz",&stat);
TRACE_EVENT_P1("ffs_stat wapdata.zzz', result = %d", result);
if (result==EFFS_OK)
{
if (stat.size==sizeof(FlashDataWap))
{
TRACE_EVENT("wapdata.zzz found OK & is correct size");
result = ffs_rename("/mmi/wapdata", "/mmi/wapdata.zzz");
TRACE_EVENT_P1("rename '/mmi/wapdata' to '/mmi/wapdata.zzz': result %d", result);
}
else
{
TRACE_EVENT("wapdata.zzz found, but size is incorrect");
}
}
else
{
TRACE_EVENT("wapdata.zzz not found.");
}
}
/* WAP PROFILES */
/* Check if wapprof file exists and is correct size */
result = ffs_stat("/mmi/wapprof", &stat);
TRACE_EVENT_P1("ffs_stat wapprof, result = %d", result);
if (result==EFFS_OK)
{
if (stat.size==sizeof(FlashDataWapProfiles))
{
TRACE_EVENT("wapprof found OK & is correct size");
}
}
/* Try to reconstruct intact file, in case of interrupted
* save operation */
else
{
result = ffs_stat("/mmi/wapprof.zzz",&stat);
TRACE_EVENT_P1("ffs_stat wapprof.zzz', result = %d", result);
if (result==EFFS_OK)
{
if (stat.size==sizeof(FlashDataWapProfiles))
{
TRACE_EVENT("waprof.zzz found OK & is correct size");
result = ffs_rename("/mmi/wapprof", "/mmi/wapprof.zzz");
TRACE_EVENT_P1("rename '/mmi/wapprof' to '/mmi/wapprof.zzz': result %d", result);
}
else
{
TRACE_EVENT("wapprof.zzz found, but size is incorrect");
}
}
else
{
TRACE_EVENT("wapprof.zzz not found.");
}
}
return result;
}
/*************************************************************************
* flash_wap_write()
*
* Write WAP data to file.
*
*************************************************************************/
T_FFS_RET flash_wap_write()
{
T_FFS_RET result;
/* Procedure to minimise data corruption */
/* WAP Data File */
result = ffs_file_write("/mmi/wapdata.zzz", WapData, sizeof(FlashDataWap), FFS_O_TRUNC | FFS_O_CREATE);
TRACE_EVENT_P1("write '/mmi/wapdata.zzz': result %d", result);
if (result!=EFFS_OK)
{
TRACE_EVENT("** ERROR WRITING FILE **");
return;
}
result = ffs_remove("/mmi/wapdata");
TRACE_EVENT_P1("remove '/mmi/wapdata': result %d", result);
if (result!=EFFS_OK)
{
TRACE_EVENT("/mmi/wapdata does not exist yet");
}
result = ffs_rename("/mmi/wapdata.zzz", "/mmi/wapdata");
TRACE_EVENT_P1("rename '/mmi/wapdata.zzz' to '/mmi/wapdata': result %d", result);
if (result!=EFFS_OK)
{
if (result==EFFS_NOTFOUND)
{
TRACE_EVENT("mmi/wapdata.zzz doesn't exist");
}
else
{
TRACE_EVENT("** ERROR RENAMING FILE **");
}
}
/* WAP Profiles File */
result = ffs_file_write("/mmi/wapprof.zzz", WapProfilesData, sizeof(FlashDataWapProfiles), FFS_O_TRUNC | FFS_O_CREATE);
TRACE_EVENT_P1("write '/mmi/wapprof.zzz': result %d", result);
if (result!=EFFS_OK)
{
TRACE_EVENT("** ERROR WRITING FILE **");
return;
}
result = ffs_remove("/mmi/wapprof");
TRACE_EVENT_P1("remove '/mmi/wapprof': result %d", result);
if (result!=EFFS_OK)
{
TRACE_EVENT("/mmi/wapprof does not exist yet");
}
result = ffs_rename("/mmi/wapprof.zzz", "/mmi/wapprof");
TRACE_EVENT_P1("rename '/mmi/wapprof.zzz' to '/mmi/wapprof': result %d", result);
if (result!=EFFS_OK)
{
if (result==EFFS_NOTFOUND)
{
TRACE_EVENT("mmi/wapprof doesn't exist");
}
else
{
TRACE_EVENT("** ERROR RENAMING FILE **");
}
}
return;
}
/*************************************************************************
* flash_wap_read()
*
* Read WAP data from file.
*
*************************************************************************/
T_FFS_SIZE flash_wap_read()
{
T_FFS_RET result;
T_FFS_STAT stat;
T_FFS_SIZE size;
/* Read two files. If either file is of the wrong size, return 0 */
/* WAP Data File */
/* Check if wapdata file exists and is correct size */
result = ffs_stat("/mmi/wapdata", &stat);
if (result!=EFFS_OK || stat.size!=sizeof(FlashDataWap))
{
TRACE_EVENT("mmi/wapdata does not exist or is not correct size");
return 0;
}
/* Read the file */
size = ffs_file_read("/mmi/wapdata", WapData, sizeof(FlashDataWap));
TRACE_EVENT_P1("Read 'mmi/wapdata': result %d", size);
/* WAP Profiles File */
/* Check if wapprof file exists and is correct size */
result = ffs_stat("/mmi/wapprof", &stat);
if (result!=EFFS_OK || stat.size!=sizeof(FlashDataWapProfiles))
{
TRACE_EVENT("mmi/wapprof does not exist or is not correct size");
return 0;
}
/* Read the file */
size = ffs_file_read("/mmi/wapprof", WapProfilesData, sizeof(FlashDataWapProfiles));
TRACE_EVENT_P1("Read 'mmi/wapprof': result %d", size);
return size;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -