quicksetting longpress concept on secured lock 21/122821/1
authorjin0.kim <jin0.kim@samsung.com>
Mon, 3 Apr 2017 12:47:45 +0000 (21:17 +0830)
committerjin0.kim <jin0.kim@samsung.com>
Mon, 3 Apr 2017 12:47:51 +0000 (21:17 +0830)
Change-Id: Ia62f67fc18674e1cceab22671c363f750530738e

13 files changed:
inc/common.h
inc/quickpanel-ui.h
inc/setting_module_api.h
inc/settings.h
src/common.c
src/quickpanel-ui.c
src/settings/modules/bluetooth.c
src/settings/modules/gps.c
src/settings/modules/rotate-lock.c
src/settings/modules/sound-profile.c
src/settings/modules/wifi.c
src/settings/setting_module_api.c
src/settings/settings_icon_common.c

index 443518d..818b3b8 100755 (executable)
@@ -94,7 +94,6 @@ extern void quickpanel_common_ui_del_current_popup(void);
 extern void *quickpanel_common_ui_get_buffer_from_image(const char *file_path, size_t *memfile_size, char *ext, int ext_size);
 extern char *quickpanel_common_ui_get_pkginfo_icon(const char *pkgid);
 extern char *quickpanel_common_ui_get_pkginfo_label(const char *pkgid);
-extern int quickpanel_common_ui_is_package_exist(const char *pkgid);
 extern char *quickpanel_common_ui_get_appinfo_icon(const char *pkgid);
 extern void quickpanel_common_inform_launch_app_result(const char *pkgname, int retcode);
 extern int quickpanel_common_send_message_to_app(const char *app_id, const char *operation, const char *key, const char *value);
index e805b38..f9865e8 100755 (executable)
@@ -182,5 +182,7 @@ extern Elm_Transit *quickpanel_brightness_transparent_background_set(bool on);
 
 #define APP_CONTROL_OPERATION_SECURED_LOCK "http://tizen.org/appcontrol/operation/secured_lock"
 #define QP_QUICK_SETTINGS "qp_quick_settings"
+#define QP_QUICK_SETTINGS_EVENT_CLICKED "_clicked"
+#define QP_QUICK_SETTINGS_EVENT_LONGPRESSED "_longpressed"
 
 #endif                         /* __QUICKPANEL_UI_H__ */
index 81b2466..084ecb9 100755 (executable)
@@ -34,6 +34,12 @@ typedef enum _qp_setting_icon_container_type {
        QP_SETTING_ICON_CONTAINER_ALL_LIST,
 } qp_setting_icon_container_type;
 
+typedef enum _qp_setting_icon_event_type {
+       QP_SETTING_ICON_CLICKED,
+       QP_SETTING_ICON_LONGPRESSED,
+} qp_setting_icon_event_type;
+
+
 extern Evas_Object *quickpanel_setting_module_icon_create(QP_Module_Setting *module, Evas_Object *parent);
 extern void quickpanel_setting_module_icon_add(QP_Module_Setting *module, Evas_Object *icon, qp_setting_icon_container_type container_type);
 extern void quickpanel_setting_module_icon_remove(QP_Module_Setting *module, Evas_Object *icon);
