📄 auiwap.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:
$Project code:
$Module:
$File: AUIWap.c
$Revision:
$Author: Condat(UK)
$Date:
********************************************************************************
Description:
The user interface for WAP. Provides the required menus, lists, dialogs and
utilises the functionality of the ATB appropriately.
********************************************************************************
$History: AUIWap.c
14/05/2003 - SPR#1983 - SH - Updated to latest from 1.6.3 version.
$End
*******************************************************************************/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#if defined (NEW_FRAME)
#include "typedefs.h"
#include "vsi.h"
#include "pei.h"
#include "custom.h"
#include "gsm.h"
#else /* NEW_FRAME */
#include "stddefs.h"
#include "custom.h"
#include "gsm.h"
#include "vsi.h"
#endif /* NEW_FRAME */
#include "Mfw_sys.h"
#include "mfw_mfw.h"
#include "mfw_win.h"
#include "mfw_kbd.h"
#ifndef NEW_EDITOR
#include "mfw_edt.h"
#endif
#include "mfw_tim.h"
#include "mfw_phb.h"
#include "mfw_sms.h"
#include "mfw_icn.h"
#include "mfw_mnu.h"
#include "mfw_lng.h"
#include "mfw_sat.h"
#include "mfw_kbd.h"
#include "mfw_nm.h"
#include "Mfw_cm.h"
#include "dspl.h"
#include "MmiMmi.h"
#include "MmiMain.h"
#include "MmiDummy.h"
#include "MmiDialogs.h"
#include "MmiLists.h"
#include "MmiCall.h"
#include "MmiMenu.h"
#include "MmiSoftKeys.h"
#include "MmiResources.h"
#include "MmiBlkLangDB.h"
#include "MmiBookUtils.h"
#ifdef NEW_EDITOR
#include "ATBCommon.h"
#include "ATBDisplay.h"
#include "ATBEditor.h"
#include "AUIEditor.h"
#else
#include "MmiEditor.h"
#endif
#include "MmiBookshared.h"
#include "ATBData.h"
#include "wap_types.h"
#include "ATBWapAUI.h"
#include "ATBWapACI.h"
#include "mmiSmsMenu.h"
#include "Mmismssend.h"
#include "AUIWap.h"
#include "AUIWapext.h"
#ifdef MMI_GPRS_ENABLED
#include "MmiGprs.h"
#endif
#include "cus_aci.h"
#include "p_sim.h"
#include "pcm.h"
#include "mmiColours.h"
#include "font_bitmaps.h"
/* Define this to trace memory allocations & freeings */
#undef TRACE_MEMALLOC
/* List menu attributes
*
* Needed for creating the menu.
*/
static MfwMnuAttr list_menuAttrib =
{
&menuArea,
MNU_LEFT | MNU_LIST | MNU_CUR_LINE,
-1,
NULL,
0,
COLOUR_LIST_XX, TxtNull, MNUATTRSPARE
};
/*
Local Handler: the WAP window (At the moment only one instance possible in BMI)
*/
MfwHnd wap_main_window = 0;
static BOOL wap_callActive = FALSE;
/* Set up variables and functions for tracing purposes */
#ifdef TRACE_MEMALLOC
U16 memUsed = 0;
UBYTE memTracker[110] = {0};
#endif
int check_memory(void)
{
TRACE_EVENT_P1("Memory left: %d", mfwCheckMemoryLeft());
return;
}
/*******************************************************************************
$Function: AUI_menu
$Description: The main WAP menu
$Returns: MFW_EVENT_CONSUMED
$Arguments: menu - pointer to current menu
item - pointer to current menu item
*******************************************************************************/
int AUI_menu(MfwMnu* menu, MfwMnuItem* item)
{
T_MFW_HND win;
#ifdef TRACE_AUIWAP
TRACE_FUNCTION("AUI_menu");
#endif
win = AUI_create(mfwParent( mfw_header()));
if (!win)
{
TRACE_EVENT("ERROR - Wap Already Open");
}
check_memory();
return MFW_EVENT_CONSUMED;
}
/*******************************************************************************
$Function: AUI_please_wait
$Description: Creates a "Please Wait" message that will hang around until WAP has
been started
$Returns: Window handle of the created window
$Arguments: parent_win - the parent window
*******************************************************************************/
T_MFW_HND AUI_please_wait(T_MFW_HND parent_win)
{
T_DISPLAY_DATA display_info;
TRACE_FUNCTION("AUI_please_wait()");
dlg_initDisplayData_TextId( &display_info, TxtNull, TxtNull, TxtPleaseWait, TxtNull, COLOUR_STATUS);
dlg_initDisplayData_events( &display_info, (T_VOID_FUNC)AUI_please_wait_cb, 10000, 0 );
return info_dialog(parent_win,&display_info);
}
/*******************************************************************************
$Function: AUI_please_wait_cb
$Description: Timeout callback for the please wait window
$Returns: None.
$Arguments: win - the parent window
*******************************************************************************/
void AUI_please_wait_cb(T_MFW_HND win, USHORT identifier, SHORT reason)
{
T_WAP_DATA *data = AUI_wap_data();
#ifdef TRACE_AUIWAP
TRACE_FUNCTION("AUI_please_wait_cb()");
#endif
if (!data)
{
return;
}
switch(reason)
{
case INFO_TIMEOUT:
SEND_EVENT(win, DIALOG_DESTROY, NULL, NULL);
AUI_destroy(data->win, ALL_WIN);
AUI_info_dialog(NULL, TxtTimedOut, TxtNull);
break;
}
return;
}
/*******************************************************************************
$Function: AUI_wap_start_done
$Description: WAP has started - can create new view
$Returns: None.
$Arguments: None.
*******************************************************************************/
void AUI_wap_start_done(void)
{
T_WAP_DATA *data = AUI_wap_data();
T_MMI_WAP_NEW_VIEW_IND wap_view;
#ifdef TRACE_AUIWAP
TRACE_FUNCTION("AUI_wap_start_done");
#endif
if (!data)
{
return;
}
/* Start view */
wap_view.object_id = 1;
wap_view.uaMode = 1; /* Specifies WML user agent */
wap_view.view_width = WAP_SCREEN_WIDTH; /* Width of screen for browser */
wap_view.view_height = WAP_SCREEN_HEIGHT; /* Height of screen for browser */
wap_view.font_height = WAP_CHAR_HEIGHT; /* Height of latin font */
wap_view.unicode_height = WAP_CHAR_HEIGHT; /* Height of unicode font */
wap_view.unicode_width = WAP_CHAR_WIDTH; /* Width of characters in unicode font */
/* Get height and widths of all latin characters in current font */
wap_view.font_width_length = 256;
wap_view.font_width = (UBYTE *)AUI_wap_memory_alloc(256*sizeof(UBYTE));
font_getAllAsciiWidths(wap_view.font_width);
/* Create the view */
data->View = ATB_wap_new_view(&wap_view, (void *)data);
AUI_wap_memory_free(wap_view.font_width, 256*sizeof(UBYTE));
/* We're not connected as yet */
data->connected = FALSE;
return;
}
/*******************************************************************************
$Function: AUI_wap_new_view_done
$Description: View has started - can create menu
$Returns: None
$Arguments: None.
*******************************************************************************/
void AUI_wap_new_view_done(void)
{
T_WAP_DATA *data = AUI_wap_data();
#ifdef TRACE_AUIWAP
TRACE_FUNCTION("AUI_wap_new_view_done");
#endif
if (!data)
{
return;
}
/* Initialise window */
SEND_EVENT(data->win,WAP_INIT,0,0);
/* Destroy temp_win, if it exists */
if (data->temp_win)
{
SEND_EVENT(data->temp_win, DIALOG_DESTROY, NULL, NULL);
data->temp_win = NULL;
}
/* Create WAP main menu */
data->menu_win = bookMenuStart(data->win, WAPMenuAttributes(), 0);
SEND_EVENT(data->menu_win, ADD_CALLBACK, NULL, (void *)AUI_menu_cb);
return;
}
/*******************************************************************************
$Function: AUI_menu_cb
$Description: Callback function for the WAP menu
$Returns: None.
$Arguments: parent_win - the WAP data window
identifier - unused
reason - unused
*******************************************************************************/
static void AUI_menu_cb(T_MFW_HND parent_win, UBYTE identifier, UBYTE reason)
{
T_WAP_DATA *data = AUI_wap_data();
#ifdef TRACE_AUIWAP
TRACE_FUNCTION("AUI_menu_cb");
#endif
if (!data)
{
return;
}
AUI_destroy(data->win, WAP_WIN);
return;
}
/*******************************************************************************
$Function: AUI_homepage
$Description: Enter WAP browser with URL=homepage URL
$Returns: MFW_EVENT_CONSUMED
$Arguments: menu - pointer to current menu
item - pointer to current menu item
*******************************************************************************/
int AUI_homepage(MfwMnu* menu, MfwMnuItem* item)
{
T_WAP_DATA *data = AUI_wap_data();
#ifdef TRACE_AUIWAP
TRACE_FUNCTION("AUI_homepage");
#endif
if (!data)
{
return NULL;
}
/* Connect & attempt to download homepage */
AUI_connect_URL(data->win, data->View->Profile->Homepage);
return MFW_EVENT_CONSUMED;
}
/*******************************************************************************
$Function: AUI_create
$Description: Creates a window (never shown) to which is attached all the data that
is used in WAP. This is distinct from the WAP card browser window,
which is created dynamically.
$Returns: Pointer to the new window
$Arguments: parent win - pointer to the parent window of the data window
*******************************************************************************/
T_MFW_HND AUI_create (T_MFW_HND parent_win)
{
T_MFW_WIN *win_data;
T_WAP_DATA *data;
T_MMI_WAP_START_IND wap_start;
#ifdef TRACE_AUIWAP
TRACE_FUNCTION("AUI_create");
#endif
/* Check if one instance of WAP already activated */
if (wap_main_window)
{
TRACE_EVENT("*** WAP window already open ***");
return NULL;
}
data = (T_WAP_DATA *)AUI_wap_memory_alloc (sizeof (T_WAP_DATA));
/* Create the WAP data window */
data->update_forbid = FALSE;
data->win = win_create (parent_win, 0, E_WIN_VISIBLE, (T_MFW_CB)AUI_cb);
if (data->win==NULL)
{
TRACE_EVENT("*** Failed to create main WAP window ***");
AUI_wap_memory_free((UBYTE *)data, sizeof (T_WAP_DATA));
return NULL;
}
/* Create window handler */
wap_main_window = data->win;
data->main_kbd = kbd_create (data->win, KEY_ALL, (T_MFW_CB)AUI_main_kbd_cb);
data->mmi_control.dialog = (T_DIALOG_FUNC)AUI_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 data to window */
/* Reset various window pointers */
data->edit_win = NULL;
data->options_win = NULL;
data->list_win = NULL;
data->menu_win = NULL;
data->browser_win = NULL;
data->list_data = NULL;
data->connect_win = NULL;
data->error_win = NULL;
data->call_waiting = FALSE;
/* Allocate memory for some strings. */
data->Buffer = (char *)AUI_wap_memory_alloc ((INPUT_MAX_LEN+1)*sizeof(USHORT)); /* Input buffer 1 */
data->Buffer2 = (char *)AUI_wap_memory_alloc ((INPUT_MAX_LEN+1)*sizeof(USHORT)); /* Input buffer 2 */
data->Message.text = NULL;
data->Message.length = 0;
data->LeftSoftKey = (USHORT *)AUI_wap_memory_alloc ((SOFTKEY_MAX_LEN+2)*sizeof(USHORT)); /* Left softkey text */
data->RightSoftKey = (USHORT *)AUI_wap_memory_alloc ((SOFTKEY_MAX_LEN+2)*sizeof(USHORT)); /* Right softkey text */
/* Create list for options menu */
data->OptionsList = ATB_wap_entry_list_create(WAP_OPTIONS_LIST, MAX_OPTIONS+1, OPTIONS_MAX_LEN, TRUE);
/* Generate "Please wait" window while WAP starts up */
data->temp_win = AUI_please_wait(data->win);
data->View = NULL; /* View has not yet been created */
/* Start the WAP Browser */
ATB_wap_start(&wap_start);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -