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

📄 jnw_stream.c

📁 java 1.1 gemini 08_16
💻 C
📖 第 1 页 / 共 3 页
字号:
/*****************************************************************************
*  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_stream.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!
 *
 *------------------------------------------------------------------------------
 * 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 "jnw_internal.h"

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

static j2me_stream_struct j2me_stream[J2ME_STREAM_MAX_NUMBER] = 
                                {{J2ME_STREAM_INVALID},{J2ME_STREAM_INVALID},{J2ME_STREAM_INVALID},
                                 {J2ME_STREAM_INVALID},{J2ME_STREAM_INVALID},{J2ME_STREAM_INVALID},
                                 {J2ME_STREAM_INVALID},{J2ME_STREAM_INVALID},{J2ME_STREAM_INVALID},
                                 {J2ME_STREAM_INVALID}};
                                 
static jnw_stream_result_struct j2me_stream_result = {0,0};
static jnw_stream_send_result_struct j2me_stream_send_result = {0,0,0};
static jnw_stream_read_result_struct j2me_stream_read_result = {0,0,0,KAL_FALSE,0};
static kal_uint8* j2me_stream_read_data = NULL;
static kal_uint32 J2ME_async_stream_msgid = 0;
static kal_bool flag_wait_async_stream_msgid = KAL_FALSE;

extern wap_get_prof_content_rsp_struct wap_prof;
extern kal_eventgrpid J2ME_async_stream_eventgroup;

/*****************************************************************************
 * FUNCTION
 *  readStreamAsyncEvent
 * DESCRIPTION
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  
 *****************************************************************************/
unsigned long readStreamAsyncEvent()
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    kal_uint32 event_group, ret_msgid;
    kal_status result;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    flag_wait_async_stream_msgid = KAL_TRUE;

    result = kal_retrieve_eg_events(J2ME_async_stream_eventgroup, 1, KAL_OR_CONSUME, &event_group, KAL_NO_SUSPEND);

    if (result == KAL_NOT_PRESENT)
    {
        return (0);    /* IO_WOULDBLOCK */
    }
    else
    {
        ret_msgid = J2ME_async_stream_msgid;
        J2ME_async_stream_msgid = 0;
        flag_wait_async_stream_msgid = KAL_FALSE;

        /* 2nd bit notify complete retreive async event */
        kal_set_eg_events(J2ME_async_stream_eventgroup, 0x2, KAL_OR);

        return ret_msgid;
    }
}


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

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    kal_trace(TRACE_GROUP_3, FUNC_J2ME_STREAM_RESET_NATIVE_DATA);

    if (j2me_stream_read_data != NULL)
    {
        jvm_free(j2me_stream_read_data);
        j2me_stream_read_data = NULL;
    }
}

/*****************************************************************************
 * FUNCTION
 *  j2me_stream_send_ilm
 * DESCRIPTION
 *  
 * PARAMETERS
 *  local_para_ptr      [?]         
 *  peer_buff_ptr       [?]         
 *  ilm_id              [IN]        
 *  dst_id              [IN]        
 * RETURNS
 *  void
 *****************************************************************************/
static void j2me_stream_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_stream_search
 * DESCRIPTION
 *  
 * PARAMETERS
 *  stream_id        [IN]        
 * RETURNS
 *  void
 *****************************************************************************/
kal_uint8 j2me_stream_search(kal_int16 stream_id)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/    
    kal_uint8 i = 0;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    for ( ; i < J2ME_STREAM_MAX_NUMBER; i++)
    {
        if (j2me_stream[i].id == stream_id)
        {
            return i;
        }
    }    

    return J2ME_STREAM_MAX_NUMBER;
}


/*****************************************************************************
 * FUNCTION
 *  j2me_stream_remove
 * DESCRIPTION
 *  
 * PARAMETERS
 *  stream_id        [IN]        
 * RETURNS
 *  void
 *****************************************************************************/
void j2me_stream_remove(kal_uint8 stream_id)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    int i = 0;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    kal_trace(TRACE_GROUP_3, FUNC_J2ME_STREAM_REMOVE, stream_id);
    
    i = j2me_stream_search((kal_int16)stream_id);

    if (i >= J2ME_STREAM_MAX_NUMBER)
    {
        kal_trace(TRACE_GROUP_3, FUNC_J2ME_STREAM_REMOVE_2, stream_id);
        return;
    }

    j2me_stream[i].id = J2ME_STREAM_INVALID;

    return;
}

/*****************************************************************************
 * FUNCTION
 *  j2me_stream_add
 * DESCRIPTION
 *  
 * PARAMETERS
 *  stream_id        [IN]        
 * RETURNS
 *  void
 *****************************************************************************/
void j2me_stream_add(kal_uint8 stream_id)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    int i = 0;
    kal_int16 id = (kal_int16)stream_id;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    kal_trace(TRACE_GROUP_3, FUNC_J2ME_STREAM_ADD, stream_id);
    
    i = j2me_stream_search((kal_int16) J2ME_STREAM_INVALID);

    if (i >= J2ME_STREAM_MAX_NUMBER)
    {
        ASSERT(0);
    }

    j2me_stream[i].id = id;

    return;
}


⌨️ 快捷键说明

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