📄 mmitimers.c
字号:
*******************************************************************************/
static T_MFW_HND timer_create(MfwHnd parent_window)
{
tTimerData * data = (tTimerData *)ALLOC_MEMORY (sizeof(tTimerData));
T_MFW_WIN * win;
if (data EQ NULL)
{
return NULL;
}
// Create window handler
data->win = win_create (parent_window, 0, E_WIN_VISIBLE, NULL);
if (data->win EQ NULL)
{
return NULL;
}
// connect the dialog data to the MFW-window
data->mmi_control.dialog = (T_DIALOG_FUNC)NULL;
data->mmi_control.data = data;
win = ((T_MFW_HDR *)data->win)->data;
win->user = (tTimerData *)data;
data->parent_win = parent_window;
return data->win;
}
/*******************************************************************************
$Function: timer_destroy
$Description: Destroys the timer window and frees up memory
$Returns: nothing
$Arguments: Window
*******************************************************************************/
void timer_destroy(MfwHnd own_window)
{
T_MFW_WIN * win_data;
// tTimerData * data = (tTimerData *)ALLOC_MEMORY (sizeof(tTimerData));;
tTimerData * data ; //hu binhao 2003-3-18
if (own_window)
{
win_data = ((T_MFW_HDR *)own_window)->data;
if (win_data != NULL)
data = ( tTimerData *)win_data->user;
if (data)
{
TRACE_FUNCTION ("timer_destroy()");
win_delete (data->win);
// Free Memory
FREE_MEMORY (( void *)data, sizeof( tTimerData));
}
else
{
TRACE_EVENT ("timer_destroy() called twice");
}
}
}
/*******************************************************************************
$Function: timer_cb
$Description: Callback func for the info display screen
$Returns: status int
$Arguments: Window, Identifier (which timer), Reason (which key pressed)
*******************************************************************************/
/*
static int timer_cb(T_MFW_HND win, USHORT Identifier, USHORT Reason)
{
T_MFW_WIN *win_data = ( (T_MFW_HDR *) win )->data;
tTimerData *data = (tTimerData *) win_data->user;
switch (Reason)
{
case INFO_KCD_RIGHT:
case INFO_KCD_HUP:
case INFO_KCD_CLEAR:
timer_destroy(win);
break;
case INFO_KCD_LEFT: //hu binhao 2002-12-26 3126 change right to lest
//reset_timer_OK(win, data->timer_type);
switch (Identifier)
{ case LAST_CALL: setLastCallDuration(0, INVALID);reset_timer(win);break;
case INCOMING_CALLS: resetIncomingCallsDuration();reset_timer(win);break;
case OUTGOING_CALLS: resetOutgoingCallsDuration();reset_timer(win);break;
case ALL_CALLS_DURATION: CallsDurationReset();reset_timer(win);break;//WUFEI APPEND
}
timer_destroy(win);
break;
}
return MFW_EVENT_CONSUMED;
}
*/
/*******************************************************************************
$Function: setIncomingCallsDuration
$Description: Adds call time to Incoming Calls total
$Returns: none
$Arguments: call time
*******************************************************************************/
void setIncomingCallsDuration(long call_time)
{
TRACE_EVENT("setIncomingCallsDuration()");
//add call time to existing call time
call_time = call_time + getIncomingCallsDuration();
//save new value to flash
FFS_flashData.incoming_calls_duration = call_time;
flash_write();
return;
}
/*******************************************************************************
$Function: setOutgoingCalls
$Description: Adds call time to Outgoing Calls total
$Returns: none
$Arguments: call time
*******************************************************************************/
void setOutgoingCallsDuration(long call_time)
{
TRACE_EVENT("setOutgoingCallsDuration()");
//add call time to current total
call_time = call_time + getOutgoingCallsDuration();
FFS_flashData.outgoing_calls_duration = call_time;
//write to flash
flash_write();
return;
}
/*******************************************************************************
$Function: reset_timer_OK
$Description: displays "Are you sure you want to reset this timer" window
$Returns: none
$Arguments: parent window, identifier (which timer)
*******************************************************************************/
/*
void reset_timer_OK(T_MFW_HND parent, UBYTE identifier)
{
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;
dialog_info_init(&display_info);//gdy add
display_info.KeyEvents = KEY_CLEAR|KEY_LEFT|KEY_RIGHT|KEY_HUP;
display_info.TextId = TxtOkToDelete;
display_info.TextId2 = 0;
display_info.TextString = '\0';
display_info.TextString2 = '\0';
display_info.LeftSoftKey = TxtSoftOK;
display_info.RightSoftKey = TxtCancel;
display_info.Time = FOREVER; // hu binhao 2002-12-16
display_info.Identifier = identifier;
display_info.BackColor =0xffffff;
display_info.FontColor=0xffffff;
display_info.Callback = (T_VOID_FUNC) timer_reset_OK_cb;
info_dialog( win, &display_info );
}
}*/
/*******************************************************************************
$Function: reset_timer_OK_cb
$Description: Callback function for "OK to Delete timer" window
$Returns: status int
$Arguments: window, identifier (which timer), Reason (which key pressed)
*******************************************************************************/
static int timer_reset_OK_cb(T_MFW_HND win, USHORT Identifier, USHORT Reason)
{
TRACE_EVENT("hubh_1-16-timer_reset_OK_cb");
switch (Reason)
{
case INFO_KCD_LEFT:
{
switch (Identifier)
{
/* case LAST_CALL: setLastCallDuration(0, INVALID);reset_timer(win);break;
case INCOMING_CALLS: resetIncomingCallsDuration();reset_timer(win);break;
case OUTGOING_CALLS: resetOutgoingCallsDuration();reset_timer(win);break;*/
/* 2003/10/28, wangyan, modify call time statistics menu*/
case ALL_CALLS_DURATION: CallsDurationReset();reset_timer(win);break;//WUFEI APPEND
}
}break;
case INFO_KCD_RIGHT:
case INFO_KCD_HUP:
case INFO_TIMEOUT:
{
TRACE_EVENT("hubh_1-16-INFO_TIMEOUT");
timer_destroy(win);
}
break;
}
return MFW_EVENT_CONSUMED;
}
/****************************Wufei Modified***************************************************
$Function: reset_timer
$Description: Dsiplays confirmation that timer has been reset.
$Returns: none
$Arguments: parent window
*******************************************************************************/
void reset_timer(T_MFW_HND parent)
{
T_DISPLAY_DATA display_info;
TRACE_FUNCTION ("reset_timer()");
dialog_info_init(&display_info);//gdy add
display_info.Identifier=0; //hu binhao 2002-12-16 for bug 3115
display_info.iconindex=0; //hu binhao 2002-12-16 for bug 3115
display_info.icn=0; //hu binhao 2002-12-16 for bug 3115
display_info.KeyEvents = 0;
display_info.TextId = 0;
display_info.TextId2 = TxtTimerReset;
display_info.TextString = NULL;
display_info.TextString2 = NULL;
display_info.LeftSoftKey = TxtNull;
display_info.RightSoftKey = TxtNull;
display_info.Time = FOREVER;
display_info.Callback = (T_VOID_FUNC)reset_timer_cb;
display_info.iconindex=REMIND_COMPLETE; //hu binhao 2002-1-6
info_dialog( parent, &display_info );
}
////////////2003-1-15/////////////////
static int reset_timer_cb(T_MFW_HND win, USHORT Identifier, USHORT Reason)
{
switch(Reason)
{
case INFO_KCD_RIGHT:
case INFO_KCD_LEFT:
case INFO_TIMEOUT:
timer_destroy(win);
break;
}
}
/*******************************************************************************
$Function: resetIncomingCallsDuration
$Description: Resets incoming call total to 0
$Returns: nothing
$Arguments: none
*******************************************************************************/
void resetIncomingCallsDuration()
{
TRACE_EVENT("resetIncomingCallsDuration()");
FFS_flashData.incoming_calls_duration =0;
flash_write();
}
/*******************************************************************************
$Function: resetOutgoingCallsDuration
$Description: Resets outgoing call total to 0
$Returns: nothing
$Arguments: none
*******************************************************************************/
void resetOutgoingCallsDuration()
{
TRACE_EVENT("resetOutgoingCallsDuration()");
FFS_flashData.outgoing_calls_duration = 0;
flash_write;
return;
}
/*************************WUFEI APPEND*********************************************
$Function: timerReset
$Description: Reset Call timers to 0
$Returns: nothing
$Arguments: none
*******************************************************************************/
void CallsDurationReset()
{
TRACE_EVENT("timerReset()");
FFS_flashData.outgoing_calls_duration = 0;
FFS_flashData.last_call_duration = 0;
FFS_flashData.incoming_calls_duration = 0;
flash_write();
return;
}
int timerReset(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;
dialog_info_init(&display_info);//gdy add
if(FFS_flashData.incoming_calls_duration ==0&&FFS_flashData.last_call_duration == 0&&FFS_flashData.outgoing_calls_duration == 0)
{
display_info.iconindex=REMIND_NORECORD;
display_info.KeyEvents = KEY_CLEAR|KEY_HUP;
display_info.TextId = 0;
display_info.TextId2 = TxtHaveReset;
display_info.TextString = '\0';
display_info.TextString2 = '\0';
display_info.LeftSoftKey = '\0';;
display_info.RightSoftKey = '\0';;
}
else
{
display_info.iconindex=REMIND_REQUIRE; //2003-1-6
display_info.KeyEvents = KEY_CLEAR|KEY_LEFT|KEY_RIGHT|KEY_HUP;
display_info.TextId = 0;
display_info.TextId2 = TxtOkToDelete;
display_info.TextString = '\0';
display_info.TextString2 = '\0';
display_info.LeftSoftKey = TxtYes;
display_info.RightSoftKey = TxtNo;
}
display_info.Time = FOREVER;
display_info.Identifier = ALL_CALLS_DURATION;
display_info.Callback = (T_VOID_FUNC) timer_reset_OK_cb;
info_dialog( win, &display_info );
return MFW_EVENT_CONSUMED;
}
/**************WUFEI APPEND END******************************************/
/*******************************************************************************
$Function: getLastCallDuration
$Description: gets the length of the last call made/received from PCM storage
$Returns: length of call (long)
$Arguments: none
*******************************************************************************/
unsigned long getLastCallDuration()
{
//flash_read();
return FFS_flashData.last_call_duration;;
}
/*******************************************************************************
$Function: getIncomingCallsDuration
$Description: gets the total length of incoming calls received from PCM storage
$Returns: length of calls (long)
$Arguments: none
*******************************************************************************/
unsigned long getIncomingCallsDuration()
{
//flash_read();
return FFS_flashData.incoming_calls_duration;
}
/*******************************************************************************
$Function: getOutgoingCallsDuration
$Description: gets the total length of incoming calls received from PCM storage
$Returns: length of calls (long)
$Arguments: none
*******************************************************************************/
unsigned long getOutgoingCallsDuration()
{
//flash_read();
return FFS_flashData.outgoing_calls_duration;
}
/*******************************************************************************
$Function: getTimerString
$Description: Converts a time in seconds into a string denoting hours, minutes and seconds
$Returns: none,
$Arguments: time pointer to string to store time
*******************************************************************************/
void getTimerString(unsigned long time, char* timeString)
{
char* debug_buf;
int hour,min,sec;
TRACE_EVENT("getTimerString()");
hour = time/3600;
min = (time-hour*3600)/60;
sec = (time-hour*3600-min*60);
//this prevents the time being too wide for the LCD display
if (hour > 999999)
hour = 999999;
sprintf(timeString,"%02d:%02d:%02d",hour,min,sec);
//sprintf(debug_buf, "Time String: %s", timeString);
//TRACE_EVENT(debug_buf);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -