Modify add message related.
authorKeebum Kim <keebum.kim@samsung.com>
Fri, 7 Jun 2013 08:30:00 +0000 (17:30 +0900)
committerKeebum Kim <keebum.kim@samsung.com>
Fri, 7 Jun 2013 08:30:00 +0000 (17:30 +0900)
Change-Id: Ib221efe40a0c652d9c56e8a7abe1cdbc0b409bfb

framework/storage-handler/MsgStorageMessage.cpp
framework/storage-handler/MsgStorageMms.cpp
utils/MsgSqliteWrapper.cpp

index ff8d5f1..e665654 100755 (executable)
@@ -167,8 +167,6 @@ msg_error_t MsgStoAddMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S *pS
                }
        }
 
-       dbHandle.endTrans(true);
-
        /* In the case of MMS Message, load the MMS plugin to save MMS PDU */
        if (pMsg->msgType.mainType == MSG_MMS_TYPE) {
                MMS_MESSAGE_DATA_S mmsMsg;
@@ -180,6 +178,7 @@ msg_error_t MsgStoAddMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S *pS
                        err = plg->addMessage(pMsg, pSendOptInfo, pFileData);
 
                        if (err != MSG_SUCCESS) {
+                               dbHandle.endTrans(false);
                                return MSG_ERR_STORAGE_ERROR;
                        }
 
@@ -189,12 +188,15 @@ msg_error_t MsgStoAddMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S *pS
                                err = MsgStoUpdateMMSMessage(pMsg);
 
                                if (err != MSG_SUCCESS) {
+                                       dbHandle.endTrans(false);
                                        return MSG_ERR_STORAGE_ERROR;
                                }
                        }
                }
        }
 
+       dbHandle.endTrans(true);
+
        MSG_END();
 
        return MSG_SUCCESS;
index 9009984..2b19b07 100755 (executable)
@@ -74,8 +74,6 @@ msg_error_t MsgStoUpdateMMSMessage(MSG_MESSAGE_INFO_S *pMsg)
 
        memset(sqlQuery, 0x00, sizeof(sqlQuery));
 
-       dbHandle.beginTrans();
-
        if(pMsg->msgType.subType == MSG_RETRIEVE_AUTOCONF_MMS || pMsg->msgType.subType == MSG_RETRIEVE_MANUALCONF_MMS) {
                if( pMsg->networkStatus == MSG_NETWORK_RETRIEVE_SUCCESS ) {
                        snprintf(sqlQuery, sizeof(sqlQuery),
@@ -83,7 +81,6 @@ msg_error_t MsgStoUpdateMMSMessage(MSG_MESSAGE_INFO_S *pMsg)
                                        MSGFW_MESSAGE_TABLE_NAME, pMsg->msgType.mainType, pMsg->msgType.subType, pMsg->displayTime, pMsg->networkStatus, pMsg->thumbPath,  pMsg->dataSize, pMsg->msgId);
 
                        if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS) {
-                               dbHandle.endTrans(false);
                                return MSG_ERR_DB_PREPARE;
                        }
 
@@ -95,7 +92,6 @@ msg_error_t MsgStoUpdateMMSMessage(MSG_MESSAGE_INFO_S *pMsg)
                                        MSGFW_MESSAGE_TABLE_NAME, pMsg->msgType.mainType, pMsg->msgType.subType, pMsg->networkStatus, pMsg->thumbPath,  pMsg->msgId);
 
                        if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS) {
-                               dbHandle.endTrans(false);
                                return MSG_ERR_DB_PREPARE;
                        }
 
@@ -108,7 +104,6 @@ msg_error_t MsgStoUpdateMMSMessage(MSG_MESSAGE_INFO_S *pMsg)
                                MSGFW_MESSAGE_TABLE_NAME, pMsg->msgData, pMsg->thumbPath, pMsg->dataSize, pMsg->msgId);
 
                if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS) {
-                       dbHandle.endTrans(false);
                        return MSG_ERR_DB_PREPARE;
                }
 
@@ -119,14 +114,12 @@ msg_error_t MsgStoUpdateMMSMessage(MSG_MESSAGE_INFO_S *pMsg)
                                MSGFW_MESSAGE_TABLE_NAME, pMsg->msgType.mainType, pMsg->msgType.subType, pMsg->folderId, pMsg->networkStatus, pMsg->msgId);
 
                if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS) {
-                       dbHandle.endTrans(false);
                        return MSG_ERR_DB_PREPARE;
                }
        }
 
        if (dbHandle.stepQuery() != MSG_ERR_DB_DONE) {
                dbHandle.finalizeQuery();
-               dbHandle.endTrans(false);
                MSG_DEBUG("Update MMS Message. Fail [%s]", sqlQuery);
                return MSG_ERR_DB_STEP;
        }
@@ -143,7 +136,6 @@ msg_error_t MsgStoUpdateMMSMessage(MSG_MESSAGE_INFO_S *pMsg)
 
        if (dbHandle.getTable(sqlQuery, &row) != MSG_SUCCESS) {
                dbHandle.freeTable();
-               dbHandle.endTrans(false);
                return MSG_ERR_DB_PREPARE;
        }
 
@@ -155,20 +147,16 @@ msg_error_t MsgStoUpdateMMSMessage(MSG_MESSAGE_INFO_S *pMsg)
                if (MsgStoUpdateConversation(&dbHandle, convId) != MSG_SUCCESS) {
                        MSG_DEBUG("MsgStoUpdateConversation() Error");
                        dbHandle.freeTable();
-                       dbHandle.endTrans(false);
-
                        return MSG_ERR_STORAGE_ERROR;
                }
 
        } else {
                MSG_DEBUG("MsgStepQuery() Error [%s]", sqlQuery);
                dbHandle.freeTable();
-               dbHandle.endTrans(false);
                return MSG_ERR_DB_STEP;
        }
 
        dbHandle.freeTable();
-       dbHandle.endTrans(true);
 
        MSG_END();
 
index 9a58a10..0959cc3 100755 (executable)
@@ -42,22 +42,12 @@ __thread sqlite3_stmt *stmt = NULL;
 ==================================================================================================*/
 MsgDbHandler::MsgDbHandler()
 {
-       handle = NULL;
-       stmt = NULL;
        result = NULL;
 }
 
 
 MsgDbHandler::~MsgDbHandler()
 {
-       if(handle != NULL) {
-               if (disconnect() != MSG_SUCCESS)
-                       MSG_DEBUG("disconnect is failed!!");
-       }
-
-       if(stmt != NULL)
-               finalizeQuery();
-
        if(result != NULL)
                freeTable();
 }