[MPR-976] TSC related enums and api added 66/106066/4
authorKyeonghun Lee <kh9090.lee@samsung.com>
Tue, 20 Dec 2016 09:36:05 +0000 (18:36 +0900)
committerKyeonghun Lee <kh9090.lee@samsung.com>
Tue, 31 Jan 2017 01:58:16 +0000 (17:58 -0800)
Change-Id: If9ee92f7855e8dd69c62d0623770af2f9d26faec
Signed-off-by: Kyeonghun Lee <kh9090.lee@samsung.com>
16 files changed:
framework/storage-handler/MsgStorageMessage.cpp
framework/transaction-manager/MsgCmdHandlerStorage.cpp
framework/transaction-manager/MsgTransManager.cpp
include/common/MsgCmdTypes.h
include/common/MsgInternalTypes.h
include/common/MsgTypes.h
include/framework/MsgCmdHandler.h
include/framework/MsgStorageHandler.h
include/mapi/msg_storage.h
include/mapi/msg_types.h
include/proxy/MsgHandle.h
mapi/msg_storage.cpp
plugin/mms_plugin/MmsPluginMain.cpp
proxy/MsgHandleStorage.cpp
utils/MsgDebug.cpp
utils/MsgUtilStorage.cpp

index 00d5847..9634904 100755 (executable)
@@ -3210,6 +3210,49 @@ msg_error_t MsgStoUpdateIMSI(int sim_idx)
 }
 
 
+msg_error_t MsgStoAllowTcsMessage(msg_message_id_t msgId)
+{
+       MSG_BEGIN();
+       MSG_MESSAGE_INFO_S msgInfo = {0,};
+       MSG_SENDINGOPT_INFO_S sendOptInfo = {0,};
+       msg_error_t err = MSG_SUCCESS;
+
+       err = MsgStoGetMessage(msgId, &msgInfo, &sendOptInfo);
+       if (err != MSG_SUCCESS) {
+               MSG_DEBUG("MsgStoGetMessage error [%d]", err);
+               return MSG_ERR_STORAGE_ERROR;
+       }
+
+       if (msgInfo.networkStatus == MSG_NETWORK_RETRIEVE_SUCCESS
+               && (msgInfo.msgType.subType == MSG_RETRIEVE_AUTOCONF_MMS || msgInfo.msgType.subType == MSG_RETRIEVE_MANUALCONF_MMS)) {
+               MsgPlugin *plg = MsgPluginManager::instance()->getPlugin(MSG_MMS_TYPE);
+               if (plg == NULL) {
+                       MSG_ERR("plugin is null!");
+                       return MSG_ERR_NULL_POINTER;
+               }
+
+               err = plg->updateMessage(&msgInfo, NULL, (char *)MSG_TCS_MESSAGE);
+               if (err != MSG_SUCCESS) {
+                       MSG_ERR("plg->updateMessage() failed: (%d)", err);
+               }
+
+               MsgStoUpdateMMSMessage(&msgInfo);
+
+       } else {
+               MSG_DEBUG("Not Support Msg : main type = %d, sub type = %d, network status = %d",
+                               msgInfo.msgType.mainType, msgInfo.msgType.subType, msgInfo.networkStatus);
+       }
+
+       /* Delete Temp File for Message Data */
+       if (msgInfo.bTextSms == false) {
+               MsgDeleteFile(msgInfo.msgData); //ipc
+       }
+
+       MSG_END();
+       return err;
+}
+
+
 msg_error_t MsgStoUpdateDPMRestrictedStatus(MSG_MAIN_TYPE_T msgType)
 {
        msg_error_t err = MSG_SUCCESS;
index e0e30da..3b3dd19 100755 (executable)
@@ -1766,3 +1766,37 @@ int MsgUpdateIMSIHandler(const MSG_CMD_S *pCmd, char **ppEvent)
 
        return eventSize;
 }
+
+
+int MsgAllowTcsMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent)
+{
+       msg_error_t err = MSG_SUCCESS;
+
+       if (!pCmd || !ppEvent) {
+               MSG_ERR("pCmd or ppEvent is null");
+               return 0;
+       }
+
+       int eventSize = 0;
+
+       msg_message_id_t msgId;
+
+       memcpy(&msgId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(msg_message_id_t));
+
+       err = MsgStoAllowTcsMessage(msgId);
+
+       //storage change CB
+       msg_id_list_s msgIdList;
+       msg_message_id_t msgIds[1];
+       memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
+
+       msgIdList.nCount = 1;
+       msgIds[0] = msgId;
+       msgIdList.msgIdList = msgIds;
+
+       MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_UPDATE, &msgIdList);
+
+       // Make Event Data
+       eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_ALLOW_TCS_MESSAGE, err, (void**)ppEvent);
+       return eventSize;
+}
index fd7001d..5c22741 100755 (executable)
@@ -208,6 +208,7 @@ MsgTransactionManager::MsgTransactionManager() : running(false), mx(), mxQ(), cv
        handlerMap[MSG_CMD_PLG_CHECK_UNIQUENESS] = &MsgCheckUniquenessHandler;
 #endif
        handlerMap[MSG_CMD_UPDATE_IMSI] = &MsgUpdateIMSIHandler;
+       handlerMap[MSG_CMD_ALLOW_TCS_MESSAGE] = &MsgAllowTcsMessageHandler;
 }
 
 
