📄 jnw_http.c
字号:
/*****************************************************************************
* Copyright Statement:
* --------------------
* This software is protected by Copyright and the information contained
* herein is confidential. The software may not be copied and the information
* contained herein may not be used or disclosed except with the written
* permission of MediaTek Inc. (C) 2005
*
* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
*
* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*****************************************************************************/
/*******************************************************************************
* Filename:
* ---------
* jnw_http.c
*
* Project:
* --------
* MAUI
*
* Description:
* ------------
*
*
* Author:
* -------
* -------
*
*==============================================================================
* HISTORY
* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*------------------------------------------------------------------------------
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
*------------------------------------------------------------------------------
* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*==============================================================================
*******************************************************************************/
#if !defined(__MTK_TARGET__)
/* mdi_datatype.h include MMIDataType.h which conflict with soc_api.h */
#include "Windows.h"
#endif /* !defined(__MTK_TARGET__) */
#include "jal.h"
#include "PixtelDataTypes.h"
#include "ucs2prot.h"
#include "kal_release.h" /* Basic data type */
#include "stack_common.h"
#include "stack_msgs.h"
#include "app_ltlcom.h" /* Task message communiction */
#include "stacklib.h" /* Basic type for dll, evshed, stacktimer */
#include "app_buff_alloc.h"
#include "stack_timer.h"
#include "syscomp_config.h"
#include "task_config.h"
#include "custom_config.h"
#include "wapadp.h"
#include "wap_ps_struct.h"
#include "j2me_trace.h"
#include "jam_msg_handler.h"
#include "jam_internal.h"
#include "jnw_internal.h"
#include "jvm_internal.h"
#include "jvm_adaptor.h"
#include "mmiapi.h"
/* Network */
#include "soc_api.h"
#include "soc2tcpip_struct.h"
#include "l3_inc_enums.h"
#include "app_str.h"
#include "ConnectManageGprot.h"
static kal_uint8 j2me_http_current_req_id = 0; /* even for HTTP */
static kal_uint8 j2me_https_current_req_id = 1; /* odd for HTTPS */
static kal_uint8 j2me_http_ref_count = 0;
static kal_uint8 j2me_https_ref_count = 0;
static kal_int16 j2me_http_channel_id = -1;
static kal_int16 j2me_https_channel_id = -1;
static kal_uint8 j2me_http_error_num = WPS_OK;
static j2me_http_wps_native_struct j2me_http_wps_native_data = {0, 0, 0, KAL_FALSE, 0, NULL, 0, NULL};
static j2me_http_wps_sec_session_struct j2me_http_wps_native_sec_data = { -1, -1, -1, -1, KAL_FALSE, NULL};
/* true when http channel request pending */
static kal_bool j2me_http_channel_set_pending = KAL_FALSE;
/* true when http connection is cosing */
static kal_bool j2me_http_is_closing_connection = KAL_FALSE;
extern wap_get_prof_content_rsp_struct wap_prof;
extern kal_eventgrpid J2ME_async_http_eventgroup;
kal_uint32 J2ME_async_http_msgid;
kal_bool flag_wait_async_http_msgid;
kal_bool auto_return_for_auth = KAL_TRUE;
static jnw_http_sec_certificate_file_struct jnw_http_sec_certificate = {0,NULL,0};
static void (*http_message_call_back) (int , int);
#define __JAVA_SUPPORT_HTTP_BEARER_FALLBACK__
#ifdef __JAVA_SUPPORT_HTTP_BEARER_FALLBACK__
static j2me_http_write_req_struct j2me_http_write_req_data = {0,0,0,NULL,0,NULL,0,0,NULL,KAL_FALSE};
extern wap_get_bra_prof_id_rsp_struct wap_bra_prof;
#endif /* __JAVA_SUPPORT_HTTP_BEARER_FALLBACK__ */
/* special code for WAP off */
#ifndef WAP_SUPPORT
kal_int32 wps_pun_var_part(kal_uint8 op, kal_uint32 msg_id, void *p, kal_uint8 *buf)
{
return 1;
}
#endif
/*****************************************************************************
* FUNCTION
* jnw_http_register_callback
* DESCRIPTION
* register the callback function for HTTP response. The first parameter of the call back function
* is the message id getting from jnw_http_check_response_primitive, such as MSG_WPS_SET_CHANNEL_RSP,
* and the second parameter is channel id for channel ralitive messages, conneciton id (or request
* id) for http write and read relative messages, or a dummy number for other messages.
*
* PARAMETERS
* callback_ptr [IN] callback function
* RETURNS
* void
*****************************************************************************/
void jnw_http_register_callback(void (*callback_ptr)(int , int ))
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
http_message_call_back = callback_ptr;
return;
}
/*****************************************************************************
* FUNCTION
* jnw_http_deregister_callback
* DESCRIPTION
*
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
void jnw_http_deregister_callback()
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
http_message_call_back = NULL;
return;
}
/*****************************************************************************
* FUNCTION
* jnw_http_deregister_callback
* DESCRIPTION
* Not for exporting to be used by Java VM.
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
void jnw_callback_handler(int channel_or_connect_id)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if(http_message_call_back != NULL)
{
(*http_message_call_back)(jnw_http_check_response_primitive(), channel_or_connect_id);
}
}
#ifdef __JAVA_SUPPORT_HTTP_BEARER_FALLBACK__
/*****************************************************************************
* FUNCTION
* j2me_http_reset_write_req_data
* DESCRIPTION
*
* PARAMETERS
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -