📄 atbwapaui.c
字号:
$Returns: WAP_OK
$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 = &(WapProfilesData->Profile[View->ProfileId]);
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: WAP_OK
$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;
#ifdef TRACE_ATBWAPAUI
TRACE_FUNCTION("ATB_wap_profile_names_read");
#endif
/* Default values are provided. If either of the files 'mmi/wapdata'
* or 'mmi/wapprof' aren't found, files is created with these defaults.
* The '0' size indicator indicates that one of the files was not present. */
if (flash_wap_read() == 0)
{
ATB_wap_profile_default_create();
}
View->Status = WapData->Status; /* Status flags for settings */
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] = (char *)WapProfilesData->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] = (char *)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] = (char *)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: WAP_OK
$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: WAP_OK if profile successfully saved
WAP_FAIL otherwise
$Arguments: None.
*******************************************************************************/
T_WAP_RES ATB_wap_profile_default_create()
{
UBYTE no_of_bookmarks = 10;
char *bookmarksList[] =
{
"Yahoo!",
"AOL",
"O2",
"Financial Times",
"Cnet tech news",
"T-Mobile UK",
"Ents24",
"WEB.DE",
"Vizzavi",
"El Pais"
};
char *bookURLList[] =
{
"http://wap.yahoo.com",
"http://wap.aol.co.uk",
"http://wap.o2.co.uk/",
"http://wap.ft.com",
"http://wap.cnet.com",
"http://wap.t-mobile.co.uk",
"http://wap.ents24.co.uk",
"http://wap.web.de",
"http://wap.vizzavi.co.uk",
"http://wap.elpais.es"
};
UBYTE no_of_history = 0;
char *historyList[] = { "dummy" };
char *histURLList[] = { "www.dummy.org" };
UBYTE no_of_profiles = 3;
char *profilesDefault[] = { "Breathe", "Vodaf.CSD", "Vodaf.GPRS"};
char *homepageURL[] = { "http://wap.yahoo.com", "http://wap.yahoo.com", "http://wap.yahoo.com"};
char *IPAddress1[] = { "062.024.128.014", "212.183.137.012", "212.183.137.012"};
char *IPAddress2[] = { "062.024.128.014", "212.001.130.132", "212.001.130.132"};
char *DialupNumber[] = { "00448704290000", "00447836900808", "00448456609561" };
char *APN[] = { "none", "none", "wap.vodafone.co.uk"};
char *Username[] = { "breathe", "user@vodafone.net", "user@vodafone.net" };
char *Password[] = { "breathewap", "user", "user"};
UBYTE AccessType[] = { WAP_CS_DATA, WAP_CS_DATA, WAP_GPRS_DATA };
UBYTE ConnectionSpeed[] = { WAP_ANALOGUE, WAP_ANALOGUE, WAP_ANALOGUE };
USHORT ResponseTimer[] = {180,60,60};
USHORT Port1[] = {9201,9201,9201};
USHORT Port2[] = {9201,9201,9201};
USHORT entryIndex;
USHORT profile;
char number[NUMBER_PADDING+1];
#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++)
{
ATB_char_to_uc(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(number,"%2d. ",entryIndex+1); /* store number */
ATB_char_to_uc(WapData->History[entryIndex], number);
ATB_char_to_uc(&WapData->History[entryIndex][NUMBER_PADDING], historyList[entryIndex]);
strcpy(WapData->HistoryURL[entryIndex], histURLList[entryIndex]);
}
/* Copy profile data into WapData and WapProfilesData structures */
WapData->no_of_profiles = no_of_profiles;
for (profile = 0; profile<no_of_profiles; profile++)
{
ATB_char_to_uc(WapProfilesData->Profile[profile].Title, profilesDefault[profile]);
strcpy(WapProfilesData->Profile[profile].Homepage, homepageURL[profile]);
WapProfilesData->Profile[profile].ConnectionType = WAP_TEMPORARY;
WapProfilesData->Profile[profile].ConnectionSpeed = ConnectionSpeed[profile];
WapProfilesData->Profile[profile].Security = FALSE;
WapProfilesData->Profile[profile].AccessType = AccessType[profile];
WapProfilesData->Profile[profile].ResponseTimer = ResponseTimer[profile];
WapProfilesData->Profile[profile].Port1 = Port1[profile];
WapProfilesData->Profile[profile].Port2 = Port2[profile];
strcpy(WapProfilesData->Profile[profile].IPAddress1, IPAddress1[profile]);
strcpy(WapProfilesData->Profile[profile].IPAddress2, IPAddress2[profile]);
strcpy(WapProfilesData->Profile[profile].DialupNumber, DialupNumber[profile]);
strcpy(WapProfilesData->Profile[profile].APN, APN[profile]);
strcpy(WapProfilesData->Profile[profile].Username, Username[profile]);
strcpy(WapProfilesData->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;
}
/*******************************************************************************
$Function: ATB_wap_profile_send
$Description: Sends the configuration information of the current profile to the WAP task.
$Returns: None.
$Arguments: View - the current view
*******************************************************************************/
void ATB_wap_profile_send(T_WAP_VIEW *View)
{
T_WAP_PROFILE *Profile = View->Profile;
ULONG IPAddressLong;
#ifdef TRACE_ATBWAPAUI
TRACE_FUNCTION("ATB_wap_profile_send");
#endif
/* Set bearer for data channel */
switch(Profile->AccessType)
{
case WAP_GPRS_DATA:
ATB_wap_conn_config_int(View, configACCESS_TYPE, BEARER_GSM_GPRS);
break;
case WAP_CS_DATA:
ATB_wap_conn_config_int(View, configACCESS_TYPE, BEARER_GSM_CSD);
break;
case WAP_SMS:
ATB_wap_conn_config_int(View, configACCESS_TYPE, BEARER_GSM_SMS);
break;
}
/* Setup timeout */
ATB_wap_conn_config_int(View, configTIMEOUT, Profile->ResponseTimer);
/* Set IP address
* Trying first IP address, so set flag accordingly */
View->secondaryIP = FALSE;
ATB_conv_str_to_IP(Profile->IPAddress1, strlen(Profile->IPAddress1), &IPAddressLong);
ATB_wap_conn_config_str(View, configUDP_IP_GW, (CHAR *)&IPAddressLong, sizeof(ULONG));
/* Set WAP Server Authentification name */
ATB_wap_conn_config_str(View, configAUTH_ID_GW, Profile->Username, strlen(Profile->Username));
/* Set WAP Server Authentification password */
ATB_wap_conn_config_str(View, configAUTH_PASS_GW, Profile->Password, strlen(Profile->Password));
/* Set WAP host */
ATB_wap_conn_config_str(View, configADD_HOST, Profile->Homepage, strlen(Profile->Homepage));
/* Set connection port 1 */
ATB_wap_conn_config_int(View, WAP_setPort1, Profile->Port1);
/* Set connection port 2 */
ATB_wap_conn_config_int(View, WAP_setPort2, Profile->Port2);
return;
}
/*******************************************************************************
$Function: ATB_wap_secondary_IP
$Description: If first IP address fails, try using secondary one.
$Returns: None.
$Arguments: View - the current view
*******************************************************************************/
void ATB_wap_secondary_IP(T_WAP_VIEW *View)
{
ULONG IPAddressLong;
#ifdef TRACE_ATBWAPAUI
TRACE_FUNCTION("ATB_wap_secondary_IP()");
#endif
/* We're now using secondary IP */
View->secondaryIP = TRUE;
/* Send IP configuration to WAP browser */
ATB_conv_str_to_IP(View->Profile->IPAddress2, strlen(View->Profile->IPAddress2), &IPAddressLong);
ATB_wap_conn_config_str(View, configUDP_IP_GW, (CHAR *)&IPAddressLong, sizeof(ULONG));
/* Reload the requested page */
ATB_wap_download_url(View, View->URL, TRUE);
return;
}
/*******************************************************************************
$Function: ATB_wap_entry_list_create
$Description: Creates an entries list
$Returns: Pointer to entry list
$Arguments: type - type of list
max_entries - maximum number of entries in list
entry_size - size of entries in characters
unicode - TRUE if entries are unicode
*******************************************************************************/
T_WAP_LIST * ATB_wap_entry_list_create(WAP_LIST_TYPE type, UBYTE max_entries, UBYTE entry_size, BOOL unicode)
{
T_WAP_LIST *EntryList;
#ifdef TRACE_ATBWAPAUI
TRACE_FUNCTION("ATB_wap_entry_list_create");
#endif
/* Allocate memory */
EntryList = (T_WAP_LIST *)AUI_wap_memory_alloc(sizeof(T_WAP_LIST));
EntryList->Entry = (char **)AUI_wap_memory_alloc(max_entries*sizeof(char*));
/* Assign list parameters */
EntryList->type = type;
EntryList->max_entries = max_entries;
EntryList->entry_size = entry_size;
EntryList->no_of_entries = 0;
EntryList->unicode = unicode;
return EntryList;
}
/*******************************************************************************
$Function: ATB_wap_entry_list_destroy
$Description: Destroys an entries list
$Returns: WAP_OK
WAP_FAIL if list does not exist
$Arguments: EntryList - pointer to entry list data
*******************************************************************************/
T_WAP_RES ATB_wap_entry_list_destroy(T_WAP_LIST *EntryList)
{
#ifdef TRACE_ATBWAPAUI
TRACE_FUNCTION("AUI_wap_entry_list_destroy");
#endif
/* Ensure list exists */
if (EntryList==NULL)
return WAP_FAIL;
/* Destroy structure */
AUI_wap_memory_free((UBYTE *)EntryList->Entry, EntryList->max_entries*sizeof(char *));
AUI_wap_memory_free((UBYTE *)EntryList,sizeof(T_WAP_LIST));
return WAP_OK;
}
/*******************************************************************************
$Function: ATB_wap_entry_add
$Description: Adds an entry to an entry list
$Returns: WAP_OK if added successfully
WAP_FAIL if the list is full
$Arguments: Entrylist - Pointer to entries table
Entry - Entry to add
*******************************************************************************/
T_WAP_RES ATB_wap_entry_add(T_WAP_LIST *EntryList, char *Entry)
{
UBYTE entryIndex = En
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -