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

📄 pim_list.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) 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:
* ---------
*
*
* Project:
* --------
*  MAUI
 *
* Description:
* ------------
*
*
* Author:
* -------
*   Eric Chen (mtk01254)
*
*============================================================================
*             HISTORY
* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*------------------------------------------------------------------------------
* $Log$
 *
 * 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 "j2me_custom_option.h"
#if defined(SUPPORT_JSR_75_PIM)
#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_trace.h"
#include "jpim_interface.h"

#include "pim.h"


extern kal_int32 contactFields[];
extern kal_int32 eventFields[];
extern kal_int32 todoFields[];
extern kal_int32 contactAttrs[];

static ICategory categories[NUM_CATEGORIES];
static kal_int8 nCategory = -1;
static kal_int32 ctdbh = -1;

#define THROW_FAILED_WITH_EXEC(__test_block__, listtype, __fail_block__)            \
{                                                                                   \
    kal_int32 result;                                                               \
    result = pim_tsfErrCode(listtype, __test_block__);                              \
    if(result != SUCCESS)                                                           \
    {                                                                               \
        PIM_THROW(result, NULL, pim_getDetailError());                              \
        {                                                                           \
            __fail_block__;                                                         \
        }                                                                           \
    }                                                                               \
}
#define THROW_FAILED_WITH_EXEC2(__test_block__, __fail_block__)    \
{                                                                  \
    kal_int32 result;                                              \
    result = __test_block__;                                       \
    if(result != SUCCESS)                                          \
    {                                                              \
        PIM_THROW(result, NULL, pim_getDetailError());             \
        {                                                          \
            __fail_block__;                                        \
        }                                                          \
    }                                                              \
}

#define CHECK_ATTR_RELOAD(listtype, dbhandle, __fail_block__) \
    THROW_FAILED_WITH_EXEC2(pim_checkAttrReload(listtype, dbhandle),__fail_block__);

#define CHECK_FIELD_RELOAD(listtype, dbhandle,__fail_block__)   \
    THROW_FAILED_WITH_EXEC2(pim_checkFieldReload(listtype, dbhandle),__fail_block__);

#define CHECK_FIELD_SUPPORT(listtype, dbhandle, field, __fail_block__)   \
    THROW_FAILED_WITH_EXEC2(pim_checkFieldValid(listtype, dbhandle, field),__fail_block__);


/*****************************************************************************
 * FUNCTION
 *  pim_initCategories
 * DESCRIPTION
 *  void
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
kal_int32 pim_initCategories(void)
{
    nCategory = ctdbh = -1;
    return 0;
}


#if 0
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
#endif
/*****************************************************************************
 * FUNCTION
 *  getItemByIndex
 * DESCRIPTION
 * PARAMETERS
 *  rechandle       [IN]
 *  listtype        [IN]
 *  patch           [IN]
 * RETURNS
 *****************************************************************************/
kal_int32 pim_getItemByIndex(kal_int32 listtype, kal_int32 dbhandle, kal_int32 rechandle, void **patch)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    kal_int32 returnCode;

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

    /* the same item with cache */
    switch( listtype)
    {
        case CONTACT_LIST:
            JPIM_DEBUG_1(TRACE_FUNC, FUNC_J2ME_PIM_GETITEMBYINDEX, CONTACT_LIST, pim_cntx.contact.store_index, pim_cntx.contact.sort_index, rechandle);
            if( pim_cntx.cdbh == dbhandle && getContactRecHandle(&pim_cntx.contact) == rechandle)
            {
                *patch = &pim_cntx.contact;
                pim_clearDetailError();
                return SUCCESS;
            }
            break;
        case EVENT_LIST:
            JPIM_DEBUG_1(TRACE_FUNC, FUNC_J2ME_PIM_GETITEMBYINDEX, EVENT_LIST, pim_cntx.event.handle, pim_cntx.event.index,rechandle);
            if( pim_cntx.edbh == dbhandle && getEventRecHandle(&pim_cntx.event) == rechandle)
            {
                *patch = &pim_cntx.event;
                pim_clearDetailError();
                return SUCCESS;
            }
            break;
    }


    /* not the same, need to get new item */
    switch (listtype)
    {
        case CONTACT_LIST:
            *patch = &pim_cntx.contact;
            returnCode = pim_tsfErrCode(CONTACT_LIST, getContact(dbhandle, rechandle, &pim_cntx.contact));
            if( returnCode == JPIM_SUCCESS)
            {
                pim_cntx.cdbh = dbhandle;
            }
            else
            {
                pim_cntx.cdbh = 0xFFFF;
                pim_cntx.contact.sort_index = 0xFF;
                pim_cntx.contact.store_index = 0xFF;
            }
            return returnCode;
            break;

        case EVENT_LIST:
            *patch = &pim_cntx.event;
            returnCode = pim_tsfErrCode(EVENT_LIST, getEvent(dbhandle, rechandle, &pim_cntx.event));
            if( returnCode == JPIM_SUCCESS)
            {
                pim_cntx.edbh = dbhandle;

            }
            else
            {
                pim_cntx.edbh = 0xFFFF;
                pim_cntx.event.index = 0xFF;
                pim_cntx.event.handle = 0xFF;
            }
            return returnCode;
            break;

        case TODO_LIST:
            pim_setDetailError(FEATURE_NOT_SUPPORTED);
            return PIM;
            break;
        default:
            pim_setDetailError(GENERAL_ERROR);
            return ILLARG;

    }
    return SUCCESS;
}


/*****************************************************************************
 * FUNCTION
 *  pim_getCategories
 * DESCRIPTION
 * PARAMETERS
 *  void
 * RETURNS
 *****************************************************************************/
kal_int32 pim_getCategories(kal_int32 dbhandle)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    kal_int32 result;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    JPIM_DEBUG_1(TRACE_FUNC, FUNC_J2ME_PIM_GETCATEGORIES, nCategory, ctdbh, dbhandle);

    if ( nCategory < 0 || ctdbh != dbhandle)
    {
        nCategory = getGroupCount(dbhandle);
        ctdbh = dbhandle;

        ASSERT( nCategory <= NUM_CATEGORIES );

        if( nCategory > 0 )
        {
            nCategory = NUM_CATEGORIES;
            ctdbh = dbhandle;

            result = pim_tsfErrCode(CONTACT_LIST, getGroupInfo(dbhandle, (kal_uint8*)&nCategory, categories));

            if (result != SUCCESS)
            {
                nCategory = ctdbh = -1;
                return result;
            }
        }
    }
    return SUCCESS;
}


/*****************************************************************************
 * FUNCTION
 *  getIndexOfCategory

⌨️ 快捷键说明

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