Coverity fix: check return type
[platform/core/messaging/msg-service.git] / framework / submit-handler / MsgSubmitHandler.cpp
index b1d21cb..14ac522 100755 (executable)
@@ -25,7 +25,7 @@
 #include "MsgPluginManager.h"
 #include "MsgStorageHandler.h"
 #include "MsgSubmitHandler.h"
-
+#include "MsgUtilFunction.h"
 
 
 /*==================================================================================================
@@ -39,6 +39,20 @@ msg_error_t MsgSubmitReq(MSG_REQUEST_INFO_S *pReqInfo, bool bScheduled)
        pReqInfo->reqId = reqId;
        reqId++;
 
+       if (msg_check_dpm_policy(pReqInfo->msgInfo.msgType.mainType) == false) {
+               MSG_DEBUG("Messaging is restricted by DPM policy.");
+               MsgDbHandler *dbHandle = getDbHandle();
+               MsgStoUpdateNetworkStatus(dbHandle, &(pReqInfo->msgInfo), MSG_NETWORK_SEND_FAIL);
+               if (pReqInfo->msgInfo.msgType.subType != MSG_RETRIEVE_MMS)
+                       /* sending popup */
+                       msg_syspopup_message(true);
+               else
+                       /* retrieving popup */
+                       msg_syspopup_message(false);
+
+               return MSG_ERR_DPM_RESTRICT;
+       }
+
        MSG_DEBUG("==== Msg ID = [%d] ====", pReqInfo->msgInfo.msgId);
        MSG_DEBUG("==== Folder ID = [%d] ====", pReqInfo->msgInfo.folderId);
        MSG_INFO("==== Main Type = [%d] ====", pReqInfo->msgInfo.msgType.mainType);
@@ -90,10 +104,11 @@ msg_error_t MsgSubmitReqSMS(MSG_REQUEST_INFO_S *pReqInfo)
        if (pReqInfo->msgInfo.msgPort.valid == false) {
                pReqInfo->msgInfo.folderId = MSG_OUTBOX_ID;
 
-       if (pReqInfo->msgInfo.msgId > 0 && (pReqInfo->msgInfo.folderId == MSG_DRAFT_ID || pReqInfo->msgInfo.folderId == MSG_OUTBOX_ID))
-               err = MsgStoUpdateMessage(&(pReqInfo->msgInfo), &(pReqInfo->sendOptInfo));
-               if (err != MSG_SUCCESS)
-                       return err;
+               if (pReqInfo->msgInfo.msgId > 0 && (pReqInfo->msgInfo.folderId == MSG_DRAFT_ID || pReqInfo->msgInfo.folderId == MSG_OUTBOX_ID)) {
+                       err = MsgStoUpdateMessage(&(pReqInfo->msgInfo), &(pReqInfo->sendOptInfo));
+                       if (err != MSG_SUCCESS)
+                               return err;
+               }
        }
 
        err = plg->submitReq(pReqInfo);
@@ -148,7 +163,9 @@ msg_error_t MsgSubmitReqMMS(MSG_REQUEST_INFO_S *pReqInfo)
                /* copy whole of MMS PDU filepath to msgData */
                strncpy(fileName, pReqInfo->msgInfo.msgData, MSG_FILENAME_LEN_MAX);
                memset(pReqInfo->msgInfo.msgData, 0x00, sizeof(pReqInfo->msgInfo.msgData));
-               snprintf(pReqInfo->msgInfo.msgData, sizeof(pReqInfo->msgInfo.msgData), "%s%s", MSG_IPC_DATA_PATH, fileName);
+               int wrn = snprintf(pReqInfo->msgInfo.msgData, sizeof(pReqInfo->msgInfo.msgData), "%s%s", MSG_IPC_DATA_PATH, fileName);
+               if(wrn<0)
+                       MSG_DEBUG("snprintf was failed");
 
                MSG_SEC_DEBUG("JAVA MMS PDU filepath:%s", pReqInfo->msgInfo.msgData);
 
@@ -255,7 +272,11 @@ msg_error_t MsgSubmitReqMMS(MSG_REQUEST_INFO_S *pReqInfo)
        char keyName[MAX_VCONFKEY_NAME_LEN];
        memset(keyName, 0x00, sizeof(keyName));
        snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_CHANGED, pReqInfo->msgInfo.sim_idx);
-       MSG_SIM_STATUS_T simStatus = (MSG_SIM_STATUS_T)MsgSettingGetInt(keyName);
+       int tmpval = 0;
+       if (MsgSettingGetInt(keyName, &tmpval) != MSG_SUCCESS) {
+               MSG_INFO("MsgSettingGetInt() is failed");
+       }
+       MSG_SIM_STATUS_T simStatus = (MSG_SIM_STATUS_T)tmpval;
 
        if(simStatus == MSG_SIM_STATUS_NOT_FOUND) {
                MSG_DEBUG("SIM is not present...");
@@ -271,7 +292,7 @@ msg_error_t MsgSubmitReqMMS(MSG_REQUEST_INFO_S *pReqInfo)
                MsgStoSetReadReportSendStatus(pReqInfo->msgInfo.msgId, MMS_RECEIVE_READ_REPORT_SENT);
 
        if (err != MSG_SUCCESS) {
-               if(pReqInfo->msgInfo.msgType.subType == MSG_RETRIEVE_MMS )
+               if(pReqInfo->msgInfo.msgType.subType == MSG_RETRIEVE_MMS)
                        MsgStoUpdateNetworkStatus(dbHandle, &(pReqInfo->msgInfo), MSG_NETWORK_RETRIEVE_FAIL);
                else
                        MsgStoUpdateNetworkStatus(dbHandle, &(pReqInfo->msgInfo), MSG_NETWORK_SEND_FAIL);
@@ -280,13 +301,6 @@ msg_error_t MsgSubmitReqMMS(MSG_REQUEST_INFO_S *pReqInfo)
        return err;
 }
 
-msg_error_t MsgCancelReq(msg_request_id_t reqId)
-{
-       msg_error_t err = MSG_SUCCESS;
-
-       return err;
-}
-
 
 msg_error_t MsgUpdateSentMsg(msg_message_id_t MsgId, msg_network_status_t Status)
 {
@@ -301,7 +315,7 @@ msg_error_t MsgUpdateSentMsg(msg_message_id_t MsgId, msg_network_status_t Status
                if (MsgStoGetMmsSendOpt(MsgId, &sendOpt) == MSG_SUCCESS)
                        bKeepCopy = sendOpt.bKeepCopy;
                else
-                       ret = MsgSettingGetBool(MSG_KEEP_COPY, &bKeepCopy);
+                       err = MsgSettingGetBool(MSG_KEEP_COPY, &bKeepCopy);
        }
 
        /* Move Msg to SENTBOX */