From: Kyeonghun Lee Date: Tue, 22 Nov 2016 10:57:42 +0000 (+0900) Subject: [TSAM-9946] sync thread change callback with result of msg_get_thread_view_list() X-Git-Tag: submit/tizen_3.0/20161124.052156~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b90172b521054fad02441fa25c05fc79eca0101b;p=platform%2Fcore%2Fmessaging%2Fmsg-service.git [TSAM-9946] sync thread change callback with result of msg_get_thread_view_list() Change-Id: Iad5ed1f9b53ccc6dce448c090f620325c0ad47e2 Signed-off-by: Kyeonghun Lee --- diff --git a/framework/storage-handler/MsgStorageMessage.cpp b/framework/storage-handler/MsgStorageMessage.cpp index 24196e0..0e7754b 100755 --- a/framework/storage-handler/MsgStorageMessage.cpp +++ b/framework/storage-handler/MsgStorageMessage.cpp @@ -1016,7 +1016,7 @@ msg_error_t MsgStoDeleteMessage(msg_message_id_t msgId, bool bCheckIndication) dbHandle->endTrans(true); /* Update Thread Callback */ - if (bCheckIndication == true && MsgExistConversation(dbHandle, convId) == true) + if (bCheckIndication == true && MsgExistConversation(dbHandle, convId) == true && MsgExistInThreadViewList(dbHandle, convId) == true) MsgTransactionManager::instance()->broadcastThreadChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_UPDATE, convId); if (msgType.mainType == MSG_SMS_TYPE && folderId == MSG_INBOX_ID) { @@ -1316,7 +1316,7 @@ msg_error_t MsgStoDeleteAllMessageInFolder(msg_folder_id_t folderId, bool bOnlyD /* Update Thread Callback */ while (!threadList2.empty()) { msg_thread_id_t cur_thread_id = threadList2.front(); - if (MsgExistConversation(dbHandle, cur_thread_id) == true) + if (MsgExistConversation(dbHandle, cur_thread_id) == true && MsgExistInThreadViewList(dbHandle, cur_thread_id) == true) MsgTransactionManager::instance()->broadcastThreadChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_UPDATE, cur_thread_id); threadList2.pop(); @@ -1681,7 +1681,7 @@ msg_error_t MsgStoDeleteMessageByList(msg_id_list_s *pMsgIdList) /* Update Thread Callback */ while (!threadList3.empty()) { msg_thread_id_t cur_thread_id = threadList3.front(); - if (MsgExistConversation(dbHandle, cur_thread_id) == true) + if (MsgExistConversation(dbHandle, cur_thread_id) == true && MsgExistInThreadViewList(dbHandle, cur_thread_id) == true) MsgTransactionManager::instance()->broadcastThreadChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_UPDATE, cur_thread_id); threadList3.pop(); diff --git a/framework/transaction-manager/MsgTransManager.cpp b/framework/transaction-manager/MsgTransManager.cpp index 724418f..ff9ac7b 100755 --- a/framework/transaction-manager/MsgTransManager.cpp +++ b/framework/transaction-manager/MsgTransManager.cpp @@ -1293,7 +1293,7 @@ void MsgTransactionManager::broadcastStorageChangeCB(const msg_error_t err, cons } else if (storageChangeType == MSG_STORAGE_CHANGE_DELETE) { std::list::iterator it = cur_conv_list.begin(); for (; it != cur_conv_list.end(); ) { - if (MsgExistConversation(dbHandle, *it) == false) { + if (MsgExistConversation(dbHandle, *it) == false || MsgExistInThreadViewList(dbHandle, *it) == false) { broadcastThreadChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_DELETE, *it); it = cur_conv_list.erase(it); } else{ diff --git a/include/utils/MsgUtilStorage.h b/include/utils/MsgUtilStorage.h index 445157e..9a7dff5 100755 --- a/include/utils/MsgUtilStorage.h +++ b/include/utils/MsgUtilStorage.h @@ -63,6 +63,7 @@ bool MsgExistAddress(MsgDbHandler *pDbHandle, const MSG_MESSAGE_INFO_S *pMsg, ms bool MsgExistAddress(MsgDbHandler *pDbHandle, MSG_MESSAGE_INFO_S *pMsg, msg_thread_id_t convId, int index); bool MsgExistConversation(MsgDbHandler *pDbHandle, msg_thread_id_t convId); bool MsgExistMessage(MsgDbHandler *pDbHandle, MSG_MESSAGE_INFO_S *pMsg); +bool MsgExistInThreadViewList(MsgDbHandler *pDbHandle, msg_thread_id_t convId); int MsgStoGetUnreadCnt(MsgDbHandler *pDbHandle, MSG_MAIN_TYPE_T MsgType); msg_error_t MsgStoGetMmsRawFilePath(MsgDbHandler *pDbHandle, msg_message_id_t msgId, char *pFilePath); diff --git a/utils/MsgUtilStorage.cpp b/utils/MsgUtilStorage.cpp index c632958..d51b90b 100755 --- a/utils/MsgUtilStorage.cpp +++ b/utils/MsgUtilStorage.cpp @@ -1351,6 +1351,33 @@ bool MsgExistConversation(MsgDbHandler *pDbHandle, msg_thread_id_t convId) return true; } +bool MsgExistInThreadViewList(MsgDbHandler *pDbHandle, msg_thread_id_t convId) +{ + msg_error_t err = MSG_SUCCESS; + + char sqlQuery[MAX_QUERY_LEN+1]; + + int rowCnt = 0; + + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID FROM %s WHERE CONV_ID = %d AND FOLDER_ID > %d AND FOLDER_ID < %d AND STORAGE_ID = %d;", + MSGFW_MESSAGE_TABLE_NAME, convId, MSG_ALLBOX_ID, MSG_SPAMBOX_ID, MSG_STORAGE_PHONE); + + err = pDbHandle->getTable(sqlQuery, &rowCnt, NULL); + + if (err == MSG_ERR_DB_NORECORD) { + pDbHandle->freeTable(); + return false; + } else if (err != MSG_SUCCESS) { + pDbHandle->freeTable(); + return false; + } + pDbHandle->freeTable(); + + return true; +} + bool MsgExistMessage(MsgDbHandler *pDbHandle, MSG_MESSAGE_INFO_S *pMsg) { msg_error_t err = MSG_SUCCESS;