FreeCalypso > hg > fc-tourmaline
changeset 179:d0a2eaf41733
mmiTimeDate.c: formatting fixes and dead code elimination
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 19 Jan 2021 04:26:17 +0000 |
parents | 053ff6a94961 |
children | 6b5d787d9ade |
files | src/ui/bmi/mmiTimeDate.c |
diffstat | 1 files changed, 75 insertions(+), 1043 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ui/bmi/mmiTimeDate.c Tue Jan 19 04:05:57 2021 +0000 +++ b/src/ui/bmi/mmiTimeDate.c Tue Jan 19 04:26:17 2021 +0000 @@ -1,6 +1,6 @@ /******************************************************************************* - CONDAT (UK) + CONDAT (UK) ******************************************************************************** @@ -11,19 +11,18 @@ $Project name: Basic MMI $Project code: BMI (6349) - $Module: MMI - $File: MmiTimeDate.c - $Revision: 1.0 + $Module: MMI + $File: MmiTimeDate.c + $Revision: 1.0 - $Author: Condat(UK) - $Date: 22/02/01 + $Author: Condat(UK) + $Date: 22/02/01 ******************************************************************************** Description: - ******************************************************************************** $History: MmiTimeDate.c @@ -67,7 +66,7 @@ format flag. Also the conversion of time from 24 to 12 or 12 to 24 hour format is done before displaying it on the alarm editor screen. - 25/10/00 Original Condat(UK) BMI version. + 25/10/00 Original Condat(UK) BMI version. $End @@ -140,7 +139,6 @@ #include "dspl.h" - #include "MmiMmi.h" #include "MmiDummy.h" #include "MmiDialogs.h" @@ -220,79 +218,16 @@ { T_MMI_CONTROL mmi_control; T_MFW_HND parent_win; - T_MFW_HND win; /* The main time/date window */ - T_MFW_HND edit_win; /* The editor window */ - char buffer[MAX_DIG_TIDA]; /* Buffer to store currently edited time/date */ + T_MFW_HND win; /* The main time/date window */ + T_MFW_HND edit_win; /* The editor window */ + char buffer[MAX_DIG_TIDA]; /* Buffer to store currently edited time/date */ } T_tida; #else /* NEW_EDITOR */ /* OLD VERSION */ - -static int tida_edt_kbd_long_cb (MfwEvt e, MfwKbd *kc); -static void tida_edt_tim_out_cb(T_MFW_EVENT event,T_MFW_TIM * t); -static int check_time (T_MFW_HND win, void * edt_dat); -static int check_date (T_MFW_HND win, void * edt_dat); -static int tida_edt_kbd_cb (MfwEvt e, MfwKbd *kc); -static void tida_editor(T_MFW_HND win, USHORT event, SHORT value, void * parameter); -static int tida_edt_win_cb (T_MFW_EVENT event,T_MFW_WIN * win); -static int tida_win_cb (T_MFW_EVENT event, T_MFW_WIN * win); -static void tida_main(T_MFW_HND win, USHORT event, SHORT value, void * parameter); -static void reset_edt_attr_sett(int editZone, U32 colIndex, U8 font,U8 mode, - U8 *controls, char *text,U16 size,MfwEdtAttr* attr); - -static MfwHnd win; /* our window */ -static DisplayData DisplayInfo; - -#define MAX_DIG_TIDA 20 /* size of buffer (??) */ -#define MAX_LEN_DATE 11 /* maximum number of digits date*/ -#define MAX_LEN_TIME 6 /* maximum number of digits time*/ -#define DATE_TEXT_X 0 -#define DATE_TEXT_Y 0 - -typedef enum -{ - ALARM, - SETTING -} timeDateMode; +/* removed in FreeCalypso */ -typedef struct -{ - T_MMI_CONTROL mmi_control; - T_MFW_HND parent_win; - T_MFW_HND tida_win; - USHORT display_id1; - USHORT display_id2; - DAT_TIME_CASE state; /* setting state */ -} T_tida; - -typedef struct -{ - T_MMI_CONTROL mmi_control; - T_MFW_HND parent_win; - T_MFW_HND tida_edt_win; - T_MFW_HND kbd_handle; - T_MFW_HND kbd_long_handle; - T_MFW_HND editor_handle; - T_MFW_HND tim_out_handle; - DAT_TIME_CASE state; /* setting state */ - char edtbuf1[MAX_DIG_TIDA]; - MfwEdtAttr edit1Attr; - UBYTE index; -}T_tida_edt; - - - -/* - * Settings menu subs: - */ - -#define TIMERCLEAR 2500 - -//Flag to indicate whether we're setting the current or alarm date/time. -static UBYTE DateTimeEntryMode; - -extern UBYTE getcurrentAlarmTone(void); //mmisounds #endif /* NEW_EDITOR */ T_MFW_HND td_handle; @@ -305,9 +240,9 @@ $Function: time_date_init - $Description: initialises time and date + $Description: initialises time and date - $Returns: none. + $Returns: none. $Arguments: none @@ -321,9 +256,9 @@ $Function: time_date_init - $Description: deletes mfw td + $Description: deletes mfw td - $Returns: none. + $Returns: none. $Arguments: none @@ -337,9 +272,9 @@ $Function: time_date_cb - $Description: handles alarm event from MFW + $Description: handles alarm event from MFW - $Returns: none. + $Returns: none. $Arguments: none @@ -356,9 +291,9 @@ $Function: alarm_screen_cb added for SPR 2184 - $Description: Handles alarm screen keypresses + $Description: Handles alarm screen keypresses - $Returns: none. + $Returns: none. $Arguments: window handle, identifier, reason(key pressed) @@ -409,27 +344,26 @@ $Function: alarm_screen - $Description: displays alarm screen + $Description: displays alarm screen - $Returns: none. + $Returns: none. $Arguments: none *******************************************************************************/ void alarm_screen(void) { - T_MFW_HND idle_win = idle_get_window(); - T_DISPLAY_DATA display_info; - T_MFW_TIME* time; + T_MFW_HND idle_win = idle_get_window(); + T_DISPLAY_DATA display_info; + T_MFW_TIME* time; static char text[25]; - TRACE_FUNCTION("alarm_screen()"); - /*SPR 2639, convert function to use new MFW functions*/ - time = mfw_td_get_time(); + /*SPR 2639, convert function to use new MFW functions*/ + time = mfw_td_get_time(); - sprintf(text, "%02d:%02d", time->hour, time->minute); + sprintf(text, "%02d:%02d", time->hour, time->minute); // Apr 05, 2005 REF: ENH 29994 xdeepadh /*SPR 2639 get current alarm id and play it*/ //Nov 02, 2005 REF:ER OMAPS00039044 xdeepadh @@ -483,20 +417,16 @@ /* Call Info Screen */ info_dialog( idle_win, &display_info ); - - } - - /******************************************************************************* $Function: clear_alarm - $Description: handles menu option to cancel any existing alarm setting + $Description: handles menu option to cancel any existing alarm setting - $Returns: status int + $Returns: status int $Arguments: menu and item (not used) @@ -505,7 +435,6 @@ { T_MFW_HND win = mfwParent( mfw_header() ); T_DISPLAY_DATA display_info; - /*SPR 2639, changed to use new MFW functions*/ mfw_td_cancel_alarm(); @@ -516,9 +445,7 @@ */ info_dialog( win, &display_info ); - return MFW_EVENT_CONSUMED; - } @@ -526,9 +453,9 @@ $Function: twelve_hour_clock - $Description: handles selection of twleve hour clock in menu + $Description: handles selection of twleve hour clock in menu - $Returns: status int + $Returns: status int $Arguments: menu and item (not used) @@ -556,7 +483,7 @@ $Description: handles selection of twleve hour clock in menu - $Returns: status int + $Returns: status int $Arguments: menu and item (not used) *******************************************************************************/ @@ -575,7 +502,6 @@ info_dialog( win, &display_info ); return MFW_EVENT_CONSUMED; - } @@ -584,9 +510,9 @@ $Function: alarmTimeDate $Description: Called when user selects alarm in menu. Begins editor to enter - desired alarm time and date. + desired alarm time and date. - $Returns: status int + $Returns: status int $Arguments: menu and item (not used) @@ -595,18 +521,17 @@ { /* SPR#1428 - SH - New Editor changes */ #ifdef NEW_EDITOR - T_MFW_HND idle_win = idle_get_window(); - T_MFW_HND win = tida_create(idle_win); /* Parent_window is idle */ + T_MFW_HND idle_win = idle_get_window(); + T_MFW_HND win = tida_create(idle_win); /* Parent_window is idle */ - T_MFW_WIN *win_data = ((T_MFW_HDR *)win)->data; - T_tida *data = (T_tida *)win_data->user; + T_MFW_WIN *win_data = ((T_MFW_HDR *)win)->data; + T_tida *data = (T_tida *)win_data->user; TRACE_FUNCTION ("MmiTimeDate:alarmTimeDate()"); if(data->win) { - SEND_EVENT(data->win, TIDA_ALARMDATE,0,0); - + SEND_EVENT(data->win, TIDA_ALARMDATE,0,0); } #else /* NEW_EDITOR */ T_MFW_HND idle_win = idle_get_window(); @@ -633,9 +558,9 @@ $Function: settingsTimeDate - $Description: settings date and time menu function + $Description: settings date and time menu function - $Returns: none. + $Returns: none. $Arguments: @@ -644,18 +569,17 @@ { /* SPR#1428 - SH - New Editor changes */ #ifdef NEW_EDITOR - T_MFW_HND idle_win = idle_get_window(); - T_MFW_HND win = tida_create(idle_win); /* Parent_window is idle */ + T_MFW_HND idle_win = idle_get_window(); + T_MFW_HND win = tida_create(idle_win); /* Parent_window is idle */ - T_MFW_WIN *win_data = ((T_MFW_HDR *)win)->data; - T_tida *data = (T_tida *)win_data->user; + T_MFW_WIN *win_data = ((T_MFW_HDR *)win)->data; + T_tida *data = (T_tida *)win_data->user; TRACE_FUNCTION ("MmiTimeDate:settingsTimeDate()"); if(data->win) { - SEND_EVENT(data->win, TIDA_DATE,0,0); - + SEND_EVENT(data->win, TIDA_DATE,0,0); } #else /* NEW_EDITOR */ T_MFW_HND idle_win = idle_get_window(); @@ -687,11 +611,11 @@ /******************************************************************************* - $Function: tida_create + $Function: tida_create $Description: Create the main time/date window - $Returns: The window handle + $Returns: The window handle $Arguments: parent_win - The parent window @@ -729,11 +653,11 @@ /******************************************************************************* - $Function: tida_destroy + $Function: tida_destroy $Description: Destroy the main time/date window - $Returns: None + $Returns: None $Arguments: win - The main time/date window @@ -766,12 +690,12 @@ /******************************************************************************* - $Function: tida_win_cb + $Function: tida_win_cb $Description: Window callback function for time and date. This is a non-displaying - window, so does nothing! + window, so does nothing! - $Returns: None. + $Returns: None. $Arguments: @@ -787,11 +711,11 @@ /******************************************************************************* - $Function: tida_exec_cb + $Function: tida_exec_cb $Description: Main dialog function for time and date - $Returns: None. + $Returns: None. $Arguments: @@ -807,9 +731,6 @@ TRACE_FUNCTION("MmiTimeDate:tida_main"); - - - switch(event) { case TIDA_INIT: @@ -958,17 +879,17 @@ /******************************************************************************* - $Function: tida_edit_create + $Function: tida_edit_create $Description: Creates an editor with the supplied properties - $Returns: The editor window. + $Returns: The editor window. $Arguments: parent - The parent window - Identifier - ID used in callback to identify type of editor - TitleId - The title of the editor - buffer - The text buffer - formatString - The formatting that governs the input + Identifier - ID used in callback to identify type of editor + TitleId - The title of the editor + buffer - The text buffer + formatString - The formatting that governs the input *******************************************************************************/ @@ -988,15 +909,15 @@ /******************************************************************************* - $Function: tida_edit_cb + $Function: tida_edit_cb $Description: Callback function for editor - $Returns: None + $Returns: None - $Arguments: win - The main time/date window - Identifier - ID used in callback to identify type of editor - value - What prompted the callback + $Arguments: win - The main time/date window + Identifier - ID used in callback to identify type of editor + value - What prompted the callback *******************************************************************************/ @@ -1011,9 +932,6 @@ T_MFW_TIME* currclock; /*SPR 2639*/ //, *tempclock; // RAVI T_MFW_DATE* currdate; - - - switch(value) { /* Terminate editor */ @@ -1190,17 +1108,17 @@ $Description: Displays a dialog - $Returns: None. + $Returns: None. - $Arguments: win - The parent window - textId - Will display "<textId> Not Allowed" + $Arguments: win - The parent window + textId - Will display "<textId> Not Allowed" *******************************************************************************/ void tida_show_dlg(T_MFW_HND win, USHORT textId1, USHORT textId2) { - T_DISPLAY_DATA display_info; - dlg_initDisplayData_TextId( &display_info, TxtNull, TxtNull, textId1, textId2, COLOUR_STATUS); - dlg_initDisplayData_events( &display_info, (T_VOID_FUNC)NULL, THREE_SECS, KEY_CLEAR|KEY_LEFT|KEY_RIGHT ); + T_DISPLAY_DATA display_info; + dlg_initDisplayData_TextId( &display_info, TxtNull, TxtNull, textId1, textId2, COLOUR_STATUS); + dlg_initDisplayData_events( &display_info, (T_VOID_FUNC)NULL, THREE_SECS, KEY_CLEAR|KEY_LEFT|KEY_RIGHT ); /* Call Info Screen */ @@ -1217,7 +1135,7 @@ $Description: Checks a date to see if it's valid - $Returns: TRUE if it's valid, FALSE otherwise + $Returns: TRUE if it's valid, FALSE otherwise $Arguments: datestring - The date string @@ -1282,7 +1200,7 @@ $Description: Checks a time to see if it's valid - $Returns: TRUE if it's valid, FALSE otherwise + $Returns: TRUE if it's valid, FALSE otherwise $Arguments: timestring - The time string @@ -1322,892 +1240,6 @@ #else /* NEW_EDITOR */ /* OLD VERSION */ - -/******************************************************************************* - - $Function: date_time_create - - $Description: create main dialog for time and date (SINGLE_DYNAMIC) - - $Returns: none. - - $Arguments: - -*******************************************************************************/ -T_MFW_HND date_time_create (T_MFW_HND parent_window) -{ - T_MFW_WIN * win; - - T_tida * data = (T_tida *)ALLOC_MEMORY (sizeof (T_tida)); - data->tida_win = win_create (parent_window, 0, MfwWinVisible, (T_MFW_CB)tida_win_cb); - - TRACE_FUNCTION("MmiTimeDate:date_time_create"); - - if (data->tida_win EQ 0) - return 0; - - /* - * Create window handler - */ - data->mmi_control.dialog = (T_DIALOG_FUNC)tida_main;/* dialog main function */ - data->mmi_control.data = data; - data->parent_win = parent_window; - win = ((T_MFW_HDR *)data->tida_win)->data; - win->user = (void *) data; - - - /* - * return window handle - */ - - mfwSetSignallingMethod(1); - winShow(data->tida_win); - - - return data->tida_win; -} -/******************************************************************************* - - $Function: date_time_destroy - - $Description: destroy main dialog for time and date - - $Returns: none. - - $Arguments: - -*******************************************************************************/ -void date_time_destroy (T_MFW_HND own_window) -{ - T_tida * data; - T_MFW_WIN * win; - - if (own_window) - { - TRACE_EVENT("MmiTimeDate:date_time_destroy"); - win = ((T_MFW_HDR *)own_window)->data; - data = (T_tida *)win->user; - - if(data) - { - win_delete (data->tida_win); - FREE_MEMORY((void *)data,(sizeof(T_tida))); - } - } -} -/******************************************************************************* - - $Function: date_time_edt_create - - $Description: create editor dialog for time and date(SINGLE_DYNAMIC) - - $Returns: none. - - $Arguments: - -*******************************************************************************/ -T_MFW_HND date_time_edt_create(T_MFW_HND parent_window) -{ - T_tida_edt * data = (T_tida_edt *)ALLOC_MEMORY (sizeof (T_tida_edt)); - - T_MFW_WIN * win; - - data->tida_edt_win = win_create (parent_window, 0, MfwWinVisible, (T_MFW_CB)tida_edt_win_cb); - - TRACE_FUNCTION("MmiTimeDate:date_time_edt_create"); - - if (data->tida_edt_win EQ 0) - return 0; - - /* - * Create window handler - */ - data->mmi_control.dialog = (T_DIALOG_FUNC)tida_editor; - data->mmi_control.data = data; - data->parent_win = parent_window; - win = ((T_MFW_HDR *)data->tida_edt_win)->data; - win->user = (void *) data; - /* - * Create any other handler - */ - editor_attr_init(&data->edit1Attr, TIMEDATE_EDITOR_AREA, edtCurBar1 | edtModOverWr, 0, (char*)data->edtbuf1,MAX_DIG_TIDA,COLOUR_EDITOR_XX ); - - data->tim_out_handle = tim_create(data->tida_edt_win,TIMERCLEAR,(T_MFW_CB)tida_edt_tim_out_cb); - data->editor_handle = edt_create(data->tida_edt_win,&data->edit1Attr,0,0); - data->kbd_handle = kbd_create(data->tida_edt_win,KEY_ALL,(T_MFW_CB)tida_edt_kbd_cb); - data->kbd_long_handle = kbd_create(data->tida_edt_win,KEY_ALL | KEY_LONG,(T_MFW_CB)tida_edt_kbd_long_cb); - /* - * return window handle - */ - return data->tida_edt_win; -} -/******************************************************************************* - - $Function: date_time_edt_destroy - - $Description: destroy editor dialog for time and date - - $Returns: none. - - $Arguments: - -*******************************************************************************/ -void date_time_edt_destroy (T_MFW_HND own_window) -{ - T_tida_edt * data ; - T_MFW_WIN * win; - - - if (own_window) - { - TRACE_FUNCTION ("MmiTimeDate:date_time_edt_destroy"); - - win = ((T_MFW_HDR *)own_window)->data; - data = (T_tida_edt *)win->user; - - if(data) - { - win_delete (data->tida_edt_win); - FREE_MEMORY((void *)data,(sizeof(T_tida_edt))); - } - } -} -/******************************************************************************* - - $Function: tida_main - - $Description: main dialog function for time and date - - $Returns: none. - - $Arguments: - -*******************************************************************************/ -static void tida_main(T_MFW_HND win, USHORT event, SHORT value, void * parameter) -{ - T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data; - T_tida * tida_data = (T_tida *)win_data->user;//tida main data - T_tida_edt * tida_edt_data = (T_tida_edt *) parameter;//tida editor data - T_MFW_HND tida_edt_win; - T_DISPLAY_DATA display_info; - - TRACE_FUNCTION("MmiTimeDate:tida_main"); - - switch(event) - { - case DATE_SHOW: - tida_data->state = DATE_SHOW; - tida_data->display_id1 = TxtEnterDate; - tida_edt_win = date_time_edt_create(tida_data->tida_win); - if(tida_edt_win) - { - SEND_EVENT(tida_edt_win,event,0,tida_data); - } - break; - case DATE_ENTRY: - tida_data->state = DATE_ENTRY; - tida_data->display_id1 = TxtEnterDate; - tida_edt_win = date_time_edt_create(tida_data->tida_win); - { - SEND_EVENT(tida_edt_win,event,0,tida_data); - } - break; - case TIME_ENTRY: - tida_data->state = TIME_ENTRY; - tida_data->display_id1 = TxtEnterTime; - tida_edt_win = date_time_edt_create(tida_data->tida_win); - { - SEND_EVENT(tida_edt_win,event,0,tida_data); - } - break; - case TIME_SHOW: - tida_data->state = TIME_SHOW; - tida_data->display_id1 = TxtEnterTime; - tida_edt_win = date_time_edt_create(tida_data->tida_win); - if(tida_edt_win) - { - SEND_EVENT(tida_edt_win,event,0,tida_data); - } - break; - case ENTRY_OK: - dlg_initDisplayData_TextId( &display_info, TxtNull, TxtNull, TxtSaved, TxtNull, COLOUR_STATUS); - dlg_initDisplayData_events( &display_info, (T_VOID_FUNC)tida_info_cb, THREE_SECS, KEY_ALL ); - display_info.Identifier = SAVED; - info_dialog(tida_data->tida_win,&display_info); /* information screen "Saved" */ - break; - case SAVED: - case TIDA_ABORT: - case TIDA_CLEAR: - case TIDA_TO_IDLE: - date_time_destroy(tida_data->tida_win); - break; - default: - break; - } -} -/******************************************************************************* - - $Function: tida_info_cb - - $Description: callback function from info dialog for time and date - - $Returns: none. - - $Arguments: - -*******************************************************************************/ -void tida_info_cb(T_MFW_HND win, USHORT identifier, UBYTE reasons) -{ - T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data; - T_tida * tida_data = (T_tida *)win_data->user; - - TRACE_FUNCTION ("MmiTimeDate: tida_info_cb"); - - switch(identifier) - { - case SAVED: - SEND_EVENT(tida_data->tida_win,identifier,0,NULL); - break; - default: - break; - } -} - -/******************************************************************************* - - $Function: tida_win_cb - - $Description: windows main callback function for time and date - - $Returns: none. - - $Arguments: - -*******************************************************************************/ -static int tida_win_cb (T_MFW_EVENT event, T_MFW_WIN * win) -{ -TRACE_FUNCTION ("MmiTimeDate: tida_win_cb"); - if (event EQ MfwWinVisible) - { - /* - * Top Window has no output - */ - dspl_ClearAll(); - return 1; - } - return 0; -} -/******************************************************************************* - - $Function: tida_edt_win_cb - - $Description: windows callback function for editor for time and date - - $Returns: none. - - $Arguments: - -*******************************************************************************/ -static int tida_edt_win_cb (T_MFW_EVENT event,T_MFW_WIN * win) -{ - - - T_tida_edt * edt_data = (T_tida_edt *)win->user;//tida edt data - T_MFW_WIN * win_tida =((T_MFW_HDR *)edt_data->parent_win)->data; - T_tida * tida_data = (T_tida *)win_tida->user; // tida main data - char lin1[MAX_LEN_DATE]; - char lin2[MAX_LEN_TIME]; - T_MFW_TIME* currclock; /*SPR 2639*/ - T_MFW_DATE* currdate; - //T_MFW_TIME alarmTime; /*SPR 2639*/ - - - currclock = mfw_td_get_time(&currclock);/*SPR 2639*/ - currdate = mfw_td_get_date(&currdate); - - - TRACE_FUNCTION ("MmiTimeDate:tida_edt_win_cb"); - - if (event EQ MfwWinVisible) - { - dspl_ClearAll(); - PROMPT(DATE_TEXT_X,DATE_TEXT_Y,0,tida_data->display_id1); - softKeys_displayId(TxtSoftOK,TxtSoftBack,0,COLOUR_EDITOR_XX); - - - if(tida_data->state EQ DATE_SHOW) - { - if ((DateTimeEntryMode == SETTING) || (alarmDate.day == 0)) - { if (currdate->day == 0) //if no date set - sprintf(lin1,"dd/mm/yyyy"); - else - sprintf(lin1,"%02d/%02d/%04d",currdate->day,currdate->month,currdate->year); - } - else - sprintf(lin1,"%02d/%02d/%04d",alarmDate.day,alarmDate.month,alarmDate.year); - - strncpy(edt_data->edtbuf1,lin1,MAX_LEN_DATE); - edtShow(edt_data->editor_handle); - } - else if(tida_data->state EQ DATE_ENTRY) - { - if ((DateTimeEntryMode == SETTING) || (alarmDate.day == 0)) - { if (currdate->day == 0) - sprintf(lin1,"dd/mm/yyyy");//if no date set - else - sprintf(lin1,"%02d/%02d/%04d",currdate->day,currdate->month,currdate->year); - } - else - { - sprintf(lin1,"%02d/%02d/%04d",alarmDate.day,alarmDate.month,alarmDate.year); - } - strncpy(edt_data->edtbuf1,lin1,MAX_LEN_DATE); - edt_data->index = 0; - edtShow(edt_data->editor_handle); - softKeys_displayId(TxtSoftOK,TxtSoftBack,0,COLOUR_EDITOR_XX); - } - else if(tida_data->state EQ TIME_ENTRY) - { - if ((DateTimeEntryMode == SETTING) || (alarmDate.day==0)) - sprintf(lin2,"%02d:%02d",mfw_td_convert_to_24_hour(currclock), currclock->minute); - else - sprintf(lin2,"%02d:%02d",alarmTime.hour, alarmTime.minute); - strncpy(edt_data->edtbuf1,lin2,MAX_LEN_TIME); - edt_data->index = 0; - edtShow(edt_data->editor_handle); - softKeys_displayId(TxtSoftOK,TxtSoftBack,0,COLOUR_EDITOR_XX); - } - else if(tida_data->state EQ TIME_SHOW) - { if ((DateTimeEntryMode == SETTING) || (alarmDate.day == 0)) - sprintf(lin2,"%02d:%02d",mfw_td_convert_to_24_hour(currclock), currclock->minute); - else - sprintf(lin2,"%02d:%02d",alarmTime.hour, alarmTime.minute); - strncpy(edt_data->edtbuf1,lin2,MAX_LEN_TIME); - edtShow(edt_data->editor_handle); - } - return 1; - } - return 0; - -} -/******************************************************************************* - - $Function: tida_editor - - $Description: dialog function for editor for time and date - - $Returns: none. - - $Arguments: - -*******************************************************************************/ -static void tida_editor(T_MFW_HND win, USHORT event, SHORT value, void * parameter) -{ - T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data; - T_tida_edt * edt_data = (T_tida_edt *)win_data->user; - - - T_tida * tida_data = (T_tida *)parameter;//tida main data - - edt_data->state = tida_data->state; - - TRACE_FUNCTION("MmiTimeDate:tida_editor"); - - /* - * depending on event - */ - switch (event) - { - case DATE_SHOW: - case TIME_SHOW: - memset(edt_data->edtbuf1, '\0', sizeof(edt_data->edtbuf1));/* initial buffer */ - edt_data->index = 0; - winShow(edt_data->tida_edt_win); - break; - case DATE_ENTRY: - case TIME_ENTRY: - winShow(edt_data->tida_edt_win); - break; - default: - break; - } -} -/******************************************************************************* - - $Function: tida_edt_kbd_cb - - $Description: keyboard event handler for time and date - - $Returns: none. - - $Arguments: - -*******************************************************************************/ -static int tida_edt_kbd_cb (MfwEvt e, MfwKbd *kc) -{ - - T_MFW_HND win = mfw_parent(mfw_header()); - - T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data; - T_tida_edt * edt_data = (T_tida_edt *)win_data->user;//tida edt data - - T_MFW_WIN * win_tida =((T_MFW_HDR *)edt_data->parent_win)->data; - T_tida * tida_data = (T_tida *)win_tida->user; // tida main data - - char lin1[MAX_LEN_DATE]; - char lin2[MAX_LEN_TIME]; - T_MFW_TIME* currclock; /*SPR 2639*/ - currclock = mfw_td_get_time();/*SPR 2639*/ - - TRACE_FUNCTION ("MmiTimeDate: tida_edt_kbd_cb"); +/* removed in FreeCalypso */ - switch(kc->code) - { - case KCD_0: - case KCD_1: - case KCD_2: - case KCD_3: - case KCD_4: - case KCD_5: - case KCD_6: - case KCD_7: - case KCD_8: - case KCD_9: - if(edt_data->state EQ DATE_ENTRY) /* date entering */ - { - if(edt_data->index < (MAX_LEN_DATE - 1)) - { - if((edt_data->index NEQ 2) && (edt_data->index NEQ 5)) - { - edt_data->edtbuf1[edt_data->index] = '0' + kc->code; - edtChar(edt_data->editor_handle,edt_data->edtbuf1[edt_data->index]); - edt_data->index++; - } - - if((edt_data->index EQ 2) || (edt_data->index EQ 5)) - { - edtChar(edt_data->editor_handle,'/'); - edt_data->edtbuf1[edt_data->index] = '/'; - edt_data->index++; - } - } - } - else if(edt_data->state EQ TIME_ENTRY) /* time entering */ - { - if(edt_data->index < (MAX_LEN_TIME -1)) - { - if(edt_data->index NEQ 2) - { - edt_data->edtbuf1[edt_data->index] = '0' + kc->code; - edtChar(edt_data->editor_handle,edt_data->edtbuf1[edt_data->index]); - edt_data->index++; - } - if(edt_data->index EQ 2) - { - edtChar(edt_data->editor_handle,':'); - edt_data->edtbuf1[edt_data->index] = ':'; - edt_data->index++; - } - } - } - break; - case KCD_MNUSELECT: - case KCD_LEFT: /* select and ok button */ - if(edt_data->state EQ DATE_ENTRY) - { - if(check_date(win,edt_data)) - { - - TRACE_EVENT("datecheck ok"); - edtClear(edt_data->editor_handle); - edtHide(edt_data->editor_handle); /* verification date successfull */ - date_time_edt_destroy(edt_data->tida_edt_win); - SEND_EVENT(tida_data->tida_win,TIME_ENTRY,0,tida_data); - - } - else - { - memset(edt_data->edtbuf1, '\0', sizeof(edt_data->edtbuf1));/* initial buffer */ - edt_data->index = 0; - - sprintf(lin1,"dd/mm/yyyy"); - strncpy(edt_data->edtbuf1,lin1,MAX_LEN_DATE); - edtReset(edt_data->editor_handle); - edtShow(edt_data->editor_handle); - } - } - else if(edt_data->state EQ TIME_ENTRY) - { - if(check_time(win,edt_data)) - { - TRACE_EVENT("timecheck ok"); - edtClear(edt_data->editor_handle); - edtHide(edt_data->editor_handle); /* verification date successfull */ - date_time_edt_destroy(edt_data->tida_edt_win); - SEND_EVENT(tida_data->tida_win,ENTRY_OK,0,tida_data); - } - else - { - memset(edt_data->edtbuf1, '\0', sizeof(edt_data->edtbuf1));/* initial buffer */ - edt_data->index = 0; - - sprintf(lin2,"%02d:%02d",mfw_td_convert_to_24_hour(currclock), currclock->minute); - strncpy(edt_data->edtbuf1,lin2,MAX_LEN_TIME); - edtReset(edt_data->editor_handle); - edtShow(edt_data->editor_handle); - } - } - else if(edt_data->state EQ DATE_SHOW) - { - date_time_edt_destroy(edt_data->tida_edt_win); - SEND_EVENT(tida_data->tida_win,DATE_ENTRY,0,tida_data); - } /* start date entering */ - - else if(edt_data->state EQ TIME_SHOW) - { - date_time_edt_destroy(edt_data->tida_edt_win); - SEND_EVENT(tida_data->tida_win,TIME_ENTRY,0,tida_data); /* start time entering */ - } - break; - case KCD_RIGHT: /* back to previous menu */ - date_time_edt_destroy(edt_data->tida_edt_win); - SEND_EVENT(tida_data->tida_win,TIDA_ABORT,0,tida_data); - break; - case KCD_MNUUP: /* cursor to right */ - if((edt_data->state EQ DATE_ENTRY) || (edt_data->state EQ TIME_ENTRY)) /* cursor to rigt */ - { - edt_data->index++; - edtChar(edt_data->editor_handle,ecRight); - - if(((edt_data->state EQ DATE_ENTRY) && ((edt_data->index EQ 2)||(edt_data->index EQ 5))) || ((edt_data->state EQ TIME_ENTRY) && (edt_data->index EQ 2))) - { - edt_data->index++; - edtChar(edt_data->editor_handle,ecRight); - } - - } - break; - case KCD_HUP: - case KCD_MNUDOWN: /* cursor to left or clear */ - if((!(edt_data->state EQ DATE_SHOW)) && (!(edt_data->state EQ TIME_SHOW))) - { - if(edt_data->state EQ DATE_ENTRY) - { - if(edt_data->index EQ 0) - ; - else - edt_data->index--; - - if((edt_data->index EQ 2)||(edt_data->index EQ 5)) - { - if(edt_data->index EQ 0) - ; - else - edt_data->index--; - - edtChar(edt_data->editor_handle,ecLeft); - edtChar(edt_data->editor_handle,ecLeft); - } - else - edtChar(edt_data->editor_handle,ecLeft); - } - if(edt_data->state EQ TIME_ENTRY) - { - if(edt_data->index EQ 0) - ; - else - edt_data->index--; - - if(edt_data->index EQ 2) - { - if(edt_data->index EQ 0) - ; - else - edt_data->index--; - - edtChar(edt_data->editor_handle,ecLeft); - edtChar(edt_data->editor_handle,ecLeft); - } - else - edtChar(edt_data->editor_handle,ecLeft); - } - } - else - timStart(edt_data->tim_out_handle); /* waiting for release clear otherwise to previous screen */ - break; - default: - return MFW_EVENT_CONSUMED; - } - return MFW_EVENT_CONSUMED; -} - -/******************************************************************************* - - $Function: check_date - - $Description: check date after date entering - - $Returns: none. - - $Arguments: - -*******************************************************************************/ -static int check_date (T_MFW_HND win, void * edt_dat) -{ - U8 i; - T_tida_edt * edt_data = (T_tida_edt *)edt_dat; - T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data; - T_tida * tida_data = (T_tida *)win_data->user; - T_MFW_DATE tempdate; - - char internday[3]; - char internmonth[3]; - char internyear[5]; - - char debug[20]; - T_MFW_TIME* currclock; /*SPR 2639*/ - T_MFW_DATE* currdate; - //T_MFW_TIME alarmTime; /*SPR 2639*/ - - - currclock= mfw_td_get_time();/*SPR 2639*/ - currdate =mfw_td_get_date(); - - TRACE_FUNCTION ("MmiTimeDate:check_date"); - - memset(internday, '\0', sizeof(internday));/* initial string */ - memset(internmonth, '\0', sizeof(internmonth)); - memset(internyear, '\0', sizeof(internyear)); - - internday[0] = edt_data->edtbuf1[0]; - internday[1] = edt_data->edtbuf1[1]; - internmonth[0] = edt_data->edtbuf1[3]; - internmonth[1] = edt_data->edtbuf1[4]; - for(i = 0;i<4;i++) - { - internyear[i] = edt_data->edtbuf1[6+i]; - } - - tempdate.month = atoi(internmonth); - if((tempdate.month > 12) || (tempdate.month < 1)) - return FALSE; - - tempdate.day = atoi(internday); - if((tempdate.day > 30) || (tempdate.day < 1)) - { - if(tempdate.day EQ 31) - { - switch(tempdate.month) - { - case 1: - case 3: - case 5: - case 7: - case 8: - case 10: - case 12: - break; - default: - return FALSE; - - } - } - else - return FALSE; - } - - tempdate.year = atoi(internyear); - - if(tempdate.year < 2000) - return FALSE; - - if((tempdate.month EQ 2) && (tempdate.day EQ 29)) - { - if(!(tempdate.year%4) || (tempdate.year EQ 2000)) - { - if(DateTimeEntryMode == ALARM) - { - alarmDate.day = tempdate.day; - alarmDate.month = tempdate.month; - alarmDate.year = tempdate.year; - } - else - { - - currdate->day = tempdate.day; - currdate->month = tempdate.month; - currdate->year = tempdate.year; - mfw_td_set_date(currdate);/*SPR 2639*/ - } - return TRUE; - } - else - return FALSE; - } - else - { - if(DateTimeEntryMode == ALARM) - { - - - alarmDate.day = tempdate.day; - alarmDate.month = tempdate.month; - alarmDate.year = tempdate.year; - - } - else - { - currdate->day = tempdate.day; - currdate->month = tempdate.month; - currdate->year = tempdate.year; - } - mfw_td_set_date(currdate);/*SPR 2639*/ - return TRUE; - } -} -/******************************************************************************* - - $Function: check_time - - $Description: check time after time entering - - $Returns: none. - - $Arguments: - -*******************************************************************************/ -static int check_time (T_MFW_HND win, void * edt_dat) -{ - T_tida_edt * edt_data = (T_tida_edt *)edt_dat; - T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data; - T_tida * tida_data = (T_tida *)win_data->user; - T_MFW_TIME tempclock; - char debug[50]; - char internmin[3]; - char internhour[3]; - T_MFW_TIME* currclock; /*SPR 2639*/ - T_MFW_DATE* currdate; - T_MFW_TIME_FORMAT current_format; - //T_MFW_TIME alarmTime; /*SPR 2639*/ - - currclock = mfw_td_get_time();/*SPR 2639*/ - currdate = mfw_td_get_date(); - - current_format = currclock->format; - memset(internmin, '\0', sizeof(internmin));/* initial string */ - memset(internhour, '\0', sizeof(internhour)); - - internhour[0] = edt_data->edtbuf1[0]; - internhour[1] = edt_data->edtbuf1[1]; - internmin[0] = edt_data->edtbuf1[3]; - internmin[1] = edt_data->edtbuf1[4]; - - tempclock.hour = atoi(internhour); - if(tempclock.hour > 23) - return FALSE; - - tempclock.minute = atoi(internmin); - if(tempclock.minute >59) - return FALSE; - if (DateTimeEntryMode == ALARM) - { - alarmTime.hour = tempclock.hour; /*SPR 2639*/ - alarmTime.minute = tempclock.minute; - alarmTime.format = MFW_TIME_FORMAT_24HOUR; - mfw_td_set_alarm(&alarmTime, &alarmDate); - } - else - { - - - currclock->hour = tempclock.hour; - currclock->minute = tempclock.minute; - currclock->format = MFW_TIME_FORMAT_24HOUR; - mfw_td_set_time(currclock);/*SPR 2639*/ - mfw_td_set_time_format(current_format); - } - - return TRUE; -} -/******************************************************************************* - - $Function: tida_edt_tim_out_cb - - $Description: Callback function for timer for time and date - - $Returns: none. - - $Arguments: - -*******************************************************************************/ -static void tida_edt_tim_out_cb(T_MFW_EVENT event,T_MFW_TIM * t) -{ - T_MFW_HND win = mfw_parent(mfw_header()); - - T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data; - T_tida_edt * tida_edt_data = (T_tida_edt *)win_data->user; - - T_MFW_WIN * win_tida =((T_MFW_HDR *)tida_edt_data->parent_win)->data; - T_tida * tida_data = (T_tida *)win_tida->user; // tida main data - - date_time_edt_destroy(tida_edt_data->tida_edt_win); - SEND_EVENT(tida_data->tida_win,TIDA_CLEAR,0,tida_data); - -} -/******************************************************************************* - - $Function: tida_edt_kbd_long_cb - - $Description: keyboard long event handler for time and date - - $Returns: none. - - $Arguments: - -*******************************************************************************/ -static int tida_edt_kbd_long_cb (MfwEvt e, MfwKbd *kc) -{ - T_MFW_HND win = mfw_parent(mfw_header()); - - T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data; - T_tida_edt * edt_data = (T_tida_edt *)win_data->user;//tida edt data - - T_MFW_WIN * win_tida =((T_MFW_HDR *)edt_data->parent_win)->data; - T_tida * tida_data = (T_tida *)win_tida->user; // tida main data - - TRACE_FUNCTION("MmiTimeDate:tida_edt_kbd_long_cb"); - - if ((e & KEY_CLEAR) && (e & KEY_LONG)) - { - - if((!(edt_data->state EQ DATE_SHOW)) && (!(edt_data->state EQ TIME_SHOW))) - { - - if(edt_data->state EQ DATE_ENTRY) - { - date_time_edt_destroy(edt_data->tida_edt_win); - SEND_EVENT(tida_data->tida_win,DATE_SHOW,0,tida_data); - } - else if(edt_data->state EQ TIME_ENTRY) - { - date_time_edt_destroy(edt_data->tida_edt_win); - - SEND_EVENT(tida_data->tida_win,TIME_ENTRY,0,tida_data); - - } - return MFW_EVENT_CONSUMED; - - } - else - { - timStop(edt_data->tim_out_handle); - date_time_edt_destroy(edt_data->tida_edt_win); - SEND_EVENT(tida_data->tida_win,TIDA_TO_IDLE,0,tida_data); - return MFW_EVENT_CONSUMED; - } - } - else - return MFW_EVENT_CONSUMED; -} #endif /* NEW_EDITOR */ -