@@ -44,6 +50,7 @@ extern void quickpanel_setting_module_icon_view_update(QP_Module_Setting *module
 extern void quickpanel_setting_module_icon_view_update_text(QP_Module_Setting *module);
 extern void quickpanel_setting_module_icon_status_update(QP_Module_Setting *module, int flag_extra_1, int flag_extra_2);
 extern int quickpanel_setting_module_is_icon_clickable(QP_Module_Setting *module);
+extern int quickpanel_setting_module_is_immediate_actionable(QP_Module_Setting *module, qp_setting_icon_event_type event_type);
 extern void quickpanel_setting_module_icon_timer_add(QP_Module_Setting *module);
 extern void quickpanel_setting_module_icon_timer_del(QP_Module_Setting *module);
 extern void quickpanel_setting_module_progress_mode_set(QP_Module_Setting *module, int is_enable, int is_request_on);
@@ -52,5 +59,6 @@ extern QP_Module_Setting *quickpanel_setting_module_get_from_icon(Evas_Object *i
 extern void quickpanel_setting_module_syspopup_launch(char *appid, char *key, char *value);
 extern int quickpanel_setting_module_dpm_state_get(char *module_name, int *state);
 extern void quickpanel_setting_module_operate(const char *module_name);
+extern void quickpanel_setting_module_longpress_operate(const char *module_name);
 
 #endif /* __SETTING_MODULE_API_H__ */
index fe10239..561ce71 100755 (executable)
@@ -55,6 +55,7 @@ typedef struct _QP_Setting_Loaded_Item QP_Setting_Loaded_Item;
 
 struct _QP_Module_Setting {
        char *name;
+       char *setting_pkgname;
        int is_disable_feedback;
 
        /* func */
index c861b62..9e386a2 100755 (executable)
@@ -410,26 +410,6 @@ HAPI char *quickpanel_common_ui_get_pkginfo_label(const char *pkgid)
 
 }
 
-HAPI int quickpanel_common_ui_is_package_exist(const char *pkgid)
-{
-       int ret = 0;
-       retif(pkgid == NULL, 0, "invalid parameter");
-
-       package_info_h package_info = NULL;
-
-       ret = package_manager_get_package_info(pkgid, &package_info);
-       if (ret == PACKAGE_MANAGER_ERROR_NO_SUCH_PACKAGE) {
-               DBG("package %s isn't exist", pkgid);
-               return 0;
-       }
-
-       if (package_info)
-               package_info_destroy(package_info);
-
-
-       return 1;
-}
-
 static void _quickpanel_move_data_to_service(const char *key, const char *val, void *data)
 {
        retif(data == NULL || key == NULL || val == NULL, , "Invialid parameter!");
index 9d9290e..f6fe150 100755 (executable)
@@ -946,7 +946,9 @@ static void _app_service_cb(app_control_h service, void *data)
 
        int ret;
        char *op = NULL;
-       char *val = NULL;
+       char *moudle_info = NULL;
+       char *search_click_event = NULL;
+       char *search_longpress_event = NULL;
 
        ret = app_control_get_operation(service, &op);
        if (ret != APP_CONTROL_ERROR_NONE)
@@ -956,18 +958,26 @@ static void _app_service_cb(app_control_h service, void *data)
 
        if (!strncmp(APP_CONTROL_OPERATION_SECURED_LOCK, op, strlen(APP_CONTROL_OPERATION_SECURED_LOCK))) {
 
-               ret = app_control_get_extra_data(service, QP_QUICK_SETTINGS, &val);
-               if (ret != APP_CONTROL_ERROR_NONE)
-                       ERR("Failed to get extra data (%d)", ret);
+               ret = app_control_get_extra_data(service, QP_QUICK_SETTINGS, &moudle_info);
+               if (ret == APP_CONTROL_ERROR_NONE && moudle_info != NULL) {
+
+                       search_click_event = strstr(moudle_info, QP_QUICK_SETTINGS_EVENT_CLICKED);
+                       if (search_click_event != NULL) {
+                               *(moudle_info + strlen(moudle_info) - strlen(QP_QUICK_SETTINGS_EVENT_CLICKED)) = '\0';
+                               quickpanel_setting_module_operate(moudle_info);
+                       } else {
+                               search_longpress_event = strstr(moudle_info, QP_QUICK_SETTINGS_EVENT_LONGPRESSED);
+                               if (search_longpress_event != NULL) {
+                                       *(moudle_info + strlen(moudle_info) - strlen(QP_QUICK_SETTINGS_EVENT_LONGPRESSED)) = '\0';
+                                       quickpanel_setting_module_longpress_operate(moudle_info);
+                               }
+                       }
+
+                       free(moudle_info);
 
-               if (!strncmp("wifi", val, strlen("wifi")))
-                       quickpanel_setting_module_operate("wifi");
-               else if (!strncmp("gps", val, strlen("gps")))
-                       quickpanel_setting_module_operate("gps");
-               else if (!strncmp("bluetooth", val, strlen("bluetooth")))
-                       quickpanel_setting_module_operate("bluetooth");
+                       quickpanel_page_secured_lock_set(QP_SECURED_LOCK_OFF);
+               }
 
-               quickpanel_page_secured_lock_set(QP_SECURED_LOCK_OFF);
        } else {
                _service_request_process(service, data);
        }
index c27e1ea..0082c09 100755 (executable)
@@ -33,7 +33,6 @@
 #define BUTTON_ICON_NORMAL "quick_icon_bluetooth.png"
 #define BUTTON_ICON_HIGHLIGHT NULL
 #define BUTTON_ICON_DIM NULL
-#define PACKAGE_SETTING_MENU "ug-bluetooth-efl"
 
 int bt_service = BT_ERROR_NONE;
 
@@ -61,11 +60,16 @@ static const char *_icon_get(qp_setting_icon_image_type type)
 
 static void _long_press_cb(void *data)
 {
+       QP_Module_Setting *module = (QP_Module_Setting *)data;
        if (bt_service == BT_ERROR_NOT_SUPPORTED) {
                quickpanel_setting_show_not_supported_message();
                return;
        }
-       quickpanel_setting_icon_handler_longpress(PACKAGE_SETTING_MENU, NULL, NULL);
+
+       if (quickpanel_setting_module_is_immediate_actionable(module, QP_SETTING_ICON_LONGPRESSED) == false)
+               return;
+
+       quickpanel_setting_icon_handler_longpress(module->setting_pkgname, NULL, NULL);
 }
 
 static void _view_update(Evas_Object *view, int state, int flag_extra_1, int flag_extra_2)
@@ -147,7 +151,6 @@ static void _mouse_clicked_cb(void *data, Evas_Object *obj, const char *emission
 {
        int dpm_state = 0;
        QP_Module_Setting *module = (QP_Module_Setting *)data;
-       Eina_Bool secured_lock = EINA_FALSE;
 
        retif(module == NULL, , "Invalid parameter!");
 
@@ -160,6 +163,10 @@ static void _mouse_clicked_cb(void *data, Evas_Object *obj, const char *emission
                return;
 
 
+       if (quickpanel_setting_module_is_immediate_actionable(module, QP_SETTING_ICON_CLICKED) == 0)
+               return;
+
+
        if (quickpanel_setting_module_dpm_state_get(module->name, &dpm_state) == 0)
                return;
 
@@ -169,13 +176,8 @@ static void _mouse_clicked_cb(void *data, Evas_Object *obj, const char *emission
                return;
        }
 
-       secured_lock = quickpanel_setting_get_secured_lock_state();
-       if (secured_lock == EINA_TRUE) {
-               quickpanel_uic_close_quickpanel(false, 0);
-               quickpanel_common_send_message_to_app("org.tizen.lockscreen", APP_CONTROL_OPERATION_SECURED_LOCK, QP_QUICK_SETTINGS, module->name);
-       } else {
-               _state_change(module);
-       }
+       _state_change(module);
+
 }
 
 static void _bluetooth_status_changed_cb(int result, bt_adapter_state_e adapter_state, void *user_data)
@@ -267,6 +269,7 @@ static void _refresh(void *data)
 
 QP_Module_Setting bluetooth = {
        .name                           = "bluetooth",
+       .setting_pkgname        = "ug-bluetooth-efl",
        .init                           = _init,
        .fini                           = _fini,
        .lang_changed           = _lang_changed,
index 3677db0..374e315 100755 (executable)
@@ -37,7 +37,6 @@
 #define BUTTON_ICON_NORMAL "quick_icon_location.png"
 #define BUTTON_ICON_HIGHLIGHT NULL
 #define BUTTON_ICON_DIM NULL
-#define PACKAGE_SETTING_MENU "org.tizen.setting-location"
 #define OPERATION_SETTING_MENU "http://tizen.org/appcontrol/operation/configure/location"
 #define PACKAGE_SYSPOPUP "gps-syspopup"
 
@@ -65,7 +64,12 @@ static const char *_icon_get(qp_setting_icon_image_type type)
 
 static void _long_press_cb(void *data)
 {
-       quickpanel_setting_icon_handler_longpress(PACKAGE_SETTING_MENU, NULL, NULL);
+       QP_Module_Setting *module = (QP_Module_Setting *)data;
+
+       if (quickpanel_setting_module_is_immediate_actionable(module, QP_SETTING_ICON_LONGPRESSED) == false)
+               return;
+
+       quickpanel_setting_icon_handler_longpress(module->setting_pkgname, NULL, NULL);
 }
 
 static void _gps_syspopup_launch(int is_on)
@@ -173,7 +177,6 @@ static void _mouse_clicked_cb(void *data, Evas_Object *obj, const char *emission
 {
        int dpm_state = 0;
        QP_Module_Setting *module = (QP_Module_Setting *)data;
-       Eina_Bool secured_lock = EINA_FALSE;
 
        retif(module == NULL, , "Invalid parameter!");
 
@@ -185,18 +188,17 @@ static void _mouse_clicked_cb(void *data, Evas_Object *obj, const char *emission
                return;
 
 
+       if (quickpanel_setting_module_is_immediate_actionable(module, QP_SETTING_ICON_CLICKED) == 0)
+               return;
+
+
        if (dpm_state == 0) {
                quickpanel_setting_module_syspopup_launch(DPM_SYSPOPUP, "id", "location");
                return;
        }
 
-       secured_lock = quickpanel_setting_get_secured_lock_state();
-       if (secured_lock == EINA_TRUE) {
-               quickpanel_uic_close_quickpanel(false, 0);
-               quickpanel_common_send_message_to_app("org.tizen.lockscreen", APP_CONTROL_OPERATION_SECURED_LOCK, QP_QUICK_SETTINGS, module->name);
-       } else {
-               _state_change(module);
-       }
+       _state_change(module);
+
 }
 
 static void _gps_vconf_cb(keynode_t *node, void *data)
@@ -369,6 +371,7 @@ static int _handler_ipc(const char *command, void *data)
 
 QP_Module_Setting gps = {
        .name                           = "gps",
+       .setting_pkgname        = "org.tizen.setting-location",
        .init                           = _init,
        .fini                           = _fini,
        .lang_changed           = _lang_changed,
index 54722bd..33fab66 100755 (executable)
@@ -34,7 +34,6 @@
 #define BUTTON_ICON_NORMAL "quick_icon_auto_rotate.png"
 #define BUTTON_ICON_HIGHLIGHT NULL
 #define BUTTON_ICON_DIM NULL
-#define PACKAGE_SETTING_MENU "org.tizen.setting-display"
 
 static void _mouse_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source);
 
@@ -60,7 +59,12 @@ static const char *_icon_get(qp_setting_icon_image_type type)
 
 static void _long_press_cb(void *data)
 {
-       quickpanel_setting_icon_handler_longpress(PACKAGE_SETTING_MENU, "viewtype", "main");
+       QP_Module_Setting *module = (QP_Module_Setting *)data;
+
+       if (quickpanel_setting_module_is_immediate_actionable(module, QP_SETTING_ICON_LONGPRESSED) == false)
+               return;
+
+       quickpanel_setting_icon_handler_longpress(module->setting_pkgname, "viewtype", "main");
 }
 
 static void _view_update(Evas_Object *view, int state, int flag_extra_1, int flag_extra_2)
@@ -186,6 +190,7 @@ static void _refresh(void *data)
 
 QP_Module_Setting rotate = {
        .name                           = "rotate",
+       .setting_pkgname        = "org.tizen.setting-display",
        .init                           = _init,
        .fini                           = _fini,
        .lang_changed           = _lang_changed,
index c2e4213..9551cd1 100755 (executable)
@@ -36,7 +36,6 @@
 #define BUTTON_ICON_SND_HIGHLIGHT "quick_icon_sn_vf.png"
 #define BUTTON_ICON_MUTE_NORMAL "quick_icon_sf_vf.png"
 #define BUTTON_ICON_VIB_HIGHLIGHT "quick_icon_sf_vn.png"
-#define PACKAGE_SETTING_MENU "org.tizen.setting-profile"
 #define SAM_LOG_FEATURE_SOUND "ST0C"
 
 typedef enum {
@@ -129,7 +128,12 @@ static const char *_icon_get(qp_setting_icon_image_type type)
 
 static void _long_press_cb(void *data)
 {
-       quickpanel_setting_icon_handler_longpress(PACKAGE_SETTING_MENU, NULL, NULL);
+       QP_Module_Setting *module = (QP_Module_Setting *)data;
+
+       if (quickpanel_setting_module_is_immediate_actionable(module, QP_SETTING_ICON_LONGPRESSED) == false)
+               return;
+
+       quickpanel_setting_icon_handler_longpress(module->setting_pkgname, NULL, NULL);
 
 }
 
@@ -311,6 +315,7 @@ static void _refresh(void *data)
 
 QP_Module_Setting sound = {
        .name                           = "sound",
+       .setting_pkgname        = "org.tizen.setting-profile",
        .init                                   = _init,
        .fini                                   = _fini,
        .lang_changed                   = _lang_changed,
index 90a351c..17cb363 100755 (executable)
@@ -37,9 +37,6 @@
 #define BUTTON_ICON_NORMAL "quick_icon_wifi.png"
 #define BUTTON_ICON_HIGHLIGHT NULL
 #define BUTTON_ICON_DIM NULL
-#define PACKAGE_SETTING_MENU "wifi-efl-ug-lite"
-#define PACKAGE_SETTING_MENU_PTN "wifi-efl-ug" // for redwood partner
-
 
 static int _wifi_on(void *data, const char *popup_txt);
 static int _wifi_off(void);
@@ -73,17 +70,17 @@ static const char *_icon_get(qp_setting_icon_image_type type)
 
 static void _long_press_cb(void *data)
 {
+       QP_Module_Setting *module = (QP_Module_Setting *)data;
        if (wifi_manager == NULL && wifi_error_type == WIFI_MANAGER_ERROR_NOT_SUPPORTED) {
                quickpanel_setting_show_not_supported_message();
                return;
        }
 
-       if (quickpanel_common_ui_is_package_exist(PACKAGE_SETTING_MENU)) {
-               quickpanel_setting_icon_handler_longpress(PACKAGE_SETTING_MENU, NULL, NULL);
-       } else {
-               DBG("No package[%s] try[%s]", PACKAGE_SETTING_MENU, PACKAGE_SETTING_MENU_PTN);
-               quickpanel_setting_icon_handler_longpress(PACKAGE_SETTING_MENU_PTN, NULL, NULL);
-       }
+       if (quickpanel_setting_module_is_immediate_actionable(module, QP_SETTING_ICON_LONGPRESSED) == false)
+               return;
+
+
+       quickpanel_setting_icon_handler_longpress(module->setting_pkgname, NULL, NULL);
 }
 
 static void _view_update(Evas_Object *view, int state, int flag_extra_1, int flag_extra_2)
@@ -179,7 +176,6 @@ static void _mouse_clicked_cb(void *data, Evas_Object *obj, const char *emission
 {
        int dpm_state = 0;
        QP_Module_Setting *module = (QP_Module_Setting *)data;
-       Eina_Bool secured_lock = EINA_FALSE;
 
        if (wifi_manager == NULL && wifi_error_type == WIFI_MANAGER_ERROR_NOT_SUPPORTED) {
                quickpanel_setting_show_not_supported_message();
@@ -192,6 +188,10 @@ static void _mouse_clicked_cb(void *data, Evas_Object *obj, const char *emission
                return;
 
 
+       if (quickpanel_setting_module_is_immediate_actionable(module, QP_SETTING_ICON_CLICKED) == 0)
+               return;
+
+
        if (quickpanel_setting_module_dpm_state_get(module->name, &dpm_state) == 0)
                return;
 
@@ -201,13 +201,7 @@ static void _mouse_clicked_cb(void *data, Evas_Object *obj, const char *emission
                return;
        }
 
-       secured_lock = quickpanel_setting_get_secured_lock_state();
-       if (secured_lock == EINA_TRUE) {
-               quickpanel_uic_close_quickpanel(false, 0);
-               quickpanel_common_send_message_to_app("org.tizen.lockscreen", APP_CONTROL_OPERATION_SECURED_LOCK, QP_QUICK_SETTINGS, module->name);
-       } else {
-               _state_change(module);
-       }
+       _state_change(module);
 }
 
 static int _register_module_event_handler(void *data)
@@ -591,6 +585,7 @@ static int _handler_ipc(const char *command, void *data)
 
 QP_Module_Setting wifi = {
        .name                           = "wifi",
+       .setting_pkgname        = "wifi-efl-ug",
        .init                           = _init,
        .fini                           = _fini,
        .lang_changed           = _lang_changed,
index 6f2243c..dcdee04 100755 (executable)
@@ -29,6 +29,7 @@
 #include "setting_utils.h"
 #include "setting_module_api.h"
 #include "settings_icon_common.h"
+#include "common_uic.h"
 
 #ifdef QP_SCREENREADER_ENABLE
 #include "accessibility.h"
@@ -190,6 +191,38 @@ HAPI int quickpanel_setting_module_is_icon_clickable(QP_Module_Setting *module)
        return 1;
 }
 
+
+HAPI int quickpanel_setting_module_is_immediate_actionable(QP_Module_Setting *module, qp_setting_icon_event_type event_type)
+{
+       Eina_Bool secured_lock = EINA_FALSE;
+       char buf[MAX_NAM_LEN];
+       retif(module == NULL || module->loader == NULL, 0, "invalid parameter");
+
+       secured_lock = quickpanel_setting_get_secured_lock_state();
+       if (secured_lock == EINA_TRUE) {
+               strncpy(buf, module->name, strlen(module->name));
+               buf[strlen(module->name)] = '\0';
+
+               switch (event_type) {
+               case QP_SETTING_ICON_CLICKED:
+                       strncat(buf, QP_QUICK_SETTINGS_EVENT_CLICKED, strlen(QP_QUICK_SETTINGS_EVENT_CLICKED));
+                       break;
+               case QP_SETTING_ICON_LONGPRESSED:
+                       strncat(buf, QP_QUICK_SETTINGS_EVENT_LONGPRESSED, strlen(QP_QUICK_SETTINGS_EVENT_LONGPRESSED));
+                       break;
+               default:
+                       break;
+               }
+
+               quickpanel_common_send_message_to_app("org.tizen.lockscreen", APP_CONTROL_OPERATION_SECURED_LOCK, QP_QUICK_SETTINGS, buf);
+               quickpanel_uic_close_quickpanel(false, 0);
+               return 0;
+       }
+
+       return 1;
+}
+
+
 static Eina_Bool _timer_expire_cb(void *data)
 {
        retif(data == NULL, ECORE_CALLBACK_CANCEL, "invalid parameter");
@@ -366,7 +399,24 @@ HAPI void quickpanel_setting_module_operate(const char *module_name)
        QP_Module_Setting *module = NULL;
 
        module = quickpanel_settings_module_get_by_name(module_name);
-       if (module->state_change)
+
+       if (module != NULL && module->state_change)
                module->state_change(module);
+       else
+               DBG("Faild to get module [%s]", module_name);
 
 }
+
+
+HAPI void quickpanel_setting_module_longpress_operate(const char *module_name)
+{
+       QP_Module_Setting *module = NULL;
+
+       module = quickpanel_settings_module_get_by_name(module_name);
+       if (module != NULL && module->setting_pkgname)
+               quickpanel_setting_icon_handler_longpress(module->setting_pkgname, NULL, NULL);
+       else
+               DBG("Faild to get module [%s]", module_name);
+
+}
+
index 2e2b15f..dfa9bed 100755 (executable)
@@ -68,7 +68,7 @@ static Eina_Bool _icon_handler_longpress(void *data)
                        if (module->name)
                                DBG("launch setting menu of %s", module->name);
 
-                       module->handler_longpress(obj);
+                       module->handler_longpress(module);
 
                        elm_object_signal_emit(obj, "mouse,up,1", "background.super");
                }
@@ -227,7 +227,7 @@ HAPI void quickpanel_setting_icon_handler_longpress(const char *pkgname, const c
 
        ret = quickpanel_common_send_message_to_app(pkgname, NULL, key, value);
        quickpanel_common_inform_launch_app_result(pkgname, ret);
-       quickpanel_uic_close_quickpanel(true, 1);
+       quickpanel_uic_close_quickpanel(false, 0);
 }
 #endif