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

📄 jam_platform_request.c

📁 java 1.1 gemini 08_16
💻 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:
 * ---------
 *  jam_platform_request.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!
 *
 *
 *------------------------------------------------------------------------------
 * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! 
 *==============================================================================
 *******************************************************************************/

#include <EventsGprot.h>
#include <wap_ps_struct.h>
#include <CallManagementGprot.h>
#include <JavaAgencyGProt.h>
#include "mmiapi_struct.h"
#include "mmiapi_enum.h"
#include "mmiapi.h"
#include "jal.h"
#include "jal_internal.h"
#include "jam_msg_handler.h"
#include "jam_msg_util.h"
#include "wapadp.h"
#include "MMI_features.h"
#include "VdoPlyGProt.h"
#ifdef __MMI_UCM__
#include "UCMGprot.h"
#endif


/* WAP User Agent. The size is determined by wap_get_user_agent_rsp_struct */
kal_uint8 jam_user_agent[256] = {0};
kal_bool parse_the_first_word = KAL_TRUE;

/*****************************************************************************
 * FUNCTION
 *  jam_activate_wap_browser
 * DESCRIPTION
 *  launch browser and connet to the specified URL
 * PARAMETERS
 *  url     [?]     URL address in ascii encoding
 * RETURNS
 *  0 if success
 *****************************************************************************/
int jam_activate_wap_browser(char *url)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    ilm_struct *ilm_ptr;

    wap_browser_startup_req_struct *para = NULL;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/

    if (mmi_java_is_no_network_service())
    {
        return JAM_PR_BROWSER_NO_NETWORK_SERVICE;
    }

#ifdef J2ME_SUPPORT_BACKGROUND
    /* platform request is not available during bg running state */
    if (jvm_get_state() == JVM_BG_RUNNING_STATE ||
        jvm_get_state() == JVM_SHORT_EVENT_STATE ||
        jvm_get_state() == JVM_LONG_EVENT_STATE )
    {    
        return JAM_PR_BROWSER_NOT_AVAILABLE;
    }
#endif /* J2ME_SUPPORT_BACKGROUND */

    /* Disable key handler to prevent sending duplicated requests */
    ClearAllKeyHandler();
    ClearKeyHandler(KEY_END, KEY_EVENT_DOWN);

    para = (wap_browser_startup_req_struct*) construct_local_para((kal_uint16) sizeof(wap_browser_startup_req_struct), 0);

    para->type = 2;
    strncpy((char*)para->url, url, (sizeof(para->url) - 1));

    ilm_ptr = allocate_ilm(MOD_J2ME);
    ilm_ptr->msg_id = MSG_ID_WAP_BROWSER_STARTUP_REQ;
    ilm_ptr->peer_buff_ptr = NULL;
    ilm_ptr->local_para_ptr = (local_para_struct*) para;
    SEND_ILM(MOD_J2ME, wap_get_service_module(MSG_ID_WAP_BROWSER_STARTUP_REQ), J2ME_WAP_SAP, ilm_ptr);

    return JAM_PR_BROWSER_OK;
}


/*****************************************************************************
 * FUNCTION
 *  jam_make_call
 * DESCRIPTION
 *  make a outgoing phone call
 * PARAMETERS
 *  number      [?]     phone number in UCS2 encoding
 * RETURNS
 *  -1 if empty number; 0 if success
 *****************************************************************************/
int jam_make_call(char *number)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    ilm_struct *ilm_ptr;
    mmi_make_call_req_ind_struct *p = NULL;
    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    if (number == NULL)
    {
        return JAM_PR_CALL_INVALID_PHONE_NUMBER;
    }

    /* number is too long */
    if(get_ucs2_len((kal_wchar*)number) > 90)
    {
        return JAM_PR_CALL_INVALID_PHONE_NUMBER;
    }

#ifdef J2ME_SUPPORT_BACKGROUND
    /* platform request is not available during bg running state */
    if (jvm_get_state() == JVM_BG_RUNNING_STATE ||
        jvm_get_state() == JVM_SHORT_EVENT_STATE ||
        jvm_get_state() == JVM_LONG_EVENT_STATE )
    {    
        return JAM_PR_CALL_NOT_AVAILABLE;
    }
#endif /* J2ME_SUPPORT_BACKGROUND */

    p = (mmi_make_call_req_ind_struct*) construct_local_para(sizeof(mmi_make_call_req_ind_struct), TD_CTRL);
    
    memcpy(p->strNumber, number, (get_ucs2_len((kal_wchar*)number) << 1) + 2);

