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) {
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);
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);
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 {