add code for dpm restriction toast 90/106790/3
authorKyeonghun Lee <kh9090.lee@samsung.com>
Fri, 23 Dec 2016 05:39:47 +0000 (14:39 +0900)
committerKyeonghun Lee <kh9090.lee@samsung.com>
Fri, 23 Dec 2016 05:44:11 +0000 (14:44 +0900)
- security team request

Change-Id: Id74d997a77009728296a6e94e75f4c0b57a05ee4
Signed-off-by: Kyeonghun Lee <kh9090.lee@samsung.com>
framework/submit-handler/MsgSubmitHandler.cpp
include/utils/MsgUtilFunction.h
utils/MsgUtilFunction.cpp

index 82d0d20..aba0c2d 100755 (executable)
@@ -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;
        }
 
index 82ded6e..8c3b05b 100755 (executable)
@@ -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 */
index 554dbf6..fa8ff5a 100755 (executable)
@@ -30,6 +30,7 @@
 #include <ctype.h>
 #include <aul.h>
 #include <aul_svc.h>
+#include <gio/gio.h>
 
 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;
+       }
+}