diff options
-rwxr-xr-x | config/msg-service-db.sql | 8 | ||||
-rwxr-xr-x | framework/storage-handler/MsgStorageManager.cpp | 17 | ||||
-rwxr-xr-x | framework/storage-handler/MsgStorageMessage.cpp | 20 | ||||
-rwxr-xr-x | include/utils/MsgSqliteWrapper.h | 1 | ||||
-rwxr-xr-x | plugin/sms_plugin/SmsPluginStorage.cpp | 56 | ||||
-rwxr-xr-x | plugin/sms_plugin/SmsPluginTransport.cpp | 11 | ||||
-rwxr-xr-x | plugin/sms_plugin/include/SmsPluginStorage.h | 4 |
7 files changed, 111 insertions, 6 deletions
diff --git a/config/msg-service-db.sql b/config/msg-service-db.sql index b4b5627..6893c8c 100755 --- a/config/msg-service-db.sql +++ b/config/msg-service-db.sql @@ -264,6 +264,14 @@ CREATE TABLE MSG_ADDRESS_TEMP_TABLE ADDRESS_VAL TEXT NOT NULL DEFAULT '' ); +CREATE TABLE MSG_SENTFAIL_INDEX_TABLE +( + MSG_ID INTEGER PRIMARY KEY , + SENTFAIL_INDEX INTEGER DEFAULT 0 , + + FOREIGN KEY(MSG_ID) REFERENCES MSG_MESSAGE_TABLE(MSG_ID) +); + CREATE INDEX MSG_CONVERSATION_INDEX ON MSG_CONVERSATION_TABLE(CONV_ID); CREATE INDEX MSG_FOLDER_INDEX ON MSG_FOLDER_TABLE(FOLDER_ID); CREATE INDEX MSG_MESSAGE_INDEX ON MSG_MESSAGE_TABLE(MSG_ID, CONV_ID, FOLDER_ID); diff --git a/framework/storage-handler/MsgStorageManager.cpp b/framework/storage-handler/MsgStorageManager.cpp index 1590363..ca1e821 100755 --- a/framework/storage-handler/MsgStorageManager.cpp +++ b/framework/storage-handler/MsgStorageManager.cpp @@ -169,6 +169,23 @@ void MsgUpdateDBtoVer3() else MSG_SEC_DEBUG("FAIL : create %s [%d].", MSGFW_MMS_RECIPIENTS_TABLE_NAME, err); } + + if (!dbHandle->checkTableExist(MSGFW_SENTFAIL_INDEX_TABLE_NAME)) { + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + snprintf(sqlQuery, sizeof(sqlQuery), + "CREATE TABLE %s ( " + "MSG_ID INTEGER PRIMARY KEY, " + "SENTFAIL_INDEX INTEGER DEFAULT 0, " + "FOREIGN KEY(MSG_ID) REFERENCES MSG_MESSAGE_TABLE(MSG_ID));", + MSGFW_SENTFAIL_INDEX_TABLE_NAME); + + err = dbHandle->execQuery(sqlQuery); + + if (err == MSG_SUCCESS) + MSG_SEC_DEBUG("SUCCESS : create %s.", MSGFW_SENTFAIL_INDEX_TABLE_NAME); + else + MSG_SEC_DEBUG("FAIL : create %s [%d].", MSGFW_SENTFAIL_INDEX_TABLE_NAME, err); + } } diff --git a/framework/storage-handler/MsgStorageMessage.cpp b/framework/storage-handler/MsgStorageMessage.cpp index 8c5111d..e5e9ce4 100755 --- a/framework/storage-handler/MsgStorageMessage.cpp +++ b/framework/storage-handler/MsgStorageMessage.cpp @@ -834,6 +834,16 @@ msg_error_t MsgStoDeleteMessage(msg_message_id_t msgId, bool bCheckIndication) return MSG_ERR_DB_EXEC; } + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID = %d;", + MSGFW_SENTFAIL_INDEX_TABLE_NAME, msgId); + + /* Delete Data from SENTFAIL_INDEX table */ + if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) { + dbHandle->endTrans(false); + return MSG_ERR_DB_EXEC; + } + if (msgType.subType == MSG_CB_SMS || msgType.subType == MSG_JAVACB_SMS || (msgType.subType >= MSG_CMAS_PRESIDENTIAL && msgType.subType <= MSG_CMAS_OPERATOR_DEFINED)) { memset(sqlQuery, 0x00, sizeof(sqlQuery)); @@ -1070,13 +1080,14 @@ msg_error_t MsgStoDeleteAllMessageInFolder(msg_folder_id_t folderId, bool bOnlyD MSGFW_SYNCML_MSG_TABLE_NAME, MSGFW_SMS_SENDOPT_TABLE_NAME, MMS_PLUGIN_MESSAGE_TABLE_NAME, MSGFW_MMS_PREVIEW_TABLE_NAME, MSGFW_REPORT_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, - MSGFW_MMS_RECIPIENTS_TABLE_NAME, MSGFW_UNIQUENESS_INFO_TABLE_NAME}; + MSGFW_MMS_RECIPIENTS_TABLE_NAME, MSGFW_UNIQUENESS_INFO_TABLE_NAME, + MSGFW_SENTFAIL_INDEX_TABLE_NAME}; #else const char *tableList[] = {MSGFW_PUSH_MSG_TABLE_NAME, MSGFW_CB_MSG_TABLE_NAME, MSGFW_SYNCML_MSG_TABLE_NAME, MSGFW_SMS_SENDOPT_TABLE_NAME, MMS_PLUGIN_MESSAGE_TABLE_NAME, MSGFW_MMS_PREVIEW_TABLE_NAME, MSGFW_REPORT_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, - MSGFW_MMS_RECIPIENTS_TABLE_NAME}; + MSGFW_MMS_RECIPIENTS_TABLE_NAME, MSGFW_SENTFAIL_INDEX_TABLE_NAME}; #endif int listCnt = sizeof(tableList)/sizeof(char *); @@ -1415,14 +1426,15 @@ msg_error_t MsgStoDeleteMessageByList(msg_id_list_s *pMsgIdList) MSGFW_SYNCML_MSG_TABLE_NAME, MSGFW_SMS_SENDOPT_TABLE_NAME, MSGFW_REPORT_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, MSGFW_SMS_REPORT_TABLE_NAME, MSGFW_MMS_MULTIPART_TABLE_NAME, - MSGFW_MMS_RECIPIENTS_TABLE_NAME, MSGFW_UNIQUENESS_INFO_TABLE_NAME}; + MSGFW_MMS_RECIPIENTS_TABLE_NAME, MSGFW_UNIQUENESS_INFO_TABLE_NAME, + MSGFW_SENTFAIL_INDEX_TABLE_NAME}; #else const char *tableList[] = {MMS_PLUGIN_MESSAGE_TABLE_NAME, MSGFW_MMS_PREVIEW_TABLE_NAME, MSGFW_PUSH_MSG_TABLE_NAME, MSGFW_CB_MSG_TABLE_NAME, MSGFW_SYNCML_MSG_TABLE_NAME, MSGFW_SMS_SENDOPT_TABLE_NAME, MSGFW_REPORT_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, MSGFW_SMS_REPORT_TABLE_NAME, MSGFW_MMS_MULTIPART_TABLE_NAME, - MSGFW_MMS_RECIPIENTS_TABLE_NAME}; + MSGFW_MMS_RECIPIENTS_TABLE_NAME, MSGFW_SENTFAIL_INDEX_TABLE_NAME}; #endif int listCnt = sizeof(tableList)/sizeof(char *); diff --git a/include/utils/MsgSqliteWrapper.h b/include/utils/MsgSqliteWrapper.h index 11a4ae9..e312397 100755 --- a/include/utils/MsgSqliteWrapper.h +++ b/include/utils/MsgSqliteWrapper.h @@ -64,6 +64,7 @@ #define MSGFW_TMP_MSGID_TABLE_NAME "MSG_TMP_MSGID_TABLE" #define MSGFW_ADDRESS_TEMP_TABLE_NAME "MSG_ADDRESS_TEMP_TABLE" +#define MSGFW_SENTFAIL_INDEX_TABLE_NAME "MSG_SENTFAIL_INDEX_TABLE" #define MAX_QUERY_LEN 3072 #define MAX_FOLDER_NAME_LEN 20 diff --git a/plugin/sms_plugin/SmsPluginStorage.cpp b/plugin/sms_plugin/SmsPluginStorage.cpp index 492453a..466f4ed 100755 --- a/plugin/sms_plugin/SmsPluginStorage.cpp +++ b/plugin/sms_plugin/SmsPluginStorage.cpp @@ -623,6 +623,14 @@ msg_error_t SmsPluginStorage::deleteSmsMessage(msg_message_id_t msgId) return MSG_ERR_DB_EXEC; } + /** Delete Message from msg_sentfail_index table */ + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID = %d;", MSGFW_SENTFAIL_INDEX_TABLE_NAME, msgId); + if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) { + dbHandle->endTrans(false); + return MSG_ERR_DB_EXEC; + } + /** Clear Conversation table */ if (MsgStoClearConversationTable(dbHandle) != MSG_SUCCESS) { dbHandle->endTrans(false); @@ -1137,3 +1145,51 @@ bool SmsPluginStorage::isDuplicatedCBMsg(MSG_MESSAGE_INFO_S *pMsgInfo) return false; } + + +msg_error_t SmsPluginStorage::setFailedIndex(MsgDbHandler *pDbHandle, msg_message_id_t msgId, int failedIndex) +{ + msg_error_t err = MSG_SUCCESS; + char sqlQuery[MAX_QUERY_LEN+1] = {0}; + if (failedIndex > 0) { + snprintf(sqlQuery, sizeof(sqlQuery), "INSERT OR REPLACE INTO %s(MSG_ID, SENTFAIL_INDEX) VALUES(%d, %d);", + MSGFW_SENTFAIL_INDEX_TABLE_NAME, msgId, failedIndex); + } else { + snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID = %d;", + MSGFW_SENTFAIL_INDEX_TABLE_NAME, msgId); + } + + if (pDbHandle->execQuery(sqlQuery) != MSG_SUCCESS) + err = MSG_ERR_DB_EXEC; + + return err; +} + + +int SmsPluginStorage::getFailedIndex(MsgDbHandler *pDbHandle, msg_message_id_t msgId) +{ + int ret = 0; + char sqlQuery[MAX_QUERY_LEN+1] = {0}; + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT SENTFAIL_INDEX FROM %s WHERE MSG_ID = %d;", + MSGFW_SENTFAIL_INDEX_TABLE_NAME, msgId); + + if (pDbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) + return 0; + + if (pDbHandle->stepQuery() == MSG_ERR_DB_ROW) { + ret = pDbHandle->columnInt(0); + } else { + pDbHandle->finalizeQuery(); + return 0; + } + + pDbHandle->finalizeQuery(); + + return ret; +} + + +msg_error_t SmsPluginStorage::deleteFailedIndex(MsgDbHandler *pDbHandle, msg_message_id_t msgId) +{ + return setFailedIndex(pDbHandle, msgId, 0); +} diff --git a/plugin/sms_plugin/SmsPluginTransport.cpp b/plugin/sms_plugin/SmsPluginTransport.cpp index 35bf189..9a84d00 100755 --- a/plugin/sms_plugin/SmsPluginTransport.cpp +++ b/plugin/sms_plugin/SmsPluginTransport.cpp @@ -113,7 +113,9 @@ void SmsPluginTransport::submitRequest(SMS_REQUEST_INFO_S *pReqInfo) MSG_INFO("MsgSettingGetString() is failed"); } - for (int i = 0; i < pReqInfo->msgInfo.nAddressCnt; i++) { + int failedIndex = SmsPluginStorage::instance()->getFailedIndex(dbHandle, pReqInfo->msgInfo.msgId); + + for (int i = failedIndex; i < pReqInfo->msgInfo.nAddressCnt; i++) { /* Make SMS_SUBMIT_DATA_S from MSG_REQUEST_INFO_S */ SMS_SUBMIT_DATA_S submitData = {{0}, }; msgInfoToSubmitData(&(pReqInfo->msgInfo), &submitData, &(tpdu.data.submit.dcs.codingScheme), i); @@ -301,6 +303,7 @@ void SmsPluginTransport::submitRequest(SMS_REQUEST_INFO_S *pReqInfo) } } else { SmsPluginEventHandler::instance()->handleSentStatus(MSG_NETWORK_SEND_FAIL); + SmsPluginStorage::instance()->setFailedIndex(dbHandle, pReqInfo->msgInfo.msgId, i); if (msisdn) { free(msisdn); @@ -312,7 +315,7 @@ void SmsPluginTransport::submitRequest(SMS_REQUEST_INFO_S *pReqInfo) /* Tizen Validation System */ MSG_SMS_VLD_INFO("%d, SMS Send Start, %s->%s, %s", pReqInfo->msgInfo.msgId, \ (msisdn == NULL)?"ME":msisdn, \ - pReqInfo->msgInfo.addressList[0].addressVal, \ + pReqInfo->msgInfo.addressList[i].addressVal, \ "Success"); MSG_SMS_VLD_TXT("%d, [%s]", pReqInfo->msgInfo.msgId, pReqInfo->msgInfo.msgText); @@ -365,6 +368,8 @@ void SmsPluginTransport::submitRequest(SMS_REQUEST_INFO_S *pReqInfo) MsgInsertTicker("Sending SMS is failed", SMS_MESSAGE_SENDING_FAIL, true, pReqInfo->msgInfo.msgId); } + SmsPluginStorage::instance()->setFailedIndex(dbHandle, pReqInfo->msgInfo.msgId, i); + if (msisdn) { free(msisdn); msisdn = NULL; @@ -377,6 +382,8 @@ void SmsPluginTransport::submitRequest(SMS_REQUEST_INFO_S *pReqInfo) } } + SmsPluginStorage::instance()->deleteFailedIndex(dbHandle, pReqInfo->msgInfo.msgId); + _RETURN_FUNC : if (msisdn) { free(msisdn); diff --git a/plugin/sms_plugin/include/SmsPluginStorage.h b/plugin/sms_plugin/include/SmsPluginStorage.h index f3a86b9..ed55f63 100755 --- a/plugin/sms_plugin/include/SmsPluginStorage.h +++ b/plugin/sms_plugin/include/SmsPluginStorage.h @@ -73,6 +73,10 @@ public: msg_error_t releasePushEvent(); msg_error_t updateSmsMessage(MSG_MESSAGE_INFO_S *pMsgInfo); bool isDuplicatedCBMsg(MSG_MESSAGE_INFO_S *pMsgInfo); + + msg_error_t setFailedIndex(MsgDbHandler *pDbHandle, msg_message_id_t msgId, int failedIndex); + int getFailedIndex(MsgDbHandler *pDbHandle, msg_message_id_t msgId); + msg_error_t deleteFailedIndex(MsgDbHandler *pDbHandle, msg_message_id_t msgId); private: SmsPluginStorage(); ~SmsPluginStorage(); |