From: Keebum Kim Date: Thu, 31 Oct 2013 09:28:44 +0000 (+0900) Subject: Fix contact sync. X-Git-Tag: 2.2.1_release X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6a9c76332674a0ac4e176bf853af20bdef77e603;p=framework%2Fmessaging%2Fmsg-service.git Fix contact sync. --- diff --git a/include/utils/MsgUtilStorage.h b/include/utils/MsgUtilStorage.h index 6a1c79e..de2b9d8 100755 --- a/include/utils/MsgUtilStorage.h +++ b/include/utils/MsgUtilStorage.h @@ -50,7 +50,7 @@ bool MsgExistAddress(MsgDbHandler *pDbHandle, const MSG_MESSAGE_INFO_S *pMsg, ms int MsgStoGetUnreadCnt(MsgDbHandler *pDbHandle, MSG_MAIN_TYPE_T MsgType); msg_error_t MsgStoAddContactInfo(MsgDbHandler *pDbHandle, MSG_CONTACT_INFO_S *pContactInfo, const char *pNumber); -msg_error_t MsgStoClearContactInfo(MsgDbHandler *pDbHandle, int ContactId); +msg_error_t MsgStoResetContactInfo(MsgDbHandler *pDbHandle, int ContactId); msg_error_t MsgStoClearContactInfo(MsgDbHandler *pDbHandle, int ContactId, const char *pNumber); msg_error_t MsgStoGetMmsRawFilePath(MsgDbHandler *pDbHandle, msg_message_id_t msgId, char *pFilePath); bool MsgStoCheckReadReportRequested(MsgDbHandler *pDbHandle, msg_message_id_t MsgId); diff --git a/packaging/msg-service.spec b/packaging/msg-service.spec index 959abc6..1404641 100755 --- a/packaging/msg-service.spec +++ b/packaging/msg-service.spec @@ -1,5 +1,5 @@ Name: msg-service -Version: 0.9.10 +Version: 0.9.11 Release: 1 License: Flora Summary: Messaging Framework Library diff --git a/utils/MsgContact.cpp b/utils/MsgContact.cpp index b614b7f..56518f5 100755 --- a/utils/MsgContact.cpp +++ b/utils/MsgContact.cpp @@ -219,6 +219,9 @@ msg_error_t MsgGetContactInfo(const MSG_ADDRESS_INFO_S *pAddrInfo, MSG_CONTACT_I 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) { @@ -227,8 +230,6 @@ msg_error_t MsgGetContactInfo(const MSG_ADDRESS_INFO_S *pAddrInfo, MSG_CONTACT_I 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; } @@ -236,21 +237,15 @@ msg_error_t MsgGetContactInfo(const MSG_ADDRESS_INFO_S *pAddrInfo, MSG_CONTACT_I 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) { @@ -259,8 +254,6 @@ msg_error_t MsgGetContactInfo(const MSG_ADDRESS_INFO_S *pAddrInfo, MSG_CONTACT_I 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; } @@ -268,27 +261,19 @@ msg_error_t MsgGetContactInfo(const MSG_ADDRESS_INFO_S *pAddrInfo, MSG_CONTACT_I 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 @@ -535,7 +520,7 @@ bool MsgUpdateContact(int index, int type) 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); @@ -632,7 +617,7 @@ bool MsgUpdateContact(int index, int type) bool MsgDeleteContact(int index) { - if (MsgStoClearContactInfo(&ContactDbHandle, index) != MSG_SUCCESS) + if (MsgStoResetContactInfo(&ContactDbHandle, index) != MSG_SUCCESS) return false; return true; diff --git a/utils/MsgUtilStorage.cpp b/utils/MsgUtilStorage.cpp index 6a582fa..b4034aa 100755 --- a/utils/MsgUtilStorage.cpp +++ b/utils/MsgUtilStorage.cpp @@ -1014,16 +1014,17 @@ msg_error_t MsgStoAddContactInfo(MsgDbHandler *pDbHandle, MSG_CONTACT_INFO_S *pC } -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); @@ -1034,20 +1035,21 @@ msg_error_t MsgStoClearContactInfo(MsgDbHandler *pDbHandle, int contactId) 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; iexecQuery(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();