📄 jnw_http.c
字号:
*****************************************************************************/
kal_int16 J2ME_http_get_channel_id(int request_id)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
int req_id = request_id;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
kal_trace(TRACE_GROUP_3, FUNC_J2ME_HTTP_GET_CHANNEL_ID, req_id, j2me_http_channel_id, j2me_https_channel_id);
if ((req_id % 2) == 0) /* even for J2ME_HTTP_WPS_CHANNEL_HTTP */
{
return j2me_http_channel_id;
}
else /* odd for J2ME_HTTP_WPS_CHANNEL_HTTPS */
{
return j2me_https_channel_id;
}
}
/*****************************************************************************
* FUNCTION
* J2ME_http_send_ilm
* DESCRIPTION
*
* PARAMETERS
* local_para_ptr [?]
* peer_buff_ptr [?]
* ilm_id [IN]
* dst_id [IN]
* RETURNS
* void
*****************************************************************************/
static void J2ME_http_send_ilm(void *local_para_ptr, void *peer_buff_ptr, msg_type ilm_id, module_type dst_id)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
ilm_struct *ilm_ptr = NULL;
sap_type sap_id;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
switch (dst_id)
{
case MOD_WPS:
sap_id = J2ME_WAP_SAP;
break;
default:
sap_id = J2ME_WAP_SAP;
break;
} /* switch (dst_id) */
ilm_ptr = allocate_ilm(MOD_JASYN);
ilm_ptr->local_para_ptr = (local_para_struct*) local_para_ptr;
ilm_ptr->msg_id = ilm_id;
ilm_ptr->peer_buff_ptr = (peer_buff_struct*) peer_buff_ptr;
SEND_ILM(MOD_JASYN, dst_id, sap_id, ilm_ptr)}
/*****************************************************************************
* FUNCTION
* J2ME_http_unset_channel
* DESCRIPTION
*
* PARAMETERS
* channel_type [IN]
* RETURNS
* void
*****************************************************************************/
void J2ME_http_unset_channel(int channel_type)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
int channelType = channel_type;
wps_unset_channel_req_struct *unset_channel_req = NULL;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
kal_trace(TRACE_GROUP_3, FUNC_J2ME_HTTP_UNSET_CHANNEL, channelType, j2me_http_channel_id, j2me_https_channel_id);
kal_trace(TRACE_GROUP_3, FUNC_J2ME_HTTP_UNSET_CHANNEL, channelType, j2me_http_ref_count, j2me_https_ref_count);
if (channelType == J2ME_HTTP_WPS_CHANNEL_HTTP)
{
if (j2me_http_channel_id >= 0)
{
unset_channel_req =
(wps_unset_channel_req_struct*) construct_local_para(sizeof(wps_unset_channel_req_struct), TD_CTRL);
unset_channel_req->channel_id = j2me_http_channel_id;
while (j2me_http_ref_count > 0)
{
jui_widget_hide_connect_icon();
j2me_http_ref_count--;
}
}
else
{
return;
}
}
else
{ /* channelType == J2ME_HTTP_WPS_CHANNEL_HTTPS */
if (j2me_https_channel_id >= 0)
{
unset_channel_req =
(wps_unset_channel_req_struct*) construct_local_para(sizeof(wps_unset_channel_req_struct), TD_CTRL);
unset_channel_req->channel_id = j2me_https_channel_id;
J2ME_http_reset_native_sec_data();
while (j2me_https_ref_count > 0)
{
jui_widget_hide_connect_icon();
j2me_https_ref_count--;
}
}
else
{
return;
}
}
J2ME_http_send_ilm(unset_channel_req, NULL, MSG_ID_WPS_UNSET_CHANNEL_REQ, MOD_WPS);
return;
}
/*****************************************************************************
* FUNCTION
* J2ME_http_send_abort
* DESCRIPTION
*
* PARAMETERS
* request_id [IN]
* RETURNS
*
*****************************************************************************/
kal_bool J2ME_http_send_abort(int request_id)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
int req_id = request_id;
kal_int16 channel_id;
wps_cancel_req_struct *abort_req;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
kal_trace(TRACE_GROUP_3, FUNC_J2ME_HTTP_SEND_ABORT, req_id);
abort_req = (wps_cancel_req_struct*) construct_local_para(sizeof(wps_cancel_req_struct), TD_CTRL);
abort_req->request_id = req_id;
channel_id = J2ME_http_get_channel_id(req_id);
if (channel_id < 0)
{
return KAL_FALSE;
}
else
{
abort_req->channel_id = (kal_uint8) channel_id;
}
J2ME_http_send_ilm(abort_req, NULL, MSG_ID_WPS_CANCEL_REQ, MOD_WPS);
return KAL_TRUE;
}
/*****************************************************************************
* FUNCTION
* J2ME_http_close_channel
* DESCRIPTION
* obsolete function. Do not use!
* PARAMETERS
* channel_type [IN]
* RETURNS
*
*****************************************************************************/
kal_bool J2ME_http_close_channel(int channel_type)
{
#if (0)
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
#endif
ASSERT(0);
return KAL_TRUE;
}
/*****************************************************************************
* FUNCTION
* http_wps_response_handler
* DESCRIPTION
*
* PARAMETERS
* ilm_ptr [?]
* RETURNS
* void
*****************************************************************************/
void http_wps_response_handler(ilm_struct *ilm_ptr)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
kal_bool call_back_needed = KAL_FALSE;
kal_int32 call_back_id = 0;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
kal_trace(TRACE_GROUP_3, FUNC_HTTP_WPS_RESPONSE_HANDLER);
if (J2ME_async_http_msgid && flag_wait_async_http_msgid)
{
/* Pedning async event */
kal_uint32 event_group, polling = 0;
kal_status result;
while (1)
{
/* 2nd bit indicate wait pending async event consumed */
result = kal_retrieve_eg_events(J2ME_async_http_eventgroup, 0x2, KAL_OR_CONSUME, &event_group, KAL_NO_SUSPEND);
if (result != KAL_NOT_PRESENT || polling++ >= 100)
{
break;
}
/* To avoid deadlock and complicated timer control, use polling */
kal_sleep_task(1);
}
}
J2ME_http_reset_native_data();
J2ME_async_http_msgid = ilm_ptr->msg_id;
switch (ilm_ptr->msg_id)
{
case MSG_ID_WPS_SET_CHANNEL_RSP:
{
wps_set_channel_rsp_struct *p = (wps_set_channel_rsp_struct*) ilm_ptr->local_para_ptr;
kal_trace(TRACE_GROUP_3, FUNC_HTTP_WPS_RESPONSE_HANDLER_1);
j2me_http_wps_native_data.msg_type = MSG_WPS_SET_CHANNEL_RSP;
if (p->result == WPS_OK)
{
jui_widget_show_connect_icon();
if (j2me_http_channel_set_pending)
{
j2me_http_channel_id = p->channel_id;
j2me_http_ref_count = 1;
}
else
{
j2me_https_channel_id = p->channel_id;
j2me_https_ref_count = 1;
}
}
j2me_http_channel_set_pending = KAL_FALSE;
J2ME_http_update_result(p->result);
call_back_id = p->channel_id;
call_back_needed = KAL_TRUE;
}
break;
case MSG_ID_WPS_UNSET_CHANNEL_RSP:
{
wps_unset_channel_rsp_struct *p = (wps_unset_channel_rsp_struct*) ilm_ptr->local_para_ptr;
kal_trace(TRACE_GROUP_3, FUNC_HTTP_WPS_RESPONSE_HANDLER_2);
j2me_http_wps_native_data.msg_type = MSG_WPS_UNSET_CHANNEL_RSP;
if (p->result == WPS_OK)
{
if (p->channel_id == j2me_http_channel_id)
{
j2me_http_channel_id = -1;
}
else if (p->channel_id == j2me_https_channel_id)
{
j2me_https_channel_id = -1;
}
}
J2ME_http_update_result(p->result);
call_back_id = p->channel_id;
call_back_needed = KAL_TRUE;
}
break;
case MSG_ID_WPS_HTTP_RSP:
{
wps_http_rsp_struct *p = (wps_http_rsp_struct*) ilm_ptr->local_para_ptr;
wps_http_rsp_var_struct http_rsp_var;
kal_uint16 pdu_length = 0;
kal_trace(TRACE_GROUP_3, FUNC_HTTP_WPS_RESPONSE_HANDLER_3);
j2me_http_wps_native_data.msg_type = MSG_WPS_HTTP_RSP;
j2me_http_wps_native_data.req_id = p->request_id;
if (p->result == WPS_OK)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -