📄 jpim_phonebook.c
字号:
#ifdef JSR_75_PIM_EXTRA_INFO
if (field == JPIM_C_ADDR)
{
switch(index)
{
case JPIM_C_ADDR_POBOX:
return (kal_wchar*)GetString(STR_ID_PHB_ADR_POBOX);
case JPIM_C_ADDR_EXTRA:
return (kal_wchar*)GetString(STR_ID_PHB_ADR_EXTENSION);
case JPIM_C_ADDR_STREET:
return (kal_wchar*)GetString(STR_ID_PHB_ADR_STREET);
case JPIM_C_ADDR_LOCALITY:
return (kal_wchar*)GetString(STR_ID_PHB_ADR_CITY);
case JPIM_C_ADDR_REGION:
return (kal_wchar*)GetString(STR_ID_PHB_ADR_STATE);
case JPIM_C_ADDR_POSTALCODE:
return (kal_wchar*)GetString(STR_ID_PHB_ADR_POSTALCODE);
case JPIM_C_ADDR_COUNTRY:
return (kal_wchar*)GetString(STR_ID_PHB_ADR_COUNTRY);
}
}
#endif
return NULL;
}
/*****************************************************************************
* FUNCTION
* jpim_phb_getAttrLabel
* DESCRIPTION
*
* PARAMETERS
* attr [IN]
* RETURNS
*
*****************************************************************************/
kal_wchar *jpim_phb_getAttrLabel(kal_int32 attr)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
JPIM_DEBUG_1(TRACE_GROUP_2, JPIM_PHB_GETATTRLABEL, attr);
switch (attr)
{
case JPIM_C_ATTR_FAX:
return L"Fax";
case JPIM_C_ATTR_HOME:
return L"Home";
case JPIM_C_ATTR_MOBILE:
return L"Mobile";
case JPIM_C_ATTR_WORK:
return L"Work";
case JPIM_C_ATTR_PREFERRED:
return L"Preferdered";
default:
return NULL;
}
}
/*****************************************************************************
* FUNCTION
* jpim_phb_getCount
* DESCRIPTION
*
* PARAMETERS
* storage [IN]
* group [IN]
* sort_type(?) [IN]
* RETURNS
*
*****************************************************************************/
kal_int32 jpim_phb_getCount(kal_uint8 storage, kal_uint8 group)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
kal_uint32 event_group;
mmi_phb_handler_get_entry_req_struct *p =
(mmi_phb_handler_get_entry_req_struct*) construct_local_para(
sizeof(mmi_phb_handler_get_entry_req_struct),
TD_CTRL);
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
JPIM_DEBUG(TRACE_GROUP_2, JPIM_PHB_GETCOUNT);
p->count = 0;
p->entry_ptr = NULL;
p->index = 1;
p->sort_type = MMI_PHB_NO_SORT;
p->storage = jpim_transfer_phb_storage(storage);
p->group = group;
/* set cmccphk_state before send message!! */
jpim_phb_state = JPIM_PHB_STATE_GET_COUNT;
jpim_phb_result = MMI_PHB_JAVA_ERROR;
jpim_phb_count = -1;
if (jpim_check_vm_state(0))
{
jpim_send_ilm(p, MSG_ID_MMI_PHB_JAVA_GET_ENTRY_REQ);
kal_retrieve_eg_events(J2ME_pim_event_group, JPIM_PHB_EG_GETCOUNT, KAL_OR_CONSUME, &event_group, KAL_SUSPEND);
}
if (jpim_phb_result != MMI_PHB_JAVA_SUCCESS)
{
return -1;
}
else
{
return jpim_phb_count;
}
}
/*****************************************************************************
* FUNCTION
* jpim_phb_fetchByIndex
* DESCRIPTION
*
* PARAMETERS
* entry [?] [?]
* index [IN]
* sort_type [IN]
* storage [IN]
* group [IN]
* RETURNS
*
*****************************************************************************/
kal_int32 jpim_phb_fetchByIndex(
mmi_phb_handler_entry_struct *entry,
kal_uint16 index,
kal_uint8 sort_type,
kal_uint8 storage,
kal_uint8 group)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
kal_uint32 event_group;
mmi_phb_handler_get_entry_req_struct *p =
(mmi_phb_handler_get_entry_req_struct*) construct_local_para(
sizeof(mmi_phb_handler_get_entry_req_struct),
TD_CTRL);
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
p->count = 1;
p->entry_ptr = entry;
p->index = index;
p->sort_type = jpim_transfer_phb_sort(sort_type);
p->storage = jpim_transfer_phb_storage(storage);
p->group = group;
jpim_phb_result = MMI_PHB_JAVA_ERROR;
jpim_phb_state = JPIM_PHB_STATE_GET_ENTRY;
if (jpim_check_vm_state(0))
{
jpim_send_ilm(p, MSG_ID_MMI_PHB_JAVA_GET_ENTRY_REQ);
kal_retrieve_eg_events(J2ME_pim_event_group, JPIM_PHB_EG_FETCH_INDEX, KAL_OR_CONSUME, &event_group, KAL_SUSPEND);
JPIM_DEBUG(TRACE_GROUP_2, JPIM_PHB_FETCHBYINDEX, entry->store_index, entry->sort_index);
}
else
{
free_local_para((local_para_struct*) p);
}
return jpim_transfer_error_code(JPIM_PHONEBOOK, jpim_phb_result);
}
/*****************************************************************************
* FUNCTION
* jpim_phb_appendEntry
* DESCRIPTION
* This function adds a new entry into the event database.
* If the entry is successfully added to the database, the index and entry
* handle fields are assigned values.
* The application must assign a value to at least "Name" or "Number"
* to add a new entry.
* PARAMETERS
* entry [IN/OUT] The correct values are assigned to the index and handle.
* sort_type [IN] jpim_phb_sort_type_enum
* storage [IN] jpim_phb_storage_enum
* RETURNS
* jpim_error_code_enum
*****************************************************************************/
kal_int32 jpim_phb_appendEntry(mmi_phb_handler_entry_struct *entry, kal_uint8 storage)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
kal_uint32 event_group;
mmi_phb_handler_set_entry_req_struct *p =
(mmi_phb_handler_set_entry_req_struct*) construct_local_para(
sizeof(mmi_phb_handler_set_entry_req_struct),
TD_CTRL);
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
JPIM_DEBUG(TRACE_GROUP_2, JPIM_PHB_APPENDENTRY);
p->entry_ptr = entry;
p->index = 0xffff;
p->storage = jpim_transfer_phb_storage(storage);
jpim_phb_result = MMI_PHB_JAVA_ERROR;
jpim_phb_state = JPIM_PHB_STATE_APPEND_ENTRY;
jpim_phb_index = 0xffff;
jpim_phb_handle = 0xffff;
if (jpim_check_vm_state(1))
{
jpim_send_ilm(p, MSG_ID_MMI_PHB_JAVA_SET_ENTRY_REQ);
kal_retrieve_eg_events(J2ME_pim_event_group, JPIM_PHB_EG_APPEND_ENTRY, KAL_OR_CONSUME, &event_group, KAL_SUSPEND);
entry->sort_index = jpim_phb_index;
entry->store_index = jpim_phb_handle;
}
else
{
free_local_para((local_para_struct*) p);
}
return jpim_transfer_error_code(JPIM_PHONEBOOK, jpim_phb_result);
}
/*****************************************************************************
* FUNCTION
* jpim_phb_upddateEntry
* DESCRIPTION
* This function updates an entry in the phonebook database.
* The index (physical storage index) must refer to a valid entry in the
* database, otherwise an "invalid index" error is returned.
* If the sort index changes after the update, a new sort index is assigned.
* PARAMETERS
* entry [IN/OUT] The correct values are assigned to the index and handle.
* sort_type [IN] jpim_phb_sort_type_enum
* storage [IN] jpim_phb_storage_enum
* index [IN]
* RETURNS
* jpim_error_code_enum
*****************************************************************************/
kal_int32 jpim_phb_upddateEntry(mmi_phb_handler_entry_struct *entry)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
kal_uint32 event_group;
mmi_phb_handler_set_entry_req_struct *p =
(mmi_phb_handler_set_entry_req_struct*) construct_local_para(
sizeof(mmi_phb_handler_set_entry_req_struct),
TD_CTRL);
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
JPIM_DEBUG(TRACE_GROUP_2, JPIM_PHB_UPDDATEENTRY);
p->entry_ptr = entry;
p->index = entry->store_index;
p->storage = MMI_STORAGE_BOTH;
jpim_phb_result = MMI_PHB_JAVA_ERROR;
jpim_phb_state = JPIM_PHB_STATE_UPDATE_ENTRY;
jpim_phb_index = 0xffff;
jpim_phb_handle = 0xffff;
if (jpim_check_vm_state(1))
{
jpim_send_ilm(p, MSG_ID_MMI_PHB_JAVA_SET_ENTRY_REQ);
kal_retrieve_eg_events(J2ME_pim_event_group, JPIM_PHB_EG_UPDATE_ENTRY, KAL_OR_CONSUME, &event_group, KAL_SUSPEND);
entry->sort_index = jpim_phb_index;
entry->store_index = jpim_phb_handle;
}
else
{
free_local_para((local_para_struct*) p);
}
return jpim_transfer_error_code(JPIM_PHONEBOOK, jpim_phb_result);
}
/*****************************************************************************
* FUNCTION
* jpim_phb_deleteEntry
* DESCRIPTION
* This function deletes an entry from the phonebook database.
* PARAMETERS
* handle [IN]
* RETURNS
* jpim_error_code_enum
*****************************************************************************/
kal_int32 jpim_phb_deleteEntry(kal_uint16 handle)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
kal_uint32 event_group;
mmi_phb_handler_set_entry_req_struct *p =
(mmi_phb_handler_set_entry_req_struct*) construct_local_para(
sizeof(mmi_phb_handler_set_entry_req_struct),
TD_CTRL);
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
JPIM_DEBUG(TRACE_GROUP_2, JPIM_PHB_DELETEENTRY);
p->entry_ptr = NULL;
p->index = handle;
p->storage = MMI_STORAGE_BOTH;
jpim_phb_result = MMI_PHB_JAVA_ERROR;
jpim_phb_state = JPIM_PHB_STATE_DELETE_ENTRY;
if (jpim_check_vm_state(1))
{
jpim_send_ilm(p, MSG_ID_MMI_PHB_JAVA_SET_ENTRY_REQ);
kal_retrieve_eg_events(J2ME_pim_event_group, JPIM_PHB_EG_DELETE_ENTRY, KAL_OR_CONSUME, &event_group, KAL_SUSPEND);
}
else
{
free_local_para((local_para_struct*) p);
}
return jpim_transfer_error_code(JPIM_PHONEBOOK, jpim_phb_result);
}
/*****************************************************************************
* FUNCTION
* jpim_phb_searchEntry
* DESCRIPTION
* This function searches for a specific pattern in the phonebook database.
* If the search type is by number, the entry with the smallest distance to
* the pattern (best match) is returned. If the search type is "Name" or
* "E-mail", only the prefix-matched items are listed.
* Therefore, possibly nothing is returned if searching by "Name"
* or "Email". Furthermore, the sort index in entry sorting is assigned by
* the sort_type.
* PARAMETERS
* entry [IN/OUT]
* sort_type [IN] jpim_phb_sort_type_enum
* storage [IN] jpim_phb_storage_enum
* search_type [IN] jpim_phb_sort_type_enum
* group [IN]
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -