📄 atbwapaui.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: ATBWapAUI.c
$Revision:
$Author: Condat(UK)
$Date:
********************************************************************************
Description:
Provides most of the functionality of the ATB, as well as an interface with the AUI.
********************************************************************************
$History: ATBWapAUI.c
15/05/2003 - SPR#1983 - SH - Updated to latest from 1.6.3 version.
$End
*******************************************************************************/
#ifndef MFW
#define MFW
#endif
#ifdef MFW
#define ENTITY_MFW
#else
#ifdef SMI
#define ENTITY_SMI
#else
#define ENTITY_ACI
#endif
#endif
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#ifdef NEW_FRAME
#include "typedefs.h"
#else /* NEW_FRAME */
#include "stddefs.h"
#endif /* NEW_FRAME */
#include "Ffs.h"
#include "MmiWapFfs.h"
#include "gledef.h"
#include "capiclnt.h"
#include "aapiclnt.h"
#include "wap_types.h"
#include "ATBWapACI.h"
#include "ATBData.h"
#include "ATBWapAUI.h"
#include "font_bitmaps.h"
#include "cus_aci.h"
#include "p_sim.h"
#include "pcm.h"
#include "dspl.h"
#define DEFAULT_PROFILE 0 /* The default starting profile */
static T_WAP_VIEW *View_header = 0; /* View header points to first element in the view chain */
static T_WAP_VIEW *Current_view = 0; /* Points to the current view */
/* LOCAL FUNCTION PROTOTYPES */
void long_IP_to_char_IP(ULONG IPs,char* IPd);
static void ATB_wap_buffer_text_draw(T_WAP_MMI_SEND_TEXT_IND *parameter);
static void ATB_wap_buffer_table_draw(T_WAP_MMI_SEND_TABLE_IND *parameter);
static void ATB_wap_buffer_line_draw(SHORT x1, SHORT y1, SHORT x2, SHORT y2);
static BOOL ATB_wap_buffer_onscreen(SHORT x, SHORT y, SHORT *deltaX, SHORT *deltaY);
static void ATB_wap_buffer_image_display(T_WAP_MMI_SEND_IMAGE_IND *image);
static void ATB_wap_buffer_image_scale(T_WAP_MMI_SEND_IMAGE_IND *image);
#if defined(TRACE_ATBWAPAUI) || defined(TRACE_ATBWAPACI)
/* Functions to display strings, for tracing purposes. */
void ATB_trace_string(char *String, USHORT length)
{
UBYTE stringIndex;
UBYTE trace_string[41];
for (stringIndex=0; (stringIndex<40 && stringIndex<length); stringIndex++)
trace_string[stringIndex] = String[stringIndex];
trace_string[stringIndex] = 0;
TRACE_EVENT_P2("%s (%d)", trace_string, length);
return;
}
void ATB_trace_ushort_string(USHORT *String, USHORT length)
{
USHORT stringIndex;
UBYTE trace_string[41];
for (stringIndex=0; (stringIndex<40 && stringIndex<length); stringIndex++)
trace_string[stringIndex] = (char) String[stringIndex];
trace_string[stringIndex] = 0;
TRACE_EVENT_P2("%s (%d)", trace_string, length);
return;
}
#endif
/*******************************************************************************
$Function: ATB_wap_start
$Description: Starts the WAP application and initialises the view chain
$Returns: None.
$Arguments: parameter - dummy empty parameter
*******************************************************************************/
void ATB_wap_start(T_MMI_WAP_START_IND *parameter)
{
#ifdef TRACE_ATBWAPAUI
TRACE_FUNCTION("ATB_wap_start");
#endif
M_MMI_WAP_START_IND(parameter);
/* Initialise the pointer to the view chain */
View_header = NULL;
Current_view = NULL;
return;
}
/*******************************************************************************
$Function: ATB_wap_new_view
$Description: Starts a new view, defining the graphical size of the screen to
be handled.
$Returns: Pointer to the data structure of the new view
$Arguments: parameter - width and height of the WAP view, etc.
UIdata - Optional generic pointer, for use by the AUI. This
can point to window information, etc, but is not used
by ATB.
*******************************************************************************/
T_WAP_VIEW* ATB_wap_new_view(T_MMI_WAP_NEW_VIEW_IND *parameter, void* UIdata)
{
T_WAP_VIEW *View;
T_WAP_VIEW *ViewIndex;
#ifdef TRACE_ATBWAPAUI
TRACE_FUNCTION("ATB_wap_new_view");
#endif
/* Create the view */
View = (T_WAP_VIEW *) AUI_wap_memory_alloc (sizeof(T_WAP_VIEW));
/* Allocate memory for two FFS files */
WapData = (FlashDataWap *) AUI_wap_memory_alloc(sizeof(FlashDataWap));
WapProfilesData = (FlashDataWapProfiles *) AUI_wap_memory_alloc(sizeof(FlashDataWapProfiles));
/* Allocate some arrays and lists */
View->URL = (char *)AUI_wap_memory_alloc ((URL_MAX_LEN+1)*sizeof(char));
View->Title = (USHORT *)AUI_wap_memory_alloc ((CARD_TITLE_MAX_LEN+1)*sizeof(USHORT));
/* Set up some default values */
View->cardWidth = WAP_SCREEN_WIDTH;
View->cardHeight = WAP_SCREEN_HEIGHT;
View->object_id = parameter->object_id;
View->channel = WAP_CHANNEL_ID;
View->UIdata = UIdata;
View->ElementHeader = NULL; /* Element chain is as yet empty */
View->NextView = NULL;
View->browser_status = ATB_WAP_NO_STATUS; /* Browser status is idle */
View->CustSoftKeys = FALSE; /* Whether we have customised soft keys */
View->cId = -1;
/* Create entry lists */
View->ProfilesList = ATB_wap_entry_list_create(WAP_PROFILES_LIST, MAX_PROFILES, PROFILENAME_MAX_LEN, TRUE);
View->Bookmarks = ATB_wap_entry_list_create(WAP_BOOKMARKS_LIST, MAX_BOOKMARKS, CARD_TITLE_MAX_LEN, TRUE);
View->BookmarksURL = ATB_wap_entry_list_create(WAP_URL_LIST, MAX_BOOKMARKS, URL_MAX_LEN, FALSE);
View->History = ATB_wap_entry_list_create(WAP_HISTORY_LIST, MAX_HISTORY, CARD_TITLE_MAX_LEN+NUMBER_PADDING, TRUE);
View->HistoryURL = ATB_wap_entry_list_create(WAP_URL_LIST, MAX_HISTORY, URL_MAX_LEN, FALSE);
/* Read in profile information from flash */
ATB_wap_profile_names_read(View);
ATB_wap_profile_read(View, View->ProfileId);
/* Add this view to the view chain */
if (View_header == NULL)
View_header = View; /* This is the first entry */
else
{
ViewIndex = View_header;
while (ViewIndex->NextView != NULL) /* If not the last entry, */
ViewIndex = ViewIndex->NextView; /* find the next entry! */
ViewIndex->NextView = View; /* New entry is last entry in chain */
}
Current_view = View;
/* Tell WAP Browser to create new view */
M_MMI_WAP_NEW_VIEW_IND(parameter);
return View;
}
/*******************************************************************************
$Function: ATB_wap_get_view
$Description: Returns a pointer to a view, given its object_id
$Returns: Pointer to the data structure of the specified view, or NULL if not found
$Arguments: object_id - the id of the view
*******************************************************************************/
T_WAP_VIEW* ATB_wap_get_view(UBYTE object_id)
{
T_WAP_VIEW *View = View_header;
UBYTE Index;
#ifdef TRACE_ATBWAPAUI
TRACE_FUNCTION("ATB_wap_get_view()");
#endif
if (!View_header)
{
return NULL;
}
/* If object_id is 0, any view will do */
if (object_id==0)
return View;
/* Search for object_id */
for (Index = 0; View!=NULL && View->object_id!=object_id; Index++)
{
View = View->NextView;
}
return View;
}
/*******************************************************************************
$Function: ATB_wap_destroy
$Description: Destroys any open view. If no views are open, destroys the WAP
application by calling ATB_wap_terminate().
$Returns: WAP_OK if successful, WAP_FAIL if otherwise
$Arguments: None.
*******************************************************************************/
T_WAP_RES ATB_wap_destroy()
{
T_MMI_WAP_CLOSE_VIEW_IND parameter1;
static T_MMI_WAP_TERMINATE_IND parameter2;
T_WAP_VIEW *ViewIndex;
T_WAP_VIEW *NextView;
#ifdef TRACE_ATBWAPAUI
TRACE_FUNCTION("ATB_wap_destroy");
#endif
/* Destroy the view chain.
* If views still exist, destroy the bottom one */
if (View_header!=NULL) /* Until end of chain */
{
ViewIndex = View_header; /* Store the current entry pointer */
View_header = ViewIndex->NextView; /* Find the next entry */
parameter1.object_id = ViewIndex->object_id;
/* Destroy entry lists */
ATB_wap_entry_list_destroy(ViewIndex->ProfilesList);
ATB_wap_entry_list_destroy(ViewIndex->Bookmarks);
ATB_wap_entry_list_destroy(ViewIndex->BookmarksURL);
ATB_wap_entry_list_destroy(ViewIndex->History);
ATB_wap_entry_list_destroy(ViewIndex->HistoryURL);
/* Free strings */
AUI_wap_memory_free ((UBYTE *)ViewIndex->URL, (URL_MAX_LEN+1)*sizeof(char));
AUI_wap_memory_free ((UBYTE *)ViewIndex->Title, (CARD_TITLE_MAX_LEN+1)*sizeof(USHORT));
/* Clear the element buffer */
ATB_wap_buffer_clear(ViewIndex);
/* If a new card is being created, clear this too */
ViewIndex->ElementHeader = ViewIndex->NewElementHeader;
ATB_wap_buffer_clear(ViewIndex);
/* Free View memory */
AUI_wap_memory_free((UBYTE *)ViewIndex, sizeof(T_WAP_VIEW));
/* Tell WAP Browser to close the view */
M_MMI_WAP_CLOSE_VIEW_IND(¶meter1);
return WAP_OK;
}
else
{
/* Destroy the RAM copy of the FFS data */
if (WapData)
{
AUI_wap_memory_free ((UBYTE *)WapData, sizeof(FlashDataWap));
WapData = NULL;
}
/* Destroy the RAM copy of the FFS profiles information */
if (WapProfilesData)
{
AUI_wap_memory_free ((UBYTE *)WapProfilesData, sizeof(FlashDataWapProfiles));
WapProfilesData = NULL;
}
View_header = NULL;
Current_view = NULL;
/* Shut down WAP Browser */
return ATB_wap_terminate(¶meter2);
}
}
/*******************************************************************************
$Function: ATB_wap_UIdata
$Description: Returns the UI pointer, for use by AUI
$Returns: The void pointer
$Arguments: None.
*******************************************************************************/
void * ATB_wap_UIdata()
{
if (View_header)
return View_header->UIdata;
else
return NULL;
}
/*******************************************************************************
$Function: ATB_wap_terminate
$Description: Closes the WAP application and frees all the memory allocated
$Returns: WAP_OK
$Arguments: parameter - see MMI_WAP_TERMINATE_IND
*******************************************************************************/
T_WAP_RES ATB_wap_terminate(T_MMI_WAP_TERMINATE_IND *parameter)
{
#ifdef TRACE_ATBWAPAUI
TRACE_FUNCTION("ATB_wap_terminate");
#endif
M_MMI_WAP_TERMINATE_IND(parameter);
return WAP_OK;
}
/*******************************************************************************
$Function: ATB_wap_config_int
$Description: Sends integer configuration information to the browser
$Returns: WAP_OK
$Arguments: View - The current view
param - ID of the configuration
value - Integer value of the configuration
*******************************************************************************/
T_WAP_RES ATB_wap_config_int(T_WAP_VIEW *View, USHORT param, U32 value)
{
T_MMI_WAP_CONFIGURE_IND parameter;
parameter.object_id = View->object_id;
parameter.type = WAP_IntConfig;
parameter.param = param;
parameter.intvalue = value;
parameter.strvalue = NULL;
parameter.length = 0;
M_MMI_WAP_CONFIGURE_IND(¶meter);
return WAP_OK;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -