Fix contact sync. tizen_2.2 2.2.1_release submit/tizen_2.2/20131107.061408
authorKeebum Kim <keebum.kim@samsung.com>
Thu, 31 Oct 2013 09:28:44 +0000 (18:28 +0900)
committerKeebum Kim <keebum.kim@samsung.com>
Thu, 31 Oct 2013 09:32:08 +0000 (18:32 +0900)
include/utils/MsgUtilStorage.h
packaging/msg-service.spec
utils/MsgContact.cpp
utils/MsgUtilStorage.cpp

index 6a1c79e..de2b9d8 100755 (executable)
@@ -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);
index 959abc6..1404641 100755 (executable)
@@ -1,5 +1,5 @@
 Name:           msg-service
-Version:        0.9.10
+Version:        0.9.11
 Release:        1
 License:        Flora
 Summary:        Messaging Framework Library
index b614b7f..56518f5 100755 (executable)
@@ -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;
index 6a582fa..b4034aa 100755 (executable)
@@ -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; 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();