#ifdef __MMI_DUAL_SIM_MASTER__
    if (jam_get_sim_id() == WAP_SIM_ID_SIM2)
    {
        p->call_type = MMI_UCM_VOICE_CALL_TYPE_SIM2;
    }
    else 
    {
        p->call_type = MMI_UCM_VOICE_CALL_TYPE;
    }
#endif /* __MMI_DUAL_SIM_MASTER__ */

    ilm_ptr = allocate_ilm(MOD_J2ME);

    ilm_ptr->msg_id = MSG_ID_MMI_MAKE_CALL_REQ_IND;
    ilm_ptr->local_para_ptr = (local_para_struct*) p;
    ilm_ptr->peer_buff_ptr = NULL;

    SEND_ILM(MOD_J2ME, MOD_MMI, MMI_J2ME_SAP, ilm_ptr);

    return JAM_PR_CALL_OK;
}


/*****************************************************************************
 * FUNCTION
 *  jam_activate_rtsp_player
 * DESCRIPTION
 *  launch RTSP player and connet to the specified URL
 * PARAMETERS
 *  url     [?]     URL address in ascii encoding
 * RETURNS
 *  0 if success
 *****************************************************************************/
int jam_activate_rtsp_player(char *url)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
#ifndef __MMI_VIDEO_STREAM__
    return JAM_PR_RTSP_NOT_SUPPORT;
#else /* __MMI_VIDEO_STREAM__ */

#ifdef J2ME_SHARE_MED_EXT_MEM
    return JAM_PR_RTSP_NOT_AVAILABLE;
#endif /* J2ME_SHARE_MED_EXT_MEM */

    if (mmi_java_is_no_network_service())
    {
        return JAM_PR_RTSP_NO_NETWORK_SERVICE;
    }

#ifdef J2ME_SUPPORT_BACKGROUND
    /* platform request is not available during bg running state */
    if (jvm_get_state() == JVM_BG_RUNNING_STATE ||
        jvm_get_state() == JVM_SHORT_EVENT_STATE ||
        jvm_get_state() == JVM_LONG_EVENT_STATE )
    {    
        return JAM_PR_RTSP_NOT_AVAILABLE;
    }
#endif /* J2ME_SUPPORT_BACKGROUND */

    /* Disable key handler to prevent sending duplicated requests */
    ClearAllKeyHandler();
    ClearKeyHandler(KEY_END, KEY_EVENT_DOWN);

    mmi_vdoply_send_rtsp_url_req((PS8) url);

    return JAM_PR_RTSP_OK;

#endif /* __MMI_VIDEO_STREAM__ */
    
}

/*****************************************************************************
 * FUNCTION
 *  jam_get_user_agent
 * DESCRIPTION
 *  get user agent 
 * PARAMETERS
 *  none.
 * RETURNS
 *  pointer to user agent array
 *****************************************************************************/
kal_uint8* jam_get_user_agent()
{
	if(parse_the_first_word)
	{
		int i = 0;
		while(jam_user_agent[i] != 0 && jam_user_agent[i] != ' ')
		{
			i++;
		}
		
		jam_user_agent[i] = 0;
		parse_the_first_word = KAL_FALSE;
	}
	
	return jam_user_agent;
}

/*****************************************************************************
 * FUNCTION
 *  jam_get_full_user_agent
 * DESCRIPTION
 *  get full name user agent. 
 * PARAMETERS
 *  none.
 * RETURNS
 *  pointer to user agent array
 *****************************************************************************/
kal_char* jam_get_full_user_agent(void)
{
	parse_the_first_word = KAL_FALSE;
	
	return (kal_char*)jam_get_user_agent();
}

/*****************************************************************************
 * FUNCTION
 *  jam_set_user_agent
 * DESCRIPTION
 *  set user agent
 *  If the length of user_agent is larger than jam_user_agent,
 *  the exceeded part would be ignored.
 * PARAMETERS
 *  user_agent : user agent
 *  len : length of user agent
 * RETURNS
 *  void
 *****************************************************************************/
void jam_set_user_agent(kal_uint8* user_agent, kal_uint16 len)
{
	kal_uint16 length = len > sizeof(jam_user_agent) ? sizeof(jam_user_agent) : len;

	parse_the_first_word = KAL_TRUE;
		
	memset(jam_user_agent,0,sizeof(jam_user_agent));
	memcpy(jam_user_agent,user_agent,length);
	
	return;
}

⌨️ 快捷键说明

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