📄 mmitimers.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: Basic MMI
$Project code: BMI (6349)
$Module: MMI
$File: MmiTimers.c
$Revision: 1.0
$Author: Condat(UK)
$Date: 22/02/01
********************************************************************************
Description: This handles the storage of call times.
********************************************************************************
$History: MmiTimers.c
25/10/00 Original Condat(UK) BMI version.
$End
*******************************************************************************/
/*******************************************************************************
Include files
*******************************************************************************/
#define ENTITY_MFW
/* includes */
#include <string.h>
#include <stdio.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 "mfw_sys.h"
#include "p_sim.h"
#include "vsi.h"
#include "mfw_mfw.h"
#include "mfw_win.h"
#include "mfw_kbd.h"
#include "mfw_edt.h"
#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_sat.h"
#include "mfw_phb.h"
#include "ksd.h"
#include "psa.h"
#include "mfw_sms.h"
#include "mfw_sat.h"
#include "dspl.h"
#include "gdi.h" //ES!!
#include "MmiMmi.h"
#include "MmiDummy.h"
#include "MmiDialogs.h"
#include "MmiLists.h"
//#include "MmiIdle.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 "MmiTimers.h"
#include "mfw_ffs.h"
#include "encrypt.h" // 2004.6.2 WYJ add
/*******************************************************************************
Local Function Prototypes
*******************************************************************************/
static T_MFW_HND timer_create(MfwHnd parent_window);
void timer_destroy(MfwHnd own_window);
unsigned long getLastCallDuration();
void getTimerString(unsigned long time, char* timeString);
void setIncomingCallsDuration(long call_time);
void resetIncomingCallsDuration();
unsigned long getIncomingCallsDuration();
void setOutgoingCallsDuration(long call_time);
void resetOutgoingCallsDuration();
unsigned long getOutgoingCallsDuration();
static int timer_cb(T_MFW_HND win, USHORT Identifier, USHORT Reason);
static int timer_reset_OK_cb(T_MFW_HND win, USHORT Identifier, USHORT Reason);
void reset_timer_OK(T_MFW_HND parent, UBYTE Identifier);
void reset_timer(T_MFW_HND parent);
static int reset_timer_cb(T_MFW_HND win, USHORT Identifier, USHORT Reason);
void CallsDurationReset(); //WUFEI APPEND
/*******************************************************************************
Public Methods
*******************************************************************************/
/*******************************************************************************
$Function: setLastCallDuration
$Description: writes the duration of the last call to PCM and adds that duration to the
outgoing or incoming call total.
$Returns: none.
$Arguments: The call time and the call's direction (incoming or outgoing)
*******************************************************************************/
#ifdef _ENCRYPT_
extern T_ENCRYPT Encrypt_ffs;
#endif
void setLastCallDuration(long call_time, UBYTE call_direction)
{
#ifdef _ENCRYPT_
T_FFS_STAT s;
int status;
#endif
TRACE_EVENT("setLastCallDuration()");
FFS_flashData.last_call_duration = call_time;
flash_write();//WUFEI MODIFY
//2004.6.2 WYJ add
/* 2004/06/14 sunsj modify for flash file directory */
#ifdef _ENCRYPT_
/* 读数据到Encrypt_ffs */
status = ffs_stat("/bmi/mi", &s);
if(status != EFFS_NOTFOUND) // 读数据
{
status = ffs_fread("/bmi/mi", &Encrypt_ffs, sizeof(T_ENCRYPT));
}
else // 创建一个初始化文件
{
memset(&Encrypt_ffs, 0, sizeof(T_ENCRYPT));
status = ffs_fwrite("/bmi/mi", &Encrypt_ffs, sizeof(T_ENCRYPT));
}
Encrypt_ffs.during_time += call_time;
status = ffs_fwrite("/bmi/mi", &Encrypt_ffs, sizeof(T_ENCRYPT));
#endif
//2004.6.2 WYJ add end
if (call_direction == INCOMING)
setIncomingCallsDuration(call_time);
if (call_direction == OUTGOING)
setOutgoingCallsDuration(call_time);
return;
}
int timerstatistics(MfwMnu* m, MfwMnuItem* i) /* 2003/10/28, wangyan, modify call time statistics menu*/
{
T_MFW_HND parent = mfwParent( mfw_header() );
T_DISPLAY_DATA display_info;
T_MFW_HND win = timer_create(parent);
T_MFW_WIN *win_data = ( (T_MFW_HDR *) win )->data;
tTimerData *data = (tTimerData *) win_data->user;
// char text[25];
/*2004/0414,talcon modify ,add static*/
//char timeString1[10], timeString2[10], timeString3[10];
static char timeString1[10], timeString2[10], timeString3[10];
// memset(data->text,'\0',sizeof(data->text));
// memset(text,'\0',sizeof(text));
memset(timeString1,'\0',sizeof(timeString1));
memset(timeString2,'\0',sizeof(timeString2));
memset(timeString3,'\0',sizeof(timeString3));
getTimerString(getLastCallDuration(), timeString1);
getTimerString(getIncomingCallsDuration(), timeString2);
getTimerString(getOutgoingCallsDuration(), timeString3);
dialog_info_init(&display_info);
display_info.KeyEvents = KEY_CLEAR | KEY_RIGHT | KEY_HUP;
display_info.LeftSoftKey = '\0'; //hu binhao 2002-12-25 for 3126
display_info.RightSoftKey = TxtSoftBack;
display_info.TextId = TxtLastCall;
display_info.TextId2 = TxtIncomingCalls;
display_info.TextId3 = TxtOutgoingCalls;
display_info.TextString = timeString1;
display_info.TextString2=timeString2;
display_info.TextString3=timeString3;
display_info.Identifier = MMI_TIMER_STATISTICS; //hu binhao 2002-12-26
display_info.Time = FOREVER; //hu binhao 12-16
display_info.Callback = (T_VOID_FUNC) timer_reset_OK_cb;
info_dialog( win, &display_info );
return MFW_EVENT_CONSUMED;
}
#if 0 /* 2003/10/22, wangyan, modify call time statistics menu*/
/*******************************************************************************
$Function: timerLastCall
$Description: handles user selction of "Last Call" in Call Timers Menu.
$Returns: status int
$Arguments: menu and menu item (neither used)
*******************************************************************************/
int timerLastCall(MfwMnu* m, MfwMnuItem* i)
{ T_MFW_HND parent = mfwParent( mfw_header() );
T_DISPLAY_DATA display_info;
T_MFW_HND win = timer_create(parent);
T_MFW_WIN *win_data = ( (T_MFW_HDR *) win )->data;
tTimerData *data = (tTimerData *) win_data->user;
char text[25];
char timeString[30];
//clear the editor-buffer before
memset(data->text,'\0',sizeof(data->text));
memset(timeString,'\0',sizeof(timeString));
data->timer_type = LAST_CALL;
TRACE_EVENT("timerLastCall()");
getTimerString((int)getLastCallDuration(), (char*)timeString);
sprintf(data->text, "%s", (char*)timeString);
dialog_info_init(&display_info);//gdy add
if(FFS_flashData.last_call_duration ==0)
{
display_info.KeyEvents = KEY_CLEAR | KEY_HUP;
display_info.TextId = 0;
display_info.TextId2 = 0;
display_info.iconindex=REMIND_NORECORD; //hu binhao 2002
display_info.TextString = '\0';
display_info.TextString2 = data->text;
display_info.LeftSoftKey = '\0'; //hu binhao 2002-12-25 for 3126
display_info.RightSoftKey = '\0';
}
else
{
display_info.KeyEvents = KEY_CLEAR|KEY_LEFT|KEY_RIGHT | KEY_HUP;
display_info.TextId = 0;
display_info.TextId2 = TxTMakeSureTimeReset;
display_info.TextString = data->text;
display_info.TextString2 = '\0';
display_info.LeftSoftKey = TxtReset; //hu binhao 2002-12-25 for 3126
display_info.RightSoftKey = TxtSoftBack; //hu binhao 2002-12-25 for 3126
display_info.iconindex=REMIND_REQUIRE;
}
display_info.Identifier = LAST_CALL; //hu binhao 2002-12-26
display_info.Time = FOREVER; //hu binhao 2002-12-16
display_info.Callback = (T_VOID_FUNC) timer_reset_OK_cb;
/* Call Info Screen
*/
info_dialog( win, &display_info );
return MFW_EVENT_CONSUMED;
}
/*******************************************************************************
$Function: timerIncomingCalls
$Description: handles user selction of "Incoming Calls" in Call Timers Menu.
$Returns: status int
$Arguments: menu and menu item (neither used)
*******************************************************************************/
int timerIncomingCalls(MfwMnu* m, MfwMnuItem* i)
{ T_MFW_HND parent = mfwParent( mfw_header() );
T_DISPLAY_DATA display_info;
T_MFW_HND win = timer_create(parent);
T_MFW_WIN *win_data = ( (T_MFW_HDR *) win )->data;
tTimerData *data = (tTimerData *) win_data->user;
// char text_g[25];
char timeString[30];
//clear the editor-buffer before
memset(data->text,'\0',sizeof(data->text));
memset(timeString,'\0',sizeof(timeString));
data->timer_type = INCOMING_CALLS;
TRACE_EVENT("timerLastCall()");
getTimerString((int)getIncomingCallsDuration(), (char*)timeString);
//sprintf(text, "%s", (char*)timeString);
sprintf(data->text, "%s", (char*)timeString);
dialog_info_init(&display_info); //gdy add
if(FFS_flashData.incoming_calls_duration ==0)
{
display_info.KeyEvents = KEY_CLEAR|KEY_HUP;
display_info.TextId = 0;
display_info.TextId2 = 0;
display_info.TextString = '\0';
display_info.TextString2 = data->text;
display_info.LeftSoftKey = '\0';
display_info.RightSoftKey = '\0';
display_info.iconindex=REMIND_NORECORD; //hu binhao 2003-1-6
}
else
{
display_info.KeyEvents = KEY_CLEAR|KEY_LEFT|KEY_RIGHT|KEY_HUP;
display_info.TextId = 0;
display_info.TextId2 = TxTMakeSureTimeReset;
display_info.TextString = data->text; //hu binhao 2002-2-28
display_info.TextString2 = '\0';
display_info.LeftSoftKey = TxtReset;
display_info.iconindex=REMIND_REQUIRE; //hu binhao 2003-1-6
display_info.RightSoftKey = TxtSoftBack;
}
display_info.Identifier = INCOMING_CALLS; //hu binhao 2002-12-26
display_info.Time = FOREVER; //hu binhao 12-16
display_info.Callback = (T_VOID_FUNC) timer_reset_OK_cb;
/* Call Info Screen
*/
info_dialog( win, &display_info );
return MFW_EVENT_CONSUMED;
}
/*******************************************************************************
$Function: timerOutgoingCalls
$Description: handles user selction of "Outgoing Calls" in Call Timers Menu.
$Returns: status int
$Arguments: menu and menu item (neither used)
*******************************************************************************/
int timerOutgoingCalls(MfwMnu* m, MfwMnuItem* i)
{ T_MFW_HND parent = mfwParent( mfw_header() );
T_DISPLAY_DATA display_info;
T_MFW_HND win = timer_create(parent);
T_MFW_WIN *win_data = ( (T_MFW_HDR *) win )->data;
tTimerData *data = (tTimerData *) win_data->user;
// char text[25];
char timeString[30];
//clear the editor-buffer before
memset(data->text,'\0',sizeof(data->text));
memset(timeString,'\0',sizeof(timeString));
data->timer_type = OUTGOING_CALLS;
TRACE_EVENT("timerLastCall()");
getTimerString((int)getOutgoingCallsDuration(), (char*)timeString);
sprintf(data->text, "%s", (char*)timeString);
dialog_info_init(&display_info);//gdy add
if(FFS_flashData.outgoing_calls_duration ==0)
{
display_info.KeyEvents = KEY_CLEAR|KEY_HUP;
display_info.TextId = 0;
display_info.TextId2 = 0;
display_info.TextString2 = data->text;
//display_info.TextString2 = '\0';
display_info.LeftSoftKey = '\0';
display_info.RightSoftKey = '\0';
display_info.iconindex = REMIND_NORECORD; //hu binhao 2003-1-6
}
else
{
display_info.KeyEvents = KEY_CLEAR|KEY_LEFT|KEY_RIGHT|KEY_HUP;
display_info.TextId = 0;
display_info.TextId2 = TxTMakeSureTimeReset;
display_info.TextString = data->text;
display_info.TextString2 = '\0';
display_info.LeftSoftKey = TxtReset;
display_info.iconindex = REMIND_REQUIRE; //hu binhao 2002-1-6
display_info.RightSoftKey = TxtSoftBack;
}
display_info.Identifier = OUTGOING_CALLS; //hu binhao 2002-12-26
display_info.Time = FOREVER;
display_info.Callback = (T_VOID_FUNC) timer_reset_OK_cb;
/* Call Info Screen
*/
info_dialog( win, &display_info );
return MFW_EVENT_CONSUMED;
}
#endif
/*******************************************************************************
Private Methods
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -