increase code quality 54/239354/1 accepted/tizen/unified/20200728.135430 submit/tizen/20200728.053509
authorYoungjae Shin <yj99.shin@samsung.com>
Fri, 24 Jul 2020 06:26:41 +0000 (15:26 +0900)
committerYoungjae Shin <yj99.shin@samsung.com>
Fri, 24 Jul 2020 06:26:47 +0000 (15:26 +0900)
separate big functions
change global variables to static variables

Change-Id: I27811308563de0e1aaa1dd327c8b837be49678d5

src/bt-syspopup-m.c
src/bt-syspopup-w.c

index f43336c..7e5255b 100644 (file)
@@ -120,7 +120,7 @@ static int __bluetooth_timeout(bundle *b, void *data)
        return 0;
 }
 
-syspopup_handler handler = {
+static syspopup_handler handler = {
        .def_term_fn = __bluetooth_term,
        .def_timeout_fn = __bluetooth_timeout
 };
@@ -1138,8 +1138,7 @@ static void __bluetooth_draw_auth_popup(struct bt_popup_appdata *ad,
                elm_object_part_text_set(ad->popup, "title,text",
                                BT_STR_ALLOW_APP_PERMISSION);
 
-               snprintf(temp_str, BT_TITLE_STR_MAX_LEN + BT_TEXT_EXTRA_LEN,
-                                       "%s", title);
+               snprintf(temp_str, sizeof(temp_str), "%s", title);
 
                label = elm_label_add(ad->popup);
                elm_object_style_set(label, "popup/default");
@@ -1957,456 +1956,493 @@ static void __bluetooth_draw_toast_popup(struct bt_popup_appdata *ad, char *toas
        FN_END;
 }
 
-/* AUL bundle handler */
-static int __bluetooth_launch_handler(struct bt_popup_appdata *ad,
-                            void *reset_data, const char *event_type)
+static inline int __handle_pin_request(struct bt_popup_appdata *ad, bundle *kb)
 {
-       FN_START;
-       bundle *kb = (bundle *) reset_data;
-       char view_title[BT_TITLE_STR_MAX_LEN] = { 0 };
-       char text[BT_GLOBALIZATION_STR_LENGTH] = { 0 };
-       int timeout = 0;
-       char *device_name = NULL;
-       char *passkey = NULL;
-       char *file = NULL;
-       char *agent_path;
-       char *conv_str = NULL;
-       char *stms_str = NULL;
-       char *popup_text = NULL;
-       char *tmp_timeout = NULL;
        int ret;
+       char *conv_str = NULL;
+       char *device_name = NULL;
+       char *agent_path = NULL;
+       char view_title[BT_TITLE_STR_MAX_LEN];
+       char text[BT_GLOBALIZATION_STR_LENGTH];
 
-       if (!reset_data || !event_type)
-               return -1;
-
-       BT_INFO("Event Type = %s[0X%X]", event_type, ad->event_type);
+       ret = bundle_get_str(kb, "device-name", &device_name);
+       if (ret != BUNDLE_ERROR_NONE)
+               BT_ERR("bundle_get_str() is failed : %d\n", ret);
 
-       if (!strcasecmp(event_type, "pin-request")) {
-               ret = bundle_get_str(kb, "device-name", &device_name);
-               if (ret != BUNDLE_ERROR_NONE)
-                       BT_ERR("bundle_get_str() is failed : %d\n", ret);
+       ret = bundle_get_str(kb, "agent-path", &agent_path);
+       if (ret != BUNDLE_ERROR_NONE)
+               BT_ERR("bundle_get_str() is failed : %d\n", ret);
 
-               ret = bundle_get_str(kb, "agent-path", &agent_path);
-               if (ret != BUNDLE_ERROR_NONE)
-                       BT_ERR("bundle_get_str() is failed : %d\n", ret);
+       ad->agent_proxy = __bluetooth_create_agent_proxy(ad->conn, agent_path);
+       if (!ad->agent_proxy)
+               return -1;
 
-               ad->agent_proxy = __bluetooth_create_agent_proxy(ad->conn, agent_path);
-               retv_if(!ad->agent_proxy, -1);
+       if (device_name)
+               conv_str = elm_entry_utf8_to_markup(device_name);
 
-               if (device_name)
-                       conv_str = elm_entry_utf8_to_markup(device_name);
+       snprintf(view_title, sizeof(view_title), BT_STR_BLUETOOTH_PAIRING_REQUEST);
 
-               snprintf(view_title, BT_TITLE_STR_MAX_LEN,
-                       BT_STR_BLUETOOTH_PAIRING_REQUEST);
+       char *stms_str = BT_STR_ENTER_THE_PIN_TO_PAIR;
+       snprintf(text, sizeof(text), stms_str, conv_str);
 
-               stms_str = BT_STR_ENTER_THE_PIN_TO_PAIR;
+       free(conv_str);
 
-               snprintf(text, BT_GLOBALIZATION_STR_LENGTH,
-                       stms_str, conv_str);
+       /* Request user inputted PIN for basic pairing */
+       __bluetooth_draw_input_view(ad, view_title, text, __bluetooth_input_request_cb);
 
-               if (conv_str)
-                       free(conv_str);
+       return 0;
+}
 
-               /* Request user inputted PIN for basic pairing */
-               __bluetooth_draw_input_view(ad, view_title, text,
-                                         __bluetooth_input_request_cb);
-       } else if (!strcasecmp(event_type, "passkey-confirm-request")) {
-               ret = bundle_get_str(kb, "device-name", &device_name);
-               if (ret != BUNDLE_ERROR_NONE)
-                       BT_ERR("bundle_get_str() is failed : %d\n", ret);
+static inline int __handle_passkey_confirm_request(struct bt_popup_appdata *ad, bundle *kb)
+{
+       int ret;
+       char *device_name = NULL;
+       char *agent_path = NULL;
+       char *passkey = NULL;
+       char view_title[BT_TITLE_STR_MAX_LEN];
 
-               ret = bundle_get_str(kb, "passkey", &passkey);
-               if (ret != BUNDLE_ERROR_NONE)
-                       BT_ERR("bundle_get_str() is failed : %d\n", ret);
+       ret = bundle_get_str(kb, "device-name", &device_name);
+       if (ret != BUNDLE_ERROR_NONE)
+               BT_ERR("bundle_get_str() is failed : %d\n", ret);
 
-               ret = bundle_get_str(kb, "agent-path", &agent_path);
-               if (ret != BUNDLE_ERROR_NONE)
-                       BT_ERR("bundle_get_str() is failed : %d\n", ret);
+       ret = bundle_get_str(kb, "passkey", &passkey);
+       if (ret != BUNDLE_ERROR_NONE)
+               BT_ERR("bundle_get_str() is failed : %d\n", ret);
 
+       ret = bundle_get_str(kb, "agent-path", &agent_path);
+       if (ret != BUNDLE_ERROR_NONE)
+               BT_ERR("bundle_get_str() is failed : %d\n", ret);
 
-               ad->agent_proxy = __bluetooth_create_agent_proxy(ad->conn, agent_path);
-               if (!ad->agent_proxy)
-                       return -1;
+       ad->agent_proxy = __bluetooth_create_agent_proxy(ad->conn, agent_path);
+       if (!ad->agent_proxy)
+               return -1;
 
-               if (device_name && passkey) {
-                       stms_str = BT_STR_CONFIRM_PASSKEY_PS_TO_PAIR_WITH_PS;
+       if (device_name && passkey) {
+               char *stms_str = BT_STR_CONFIRM_PASSKEY_PS_TO_PAIR_WITH_PS;
 
-                       snprintf(view_title, BT_TITLE_STR_MAX_LEN,
-                               stms_str, passkey, device_name);
+               snprintf(view_title, sizeof(view_title), stms_str, passkey, device_name);
 
-                       BT_INFO("title: %s", view_title);
+               BT_INFO("title: %s", view_title);
 
-                       __bluetooth_draw_popup(ad, BT_STR_BLUETOOTH_PAIRING_REQUEST,
-                                       view_title, BT_STR_CANCEL, BT_STR_CONFIRM,
-                                       __bluetooth_passkey_confirm_cb);
-               } else {
-                       timeout = BT_ERROR_TIMEOUT;
-               }
-       } else if (!strcasecmp(event_type, "visibility-request")) {
-               BT_INFO("visibility request popup");
+               __bluetooth_draw_popup(ad, BT_STR_BLUETOOTH_PAIRING_REQUEST,
+                       view_title, BT_STR_CANCEL, BT_STR_CONFIRM,
+                       __bluetooth_passkey_confirm_cb);
+       } else {
+               return BT_ERROR_TIMEOUT;
+       }
+       return 0;
+}
+static inline int __handle_visibility_request(struct bt_popup_appdata *ad, bundle *kb)
+{
+       int timeout = 0;
+       char *popup_text;
+       char *tmp_timeout;
 
-               if (ad->visibility_timeout) {
-                       timeout = atoi(ad->visibility_timeout);
+       BT_INFO("visibility request popup");
 
-                       if (timeout <= BT_VISIBILITY_TIMEOUT_MIN)
-                               tmp_timeout = BT_VISIBILITY_TIMEOUT_MIN_STR;
-                       else if (timeout >= BT_VISIBILITY_TIMEOUT_MAX)
-                               tmp_timeout = BT_VISIBILITY_TIMEOUT_MAX_STR;
-                       else
-                               tmp_timeout = ad->visibility_timeout;
-               } else {
-                       /* default timeout value */
-                       tmp_timeout = BT_VISIBILITY_TIMEOUT_DEFAULT_STR;
-               }
+       if (ad->visibility_timeout) {
+               timeout = atoi(ad->visibility_timeout);
 
-               popup_text = format_string("Requesting permission to turn on Bluetooth and to set Visibility during %s seconds. Do you want to do this?",
-                               tmp_timeout);
+               if (timeout <= BT_VISIBILITY_TIMEOUT_MIN)
+                       tmp_timeout = BT_VISIBILITY_TIMEOUT_MIN_STR;
+               else if (timeout >= BT_VISIBILITY_TIMEOUT_MAX)
+                       tmp_timeout = BT_VISIBILITY_TIMEOUT_MAX_STR;
+               else
+                       tmp_timeout = ad->visibility_timeout;
+       } else {
+               /* default timeout value */
+               tmp_timeout = BT_VISIBILITY_TIMEOUT_DEFAULT_STR;
+       }
 
-               __bluetooth_draw_popup(ad, "Bluetooth permission request", popup_text, BT_STR_CANCEL, BT_STR_CONFIRM,
-                                       __bluetooth_visibility_confirm_cb);
+       popup_text = format_string("Requesting permission to turn on Bluetooth and to set Visibility during %s seconds. Do you want to do this?",
+               tmp_timeout);
 
-               g_free(popup_text);
+       __bluetooth_draw_popup(ad, "Bluetooth permission request", popup_text,
+               BT_STR_CANCEL, BT_STR_CONFIRM, __bluetooth_visibility_confirm_cb);
 
-       } else if (!strcasecmp(event_type, "passkey-request")) {
-               char *device_name = NULL;
+       g_free(popup_text);
+       return timeout;
+}
 
-               ret = bundle_get_str(kb, "device-name", &device_name);
-               if (ret != BUNDLE_ERROR_NONE)
-                       BT_ERR("bundle_get_str() is failed : %d\n", ret);
+static inline int __handle_passkey_request(struct bt_popup_appdata *ad, bundle *kb)
+{
+       int ret;
+       char *conv_str = NULL;
+       char *device_name = NULL;
+       char *agent_path = NULL;
+       char view_title[BT_TITLE_STR_MAX_LEN];
+       char text[BT_GLOBALIZATION_STR_LENGTH];
 
-               ret = bundle_get_str(kb, "agent-path", &agent_path);
-               if (ret != BUNDLE_ERROR_NONE)
-                       BT_ERR("bundle_get_str() is failed : %d\n", ret);
+       ret = bundle_get_str(kb, "device-name", &device_name);
+       if (ret != BUNDLE_ERROR_NONE)
+               BT_ERR("bundle_get_str() is failed : %d\n", ret);
 
-               ad->agent_proxy = __bluetooth_create_agent_proxy(ad->conn, agent_path);
-               if (!ad->agent_proxy)
-                       return -1;
+       ret = bundle_get_str(kb, "agent-path", &agent_path);
+       if (ret != BUNDLE_ERROR_NONE)
+               BT_ERR("bundle_get_str() is failed : %d\n", ret);
 
-               if (device_name)
-                       conv_str = elm_entry_utf8_to_markup(device_name);
+       ad->agent_proxy = __bluetooth_create_agent_proxy(ad->conn, agent_path);
+       if (!ad->agent_proxy)
+               return -1;
 
-               snprintf(view_title, BT_TITLE_STR_MAX_LEN,
-                       BT_STR_BLUETOOTH_PAIRING_REQUEST);
+       if (device_name)
+               conv_str = elm_entry_utf8_to_markup(device_name);
 
-               stms_str = BT_STR_ENTER_THE_PIN_TO_PAIR;
+       snprintf(view_title, sizeof(view_title), BT_STR_BLUETOOTH_PAIRING_REQUEST);
 
-               snprintf(text, BT_GLOBALIZATION_STR_LENGTH,
-                       stms_str, conv_str);
+       char *stms_str = BT_STR_ENTER_THE_PIN_TO_PAIR;
+       snprintf(text, sizeof(text), stms_str, conv_str);
 
-               if (conv_str)
-                       free(conv_str);
+       free(conv_str);
 
-               /* Request user inputted Passkey for basic pairing */
-               __bluetooth_draw_input_view(ad, view_title, text,
-                                         __bluetooth_input_request_cb);
+       /* Request user inputted Passkey for basic pairing */
+       __bluetooth_draw_input_view(ad, view_title, text, __bluetooth_input_request_cb);
 
-       } else if (!strcasecmp(event_type, "passkey-display-request")) {
-               ret = bundle_get_str(kb, "device-name", &device_name);
-               if (ret != BUNDLE_ERROR_NONE)
-                       BT_ERR("bundle_get_str() is failed : %d\n", ret);
+       return 0;
+}
 
-               ret = bundle_get_str(kb, "passkey", &passkey);
-               if (ret != BUNDLE_ERROR_NONE)
-                       BT_ERR("bundle_get_str() is failed : %d\n", ret);
+static inline int __handle_passkey_event_requests(struct bt_popup_appdata *ad, bundle *kb, const char *title)
+{
+       int ret;
+       int timeout = 0;
+       char *device_name = NULL;
+       char *passkey = NULL;
+       char view_title[BT_TITLE_STR_MAX_LEN];
 
-               if (device_name && passkey) {
-                       stms_str = BT_STR_ENTER_PS_ON_PS_TO_PAIR;
+       ret = bundle_get_str(kb, "device-name", &device_name);
+       if (ret != BUNDLE_ERROR_NONE)
+               BT_ERR("bundle_get_str() is failed : %d\n", ret);
 
-                       snprintf(view_title, BT_TITLE_STR_MAX_LEN,
-                               stms_str, passkey, device_name);
+       ret = bundle_get_str(kb, "passkey", &passkey);
+       if (ret != BUNDLE_ERROR_NONE)
+               BT_ERR("bundle_get_str() is failed : %d\n", ret);
 
-                       BT_INFO("title: %s", view_title);
+       if (device_name && passkey) {
+               char *stms_str = BT_STR_ENTER_PS_ON_PS_TO_PAIR;
+               snprintf(view_title, sizeof(view_title), stms_str, passkey, device_name);
 
-                       __bluetooth_draw_popup(ad, BT_STR_SHOW_PASSWORD, view_title,
-                                               BT_STR_CANCEL, NULL,
-                                               __bluetooth_input_cancel_cb);
-               } else {
-                       timeout = BT_ERROR_TIMEOUT;
-               }
-       } else if (!strcasecmp(event_type, "authorize-request")) {
-               timeout = BT_AUTHORIZATION_TIMEOUT;
+               BT_INFO("title: %s", view_title);
 
-               ret = bundle_get_str(kb, "device-name", &device_name);
-               if (ret != BUNDLE_ERROR_NONE)
-                       BT_ERR("bundle_get_str() is failed : %d\n", ret);
+               __bluetooth_draw_popup(ad, title, view_title,
+                       BT_STR_CANCEL, NULL, __bluetooth_input_cancel_cb);
+       } else {
+               timeout = BT_ERROR_TIMEOUT;
+       }
+       return timeout;
+}
 
-               ret = bundle_get_str(kb, "agent-path", &agent_path);
-               if (ret != BUNDLE_ERROR_NONE)
-                       BT_ERR("bundle_get_str() is failed : %d\n", ret);
+static inline int __handle_authorize_request(struct bt_popup_appdata *ad, bundle *kb)
+{
+       int ret;
+       char *conv_str = NULL;
+       char *device_name = NULL;
+       char *agent_path = NULL;
+       char view_title[BT_TITLE_STR_MAX_LEN];
 
-               ad->agent_proxy = __bluetooth_create_agent_proxy(ad->conn, agent_path);
-               if (!ad->agent_proxy)
-                       return -1;
+       ret = bundle_get_str(kb, "device-name", &device_name);
+       if (ret != BUNDLE_ERROR_NONE)
+               BT_ERR("bundle_get_str() is failed : %d\n", ret);
 
-               if (device_name)
-                       conv_str = elm_entry_utf8_to_markup(device_name);
+       ret = bundle_get_str(kb, "agent-path", &agent_path);
+       if (ret != BUNDLE_ERROR_NONE)
+               BT_ERR("bundle_get_str() is failed : %d\n", ret);
 
-               stms_str = BT_STR_ALLOW_PS_TO_CONNECT_Q;
+       ad->agent_proxy = __bluetooth_create_agent_proxy(ad->conn, agent_path);
+       if (!ad->agent_proxy)
+               return -1;
 
-               snprintf(view_title, BT_TITLE_STR_MAX_LEN,
-                       stms_str, conv_str);
+       if (device_name)
+               conv_str = elm_entry_utf8_to_markup(device_name);
 
-               if (conv_str)
-                       free(conv_str);
+       char *stms_str = BT_STR_ALLOW_PS_TO_CONNECT_Q;
+       snprintf(view_title, sizeof(view_title), stms_str, conv_str);
+       free(conv_str);
 
-               __bluetooth_draw_auth_popup(ad, view_title, BT_STR_CANCEL, BT_STR_ACCEPT,
-                                    __bluetooth_authorization_request_cb);
-       } else if (!strcasecmp(event_type, "app-confirm-request")) {
-               BT_DBG("app-confirm-request");
-               timeout = BT_AUTHORIZATION_TIMEOUT;
+       __bluetooth_draw_auth_popup(ad, view_title, BT_STR_CANCEL, BT_STR_ACCEPT,
+               __bluetooth_authorization_request_cb);
 
-               char *title = NULL;
-               char *type = NULL;
+       return BT_AUTHORIZATION_TIMEOUT;
+}
 
-               ret = bundle_get_str(kb, "title", &title);
-               if (ret != BUNDLE_ERROR_NONE)
-                       BT_ERR("bundle_get_str() is failed : %d\n", ret);
+static inline int __handle_app_confirm_request(struct bt_popup_appdata *ad, bundle *kb)
+{
+       int ret;
+       int timeout = BT_AUTHORIZATION_TIMEOUT;
+       char *title = NULL;
+       char *type = NULL;
 
-               ret = bundle_get_str(kb, "type", &type);
-               if (ret != BUNDLE_ERROR_NONE)
-                       BT_ERR("bundle_get_str() is failed : %d\n", ret);
+       BT_DBG("app-confirm-request");
 
-               if (!title)
-                       return -1;
+       ret = bundle_get_str(kb, "title", &title);
+       if (ret != BUNDLE_ERROR_NONE)
+               BT_ERR("bundle_get_str() is failed : %d\n", ret);
 
-               if (strcasecmp(type, "twobtn") == 0) {
-                       __bluetooth_draw_popup(ad, NULL, title, BT_STR_CANCEL, BT_STR_OK,
-                                            __bluetooth_app_confirm_cb);
-               } else if (strcasecmp(type, "onebtn") == 0) {
-                       timeout = BT_NOTIFICATION_TIMEOUT;
-                       __bluetooth_draw_popup(ad, NULL, title, BT_STR_OK, NULL,
-                                            __bluetooth_app_confirm_cb);
-               } else if (strcasecmp(type, "none") == 0) {
-                       timeout = BT_NOTIFICATION_TIMEOUT;
-                       __bluetooth_draw_popup(ad, NULL, title, NULL, NULL,
-                                            __bluetooth_app_confirm_cb);
-               }
-       } else if (!strcasecmp(event_type, "push-authorize-request")) {
-               timeout = BT_AUTHORIZATION_TIMEOUT;
+       ret = bundle_get_str(kb, "type", &type);
+       if (ret != BUNDLE_ERROR_NONE)
+               BT_ERR("bundle_get_str() is failed : %d\n", ret);
 
-               ret = bundle_get_str(kb, "device-name", &device_name);
-               if (ret != BUNDLE_ERROR_NONE)
-                       BT_ERR("bundle_get_str() is failed : %d\n", ret);
+       if (!title)
+               return -1;
 
-               ret = bundle_get_str(kb, "file", &file);
-               if (ret != BUNDLE_ERROR_NONE)
-                       BT_ERR("bundle_get_str() is failed : %d\n", ret);
+       if (strcasecmp(type, "twobtn") == 0) {
+               __bluetooth_draw_popup(ad, NULL, title, BT_STR_CANCEL, BT_STR_OK,
+                       __bluetooth_app_confirm_cb);
+       } else if (strcasecmp(type, "onebtn") == 0) {
+               timeout = BT_NOTIFICATION_TIMEOUT;
+               __bluetooth_draw_popup(ad, NULL, title, BT_STR_OK, NULL,
+                       __bluetooth_app_confirm_cb);
+       } else if (strcasecmp(type, "none") == 0) {
+               timeout = BT_NOTIFICATION_TIMEOUT;
+               __bluetooth_draw_popup(ad, NULL, title, NULL, NULL, __bluetooth_app_confirm_cb);
+       }
+       return timeout;
+}
 
-               if (device_name) {
-                       snprintf(view_title, BT_TITLE_STR_MAX_LEN,
-                               "%s%s%s", BT_STR_RECEIVE_PS_FROM_PS_Q, file, device_name);
-               }
+static inline int __handle_push_authorize_request(struct bt_popup_appdata *ad, bundle *kb)
+{
+       int ret;
+       char *file = NULL;
+       char *device_name = NULL;
+       char view_title[BT_TITLE_STR_MAX_LEN];
 
-               __bluetooth_draw_popup(ad, BT_STR_RECEIVE_FILE, view_title, BT_STR_CANCEL, BT_STR_OK,
-                               __bluetooth_push_authorization_request_cb);
-       } else if (!strcasecmp(event_type, "confirm-overwrite-request")) {
-               timeout = BT_AUTHORIZATION_TIMEOUT;
+       ret = bundle_get_str(kb, "device-name", &device_name);
+       if (ret != BUNDLE_ERROR_NONE)
+               BT_ERR("bundle_get_str() is failed : %d\n", ret);
 
-               ret = bundle_get_str(kb, "file", &file);
-               if (ret != BUNDLE_ERROR_NONE)
-                       BT_ERR("bundle_get_str() is failed : %d\n", ret);
+       ret = bundle_get_str(kb, "file", &file);
+       if (ret != BUNDLE_ERROR_NONE)
+               BT_ERR("bundle_get_str() is failed : %d\n", ret);
 
-               stms_str = BT_STR_OVERWRITE_FILE_Q;
+       if (device_name) {
+               snprintf(view_title, sizeof(view_title), "%s%s%s",
+                       BT_STR_RECEIVE_PS_FROM_PS_Q, file, device_name);
+       }
 
-               snprintf(view_title, BT_TITLE_STR_MAX_LEN,
-                               stms_str, file);
+       __bluetooth_draw_popup(ad, BT_STR_RECEIVE_FILE, view_title, BT_STR_CANCEL, BT_STR_OK,
+               __bluetooth_push_authorization_request_cb);
 
-               __bluetooth_draw_popup(ad, BT_STR_RECEIVE_FILE, view_title,
-                               BT_STR_CANCEL, BT_STR_OK,
-                               __bluetooth_app_confirm_cb);
-       } else if (!strcasecmp(event_type, "keyboard-passkey-request")) {
-               ret = bundle_get_str(kb, "device-name", &device_name);
-               if (ret != BUNDLE_ERROR_NONE)
-                       BT_ERR("bundle_get_str() is failed : %d\n", ret);
+       return BT_AUTHORIZATION_TIMEOUT;
+}
 
-               ret = bundle_get_str(kb, "passkey", &passkey);
-               if (ret != BUNDLE_ERROR_NONE)
-                       BT_ERR("bundle_get_str() is failed : %d\n", ret);
+static inline int __handle_confirm_overwrite_request(struct bt_popup_appdata *ad, bundle *kb)
+{
+       int ret;
+       char *file = NULL;
+       char view_title[BT_TITLE_STR_MAX_LEN];
 
+       ret = bundle_get_str(kb, "file", &file);
+       if (ret != BUNDLE_ERROR_NONE)
+               BT_ERR("bundle_get_str() is failed : %d\n", ret);
 
-               if (device_name && passkey) {
-                       stms_str = BT_STR_ENTER_PS_ON_PS_TO_PAIR;
+       char *stms_str = BT_STR_OVERWRITE_FILE_Q;
+       snprintf(view_title, sizeof(view_title), stms_str, file);
 
-                       snprintf(view_title, BT_TITLE_STR_MAX_LEN,
-                               stms_str, passkey, device_name);
+       __bluetooth_draw_popup(ad, BT_STR_RECEIVE_FILE, view_title,
+               BT_STR_CANCEL, BT_STR_OK, __bluetooth_app_confirm_cb);
 
-                       BT_INFO("title: %s", view_title);
+       return BT_AUTHORIZATION_TIMEOUT;
+}
 
-                       __bluetooth_draw_popup(ad, BT_STR_BLUETOOTH_PAIRING_REQUEST,
-                                               view_title,
-                                               BT_STR_CANCEL, NULL,
-                                               __bluetooth_input_cancel_cb);
-               } else {
-                       timeout = BT_ERROR_TIMEOUT;
-               }
-       } else if (!strcasecmp(event_type, "bt-information")) {
-               BT_DBG("bt-information");
-               timeout = BT_NOTIFICATION_TIMEOUT;
+static inline int __handle_bt_information(struct bt_popup_appdata *ad, bundle *kb)
+{
+       int ret;
+       char *title = NULL;
+       char *type = NULL;
 
-               char *title = NULL;
-               char *type = NULL;
+       BT_DBG("bt-information");
 
-               ret = bundle_get_str(kb, "title", &title);
-               if (ret != BUNDLE_ERROR_NONE)
-                       BT_ERR("bundle_get_str() is failed : %d\n", ret);
+       ret = bundle_get_str(kb, "title", &title);
+       if (ret != BUNDLE_ERROR_NONE)
+               BT_ERR("bundle_get_str() is failed : %d\n", ret);
 
-               ret = bundle_get_str(kb, "type", &type);
-               if (ret != BUNDLE_ERROR_NONE)
-                       BT_ERR("bundle_get_str() is failed : %d\n", ret);
+       ret = bundle_get_str(kb, "type", &type);
+       if (ret != BUNDLE_ERROR_NONE)
+               BT_ERR("bundle_get_str() is failed : %d\n", ret);
 
-               if (title != NULL) {
-                       if (strlen(title) > 255)
-                               return -1;
-               } else
+       if (title) {
+               if (255 < strlen(title))
                        return -1;
+       } else
+               return -1;
 
-               if (strcasecmp(type, "onebtn") == 0) {
-                       __bluetooth_draw_popup(ad, NULL, title, BT_STR_OK, NULL,
-                                            __bluetooth_app_confirm_cb);
-               } else if (strcasecmp(type, "none") == 0) {
-                       __bluetooth_draw_popup(ad, NULL, title, NULL, NULL,
-                                            __bluetooth_app_confirm_cb);
-               }
-       } else if (!strcasecmp(event_type, "exchange-request")) {
-               timeout = BT_AUTHORIZATION_TIMEOUT;
+       if (strcasecmp(type, "onebtn") == 0) {
+               __bluetooth_draw_popup(ad, NULL, title, BT_STR_OK, NULL,
+                       __bluetooth_app_confirm_cb);
+       } else if (strcasecmp(type, "none") == 0) {
+               __bluetooth_draw_popup(ad, NULL, title, NULL, NULL, __bluetooth_app_confirm_cb);
+       }
 
-               ret = bundle_get_str(kb, "device-name", &device_name);
-               if (ret != BUNDLE_ERROR_NONE)
-                       BT_ERR("bundle_get_str() is failed : %d\n", ret);
+       return BT_NOTIFICATION_TIMEOUT;
+}
 
-               ret = bundle_get_str(kb, "agent-path", &agent_path);
-               if (ret != BUNDLE_ERROR_NONE)
-                       BT_ERR("bundle_get_str() is failed : %d\n", ret);
+static inline int __handle_exchange_request(struct bt_popup_appdata *ad, bundle *kb)
+{
+       int ret;
+       char *device_name = NULL;
+       char *agent_path = NULL;
+       char view_title[BT_TITLE_STR_MAX_LEN];
 
-               ad->agent_proxy = __bluetooth_create_agent_proxy(ad->conn, agent_path);
-               if (!ad->agent_proxy)
-                       return -1;
+       ret = bundle_get_str(kb, "device-name", &device_name);
+       if (ret != BUNDLE_ERROR_NONE)
+               BT_ERR("bundle_get_str() is failed : %d\n", ret);
 
-               if (device_name) {
-                       stms_str = BT_STR_WANTS_TO_SEND_YOU_A_FILE;
+       ret = bundle_get_str(kb, "agent-path", &agent_path);
+       if (ret != BUNDLE_ERROR_NONE)
+               BT_ERR("bundle_get_str() is failed : %d\n", ret);
 
-                       snprintf(view_title, BT_TITLE_STR_MAX_LEN,
-                               stms_str, device_name);
-               }
+       ad->agent_proxy = __bluetooth_create_agent_proxy(ad->conn, agent_path);
+       if (!ad->agent_proxy)
+               return -1;
 
-               __bluetooth_draw_popup(ad, BT_STR_RECEIVE_FILE,
-                               view_title, BT_STR_CANCEL, BT_STR_ACCEPT,
-                                    __bluetooth_authorization_request_cb);
-       } else if (!strcasecmp(event_type, "phonebook-request")) {
-               timeout = BT_AUTHORIZATION_TIMEOUT;
+       if (device_name) {
+               char *stms_str = BT_STR_WANTS_TO_SEND_YOU_A_FILE;
+               snprintf(view_title, sizeof(view_title), stms_str, device_name);
+       }
 
-               ret = bundle_get_str(kb, "device-name", &device_name);
-               if (ret != BUNDLE_ERROR_NONE)
-                       BT_ERR("bundle_get_str() is failed : %d\n", ret);
+       __bluetooth_draw_popup(ad, BT_STR_RECEIVE_FILE, view_title, BT_STR_CANCEL,
+               BT_STR_ACCEPT, __bluetooth_authorization_request_cb);
 
-               ret = bundle_get_str(kb, "agent-path", &agent_path);
-               if (ret != BUNDLE_ERROR_NONE)
-                       BT_ERR("bundle_get_str() is failed : %d\n", ret);
+       return BT_AUTHORIZATION_TIMEOUT;
+}
 
+static inline int __handle_pb_and_msg_request(struct bt_popup_appdata *ad, bundle *kb, const char *stms_str)
+{
+       int ret;
+       char *device_name = NULL;
+       char *agent_path = NULL;
+       char *conv_str = NULL;
+       char view_title[BT_TITLE_STR_MAX_LEN];
 
-               ad->agent_proxy = __bluetooth_create_agent_proxy(ad->conn, agent_path);
-               if (!ad->agent_proxy)
-                       return -1;
+       ret = bundle_get_str(kb, "device-name", &device_name);
+       if (ret != BUNDLE_ERROR_NONE)
+               BT_ERR("bundle_get_str() is failed : %d\n", ret);
 
-               if (device_name)
-                       conv_str = elm_entry_utf8_to_markup(device_name);
+       ret = bundle_get_str(kb, "agent-path", &agent_path);
+       if (ret != BUNDLE_ERROR_NONE)
+               BT_ERR("bundle_get_str() is failed : %d\n", ret);
 
-               stms_str = BT_STR_PS_CONTACT_REQUEST;
+       ad->agent_proxy = __bluetooth_create_agent_proxy(ad->conn, agent_path);
+       if (!ad->agent_proxy)
+               return -1;
 
-               snprintf(view_title, BT_TITLE_STR_MAX_LEN,
-                       stms_str, conv_str);
+       if (device_name)
+               conv_str = elm_entry_utf8_to_markup(device_name);
 
-               if (conv_str)
-                       free(conv_str);
+       snprintf(view_title, sizeof(view_title), stms_str, conv_str);
+       free(conv_str);
 
 #ifdef TIZEN_REDWOOD
-               __bluetooth_draw_auth_popup(ad, view_title, BT_STR_CANCEL, BT_STR_OK,
-                                    __bluetooth_authorization_request_cb);
+       __bluetooth_draw_auth_popup(ad, view_title, BT_STR_CANCEL, BT_STR_OK,
+               __bluetooth_authorization_request_cb);
 #else
-               __bluetooth_draw_access_request_popup(ad, BT_STR_ALLOW_APP_PERMISSION,
-                                       view_title, BT_STR_CANCEL, BT_STR_ALLOW,
-                                       __bluetooth_authorization_request_cb);
+       __bluetooth_draw_access_request_popup(ad, BT_STR_ALLOW_APP_PERMISSION,
+               view_title, BT_STR_CANCEL, BT_STR_ALLOW,
+               __bluetooth_authorization_request_cb);
 #endif
-       } else if (!strcasecmp(event_type, "message-request")) {
-               timeout = BT_AUTHORIZATION_TIMEOUT;
-
-               ret = bundle_get_str(kb, "device-name", &device_name);
-               if (ret != BUNDLE_ERROR_NONE)
-                       BT_ERR("bundle_get_str() is failed : %d\n", ret);
-
-               ret = bundle_get_str(kb, "agent-path", &agent_path);
-               if (ret != BUNDLE_ERROR_NONE)
-                       BT_ERR("bundle_get_str() is failed : %d\n", ret);
-
-               ad->agent_proxy = __bluetooth_create_agent_proxy(ad->conn, agent_path);
-               if (!ad->agent_proxy)
-                       return -1;
-
-               if (device_name)
-                       conv_str = elm_entry_utf8_to_markup(device_name);
+       return BT_AUTHORIZATION_TIMEOUT;
+}
 
-               stms_str = BT_STR_PS_MESSAGE_REQUEST;
+static inline void __handle_pairing_retry_request(struct bt_popup_appdata *ad, bundle *kb)
+{
+       int ret;
+       char *conv_str = NULL;
+       char *device_name = NULL;
+       char view_title[BT_TITLE_STR_MAX_LEN];
 
-               snprintf(view_title, BT_TITLE_STR_MAX_LEN,
-                       stms_str, conv_str);
+       ret = bundle_get_str(kb, "device-name", &device_name);
+       if (ret != BUNDLE_ERROR_NONE)
+               BT_ERR("bundle_get_str() is failed : %d\n", ret);
 
-               if (conv_str)
-                       free(conv_str);
+       if (device_name)
+               conv_str = elm_entry_utf8_to_markup(device_name);
 
-#ifdef TIZEN_REDWOOD
-               __bluetooth_draw_auth_popup(ad, view_title, BT_STR_CANCEL, BT_STR_OK,
-                                    __bluetooth_authorization_request_cb);
-#else
-               __bluetooth_draw_access_request_popup(ad, BT_STR_ALLOW_APP_PERMISSION,
-                                       view_title, BT_STR_CANCEL, BT_STR_ALLOW,
-                                       __bluetooth_authorization_request_cb);
-#endif
-       } else if (!strcasecmp(event_type, "pairing-retry-request")) {
-               int ret;
-               ret = bundle_get_str(kb, "device-name", &device_name);
-               if (ret != BUNDLE_ERROR_NONE)
-                       BT_ERR("bundle_get_str() is failed : %d\n", ret);
+       char *stms_str = BT_STR_UNABLE_TO_PAIR;
+       snprintf(view_title, sizeof(view_title), stms_str, conv_str);
+       free(conv_str);
 
-               if (device_name)
-                       conv_str = elm_entry_utf8_to_markup(device_name);
+       ret = notification_status_message_post(view_title);
+       if (ret != NOTIFICATION_ERROR_NONE)
+               BT_ERR("notification_status_message_post() is failed : %d\n", ret);
+}
 
-               stms_str = BT_STR_UNABLE_TO_PAIR;
+static inline void __handle_remote_legacy_pair_failed(struct bt_popup_appdata *ad, bundle *kb)
+{
+       int ret;
+       char *conv_str = NULL;
+       char *device_name = NULL;
+       char text[BT_GLOBALIZATION_STR_LENGTH];
 
-               snprintf(view_title, BT_TITLE_STR_MAX_LEN,
-                       stms_str, conv_str);
+       BT_DBG("remote-legacy-pair-failed");
+       ret = bundle_get_str(kb, "device-name", &device_name);
+       if (ret != BUNDLE_ERROR_NONE)
+               BT_ERR("bundle_get_str() is failed : %d\n", ret);
 
-               if (conv_str)
-                       free(conv_str);
+       if (device_name)
+               conv_str = elm_entry_utf8_to_markup(device_name);
 
-               ret = notification_status_message_post(view_title);
-               if (ret != NOTIFICATION_ERROR_NONE)
-                       BT_ERR("notification_status_message_post() is failed : %d\n", ret);
-       } else if (!strcasecmp(event_type, "remote-legacy-pair-failed")) {
-               BT_DBG("remote-legacy-pair-failed");
-               ret = bundle_get_str(kb, "device-name", &device_name);
-               if (ret != BUNDLE_ERROR_NONE)
-                       BT_ERR("bundle_get_str() is failed : %d\n", ret);
+       char *stms_str = BT_STR_UNABLE_TO_PAIR;
+       snprintf(text, sizeof(text), stms_str, conv_str);
+       free(conv_str);
 
-               if (device_name)
-                       conv_str = elm_entry_utf8_to_markup(device_name);
+       __bluetooth_draw_information_popup(ad, "Bluetooth Error",
+               text, BT_STR_OK, __bluetooth_information_cb);
+}
 
-               stms_str = BT_STR_UNABLE_TO_PAIR;
+/* AUL bundle handler */
+static int __bluetooth_launch_handler(struct bt_popup_appdata *ad,
+                            void *reset_data, const char *event_type)
+{
+       FN_START;
+       int timeout = 0;
+       bundle *kb = (bundle *) reset_data;
 
-               snprintf(text, BT_GLOBALIZATION_STR_LENGTH,
-                       stms_str, conv_str);
+       if (!reset_data || !event_type)
+               return -1;
 
-               if (conv_str)
-                       free(conv_str);
+       BT_INFO("Event Type = %s[0X%X]", event_type, ad->event_type);
 
-               __bluetooth_draw_information_popup(ad, "Bluetooth Error",
-                                       text, BT_STR_OK,
-                                       __bluetooth_information_cb);
+       if (!strcasecmp(event_type, "pin-request")) {
+               timeout = __handle_pin_request(ad, kb);
+       } else if (!strcasecmp(event_type, "passkey-confirm-request")) {
+               timeout = __handle_passkey_confirm_request(ad, kb);
+       } else if (!strcasecmp(event_type, "visibility-request")) {
+               timeout = __handle_visibility_request(ad, kb);
+       } else if (!strcasecmp(event_type, "passkey-request")) {
+               timeout = __handle_passkey_request(ad, kb);
+       } else if (!strcasecmp(event_type, "passkey-display-request")) {
+               timeout = __handle_passkey_event_requests(ad, kb, BT_STR_SHOW_PASSWORD);
+       } else if (!strcasecmp(event_type, "authorize-request")) {
+               timeout = __handle_authorize_request(ad, kb);
+       } else if (!strcasecmp(event_type, "app-confirm-request")) {
+               timeout = __handle_app_confirm_request(ad, kb);
+       } else if (!strcasecmp(event_type, "push-authorize-request")) {
+               timeout = __handle_push_authorize_request(ad, kb);
+       } else if (!strcasecmp(event_type, "confirm-overwrite-request")) {
+               timeout = __handle_confirm_overwrite_request(ad, kb);
+       } else if (!strcasecmp(event_type, "keyboard-passkey-request")) {
+               timeout = __handle_passkey_event_requests(ad, kb,
+                       BT_STR_BLUETOOTH_PAIRING_REQUEST);
+       } else if (!strcasecmp(event_type, "bt-information")) {
+               timeout = __handle_bt_information(ad, kb);
+       } else if (!strcasecmp(event_type, "exchange-request")) {
+               timeout = __handle_exchange_request(ad, kb);
+       } else if (!strcasecmp(event_type, "phonebook-request")) {
+               timeout = __handle_pb_and_msg_request(ad, kb, BT_STR_PS_CONTACT_REQUEST);
+       } else if (!strcasecmp(event_type, "message-request")) {
+               timeout = __handle_pb_and_msg_request(ad, kb, BT_STR_PS_MESSAGE_REQUEST);
+       } else if (!strcasecmp(event_type, "pairing-retry-request")) {
+               __handle_pairing_retry_request(ad, kb);
+       } else if (!strcasecmp(event_type, "remote-legacy-pair-failed")) {
+               __handle_remote_legacy_pair_failed(ad, kb);
        } else if (!strcasecmp(event_type, "music-auto-connect-request")) {
                __bluetooth_draw_toast_popup(ad, "Connecting...");
        } else {
                return -1;
        }
 
+       if (timeout < 0)
+               return -1;
+
        if (ad->event_type != BT_EVENT_FILE_RECEIVED && timeout != 0) {
                ad->timer = ecore_timer_add(timeout, (Ecore_Task_Cb)
                                        __bluetooth_request_timeout_cb, ad);
index ad6c2a6..e95a353 100644 (file)
@@ -67,7 +67,7 @@ static int __bluetooth_timeout(bundle *b, void *data)
        return 0;
 }
 
-syspopup_handler handler = {
+static syspopup_handler handler = {
        .def_term_fn = __bluetooth_term,
        .def_timeout_fn = __bluetooth_timeout
 };
@@ -1754,8 +1754,7 @@ static int __bluetooth_launch_handler(struct bt_popup_appdata *ad,
                /* Request user inputted PIN for basic pairing */
                __bluetooth_draw_input_view(ad, view_title, conv_str);
 
-               if (conv_str)
-                       free(conv_str);
+               free(conv_str);
                break;
 
        case BT_EVENT_PASSKEY_CONFIRM_REQUEST:
@@ -1771,10 +1770,8 @@ static int __bluetooth_launch_handler(struct bt_popup_appdata *ad,
                        conv_str = elm_entry_utf8_to_markup(device_name);
 
                        stms_str = BT_STR_CONFIRM_PASSKEY_PS_TO_PAIR_WITH_PS;
-                       snprintf(view_title, BT_TITLE_STR_MAX_LEN, stms_str,
-                            conv_str, passkey);
-                       if (conv_str)
-                               free(conv_str);
+                       snprintf(view_title, sizeof(view_title), stms_str, conv_str, passkey);
+                       free(conv_str);
                        BT_INFO("title: %s", view_title);
 
                        __bluetooth_draw_text_popup(ad, view_title,
@@ -1807,8 +1804,7 @@ static int __bluetooth_launch_handler(struct bt_popup_appdata *ad,
                        conv_str = elm_entry_utf8_to_markup(device_name);
 
                        __bluetooth_draw_text_popup_no_button(ad, conv_str, passkey);
-                       if (conv_str)
-                               free(conv_str);
+                       free(conv_str);
 
                        __bluetooth_send_signal_pairing_confirm_result(ad, 1);
                        g_dbus_proxy_call(ad->agent_proxy,
@@ -1833,18 +1829,15 @@ static int __bluetooth_launch_handler(struct bt_popup_appdata *ad,
                if (device_name)
                        conv_str = elm_entry_utf8_to_markup(device_name);
 
-               snprintf(view_title, BT_TITLE_STR_MAX_LEN,
-                        "%s", BT_STR_PAIRING_REQUEST);
+               snprintf(view_title, sizeof(view_title), "%s", BT_STR_PAIRING_REQUEST);
 
                stms_str = BT_STR_ENTER_PIN_TO_PAIR;
-               snprintf(text, BT_GLOBALIZATION_STR_LENGTH,
-                        stms_str, conv_str);
+               snprintf(text, sizeof(text), stms_str, conv_str);
 
                /* Request user inputted Passkey for basic pairing */
                __bluetooth_draw_input_view(ad, view_title, conv_str);
 
-               if (conv_str)
-                       free(conv_str);
+               free(conv_str);
                break;
        }
 
@@ -1856,11 +1849,9 @@ static int __bluetooth_launch_handler(struct bt_popup_appdata *ad,
                        conv_str = elm_entry_utf8_to_markup(device_name);
 
                        stms_str = BT_STR_ENTER_PS_ON_PS_TO_PAIR;
-                       snprintf(view_title, BT_TITLE_STR_MAX_LEN,
-                            stms_str, passkey, conv_str);
+                       snprintf(view_title, sizeof(view_title), stms_str, passkey, conv_str);
 
-                       if (conv_str)
-                               free(conv_str);
+                       free(conv_str);
 
                        __bluetooth_draw_passkey_display_popup(ad, view_title,
                                        __bluetooth_input_cancel_cb, ad);
@@ -1884,11 +1875,9 @@ static int __bluetooth_launch_handler(struct bt_popup_appdata *ad,
                        conv_str = elm_entry_utf8_to_markup(device_name);
 
                stms_str = BT_STR_ALLOW_PS_TO_CONNECT_Q;
-               snprintf(view_title, BT_TITLE_STR_MAX_LEN,
-                               stms_str, conv_str);
+               snprintf(view_title, sizeof(view_title), stms_str, conv_str);
 
-               if (conv_str)
-                       free(conv_str);
+               free(conv_str);
 
                __bluetooth_draw_auth_popup(ad, view_title,
                                __bluetooth_authorization_request_cb);
@@ -1902,11 +1891,9 @@ static int __bluetooth_launch_handler(struct bt_popup_appdata *ad,
                        conv_str = elm_entry_utf8_to_markup(device_name);
 
                        stms_str = BT_STR_ENTER_PS_ON_PS_TO_PAIR;
-                       snprintf(view_title, BT_TITLE_STR_MAX_LEN,
-                            stms_str, passkey, conv_str);
+                       snprintf(view_title, sizeof(view_title), stms_str, passkey, conv_str);
 
-                       if (conv_str)
-                               free(conv_str);
+                       free(conv_str);
 
                        __bluetooth_draw_passkey_display_popup(ad, view_title,
                                        __bluetooth_input_cancel_cb, ad);
@@ -1936,10 +1923,8 @@ static int __bluetooth_launch_handler(struct bt_popup_appdata *ad,
 
                if (device_name) {
                        stms_str = BT_STR_RESET;
-                       snprintf(view_title, BT_TITLE_STR_MAX_LEN,
-                                       stms_str, device_name, device_name);
-                       __bluetooth_draw_reset_popup(ad, view_title,
-                                       __bluetooth_reset_cb);
+                       snprintf(view_title, sizeof(view_title), stms_str, device_name, device_name);
+                       __bluetooth_draw_reset_popup(ad, view_title, __bluetooth_reset_cb);
                } else {
                        BT_ERR("device name NULL");
                        timeout = BT_ERROR_TIMEOUT;
@@ -2191,6 +2176,44 @@ static void __bluetooth_resume(void *data)
        return;
 }
 
+static int __bluetooth_reset_sub(app_control_h app_control, struct bt_popup_appdata *ad)
+{
+       char *operation = NULL;
+
+       BT_ERR("event type is NULL");
+
+       /* Get app control operation */
+       if (app_control_get_operation(app_control, &operation) < 0) {
+               BT_ERR("Get operation error");
+               return -1;
+       }
+
+       if (operation)
+               BT_INFO("operation: %s", operation);
+
+       if (g_strcmp0(operation, APP_CONTROL_OPERATION_SETTING_BT_VISIBILITY) == 0) {
+               char *timeout = NULL;
+
+               ad->visibility_timeout = NULL;
+               int ret = app_control_get_extra_data(app_control, "timeout", &timeout);
+               if (ret < 0) {
+                       BT_ERR("Get data error");
+               } else {
+                       BT_INFO("Get visibility timeout : %s", timeout);
+                       if (timeout)
+                               ad->visibility_timeout = timeout;
+               }
+
+               ad->event_type = BT_EVENT_VISIBILITY_REQUEST;
+       } else if (g_strcmp0(operation, APP_CONTROL_OPERATION_SETTING_BT_ENABLE) == 0) {
+               ad->event_type = BT_EVENT_ENABLE_REQUEST;
+       } else {
+               BT_ERR("Abnormal app control operation!");
+               return -1;
+       }
+       return 0;
+}
+
 static void __bluetooth_reset(app_control_h app_control, void *user_data)
 {
        struct bt_popup_appdata *ad = user_data;
@@ -2211,39 +2234,9 @@ static void __bluetooth_reset(app_control_h app_control, void *user_data)
        /* Start Main UI */
        event_type = bundle_get_val(b, "event-type");
        if (event_type == NULL) {
-               char *operation = NULL;
-
-               BT_ERR("event type is NULL");
-
-               /* Get app control operation */
-               if (app_control_get_operation(app_control, &operation) < 0) {
-                       BT_ERR("Get operation error");
+               ret = __bluetooth_reset_sub(app_control, ad);
+               if (ret < 0)
                        return;
-               }
-
-               if (operation)
-                       BT_INFO("operation: %s", operation);
-
-               if (g_strcmp0(operation, APP_CONTROL_OPERATION_SETTING_BT_VISIBILITY) == 0) {
-                       char *timeout = NULL;
-
-                       ad->visibility_timeout = NULL;
-                       ret = app_control_get_extra_data(app_control, "timeout", &timeout);
-                       if (ret < 0) {
-                               BT_ERR("Get data error");
-                       } else {
-                               BT_INFO("Get visibility timeout : %s", timeout);
-                               if (timeout)
-                                       ad->visibility_timeout = timeout;
-                       }
-
-                       ad->event_type = BT_EVENT_VISIBILITY_REQUEST;
-               } else if (g_strcmp0(operation, APP_CONTROL_OPERATION_SETTING_BT_ENABLE) == 0) {
-                       ad->event_type = BT_EVENT_ENABLE_REQUEST;
-               } else {
-                       BT_ERR("Abnormal app control operation!");
-                       return;
-               }
        } else {
                BT_INFO("event_type : %s", event_type);
 
@@ -2273,14 +2266,12 @@ static void __bluetooth_reset(app_control_h app_control, void *user_data)
                        BT_ERR("syspopup_reset err");
                        return;
                }
-
-               goto DONE;
+       } else {
+               ret = syspopup_create(b, &handler, ad->win_main, ad);
+               if (ret == -1)
+                       BT_ERR("No syspopup call - Just AUL operation");
        }
 
-       ret = syspopup_create(b, &handler, ad->win_main, ad);
-       if (ret == -1)
-               BT_ERR("No syspopup call - Just AUL operation");
-DONE:
        ret = __bluetooth_launch_handler(ad, b);
        if (ret != 0) {
                BT_ERR("__bluetooth_launch_handler is failed. event[%d], ret[%d]",