From 05642f11c3f4965f211b77da2500cac56b98be0b Mon Sep 17 00:00:00 2001 From: Keebum Kim Date: Tue, 8 Oct 2013 14:23:10 +0900 Subject: [PATCH] Fix contact sync related. --- include/common/MsgStorageTypes.h | 1 + utils/MsgContact.cpp | 22 +++++++++++++++++++++- utils/MsgUtilStorage.cpp | 23 ++++++++++++++--------- 3 files changed, 36 insertions(+), 10 deletions(-) diff --git a/include/common/MsgStorageTypes.h b/include/common/MsgStorageTypes.h index e1ddc60..bc0cd25 100755 --- a/include/common/MsgStorageTypes.h +++ b/include/common/MsgStorageTypes.h @@ -93,6 +93,7 @@ typedef struct msg_contact_id_t contactId; /**< Indicates the unique contact ID. */ char firstName[MAX_DISPLAY_NAME_LEN+1]; /**< Indicates the first name of contact. */ char lastName[MAX_DISPLAY_NAME_LEN+1]; /**< Indicates the last name of contact. */ + char displayName[MAX_DISPLAY_NAME_LEN+1]; /**< Indicates the display name of contact. */ char imagePath[MAX_IMAGE_PATH_LEN+1]; /**< Indicates the image path of contact. */ } MSG_CONTACT_INFO_S; diff --git a/utils/MsgContact.cpp b/utils/MsgContact.cpp index 0c2399e..80cd6d3 100755 --- a/utils/MsgContact.cpp +++ b/utils/MsgContact.cpp @@ -271,14 +271,24 @@ msg_error_t MsgGetContactInfo(const MSG_ADDRESS_INFO_S *pAddrInfo, MSG_CONTACT_I MSG_DEBUG("contacts_record_get_str_p() Error [%d]", ret); } + char* strDisplayName = NULL; + ret = contacts_record_get_str_p(contact, _contacts_contact.display_name, &strDisplayName); + if (ret != CONTACTS_ERROR_NONE) { + MSG_DEBUG("contacts_record_get_str_p() Error [%d]", ret); + } + if (strFirstName != NULL) strncpy(pContactInfo->firstName, strFirstName, MAX_DISPLAY_NAME_LEN); if (strLastName != NULL) strncpy(pContactInfo->lastName, strLastName, MAX_DISPLAY_NAME_LEN); + + if (strDisplayName != NULL) + strncpy(pContactInfo->displayName, strDisplayName, MAX_DISPLAY_NAME_LEN); } MSG_DEBUG("pContactInfo->firstName : [%s], pContactInfo->lastName : [%s]", pContactInfo->firstName, pContactInfo->lastName); + MSG_DEBUG("pContactInfo->displayName : [%s]", pContactInfo->displayName); ret = contacts_record_get_int(contact, _contacts_contact.id, (int*)&pContactInfo->contactId); if (ret != CONTACTS_ERROR_NONE) { @@ -466,13 +476,23 @@ bool MsgUpdateContact(int index, int type) MSG_DEBUG("contacts_record_get_str_p() Error [%d]", ret); } - MSG_DEBUG("First Name : [%s], Last Name : [%s]", strFirstName, strLastName); + char* strDisplayName = NULL; + ret = contacts_record_get_str_p(contact, _contacts_contact.display_name, &strDisplayName); + if (ret != CONTACTS_ERROR_NONE) { + MSG_DEBUG("contacts_record_get_str_p() Error [%d]", ret); + } if (strFirstName != NULL) strncpy(contactInfo.firstName, strFirstName, MAX_DISPLAY_NAME_LEN); if (strLastName != NULL) strncpy(contactInfo.lastName, strLastName, MAX_DISPLAY_NAME_LEN); + + if (strDisplayName != NULL) + strncpy(contactInfo.displayName, strDisplayName, MAX_DISPLAY_NAME_LEN); + + MSG_DEBUG("First Name : [%s], Last Name : [%s]", contactInfo.firstName, contactInfo.lastName); + MSG_DEBUG("displayName : [%s]", contactInfo.displayName); } MsgStoClearContactInfo(&ContactDbHandle, index); diff --git a/utils/MsgUtilStorage.cpp b/utils/MsgUtilStorage.cpp index 2de1578..88e457e 100755 --- a/utils/MsgUtilStorage.cpp +++ b/utils/MsgUtilStorage.cpp @@ -374,7 +374,7 @@ msg_error_t MsgStoAddAddress(MsgDbHandler *pDbHandle, const MSG_MESSAGE_INFO_S * // Add Address memset(sqlQuery, 0x00, sizeof(sqlQuery)); - snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, %d, %d, %d, '%s', %d, '', ?, ?, '%s', 0);", + snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, %d, %d, %d, '%s', %d, ?, ?, ?, '%s', 0);", MSGFW_ADDRESS_TABLE_NAME, addrId, *pConvId, pMsg->addressList[i].addressType, pMsg->addressList[i].recipientType, pMsg->addressList[i].addressVal, contactInfo.contactId, contactInfo.imagePath); @@ -383,8 +383,9 @@ msg_error_t MsgStoAddAddress(MsgDbHandler *pDbHandle, const MSG_MESSAGE_INFO_S * if (pDbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) return MSG_ERR_DB_PREPARE; - pDbHandle->bindText(contactInfo.firstName, 1); - pDbHandle->bindText(contactInfo.lastName, 2); + pDbHandle->bindText(contactInfo.displayName, 1); + pDbHandle->bindText(contactInfo.firstName, 2); + pDbHandle->bindText(contactInfo.lastName, 3); if (pDbHandle->stepQuery() != MSG_ERR_DB_DONE) { pDbHandle->finalizeQuery(); @@ -981,9 +982,13 @@ msg_error_t MsgStoAddContactInfo(MsgDbHandler *pDbHandle, MSG_CONTACT_INFO_S *pC char sqlQuery[MAX_QUERY_LEN+1]; memset(sqlQuery, 0x00, sizeof(sqlQuery)); - snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET \ - CONTACT_ID = %d, FIRST_NAME = ?, LAST_NAME = ?, IMAGE_PATH = '%s' \ - WHERE ADDRESS_VAL = '%s';", + snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET " + "CONTACT_ID = %d, " + "DISPLAY_NAME = ?, " + "FIRST_NAME = ?, " + "LAST_NAME = ?, " + "IMAGE_PATH = '%s' " + "WHERE ADDRESS_VAL = '%s';", MSGFW_ADDRESS_TABLE_NAME, pContactInfo->contactId, pContactInfo->imagePath, pNumber); if (pDbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) { @@ -991,9 +996,9 @@ msg_error_t MsgStoAddContactInfo(MsgDbHandler *pDbHandle, MSG_CONTACT_INFO_S *pC return MSG_ERR_DB_PREPARE; } - pDbHandle->bindText(pContactInfo->firstName, 1); - - pDbHandle->bindText(pContactInfo->lastName, 2); + pDbHandle->bindText(pContactInfo->displayName, 1); + pDbHandle->bindText(pContactInfo->firstName, 2); + pDbHandle->bindText(pContactInfo->lastName, 3); if (pDbHandle->stepQuery() != MSG_ERR_DB_DONE) { pDbHandle->finalizeQuery(); -- 2.7.4