Add load/update dnd_allow_exception routine 52/87952/1 accepted/tizen/common/20160922.120900 submit/tizen/20160922.051802
authorMyungki Lee <mk5004.lee@samsung.com>
Mon, 12 Sep 2016 08:59:00 +0000 (17:59 +0900)
committerMyungki Lee <mk5004.lee@samsung.com>
Mon, 12 Sep 2016 08:59:00 +0000 (17:59 +0900)
Change-Id: Id0bc75db2a1e99458c1f644f51fc713466cf4477
Signed-off-by: Myungki Lee <mk5004.lee@samsung.com>
include/notification_service.h
src/notification_service.c

index 9dca6c5..8d771c1 100755 (executable)
@@ -40,6 +40,8 @@ int notification_add_noti_template(GVariant *parameters, GVariant **reply_body,
 int notification_get_noti_template(GVariant *parameters, GVariant **reply_body, pid_t pid, uid_t uid);
 int notification_get_noti_package_template(GVariant *parameters, GVariant **reply_body, uid_t uid);
 int notification_get_block_state(GVariant *parameters, GVariant **reply_body, uid_t uid);
+int notification_load_dnd_allow_exception(GVariant *parameters, GVariant **reply_body, uid_t uid);
+int notification_update_dnd_allow_exception(GVariant *parameters, GVariant **reply_body, uid_t uid);
 int notification_register_dbus_interface();
 
 /* End of a file */
index 702f67c..0eb8b89 100755 (executable)
@@ -137,6 +137,10 @@ static void _noti_dbus_method_call_handler(GDBusConnection *conn,
                ret = notification_get_noti_package_template(parameters, &reply_body, uid);
        else if (g_strcmp0(method_name, "get_noti_block_state") == 0)
                ret = notification_get_block_state(parameters, &reply_body, uid);
+       else if (g_strcmp0(method_name, "load_dnd_allow_exception") == 0)
+               ret = notification_load_dnd_allow_exception(parameters, &reply_body, uid);
+       else if (g_strcmp0(method_name, "update_dnd_allow_exception") == 0)
+               ret = notification_update_dnd_allow_exception(parameters, &reply_body, uid);
 
        if (ret == NOTIFICATION_ERROR_NONE) {
                DbgPrint("notification service success : %d", ret);
@@ -297,6 +301,18 @@ int notification_register_dbus_interface()
                        "          <arg type='v' name='state' direction='out'/>"
                        "        </method>"
 
+                       "        <method name='update_dnd_allow_exception'>"
+                       "          <arg type='i' name='type' direction='in'/>"
+                       "          <arg type='i' name='value' direction='in'/>"
+                       "          <arg type='i' name='uid' direction='in'/>"
+                       "        </method>"
+
+                       "        <method name='load_dnd_allow_exception'>"
+                       "          <arg type='i' name='uid' direction='in'/>"
+                       "          <arg type='i' name='count' direction='out'/>"
+                       "          <arg type='a(v)' name='dnd_allow_exception' direction='out'/>"
+                       "        </method>"
+
                        "        <method name='post_toast'>"
                        "        </method>"
                        "  </interface>"
@@ -714,6 +730,7 @@ int notification_load_system_setting(GVariant *parameters, GVariant **reply_body
        notification_system_setting_h setting = NULL;
        uid_t param_uid;
 
+
        g_variant_get(parameters, "(i)", &param_uid);
        ret = _validate_and_set_param_uid_with_uid(uid, &param_uid);
        if (ret != NOTIFICATION_ERROR_NONE)
@@ -1432,6 +1449,82 @@ int notification_get_block_state(GVariant *parameters, GVariant **reply_body, ui
        DbgPrint("get notification block state done");
        return ret;
 }
+int notification_load_dnd_allow_exception(GVariant *parameters, GVariant **reply_body, uid_t uid)
+{
+       int ret;
+       int count = 0;
+       int i;
+       uid_t param_uid;
+       GVariant *body = NULL;
+       GVariantBuilder *builder;
+       dnd_allow_exception_h dnd_allow_exception = NULL;
+       dnd_allow_exception_h temp;
+
+       g_variant_get(parameters, "(i)", &param_uid);
+
+       ret = _validate_and_set_param_uid_with_uid(uid, &param_uid);
+       if (ret != NOTIFICATION_ERROR_NONE)
+               return ret;
+
+       ret = notification_system_setting_load_dnd_allow_exception(&dnd_allow_exception, &count, param_uid);
+       if (ret != NOTIFICATION_ERROR_NONE) {
+               ErrPrint("failed to load dnd_allow_exception : %d", ret);
+               return ret;
+       }
+
+       builder = g_variant_builder_new(G_VARIANT_TYPE("a(v)"));
+
+       if (dnd_allow_exception) {
+               for (i = 0; i < count; i++) {
+                       temp = dnd_allow_exception + i;
+                       body = notification_ipc_make_gvariant_from_dnd_allow_exception(temp);
+                       g_variant_builder_add(builder, "(v)", body);
+               }
+               free(dnd_allow_exception);
+       }
+
+       *reply_body = g_variant_new("(ia(v))", count, builder);
+       g_variant_builder_unref(builder);
+
+       if (*reply_body == NULL) {
+               ErrPrint("cannot make reply_body");
+               return NOTIFICATION_ERROR_OUT_OF_MEMORY;
+       }
+
+       DbgPrint("load dnd_allow_exception");
+       return ret;
+}
+
+int notification_update_dnd_allow_exception(GVariant *parameters, GVariant **reply_body, uid_t uid)
+{
+       int ret;
+       int type;
+       int value;
+       uid_t param_uid;
+
+       g_variant_get(parameters, "(iii)", &type, &value, &param_uid);
+
+       ret = _validate_and_set_param_uid_with_uid(uid, &param_uid);
+       if (ret != NOTIFICATION_ERROR_NONE)
+               return ret;
+
+       ret = notification_system_setting_update_dnd_allow_exception(type,
+                       value,
+                       param_uid);
+       if (ret != NOTIFICATION_ERROR_NONE) {
+               ErrPrint("failed to update dnd_allow_exception : %d", ret);
+               return ret;
+       }
+
+       *reply_body = g_variant_new("()");
+       if (*reply_body == NULL) {
+               ErrPrint("cannot make reply_body");
+               return NOTIFICATION_ERROR_OUT_OF_MEMORY;
+       }
+
+       DbgPrint("update dnd_allow_exception");
+       return ret;
+}
 
 static void _notification_data_init(void)
 {