📄 auiwap.c
字号:
{
return;
}
/* Standard values for events */
timer = FOREVER;
keyEvents = KEY_CLEAR | KEY_RIGHT;
/* Decide on message to display depending on status */
switch(status)
{
case ATB_WAP_ATTACHING:
dlg_initDisplayData_TextId( &display_info, TxtNull, TxtCancel, TxtAttaching, TxtGPRS, COLOUR_WAP_POPUP);
AUI_wap_string_alloc(&data->Message, PROFILENAME_MAX_LEN+1); /* +1 space for 0x80 */
data->Message.text[0] = 0x7F80;
ATB_uc_text_copy(&data->Message.text[1], data->View->Profile->Title, PROFILENAME_MAX_LEN);
display_info.TextString2 = (char *)data->Message.text;
break;
case ATB_WAP_LOGGING_IN:
dlg_initDisplayData_TextId( &display_info, TxtNull, TxtCancel, TxtConnecting, TxtNull, COLOUR_WAP_POPUP);
AUI_wap_string_alloc(&data->Message, PROFILENAME_MAX_LEN+1); /* +1 space for 0x80 */
data->Message.text[0] = 0x7F80;
ATB_uc_text_copy(&data->Message.text[1], data->View->Profile->Title, PROFILENAME_MAX_LEN);
display_info.TextString2 = (char *)data->Message.text;
break;
case ATB_WAP_CONNECTING:
dlg_initDisplayData_TextId( &display_info, TxtNull, TxtCancel, TxtLoggingIn, TxtNull, COLOUR_WAP_POPUP);
AUI_wap_string_alloc(&data->Message, PROFILENAME_MAX_LEN+1); /* +1 space for 0x80 */
data->Message.text[0] = 0x7F80;
ATB_uc_text_copy(&data->Message.text[1], data->View->Profile->Title, PROFILENAME_MAX_LEN);
display_info.TextString2 = (char *)data->Message.text;
break;
case ATB_WAP_CARD_READING:
dlg_initDisplayData_TextId( &display_info, TxtNull, TxtCancel, TxtDownloading, TxtNull, COLOUR_WAP_POPUP);
AUI_wap_string_alloc(&data->Message, CARD_TITLE_MAX_LEN+1); /* +1 space for 0x80 */
data->Message.text[0] = 0x7F80;
ATB_uc_text_copy(&data->Message.text[1], data->View->Title, CARD_TITLE_MAX_LEN);
/* Show name of card being read */
display_info.TextString2 = (char *)data->Message.text;
break;
case ATB_WAP_DEACTIVATING:
/* Waiting for context to deactivate, dialog with no cancel button */
dlg_initDisplayData_TextId( &display_info, TxtNull, TxtNull, TxtPleaseWait, TxtNull, COLOUR_WAP_POPUP);
timer = TEN_SECS;
keyEvents = 0;
break;
case ATB_WAP_PLEASE_WAIT:
default:
dlg_initDisplayData_TextId(&display_info, TxtNull, TxtCancel, TxtPleaseWait, TxtNull, COLOUR_WAP_POPUP);
break;
}
/* Destroy any previous dialog */
AUI_destroy(data->win, CONNECT_WIN);
/* Create new dialog */
dlg_initDisplayData_events( &display_info, (T_VOID_FUNC)AUI_connecting_dialog_cb, timer, keyEvents );
return info_dialog(data->win, &display_info);
}
/*******************************************************************************
$Function: AUI_connecting_dialog_cb
$Description: Callback function for connecting dialog
$Returns: void
$Arguments: win - pointer to the WAP data window
identifier - identifies function that has called callback
reason - reason for callback
*******************************************************************************/
void AUI_connecting_dialog_cb (T_MFW_HND win, UBYTE identifier, UBYTE reason)
{
T_WAP_DATA *data = AUI_wap_data();
#ifdef TRACE_AUIWAP
TRACE_FUNCTION("AUI_connecting_dialog_cb");
#endif
/* Dialog has been destroyed, set handle to NULL */
data->connect_win = NULL;
/* Free memory allocated for status message */
AUI_wap_string_free(&data->Message);
switch(reason)
{
case INFO_KCD_HUP:
case INFO_KCD_RIGHT:
/* If browser is active, completely exit WAP.
* Otherwise, just return to last menu. */
if (data->browser_win)
{
AUI_destroy(data->win, RETURN_TO_MENU);
}
else
{
/* Cancel any pending operation */
ATB_wap_stop_download(data->View);
/* End the call. */
AUI_wap_end_call(data->View->cId);
/* Indicate we're no longer connected */
if (!ATB_wap_status_get(data->View, ATB_WAP_DEACTIVATING))
{
ATB_wap_status_change(data->View, ATB_WAP_ONLINE_CONNECTION_CLOSED);
}
}
break;
default:
break;
}
return;
}
/*******************************************************************************
$Function: AUI_connect_URL
$Description: Connects to WAP gateway (if required) and starts to download URL
$Returns: None.
$Arguments: win - pointer to the WAP data window
URL - URL to connect to
*******************************************************************************/
void AUI_connect_URL (T_MFW_HND win, char *URL)
{
T_WAP_DATA *data = AUI_wap_data();
T_WAP_VIEW *View;
#ifdef TRACE_AUIWAP
TRACE_FUNCTION("AUI_connect_URL");
#endif
if (!data)
{
return;
}
View = data->View;
/* If the browser is already visible, we can destroy the other windows */
if (data->browser_win)
{
AUI_destroy(data->win, LIST_WIN | MENU_WIN | OPTIONSMENU_WIN | EDIT_WIN | OPTIONS_WIN);
}
/* Display "Please Wait" to cover delay until call dialog is displayed.
* Only display "Please Wait" if browser window is not open. */
if (!data->browser_win || !data->connected)
{
ATB_wap_status_change(data->View, ATB_WAP_PLEASE_WAIT);
}
/* If we're not connected, send configuration data to WAP Browser */
if (!data->connected)
{
ATB_wap_profile_send(View);
}
/* This is now the current URL */
strcpy(View->URL, URL);
/* Send event requesting URL download */
ATB_wap_download_url(View, URL, TRUE);
/* Destroy some windows for now; we want to return to the list win
* if the connection is cancelled */
AUI_destroy(data->win, OPTIONS_WIN | EDIT_WIN);
return;
}
/*******************************************************************************
$Function: AUI_win_create
$Description: Create the WAP card browser window
$Returns: void
$Arguments: parent_win - Pointer to the WAP data window
*******************************************************************************/
T_MFW_HND AUI_win_create (T_MFW_HND parent_win)
{
T_MFW_WIN *win_data;
T_WAP_BROWSER *data = (T_WAP_BROWSER *)AUI_wap_memory_alloc(sizeof(T_WAP_BROWSER));
#ifdef TRACE_AUIWAP
TRACE_FUNCTION("AUI_win_create");
#endif
/* Create the browser window */
data->win = win_create(parent_win,0,E_WIN_VISIBLE, (T_MFW_CB)AUI_win_cb);
/* Create keyboard handler */
data->kbd = kbd_create (data->win, KEY_ALL, (T_MFW_CB)AUI_kbd_cb);
data->kbd_long = kbd_create (data->win, KEY_ALL|KEY_LONG, (T_MFW_CB)AUI_kbd_long_cb);
/* Create window handler */
data->mmi_control.dialog = (T_DIALOG_FUNC)AUI_win_control;
data->mmi_control.data = (void *)data;
data->parent_win = parent_win;
win_data = ((T_MFW_HDR *)data->win)->data;
win_data->user = (void *)data; /* Attach browser data to window */
return data->win;
}
/*******************************************************************************
$Function: AUI_win_destroy
$Description: Destroy the WAP card browser window
$Returns: void
$Arguments: win - Pointer to the WAP browser window
*******************************************************************************/
int AUI_win_destroy (T_MFW_HND win)
{
T_MFW_WIN *win_data = ((T_MFW_HDR *)win)->data;
T_WAP_BROWSER *data = (T_WAP_BROWSER *)win_data->user;
#ifdef TRACE_AUIWAP
TRACE_FUNCTION("AUI_win_destroy");
#endif
/* Delete keyboard handlers */
kbd_delete(data->kbd);
kbd_delete(data->kbd_long);
/* Delete window */
win_delete(win);
AUI_wap_memory_free((UBYTE *)data, sizeof(T_WAP_BROWSER));
return 1;
}
/*******************************************************************************
$Function: AUI_win_control
$Description: Dialog function for WAP Browser window
$Returns: None.
$Arguments: win - WAP card browser window
event - Window handle event
value - not used
parameter - not used
*******************************************************************************/
void AUI_win_control (T_MFW_HND win, USHORT event, SHORT value, void * parameter)
{
T_MFW_WIN *win_data = ((T_MFW_HDR *)win)->data;
T_WAP_BROWSER *data = (T_WAP_BROWSER *)win_data->user;
#ifdef TRACE_AUIWAP
TRACE_FUNCTION("AUI_win_control");
#endif
switch (event)
{
case WAP_INIT:
break;
case WAP_SHOW_CARD:
win_show(win);
break;
}
return;
}
/*******************************************************************************
$Function: AUI_win_cb
$Description: Callback function for browser window
$Returns: None.
$Arguments: event - window handle event
win - WAP browser window
*******************************************************************************/
static int AUI_win_cb (T_MFW_EVENT event, T_MFW_WIN * win)
{
T_WAP_DATA *data = AUI_wap_data();
#ifdef TRACE_AUIWAP
TRACE_FUNCTION("AUI_win_cb");
#endif
if (!data)
{
return NULL;
}
if (data->update_forbid)
{
return NULL;
}
switch (event)
{
case E_WIN_VISIBLE:
if (win->flags & E_WIN_VISIBLE)
{
/* Clear the browser area */
resources_setColour( COLOUR_WAP );
dspl_ClearAll();
/* Display the buffered page */
ATB_wap_buffer_display(data->View);
/* Display softkeys */
resources_setSKColour( COLOUR_WAP );
/* Display "Cancel" when downloading or reading in a card */
if (ATB_wap_status_get(data->View, ATB_WAP_DOWNLOADING)
|| ATB_wap_status_get(data->View, ATB_WAP_CARD_READING))
{
displaySoftKeys(TxtNull, TxtCancel);
}
else
{
if (data->View->CustSoftKeys)
{
displayCustSoftKeys((char *)data->LeftSoftKey, (char *)data->RightSoftKey);
}
else
{
if (data->View->CanGoBack)
displaySoftKeys(TxtSoftOptions, TxtSoftBack); /* Show "options" and "back" */
else
displaySoftKeys(TxtSoftOptions, TxtNull); /* Only show "options" if we can't go back */
}
}
}
break;
default:
return 0;
}
return 1;
}
/*******************************************************************************
$Function: AUI_kbd_cb
$Description: Keyboard event handler for browser window
$Returns: status int
$Arguments: event - window handle event
keyboard - keyboard control block
*******************************************************************************/
static int AUI_kbd_cb (T_MFW_EVENT event, T_MFW_KBD *keyboard)
{
T_WAP_DATA *data = AUI_wap_data();
T_WAP_VIEW *View;
#ifdef TRACE_AUIWAP
TRACE_FUNCTION("AUI_kbd_cb");
#endif
if (!data)
{
return NULL;
}
View = data->View;
switch (keyboard->code)
{
case KCD_LEFT:
/* Open options menu if not downloading or reading a card */
if (!ATB_wap_status_get(View, ATB_WAP_DOWNLOADING)
&& !ATB_wap_status_get(View, ATB_WAP_CARD_READING))
{
AUI_wap_options_menu_open(ATB_wap_buffer_identify_element(View));
}
break;
case KCD_RIGHT:
/* Open options menu if not downloading or reading a card */
if (ATB_wap_status_get(View, ATB_WAP_DOWNLOADING)
|| ATB_wap_status_get(View, ATB_WAP_CARD_READING))
{
ATB_wap_stop_download(View);
}
else
{
if (View->CustSoftKeys)
ATB_wap_key_selected(View, View->CustSoftKeyId); /* Customised right soft key */
else
ATB_wap_card_go_back(View); /* Otherwise default is "Back" */
}
break;
/* Scroll card up */
case KCD_MNUUP:
ATB_wap_card_key_event(View, WAP_KEY_UP);
break;
/* Scroll card down */
case KCD_MNUDOWN:
ATB_wap_card_key_event(View, WAP_KEY_DOWN);
break;
/* Scroll card left */
case KCD_MNULEFT:
case KCD_1:
ATB_wap_card_key_event(View, WAP_KEY_LEFT);
break;
/* Scroll card right */
case KCD_MNURIGHT:
case KCD_3:
ATB_wap_card_key_event(View, WAP_KEY_RIGHT);
break;
/* Top of card */
case KCD_2:
ATB_wap_card_scroll(View,0);
break;
/* Scroll up a page */
case KCD_5:
ATB_wap_card_scroll(View,View->cardYPosition-WAP_PAGE_SCROLL);
break;
/* Scroll down a page */
case KCD_8:
ATB_wap_card_scroll(View,View->cardYPosition+WAP_PAGE_SCROLL);
break;
/* Bottom of card */
case KCD_0:
ATB_wap_card_scroll(View,View->cardHeight-WAP_SCREEN_HEIGHT);
break;
/* Select*/
case KCD_MNUSELECT:
case KCD_CALL:
ATB_wap_card_key_event(View, WAP_KEY_SELECT);
break;
/* Exit WAP */
case KCD_HUP:
ATB_wap_stop_download(View);
AUI_destroy(data->win,RETURN_TO_MENU);
break;
/* Toggle image scaling */
case KCD_STAR:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -