modules/information/do_not_disturb: Implemented. 93/80693/5 accepted/tizen/mobile/20161015.000523 submit/tizen/20161012.154048 submit/tizen/20161014.073410 submit/tizen_3.0/20161012.154009
authorRadoslaw Czerski <r.czerski@samsung.com>
Wed, 12 Oct 2016 06:03:46 +0000 (08:03 +0200)
committerLukasz Stanislawski <l.stanislaws@samsung.com>
Wed, 12 Oct 2016 13:48:31 +0000 (06:48 -0700)
Change-Id: I6c8f4da54525b4eba2cbc834a1686d6ece6d0456
Signed-off-by: Radoslaw Czerski <r.czerski@samsung.com>
inc/indicator.h
res/resource/icons/Do_Not_Disturb/b03_event_dnd.png [new file with mode: 0644]
src/modules/modules.c
src/modules/setting/do_not_disturb.c [new file with mode: 0644]

index 78698a8..6ae4b79 100644 (file)
@@ -63,7 +63,7 @@ enum {
        /* Right Side */
        INDICATOR_PRIORITY_SYSTEM_MIN,
        INDICATOR_PRIORITY_SYSTEM_1 = INDICATOR_PRIORITY_SYSTEM_MIN, /* SYSTEM - Alarm */
-       INDICATOR_PRIORITY_SYSTEM_2, /* SYSTEM - Call divert */
+       INDICATOR_PRIORITY_SYSTEM_2, /* SYSTEM - Do not disturb */
        INDICATOR_PRIORITY_SYSTEM_3, /* SYSTEM - MMC */
        INDICATOR_PRIORITY_SYSTEM_4,  /* SYSTEM - GPS */
        INDICATOR_PRIORITY_SYSTEM_5,  /* SYSTEM - Private mode */
diff --git a/res/resource/icons/Do_Not_Disturb/b03_event_dnd.png b/res/resource/icons/Do_Not_Disturb/b03_event_dnd.png
new file mode 100644 (file)
index 0000000..80f71a4
Binary files /dev/null and b/res/resource/icons/Do_Not_Disturb/b03_event_dnd.png differ
index 4cb5e21..344b189 100644 (file)
@@ -17,7 +17,6 @@
  *
  */
 
-
 #include "common.h"
 #include "modules.h"
 
@@ -52,6 +51,7 @@ extern icon_s silent;
 extern icon_s bluetooth;
 extern icon_s gps;
 extern icon_s nfc;
+extern icon_s dnd;
 
 /* Clock */
 extern icon_s sysclock;
@@ -105,6 +105,7 @@ static icon_s *modules[] = {
        &bluetooth,
        &gps,
        &nfc,
+       &dnd,
 
        /*Smart Stay*/
        &earphone,
diff --git a/src/modules/setting/do_not_disturb.c b/src/modules/setting/do_not_disturb.c
new file mode 100644 (file)
index 0000000..78b877a
--- /dev/null
@@ -0,0 +1,115 @@
+/*
+ *  Indicator
+ *
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <notification_setting_internal.h>
+#include "icon.h"
+#include "log.h"
+#include "common.h"
+
+#define MODULE_NAME "do_not_disturb"
+#define ICON_PRIORITY INDICATOR_PRIORITY_SYSTEM_2
+#define DND_ICON_PATH "Do_Not_Disturb/b03_event_dnd.png"
+
+static int dnd_register_dnd_module(void *data);
+static int dnd_unregister_dnd_module(void);
+
+icon_s dnd = {
+       .type = INDICATOR_IMG_ICON,
+       .name = MODULE_NAME,
+       .priority = ICON_PRIORITY,
+       .always_top = EINA_FALSE,
+       .exist_in_view = EINA_FALSE,
+       .img_obj = {0,},
+       .img_obj.data = DND_ICON_PATH,
+       .obj_exist = EINA_FALSE,
+       .area = INDICATOR_ICON_AREA_SYSTEM,
+       .init = dnd_register_dnd_module,
+       .fini = dnd_unregister_dnd_module,
+};
+
+
+static void _dnd_image_icon_state_change(bool state)
+{
+       if (state)
+               icon_show(&dnd);
+       else
+               icon_hide(&dnd);
+
+
+}
+
+
+static void _dnd_cb(void *user_data, int do_not_disturb)
+{
+       _D("_dnd_cb");
+       _dnd_image_icon_state_change(do_not_disturb);
+}
+
+
+static int dnd_enabled_check()
+{
+       notification_system_setting_h setting;
+       int ret = NOTIFICATION_ERROR_NONE;
+
+       bool dnd = false;
+
+       ret = notification_system_setting_load_system_setting(&setting);
+       retvm_if(ret != NOTIFICATION_ERROR_NONE, FAIL,
+                       "notification_system_setting_load_system_setting failed[%d]:%s",
+                       ret, get_error_message(ret));
+
+       ret = notification_system_setting_get_do_not_disturb(setting, &dnd);
+       if (ret != NOTIFICATION_ERROR_NONE) {
+               _E("notification_system_setting_load_system_setting failed[%d]:%s",
+                               ret, get_error_message(ret));
+
+               notification_system_setting_free_system_setting(setting);
+               return FAIL;
+       }
+
+       _dnd_image_icon_state_change(dnd);
+
+       notification_system_setting_free_system_setting(setting);
+
+       return OK;
+}
+
+
+static int dnd_register_dnd_module(void *data)
+{
+       _D("dnd_register_dnd_module");
+       int ret;
+       ret = notification_register_system_setting_dnd_changed_cb(_dnd_cb, data);
+       retvm_if(ret != NOTIFICATION_ERROR_NONE, FAIL,
+                       "notification_register_system_setting_dnd_changed_cb failed[%d]:%s",
+                       ret, get_error_message(ret));
+
+       ret = dnd_enabled_check();
+       if (ret != NOTIFICATION_ERROR_NONE)
+               _E("dnd_enabled_check failed[%d]:%s", ret, get_error_message(ret));
+
+       return OK;
+}
+
+
+static int dnd_unregister_dnd_module(void)
+{
+       notification_unregister_system_setting_dnd_changed_cb(_dnd_cb);
+       return OK;
+}