📄 wap_gle.c
字号:
/*
+-----------------------------------------------------------------------------
| File : wap_gle.c
+-----------------------------------------------------------------------------
| Copyright Condat AG 1999-2001, Berlin
| All rights reserved.
|
| This file is confidential and a trade secret of Condat AG
| The receipt of or possession of this file does not convey
| any rights to reproduce or disclose its contents or to
| manufacture, use, or sell anything it may describe, in
| whole, or in part, without the specific written consent of
| Condat AG.
+-----------------------------------------------------------------------------
| Purpose : callbacks for GLE
|
| History: 15/05/2003 - SPR#1983 - SH - Updated to latest from 1.6.3 version.
+-----------------------------------------------------------------------------
*/
#ifndef WAP_GLE_C
#define WAP_GLE_C
#endif
#define ENTITY_WAP
/*==== INCLUDES ===================================================*/
#if defined (NEW_FRAME)
#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
#include <stddef.h>
#include "typedefs.h"
#include "pcm.h"
#include "pconst.cdg"
#include "mconst.cdg"
#include "message.h"
#include "ccdapi.h"
#include "vsi.h"
#include "custom.h"
#include "gsm.h"
#include "prim.h"
#include "cnf_wap.h"
#include "mon_wap.h"
#include "pei.h"
#include "tok.h"
#include "dti.h" /* functionality of the dti library */
#else
#include <stdarg.h>
#include <string.h>
#include "stddefs.h"
#include "pconst.cdg"
#include "message.h"
#include "ccdapi.h"
#include "custom.h"
#include "gsm.h"
#include "cnf_wap.h"
#include "mon_wap.h"
#include "prim.h"
#include "vsi.h"
#include "pei.h"
#include "tok.h"
#endif
#include "wap.h"
#include "cus_wap.h"
#include "aapimmi.h"
#include "capimmi.h"
#include "aapiclnt.h"
#include "aapigle.h"
#include "capiclnt.h"
#include "wip_mem.h"
#include "wap_types.h"
#include "wap_wapmmi.h"
#include "gledef.h"
/* Use these to access font height & widths */
static SHORT view_width;
static SHORT view_height;
static UBYTE font_height = 0;
static UBYTE *font_width = NULL;
static UBYTE font_max_width = 0;
static UBYTE unicode_width;
static UBYTE unicode_height;
/* This is provided for debugging use */
void traceWAP(char *string)
{
TRACE_EVENT(string);
return;
}
/*******************************************************************************
$Function: setupDisplayData
$Description: Stores some information about the target display
$Returns: None.
$Arguments: view_width_in - width of the WAP view in pixels
view_height_in - height of the WAP view in pixels
font_width_in - array of widths for 256 ascii characters
font_height_in - height of font
unicode_width_in - fixed width of unicode font
unicode_height_in - height of unicode font
*******************************************************************************/
void setupDisplayData(USHORT view_width_in, USHORT view_height_in, UBYTE *font_width_in, UBYTE font_height_in, UBYTE unicode_width_in, UBYTE unicode_height_in)
{
USHORT index;
view_height = view_height_in;
view_width = view_width_in;
font_height = font_height_in;
unicode_width = unicode_width_in;
unicode_height = unicode_height_in;
if (font_width==NULL)
{
font_width = (UBYTE *)wip_malloc(256*sizeof(UBYTE));
font_max_width = 0;
for (index = 0; index<256; index++)
{
font_width[index] = font_width_in[index];
if (font_width[index] > font_max_width)
font_max_width = font_width[index];
}
}
return;
}
/*******************************************************************************
$Function: freeDisplayData
$Description: Resets display information, freeing memory
$Returns: None.
$Arguments: None
*******************************************************************************/
void freeDisplayData(void)
{
TRACE_FUNCTION("freeDisplayData");
wip_free(font_width);
font_width = NULL;
return;
}
/*******************************************************************************
$Function: WAP_ImageCopy
$Description: Copies an image, allocating memory for it, and scaling it if necessary
SPR#2486 - Added.
$Returns: Pointer to the allocated image.
$Arguments: oldImage - Pointer to the original image data
oldWidth - Width of the original image in pixels
oldHeight - Height of the original image in pixels
newWidth - Width of the new image in pixels
newHeight - Height of the new image in pixels
*******************************************************************************/
UBYTE *WAP_ImageCopy(UBYTE *oldImage, UINT16 oldWidth, UINT16 oldHeight,
UINT16 newWidth, UINT16 newHeight)
{
UBYTE *Image; /* Pointer to the new image data */
USHORT heightIndex;
USHORT widthIndex;
USHORT oldIndex;
USHORT newIndex;
USHORT byteWidth;
USHORT scrByteWidth;
UBYTE oldMask; /* Pixel shift, shift bytes by this amount */
UBYTE newMask;
USHORT xScale;
USHORT xScaleOld;
USHORT yScale;
USHORT yScaleOld;
#ifdef TRACE_WAP_GLE
TRACE_FUNCTION("WAP_ImageCopy");
#endif
/* Work out the width of the original image in bytes */
byteWidth = oldWidth/8;
if (oldWidth % 8)
byteWidth++;
/* Work out the width of the scaled image in bytes */
scrByteWidth = newWidth/8;
if (newWidth % 8)
scrByteWidth++;
Image = (UBYTE *)wip_malloc(scrByteWidth * newHeight * sizeof(GleBitmap));
/* If there's no scaling to do, copy the image and that's it! */
if (newWidth==oldWidth && newHeight==oldHeight)
{
memcpy(Image, oldImage, byteWidth * oldHeight);
}
else
{
oldIndex = -1;
newIndex = -1;
yScaleOld = 0;
/* Scale the image */
for (heightIndex = 0; heightIndex<oldHeight; heightIndex++)
{
yScale = (USHORT) (heightIndex+1)*newHeight/oldHeight;
if (yScale != yScaleOld)
{
oldMask = 1; /* Mask within the byte of the first pixel */
newMask = 1;
xScaleOld = 0;
for (widthIndex = 0; widthIndex<oldWidth; widthIndex++)
{
xScale = (USHORT) (widthIndex+1)*newWidth/oldWidth;
if (oldMask == 1)
{
oldMask = 128;
oldIndex++;
}
else
oldMask /= 2;
if (xScale != xScaleOld)
{
if (newMask == 1)
{
newMask = 128;
newIndex++;
Image[newIndex] = 0;
}
else
newMask /= 2;
if (oldImage[oldIndex] & oldMask) /* If old pixel set, */
Image[newIndex] |= newMask; /* set new pixel */
}
xScaleOld = xScale;
}
}
else
{
oldIndex += byteWidth;
}
yScaleOld = yScale;
}
}
return Image;
}
/*******************************************************************************
$Function: GLEa_error
$Description: The GLE calls this when an error occurred during an operation
$Returns: None.
$Arguments: viewId - the id of the view
errorCode - the code of the error
*******************************************************************************/
VOID GLEa_error(UINT8 viewId, UINT16 errorCode)
{
#ifdef TRACE_WAP_GLE
TRACE_EVENT("GLEa_error");
TRACE_EVENT_P1("Error code: %d", errorCode);
#endif
return;
}
/*******************************************************************************
$Function: GLEa_status
$Description: The GLE calls this when an error occurred during an operation
$Returns: None.
$Arguments: viewId - the id of the view
statusCode - the status code
*******************************************************************************/
VOID GLEa_status(UINT8 viewId, UINT16 statusCode)
{
#ifdef TRACE_WAP_GLE
TRACE_EVENT("GLEa_status");
TRACE_EVENT_P1("Status code: %d", statusCode);
#endif
return;
}
/*******************************************************************************
$Function: GLEa_newCard
$Description: A new card has been received
$Returns: None.
$Arguments: viewId - the id of the view
title - title of the card
URL - URL of the card
isBookmarkable - TRUE if the URL can be added to the bookmark list
history - pointer to the history list
*******************************************************************************/
VOID GLEa_newCard(UINT8 viewId, const GLE_STRING title, const CHAR *URL, BOOL isBookmarkable, const WCHAR * const *history)
{
T_WAP_MMI_NEW_CARD_IND parameter;
/* USHORT historyIndex; */
/* USHORT historyIndexIndex; */
#ifdef TRACE_WAP_GLE
TRACE_FUNCTION("GLEa_newCard");
if (strlen(URL)>60)
{
TRACE_EVENT("URL too long to trace");
}
else
{
TRACE_EVENT_P1("URL: %s", URL);
}
TRACE_EVENT_P1("isBookmarkable: %d", isBookmarkable);
#endif
parameter.object_id = viewId;
parameter.title_length = (UINT16) GLEa_strlen(title);
parameter.Title = (USHORT *)title;
parameter.Url = (CHAR *)URL;
parameter.url_length = (UINT16) strlen(URL)+1;
parameter.is_bookmarkable = isBookmarkable;
parameter.history_length = 2;
/* Currently, we are not interested in the history list as such, rather whether or not the current card
has a history or not, since this will determine whether the back soft key will appear. So we only transmit
four bytes (2 x U32), and if those are zero then this is the first card in the history.*/
parameter.History = (USHORT**)history;
W_WAP_MMI_NEW_CARD_IND(¶meter);
return;
}
/*******************************************************************************
$Function: GLEa_drawCardRequest
$Description: Called before GLE draws the content of the view.
$Returns: FALSE if the WAP application doesn't allow the card to be drawn
currently, TRUE if it does.
$Arguments: viewId - the id of the view
contentPosX - x position of the content that is currently displayed
at the left of the screen. Can be used to update a
horizontal scrollbar.
contentWidth - The total width of the content in the card.
contentPosY - y position of the content that is currently displayed
at the top of the screen. Can be used to update a
vertical scrollbar.
contentHeight - The total height of the content in the card.
*******************************************************************************/
BOOL GLEa_drawCardRequest(UINT8 viewId, UINT16 contentPosX, UINT16 contentWidth, UINT16 contentPosY, UINT16 contentHeight)
{
T_WAP_MMI_DRAW_CARD_IND parameter;
#ifdef TRACE_WAP_GLE
TRACE_EVENT("GLEa_drawCardRequest");
TRACE_EVENT_P4("posX, posY, width, height: %d, %d, %d, %d", contentPosX, contentPosY, contentWidth, contentHeight);
#endif
parameter.object_id = viewId;
parameter.contentPosX = contentPosX;
parameter.contentPosY = contentPosY;
parameter.contentWidth = contentWidth;
parameter.contentHeight = contentHeight;
W_WAP_MMI_DRAW_CARD_IND(¶meter);
return TRUE;
}
/*******************************************************************************
$Function: GLEa_drawCardCompleted
$Description: Called after the GLE has drawn the content of the view corresponding
to viewId. If drawing was directed to an offscreen window, the platform
should then copy this to the screen.
$Returns: None.
$Arguments: viewId - the id of the view
*******************************************************************************/
VOID GLEa_drawCardCompleted(UINT8 viewId)
{
T_WAP_MMI_CARD_DRAW_COMPLETED_IND parameter;
#ifdef TRACE_WAP_GLE
TRACE_EVENT("GLEa_drawCardCompleted");
#endif
parameter.object_id = viewId;
W_WAP_MMI_CARD_DRAW_COMPLETED_IND(¶meter);
return;
}
/*******************************************************************************
$Function: GLEa_clearCard
$Description: Erases the content in the view (window) corresponding to viewId.
$Returns: None.
$Arguments: viewId - the id of the view
*******************************************************************************/
VOID GLEa_clearCard(UINT8 viewId)
{
T_WAP_MMI_CLEAR_CARD_IND parameter;
#ifdef TRACE_WAP_GLE
TRACE_EVENT("GLEa_clearCard");
#endif
parameter.object_id = viewId;
W_WAP_MMI_CLEAR_CARD_IND(¶meter);
return;
}
/*******************************************************************************
$Function: GLEa_playSoundClick
$Description: Play a sound
$Returns: None.
$Arguments: None.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -