return 0;
}
-syspopup_handler handler = {
+static syspopup_handler handler = {
.def_term_fn = __bluetooth_term,
.def_timeout_fn = __bluetooth_timeout
};
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");
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);