⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 atbwapaui.c

📁 是一个手机功能的模拟程序
💻 C
📖 第 1 页 / 共 5 页
字号:
/*******************************************************************************

					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

	
	   
 $End

*******************************************************************************/
#define MFW

#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 "AUIWap.h"
#include "font_bitmaps.h"

#include "cus_aci.h"
#include "p_sim.h"
#include "pcm.h"
#include "dspl.h"
#include "mfw_kbd.h"//zhaowm 2003.1.9
#include "MmiMain.h"  

#define TRACE_ATBWAPAUI
#define WAP_TRACE 1
#include "mmiutilapi.h"
#define TRACE_EVENT(f) WAP_TRACE_EVENT(("bmi--AtbWapAui.c<<<talcon,%s",f));
#define TRACE_FUNCTION(f) TRACE_EVENT(f)



void long_IP_to_char_IP(ULONG IPs,char* IPd);


#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
#ifdef MMS_WAP_ENABLED
static T_WAP_VIEW		*Wap_view = 0;				
static T_WAP_VIEW		*MMS_view = 0;				
#endif

static char	debug[50];

// LOCAL FUNCTION PROTOTYPES

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.
 * SPR#1437 - SH - Fixed these so they won't overwrite array bounds */
	
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:		

 $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
#ifdef MMS_WAP_ENABLED
	Wap_view = NULL;
#else
	View_header = NULL;
	Current_view = NULL;
#endif
	
	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
 				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 *) AUI_wap_memory_alloc (sizeof(T_WAP_VIEW));	// Create the view
	T_WAP_VIEW *ViewIndex;

#ifdef TRACE_ATBWAPAUI
	TRACE_FUNCTION("ATB_wap_new_view");
#endif

	//WapData = (FlashDataWap *) AUI_wap_memory_alloc(sizeof(FlashDataWap));		//zhaowm 2002.12.23// Allocate memory for flash data

	View->URL			= (char *)AUI_wap_memory_alloc ((URL_MAX_LEN+1)*sizeof(char)); // space for URL text
	View->Title			= (char *)AUI_wap_memory_alloc ((CARD_TITLE_MAX_LEN+1)*sizeof(char)); // Title of card
	View->cardWidth		= WAP_SCREEN_WIDTH;
	View->cardHeight	= WAP_SCREEN_HEIGHT;
	View->ProfilesList	= ATB_wap_entry_list_create(WAP_PROFILES_LIST, MAX_PROFILES, PROFILENAME_MAX_LEN); // ...profiles names list
	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;	/* SPR#1547 - SH - Replaced 'status' with 'browser_status' */
	View->CustSoftKeys	= FALSE;												// Whether we have customised soft keys
	View->Bookmarks		= ATB_wap_entry_list_create(WAP_BOOKMARKS_LIST, MAX_BOOKMARKS, CARD_TITLE_MAX_LEN);		    // Create bookmarks list
	View->BookmarksURL	= ATB_wap_entry_list_create(WAP_URL_LIST, MAX_BOOKMARKS, URL_MAX_LEN);	
	View->History		= ATB_wap_entry_list_create(WAP_HISTORY_LIST, MAX_HISTORY, CARD_TITLE_MAX_LEN+NUMBER_PADDING); // ...history list...
	View->HistoryURL	= ATB_wap_entry_list_create(WAP_URL_LIST, MAX_HISTORY, URL_MAX_LEN);
	
	ATB_wap_profile_names_read(View);					 						// Read in the names of profiles
	ATB_wap_profile_read(View, View->ProfileId);								// Read in the current profile
	
#ifndef MMS_WAP_ENABLED
	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;
#else
	ATB_wap_wiew_add(View);
#endif
	
	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;

	if (!View_header)
	{
		TRACE_EVENT("blank view header");
		return NULL;
	}

	/* SPR#1497 - SH - If object_id is 0, any view will do */

	if (object_id==0)
		return View;

#ifdef TRACE_ATBWAPAUI
	TRACE_FUNCTION("ATB_wap_get_view");
#endif

	for (Index = 0; View!=NULL && View->object_id!=object_id; Index++)			// Searches for object_id
	{
		View = View->NextView;
	}

	return View;
}


/*******************************************************************************

 $Function:    	ATB_wap_destroy_view

 $Description:	Destroys a view
 
 $Returns:		WAP_OK if successful, WAP_FAIL if otherwise

 $Arguments:	View - pointer to the view to be destroyed
 				
 
*******************************************************************************/

