TizenRefApp-8699 Screen Do not disturb loading occurs long time 68/135468/2 submit/tizen/20170627.074808 submit/tizen/20170707.092054 submit/tizen/20170801.100321 submit/tizen_4.0/20170811.094300
authorOleksander Kostenko <o.kostenko@samsung.com>
Thu, 22 Jun 2017 11:33:57 +0000 (14:33 +0300)
committerOleksandr Kostenko <o.kostenko@samsung.com>
Thu, 22 Jun 2017 12:25:09 +0000 (12:25 +0000)
Change-Id: Id8bbc25091d7374a3e6003c9cdfe20d6b54ba027
Signed-off-by: Oleksander Kostenko <o.kostenko@samsung.com>
inc/app-setting-info.h
src/app-setting-info.c
src/notification-setting-info.c

index 225e936..d8bd099 100755 (executable)
@@ -35,20 +35,6 @@ typedef struct {
 } item_info_s;
 
 /**
- * @brief Gets path icon of application with specified package name.
- * @param[in] package name of application.
- * @return path to icon.
- */
-HAPI char *get_app_icon(const char *appid);
-
-/**
- * @brief Gets display name of application with specified package name.
- * @param[in] package name of application.
- * @return application's display name.
- */
-HAPI char *get_app_name(const char *appid);
-
-/**
  * @brief A function aimed to compare display names in list of item_info_s items in eina_list_sort().
  * @param[in] first item to compare.
  * @param[in] second item to compare.
@@ -57,5 +43,13 @@ HAPI char *get_app_name(const char *appid);
  */
 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);
+
 
 #endif //__APP_SETTING_INFO_H__
index 77b74be..fbdcd00 100755 (executable)
@@ -31,36 +31,21 @@ int apps_sort_cb(const void *d1, const void *d2)
        return strcmp(tmp1->name, tmp2->name);
 }
 
-HAPI char *get_app_icon(const char *appid)
+HAPI void get_app_info(const char *appid, item_info_s *app_data)
 {
-       char *icon_path = NULL;
        app_info_h app_info;
        int error_code = app_info_create(appid, &app_info);
        if (error_code == APP_MANAGER_ERROR_NONE) {
-               error_code = app_info_get_icon(app_info, &icon_path);
-               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)
+                       NOTISET_ERR("app_info_get_label() failed with error-code %d", error_code);
+
+               error_code = app_info_get_icon(app_info, &app_data->icon);
+               if (error_code != APP_MANAGER_ERROR_NONE)
                        NOTISET_ERR("app_info_get_icon() failed with error-code %d", error_code);
-               }
-               app_info_destroy(app_info);
-       } else {
-               NOTISET_ERR("app_info_create() failed with error-code %d", error_code);
-       }
-       return icon_path;
-}
 
-HAPI char *get_app_name(const char *appid)
-{
-       char *name = NULL;
-       app_info_h app_info;
-       int error_code = app_info_create(appid, &app_info);
-       if (error_code == APP_MANAGER_ERROR_NONE) {
-               error_code = app_info_get_label(app_info, &name);
-               if (error_code != APP_MANAGER_ERROR_NONE) {
-                       NOTISET_ERR("app_info_get_label() failed with error-code %d", error_code);
-               }
                app_info_destroy(app_info);
        } else {
                NOTISET_ERR("app_info_create() failed with error-code %d", error_code);
        }
-       return name;
 }
index fb81f47..77a9e0d 100755 (executable)
@@ -26,7 +26,6 @@ setting_info_s *setting_info = NULL;
 #define PHONE_PACKAGE "org.tizen.phone"
 #define CALENDAR_PACKAGE "org.tizen.calendar"
 #define MESSAGES_PACKAGE "org.tizen.message"
-/* TODO: we have no clock on device, when it will be add, we will need to change package id */
 #define CLOCK_PACKAGE "org.tizen.clock"
 
 Eina_Bool create_app_notification_list()
