TizenRefApp-8713 Three Calendar and Contacts apps in App notifications list 61/144961/7 submit/tizen/20170822.091039
authorEvgen Servetnik <e.servetnik@samsung.com>
Fri, 18 Aug 2017 14:08:13 +0000 (17:08 +0300)
committerEvgen Servetnik <e.servetnik@samsung.com>
Tue, 22 Aug 2017 07:58:28 +0000 (10:58 +0300)
Change-Id: I43240d1e3a089e53857cdd827deabbe68cf729fa
Signed-off-by: Evgen Servetnik <e.servetnik@samsung.com>
inc/app-setting-info.h
inc/notification-setting-info.h
src/app-details.c
src/app-setting-info.c
src/excepted-apps-efl.c
src/list_notification.c [new file with mode: 0644]
src/notification-setting-info.c

index d8bd09954b7cae52ab34661e7dad51d862288ae4..847cd09a07561a94c52bfbd52ef04feebad773c2 100755 (executable)
 
 #include <tizen.h>
 #include "log.h"
-
 /**
  * @brief A data-structure that represents a notification settings for a specific application.
  */
 typedef struct {
+       char *package_id;
        char *appid;                /**< @brief Application's package name.*/
        char *name;                 /**< @brief Application's display name.*/
        char *icon;                 /**< @brief Path to application's icon.*/
@@ -45,11 +45,10 @@ HAPI int apps_sort_cb(const void *d1, const void *d2);
 
 /**
  * @brief A function is set to item its name and icon path by using application id
- * @param[in] appid application id.
  * @param[in] app_data item.
  * @see item_info_s
  */
-HAPI void get_app_info(const char *appid, item_info_s *app_data);
+HAPI void get_app_info(item_info_s *app_data);
 
 
 #endif //__APP_SETTING_INFO_H__
index d3014e49f522e5423a18d1484eb8024e951a4ef2..cb5594972454b9f9a938f31a453760cd62cd88fe 100755 (executable)
@@ -87,4 +87,8 @@ void remove_apps_noti_blocked_list();
 void remove_excepted_apps_list();
 void update_apps_settings_info();
 
+Eina_List *create_base_app_notification_list();
+
+void free_item_info(item_info_s *item_info);
+
 #endif /* __NOTIFICATION_SETTING_INFO_H__ */
index 5a0348418c2be6eef9f7ace53d9a88a07d86ecfc..aa5c08fea6bc53a3a69f88c514877a8c67e81291 100644 (file)
@@ -50,12 +50,12 @@ static void close_app_details_cb(void *data, Evas_Object *obj, void *event_info)
 
 static Eina_Bool allow_noti_status_get()
 {
-       return get_allow_to_nofity(g_app_info->appid);
+       return get_allow_to_nofity(g_app_info->package_id);
 }
 
 static void allow_noti_status_set(Eina_Bool value)
 {
-       set_allow_to_nofity(g_app_info->appid, value);
+       set_allow_to_nofity(g_app_info->package_id, value);
 }
 
 static void allow_noti_check_changed_cb(void *data, Evas_Object *obj, void *event_info)
@@ -71,7 +71,7 @@ static Eina_Bool popup_noti_status_get()
        bool state = false;
        notification_setting_h setting = NULL;
 
-       int err = notification_setting_get_setting_by_package_name(g_app_info->appid, &setting);
+       int err = notification_setting_get_setting_by_package_name(g_app_info->package_id, &setting);
        if (err != NOTIFICATION_ERROR_NONE) {
                NOTISET_ERR("notification_setting_get_setting_by_package_name [%d]\n", err);
        } else if (setting == NULL) {
@@ -92,7 +92,7 @@ static void popup_noti_status_set(Eina_Bool value)
        NOTISET_TRACE_BEGIN;
        notification_setting_h setting = NULL;
 
-       int err = notification_setting_get_setting_by_package_name(g_app_info->appid, &setting);
+       int err = notification_setting_get_setting_by_package_name(g_app_info->package_id, &setting);
        if (err != NOTIFICATION_ERROR_NONE) {
                NOTISET_ERR("notification_setting_get_setting_by_package_name [%d]\n", err);
        } else if (setting == NULL) {
@@ -175,7 +175,7 @@ static int noti_on_lock_screen_status_get()
        lock_screen_content_level_e level = SHOW_ALL_CONTENT;
        notification_setting_h setting = NULL;
 
-       int err = notification_setting_get_setting_by_package_name(g_app_info->appid, &setting);
+       int err = notification_setting_get_setting_by_package_name(g_app_info->package_id, &setting);
        if (err != NOTIFICATION_ERROR_NONE) {
                NOTISET_ERR("notification_setting_get_setting_by_package_name [%d]\n", err);
        } else if (setting == NULL) {
@@ -331,7 +331,7 @@ static void gl_radio_sel_cb(void *data, Evas_Object *obj, void *event_info)
        int index = (uintptr_t)elm_object_item_data_get(it);
        elm_radio_value_set(radio, index);
 
-       int err = notification_setting_get_setting_by_package_name(g_app_info->appid, &setting);
+       int err = notification_setting_get_setting_by_package_name(g_app_info->package_id, &setting);
        if (err != NOTIFICATION_ERROR_NONE) {
                NOTISET_ERR("notification_setting_get_setting_by_package_name [%d]\n", err);
        } else if (setting == NULL) {
index fbdcd000ed22c3288cd14138da9e87ffad5c263d..996e06078d4f88a6f23922a725388d123adbca51 100755 (executable)
@@ -31,10 +31,10 @@ int apps_sort_cb(const void *d1, const void *d2)
        return strcmp(tmp1->name, tmp2->name);
 }
 
-HAPI void get_app_info(const char *appid, item_info_s *app_data)
+HAPI void get_app_info(item_info_s *app_data)
 {
        app_info_h app_info;
-       int error_code = app_info_create(appid, &app_info);
+       int error_code = app_info_create(app_data->appid, &app_info);
        if (error_code == APP_MANAGER_ERROR_NONE) {
                error_code = app_info_get_label(app_info, &app_data->name);
                if (error_code != APP_MANAGER_ERROR_NONE)
index a0bf66b3c443ea26216a35a6471842667bcd1c7a..e26e1a8d1bc0aca95f754c69cce4768467bff641 100755 (executable)
@@ -89,7 +89,7 @@ void _excepted_check_changed_cb(void *data, Evas_Object *obj, void *event_info)
        data_list->do_not_disturb_except = state;
        is_need_to_update = is_list_main_need_to_be_update(data_list);
 
-       NOTISET_DBG("appid = %s state = %d", data_list->appid, state);
+       NOTISET_DBG("appid = %s state = %d", data_list->package_id, state);
 }
 
 static void _done_button_cb(void *data, Evas_Object *obj, void *event_info)
diff --git a/src/list_notification.c b/src/list_notification.c
new file mode 100644 (file)
index 0000000..a81c06f
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+* Copyright 2017 Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.1 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://floralicense.org/license/
+*
+* 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-info.h"
+
+static item_info_s *create_item_info(notification_setting_h notification_setting_item, int index) {
+       item_info_s *item_info = NULL;
+       item_info = calloc(1, sizeof(item_info_s));
+       if (!item_info)
+               return NULL;
+
+       notification_setting_get_package_name(notification_setting_item, &item_info->package_id);
+       if (!item_info->package_id) {
+               free_item_info(item_info);
+               return NULL;
+       }
+
+       notification_setting_get_allow_to_notify(notification_setting_item, &item_info->allow_to_notify);
+
+       notification_setting_get_do_not_disturb_except(notification_setting_item, &item_info->do_not_disturb_except);
+
+       notification_setting_get_appid(notification_setting_item, &item_info->appid);
+
+       if (!item_info->appid) {
+               free_item_info(item_info);
+               return NULL;
+       }
+
+       get_app_info(item_info);
+       item_info->index = index;
+       return item_info;
+}
+
+Eina_List *create_base_app_notification_list(){
+       Eina_List *app_notification = NULL;
+       Eina_List *l = NULL;
+       int count = 0;
+       bool is_found = false;
+       void *data;
+       notification_setting_h setting_array = NULL;
+       notification_setting_h current_notification_setting = NULL;
+       notification_setting_get_setting_array(&setting_array, &count);
+       if (!count)
+               return NULL;
+
+       for (int i = 0; i < count; i++) {
+               is_found = false;
+               current_notification_setting = setting_array + i;
+               char *package_name = NULL;
+               notification_setting_get_package_name(current_notification_setting, &package_name);
+               if(!package_name)
+                       continue;
+               EINA_LIST_FOREACH(app_notification, l, data) {
+                       item_info_s *current_list_element = (item_info_s *)data;
+                       if (!current_list_element)
+                               break;
+
+                       if (!strcmp(package_name, current_list_element->package_id)) {
+                               is_found = true;
+                               break;
+                       }
+               }
+               FREEIF(package_name);
+               if (!is_found) {
+                       item_info_s *info = create_item_info(current_notification_setting, i);
+                       if (info)
+                               app_notification = eina_list_append(app_notification, info);
+               }
+       }
+       notification_setting_free_notification(setting_array);
+       return app_notification;
+}
index 77a9e0d4f5d0acf5270d6356c5de09f916a77051..a0eae4f4185e46d4883d3995193e4fe0d6308a6f 100755 (executable)
@@ -31,61 +31,35 @@ setting_info_s *setting_info = NULL;
 Eina_Bool create_app_notification_list()
 {
        NOTISET_TRACE_BEGIN;
-       int i = 0;
-       int count = 0;
-       char *app_id = NULL;
-       bool allow_to_notify = false;
-       bool do_not_disturb_except = false;
-       notification_setting_h setting_array = NULL;
-       notification_setting_h temp = NULL;
        item_info_s *item_info = NULL;
 
+       Eina_List *not_excepted_list = NULL;
+       Eina_List *l = NULL;
+       void *data;
+
        remove_apps_noti_allowed_list();
        remove_apps_noti_blocked_list();
        setting_info = calloc(1, sizeof(setting_info_s));
        retv_if(!setting_info, EINA_FALSE);
 
-       notification_setting_get_setting_array(&setting_array, &count);
-       retv_if(!setting_array, EINA_FALSE);
-       NOTISET_DBG("count %d", count);
-
-       for (i = 0; i < count; i++) {
-               item_info = calloc(1, sizeof(item_info_s));
-               retv_if(!item_info, EINA_FALSE);
-
-               temp = setting_array + i;
-
-               notification_setting_get_appid(temp, &app_id);
-               item_info->appid = app_id;
-
-               notification_setting_get_allow_to_notify(temp, &allow_to_notify);
-               item_info->allow_to_notify = allow_to_notify;
-
-               notification_setting_get_do_not_disturb_except(temp, &do_not_disturb_except);
-               item_info->do_not_disturb_except = do_not_disturb_except;
-
-               get_app_info(app_id, item_info);
-
-               item_info->index = i;
+       not_excepted_list = create_base_app_notification_list();
 
-               if (item_info->name && strcmp(app_id, CALENDAR_PACKAGE)
-                                                       && strcmp(app_id, CLOCK_PACKAGE)
-                                                       && strcmp(app_id, PHONE_PACKAGE)) {
+       EINA_LIST_FOREACH(not_excepted_list, l, data) {
+               item_info = (item_info_s*) data;
+               if (item_info->name) {
                        if (item_info->allow_to_notify)
                                setting_info->apps_noti_allowed_list = eina_list_append(setting_info->apps_noti_allowed_list, item_info);
                        else
                                setting_info->apps_noti_blocked_list = eina_list_append(setting_info->apps_noti_blocked_list, item_info);
                } else {
-                       FREEIF(app_id);
-                       FREEIF(item_info->name);
-                       FREEIF(item_info->icon);
-                       FREEIF(item_info);
+                       free_item_info(item_info);
                }
        }
 
+       eina_list_free(not_excepted_list);
+
        setting_info->apps_noti_allowed_list = eina_list_sort(setting_info->apps_noti_allowed_list, eina_list_count(setting_info->apps_noti_allowed_list), apps_sort_cb);
        setting_info->apps_noti_blocked_list = eina_list_sort(setting_info->apps_noti_blocked_list, eina_list_count(setting_info->apps_noti_blocked_list), apps_sort_cb);
-       notification_setting_free_notification(setting_array);
        return EINA_TRUE;
 }
 
@@ -95,7 +69,7 @@ void update_app_notification_list_on_item(item_info_s *item_info)
 
        setting_info->apps_noti_allowed_list = eina_list_remove(setting_info->apps_noti_allowed_list, item_info);
        setting_info->apps_noti_blocked_list = eina_list_remove(setting_info->apps_noti_blocked_list, item_info);
-       if (get_allow_to_nofity(item_info->appid))
+       if (get_allow_to_nofity(item_info->package_id))
                setting_info->apps_noti_allowed_list = eina_list_sorted_insert(setting_info->apps_noti_allowed_list, apps_sort_cb, item_info);
        else
                setting_info->apps_noti_blocked_list = eina_list_sorted_insert(setting_info->apps_noti_blocked_list, apps_sort_cb, item_info);
@@ -104,81 +78,58 @@ void update_app_notification_list_on_item(item_info_s *item_info)
 void create_do_not_disturb_application_list()
 {
        NOTISET_TRACE_BEGIN;
-       int i = 0;
-       int count = 0;
-       char *app_id = NULL;
-       bool allow_to_notify = false;
-       bool do_not_disturb_except = false;
-       notification_setting_h setting_array = NULL;
-       notification_setting_h temp = NULL;
-
+       Eina_List *not_excepted_list = NULL;
+       Eina_List *l = NULL;
+       void *data;
+       item_info_s *item_info = NULL;
        remove_excepted_apps_list();
 
        setting_info = calloc(1, sizeof(setting_info_s));
        ret_if(!setting_info);
 
-       notification_setting_get_setting_array(&setting_array, &count);
-       ret_if(!setting_array);
-       NOTISET_DBG("count %d", count);
-
-       item_info_s *item_info = NULL;
-       for (i = 0; i < count; i++) {
-               item_info = calloc(1, sizeof(item_info_s));
-               if (item_info) {
-                       temp = setting_array + i;
-
-                       notification_setting_get_appid(temp, &app_id);
-                       item_info->appid = app_id;
-
-                       notification_setting_get_allow_to_notify(temp, &allow_to_notify);
-                       item_info->allow_to_notify = allow_to_notify;
+       not_excepted_list = create_base_app_notification_list();
 
-                       notification_setting_get_do_not_disturb_except(temp, &do_not_disturb_except);
-                       item_info->do_not_disturb_except = do_not_disturb_except;
-
-                       get_app_info(app_id, item_info);
-
-                       if (!strcmp(app_id, CALENDAR_PACKAGE))
-                               item_info->name = strdup(APP_STRING("IDS_COM_BODY_CALENDAR_EVENTS"));
-                       else if (!strcmp(app_id, CLOCK_PACKAGE))
-                               item_info->name = strdup(APP_STRING("IDS_ST_BODY_ALARMS"));
-
-                       item_info->index = i;
-
-                       if (item_info->name && strcmp(app_id, PHONE_PACKAGE)) {
-                               if ((allow_to_notify && !strcmp(app_id, MESSAGES_PACKAGE))
-                                               || !strcmp(app_id, CLOCK_PACKAGE)
-                                               || !strcmp(app_id, CALENDAR_PACKAGE)) {
-                                       setting_info->first_allowed_list = eina_list_append(setting_info->first_allowed_list, item_info);
-                                       if (do_not_disturb_except) {
-                                               setting_info->first_excepted_list = eina_list_append(setting_info->first_excepted_list, item_info);
-                                       }
+       EINA_LIST_FOREACH(not_excepted_list, l, data) {
+               item_info = (item_info_s*) data;
+               if (!strcmp(item_info->package_id, CALENDAR_PACKAGE)) {
+                       FREEIF(item_info->name);
+                       item_info->name = strdup(APP_STRING("IDS_COM_BODY_CALENDAR_EVENTS"));
+               }
+               if (!strcmp(item_info->package_id, CLOCK_PACKAGE)) {
+                       FREEIF(item_info->name);
+                       item_info->name = strdup(APP_STRING("IDS_ST_BODY_ALARMS"));
+               }
+               if (item_info->name && strcmp(item_info->package_id, PHONE_PACKAGE)) {
+                       if ((item_info->allow_to_notify && !strcmp(item_info->package_id, MESSAGES_PACKAGE))
+                                       || !strcmp(item_info->package_id, CLOCK_PACKAGE)
+                                       || !strcmp(item_info->package_id, CALENDAR_PACKAGE)) {
+                               setting_info->first_allowed_list = eina_list_append(setting_info->first_allowed_list, item_info);
+                               if (item_info->do_not_disturb_except) {
+                                       setting_info->first_excepted_list = eina_list_append(setting_info->first_excepted_list, item_info);
                                }
+                       }
 
-                               if (allow_to_notify && strcmp(app_id, MESSAGES_PACKAGE)
-                                                                       && strcmp(app_id, CALENDAR_PACKAGE)
-                                                                       && strcmp(app_id, CLOCK_PACKAGE)) {
-                                       if (do_not_disturb_except) {
-                                               setting_info->excepted_list = eina_list_append(setting_info->excepted_list, item_info);
-                                       } else {
-                                               setting_info->not_excepted_list = eina_list_append(setting_info->not_excepted_list, item_info);
-                                       }
+                       if (item_info->allow_to_notify && strcmp(item_info->package_id, MESSAGES_PACKAGE)
+                                                               && strcmp(item_info->package_id, CALENDAR_PACKAGE)
+                                                               && strcmp(item_info->package_id, CLOCK_PACKAGE)) {
+                               if (item_info->do_not_disturb_except) {
+                                       setting_info->excepted_list = eina_list_append(setting_info->excepted_list, item_info);
+                               } else {
+                                       setting_info->not_excepted_list = eina_list_append(setting_info->not_excepted_list, item_info);
                                }
-                       } else {
-                               FREEIF(app_id);
-                               FREEIF(item_info->name);
-                               FREEIF(item_info->icon);
-                               FREEIF(item_info);
                        }
+               } else {
+                       free_item_info(item_info);
                }
        }
+       eina_list_free(not_excepted_list);
+
 
        setting_info->first_excepted_list = eina_list_sort(setting_info->first_excepted_list, eina_list_count(setting_info->first_excepted_list), apps_sort_cb);
        setting_info->first_allowed_list = eina_list_sort(setting_info->first_allowed_list, eina_list_count(setting_info->first_allowed_list), apps_sort_cb);
        setting_info->excepted_list = eina_list_sort(setting_info->excepted_list, eina_list_count(setting_info->excepted_list), apps_sort_cb);
        setting_info->not_excepted_list = eina_list_sort(setting_info->not_excepted_list, eina_list_count(setting_info->not_excepted_list), apps_sort_cb);
 
-       notification_setting_free_notification(setting_array);
 }
 
 void update_do_not_disturb_application_list()
@@ -383,7 +334,6 @@ out:
 
 bool set_excepted_apps(char *pkg_name, bool state)
 {
-       NOTISET_TRACE_BEGIN;
 
        int err = NOTIFICATION_ERROR_NONE;
 
@@ -419,14 +369,10 @@ static void _remove_apps_list(Eina_List *input_list)
 {
        NOTISET_TRACE_BEGIN;
        item_info_s *item_info = NULL;
-
        if (input_list) {
                EINA_LIST_FREE(input_list, item_info)
                {
-                       FREEIF(item_info->appid);
-                       FREEIF(item_info->name);
-                       FREEIF(item_info->icon);
-                       FREEIF(item_info);
+                       free_item_info(item_info);
                }
        }
 }
@@ -465,6 +411,14 @@ void remove_excepted_apps_list()
        }
 }
 
+void free_item_info(item_info_s *item_info){
+       FREEIF(item_info->appid);
+       FREEIF(item_info->package_id);
+       FREEIF(item_info->name);
+       FREEIF(item_info->icon);
+       FREEIF(item_info);
+}
+
 void update_apps_settings_info()
 {
        NOTISET_TRACE_BEGIN;
@@ -479,7 +433,7 @@ void update_apps_settings_info()
 
                while (list) {
                        item_info_s *item = (item_info_s *)eina_list_data_get(list);
-                       set_excepted_apps(item->appid, item->do_not_disturb_except);
+                       set_excepted_apps(item->package_id, item->do_not_disturb_except);
                        list = eina_list_next(list);
                }
        }