Modify add, update message.
authorKeebum Kim <keebum.kim@samsung.com>
Wed, 6 Feb 2013 06:12:01 +0000 (15:12 +0900)
committerKeebum Kim <keebum.kim@samsung.com>
Wed, 6 Feb 2013 06:12:01 +0000 (15:12 +0900)
Change-Id: I7540e8c23642c788719642ab9b40f106b8fbb778

framework/storage-handler/MsgStorageMessage.cpp
framework/transaction-manager/MsgCmdHandlerTransport.cpp
plugin/mms_plugin/MmsPluginMain.cpp

index b088560..252c372 100755 (executable)
@@ -101,25 +101,6 @@ msg_error_t MsgStoAddMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S *pS
                pMsg->threadId = convId;
        }
 
-
-       ///////// temporary code for draft message in conversation view.
-       if(convId > 0 && pMsg->folderId == MSG_DRAFT_ID) {
-               memset(sqlQuery, 0x00, sizeof(sqlQuery));
-
-               snprintf(sqlQuery, sizeof(sqlQuery),
-                               "DELETE FROM %s WHERE CONV_ID = %d AND FOLDER_ID = %d;",
-                               MSGFW_MESSAGE_TABLE_NAME, convId, MSG_DRAFT_ID);
-
-               MSG_DEBUG("sqlQuery [%s]", sqlQuery);
-
-               err = dbHandle.execQuery(sqlQuery);
-
-               if (err != MSG_SUCCESS) {
-                       MSG_DEBUG("fail to delete draft messages.");
-               }
-       }
-       ////////
-
        err = dbHandle.getRowId(MSGFW_MESSAGE_TABLE_NAME, &rowId);
 
        if (err != MSG_SUCCESS) {
@@ -229,6 +210,47 @@ msg_error_t MsgStoUpdateMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S
 
        dbHandle.beginTrans();
 
+       MSG_MAIN_TYPE_T prevType;
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MAIN_TYPE FROM %s WHERE MSG_ID = %d;",
+                       MSGFW_MESSAGE_TABLE_NAME, pMsg->msgId);
+
+       MSG_DEBUG("QUERY : %s", sqlQuery);
+
+       if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS) {
+               dbHandle.endTrans(false);
+               return MSG_ERR_DB_PREPARE;
+       }
+
+       if (dbHandle.stepQuery() != MSG_ERR_DB_ROW) {
+               dbHandle.finalizeQuery();
+               dbHandle.endTrans(false);
+               return MSG_ERR_STORAGE_ERROR;
+       }
+
+       prevType = dbHandle.columnInt(0);
+       dbHandle.finalizeQuery();
+
+       //check msg type with previous type
+       if (prevType != pMsg->msgType.mainType) {
+               MSG_DEBUG("different msg type to update [prev : %d], [current : %d]", prevType, pMsg->msgType.mainType);
+
+               err = MsgStoDeleteMessage(pMsg->msgId, false);
+               if (err != MSG_SUCCESS) {
+                       dbHandle.endTrans(false);
+                       return err;
+               }
+
+               err = MsgStoAddMessage(pMsg, pSendOptInfo);
+               if (err != MSG_SUCCESS) {
+                       dbHandle.endTrans(false);
+                       return err;
+               }
+
+               dbHandle.endTrans(false);
+               return err;
+       }
+
        if (pMsg->nAddressCnt > 0) {
                err = MsgStoAddAddress(&dbHandle, pMsg, &convId);
 
@@ -338,6 +360,16 @@ msg_error_t MsgStoUpdateMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S
                        dbHandle.endTrans(false);
                        return MSG_ERR_STORAGE_ERROR;
                }
+
+               if (pMsg->msgType.subType == MSG_SENDREQ_MMS) {
+                       MSG_DEBUG("pMsg->msgText: %s, pMsg->thumbPath: %s ", pMsg->msgText, pMsg->thumbPath);
+
+                       err = MsgStoUpdateMMSMessage(pMsg);
+
+                       if (err != MSG_SUCCESS) {
+                               return MSG_ERR_STORAGE_ERROR;
+                       }
+               }
        }
 
        err = MsgStoUpdateConversation(&dbHandle, convId);
index c8bbedb..d137b14 100755 (executable)
@@ -113,8 +113,12 @@ int MsgSubmitReqHandler(const MSG_CMD_S *pCmd, char **ppEvent)
        msgIds[0] = reqInfo.msgInfo.msgId;
        msgIdList.msgIdList = msgIds;
 
-       if ((err == MSG_SUCCESS || err != MSG_ERR_PLUGIN_STORAGE) && bNewMsg && reqInfo.msgInfo.msgPort.valid == false) {
-               MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_INSERT, &msgIdList);
+       if ((err == MSG_SUCCESS || err != MSG_ERR_PLUGIN_STORAGE) && reqInfo.msgInfo.msgPort.valid == false) {
+               if (bNewMsg) {
+                       MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_INSERT, &msgIdList);
+               } else {
+                       MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_UPDATE, &msgIdList);
+               }
        } else if (err == MSG_ERR_SECURITY_ERROR) { // Case of MDM enabled, it returns MSG_ERR_SECURITY_ERROR.
                MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_UPDATE, &msgIdList);
        } else {
index 0b5df12..38ca717 100755 (executable)
@@ -175,7 +175,7 @@ msg_error_t MmsUpdateMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S
        msg_error_t err = MSG_SUCCESS;
 
        try {
-               if (pMsgInfo->networkStatus == MSG_NETWORK_NOT_SEND) {
+               if (pMsgInfo->networkStatus == MSG_NETWORK_NOT_SEND || pMsgInfo->networkStatus == MSG_NETWORK_SENDING) {
                        err = MmsPluginStorage::instance()->updateMessage(pMsgInfo, pSendOptInfo, pFileData);
                } else {
                        //[Update Message ID & File path only in case of retrieve. Else update Message ID]