Invoke thread change callback on update message 45/106945/1
authorKyeonghun Lee <kh9090.lee@samsung.com>
Mon, 26 Dec 2016 01:39:34 +0000 (10:39 +0900)
committerKyeonghun Lee <kh9090.lee@samsung.com>
Mon, 26 Dec 2016 01:39:34 +0000 (10:39 +0900)
Change-Id: I160134e7c8efc3c1e2d1054a3525cebb8dee9cd4
Signed-off-by: Kyeonghun Lee <kh9090.lee@samsung.com>
framework/storage-handler/MsgStorageMessage.cpp
framework/storage-handler/MsgStorageMms.cpp
framework/transaction-manager/MsgTransManager.cpp

index 71498da..a4ff93c 100755 (executable)
@@ -297,6 +297,7 @@ msg_error_t MsgStoUpdateMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S
        char sqlQuery[MAX_QUERY_LEN+1];
 
        msg_thread_id_t convId = 0;
+       msg_thread_id_t prevConvId = pMsg->threadId;
        MsgDbHandler *dbHandle = getDbHandle();
        dbHandle->beginTrans();
 
@@ -508,6 +509,9 @@ msg_error_t MsgStoUpdateMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S
 
        dbHandle->endTrans(true);
 
+       if (prevConvId != 0 && prevConvId != convId && MsgExistInThreadViewList(dbHandle, prevConvId) == false)
+               MsgTransactionManager::instance()->broadcastThreadChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_DELETE, prevConvId);
+
        return MSG_SUCCESS;
 }
 
index bd519cd..8d3f5ab 100755 (executable)
@@ -21,6 +21,7 @@
 #include "MsgSqliteWrapper.h"
 #include "MsgStorageHandler.h"
 #include "MsgContact.h"
+#include "MsgTransManager.h"
 
 
 /*==================================================================================================
@@ -325,6 +326,10 @@ msg_error_t MsgStoUpdateMMSMessage(MSG_MESSAGE_INFO_S *pMsg)
                                        if (MsgStoClearConversationTable(dbHandle) != MSG_SUCCESS) {
                                                MSG_DEBUG("MsgStoClearConversationTable() Error");
                                        }
+
+                                       if (MsgExistInThreadViewList(dbHandle, prev_conv_id) == false) {
+                                               MsgTransactionManager::instance()->broadcastThreadChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_DELETE, prev_conv_id);
+                                       }
                                }
                        }
                }
index 2e189f8..fd7001d 100755 (executable)
@@ -1277,7 +1277,7 @@ void MsgTransactionManager::broadcastStorageChangeCB(const msg_error_t err, cons
        MsgDbHandler *dbHandle = getDbHandle();
        MsgSimpleQ<msg_thread_id_t> updatedConvQ;
 
-       if (storageChangeType == MSG_STORAGE_CHANGE_INSERT) {
+       if (storageChangeType == MSG_STORAGE_CHANGE_INSERT || storageChangeType == MSG_STORAGE_CHANGE_UPDATE) {
                for (int i = 0; i < pMsgIdList->nCount; i++) {
                        msg_thread_id_t conv_id = MsgGetThreadId(dbHandle, pMsgIdList->msgIdList[i]);
                        bool found = (std::find(cur_conv_list.begin(), cur_conv_list.end(), conv_id) != cur_conv_list.end());
@@ -1293,14 +1293,6 @@ void MsgTransactionManager::broadcastStorageChangeCB(const msg_error_t err, cons
                                }
                        }
                }
-       } else if (storageChangeType == MSG_STORAGE_CHANGE_UPDATE) {
-               for (int i = 0; i < pMsgIdList->nCount; i++) {
-                       msg_thread_id_t conv_id = MsgGetThreadId(dbHandle, pMsgIdList->msgIdList[i]);
-                       if (updatedConvQ.checkExist(conv_id, compare_func) == false) {
-                               broadcastThreadChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_UPDATE, conv_id);
-                               updatedConvQ.push_back(conv_id);
-                       }
-               }
        }
 
        updatedConvQ.clear();
@@ -1315,6 +1307,9 @@ void MsgTransactionManager::broadcastThreadChangeCB(const msg_error_t err, const
 
        MSG_DEBUG("storageChangeType [%d], threadId [%d]", storageChangeType, threadId);
 
+       if (threadId <= 0)
+               return;
+
        if (storageChangeType == MSG_STORAGE_CHANGE_DELETE)
                cur_conv_list.remove(threadId);