📄 auiwap.c
字号:
data->Format = (char *)AUI_wap_memory_alloc ((INPUT_MAX_LEN+1)*sizeof(char)); // Input format string
data->Message = (char *)AUI_wap_memory_alloc ((URL_MAX_LEN+1)*sizeof(char)); // Message buffer (URL generally longest string we'll use)
data->LeftSoftKey = (char *)AUI_wap_memory_alloc ((SOFTKEY_MAX_LEN+1)*sizeof(char)); // Left softkey text
//data->RightSoftKey = (char *)AUI_wap_memory_alloc ((SOFTKEY_MAX_LEN+1)*sizeof(char)); // Right softkey text
data->RightSoftKey = (char *)AUI_wap_memory_alloc (((SOFTKEY_MAX_LEN)*2+3)*sizeof(char)); // Right softkey text
// Create list for options menu
data->OptionsList = ATB_wap_entry_list_create(WAP_OPTIONS_LIST, MAX_OPTIONS+1, OPTIONS_MAX_LEN); // Options menu list
/* SPR#1569 - SH - Generate "Please wait" window while WAP starts up */
data->temp_win = AUI_please_wait(data->win);
data->timer = timCreate(data->win, ONE_SECS, (MfwCb)AUI_wap_startup_begin);
timStart(data->timer);
return data->win;
}
/* SPR#1569 - SH - Added this function */
int AUI_wap_startup_begin(MfwEvt evt, MfwTim timer)
{
T_MFW_HND win = wap_main_window;
T_MFW_WIN *win_data = ((T_MFW_HDR *)win)->data;
T_WAP_DATA *data = (T_WAP_DATA *)win_data->user; // WAP data
T_MMI_WAP_START_IND wap_start; // dummy parameter for the wap start event
// Create Profile (read in bookmarks, history etc).
timDelete(data->timer);
data->timer = NULL;
ATB_wap_start(&wap_start); // wap_start is just a dummy parameter
return 1;
}
/*******************************************************************************
$Function: AUI_destroy
$Description: Destroys the specified WAP windows and their data
$Returns: void
$Arguments: win - pointer to the browser window
windows - determines which windows will be destroyed.
(e.g. LIST_WIN | EDIT_WIN | OPTIONS_WIN | WAP_WIN)
*******************************************************************************/
void AUI_destroy (T_MFW_HND win, USHORT windows)
{
T_MFW_WIN *win_data = ((T_MFW_HDR *)win)->data;
T_WAP_DATA *data = (T_WAP_DATA *)win_data->user; // WAP data
USHORT entryIndex;
#ifdef TRACE_AUIWAP
UBYTE trackIndex;
TRACE_FUNCTION("AUI_destroy");
#endif
WAP_TRACE_EVENT(("hyl,AUI_destroy,%d",windows));
if (data==NULL)
return;
if ((windows & BROWSER_WIN) && (data->browser_win != NULL)) // Destroy WAP browser window
{
#ifdef TRACE_AUIWAP
TRACE_FUNCTION("AUI_destroy browser");
#endif
/* Cancel any pending operation */
ATB_wap_stop_download(data->View);
/* SPR#1739 - SH - Destroy the error dialog if it exists */
if (data->error_win)
{
SEND_EVENT(data->error_win, DIALOG_DESTROY, 0, 0);
data->error_win = NULL;
}
/* Destroy the browser */
AUI_win_destroy(data->browser_win);
data->browser_win = NULL;
/* SPR#1189 - SH - Connecting window is now explicitly destroyed, see below */
/* We're now no longer connected */
data->connected = FALSE;
}
/* SPR#1189 - SH - Can destroy connect window explicitly */
if ((windows & CONNECT_WIN) && (data->connect_win != NULL)) // Destroy "connecting" window
{
SEND_EVENT(data->connect_win,DIALOG_DESTROY,0,0);
data->connect_win = NULL;
}
if ((windows & MENU_WIN) && (data->menu_win != NULL)) // Destroy main WAP menu
{
#ifdef TRACE_AUIWAP
TRACE_FUNCTION("AUI_destroy menu");
#endif
bookMenuDestroy(data->menu_win);
data->menu_win = NULL;
}
if ((windows & OTHER_MENU_WIN) && (data->other_menu_win != NULL)) // Destroy other WAP menu wyj
{
#ifdef TRACE_AUIWAP
TRACE_FUNCTION("AUI_destroy other menu");
#endif
TRACE_FUNCTION("data->other_menu_win = %d", data->other_menu_win);
bookMenuDestroy(data->other_menu_win);
data->other_menu_win = NULL;
}
if ((windows & OPTIONSMENU_WIN) && (data->optionsmenu_win != NULL)) // Destroy options menu
{
#ifdef TRACE_AUIWAP
TRACE_FUNCTION("AUI_destroy optionsmenu");
#endif
// Remove all options list entries
for (entryIndex=0; entryIndex<(data->OptionsList->no_of_entries); entryIndex++)
{
if (data->OptionsList->Entry[entryIndex]!=NULL)
{
//AUI_wap_memory_free((UBYTE *)data->OptionsList->Entry[entryIndex], (strlen(data->OptionsList->Entry[entryIndex])+1)*sizeof(char)); // Destroy each entry
AUI_wap_memory_free((UBYTE *)data->OptionsList->Entry[entryIndex], (wstrlen(data->OptionsList->Entry[entryIndex])+3)*sizeof(char)); // Destroy each entry
data->OptionsList->Entry[entryIndex] = NULL;
}
}
if (data->optionsmenu_data) // For empty list, this memory is not allocated
{
AUI_wap_memory_free((UBYTE *)data->optionsmenu_data->List, (data->optionsmenu_data->ListLength)*sizeof(T_MFW_MNU_ITEM));
AUI_wap_memory_free((UBYTE *)data->optionsmenu_data, sizeof(ListMenuData)); // Destroy menu */
data->optionsmenu_data = NULL; // Destroy menu items list
}
listsDestroy(data->optionsmenu_win); // Same for list window
data->optionsmenu_win = NULL;
}
if ((windows & LIST_WIN) && (data->list_win != NULL)) // Destroy entry list
{
#ifdef TRACE_AUIWAP
TRACE_FUNCTION("AUI_destroy list");
#endif
if (data->list_data) // For empty list, this memory is not allocated
{
AUI_wap_memory_free((UBYTE *)data->list_data->List, (data->list_data->ListLength)*sizeof(T_MFW_MNU_ITEM));
AUI_wap_memory_free((UBYTE *)data->list_data, sizeof(ListMenuData)); // Destroy list */
data->list_data = NULL; // Destroy menu items list
}
listsDestroy(data->list_win); // Same for list window
data->list_win = NULL;
}
if ((windows & OPTIONS_WIN) && (data->options_win != NULL)) // Entry options menu (e.g. Bookmark options)
{
#ifdef TRACE_AUIWAP
TRACE_EVENT("AUI_destroy options");
#endif
bookMenuDestroy(data->options_win);
data->options_win = NULL;
}
if ((windows & EDIT_WIN) && (data->edit_win != NULL)) // Edit window
{
#ifdef TRACE_AUIWAP
TRACE_EVENT("AUI_destroy editor");
#endif
if( text_input_flag == 1 )
{
text_input_destroy(data->edit_win);
text_input_flag = 0;
}
else
{
editor_destroy(data->edit_win);
}
data->edit_win = NULL;
}
if (windows & WAP_WIN) // Destroy WAP data win (exiting WAP)
{
#ifdef TRACE_AUIWAP
TRACE_EVENT("AUI_destroy WAP");
#endif
/* SPR#1569 - SH - Destroy now happens in stages
* Display "Please wait" dialog; WAP destroy will complete on callback */
data->temp_win = AUI_please_wait(data->win);
ATB_wap_destroy(); // Destroy all views
}
#ifdef TRACE_AUIWAP
TRACE_EVENT("AUI_destroy end");
#endif
#ifdef TRACE_MEMALLOC
for (trackIndex = 0; trackIndex<110; trackIndex++) // Used to track memory allocations
{
sprintf(test_string, "TRACKINDEX %d is %d", trackIndex, memTracker[trackIndex]);
TRACE_EVENT(test_string);
}
#endif
return;
}
/*******************************************************************************
$Function: AUI_wap_close_view_done
$Description: SPR#1569 - SH - Added this function
Called when a view has been closed
$Returns: void
$Arguments: None
*******************************************************************************/
void AUI_wap_close_view_done(void)
{
#ifdef TRACE_AUIWAP
TRACE_FUNCTION("AUI_wap_close_view_done");
#endif
ATB_wap_destroy();
}
/*******************************************************************************
$Function: AUI_wap_terminate_done
$Description: SPR#1569 - SH - Added this function
Called when a WAP termination is complete
$Returns: void
$Arguments: None
*******************************************************************************/
void AUI_wap_terminate_done(void)
{
T_MFW_HND win = wap_main_window;
T_MFW_WIN *win_data = ((T_MFW_HDR *)win)->data;
T_WAP_DATA *data = (T_WAP_DATA *)win_data->user; // WAP data
#ifdef TRACE_AUIWAP
TRACE_FUNCTION("AUI_wap_terminate_done");
#endif
if (data->temp_win)
{
SEND_EVENT(data->temp_win, DIALOG_DESTROY, NULL, NULL);
data->temp_win = NULL;
}
if (data!=NULL)
{
AUI_wap_memory_free ((UBYTE *)data->Buffer, (INPUT_MAX_LEN+1)*sizeof(char)); // Delete input buffer 1
AUI_wap_memory_free ((UBYTE *)data->Buffer2, (INPUT_MAX_LEN+1)*sizeof(char)); // Delete input buffer 2
AUI_wap_memory_free ((UBYTE *)data->Format, (INPUT_MAX_LEN+1)*sizeof(char)); // Delete format string
AUI_wap_memory_free ((UBYTE *)data->Message, (URL_MAX_LEN+1)*sizeof(char)); // Delete output buffer
AUI_wap_memory_free ((UBYTE *)data->LeftSoftKey, (SOFTKEY_MAX_LEN+1)*sizeof(char)); // Delete left softkey text
AUI_wap_memory_free ((UBYTE *)data->RightSoftKey, ((SOFTKEY_MAX_LEN)*2+3)*sizeof(char)); // Delete right softkey text
//AUI_wap_memory_free ((UBYTE *)data->RightSoftKey, (SOFTKEY_MAX_LEN+1)*sizeof(char)); // Delete right softkey text
ATB_wap_entry_list_destroy(data->OptionsList); // Destroy options menu list
win_delete(data->win); // Destroy the WAP data window
wap_main_window = 0;
AUI_wap_memory_free ((UBYTE *)data, sizeof (T_WAP_DATA)); // Destroy main data structure
}
return;
}
/*******************************************************************************
$Function: AUI_cb
$Description: Callback function for WAP data window. This window displays "not
connected", since its appearance means a connection failure has
occurred. Apart from this, all information to be displayed should be
in the other WAP windows (browser window, options window etc).
$Returns: void
$Arguments: event - window handle event
win - WAP browser window
*******************************************************************************/
static int AUI_cb (T_MFW_EVENT event, T_MFW_WIN * win)
{
#ifdef TRACE_AUIWAP
TRACE_FUNCTION("AUI_cb");
#endif
switch (event)
{
case E_WIN_VISIBLE:
if (win->flags & E_WIN_VISIBLE)
{
dspl_ClearAll(); // Clear the browser area
/* SPR#1365 - SH - If this screen is displayed, the connection has been
* terminated, so display 'Not Connected' */
PROMPT(4,12,0, TxtNotConnected); //"disconnected" //"connecting"
displaySoftKeys(TxtReload,TxtExit); // Default "back" soft key
}
break;
}
return;
}
/*******************************************************************************
$Function: AUI_main_kbd_cb
$Description:
$Returns:
$Arguments:
*******************************************************************************/
static int AUI_main_kbd_cb(T_MFW_EVENT event, T_MFW_KBD *keyboard)
{
T_MFW_HND win = mfwParent( mfw_header());
T_MFW_WIN *win_data = ((T_MFW_HDR *)win)->data;
T_WAP_DATA *data = (T_WAP_DATA *)win_data->user; // WAP data
#ifdef TRACE_AUIWAP
TRACE_FUNCTION("AUI_main_kbd_cb");
#endif
TRACE_EVENT("AUI_main_kbd_cb_zhao");
switch (keyboard->code)
{
case KCD_HUP:
case KCD_RIGHT:
AUI_destroy(data->win, ALL_WIN);
break;
case KCD_LEFT:
AUI_connect_URL(data->win, data->View->URL);
break;
default:
break;
}
return MFW_EVENT_CONSUMED;
}
/*******************************************************************************
$Function: AUI_control
$Description: Dialog function for WAP data window. Since this window only
displays the "not connected" message, currently this function can
only show the window.
$Returns: void
$Arguments: win - WAP data window
event - Window handle event
value - not used
parameter - not used
*******************************************************************************/
void AUI_control (T_MFW_HND win, USHORT event, SHORT value, void * parameter)
{
T_MFW_WIN *win_data = ((T_MFW_HDR *)win)->data;
T_WAP_DATA *data = (T_WAP_DATA *)win_data->user;
#ifdef TRACE_AUIWAP
TRACE_FUNCTION("AUI_control");
#endif
switch (event)
{
case WAP_INIT:
win_show(win);
break;
}
return;
}
/*******************************************************************************
$Function: AUI_connecting_dialog
$Description: Show "Connecting..." dialog (displayed while sending configuration
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -