[TSAM-9946] sync thread change callback with result of msg_get_thread_view_list() 32/99332/1
authorKyeonghun Lee <kh9090.lee@samsung.com>
Tue, 22 Nov 2016 10:57:42 +0000 (19:57 +0900)
committerKyeonghun Lee <kh9090.lee@samsung.com>
Tue, 22 Nov 2016 10:57:42 +0000 (19:57 +0900)
Change-Id: Iad5ed1f9b53ccc6dce448c090f620325c0ad47e2
Signed-off-by: Kyeonghun Lee <kh9090.lee@samsung.com>
framework/storage-handler/MsgStorageMessage.cpp
framework/transaction-manager/MsgTransManager.cpp
include/utils/MsgUtilStorage.h
utils/MsgUtilStorage.cpp

index 24196e02c8e19b19920e252ee2dffc4f2323185b..0e7754b60c2ca1c6b5d1de10e438f99dd6b9529a 100755 (executable)
@@ -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();
index 724418f2fd1a025df541c2997beb1c1012e2c4fd..ff9ac7b8cfbc0422c986e5481dae72f0e4c7799e 100755 (executable)
@@ -1293,7 +1293,7 @@ void MsgTransactionManager::broadcastStorageChangeCB(const msg_error_t err, cons
        } else if (storageChangeType == MSG_STORAGE_CHANGE_DELETE) {
                std::list<msg_thread_id_t>::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{
index 445157e8df0217279fc7fa2ea55eac21ca2097b9..9a7dff505fe4533baaed6c8ab99d1a401a0a953d 100755 (executable)
@@ -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);
index c63295849531c3ce99e3ede21ad1b9b37ccd2870..d51b90b9c91ad9ecf42369266e793a2c5f5a53c1 100755 (executable)
@@ -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;