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

📄 jnw_socket.c

📁 java 1.1 gemini 08_16
💻 C
📖 第 1 页 / 共 5 页
字号:
/*****************************************************************************
*  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) 2001
*
*****************************************************************************/

/*****************************************************************************
 *
 * Filename:
 * ---------
 *   jam_adaptation.c
 *
 * Project:
 * --------
 *   Maui_Software
 *
 * Description:
 * ------------
 *   This file implements Network socket APIs
 *
 * 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!
 *
 *------------------------------------------------------------------------------
 * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
 *============================================================================
 ****************************************************************************/

/*************************************************************************
 * Include Header Files
 *************************************************************************/

#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 "jam_internal.h"
#include "jvm_internal.h"
#include "jnw_internal.h"
#include "jvm_adaptor.h"

#include "app2soc_struct.h"
#include "stack_common.h"
#include "stack_msgs.h"
#include "task_main_func.h"
#include "app_ltlcom.h"

/* Network */
#include "soc_api.h"
#include "soc2tcpip_struct.h"

/*************************************************************************
 * External Declaration
 *************************************************************************/

#ifdef __JBLENDIA__
extern void kjava_recvSocDataToBufPool(int handle);
extern void kjava_processDNSevent(app_soc_get_host_by_name_ind_struct* ind_ptr);
#endif
/*************************************************************************
 * Global Definition
 *************************************************************************/

/* J2ME_active_nw_acc_id (GPRS ID). */
kal_uint32 J2ME_active_nw_acc_id = 0;

/* this variable is to record the corresponding CSD network ID of the GPRS ID. */
kal_uint32 	J2ME_active_nw_acc_id_CSD = 0;

/*
 * add this variable to record which is our current ACTIVE NW ID (GPRS/CSD bearer).
 * *    Default is GPRS ID. 
 */
kal_uint32 	J2ME_current_active_nw_id = 0;

j2me_soc_notify_ind_struct J2ME_asnyc_ind[J2ME_MAX_SOC_NUM];

kal_uint32 J2ME_setasyn_bitmap;
kal_uint16 J2ME_dns_setasyn_bitmap;

/* If these is still ONE pending event, so we record the result in the J2ME_blockedasnyc_ind rather than J2ME_asnyc_ind. */
j2me_soc_notify_ind_struct J2ME_blockedasnyc_ind[J2ME_MAX_SOC_NUM];

/* Record the IND result from SOC of MSG_ID_APP_SOC_GET_HOST_BY_NAME_IND. */
j2me_soc_get_host_by_name_ind_struct J2ME_async_ghbn_ind[J2ME_MAX_SOC_NUM];

/* Record the IND result from SOC of MSG_ID_APP_SOC_GET_HOST_BY_ADDR_IND. */
j2me_soc_get_host_by_addr_ind_struct J2ME_async_ghbaddr_ind[J2ME_MAX_SOC_NUM];

#ifdef __JAVA_SUPPORT_SERVER_SOCKET__
j2me_soc_open_bearer_struct J2ME_wait_bearer[J2ME_MAX_SOC_NUM];
#endif

int net_errno;
kal_bool j2me_socket_io_activated = KAL_FALSE;

/*
 * When polling a connect of the specified handle. If we have not received the corresponding handle IND, we wet the 
 * * corresponding handle bit ON in J2ME_pendingasyn_bitmap to indicate such pending. 
 */
kal_uint32 J2ME_pendingasyn_bitmap;

extern kal_uint32 J2ME_pendingasyn_bitmap;

/* This is used to record a IND event of the handle has another IND but not processed by JNW yet. */
kal_uint32 J2ME_blockedasyn_bitmap;
extern kal_mutexid J2ME_async_mutex;

extern kal_int32 readAsyncEvent(kal_int32 handle, kal_int32 dns_idx, kal_uint32 protect);
kal_int8 _jnw_process_soc_async_event(soc_event_enum event, kal_int32 handle);
extern void jui_widget_show_connect_icon(void);
extern void jui_widget_hide_connect_icon(void);

/* I add this function for handling querying user's indication. */
extern kal_int32 get_bearer_fallback_user_confirm(void);

extern j2me_soc_notify_ind_struct J2ME_asnyc_ind[J2ME_MAX_SOC_NUM];
extern j2me_soc_notify_ind_struct J2ME_blockedasnyc_ind[J2ME_MAX_SOC_NUM];
#ifdef __JAVA_SUPPORT_SERVER_SOCKET__
extern j2me_soc_open_bearer_struct J2ME_wait_bearer[J2ME_MAX_SOC_NUM];
#endif
extern kal_uint32 J2ME_blockedasyn_bitmap;
extern kal_uint32 J2ME_setasyn_bitmap;
extern kal_uint16 J2ME_dns_setasyn_bitmap;
extern j2me_soc_get_host_by_name_ind_struct J2ME_async_ghbn_ind[J2ME_MAX_SOC_NUM];
extern kal_mutexid J2ME_async_mutex;

/* This account is used to determine whether Java can be PAUSE/RESUEM or can just be TERMINATED? */
static int _active_socket_count = 0;

extern int _active_datagram_count;

/* I add this variable to record whether we need to do bearer fallback during polling connection. */
kal_bool g_bNeedBearerfallback = KAL_FALSE;
kal_int32 g_i4CurrentIPNumber[J2ME_MAX_SOC_NUM];
kal_int32 g_i4CurrentPortNumber[J2ME_MAX_SOC_NUM];
char *g_pcHostName[J2ME_MAX_SOC_NUM];
static kal_uint16 csd_disconnect_time = 0;
static kal_bool net_initialized = KAL_FALSE;
static kal_uint8 g_dns_idx = 0;

/* Add callback function to receive asyn event */
java_asyn_ind_table J2ME_asyn_table;

/*************************************************************************
 * Function Definition
 *************************************************************************/
/* XXX - non-suitable API, refine later */
int socketCloseHandle(int handle);


/*****************************************************************************
 * FUNCTION
 *  jnw_socket_get_dns_idx
 * DESCRIPTION
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  int
 *****************************************************************************/
int jnw_socket_get_dns_idx(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    int ret_dns_idx = 0;
    int count = 0;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    
    while ((g_pcHostName[g_dns_idx] != NULL) && 
           (count < J2ME_MAX_SOC_NUM))
    {
        count++;
        g_dns_idx++;
        g_dns_idx = g_dns_idx % J2ME_MAX_SOC_NUM;
    }
    if (count >= J2ME_MAX_SOC_NUM)
    {
        return -1;
    }
    
    ret_dns_idx = g_dns_idx;
    g_dns_idx++;
    g_dns_idx = g_dns_idx % J2ME_MAX_SOC_NUM;

    return (int)ret_dns_idx;
}


/*****************************************************************************
 * FUNCTION
 *  set_java_csd_timing
 * DESCRIPTION
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void set_java_csd_timing(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    kal_trace(TRACE_INFO, FUNC_JNW_SET_CSD, csd_disconnect_time, net_initialized);

    /* change the CSD auto disconnect timer once the J2ME environment is initialized */
    if (csd_disconnect_time > 0 && !net_initialized)
    {
        soc_set_csd_auto_disconnect_timer(JAVA_CSD_DISCONNECT_TIME);
    }
}


/*****************************************************************************
 * FUNCTION
 *  restore_java_csd_timing
 * DESCRIPTION
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/

⌨️ 快捷键说明

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