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

📄 atbwapaui.c

📁 是一个手机功能的模拟程序
💻 C
📖 第 1 页 / 共 5 页
字号:
			break;
				
			case WAP_IMAGE:
				ImageElement = (T_WAP_MMI_SEND_IMAGE_IND *)Element->data;
				if (ImageElement->image_length != 0)
					AUI_wap_memory_free((UBYTE *)ImageElement->Image, ImageElement->image_length*sizeof(UBYTE));
				AUI_wap_memory_free((UBYTE *)ImageElement, sizeof(T_WAP_MMI_SEND_IMAGE_IND));
			break;
		}
		NextElement = Element->NextElement;
		AUI_wap_memory_free((UBYTE *)Element, sizeof(T_WAP_ELEMENT));
		Element = NextElement;
		elementCount++;
	}
	
#ifdef TRACE_ATBWAPAUI
	TRACE_EVENT_P1( "Elements destroyed: %d", elementCount);
#endif

	View->ElementHeader = NULL;
	return;
}


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

 $Function:    	ATB_wap_buffer_identify_element

 $Description:	Identifies which element is selected (based on the invert property) and
 				returns an appropriate type.
 
 $Returns:		The type of the element that is selected, or NULL if none

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

UBYTE ATB_wap_buffer_identify_element(T_WAP_VIEW *View)
{
	T_WAP_ELEMENT				*Element	= View->ElementHeader;
	T_WAP_MMI_SEND_TEXT_IND		*TextElement;
	T_WAP_MMI_SEND_IMAGE_IND	*ImageElement;

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

	while (Element!=NULL)
	{
		switch (Element->type)
		{
			case WAP_TEXT:
				TextElement = (T_WAP_MMI_SEND_TEXT_IND *)Element->data;
				if (TextElement->invert)
				{
					return TextElement->type;
				}
			break;

			case WAP_IMAGE:
				ImageElement = (T_WAP_MMI_SEND_IMAGE_IND *)Element->data;
				if (ImageElement->invert)
				{
					return WAP_SELECTABLE_IMAGE;
				}
		}
		Element = Element->NextElement;
	}
	
	return NULL;
}


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

 $Function:    	ATB_wap_profile_read

 $Description:	Reads in the specified profile and changes the ProfileId
 
 $Returns:		

 $Arguments:	View		- Pointer to the current view
 				ProfileId	- the id of the profile to read from the flash
 
*******************************************************************************/

T_WAP_RES ATB_wap_profile_read(T_WAP_VIEW *View, UBYTE ProfileId)
{
	T_WAP_PROFILE	*Profile		= View->Profile;
	UBYTE 			entryIndex;
	char			*Entry;
	char			*URL;

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

	View->ProfileId	= ProfileId;
	View->Profile	= &(WapData.Profile[View->ProfileId]);						// Points to appropriate profile
		
	return WAP_OK;
}


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

 $Function:    	ATB_wap_profile_names_read

 $Description:	Reads into RAM the names of all profiles stored in flash, also
 				the global bookmarks and history lists
 
 $Returns:		

 $Arguments:	Profile		- Pointer to the current profile
 
*******************************************************************************/

T_WAP_RES ATB_wap_profile_names_read(T_WAP_VIEW *View)
{
	T_WAP_PROFILE	*Profile;
	T_WAP_LIST 		*ProfilesList	= View->ProfilesList;
	USHORT			no_of_bookmarks;
	T_WAP_LIST		*Bookmarks		= View->Bookmarks;
	T_WAP_LIST		*BookmarksURL	= View->BookmarksURL;
	USHORT			no_of_history;
	T_WAP_LIST		*History		= View->History;
	T_WAP_LIST		*HistoryURL		= View->HistoryURL;
	UBYTE			entryIndex;
	char			*Entry;
	char			*URL;
	UBYTE			no_of_profiles;

	// Default values are provided.  If the file 'mmi/WapData' isn't found, a file is created
	// with these defaults.
	
#ifdef TRACE_ATBWAPAUI
	TRACE_FUNCTION("ATB_wap_profile_names_read");
#endif
   /*
	if (flash_wap_read() == EFFS_NOTFOUND)
	{
		ATB_wap_profile_default_create();
	}
   */
    //wapffsfile_init();    //zhaowm 2002/12/26
	View->Status 		= WapData.Status;									// Status flags
	View->ProfileId		= WapData.ProfileId;								// Default starting profile

	// Read in profiles list
	
	no_of_profiles = WapData.no_of_profiles;
	ProfilesList->no_of_entries = no_of_profiles;
		
	for (entryIndex = 0; entryIndex<MAX_PROFILES; entryIndex++)
	{
		ProfilesList->Entry[entryIndex] = WapData.Profile[entryIndex].Title;
	}

	// Read in bookmarks
	
	no_of_bookmarks = WapData.no_of_bookmarks;
	Bookmarks->no_of_entries	= no_of_bookmarks;
	BookmarksURL->no_of_entries	= no_of_bookmarks;
	
	for (entryIndex = 0; entryIndex<MAX_BOOKMARKS; entryIndex++)
	{
		Bookmarks->Entry[entryIndex] = WapData.Bookmarks[entryIndex];
		BookmarksURL->Entry[entryIndex] = WapData.BookmarksURL[entryIndex];
	}

	// Read in history entries
	
	no_of_history = WapData.no_of_history;
	History->no_of_entries 	= no_of_history;
	HistoryURL->no_of_entries  = no_of_history;
	
	for (entryIndex = 0; entryIndex<MAX_HISTORY; entryIndex++)
	{
		History->Entry[entryIndex] = WapData.History[entryIndex];
		HistoryURL->Entry[entryIndex] = WapData.HistoryURL[entryIndex];
	}

	return WAP_OK;
}


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

 $Function:    	ATB_wap_profile_save

 $Description:	Store the current updated profile in flash
 
 $Returns:		

 $Arguments:	View		- Pointer to the current view
 
*******************************************************************************/

T_WAP_RES ATB_wap_profile_save(T_WAP_VIEW *View)
{	

#ifdef TRACE_ATBWAPAUI
	TRACE_FUNCTION("ATB_wap_profile_save");
#endif
	
	WapData.ProfileId			= View->ProfileId;
	WapData.Status				= View->Status;
	WapData.no_of_bookmarks	= View->Bookmarks->no_of_entries;
	WapData.no_of_history		= View->History->no_of_entries;
	flash_wap_write();

	return WAP_OK;
}


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

 $Function:    	ATB_wap_profile_default_create

 $Description:	Creates a default profile in the flash if one isn't already there
 
 $Returns:		

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

T_WAP_RES ATB_wap_profile_default_create()
{	

#if 0

	UBYTE	no_of_bookmarks		= 10;	
	char	*bookmarksList[] =
	{
		"Yahoo!",
		"AOL",
		"Genie",
		"Financial Times",
		"Cnet tech news",
		"The Guardian",
		"Breathe",
		"WEB.DE",
		"Vizzavi",
		"El Pais"
	};
		
	char 	*bookURLList[]	= 
	{
		"http://wap.yahoo.com",
		"http://wap.aol.co.uk",
		"http://wap.genie.co.uk",
		"http://wap.ft.com",
		"http://wap.cnet.com",
		"http://www.guardian.co.uk/wml#C",
		"http://wap.breathe.com",
		"http://wap.web.de",
		"http://wap.vizzavi.co.uk",
		"http://wap.elpais.es"
	};

	UBYTE	no_of_history		= 0;
	char	*historyList[]		= { "dummy" };
	char	*histURLList[]		= { "dummy" };

	UBYTE	no_of_profiles	= 2;
	char 	*profilesDefault[] 	= { "profile1", "profile2"};
	char	*homepageURL[]		= { "http://wap.monternet.com", "http://wap.yahoo.com"};
	char	*IPAddress1[]		= { "010.000.000.172", "010.000.000.172"};
	char	*IPAddress2[]		= { "010.000.000.172", "010.000.000.172"};
	char	*DialupNumber[]		= { "17266", "17266" };
	char	*APN[]				= { "cmwap", "cmwap"}; 
	char	*Username[]			= { "wap", "wap" };
	char	*Password[]			= { "wap", "wap"};
	USHORT	ResponseTimer[]		= {180,60};
	USHORT	Port1[]				= {9201,9201};
	USHORT	Port2[]				= {9201,9201};


	USHORT entryIndex;
	USHORT	profile;

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

	WapData.ProfileId		= 0;
	WapData.Status	= WAP_STATUS_SAVEHISTORY | WAP_STATUS_SCALEIMAGES;

	// Copy bookmarks into WapData structure
	
	WapData.no_of_bookmarks = no_of_bookmarks;

	for (entryIndex = 0; entryIndex<no_of_bookmarks; entryIndex++)
	{
		strcpy(WapData.Bookmarks[entryIndex], bookmarksList[entryIndex]);
		strcpy(WapData.BookmarksURL[entryIndex], bookURLList[entryIndex]);
	}

	//	Copy history list into WapData structure
			
	WapData.no_of_history = no_of_history;
	
	for (entryIndex = 0; entryIndex<no_of_history; entryIndex++)
	{
		sprintf(WapData.History[entryIndex],"%2d. ",entryIndex+1);			// store number
		strcpy(WapData.History[entryIndex]+NUMBER_PADDING, historyList[entryIndex]);
		strcpy(WapData.HistoryURL[entryIndex], histURLList[entryIndex]);
	}

	// Copy profile data into WapData structure
	
	WapData.no_of_profiles    = no_of_profiles;
		
	for (profile = 0; profile<no_of_profiles; profile++)
	{
		strcpy(WapData.Profile[profile].Title, profilesDefault[profile]);
		
		strcpy(WapData.Profile[profile].Homepage, homepageURL[profile]);
		
		WapData.Profile[profile].ConnectionType	= WAP_TEMPORARY;
		WapData.Profile[profile].Security			= FALSE;
		WapData.Profile[profile].AccessType		= WAP_GPRS_DATA;//WAP_CS_DATA;
		WapData.Profile[profile].ResponseTimer		= ResponseTimer[profile];
		WapData.Profile[profile].Port1				= Port1[profile];
		WapData.Profile[profile].Port2				= Port2[profile];
		strcpy(WapData.Profile[profile].IPAddress1, IPAddress1[profile]);
		strcpy(WapData.Profile[profile].IPAddress2, IPAddress2[profile]);
		strcpy(WapData.Profile[profile].DialupNumber, DialupNumber[profile]);
		strcpy(WapData.Profile[profile].APN, APN[profile]);
		strcpy(WapData.Profile[profile].Username, Username[profile]);
		strcpy(WapData.Profile[profile].Password, Password[profile]);
	}

	// Write data to flash
	
	if (flash_wap_write()==EFFS_OK)												// Make sure flash data is written OK
		return WAP_OK;
	else
		return WAP_FAIL;

  #endif		
}


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

 $Function:    	ATB_wap_profile_send

 $Description:	Sends the configuration information of the current profile to the WAP task.
 
 $Returns:		

 $Arguments:	View  - the current view
 
*******************************************************************************/

void ATB_wap_profile_send(T_WAP_VIEW *View)
{
	T_MMI_WAP_CONFIGURE_IND					Configure;
	T_MMI_WAP_CONNECTION_CONFIGURE_IND		Connection;
	T_WAP_PROFILE							*Profile = View->Profile;
	ULONG									IPAddressLong;

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

// Configure integer values first - set up some common parameters

	Configure.object_id			= View->object_id;
	Configure.type				= WAP_IntConfig;
	Configure.length			= 0;
	Configure.strvalue			= 0;
	
	// Set max no. of history entries
	
	Configure.param				= configHISTORY_SIZE;
	Configure.intvalue			= (U32) MAX_HISTORY;
	ATB_wap_configure(&Configure);

	// Switch off images, for now
	
	Configure.param				= configDISPLAY_IMAGES;
	Configure.intvalue			= 1;
	ATB_wap_configure(&Configure);
	Configure.param				= configUPDATE_IMAGES;
	Configure.intvalue			= 0;
	ATB_wap_configure(&Configure);

	// Set default channel

	Configure.param				= configDEFAULT_CHANNEL;
	Configure.intvalue			= View->channel;
	ATB_wap_configure(&Configure);

	// Configure some connection parameters now
	Connection.object_id		= View->object_id;
	Connection.type 			= WAP_IntConfig;
	Connection.channel_id		= View->channel;
	Connection.length			= 0;
	Connection.strvalue			= 0;

	// Setup stack mode
	Connection.param			= configSTACKMODE;
	Connection.intvalue			= MODE_CO_WSP;
	ATB_wap_connection_configure(&Connection);

	// Set bearer for data channel
	Connection.param			= configACCESS_TYPE;
	switch(Profile->AccessType)
	{
		case WAP_GPRS_DATA:
			Connection.intvalue	= BEARER_GSM_GPRS;
		break;
		case WAP_CS_DATA:
			Connection.intvalue	= BEARER_GSM_CSD;
		break;
		case WAP_SMS:
			Connection.intvalue	= BEARER_GSM_SMS;
		break;
	}
	ATB_wap_connection_configure(&Connection);

		// Setup timeout
	Connection.param			= configTIMEOUT;
	Connection.intvalue			= Profile->ResponseTimer;
	ATB_wap_connection_configure(&Con

⌨️ 快捷键说明

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