@@ -34,7 +33,7 @@ Eina_Bool create_app_notification_list()
        NOTISET_TRACE_BEGIN;
        int i = 0;
        int count = 0;
-       char *package_id = NULL;
+       char *app_id = NULL;
        bool allow_to_notify = false;
        bool do_not_disturb_except = false;
        notification_setting_h setting_array = NULL;
@@ -56,8 +55,8 @@ Eina_Bool create_app_notification_list()
 
                temp = setting_array + i;
 
-               notification_setting_get_appid(temp, &package_id);
-               item_info->appid = package_id;
+               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;
@@ -65,20 +64,19 @@ Eina_Bool create_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;
 
-               item_info->icon = get_app_icon(package_id);
-               item_info->name = get_app_name(package_id);
+               get_app_info(app_id, item_info);
 
                item_info->index = i;
 
-               if (item_info->name && strcmp(package_id, CALENDAR_PACKAGE)
-                                                       && strcmp(package_id, CLOCK_PACKAGE)
-                                                       && strcmp(package_id, PHONE_PACKAGE)) {
+               if (item_info->name && strcmp(app_id, CALENDAR_PACKAGE)
+                                                       && strcmp(app_id, CLOCK_PACKAGE)
+                                                       && strcmp(app_id, PHONE_PACKAGE)) {
                        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(package_id);
+                       FREEIF(app_id);
                        FREEIF(item_info->name);
                        FREEIF(item_info->icon);
                        FREEIF(item_info);
@@ -108,7 +106,7 @@ void create_do_not_disturb_application_list()
        NOTISET_TRACE_BEGIN;
        int i = 0;
        int count = 0;
-       char *package_id = NULL;
+       char *app_id = NULL;
        bool allow_to_notify = false;
        bool do_not_disturb_except = false;
        notification_setting_h setting_array = NULL;
@@ -129,8 +127,8 @@ void create_do_not_disturb_application_list()
                if (item_info) {
                        temp = setting_array + i;
 
-                       notification_setting_get_appid(temp, &package_id);
-                       item_info->appid = package_id;
+                       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;
@@ -138,30 +136,28 @@ void create_do_not_disturb_application_list()
                        notification_setting_get_do_not_disturb_except(temp, &do_not_disturb_except);
                        item_info->do_not_disturb_except = do_not_disturb_except;
 
-                       item_info->icon = get_app_icon(package_id);
+                       get_app_info(app_id, item_info);
 
-                       if (!strcmp(package_id, CALENDAR_PACKAGE))
+                       if (!strcmp(app_id, CALENDAR_PACKAGE))
                                item_info->name = strdup(APP_STRING("IDS_COM_BODY_CALENDAR_EVENTS"));
-                       else if (!strcmp(package_id, CLOCK_PACKAGE))
+                       else if (!strcmp(app_id, CLOCK_PACKAGE))
                                item_info->name = strdup(APP_STRING("IDS_ST_BODY_ALARMS"));
-                       else
-                               item_info->name = get_app_name(package_id);
 
                        item_info->index = i;
 
-                       if (item_info->name && strcmp(package_id, PHONE_PACKAGE)) {
-                               if ((allow_to_notify && !strcmp(package_id, MESSAGES_PACKAGE))
-                                               || !strcmp(package_id, CLOCK_PACKAGE)
-                                               || !strcmp(package_id, CALENDAR_PACKAGE)) {
+                       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);
                                        }
                                }
 
-                               if (allow_to_notify && strcmp(package_id, MESSAGES_PACKAGE)
-                                                                  && strcmp(package_id, CALENDAR_PACKAGE)
-                                                                  && strcmp(package_id, CLOCK_PACKAGE)) {
+                               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 {
@@ -169,7 +165,7 @@ void create_do_not_disturb_application_list()
                                        }
                                }
                        } else {
-                               FREEIF(package_id);
+                               FREEIF(app_id);
                                FREEIF(item_info->name);
                                FREEIF(item_info->icon);
                                FREEIF(item_info);