T_WAP_RES ATB_wap_destroy_view(T_WAP_VIEW *View)
{
	T_WAP_VIEW	*ViewIndex = View_header;
	T_WAP_VIEW *Last_view = NULL;

#ifdef TRACE_ATBWAPAUI
	TRACE_FUNCTION("ATB_wap_destroy_view");
#endif

	while (ViewIndex!=View && ViewIndex!=NULL)									// Find the view in the chain
	{
		Last_view = ViewIndex;
		ViewIndex = ViewIndex->NextView;
	}

	if (ViewIndex == NULL)
		return WAP_FAIL;														// Couldn't find view in chain

	if (Last_view == NULL)														// Delete first entry in chain
		View_header = View_header->NextView;
	else
		Last_view->NextView = View->NextView;									// Break link in chain

	ATB_wap_entry_list_destroy(View->ProfilesList);								// Destroy profiles names list
	ATB_wap_entry_list_destroy(View->Bookmarks);								// Destroy bookmarks
	ATB_wap_entry_list_destroy(View->BookmarksURL);
	ATB_wap_entry_list_destroy(View->History);									// Destroy history list
	ATB_wap_entry_list_destroy(View->HistoryURL);

	AUI_wap_memory_free ((UBYTE *)View->URL, (URL_MAX_LEN+1)*sizeof(char));		// Delete URL string
	AUI_wap_memory_free ((UBYTE *)View->Title, (CARD_TITLE_MAX_LEN+1)*sizeof(char)); // Delete card title
	ATB_wap_buffer_clear(View);
	AUI_wap_memory_free ((UBYTE *)View, sizeof(T_WAP_VIEW));					// Delete View

	return WAP_OK;
}


/*******************************************************************************

 $Function:    	ATB_wap_destroy

 $Description:	Destroys the wap application, including all views (calls ATB_wap_terminate)
 
 $Returns:		WAP_OK if successful, WAP_FAIL if otherwise

 $Arguments:	
 				
 
*******************************************************************************/

T_WAP_RES ATB_wap_destroy()
{
	T_MMI_WAP_CLOSE_VIEW_IND	parameter1;
	static T_MMI_WAP_TERMINATE_IND		parameter2;	/* SPR#1569 - SH - Variable is now static */
	T_WAP_VIEW					*ViewIndex;
	T_WAP_VIEW					*NextView;

#ifdef TRACE_ATBWAPAUI
	TRACE_FUNCTION("ATB_wap_destroy");
#endif

	/* SPR#1569 - SH - Modified.  Now destroys an open view each time it is called.
	 * if there are no open views, the WAP broswer is terminated. */
	/* Get the access type (CSD/GPRS) from the root view */

/*talcon remove MMS,it is only for wap*/
#ifndef MMS_WAP_ENABLED___
	if (View_header)
	{
		parameter2.access_type = View_header->Profile->AccessType;
	}
#else
	if(Wap_view)
	{
		parameter2.access_type = Wap_view->Profile->AccessType;
	}
#endif
	
	/* Destroy the view chain.
 	 * If views still exist, destroy the bottom one */
#ifndef MMS_WAP_ENABLED___
	if (View_header!=NULL)														// Until end of chain
#else
	if (Wap_view!=NULL)		
#endif
	{
#ifndef MMS_WAP_ENABLED____
		ViewIndex = View_header;													// Store the current entry pointer
		View_header = ViewIndex->NextView;											// Find the next entry		
#else
		ViewIndex = Wap_view;
		ATB_wap_view_delete(Wap_view);
#endif

		parameter1.object_id = ViewIndex->object_id;
		
		ATB_wap_entry_list_destroy(ViewIndex->ProfilesList);					// Destroy profiles names list
		ATB_wap_entry_list_destroy(ViewIndex->Bookmarks);						// Destroy bookmarks
		ATB_wap_entry_list_destroy(ViewIndex->BookmarksURL);
		ATB_wap_entry_list_destroy(ViewIndex->History);							// Destroy history list
		ATB_wap_entry_list_destroy(ViewIndex->HistoryURL);
		AUI_wap_memory_free ((UBYTE *)ViewIndex->URL, (URL_MAX_LEN+1)*sizeof(char)); // Delete URL string
		AUI_wap_memory_free ((UBYTE *)ViewIndex->Title, (CARD_TITLE_MAX_LEN+1)*sizeof(char));   // Delete card title
		ATB_wap_buffer_clear(ViewIndex);										// Clear the element buffer
		ViewIndex->ElementHeader = ViewIndex->NewElementHeader;					// Just in case a new card is being created
		ATB_wap_buffer_clear(ViewIndex);										// Clear this too!
		AUI_wap_memory_free((UBYTE *)ViewIndex, sizeof(T_WAP_VIEW));			// Destroy the current entry
		M_MMI_WAP_CLOSE_VIEW_IND(&parameter1);
		return WAP_OK;
	}

	else
	{
		// Destroy the profiles information
	//	if (WapData)
	//	{
	//		AUI_wap_memory_free ((UBYTE *)WapData, sizeof(FlashDataWap));
	//		WapData = NULL;
	//	}
#ifndef MMS_WAP_ENABLED___
		View_header = NULL;	
		Current_view = NULL;

		return ATB_wap_terminate(&parameter2);												// Close WAP application
#else
		Current_view = MMS_view;
		if(MMS_view && MMS_view->Profile->AccessType == parameter2.access_type)
		{
			return WAP_FAIL;
		}
		else
		{

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -