/**********************************************************************************
Filename: GRZHTTPUtil.c
Author: liulj
Date Created:2010-11-25
Contains: GRZ's http utility
**********************************************************************************/
#include "MMI_features.h"
/* MTK End */
#if !defined(__MTK_TARGET__)
#include <windows.h>
#endif
#include "MMI_include.h"
/**********************/
/***** Header Files *****/
/**********************/
#ifdef FIRST_PASS
#include "BuildCfg.h"
#endif
#include "ProtocolEvents.h"
#include "HardwareEvents.h"
#include "Thrdosinterface.h"
#include "OSThreadInterfaceGprot.h"
#include "MainMenuDef.h"
#include "CustomCfg.h"
#include "audioInc.h"
#include "IdleAppDef.h"
#include "BootUp.h"
#include "ProfileGProts.h"
#include "CommonScreens.h"
#include "custom_data_account.h"
#include "custom_mmi_default_value.h"
#include "app2soc_struct.h"
#include "cbm_api.h"
#include "Mmi_frm_events.h"
#include "Conversions.h"
/* GRZ ASM*/
#include "GRZHttpUtilProt.h"
#include "GRZPhoneBookGprot.h"
extern void mmi_frm_set_protocol_event_handler_int(
mmi_frm_event_table_enum tableType,
U16 eventID,
PsFuncPtr funcPtr,
MMI_BOOL isMultiHandler);
typedef struct
{
S8 GRZSocketInputBuff[GRZ_SOCKET_MAX_INPUT_LEN + 1];
kal_uint8 GRZServerIPAddress[4];
U8 GRZSocketIsCallbackFuncCalled;
grz_soc_app_result GRZSocketResult;
soc_grz_app_enum currentSocketAppType;
//PS8 GRZSocketResultBuffer;
//S32 GRZSocketResultBufferSize;
soc_grz_app_transaction_struct *soc_grz_transaction;
} grz_socket_app_context_struct;
static grz_socket_app_context_struct *g_grz_socket_app_context;
/*for operate phone book */
S8 tmpName[MAX_PB_NAME_LENGTH]={0};
PS8 newName[MAX_PB_NAME_LENGTH]={0};
S8 tmpNumber[MAX_PB_NUMBER_LENGTH]={0};
char *bodySignal="<body>";
char *splitChar="<";
char *ptr;
char *tmpBuffer[MAX_RCV_BUFFER_SIZE]={0};
/*****************************************************************************
* FUNCTION
* grz_socket_init_context
* DESCRIPTION
*
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
void grz_socket_init_context(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
g_grz_socket_app_context=OslMalloc(sizeof(grz_socket_app_context_struct));
memset(g_grz_socket_app_context, 0, sizeof(grz_socket_app_context_struct));
g_grz_socket_app_context->GRZSocketResult = GRZ_SOC_SUCCESS;
memset(g_grz_socket_app_context->GRZSocketInputBuff, 0, sizeof(g_grz_socket_app_context->GRZSocketInputBuff));
g_grz_socket_app_context->currentSocketAppType=HTTP;
}
/*****************************************************************************
* FUNCTION
* grz_socket_release_context_and_mem
* DESCRIPTION
*
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
void grz_socket_release_context_and_mem(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (g_grz_socket_app_context)
{
OslMfree(g_grz_socket_app_context);
g_grz_socket_app_context = NULL;
}
}
/*****************************************************************************
* FUNCTION
* GRZSocketSendReq
* DESCRIPTION
*
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
void GRZSocketSendReq(const S8 *url)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
U8 grzSocketAccountId = custom_get_csd_profile_num();
grz_soc_app_result grzSocketTmpResult = GRZ_SOC_SUCCESS;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if(!g_grz_socket_app_context)
{
grz_socket_init_context();
memcpy(g_grz_socket_app_context->GRZSocketInputBuff, url, sizeof(url));
}
else
{
grzSocketTmpResult=GRZ_SOC_BUSY;
}
if (g_grz_socket_app_context->currentSocketAppType == HTTP)
{
grzSocketTmpResult = soc_grz_app_request(
HTTP,
grzSocketAccountId,
NULL,
g_grz_socket_app_context->GRZSocketInputBuff,
strlen(g_grz_socket_app_context->GRZSocketInputBuff),
NULL,
0,
GRZSocketRsp);
}
else
{
grzSocketTmpResult = GRZ_SOC_UNKNOWN_APP;
}
/* To handle the scenario that callback function is called before soc_grz_app_request() returns
by checking if value of EmSocketResult is still the same as its default value (GRZ_SOC_SUCCESS) */
if (g_grz_socket_app_context->GRZSocketResult == GRZ_SOC_SUCCESS)
{
g_grz_socket_app_context->GRZSocketResult = grzSocketTmpResult;
}
}
/*****************************************************************************
* FUNCTION
* soc_grz_app_request
* DESCRIPTION
* MMI calls this function to send request to server in internet.
* This function will start a request and response transaction.
* When a transaction already exists, the function will return Busy.
* PARAMETERS
* app_id [IN] Is ECHO,please specify server_ip_address[4], *echo_text and echo_text_len.
* account_id [IN]
* server_ip_address [?]
* url [?] And *exco_text. They will be freed when the request-response transaction ends.
* url_len [IN]
* echo_text [?] int echo_text_len
* echo_text_len [IN]
* callback [IN]
* char server_ip_address[4],(?)
* Note that following items.(?)
* RETURNS
* 0, GRZ_SOC_SUCCESS
* -1, GRZ_SOC_NO_MEMORY
* -2, GRZ_SOC_BUSY
* -3, GRZ_SOC_UNKNOWN_APP
* -4, GRZ_SOC_BEARER_FAIL
* -5, GRZ_SOC_CNT_RESET_BY_PEER
* -6, GRZ_SOC_PEER_NO_RESPONSE
* -7, GRZ_SOC_PEER_NOT_REACHABLE
* -8, GRZ_SOC_ERROR
* -9, GRZ_SOC_INVAL_PARA
*****************************************************************************/
int soc_grz_app_request(
soc_grz_app_enum app_id,
int account_id,
char server_ip_address[4],
char *url,
int url_len,
char *echo_text,
int echo_text_len,
soc_grz_app_rsp_t callback)
{
/*--
- 1
- 2
前往页