From: Kyeonghun Lee Date: Fri, 23 Dec 2016 05:39:47 +0000 (+0900) Subject: add code for dpm restriction toast X-Git-Tag: submit/tizen_3.0/20161226.023614~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F90%2F106790%2F3;p=platform%2Fcore%2Fmessaging%2Fmsg-service.git add code for dpm restriction toast - security team request Change-Id: Id74d997a77009728296a6e94e75f4c0b57a05ee4 Signed-off-by: Kyeonghun Lee --- diff --git a/framework/submit-handler/MsgSubmitHandler.cpp b/framework/submit-handler/MsgSubmitHandler.cpp index 82d0d20..aba0c2d 100755 --- a/framework/submit-handler/MsgSubmitHandler.cpp +++ b/framework/submit-handler/MsgSubmitHandler.cpp @@ -43,6 +43,13 @@ msg_error_t MsgSubmitReq(MSG_REQUEST_INFO_S *pReqInfo, bool bScheduled) 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; } diff --git a/include/utils/MsgUtilFunction.h b/include/utils/MsgUtilFunction.h index 82ded6e..8c3b05b 100755 --- a/include/utils/MsgUtilFunction.h +++ b/include/utils/MsgUtilFunction.h @@ -168,4 +168,6 @@ void msg_set_dpm_policy(int type, int state); bool msg_check_dpm_policy(int type); +void msg_syspopup_message(bool is_sending); + #endif /* MSG_UTIL_FUNCTION_H */ diff --git a/utils/MsgUtilFunction.cpp b/utils/MsgUtilFunction.cpp index 554dbf6..fa8ff5a 100755 --- a/utils/MsgUtilFunction.cpp +++ b/utils/MsgUtilFunction.cpp @@ -30,6 +30,7 @@ #include #include #include +#include typedef struct _msg_launch_app_data { char *app_id; @@ -38,6 +39,11 @@ typedef struct _msg_launch_app_data { #define DEFAULT_MIN_MATCH_DIGIT 8 +#define SYSPOPUP_BUS_NAME "org.tizen.DevicePolicyManager" +#define SYSPOPUP_OBJECT_PATH "/org/tizen/DevicePolicyManager/Syspopup" +#define SYSPOPUP_INTERFACE "org.tizen.DevicePolicyManager.Syspopup" +#define SYSPOPUP_METHOD_SHOW "show" + enum _FEATURE_INDEX_E { FEATURE_INDEX_SMS = 0, FEATURE_INDEX_MMS = 1, @@ -1331,3 +1337,55 @@ bool msg_check_dpm_policy(int type) // return dpm_policy_enable[type]; } + +void msg_syspopup_message(bool is_sending) +{ + MSG_DEBUG("popup toast for dpm restriction. is_sending [%d]", is_sending); + + GDBusConnection *connection = NULL; + GDBusProxy *dbus_proxy = NULL; + GVariant *result = NULL; + GError *error = NULL; + + connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error); + if (error) { + MSG_ERR("Connecting to system bus failed: %s\n", error->message); + goto _DBUS_ERROR; + } + + dbus_proxy = g_dbus_proxy_new_sync(connection, G_DBUS_PROXY_FLAGS_NONE, NULL, + SYSPOPUP_BUS_NAME, SYSPOPUP_OBJECT_PATH, SYSPOPUP_INTERFACE, NULL, &error); + if (error) { + MSG_ERR("Connecting to proxy failed: %s\n", error->message); + goto _DBUS_ERROR; + } + + result = g_dbus_proxy_call_sync(dbus_proxy, SYSPOPUP_METHOD_SHOW, + g_variant_new("(s)", is_sending ? "message-sending" : "message-retrieving"), + G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); + if (error) { + MSG_ERR("invoking proxy call failed: %s\n", error->message); + goto _DBUS_ERROR; + } + +_DBUS_ERROR: + if (error) { + g_error_free(error); + error = NULL; + } + + if (connection) { + g_object_unref(connection); + connection = NULL; + } + + if (dbus_proxy) { + g_object_unref(dbus_proxy); + dbus_proxy = NULL; + } + + if (result) { + g_object_unref(result); + result = NULL; + } +}