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

📄 cmcc_phonebook.c

📁 java 1.1 gemini 08_16
💻 C
📖 第 1 页 / 共 2 页
字号:
/*****************************************************************************
*  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:
 * ---------
 *   cmcc_phonebook.c
 *
 * Project:
 * --------
 *   Maui_Software
 *
 * Description:
 * ------------
 *   This file defines CMCC phonebook native API
 *
 * 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!
 */

#include <kni.h>
#include <global.h>
#include <defaultLCDUI.h>
#include <nativeGUI.h>

#include "kal_release.h"
#include "stack_common.h"
#include "stack_msgs.h"
#include "task_main_func.h"
#include "app_ltlcom.h"
#include "j2me_custom_option.h"


#include "jpim_interface.h"
#include "app_str.h"

#ifdef CLDCHI
kal_bool j2me_phonebook_event;
int j2me_phonebook_value[J2ME_PB_LEN];
kal_uint32 j2me_pb_head, j2me_pb_tail;
#else /* CLDCHI */
#endif /* CLDCHI */

#if defined(SUPPORT_CMCC)

static kal_uint8 sort_type = JPIM_PHB_NO_SORT;
static kal_uint8 storage = JPIM_PHB_STORAGE_BOTH;
static mmi_phb_handler_entry_struct entry;

#define JAVA_CMCC_PHB_SORT_BY_EMAIL 4
#define JAVA_CMCC_PHB_SORT_BY_NAME 5
#define JAVA_CMCC_PHB_SORT_BY_NOCHANGE 0


/*****************************************************************************
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 *****************************************************************************/
static mmi_phb_sort_type_enum convert_mmi_sort_type(kal_int32 n)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    switch (n)
    {
        case JAVA_CMCC_PHB_SORT_BY_EMAIL:       /* SORT_BY_EMAIL */
            return JPIM_PHB_SORT_BY_EMAIL;
        case JAVA_CMCC_PHB_SORT_BY_NAME:        /* SORT_BY_NAME */
            return JPIM_PHB_SORT_BY_NAME;
        case JAVA_CMCC_PHB_SORT_BY_NOCHANGE:    /* SORT_BY_NOCHANGE */
            return JPIM_PHB_SORT_BY_NAME;
        default:
            return JPIM_PHB_SORT_BY_NAME;
    }
}

#define JAVA_CMCC_PHB_DEVICE_ALL 1
#define JAVA_CMCC_PHB_DEVICE_PHONE 2
#define JAVA_CMCC_PHB_DEVICE_SIM 3


/*****************************************************************************
 * FUNCTION
 *  convert_mmi_storage
 * DESCRIPTION
 *
 * PARAMETERS
 *  n       [IN]
 * RETURNS
 *
 *****************************************************************************/
static MMI_PHB_STORAGE_LOCATION convert_mmi_storage(kal_int32 n)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    switch (n)
    {
        case JAVA_CMCC_PHB_DEVICE_PHONE:    /* DEVICE_PHONE */
            return JPIM_PHB_NVRAM;
        case JAVA_CMCC_PHB_DEVICE_SIM:      /* DEVICE_SIM */
            return JPIM_PHB_SIM;
        case JAVA_CMCC_PHB_DEVICE_ALL:      /* DEVICE_ALL */
            return JPIM_PHB_STORAGE_BOTH;
        default:
            return JPIM_PHB_STORAGE_BOTH;
    }
}


/*****************************************************************************
 * FUNCTION
 *  Java_com_cmcc_phonebook_PhoneBook_setOperateStyle
 * DESCRIPTION
 *
 * PARAMETERS
 *  void
 * RETURNS
 *
 *****************************************************************************/
KNIEXPORT KNI_RETURNTYPE_VOID Java_com_cmcc_phonebook_PhoneBook_setOperateStyle(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    sort_type = KNI_GetParameterAsInt(1);
    storage = KNI_GetParameterAsInt(2);

    storage = convert_mmi_storage(storage);
    sort_type = convert_mmi_sort_type(sort_type);

}


/*****************************************************************************
 * FUNCTION
 *  Java_com_cmcc_phonebook_PhoneBook_getCount
 * DESCRIPTION
 *
 * PARAMETERS
 *  void
 * RETURNS
 *
 *****************************************************************************/
KNIEXPORT KNI_RETURNTYPE_INT Java_com_cmcc_phonebook_PhoneBook_getCount(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    kal_int32 count;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    count = jpim_phb_getCount(storage, 0);
    KNI_ReturnInt((jint) count);
}


/*****************************************************************************
 * FUNCTION
 *  Java_com_cmcc_phonebook_PhoneBook_fetchByIndex
 * DESCRIPTION
 *
 * PARAMETERS
 *  void
 * RETURNS
 *
 *****************************************************************************/
KNIEXPORT KNI_RETURNTYPE_BOOLEAN Java_com_cmcc_phonebook_PhoneBook_fetchByIndex(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    kal_uint16 index;
    kal_int32 result;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    /* Java Layer index is 0~n-1, but Phonebook is 1~n */
    index = KNI_GetParameterAsInt(1) + 1;
    result = jpim_phb_fetchByIndex(&entry, (kal_uint16) index, sort_type, storage, 0);

    if (result == JPIM_SUCCESS)
    {
        KNI_ReturnInt((jint) 1);
    }
    else
    {
        KNI_ReturnInt((jint) 0);
    }

}


/*****************************************************************************
 * FUNCTION
 *  Java_com_cmcc_phonebook_PhoneBook_getCurrentName
 * DESCRIPTION
 *
 * PARAMETERS
 *  void
 * RETURNS
 *
 *****************************************************************************/
KNIEXPORT KNI_RETURNTYPE_OBJECT Java_com_cmcc_phonebook_PhoneBook_getCurrentName(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    KNI_StartHandles(1);
    KNI_DeclareHandle(str);
    KNI_NewString((const jchar*)entry.name, (jsize) app_ucs2_strlen((kal_int8*)entry.name), str);
    KNI_EndHandlesAndReturnObject(str);
}


/*****************************************************************************
 * FUNCTION
 *  Java_com_cmcc_phonebook_PhoneBook_getCurrentMobilePhone
 * DESCRIPTION
 *
 * PARAMETERS
 *  void
 * RETURNS
 *
 *****************************************************************************/
KNIEXPORT KNI_RETURNTYPE_OBJECT Java_com_cmcc_phonebook_PhoneBook_getCurrentMobilePhone(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    KNI_StartHandles(1);
    KNI_DeclareHandle(str);
    KNI_NewString((const jchar*)entry.number, (jsize) app_ucs2_strlen((kal_int8*)entry.number), str);
    KNI_EndHandlesAndReturnObject(str);
}

⌨️ 快捷键说明

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