📄 pim_main.c
字号:
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
_detail_error_code = GENERAL_ERROR;
return old;
}
/*****************************************************************************
* FUNCTION
* pim_clearDetailError
* DESCRIPTION
*
* PARAMETERS
* void
* RETURNS
*
*****************************************************************************/
void pim_clearDetailError(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
_detail_error_code = GENERAL_ERROR;
}
/*****************************************************************************
* FUNCTION
* pim_checkFieldValid
* DESCRIPTION
*
* PARAMETERS
* field [IN]
* listtype [IN]
* RETURNS
*
*****************************************************************************/
kal_int32 pim_checkAttrReload(kal_int32 listtype, kal_int32 dbhandle)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
pim_clearDetailError();
if(listtype == CONTACT_LIST)
{
return pim_getContactAttr(dbhandle, 0);
}
else if(listtype == EVENT_LIST)
{
return SUCCESS;
}
else if(listtype == TODO_LIST)
{
pim_setDetailError(FEATURE_NOT_SUPPORTED);
return PIM;
}
else
{
return ILLARG;
}
return ILLARG;
}
/*****************************************************************************
* FUNCTION
* pim_checkFieldValid
* DESCRIPTION
*
* PARAMETERS
* field [IN]
* listtype [IN]
* RETURNS
*
*****************************************************************************/
kal_int32 pim_checkFieldReload(kal_int32 listtype, kal_int32 dbhandle)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
pim_clearDetailError();
if(listtype == CONTACT_LIST)
{
return pim_getContactField(dbhandle);
}
else if(listtype == EVENT_LIST)
{
return pim_getEventField(dbhandle);
}
else if(listtype == TODO_LIST)
{
pim_setDetailError(FEATURE_NOT_SUPPORTED);
return PIM;
}
else
{
return ILLARG;
}
return ILLARG;
}
/*****************************************************************************
* FUNCTION
* pim_checkFieldValid
* DESCRIPTION
*
* PARAMETERS
* field [IN]
* listtype [IN]
* RETURNS
*
*****************************************************************************/
kal_int32 pim_checkFieldValid(kal_int32 listtype, kal_int32 dbhandle, kal_int32 field)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
kal_int32 i;
kal_int32 result;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
pim_clearDetailError();
if(listtype == CONTACT_LIST)
{
result = pim_getContactField(dbhandle);
if( result != SUCCESS )
{
return result;
}
for(i = NUM_CONTACT_FIELDS - 1 ;i >= 0 ; i--)
{
if( field == contactFields[i] )
{
return SUPPORT;
}
}
return UNSUPPFIELD;
}
else if(listtype == EVENT_LIST)
{
result = pim_getEventField(dbhandle);
if( result != SUCCESS )
{
return result;
}
for(i = NUM_EVENT_FIELDS -1 ;i >= 0 ; i--)
{
if( field == eventFields[i] )
{
return SUPPORT;
}
}
return UNSUPPFIELD;
}
else if(listtype == TODO_LIST)
{
pim_setDetailError(FEATURE_NOT_SUPPORTED);
return PIM;
}
else
{
return ILLARG;
}
return ILLARG;
}
/*****************************************************************************
* FUNCTION
* pim_tsfErrCode
* DESCRIPTION
*
* PARAMETERS
* listtype [IN]
* error [IN]
* RETURNS
*
*****************************************************************************/
kal_int32 pim_tsfErrCode(kal_int32 listtype, kal_int32 error)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if(error != JPIM_SUCCESS)
{
JPIM_DEBUG_1(TRACE_FUNC, FUNC_J2ME_PIM_TSFERRCODE, listtype , error);
}
switch (error)
{
case JPIM_SUCCESS:
pim_clearDetailError();
return SUCCESS;
case JPIM_NOT_SUPPORT:
pim_setDetailError(FEATURE_NOT_SUPPORTED);
return PIM;
case JPIM_NOT_FOUND:
pim_setDetailError(GENERAL_ERROR);
return PIM;
case JPIM_OUT_OF_INDEX:
case JPIM_INVALID_HANDLE:
case JPIM_INVALID_DATE:
case JPIM_INVALID_START_TIME:
case JPIM_INVALID_END_TIME:
case JPIM_INVALID_NOTES:
case JPIM_EXPIRED_ALARM:
case JPIM_INVALID_ALARM:
case JPIM_INVALID_REPEAT:
pim_setDetailError(GENERAL_ERROR);
return ILLARG;
default:
pim_setDetailError(GENERAL_ERROR);
return PIM;
}
return PIM;
}
/*****************************************************************************
* FUNCTION
* pim_tsfFieldCode
* DESCRIPTION
*
* PARAMETERS
* listtype [IN]
* error [IN]
* RETURNS
*
*****************************************************************************/
kal_int32 pim_tsfFieldCode(kal_int32 type, kal_int32 field)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if(type == CONTACT_LIST)
{
switch(field)
{
case JPIM_C_ADDR : return C_ADDR ;
case JPIM_C_BIRTHDAY : return C_BIRTHDAY ;
case JPIM_C_CLASS : return C_CLASS ;
case JPIM_C_EMAIL : return C_EMAIL ;
case JPIM_C_FORMATTED_ADDR : return C_FORMATTED_ADDR ;
case JPIM_C_FORMATTED_NAME : return C_FORMATTED_NAME ;
case JPIM_C_NAME : return C_NAME ;
case JPIM_C_NICKNAME : return C_NICKNAME ;
case JPIM_C_NOTE : return C_NOTE ;
case JPIM_C_ORG : return C_ORG ;
case JPIM_C_PHOTO : return C_PHOTO ;
case JPIM_C_PHOTO_URL : return C_PHOTO_URL ;
case JPIM_C_PUBLIC_KEY : return C_PUBLIC_KEY ;
case JPIM_C_PUBLIC_KEY_STRING : return C_PUBLIC_KEY_STRING ;
case JPIM_C_REVISION : return C_REVISION ;
case JPIM_C_TEL : return C_TEL ;
case JPIM_C_TITLE : return C_TITLE ;
case JPIM_C_UID : return C_UID ;
case JPIM_C_URL : return C_URL ;
default :
return -1;
}
}
else if(type == EVENT_LIST)
{
switch(field)
{
case JPIM_E_ALARM : return E_ALARM ;
case JPIM_E_CLASS : return E_CLASS ;
case JPIM_E_END : return E_END ;
case JPIM_E_LOCATION : return E_LOCATION ;
case JPIM_E_NOTE : return E_NOTE ;
case JPIM_E_REVISION : return E_REVISION ;
case JPIM_E_START : return E_START ;
case JPIM_E_SUMMARY : return E_SUMMARY ;
case JPIM_E_UID : return E_UID ;
default:
return -1;
}
}
else if(type == TODO_LIST)
{
switch(field)
{
case JPIM_E_CLASS : return TO_CLASS ;
case JPIM_E_END : return TO_COMPLETION_DATE ;
case JPIM_E_NOTE : return TO_NOTE ;
case JPIM_E_REVISION : return TO_REVISION ;
case JPIM_E_START : return TO_DUE ;
case JPIM_E_SUMMARY : return TO_SUMMARY ;
case JPIM_E_UID : return TO_UID ;
case JPIM_E_PRIORITY : return TO_PRIORITY ;
default:
return -1;
}
}
else if(type == CONTACT_ATTR)
{
switch(field)
{
case JPIM_C_ATTR_ASST : return C_ATTR_ASST ;
case JPIM_C_ATTR_AUTO : return C_ATTR_AUTO ;
case JPIM_C_ATTR_FAX : return C_ATTR_FAX ;
case JPIM_C_ATTR_HOME : return C_ATTR_HOME ;
case JPIM_C_ATTR_MOBILE : return C_ATTR_MOBILE ;
case JPIM_C_ATTR_OTHER : return C_ATTR_OTHER ;
case JPIM_C_ATTR_PAGER : return C_ATTR_PAGER ;
case JPIM_C_ATTR_PREFERRED : return C_ATTR_PREFERRED;
case JPIM_C_ATTR_SMS : return C_ATTR_SMS ;
case JPIM_C_ATTR_WORK : return C_ATTR_WORK ;
default:
return -1;
}
}
else if(type == VCAL_REPEAT)
{
switch(field)
{
case JPIM_R_FREQUENCY : return R_FREQUENCY ;
case JPIM_R_DAY_IN_MONTH : return R_DAY_IN_MONTH ;
case JPIM_R_DAY_IN_WEEK : return R_DAY_IN_WEEK ;
case JPIM_R_DAY_IN_YEAR : return R_DAY_IN_YEAR ;
case JPIM_R_MONTH_IN_YEAR : return R_MONTH_IN_YEAR ;
case JPIM_R_WEEK_IN_MONTH : return R_WEEK_IN_MONTH ;
case JPIM_R_COUNT : return R_COUNT ;
case JPIM_R_END : return R_END ;
case JPIM_R_INTERVAL : return R_INTERVAL ;
default:
return -1;
}
}
ASSERT(0);
return -1;
}
/*****************************************************************************
* FUNCTION
* pim_throw
* DESCRIPTION
*
* PARAMETERS
* exceptionID [IN]
* message [?]
* detail [IN]
* RETURNS
* void
*****************************************************************************/
void pim_throw(kal_int32 exceptionID, kal_char *message, kal_int32 detail, kal_char *f, kal_uint32 line)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
kal_int32 len = strlen(f);
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
JPIM_DEBUG_2(TRACE_FUNC, FUNC_J2ME_PIM_THROW, exceptionID, detail);
JPIM_DEBUG_2(TRACE_FUNC, JPIM_LOG_THROW, f[len-9], f[len-8], f[len-7], f[len-6], f[len-5], f[len-4], f[len-3], line);
switch (exceptionID)
{
case PIM:
KNI_ThrowNew("javax/microedition/pim/PIMException", message);
break;
case FIELDFULL:
KNI_ThrowNew("javax/microedition/pim/FieldFullException", message);
break;
case ILLARG:
KNI_ThrowNew("java/lang/IllegalArgumentException", message);
break;
case UNSUPPFIELD:
KNI_ThrowNew("javax/microedition/pim/UnsupportedFieldException", message);
break;
case SECURITY:
KNI_ThrowNew("java/lang/SecurityException", message);
break;
case NULLP:
KNI_ThrowNew("java/lang/NullPointerException", message);
break;
case RUNTIME:
KNI_ThrowNew("java/lang/RuntimeException", message);
break;
default:
KNI_ThrowNew("java/lang/Exception", message);
}
}
/*****************************************************************************
* FUNCTION
* pim_initContact
* DESCRIPTION
* initial context of pim
* PARAMETERS
* void
* RETURNS
*****************************************************************************/
static kal_int32 pim_initContact(kal_int32 dbhandle)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
pim_cntx.contact.sort_index = 0xFF;
pim_cntx.contact.store_index = 0xFF;
pim_cntx.cdbh = dbhandle;
cdbh = nContact = -1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -