return MSG_SUCCESS;
}
+ contacts_query_destroy(query);
+ contacts_filter_destroy(filter);
+
contacts_record_h contact = NULL;
if (pAddrInfo->addressType == MSG_ADDRESS_TYPE_PLMN || pAddrInfo->addressType == MSG_ADDRESS_TYPE_UNKNOWN) {
ret = contacts_list_get_current_record_p(contacts, &number);
if (ret != CONTACTS_ERROR_NONE) {
MSG_DEBUG("contacts_list_get_current_record_p() Error [%d]", ret);
- contacts_query_destroy(query);
- contacts_filter_destroy(filter);
contacts_list_destroy(contacts, true);
return MSG_SUCCESS;
}
ret = contacts_record_get_int(number, _contacts_contact_number.contact_id, &index);
if (ret != CONTACTS_ERROR_NONE) {
MSG_DEBUG("contacts_record_get_int() Error [%d]", ret);
- contacts_query_destroy(query);
- contacts_filter_destroy(filter);
contacts_list_destroy(contacts, true);
- contacts_record_destroy(number, true);
return MSG_SUCCESS;
}
ret = contacts_db_get_record(_contacts_contact._uri, index, &contact);
if (ret != CONTACTS_ERROR_NONE) {
MSG_DEBUG("contacts_db_get_record() Error [%d]", ret);
- contacts_query_destroy(query);
- contacts_filter_destroy(filter);
contacts_list_destroy(contacts, true);
contacts_record_destroy(contact, true);
- contacts_record_destroy(number, true);
return MSG_SUCCESS;
}
} else if (pAddrInfo->addressType == MSG_ADDRESS_TYPE_EMAIL) {
ret = contacts_list_get_current_record_p(contacts, &email);
if (ret != CONTACTS_ERROR_NONE) {
MSG_DEBUG("contacts_list_get_current_record_p() Error [%d]", ret);
- contacts_query_destroy(query);
- contacts_filter_destroy(filter);
contacts_list_destroy(contacts, true);
return MSG_SUCCESS;
}
ret = contacts_record_get_int(email, _contacts_contact_email.contact_id, &index);
if (ret != CONTACTS_ERROR_NONE) {
MSG_DEBUG("contacts_record_get_int() Error [%d]", ret);
- contacts_query_destroy(query);
- contacts_filter_destroy(filter);
contacts_list_destroy(contacts, true);
- contacts_record_destroy(email, true);
return MSG_SUCCESS;
}
ret = contacts_db_get_record(_contacts_contact._uri, index, &contact);
if (ret != CONTACTS_ERROR_NONE) {
MSG_DEBUG("contacts_db_get_record() Error [%d]", ret);
- contacts_query_destroy(query);
- contacts_filter_destroy(filter);
contacts_list_destroy(contacts, true);
contacts_record_destroy(contact, true);
- contacts_record_destroy(email, true);
return MSG_SUCCESS;
}
}
- contacts_query_destroy(query);
- contacts_filter_destroy(filter);
contacts_list_destroy(contacts, true);
// Name Info
MSG_DEBUG("displayName : [%s]", contactInfo.displayName);
}
- MsgStoClearContactInfo(&ContactDbHandle, index);
+ MsgStoResetContactInfo(&ContactDbHandle, index);
unsigned int count = 0;
ret = contacts_record_get_child_record_count(contact, _contacts_contact.number, &count);
bool MsgDeleteContact(int index)
{
- if (MsgStoClearContactInfo(&ContactDbHandle, index) != MSG_SUCCESS)
+ if (MsgStoResetContactInfo(&ContactDbHandle, index) != MSG_SUCCESS)
return false;
return true;
}
-msg_error_t MsgStoClearContactInfo(MsgDbHandler *pDbHandle, int contactId)
+msg_error_t MsgStoResetContactInfo(MsgDbHandler *pDbHandle, int contactId)
{
msg_error_t err = MSG_SUCCESS;
char sqlQuery[MAX_QUERY_LEN+1];
int rowCnt = 0;
+ int index = 2;
memset(sqlQuery, 0x00, sizeof(sqlQuery));
- snprintf(sqlQuery, sizeof(sqlQuery), "SELECT DISTINCT(CONV_ID) FROM %s WHERE CONTACT_ID = %d;",
+ snprintf(sqlQuery, sizeof(sqlQuery), "SELECT ADDRESS_VAL, CONV_ID FROM %s WHERE CONTACT_ID = %d;",
MSGFW_ADDRESS_TABLE_NAME, contactId);
err = pDbHandle->getTable(sqlQuery, &rowCnt);
return err;
}
- memset(sqlQuery, 0x00, sizeof(sqlQuery));
- snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET \
- CONTACT_ID = 0, DISPLAY_NAME = '', FIRST_NAME = '', LAST_NAME = '', IMAGE_PATH = '' \
- WHERE CONTACT_ID = %d;",
- MSGFW_ADDRESS_TABLE_NAME, contactId);
+ MsgDbHandler tmpDbHandle;
+ for (int i=0; i<rowCnt; i++) {
- if (pDbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
- MSG_DEBUG("Fail to execute query");
- return MSG_ERR_DB_EXEC;
- }
+ MSG_CONTACT_INFO_S contactInfo;
+ memset(&contactInfo, 0x00, sizeof(MSG_CONTACT_INFO_S));
+ MSG_ADDRESS_INFO_S addrInfo;
+ memset(&addrInfo, 0x00, sizeof(MSG_ADDRESS_INFO_S));
- MsgDbHandler tmpDbHandle;
- for (int i=1; i<=rowCnt; i++)
- MsgStoSetConversationDisplayName(&tmpDbHandle, (msg_thread_id_t)pDbHandle->getColumnToInt(i));
+ pDbHandle->getColumnToString(index++, MAX_ADDRESS_VAL_LEN, addrInfo.addressVal);
+
+ MsgGetContactInfo(&addrInfo, &contactInfo);
+ MsgStoAddContactInfo(&tmpDbHandle, &contactInfo, addrInfo.addressVal);
+
+ MsgStoSetConversationDisplayName(&tmpDbHandle, (msg_thread_id_t)pDbHandle->getColumnToInt(index++));
+ }
pDbHandle->freeTable();