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)
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) {
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) {
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) {
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) {
--- /dev/null
+/*
+* 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;
+}
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;
}
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);
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()
bool set_excepted_apps(char *pkg_name, bool state)
{
- NOTISET_TRACE_BEGIN;
int err = NOTIFICATION_ERROR_NONE;
{
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);
}
}
}
}
}
+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;
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);
}
}