index fd21d0c..5805d6a 100755 (executable)
@@ -165,6 +165,7 @@ enum _MSG_CMD_TYPE_E {
        MSG_CMD_PLG_CHECK_UNIQUENESS,
 #endif
 
+       MSG_CMD_ALLOW_TCS_MESSAGE,
        MSG_CMD_CHECK_PERMISSION,
        MSG_CMD_REG_THREAD_CHANGE_CB,
        MSG_CMD_PLG_THREAD_CHANGE_IND,
@@ -279,6 +280,7 @@ enum _MSG_EVENT_TYPE_E {
 #ifdef FEATURE_SMS_CDMA
        MSG_EVENT_PLG_CHECK_UNIQUENESS,
 #endif
+       MSG_EVENT_ALLOW_TCS_MESSAGE,
        MSG_EVENT_CHECK_PERMISSION,
        MSG_EVENT_REG_THREAD_CHANGE_CB,
        MSG_EVENT_PLG_THREAD_CHANGE_IND,
index 1a45ff6..57f2774 100755 (executable)
 #define MSG_TELEPHONY_SMS_FEATURE      "http://tizen.org/feature/network.telephony.sms"
 #define MSG_TELEPHONY_MMS_FEATURE      "http://tizen.org/feature/network.telephony.mms"
 
+#define MSG_TCS_MESSAGE                                "tcs_message"
+
 /*==================================================================================================
                                                                                        TYPES
 ==================================================================================================*/
index 12da13d..e9673b3 100755 (executable)
@@ -314,6 +314,10 @@ typedef struct {
        char mime_type[MAX_MIME_TYPE_LEN+1];
        char media_item[MSG_FILEPATH_LEN_MAX+1];
        char thumb_path[MSG_FILEPATH_LEN_MAX+1];
+       int tcs_level;
+       int malware_allow;
+       int thumb_tcs_level;
+       int thumb_malware_allow;
 } MSG_MEDIA_INFO_S;
 
 /**
index f74a208..7123add 100755 (executable)
@@ -107,6 +107,7 @@ int MsgUpdatePushEventHandler(const MSG_CMD_S *pCmd, char **ppEvent);
 int MsgAddSimMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent);
 int MsgResendMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent);
 int MsgUpdateIMSIHandler(const MSG_CMD_S *pCmd, char **ppEvent);
+int MsgAllowTcsMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent);
 #ifdef FEATURE_SMS_CDMA
 int MsgCheckUniquenessHandler(const MSG_CMD_S *pCmd, char **ppEvent);
 #endif
index de9ea56..b13434a 100755 (executable)
@@ -143,6 +143,7 @@ msg_error_t MsgStoUpdateAllAddress();
 msg_error_t MsgCheckUniqueness(bool bInsert, msg_message_id_t msgId, MSG_UNIQUE_INDEX_S *p_msg);
 #endif
 msg_error_t MsgStoUpdateIMSI(int sim_idx);
+msg_error_t MsgStoAllowTcsMessage(msg_message_id_t msgId);
 msg_error_t MsgStoUpdateDPMRestrictedStatus(MSG_MAIN_TYPE_T msgType);
 
 #endif /* MSG_STORAGE_HANDLER_H */
index 4fb9263..7ace64c 100755 (executable)
@@ -1186,6 +1186,7 @@ int msg_set_conversation_to_read(msg_handle_t handle,  msg_thread_id_t thread_id
  *
  * @see msg_db_free()
  */
+
 int msg_db_select_with_query(msg_handle_t handle, const char *query, char ***db_res, int *row_count, int *col_count);
 
 /**
@@ -1207,7 +1208,32 @@ int msg_db_select_with_query(msg_handle_t handle, const char *query, char ***db_
  *
  * @see msg_db_select_with_query()
  */
+
 int msg_db_free(msg_handle_t handle, char **db_res);
+
+/**
+ * @brief Allows TCS message with message ID.
+ * @details This API is used to update message to allow TCS.
+ *
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/message.write
+ *
+ * @remarks This function MUST be called after Message handle is opened.
+ *
+ * @param[in] handle   Message handle
+ * @param[in] msg_id   The message ID to be updated
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval MSG_SUCCESS                                 Success in operation
+ * @retval MSG_ERR_INVALID_PARAMETER   Parameter is invalid
+ * @retval MSG_ERR_STORAGE_ERROR               Storage is error
+ * @retval MSG_ERR_PERMISSION_DENIED   The application does not have the privilege to call this method
+ * @retval MSG_ERR_NOT_SUPPORTED               Not supported
+ */
+
+int msg_allow_tcs_message(msg_handle_t handle, msg_message_id_t msg_id);
+
 /**
  *     @}
  */
index b37f950..4abcebf 100755 (executable)
@@ -2089,6 +2089,10 @@ enum MSG_MEDIA_INFO_E {
        MSG_MEDIA_MIME_TYPE_STR,                         /**< Indicates the mimetype of a media file */
        MSG_MEDIA_THUMB_PATH_STR,                        /**< Indicates the thumbnail path of a media file */
        MSG_MEDIA_MESSAGE_ID_INT,                        /**< Indicates the message id */
+       MSG_MEDIA_TCS_LEVEL_INT,                         /**< Indicates detection of malware type */
+       MSG_MEDIA_MALWARE_ALLOW_INT,                     /**< Indicates malware allowed */
+       MSG_MEDIA_THUMBNAIL_TCS_LEVEL_INT,               /**< Indicates thumbnail's detection of malware type */
+       MSG_MEDIA_THUMBNAIL_MALWARE_ALLOW_INT,           /**< Indicates thumbnail's malware allowed */
 };
 
 /**
index f3acaae..bcf590b 100755 (executable)
@@ -132,6 +132,7 @@ public:
 
        msg_error_t dbSelectWithQuery(const char *query, char ***db_res, int *row_count, int *col_count);
        void dbFree(char **db_res);
+       msg_error_t allowTcsMessage(msg_message_id_t MsgId);
 
        msg_error_t getRejectMsgList(const char *pNumber, msg_struct_list_s *pRejectMsgList);
        msg_error_t regStorageChangeCallback(msg_storage_change_cb onStorageChange, void *pUserParam);
index 8710602..7407a6e 100755 (executable)
@@ -2904,6 +2904,18 @@ int msg_media_item_get_int(void *data, int field, int *value)
        case MSG_MEDIA_MESSAGE_ID_INT:
                *value = pMedia->msg_id;
                break;
+       case MSG_MEDIA_TCS_LEVEL_INT:
+               *value = pMedia->tcs_level;
+               break;
+       case MSG_MEDIA_MALWARE_ALLOW_INT:
+               *value = pMedia->malware_allow;
+               break;
+       case MSG_MEDIA_THUMBNAIL_TCS_LEVEL_INT:
+               *value = pMedia->thumb_tcs_level;
+               break;
+       case MSG_MEDIA_THUMBNAIL_MALWARE_ALLOW_INT:
+               *value = pMedia->thumb_malware_allow;
+               break;
        default:
                ret = MSG_ERR_INVALID_PARAMETER;
                break;
@@ -2911,3 +2923,22 @@ int msg_media_item_get_int(void *data, int field, int *value)
 
        return ret;
 }
+
+EXPORT_API int msg_allow_tcs_message(msg_handle_t handle, msg_message_id_t msg_id)
+{
+       msg_error_t err =  MSG_SUCCESS;
+
+       if (handle == NULL) {
+               return MSG_ERR_INVALID_PARAMETER;
+       }
+
+       try {
+               MsgHandle* pHandle = (MsgHandle*)handle;
+               err = pHandle->allowTcsMessage(msg_id);
+       } catch (MsgException& e) {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_STORAGE_ERROR;
+       }
+
+       return err;
+}
index 9f1a33c..add0c6d 100755 (executable)
@@ -187,14 +187,27 @@ 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 || pMsgInfo->networkStatus == MSG_NETWORK_SENDING) { /* draft update */
-                       err = MmsPluginStorage::instance()->updateMessage(pMsgInfo, pSendOptInfo, pFileData);
+               if (pFileData && strcmp(pFileData, MSG_TCS_MESSAGE) == 0) {
+                       MSG_DEBUG("Update TCS Message");
+
+                       if (pMsgInfo->networkStatus == MSG_NETWORK_RETRIEVE_SUCCESS
+                                       && (pMsgInfo->msgType.subType == MSG_RETRIEVE_AUTOCONF_MMS
+                                               || pMsgInfo->msgType.subType == MSG_RETRIEVE_MANUALCONF_MMS)) {
+                               MmsPluginStorage::instance()->updateMessage(pMsgInfo);
+                       } else {
+                               MSG_ERR("It is Not valid status, network = %d, subtype = %d", pMsgInfo->networkStatus, pMsgInfo->msgType.subType);
+                               return MSG_ERR_INVALID_PARAMETER;
+                       }
                } else {
-                       /* [Update Message ID & File path only in case of retrieve. Else update Message ID] */
-                       if (pMsgInfo->msgType.subType == MSG_RETRIEVE_AUTOCONF_MMS || pMsgInfo->msgType.subType == MSG_RETRIEVE_MANUALCONF_MMS) { /* retrieve conf */
-                               err = MmsPluginStorage::instance()->updateConfMessage(pMsgInfo);
+                       if (pMsgInfo->networkStatus == MSG_NETWORK_NOT_SEND || pMsgInfo->networkStatus == MSG_NETWORK_SENDING) { /* draft update */
+                               err = MmsPluginStorage::instance()->updateMessage(pMsgInfo, pSendOptInfo, pFileData);
                        } else {
-                               err = MmsPluginStorage::instance()->updateMsgServerID(pMsgInfo, pSendOptInfo); /* update send conf */
+                               /* [Update Message ID & File path only in case of retrieve. Else update Message ID] */
+                               if (pMsgInfo->msgType.subType == MSG_RETRIEVE_AUTOCONF_MMS || pMsgInfo->msgType.subType == MSG_RETRIEVE_MANUALCONF_MMS) { /* retrieve conf */
+                                       err = MmsPluginStorage::instance()->updateConfMessage(pMsgInfo);
+                               } else {
+                                       err = MmsPluginStorage::instance()->updateMsgServerID(pMsgInfo, pSendOptInfo); /* update send conf */
+                               }
                        }
                }
        } catch (MsgException& e) {
index 7e1d989..ab2f93c 100755 (executable)
@@ -1968,3 +1968,42 @@ void MsgHandle::dbFree(char **db_res)
        MsgStoDbFree(db_res);
        MSG_END();
 }
+
+
+msg_error_t MsgHandle::allowTcsMessage(msg_message_id_t MsgId)
+{
+       MSG_BEGIN();
+       int cmdSize = sizeof(MSG_CMD_S) + sizeof(msg_message_id_t);
+
+       char cmdBuf[cmdSize];
+       bzero(cmdBuf, cmdSize);
+       MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
+
+       /* Set Command Parameters */
+       pCmd->cmdType = MSG_CMD_ALLOW_TCS_MESSAGE;
+
+       /* Copy Cookie */
+       memcpy((void*)pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
+
+       /* Copy Command Data */
+       memcpy((void*)((char*)pCmd + sizeof(MSG_CMD_TYPE_T) + MAX_COOKIE_LEN), &MsgId, sizeof(msg_message_id_t));
+
+       /* Send Command to Messaging FW */
+       char* pEventData = NULL;
+       unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
+
+       write((char*)pCmd, cmdSize, &pEventData);
+
+       /* Get Return Data */
+       MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
+
+       if (pEvent == NULL) {
+               THROW(MsgException::INVALID_RESULT, "Event is NULL");
+       }
+
+       if (pEvent->eventType != MSG_EVENT_ALLOW_TCS_MESSAGE) {
+               THROW(MsgException::INVALID_RESULT, "Event Data Error");
+       }
+
+       return pEvent->result;
+}
index 4ad72be..4e426f7 100755 (executable)
@@ -216,6 +216,8 @@ const char * MsgDbgCmdStr(MSG_CMD_TYPE_T cmdType)
        case MSG_CMD_PLG_CHECK_UNIQUENESS:
                return "MSG_CMD_PLG_CHECK_UNIQUENESS";
 #endif
+       case MSG_CMD_ALLOW_TCS_MESSAGE:
+               return "MSG_CMD_ALLOW_TCS_MESSAGE";
        case MSG_CMD_CHECK_PERMISSION:
                return "MSG_CMD_CHECK_PERMISSION";
        case MSG_CMD_REG_THREAD_CHANGE_CB:
@@ -425,6 +427,8 @@ const char * MsgDbgEvtStr(MSG_EVENT_TYPE_T evtType)
        case MSG_EVENT_PLG_CHECK_UNIQUENESS:
                return "MSG_EVENT_PLG_CHECK_UNIQUENESS";
 #endif
+       case MSG_EVENT_ALLOW_TCS_MESSAGE:
+               return "MSG_EVENT_ALLOW_TCS_MESSAGE";
        case MSG_EVENT_CHECK_PERMISSION:
                return "MSG_EVENT_CHECK_PERMISSION";
 
index f2645fd..111215f 100755 (executable)
@@ -2916,7 +2916,7 @@ msg_error_t MsgStoGetMediaList(const msg_thread_id_t threadId, msg_list_handle_t
 
        for (int i = 0; i < msgIdCnt; i++) {
                memset(sqlQuery, 0x00, sizeof(sqlQuery));
-               snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID, CONTENT_TYPE, FILE_PATH, THUMB_FILE_PATH "
+               snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID, TCS_LEVEL, MALWARE_ALLOW, CONTENT_TYPE, FILE_PATH, THUMB_FILE_PATH, TCS_LEVEL, MALWARE_ALLOW "
                                "FROM %s WHERE MSG_ID = %d AND SEQ <> -1 AND (TCS_LEVEL = -1 OR MALWARE_ALLOW = 1);",
                                MSGFW_MMS_MULTIPART_TABLE_NAME, msgIds[i]);
 
@@ -2930,16 +2930,21 @@ msg_error_t MsgStoGetMediaList(const msg_thread_id_t threadId, msg_list_handle_t
                }
 
                MSG_MEDIA_INFO_S *pMedia = NULL;
+               int tcs_level = -1, malware_allow = 0, thumb_tcs_level = -1, thumb_malware_allow = 0;
                char mime_type[MAX_MIME_TYPE_LEN+1], media_item[MSG_FILEPATH_LEN_MAX+1], thumb_path[MSG_FILEPATH_LEN_MAX+1];
 
                for (int j = 0; j < rowCnt; j++) {
                        msg_id = dbHandle->getColumnToInt(index++);
+                       tcs_level = dbHandle->getColumnToInt(index++);
+                       malware_allow = dbHandle->getColumnToInt(index++);
                        memset(mime_type, 0x00, sizeof(mime_type));
                        dbHandle->getColumnToString(index++, MAX_MIME_TYPE_LEN, mime_type);
                        memset(media_item, 0x00, sizeof(media_item));
                        dbHandle->getColumnToString(index++, MSG_FILEPATH_LEN_MAX, media_item);
                        memset(thumb_path, 0x00, sizeof(thumb_path));
                        dbHandle->getColumnToString(index++, MSG_FILEPATH_LEN_MAX, thumb_path);
+                       thumb_tcs_level = dbHandle->getColumnToInt(index++);
+                       thumb_malware_allow = dbHandle->getColumnToInt(index++);
 
                        if (strstr(mime_type, "image") || strstr(mime_type, "video")) {
                                msg_struct_s *media_struct_s = new msg_struct_s;
@@ -2950,9 +2955,13 @@ msg_error_t MsgStoGetMediaList(const msg_thread_id_t threadId, msg_list_handle_t
                                pMedia = (MSG_MEDIA_INFO_S *)media_struct_s->data;
 
                                pMedia->msg_id = msg_id;
+                               pMedia->tcs_level = tcs_level;
+                               pMedia->malware_allow = malware_allow;
                                snprintf(pMedia->mime_type, MAX_MIME_TYPE_LEN, "%s", mime_type);
                                snprintf(pMedia->media_item, MSG_FILEPATH_LEN_MAX, "%s", media_item);
                                snprintf(pMedia->thumb_path, MSG_FILEPATH_LEN_MAX, "%s", thumb_path);
+                               pMedia->thumb_tcs_level = thumb_tcs_level;
+                               pMedia->thumb_malware_allow = thumb_malware_allow;
 
                                media_list = g_list_append(media_list, media_struct_s);
                        }