From 238c276e6b8d65767fe3d7366ec44e46cab6a51c Mon Sep 17 00:00:00 2001 From: "jin0.kim" Date: Wed, 22 Mar 2017 14:50:03 +0830 Subject: [PATCH] don't show up list when set don't show option in system setting Change-Id: Ibf98756896632956afa1341c0b8d14d87ee2ab9c --- inc/noti.h | 1 + inc/noti_util.h | 3 ++ inc/quickpanel-ui.h | 15 +++++++++ src/datetime/util-time.c | 1 + src/notifications/noti.c | 59 +++++++---------------------------- src/notifications/noti_list_item.c | 1 + src/notifications/noti_listbox.c | 1 + src/notifications/noti_section.c | 1 + src/notifications/noti_util.c | 18 +++++++++++ src/notifications/noti_view.c | 1 + src/notifications/noti_view_listype.c | 1 + src/notifications/noti_view_ongoing.c | 1 + src/quickpanel-ui.c | 57 +++++++++++++++++++++++++++++++++ src/service/keyboard.c | 1 + src/service/noti_led.c | 4 +++ src/service/reminder.c | 1 + 16 files changed, 118 insertions(+), 48 deletions(-) diff --git a/inc/noti.h b/inc/noti.h index 96d1473..5fde4a9 100755 --- a/inc/noti.h +++ b/inc/noti.h @@ -39,5 +39,6 @@ extern void quickpanel_noti_init_noti_section(void); extern void quickpanel_noti_update_by_system_time_changed_setting_cb(system_settings_key_e key, void *data); extern void quickpanel_noti_update_by_system_time_changed_vconf_cb(keynode_t *key, void *data); extern void quickpanel_noti_update_for_dismiss_ticker(); +extern void quickpanel_noti_update_list(); #endif diff --git a/inc/noti_util.h b/inc/noti_util.h index a6c5638..febdb24 100755 --- a/inc/noti_util.h +++ b/inc/noti_util.h @@ -21,9 +21,12 @@ #define QP_SHARED_ICON_FOLDER_NAME "noti_icons" #define QP_DEFAULT_ICON_NAME "noti_icons/quickpanel_icon_default.png" + + extern int quickpanel_noti_util_get_event_count_from_noti(notification_h noti); extern int quickpanel_noti_util_get_event_count_by_pkgname(const char *pkgname); extern char *quickpanel_noti_util_get_time(time_t t, char *buf, int buf_len); extern char *quickpanel_noti_util_get_text(notification_h noti, notification_text_type_e text_type); +extern qp_system_privacy_mode quickpanel_noti_util_get_noti_privacy_mode(notification_h noti); #endif diff --git a/inc/quickpanel-ui.h b/inc/quickpanel-ui.h index bd424f0..af38350 100755 --- a/inc/quickpanel-ui.h +++ b/inc/quickpanel-ui.h @@ -98,6 +98,19 @@ #endif #define QP_SEARCH_PKG "org.tizen.sfinder" + +typedef enum { + QP_LOCKSCREEN_STATE_UNLOCK, + QP_LOCKSCREEN_STATE_LOCK +} qp_lock_state_e; + +typedef enum { + QP_SYSTEM_PRIVACY_MODE_SHOW_ALL, + QP_SYSTEM_PRIVACY_MODE_HIDE_CONTENT, + QP_SYSTEM_PRIVACY_MODE_DO_NOT_SHOW, +} qp_system_privacy_mode; + + struct appdata { Evas_Object *win; tzsh_h tzsh; @@ -131,6 +144,8 @@ struct appdata { Ecore_Event_Handler *hdl_hardkey_down; Ecore_Event_Handler *hdl_hardkey_up; Eina_Bool is_hardkey_cancel; + qp_lock_state_e is_lock_launched; + qp_system_privacy_mode system_privacy_mode; }; typedef struct _QP_Module { diff --git a/src/datetime/util-time.c b/src/datetime/util-time.c index 706c88e..3abbd9c 100755 --- a/src/datetime/util-time.c +++ b/src/datetime/util-time.c @@ -36,6 +36,7 @@ #include #include #include +#include #include "common.h" diff --git a/src/notifications/noti.c b/src/notifications/noti.c index c07ec2f..0cce426 100755 --- a/src/notifications/noti.c +++ b/src/notifications/noti.c @@ -48,6 +48,7 @@ #include "noti.h" #include "list_util.h" #include "page_base.h" +#include "noti_util.h" #ifdef QP_SERVICE_NOTI_LED_ENABLE #include "noti_led.h" @@ -85,44 +86,6 @@ static struct _info { .current_noti = NULL, }; -#ifdef NOTIFICATION_ON_LOCKSCREEN -static bool _is_noti_privacy_hided(notification_h noti) -{ - int noti_err = 0; - char *pkgname = NULL; - notification_setting_h setting = NULL; - lock_screen_content_level_e level; - - noti_err = notification_get_pkgname(noti, &pkgname); - if (noti_err != NOTIFICATION_ERROR_NONE || pkgname == NULL) { - DBG("notification_get_pkgname failed [%d]", noti_err); - return false; - } - - noti_err = notification_setting_get_setting_by_package_name(pkgname, &setting); - if (noti_err != NOTIFICATION_ERROR_NONE || setting == NULL) { - DBG("notification_setting_get_setting_by_package_name failed [%d]", noti_err); - return false; - } - - noti_err = notifiacation_setting_get_lock_screen_content(setting, &level); - if (noti_err != NOTIFICATION_ERROR_NONE) { - DBG("notification_setting_get_setting_by_package_name failed [%d]", noti_err); - if (setting) - notification_setting_free_notification(setting); - - return false; - } - - notification_setting_free_notification(setting); - - if (level == DO_NOT_SHOW_NOTIFICATIONS) - return true; - - return false; -} -#endif - static void _ongoing_noti_section_deleted_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); static notification_h _update_item_progress(const char *pkgname, int priv_id, double progress) @@ -495,11 +458,8 @@ static void _noti_ongoing_add(Evas_Object *list, void *data, int is_prepend) notification_h noti = data; retif(list == NULL, , "Invalid parameter!"); -#ifdef NOTIFICATION_ON_LOCKSCREEN - if (noti != NULL && !_is_noti_privacy_hided(noti)) { -#else - if (noti != NULL) { -#endif + if (noti != NULL && quickpanel_noti_util_get_noti_privacy_mode(noti) != QP_SYSTEM_PRIVACY_MODE_DO_NOT_SHOW) { + noti_list_item = quickpanel_noti_list_item_create(list, noti); if (noti_list_item != NULL) { @@ -530,11 +490,7 @@ static void _noti_add(Evas_Object *list, void *data, int insert_pos) retif(list == NULL, , "Invalid parameter!"); -#ifdef NOTIFICATION_ON_LOCKSCREEN - if (noti != NULL && !_is_noti_privacy_hided(noti)) { -#else - if (noti != NULL) { -#endif + if (noti != NULL && quickpanel_noti_util_get_noti_privacy_mode(noti) != QP_SYSTEM_PRIVACY_MODE_DO_NOT_SHOW) { notification_get_layout(noti, &layout); noti_view = quickpanel_noti_list_item_create(list, noti); @@ -1415,6 +1371,13 @@ HAPI void quickpanel_noti_update_for_dismiss_ticker() } +HAPI void quickpanel_noti_update_list() +{ + struct appdata *ad = quickpanel_get_app_data(); + _update_notilist(ad); +} + + QP_Module noti = { .name = "noti", .init = _init, diff --git a/src/notifications/noti_list_item.c b/src/notifications/noti_list_item.c index a168500..be6ffca 100755 --- a/src/notifications/noti_list_item.c +++ b/src/notifications/noti_list_item.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include diff --git a/src/notifications/noti_listbox.c b/src/notifications/noti_listbox.c index 596ea33..6f1fc9b 100755 --- a/src/notifications/noti_listbox.c +++ b/src/notifications/noti_listbox.c @@ -23,6 +23,7 @@ #include #include #include +#include #include "quickpanel-ui.h" #include "common.h" diff --git a/src/notifications/noti_section.c b/src/notifications/noti_section.c index 05ba06a..4967e30 100755 --- a/src/notifications/noti_section.c +++ b/src/notifications/noti_section.c @@ -23,6 +23,7 @@ #include #include #include +#include #include "quickpanel-ui.h" #include "quickpanel_def.h" diff --git a/src/notifications/noti_util.c b/src/notifications/noti_util.c index 4d4a472..4740bfe 100755 --- a/src/notifications/noti_util.c +++ b/src/notifications/noti_util.c @@ -27,6 +27,7 @@ #include #include +#include #include #include #include @@ -39,6 +40,8 @@ #define QP_NOTI_DAY_DEC (24 * 60 * 60) #define QP_NOTI_TIME_LEN_LIMIT 12 + + HAPI int quickpanel_noti_util_get_event_count_from_noti(notification_h noti) { char *text_count = NULL; @@ -321,3 +324,18 @@ HAPI char *quickpanel_noti_util_get_text(notification_h noti, notification_text_ return NULL; } + +HAPI qp_system_privacy_mode quickpanel_noti_util_get_noti_privacy_mode(notification_h noti) +{ + struct appdata *ad = quickpanel_get_app_data(); + + lock_screen_content_level_e system_level = SHOW_ALL_CONTENT; + + if (ad->is_lock_launched == QP_LOCKSCREEN_STATE_UNLOCK) + return SHOW_ALL_CONTENT; + + system_level = ad->system_privacy_mode; + + return system_level; +} + diff --git a/src/notifications/noti_view.c b/src/notifications/noti_view.c index 737b65f..ca64395 100755 --- a/src/notifications/noti_view.c +++ b/src/notifications/noti_view.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "quickpanel-ui.h" #include "common.h" diff --git a/src/notifications/noti_view_listype.c b/src/notifications/noti_view_listype.c index 3ac30b1..3517191 100755 --- a/src/notifications/noti_view_listype.c +++ b/src/notifications/noti_view_listype.c @@ -25,6 +25,7 @@ #include #include #include +#include #include "quickpanel-ui.h" #include "common_uic.h" diff --git a/src/notifications/noti_view_ongoing.c b/src/notifications/noti_view_ongoing.c index 047a71c..ac86928 100755 --- a/src/notifications/noti_view_ongoing.c +++ b/src/notifications/noti_view_ongoing.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include diff --git a/src/quickpanel-ui.c b/src/quickpanel-ui.c index eb3b576..470b8f0 100755 --- a/src/quickpanel-ui.c +++ b/src/quickpanel-ui.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -564,6 +565,56 @@ static void _vconf_event_lcdoff_cb(keynode_t *node, quickpanel_uic_close_quickpanel(false, 0); } + +HAPI qp_system_privacy_mode _get_system_privacy_mode() +{ + int noti_err = 0; + notification_system_setting_h system_setting = NULL; + lock_screen_content_level_e system_level = SHOW_ALL_CONTENT; + qp_system_privacy_mode return_level = QP_SYSTEM_PRIVACY_MODE_SHOW_ALL; + + noti_err = notification_system_setting_load_system_setting(&system_setting); + if (noti_err != NOTIFICATION_ERROR_NONE) { + DBG("notifiacation_system_setting_load_system_setting failed [%d, %s]", noti_err, get_error_message(noti_err)); + return QP_SYSTEM_PRIVACY_MODE_SHOW_ALL; + } + + noti_err = notification_system_setting_get_lock_screen_content(system_setting, &system_level); + if (noti_err != NOTIFICATION_ERROR_NONE) + DBG("notifiacation_system_setting_get_lock_screen_content failed [%d, %s]", noti_err, get_error_message(noti_err)); + + notification_system_setting_free_system_setting(system_setting); + + if (system_level == SHOW_ALL_CONTENT) + return_level = QP_SYSTEM_PRIVACY_MODE_SHOW_ALL; + else if (system_level == HIDE_SENSITIVE_CONTENT) + return_level = QP_SYSTEM_PRIVACY_MODE_HIDE_CONTENT; + else if (system_level == DO_NOT_SHOW_NOTIFICATIONS) + return_level = QP_SYSTEM_PRIVACY_MODE_DO_NOT_SHOW; + + return return_level; +} + + +static void _lock_state_changed_cb(keynode_t *key, void *data) +{ + struct appdata *ad = data; + int ret = 0, state = 0; + + ret = vconf_get_int(VCONFKEY_IDLE_LOCK_STATE, &state); + retif(ret != 0, , "Failed to get VCONFKEY_IDLE_LOCK_STATE [%d]", ret); + + if (state == VCONFKEY_IDLE_UNLOCK) + ad->is_lock_launched = QP_LOCKSCREEN_STATE_UNLOCK; + else + ad->is_lock_launched = QP_LOCKSCREEN_STATE_LOCK; + + ad->system_privacy_mode = _get_system_privacy_mode(); + + quickpanel_noti_update_list(); +} + + static void _lock_type_changed_cb(keynode_t *node, void *data) { int ret = -1, type = 0; @@ -660,6 +711,9 @@ static void _vconf_init(struct appdata *ad) ERR("Failed to set changed callback of %s (%d), %s", VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, ret, get_error_message(ret)); _lock_type_changed_cb(NULL, NULL); + ret = vconf_notify_key_changed(VCONFKEY_IDLE_LOCK_STATE, _lock_state_changed_cb, ad); + if (ret != 0) + ERR("Failed to set changed callback of %s (%d), %s", VCONFKEY_IDLE_LOCK_STATE, ret, get_error_message(ret)); } static void _vconf_fini(struct appdata *ad) @@ -678,6 +732,9 @@ static void _vconf_fini(struct appdata *ad) ret = vconf_ignore_key_changed(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, _lock_type_changed_cb); if (ret != 0) ERR("Failed to remove changed callback of %s (%d), %s", VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, ret, get_error_message(ret)); + ret = vconf_ignore_key_changed(VCONFKEY_IDLE_LOCK_STATE, _lock_state_changed_cb); + if (ret != 0) + ERR("Failed to remove changed callback of %s (%d), %s", VCONFKEY_IDLE_LOCK_STATE, ret, get_error_message(ret)); } static void _ecore_event_init(struct appdata *ad) diff --git a/src/service/keyboard.c b/src/service/keyboard.c index d0c3dec..e2a769d 100755 --- a/src/service/keyboard.c +++ b/src/service/keyboard.c @@ -22,6 +22,7 @@ #include #include #include +#include #include "quickpanel-ui.h" // appdata diff --git a/src/service/noti_led.c b/src/service/noti_led.c index 8ed9067..8755a15 100755 --- a/src/service/noti_led.c +++ b/src/service/noti_led.c @@ -21,7 +21,11 @@ #include #include #include +#include +#include +#include +#include "quickpanel-ui.h" #include "common.h" #include "noti_util.h" #include "noti_led.h" diff --git a/src/service/reminder.c b/src/service/reminder.c index 5f38c7a..95ded93 100755 --- a/src/service/reminder.c +++ b/src/service/reminder.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include -- 2.7.4