4 * Copyright 2012 Samsung Electronics Co., Ltd
6 * Contact: Hocheol Seo <hocheol.seo@samsung.com>
7 * GirishAshok Joshi <girish.joshi@samsung.com>
8 * DoHyun Pyun <dh79.pyun@samsung.com>
10 * Licensed under the Flora License, Version 1.1 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.tizenopensource.org/license
16 * Unless required by applicable law or agreed to in writing,
17 * software distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
26 #include <eina_list.h>
28 #include <bluetooth.h>
29 #include <syspopup_caller.h>
30 #include <dbus/dbus.h>
32 #include <app_control.h>
33 #include <notification.h>
34 #include <efl_extension.h>
37 #include "bt-main-ug.h"
38 #include "bt-string-define.h"
39 #include "bt-main-view.h"
40 #include "bt-profile-view.h"
41 #include "bt-ipc-handler.h"
44 #include "bt-callback.h"
45 #include "bt-widget.h"
46 #include "bt-resource.h"
47 #include "bt-net-connection.h"
48 #include "bluetooth_internal.h"
49 #include "syspopup_caller.h"
51 #define MULTI_SHARE_SERVICE_DATA_PATH "http://tizen.org/appcontrol/data/path"
52 #define APP_CONTROL_OPERATION_SHARE_CONTACT "http://tizen.org/appcontrol/operation/share_contact"
53 #define APP_CONTROL_MIME_CONTACT "application/vnd.tizen.contact"
54 #define APP_CONTROL_MY_PROFILE_DATA_TYPE "my_profile"
55 #define SERVICE_SHARE_CONTACT_MODE "http://tizen.org/appcontrol/data/social/namecard_share_mode"
56 #define SERVICE_SHARE_CONTACT_ITEM "http://tizen.org/appcontrol/data/social/item_type"
57 #define SHARE_CONTACT_DATA_PATH "/opt/usr/media/Downloads/.bluetooth"
58 #define SHARE_CONTACT_ITEM_ID_ARRAY "http://tizen.org/appcontrol/data/social/item_id"
59 #define SHARE_CONTACT_ITEM_SHARE_MODE "http://tizen.org/appcontrol/data/social/namecard_share_mode"
60 #define HELP_SETUP_BLUETOOTH_URI "tizen-help://ug-bluetooth-efl/setupbluetooth"
63 #define HOGP_SERVICE_UUID "1812"
65 /**********************************************************************
66 * Static Functions declaration
67 ***********************************************************************/
69 static void __bt_main_onoff_btn_cb(void *data, Evas_Object *obj, void *event_info);
71 static app_control_h __bt_main_get_bt_onoff_result(bt_ug_data *ugd,
74 static app_control_h __bt_main_get_pick_result(bt_ug_data *ugd, gboolean result);
76 static int __bt_main_request_to_send(bt_ug_data *ugd, bt_dev_t *dev);
78 #ifdef KIRAN_ACCESSIBILITY
79 static char *__bt_main_get_device_string(int major_class, int minor_class);
81 static Eina_Bool __bt_cb_register_net_state_cb(void *data);
83 /**********************************************************************
85 ***********************************************************************/
87 static char *__bt_main_onoff_label_get(void *data, Evas_Object *obj,
91 bt_ug_data *ugd = NULL;
93 retv_if(data == NULL, NULL);
94 ugd = (bt_ug_data *)data;
96 if (!strcmp("elm.text", part)) {
97 return g_strdup(BT_STR_BLUETOOTH);
98 } else if (!strcmp("elm.text.multiline", part) || !strcmp("elm.text.sub", part)) {
99 char buf[1024] = {0,};
100 if (ugd->op_status == BT_ACTIVATING) {
102 snprintf(buf, sizeof(buf), "<font_size=15>%s</font_size>", BT_STR_TURNING_ON_BLUETOOTH);
104 snprintf(buf, sizeof(buf), "<font_size=30>%s</font_size>", BT_STR_TURNING_ON_BLUETOOTH);
105 return g_strdup(buf);
106 } else if (ugd->op_status == BT_DEACTIVATED) {
108 snprintf(buf, sizeof(buf), "<font_size=15>%s</font_size>", BT_STR_TURN_ON_BLUETOOTH_TO_SEE_A_LIST_OF_AVAILABLE_DEVICES);
110 snprintf(buf, sizeof(buf), "<font_size=30>%s</font_size>", BT_STR_TURN_ON_BLUETOOTH_TO_SEE_A_LIST_OF_AVAILABLE_DEVICES);
112 return g_strdup(buf);
120 static Evas_Object *__bt_main_onoff_icon_get(void *data, Evas_Object *obj,
125 bt_ug_data *ugd = NULL;
126 Evas_Object *btn = NULL;
127 bool activated = false;
128 char *icon_part = NULL;
130 retv_if(data == NULL, NULL);
133 icon_part = BT_GENLIST_ONOFF_ICON_PART_COMMON;
135 icon_part = BT_GENLIST_ONOFF_ICON_PART;
137 ugd = (bt_ug_data *)data;
139 if (!strcmp(icon_part, part)) {
140 if (ugd->op_status == BT_ACTIVATING
141 || ugd->op_status == BT_DEACTIVATING) {
142 btn = elm_progressbar_add(obj);
145 elm_object_style_set(btn, "process_small");
147 elm_object_style_set(btn, "process_medium");
149 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, 0.5);
150 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
151 elm_progressbar_pulse(btn, TRUE);
153 activated = ((ugd->op_status == BT_DEACTIVATED) ||
154 (ugd->op_status == BT_ACTIVATING)) ? false : true;
155 btn = elm_check_add(obj);
156 elm_object_style_set(btn, "on&off");
157 evas_object_pass_events_set(btn, EINA_TRUE);
158 evas_object_propagate_events_set(btn, EINA_FALSE);
159 elm_check_state_set(btn, activated);
161 #ifdef KIRAN_ACCESSIBILITY
162 elm_access_object_unregister(btn);
165 /* add smart callback */
166 evas_object_smart_callback_add(btn, "changed",
167 __bt_main_onoff_btn_cb, ugd);
169 ugd->onoff_btn = btn;
172 if (_bt_util_is_dpm_restricted(ugd->dpm_handle) == TRUE)
173 elm_object_disabled_set(btn, EINA_TRUE);
175 evas_object_show(btn);
182 static char *__bt_main_rename_desc_label_get(void *data, Evas_Object *obj,
187 if (!strcmp("elm.text.multiline", part)) {
188 char buf[1024] = {0,};
189 snprintf(buf, sizeof(buf), "<font_size=30>%s</font_size>",
190 BT_STR_RENAME_DEVICE_LABEL);
191 return g_strdup(buf);
198 static char *__bt_main_device_label_get(void *data, Evas_Object *obj,
203 bt_ug_data *ugd = NULL;
204 char buf[BT_GLOBALIZATION_STR_LENGTH] = { 0, };
205 char *dev_name = NULL;
207 #ifdef KIRAN_ACCESSIBILITY
208 char str[BT_STR_ACCES_INFO_MAX_LEN] = { 0, };
209 Evas_Object *ao = NULL;
211 retv_if(data == NULL, NULL);
213 ugd = (bt_ug_data *)data;
214 BT_DBG("part : %s", part);
216 if (!strcmp("elm.text", part)) {
217 memset(ugd->phone_name, 0x00, BT_GLOBALIZATION_STR_LENGTH);
219 _bt_util_get_phone_name(ugd->phone_name, sizeof(ugd->phone_name));
221 if (strlen(ugd->phone_name) == 0) {
222 if (bt_adapter_get_name(&dev_name) == BT_ERROR_NONE) {
223 g_strlcpy(ugd->phone_name, dev_name,
224 BT_GLOBALIZATION_STR_LENGTH);
229 BT_DBG("ugd->phone_name : %s[%zd]", ugd->phone_name, strlen(ugd->phone_name));
230 /* Check the utf8 valitation & Fill the NULL in the invalid location */
231 if (!g_utf8_validate(ugd->phone_name, -1, (const char **)&ptr))
234 dev_name = elm_entry_utf8_to_markup(ugd->phone_name);
236 g_strlcpy(buf, dev_name, BT_GLOBALIZATION_STR_LENGTH);
239 g_strlcpy(buf, ugd->phone_name, BT_GLOBALIZATION_STR_LENGTH);
241 #ifdef KIRAN_ACCESSIBILITY
242 snprintf(str, sizeof(str), "%s, %s",
243 BT_STR_DEVICE_NAME, ugd->phone_name);
244 ao = elm_object_item_access_object_get(ugd->device_name_item);
245 elm_access_info_set(ao, ELM_ACCESS_INFO, str);
248 BT_DBG("buf : %s[%zd]", buf, strlen(buf));
250 } else if (!strcmp("elm.text.sub", part)) {
251 g_strlcpy(buf, BT_STR_MY_DEVICE,
252 BT_GLOBALIZATION_STR_LENGTH);
253 #ifdef KIRAN_ACCESSIBILITY
254 ao = elm_object_item_access_object_get(ugd->paired_title);
255 snprintf(str, sizeof(str), "%s, %s", BT_STR_PAIRED_DEVICES,
256 BT_ACC_STR_GROUP_INDEX);
257 elm_access_info_set(ao, ELM_ACCESS_INFO, str);
262 BT_ERR("This part name is not exist in style.");
267 char* __bt_convert_rgba_to_hex(int r, int g, int b, int a)
272 string = g_try_malloc0(sizeof(char) * 255);
273 /* Fix : NULL_RETURNS */
277 hexcolor = (r << 24) + (g << 16) + (b << 8) + a;
278 sprintf(string, "%08x", hexcolor);
283 int _bt_idle_destroy_ug(void *data)
287 bt_ug_data *ugd = data;
288 app_control_h service = NULL;
290 retv_if(ugd == NULL, BT_UG_FAIL);
292 if (ugd->bt_launch_mode == BT_LAUNCH_PICK)
293 service = __bt_main_get_pick_result(ugd, TRUE);
294 else if (ugd->bt_launch_mode == BT_LAUNCH_ONOFF)
295 service = __bt_main_get_bt_onoff_result(ugd, TRUE);
297 _bt_ug_destroy(data, (void *)service);
300 app_control_destroy(service);
303 return BT_UG_ERROR_NONE;
306 gboolean _bt_main_is_connectable_device(bt_dev_t *dev)
310 bt_device_info_s *device_info = NULL;
312 retv_if(dev == NULL, FALSE);
315 if (TIZEN_FEATURE_BT_HOG && dev->is_le_device) {
316 BT_DBG("It is LE Device");
320 if (dev->service_list == 0) {
321 if (bt_adapter_get_bonded_device_info
322 ((const char *)dev->addr_str,
323 &device_info) != BT_ERROR_NONE) {
325 bt_adapter_free_device_info(device_info);
328 bt_device_get_service_mask_from_uuid_list
329 (device_info->service_uuid, device_info->service_count,
332 bt_adapter_free_device_info(device_info);
334 if (dev->service_list == 0) {
335 BT_ERR("No service list");
340 if ((dev->service_list & BT_SC_HFP_SERVICE_MASK) ||
341 (dev->service_list & BT_SC_HSP_SERVICE_MASK) ||
342 (dev->service_list & BT_SC_A2DP_SERVICE_MASK) ||
343 #ifdef TIZEN_BT_A2DP_SINK_ENABLE
344 (dev->service_list & BT_SC_A2DP_SOURCE_SERVICE_MASK) ||
346 (dev->service_list & BT_SC_HID_SERVICE_MASK) ||
347 (dev->service_list & BT_SC_NAP_SERVICE_MASK)) {
348 /* Connectable device */
356 static char *__bt_main_paired_device_label_get(void *data, Evas_Object *obj,
362 #ifdef KIRAN_ACCESSIBILITY
363 char str[BT_STR_ACCES_INFO_MAX_LEN] = { 0, };
365 bt_dev_t *dev = NULL;
366 bt_ug_data *ugd = NULL;
367 int r = 0, g = 0, b = 0, a = 0;
369 retv_if(data == NULL, NULL);
371 dev = (bt_dev_t *)data;
372 retv_if(dev == NULL, NULL);
374 ugd = (bt_ug_data *)dev->ugd;
375 retv_if(ugd == NULL, NULL);
377 if (!strcmp("elm.text", part)) {
378 char *name = elm_entry_utf8_to_markup(dev->name);
380 if (ugd->bt_launch_mode != BT_LAUNCH_PICK &&
381 dev->is_connected > 0 && dev->highlighted == FALSE) {
382 r = 20, g = 107, b = 147, a = 255;
383 char *color_code = __bt_convert_rgba_to_hex(r, g, b, a);
385 buf = g_strdup_printf("<color=#%s>%s</color>",
390 buf = g_strdup_printf("<color=#%s>%s</color>",
399 buf = g_strdup_printf("%s",
403 buf = g_strdup_printf("%s",
406 } else if (!strcmp("elm.text.sub", part) && ugd->bt_launch_mode != BT_LAUNCH_PICK) {
407 #ifdef KIRAN_ACCESSIBILITY
408 char *double_tap_string = NULL;
409 char *device_type = NULL;
410 Evas_Object *ao = NULL;
413 if (dev->status == BT_IDLE) {
414 if (_bt_main_is_connectable_device(dev)) {
415 if (dev->is_connected == 0) {
416 buf = g_strdup(BT_STR_PAIRED);
417 #ifdef KIRAN_ACCESSIBILITY
418 double_tap_string = NULL;
420 } else if (dev->is_connected > 0) {
421 buf = g_strdup(BT_STR_CONNECTED);
422 #ifdef KIRAN_ACCESSIBILITY
424 BT_STR_DOUBLE_TAP_DISCONNECT_D;
428 buf = g_strdup(BT_STR_PAIRED);
429 #ifdef KIRAN_ACCESSIBILITY
430 double_tap_string = BT_STR_DOUBLE_TAP_CONNECT_D;
433 } else if (dev->status == BT_CONNECTING) {
434 buf = g_strdup(BT_STR_CONNECTING);
435 } else if (dev->status == BT_SERVICE_SEARCHING) {
436 buf = g_strdup(BT_STR_SEARCHING_SERVICES);
437 } else if (dev->status == BT_DISCONNECTING) {
438 buf = g_strdup(BT_STR_DISCONNECTING);
440 #ifdef KIRAN_ACCESSIBILITY
442 __bt_main_get_device_string(dev->major_class,
444 if (double_tap_string != NULL && buf != NULL)
445 snprintf(str, sizeof(str), "%s, %s, %s, %s, %s",
447 device_type, double_tap_string,
449 else if (double_tap_string == NULL && buf != NULL)
450 snprintf(str, sizeof(str), "%s, %s, %s, %s",
452 device_type, BT_STR_MORE_BUTTON);
455 ao = elm_object_item_access_object_get(dev->genlist_item);
456 elm_access_info_set(ao, ELM_ACCESS_INFO, str);
458 } else { /* for empty item */
460 BT_ERR("empty text for label");
467 static void __bt_paired_device_profile_cb(void *data, Evas_Object *obj,
472 bt_dev_t *dev = NULL;
473 bt_ug_data *ugd = NULL;
475 ret_if(data == NULL);
477 dev = (bt_dev_t *)data;
478 ret_if(dev->ugd == NULL);
483 elm_genlist_item_selected_set((Elm_Object_Item *)event_info,
486 if (ugd->op_status == BT_SEARCHING) {
487 ret = bt_adapter_stop_device_discovery();
488 if (ret != BT_ERROR_NONE)
489 BT_ERR("Fail to stop discovery: %d", ret);
492 /* Create the profile view */
493 _bt_profile_create_view(dev);
497 static void __bt_rename_device_entry_changed_cb(void *data, Evas_Object *obj,
502 ret_if(data == NULL);
503 bt_ug_data *ugd = NULL;
505 ugd = (bt_ug_data *)data;
507 const char *entry_text = NULL;
508 char *input_str = NULL;
510 if (ugd->rename_entry != obj)
511 ugd->rename_entry = obj;
512 entry_text = elm_entry_entry_get(obj);
513 input_str = elm_entry_markup_to_utf8(entry_text);
515 if (input_str == NULL || strlen(input_str) == 0 ||
516 _bt_util_is_space_str(input_str)) {
518 elm_object_disabled_set(ugd->rename_button, EINA_TRUE);
519 elm_entry_input_panel_return_key_disabled_set(
523 if (elm_object_disabled_get(ugd->rename_button))
524 elm_object_disabled_set(ugd->rename_button, EINA_FALSE);
525 if (elm_entry_input_panel_return_key_disabled_get(obj))
526 elm_entry_input_panel_return_key_disabled_set(obj, EINA_FALSE);
528 if (input_str != NULL) {
536 static void __bt_rename_device_cancel_cb(void *data, Evas_Object *obj,
540 bt_ug_data *ugd = NULL;
542 ret_if(data == NULL);
543 ugd = (bt_ug_data *)data;
545 if (ugd->rename_entry) {
546 elm_entry_input_panel_hide(ugd->rename_entry);
547 elm_object_focus_set(ugd->rename_entry, EINA_FALSE);
550 if (ugd->rename_popup != NULL) {
551 evas_object_del(ugd->rename_popup);
552 ugd->rename_popup = NULL;
553 ugd->rename_entry_item = NULL;
554 ugd->rename_entry = NULL;
560 static void __bt_rename_device_ok_cb(void *data, Evas_Object *obj,
564 bt_ug_data *ugd = (bt_ug_data *) data;
566 const char *entry_str = elm_entry_entry_get(ugd->rename_entry);
567 char *device_name_str = NULL;
568 device_name_str = elm_entry_markup_to_utf8(entry_str);
569 ret_if(!device_name_str);
570 BT_DBG("Device name:[%s]", device_name_str);
572 if (0 != vconf_set_str(VCONFKEY_SETAPPL_DEVICE_NAME_STR, device_name_str))
573 BT_ERR("Set vconf[%s] failed", VCONFKEY_SETAPPL_DEVICE_NAME_STR);
575 _bt_update_genlist_item(ugd->device_name_item);
577 if (ugd->rename_entry) {
578 elm_entry_input_panel_hide(ugd->rename_entry);
579 elm_object_focus_set(ugd->rename_entry, EINA_FALSE);
582 evas_object_del(ugd->rename_popup);
583 ugd->rename_popup = NULL;
584 ugd->rename_entry_item = NULL;
585 ugd->rename_entry = NULL;
586 g_free(device_name_str);
591 static void __bt_rename_entry_changed_cb(void *data, Evas_Object *obj,
596 bt_ug_data *ugd = (bt_ug_data *) data;
597 ret_if(!ugd->rename_entry_item);
599 if (elm_object_part_content_get(obj, "elm.icon.eraser")) {
600 if (elm_object_focus_get(obj)) {
601 if (elm_entry_is_empty(obj)) {
602 elm_object_item_signal_emit(ugd->rename_entry_item,
603 "elm,state,eraser,hide", "");
605 elm_object_item_signal_emit(ugd->rename_entry_item,
606 "elm,state,eraser,show", "");
610 __bt_rename_device_entry_changed_cb(data, obj, event_info);
615 static void __bt_main_entry_edit_mode_show_cb(void *data, Evas *e, Evas_Object *obj,
618 evas_object_event_callback_del(obj, EVAS_CALLBACK_SHOW,
619 __bt_main_entry_edit_mode_show_cb);
621 elm_object_focus_set(obj, EINA_TRUE);
622 elm_entry_cursor_end_set(obj);
625 static void __bt_main_popup_entry_activated_cb(void *data, Evas_Object *obj, void *event_info)
630 elm_object_focus_set(obj, EINA_FALSE);
633 static Evas_Object *__bt_main_rename_entry_icon_get(
634 void *data, Evas_Object *obj, const char *part)
637 retv_if(obj == NULL || data == NULL, NULL);
639 Evas_Object *entry = NULL;
640 char *name_value = NULL;
641 char *name_value_utf = NULL;
643 static Elm_Entry_Filter_Limit_Size limit_filter_data;
644 bt_ug_data *ugd = (bt_ug_data *)data;
646 if (!strcmp(part, "elm.swallow.content")) {
647 Evas_Object *layout = NULL;
649 layout = elm_layout_add(obj);
650 elm_layout_theme_set(layout, "layout", "editfield", "singleline");
651 evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, 0.0);
652 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, 0.0);
654 name_value_utf = vconf_get_str(VCONFKEY_SETAPPL_DEVICE_NAME_STR);
655 retvm_if(!name_value_utf, NULL, "Get string is failed");
657 name_value = elm_entry_utf8_to_markup(name_value_utf);
659 entry = elm_entry_add(layout);
660 elm_entry_single_line_set(entry, EINA_TRUE);
661 elm_entry_scrollable_set(entry, EINA_TRUE);
663 evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, 0.0);
664 evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, 0.0);
666 eext_entry_selection_back_event_allow_set(entry, EINA_TRUE);
667 elm_object_signal_emit(entry, "elm,action,hide,search_icon", "");
668 elm_object_part_text_set(entry, "guide", BT_STR_DEVICE_NAME);
669 elm_object_text_set(entry, name_value);
670 elm_entry_input_panel_imdata_set(entry, "action=disable_emoticons", 24);
672 elm_entry_input_panel_return_key_type_set(entry, ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DONE);
673 limit_filter_data.max_char_count = DEVICE_NAME_MAX_CHARACTER;
674 elm_entry_markup_filter_append(entry,
675 elm_entry_filter_limit_size, &limit_filter_data);
677 elm_entry_cnp_mode_set(entry, ELM_CNP_MODE_PLAINTEXT);
678 elm_entry_input_panel_layout_set(entry, ELM_INPUT_PANEL_LAYOUT_NORMAL);
679 elm_entry_prediction_allow_set(entry, EINA_FALSE);
680 elm_entry_autocapital_type_set(entry, ELM_AUTOCAPITAL_TYPE_NONE);
682 evas_object_smart_callback_add(entry, "maxlength,reached",
683 _bt_util_max_len_reached_cb, ugd);
684 evas_object_smart_callback_add(entry, "changed",
685 __bt_rename_entry_changed_cb, ugd);
686 evas_object_smart_callback_add(entry, "preedit,changed",
687 __bt_rename_entry_changed_cb, ugd);
688 evas_object_smart_callback_add(entry, "activated",
689 __bt_main_popup_entry_activated_cb, NULL);
690 evas_object_event_callback_add(entry, EVAS_CALLBACK_SHOW,
691 __bt_main_entry_edit_mode_show_cb, ugd);
693 elm_entry_input_panel_show(entry);
694 elm_object_part_content_set(layout, "elm.swallow.content", entry);
696 ugd->rename_entry = entry;
699 free(name_value_utf);
709 static Evas_Object *__bt_main_paired_device_icon_get(void *data, Evas_Object *obj,
714 Evas_Object *btn = NULL;
715 Evas_Object *icon = NULL;
716 char *dev_icon_file = NULL;
717 bt_dev_t *dev = NULL;
719 retv_if(data == NULL, NULL);
721 dev = (bt_dev_t *)data;
723 if (!strcmp("elm.swallow.icon", part) || !strcmp("elm.icon", part)) {
724 if ((dev->major_class == BT_MAJOR_DEV_CLS_MISC)
725 && (dev->service_list != 0))
726 _bt_util_update_class_of_device_by_service_list(dev->service_list,
727 &dev->major_class, &dev->minor_class);
730 _bt_main_get_device_icon(dev->major_class,
735 icon = _bt_create_icon(obj, dev_icon_file);
736 evas_object_propagate_events_set(icon, EINA_FALSE);
737 evas_object_show(icon);
739 if (dev->highlighted || dev->is_connected)
740 evas_object_color_set(dev->icon, 20, 107, 147, 255);
742 evas_object_color_set(dev->icon, 76, 76, 76, 255);
745 evas_object_size_hint_min_set(icon, ELM_SCALE_SIZE(30), ELM_SCALE_SIZE(30));
747 evas_object_size_hint_min_set(icon, ELM_SCALE_SIZE(40), ELM_SCALE_SIZE(40));
748 } else if (!strcmp("elm.swallow.end", part) || !strcmp("elm.end", part)) {
749 BT_INFO("status : %d", dev->status);
751 if (dev->status == BT_IDLE) {
752 btn = elm_button_add(obj);
755 elm_object_style_set(btn, "info_button_small");
757 elm_object_style_set(btn, "info_button");
759 evas_object_propagate_events_set(btn, EINA_FALSE);
760 evas_object_smart_callback_add(btn, "clicked",
761 __bt_paired_device_profile_cb,
763 evas_object_show(btn);
766 btn = elm_progressbar_add(obj);
769 elm_object_style_set(btn, "process_small");
771 elm_object_style_set(btn, "process_medium");
773 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, 0.5);
774 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
775 elm_progressbar_pulse(btn, TRUE);
777 evas_object_show(btn);
787 static char *__bt_main_searched_label_get(void *data, Evas_Object *obj,
790 char buf[BT_GLOBALIZATION_STR_LENGTH] = { 0 };
791 bt_dev_t *dev = NULL;
796 dev = (bt_dev_t *)data;
797 if (!strcmp("elm.text", part)) {
798 #ifdef KIRAN_ACCESSIBILITY
799 char str[BT_STR_ACCES_INFO_MAX_LEN] = { 0, };
800 Evas_Object *ao = NULL;
802 char *dev_name_markup = elm_entry_utf8_to_markup(dev->name);
804 if (dev_name_markup) {
805 g_strlcpy(buf, dev_name_markup,
806 BT_GLOBALIZATION_STR_LENGTH);
807 free(dev_name_markup);
809 g_strlcpy(buf, dev->name, BT_GLOBALIZATION_STR_LENGTH);
812 BT_INFO("label : %s", buf);
813 #ifdef KIRAN_ACCESSIBILITY
814 snprintf(str, sizeof(str), "%s, %s", dev->name,
815 BT_STR_DOUBLE_TAP_CONNECT);
817 ao = elm_object_item_access_object_get(dev->genlist_item);
818 elm_access_info_set(ao, ELM_ACCESS_INFO, str);
821 BT_ERR("empty text for label");
828 static Evas_Object *__bt_main_searched_icon_get(void *data,
832 Evas_Object *icon = NULL;
833 char *dev_icon_file = NULL;
834 bt_dev_t *dev = NULL;
836 retv_if(data == NULL, NULL);
838 dev = (bt_dev_t *)data;
840 if (!strcmp("elm.swallow.icon", part) || !strcmp("elm.icon", part)) {
842 _bt_main_get_device_icon(dev->major_class,
846 icon = _bt_create_icon(obj, dev_icon_file);
847 if (dev->highlighted || dev->is_connected)
848 evas_object_color_set(icon, 20, 107, 147, 255);
850 evas_object_color_set(icon, 76, 76, 76, 255);
851 evas_object_propagate_events_set(icon, EINA_FALSE);
852 } else if (!strcmp("elm.swallow.end", part) || !strcmp("elm.end", part)) {
853 if (dev->status != BT_IDLE) {
856 icon = _bt_create_progressbar(obj, "process_small");
858 icon = _bt_create_progressbar(obj, "process_medium");
860 evas_object_color_set(icon, 76, 76, 76, 255);
865 evas_object_show(icon);
867 evas_object_size_hint_min_set(icon, ELM_SCALE_SIZE(30), ELM_SCALE_SIZE(30));
869 evas_object_size_hint_min_set(icon, ELM_SCALE_SIZE(40), ELM_SCALE_SIZE(40));
875 static char *__bt_main_no_device_label_get(void *data, Evas_Object *obj,
880 char buf[BT_GLOBALIZATION_STR_LENGTH] = { 0 };
881 #ifdef KIRAN_ACCESSIBILITY
882 bt_ug_data *ugd = NULL;
883 char str[BT_STR_ACCES_INFO_MAX_LEN] = { 0, };
884 Evas_Object *ao = NULL;
886 if (!strcmp("elm.text", part)) {
887 g_strlcpy(buf, BT_STR_NO_DEVICE_FOUND,
888 BT_GLOBALIZATION_STR_LENGTH);
889 snprintf(buf, sizeof(buf), "<align=center>%s</align>", BT_STR_NO_DEVICE_FOUND);
891 #ifdef KIRAN_ACCESSIBILITY
892 retv_if(data == NULL, NULL);
893 ugd = (bt_ug_data *)data;
894 g_strlcpy(str, BT_STR_NO_DEVICE_FOUND,
895 BT_STR_ACCES_INFO_MAX_LEN);
897 ao = elm_object_item_access_object_get(ugd->no_device_item);
898 elm_access_info_set(ao, ELM_ACCESS_INFO, str);
901 BT_ERR("empty text for label");
909 static char *__bt_main_paired_title_label_get(void *data, Evas_Object *obj,
914 char buf[BT_GLOBALIZATION_STR_LENGTH] = { 0, };
915 #ifdef KIRAN_ACCESSIBILITY
916 bt_ug_data *ugd = NULL;
917 char str[BT_STR_ACCES_INFO_MAX_LEN] = { 0, };
918 Evas_Object *ao = NULL;
920 if (!strcmp("elm.text", part)) {
922 g_strlcpy(buf, BT_STR_PAIRED_DEVICES,
923 BT_GLOBALIZATION_STR_LENGTH);
927 #ifdef KIRAN_ACCESSIBILITY
928 retv_if(data == NULL, NULL);
929 ugd = (bt_ug_data *)data;
930 ao = elm_object_item_access_object_get(ugd->paired_title);
931 snprintf(str, sizeof(str), "%s, %s", BT_STR_PAIRED_DEVICES,
932 BT_ACC_STR_GROUP_INDEX);
933 elm_access_info_set(ao, ELM_ACCESS_INFO, str);
939 static char *__bt_main_searched_title_label_get(void *data, Evas_Object *obj,
944 char buf[BT_GLOBALIZATION_STR_LENGTH] = { 0, };
945 bt_ug_data *ugd = NULL;
946 #ifdef KIRAN_ACCESSIBILITY
947 Evas_Object *ao = NULL;
948 char str[BT_STR_ACCES_INFO_MAX_LEN] = { 0, };
951 retv_if(data == NULL, NULL);
953 ugd = (bt_ug_data *)data;
954 if (!strcmp("elm.text", part)) {
956 if (ugd->searched_device == NULL ||
957 eina_list_count(ugd->searched_device) == 0) {
958 if (ugd->op_status == BT_SEARCHING) {
959 g_strlcpy(buf, BT_STR_SCANNING,
960 BT_GLOBALIZATION_STR_LENGTH);
961 } else if (ugd->op_status == BT_ACTIVATED) {
962 g_strlcpy(buf, BT_STR_BLUETOOTH_DEVICES,
963 BT_GLOBALIZATION_STR_LENGTH);
966 g_strlcpy(buf, BT_STR_AVAILABLE_DEVICES,
967 BT_GLOBALIZATION_STR_LENGTH);
970 #ifdef KIRAN_ACCESSIBILITY
971 snprintf(str, sizeof(str), "%s, %s",
972 buf, BT_ACC_STR_GROUP_INDEX);
973 ao = elm_object_item_access_object_get(ugd->searched_title);
974 elm_access_info_set(ao, ELM_ACCESS_INFO, str);
984 static Evas_Object *__bt_main_searched_title_icon_get(void *data, Evas_Object *obj,
989 bt_ug_data *ugd = NULL;
990 Evas_Object *progressbar = NULL;
992 retv_if(data == NULL, NULL);
993 retv_if(obj == NULL, NULL);
994 retv_if(part == NULL, NULL);
996 ugd = (bt_ug_data *)data;
998 if ((!strcmp("elm.swallow.end", part) || !strcmp("elm.end", part)) && ugd->op_status == BT_SEARCHING)
999 progressbar = _bt_create_progressbar(obj, "process_small");
1005 static app_control_h __bt_main_get_bt_onoff_result(bt_ug_data *ugd,
1008 app_control_h service = NULL;
1009 const char *result_str;
1010 bt_adapter_state_e bt_state = BT_ADAPTER_DISABLED;
1012 retv_if(ugd == NULL, NULL);
1014 app_control_create(&service);
1016 retv_if(service == NULL, NULL);
1019 result_str = BT_RESULT_SUCCESS;
1021 result_str = BT_RESULT_FAIL;
1023 if (app_control_add_extra_data(service, "result", result_str) < 0)
1024 BT_ERR("Fail to add extra data");
1026 if (bt_adapter_get_state(&bt_state) == BT_ERROR_NONE) {
1027 if (bt_state == BT_ADAPTER_ENABLED) {
1028 if (app_control_add_extra_data(service, "bt_status", BT_ADAPTER_ON) < 0)
1029 BT_ERR("Fail to add extra data");
1031 if (app_control_add_extra_data(service, "bt_status", BT_ADAPTER_OFF) < 0)
1032 BT_ERR("Fail to add extra data");
1035 BT_ERR("Fail to bt_adapter_get_state");
1041 static app_control_h __bt_main_get_pick_result(bt_ug_data *ugd, gboolean result)
1043 app_control_h service = NULL;
1044 const char *result_str;
1045 char address[BT_ADDRESS_STR_LEN] = { 0 };
1046 char value_str[BT_RESULT_STR_MAX] = { 0 };
1049 retv_if(ugd == NULL, NULL);
1050 retv_if(ugd->pick_device == NULL, NULL);
1052 dev = ugd->pick_device;
1054 app_control_create(&service);
1056 retv_if(service == NULL, NULL);
1059 result_str = BT_RESULT_SUCCESS;
1061 result_str = BT_RESULT_FAIL;
1063 if (app_control_add_extra_data(service, "result", result_str) < 0)
1064 BT_ERR("Fail to add extra data");
1066 _bt_util_addr_type_to_addr_result_string(address, dev->bd_addr);
1068 /* Original output fields will be removed */
1069 if (app_control_add_extra_data(service, "address",
1070 (const char *)address) < 0) {
1071 BT_ERR("Fail to add extra data");
1074 if (app_control_add_extra_data(service, BT_APPCONTROL_ADDRESS,
1075 (const char *)address) < 0) {
1076 BT_ERR("Fail to add extra data");
1079 if (app_control_add_extra_data(service, "name",
1080 (const char *)dev->name) < 0) {
1081 BT_ERR("Fail to add extra data");
1084 if (app_control_add_extra_data(service, BT_APPCONTROL_NAME,
1085 (const char *)dev->name) < 0) {
1086 BT_ERR("Fail to add extra data");
1089 snprintf(value_str, BT_RESULT_STR_MAX, "%d", dev->rssi);
1091 if (app_control_add_extra_data(service, "rssi",
1092 (const char *)value_str) < 0) {
1093 BT_ERR("Fail to add extra data");
1096 if (app_control_add_extra_data(service, BT_APPCONTROL_RSSI,
1097 (const char *)value_str) < 0) {
1098 BT_ERR("Fail to add extra data");
1101 memset(value_str, 0x00, sizeof(value_str));
1102 snprintf(value_str, BT_RESULT_STR_MAX, "%d", dev->is_bonded);
1104 if (app_control_add_extra_data(service, "is_bonded",
1105 (const char *)value_str) < 0) {
1106 BT_ERR("Fail to add extra data");
1109 if (app_control_add_extra_data(service, BT_APPCONTROL_IS_PAIRED,
1110 (const char *)value_str) < 0) {
1111 BT_ERR("Fail to add extra data");
1114 memset(value_str, 0x00, sizeof(value_str));
1115 snprintf(value_str, BT_RESULT_STR_MAX, "%d", dev->major_class);
1117 if (app_control_add_extra_data(service, "major_class",
1118 (const char *)value_str) < 0) {
1119 BT_ERR("Fail to add extra data");
1122 if (app_control_add_extra_data(service, BT_APPCONTROL_MAJOR_CLASS,
1123 (const char *)value_str) < 0) {
1124 BT_ERR("Fail to add extra data");
1127 memset(value_str, 0x00, sizeof(value_str));
1128 snprintf(value_str, BT_RESULT_STR_MAX, "%d", dev->minor_class);
1130 if (app_control_add_extra_data(service, "minor_class",
1131 (const char *)value_str) < 0) {
1132 BT_ERR("Fail to add extra data");
1135 if (app_control_add_extra_data(service, BT_APPCONTROL_MINOR_CLASS,
1136 (const char *)value_str) < 0) {
1137 BT_ERR("Fail to add extra data");
1140 memset(value_str, 0x00, sizeof(value_str));
1141 snprintf(value_str, BT_RESULT_STR_MAX, "%ld",
1142 (long int)dev->service_class);
1144 if (app_control_add_extra_data(service, "service_class",
1145 (const char *)value_str) < 0) {
1146 BT_ERR("Fail to add extra data");
1149 if (app_control_add_extra_data(service, BT_APPCONTROL_SERVICE_CLASS,
1150 (const char *)value_str) < 0) {
1151 BT_ERR("Fail to add extra data");
1154 if (app_control_add_extra_data_array(service, "uuids",
1155 (const char **)dev->uuids,
1156 dev->uuid_count) < 0) {
1157 BT_ERR("Fail to add extra data");
1160 if (app_control_add_extra_data_array(service, BT_APPCONTROL_UUID_LIST,
1161 (const char **)dev->uuids,
1162 dev->uuid_count) < 0) {
1163 BT_ERR("Fail to add extra data");
1169 static Eina_Bool __bt_main_quit_btn_cb(void *data, Elm_Object_Item *it)
1172 app_control_h reply = NULL;
1173 app_control_h service = NULL;
1174 bt_ug_data *ugd = (bt_ug_data *)data;
1176 retv_if(ugd == NULL, EINA_FALSE);
1178 if (ugd->bt_launch_mode == BT_LAUNCH_PICK) {
1179 app_control_create(&service);
1181 if (service == NULL) {
1182 _bt_ug_destroy(data, NULL);
1186 if (app_control_add_extra_data(service, "result",
1187 BT_RESULT_FAIL) < 0) {
1188 BT_ERR("Fail to add extra data");
1191 _bt_ug_destroy(data, (void *)service);
1193 app_control_destroy(service);
1194 } else if (ugd->bt_launch_mode == BT_LAUNCH_ONOFF) {
1195 service = __bt_main_get_bt_onoff_result(ugd, FALSE);
1197 app_control_create(&reply);
1198 if (app_control_add_extra_data(reply, "result",
1199 BT_RESULT_FAIL) < 0) {
1200 BT_ERR("Fail to add extra data");
1203 BT_DBG("BT_LAUNCH_ONOFF reply to launch request");
1204 app_control_reply_to_launch_request(reply, service,
1205 APP_CONTROL_RESULT_FAILED);
1207 _bt_ug_destroy(data, (void *)service);
1210 app_control_destroy(service);
1212 app_control_destroy(reply);
1214 _bt_ug_destroy(data, NULL);
1221 int _bt_main_enable_bt(void *data)
1225 retv_if(data == NULL, -1);
1226 bt_ug_data *ugd = (bt_ug_data *)data;
1228 if (_bt_util_is_battery_low() == TRUE) {
1229 /* Battery is critical low */
1230 _bt_main_create_information_popup(ugd, BT_STR_LOW_BATTERY);
1234 ret = bt_adapter_enable();
1235 if (ret != BT_ERROR_NONE)
1236 BT_ERR("Failed to enable bluetooth [%d]", ret);
1238 ugd->op_status = BT_ACTIVATING;
1244 int _bt_main_disable_bt(void *data)
1248 retv_if(data == NULL, -1);
1249 bt_ug_data *ugd = (bt_ug_data *)data;
1251 ret = bt_adapter_disable();
1252 if (ret != BT_ERROR_NONE) {
1253 BT_ERR("Failed to disable bluetooth [%d]", ret);
1255 ugd->op_status = BT_DEACTIVATING;
1256 elm_object_disabled_set(ugd->scan_btn, EINA_TRUE);
1263 static void __bt_main_onoff_btn_cb(void *data, Evas_Object *obj,
1267 ret_if(data == NULL);
1270 bt_ug_data *ugd = (bt_ug_data *)data;
1272 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
1273 elm_genlist_item_selected_set(item, EINA_FALSE);
1275 if (ugd->bt_launch_mode == BT_LAUNCH_HELP) {
1276 Eina_Bool check_mode = elm_check_state_get(obj);
1277 elm_check_state_set(obj, !check_mode);
1279 ret = notification_status_message_post(BT_STR_INVALID_ACTION_TRY_AGAIN);
1280 if (ret != NOTIFICATION_ERROR_NONE)
1281 BT_ERR("notification_status_message_post() is failed : %d", ret);
1286 ret_if(ugd->op_status == BT_ACTIVATING ||
1287 ugd->op_status == BT_DEACTIVATING);
1289 elm_object_disabled_set(ugd->onoff_btn, EINA_TRUE);
1291 if (ugd->op_status == BT_DEACTIVATED) {
1292 ret = _bt_main_enable_bt(data);
1293 ugd->op_status = BT_ACTIVATING;
1294 } else if (ugd->op_status != BT_DEACTIVATING &&
1295 ugd->op_status != BT_ACTIVATING) {
1296 ret = bt_adapter_disable();
1297 if (ret != BT_ERROR_NONE) {
1298 BT_ERR("Failed to disable bluetooth [%d]", ret);
1300 ugd->op_status = BT_DEACTIVATING;
1301 elm_object_disabled_set(ugd->scan_btn, EINA_TRUE);
1305 if (ugd->op_status == BT_ACTIVATING ||
1306 ugd->op_status == BT_DEACTIVATING) {
1309 elm_object_item_signal_emit(item, "elm,state,group,single", "elm");
1311 elm_genlist_item_fields_update(ugd->onoff_item, "*",
1312 ELM_GENLIST_ITEM_FIELD_TEXT);
1313 elm_genlist_item_fields_update(ugd->onoff_item, "*",
1314 ELM_GENLIST_ITEM_FIELD_CONTENT);
1319 static void __bt_main_controlbar_btn_cb(void *data, Evas_Object *obj,
1324 bt_ug_data *ugd = NULL;
1327 retm_if(data == NULL, "Invalid argument: bt_ug_data is NULL");
1329 ugd = (bt_ug_data *)data;
1331 if (ugd->op_status == BT_SEARCHING) {
1332 if (ugd->is_discovery_started) {
1334 if (TIZEN_FEATURE_BT_HOG && ugd->is_le_discovery_started == TRUE) {
1335 ret = bt_adapter_le_stop_scan();
1337 ugd->is_le_discovery_started = FALSE;
1339 if (bt_adapter_stop_device_discovery() == BT_ERROR_NONE) {
1340 elm_object_disabled_set(ugd->scan_btn, EINA_TRUE);
1341 elm_object_text_set(ugd->scan_btn, BT_STR_STOP);
1342 } else { /*the case in which stop discovery returns error from Bluez*/
1343 ugd->op_status = BT_ACTIVATED;
1344 elm_object_text_set(ugd->scan_btn, BT_STR_SCAN);
1346 if (ugd->searched_title == NULL)
1347 _bt_main_add_searched_title(ugd);
1348 _bt_update_genlist_item((Elm_Object_Item *)
1349 ugd->searched_title);
1352 } else { /*ugd->op_status != BT_SEARCHING */
1353 _bt_main_scan_device(ugd);
1359 static void __bt_main_disconnect_cb(void *data, Evas_Object *obj,
1364 bt_dev_t *dev = NULL;
1365 bt_ug_data *ugd = NULL;
1367 retm_if(data == NULL, "Invalid argument: data is NULL");
1369 dev = (bt_dev_t *)data;
1370 retm_if(dev->ugd == NULL, "ugd is NULL");
1375 evas_object_del(ugd->popup);
1379 _bt_main_disconnect_device(ugd, dev);
1384 static int __bt_main_request_to_send(bt_ug_data *ugd, bt_dev_t *dev)
1386 obex_ipc_param_t param;
1388 char **array_val = NULL;
1393 BT_DBG("%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",
1394 dev->bd_addr[0], dev->bd_addr[1],
1395 dev->bd_addr[2], dev->bd_addr[3],
1396 dev->bd_addr[4], dev->bd_addr[5]);
1398 memset(¶m, 0x00, sizeof(obex_ipc_param_t));
1399 memcpy(param.addr, dev->bd_addr, BT_ADDRESS_LENGTH_MAX);
1401 ret = app_control_get_extra_data_array(ugd->service, "files",
1403 if (ret != APP_CONTROL_ERROR_NONE) {
1404 BT_ERR("Get data error");
1408 if (array_val == NULL)
1411 param.file_cnt = cnt;
1412 param.filepath = g_new0(char *, cnt + 1);
1413 for (i = 0; i < cnt; i++) {
1415 param.filepath[i] = g_strdup(array_val[i]);
1416 DBG_SECURE("%s", param.filepath[i]);
1418 array_val[i] = NULL;
1424 param.dev_name = g_strdup(dev->name);
1426 if (app_control_get_extra_data(ugd->service, "type", &value) < 0)
1427 BT_ERR("Get data error");
1432 param.type = g_strdup(value);
1435 if (_bt_ipc_send_obex_message(¶m, ugd) != BT_UG_ERROR_NONE)
1438 g_free(param.dev_name);
1440 if (param.filepath) {
1441 for (i = 0; param.filepath[i] != NULL; i++)
1442 g_free(param.filepath[i]);
1443 g_free(param.filepath);
1446 return BT_UG_ERROR_NONE;
1450 for (i = 0; i < cnt; i++) {
1455 _bt_main_launch_syspopup(ugd, BT_SYSPOPUP_REQUEST_NAME,
1456 BT_STR_UNABLE_TO_SEND,
1457 BT_SYSPOPUP_ONE_BUTTON_TYPE);
1459 g_free(param.dev_name);
1461 if (param.filepath) {
1462 for (i = 0; param.filepath[i] != NULL; i++)
1463 g_free(param.filepath[i]);
1464 g_free(param.filepath);
1470 static void __bt_main_paired_item_sel_cb(void *data, Evas_Object *obj,
1475 bt_ug_data *ugd = NULL;
1476 bt_dev_t *dev = NULL;
1477 Elm_Object_Item *item = NULL;
1478 Evas_Object *btn = NULL;
1479 Evas_Object *popup_btn = NULL;
1483 elm_genlist_item_selected_set((Elm_Object_Item *) event_info,
1486 retm_if(data == NULL, "Invalid argument: bt_ug_data is NULL");
1488 ugd = (bt_ug_data *)data;
1489 item = (Elm_Object_Item *) event_info;
1491 ret_if(ugd->waiting_service_response == TRUE);
1492 ret_if(ugd->op_status == BT_PAIRING);
1494 if (ugd->op_status == BT_SEARCHING) {
1495 ret = bt_adapter_stop_device_discovery();
1496 if (ret != BT_ERROR_NONE) {
1497 BT_ERR("Fail to stop discovery");
1502 dev = _bt_main_get_dev_info(ugd->paired_device, item);
1503 retm_if(dev == NULL, "Invalid argument: device info is NULL");
1504 retm_if(dev->status != BT_IDLE,
1505 "Connecting / Disconnecting is in progress");
1507 if ((ugd->waiting_service_response) && (dev->service_list == 0)) {
1508 ugd->paired_item = item;
1510 _bt_main_popup_del_cb(ugd, NULL, NULL);
1512 ugd->popup_data.type = BT_POPUP_GETTING_SERVICE_LIST;
1513 ugd->popup = _bt_create_popup(ugd, _bt_main_popup_del_cb,
1516 retm_if(ugd->popup == NULL, "fail to create popup!");
1517 btn = elm_button_add(ugd->popup);
1518 elm_object_style_set(btn, "popup");
1519 elm_object_domain_translatable_text_set(
1521 PKGNAME, "IDS_BT_BUTTON_OK");
1522 elm_object_part_content_set(ugd->popup, "button1", btn);
1523 evas_object_smart_callback_add(btn, "clicked", (Evas_Smart_Cb)
1524 _bt_main_popup_del_cb, ugd);
1526 eext_object_event_callback_add(ugd->popup, EEXT_CALLBACK_BACK,
1527 _bt_main_popup_del_cb, ugd);
1529 evas_object_show(ugd->popup);
1533 if (ugd->bt_launch_mode == BT_LAUNCH_NORMAL ||
1534 ugd->bt_launch_mode == BT_LAUNCH_CONNECT_HEADSET ||
1535 ugd->bt_launch_mode == BT_LAUNCH_USE_NFC ||
1536 ugd->bt_launch_mode == BT_LAUNCH_HELP) {
1538 ugd->paired_item = item;
1540 if ((!TIZEN_FEATURE_BT_HOG && dev->service_list == 0) || (TIZEN_FEATURE_BT_HOG && (dev->service_list == 0) && (!dev->is_le_device))) {
1541 if (bt_device_start_service_search
1542 ((const char *)dev->addr_str) == BT_ERROR_NONE) {
1544 dev->status = BT_SERVICE_SEARCHING;
1545 ugd->waiting_service_response = TRUE;
1546 ugd->request_timer =
1547 ecore_timer_add(BT_SEARCH_SERVICE_TIMEOUT,
1549 _bt_main_service_request_cb,
1552 _bt_update_genlist_item(ugd->paired_item);
1555 BT_ERR("service search error");
1560 if (dev->is_connected == 0) {
1561 /* Not connected case */
1562 _bt_main_connect_device(ugd, dev);
1565 _bt_main_popup_del_cb(ugd, NULL, NULL);
1567 ugd->popup_data.type = BT_POPUP_DISCONNECT;
1568 ugd->popup_data.data = g_strdup(dev->name);
1569 ugd->popup = _bt_create_popup(ugd, NULL, NULL, 0);
1570 retm_if(!ugd->popup , "fail to create popup!");
1572 popup_btn = elm_button_add(ugd->popup);
1574 elm_object_style_set(popup_btn, "popup");
1575 elm_object_domain_translatable_text_set(
1577 PKGNAME, "IDS_BR_SK_CANCEL");
1578 elm_object_part_content_set(ugd->popup, "button1",
1580 evas_object_smart_callback_add(popup_btn, "clicked",
1581 _bt_main_popup_del_cb,
1585 popup_btn = elm_button_add(ugd->popup);
1587 elm_object_style_set(popup_btn, "popup");
1588 elm_object_domain_translatable_text_set(
1590 PKGNAME, "IDS_BT_SK_DISCONNECT");
1591 elm_object_part_content_set(ugd->popup, "button2",
1593 evas_object_smart_callback_add(popup_btn, "clicked",
1594 __bt_main_disconnect_cb,
1596 eext_object_event_callback_add(ugd->popup, EEXT_CALLBACK_BACK,
1597 eext_popup_back_cb, NULL);
1599 evas_object_show(ugd->popup);
1602 } else if (ugd->bt_launch_mode == BT_LAUNCH_SEND_FILE) {
1603 if (_bt_util_is_battery_low() == TRUE) {
1604 /* Battery is critical low */
1605 _bt_main_create_information_popup(ugd, BT_STR_LOW_BATTERY);
1609 if (__bt_main_request_to_send(ugd, dev) == BT_UG_ERROR_NONE)
1610 BT_DBG("Request file sending");
1612 _bt_ug_destroy(ugd, NULL);
1613 } else if (ugd->bt_launch_mode == BT_LAUNCH_PICK) {
1614 ugd->pick_device = dev;
1615 g_idle_add((GSourceFunc) _bt_idle_destroy_ug, ugd);
1621 static void __bt_main_searched_item_sel_cb(void *data, Evas_Object *obj,
1626 bt_ug_data *ugd = NULL;
1627 bt_dev_t *dev = NULL;
1628 Elm_Object_Item *item = NULL;
1632 elm_genlist_item_selected_set((Elm_Object_Item *) event_info,
1635 retm_if(data == NULL, "Invalid argument: bt_ug_data is NULL");
1637 ugd = (bt_ug_data *)data;
1639 ret_if(ugd->op_status == BT_PAIRING);
1641 item = (Elm_Object_Item *) event_info;
1643 dev = _bt_main_get_dev_info(ugd->searched_device,
1644 (Elm_Object_Item *) event_info);
1645 retm_if(dev == NULL, "Invalid argument: device info is NULL");
1647 if (ugd->bt_launch_mode == BT_LAUNCH_USE_NFC) {
1648 char address[18] = { 0 };
1649 app_control_h service = NULL;
1651 app_control_create(&service);
1653 ret_if(service == NULL);
1655 BT_DBG("%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X", dev->bd_addr[0],
1656 dev->bd_addr[1], dev->bd_addr[2], dev->bd_addr[3],
1657 dev->bd_addr[4], dev->bd_addr[5]);
1659 _bt_util_addr_type_to_addr_string(address, dev->bd_addr);
1661 if (app_control_add_extra_data(service, "device_address",
1662 (const char *)address) < 0) {
1663 BT_ERR("Fail to add extra data");
1666 if (app_control_add_extra_data(service, "device_name",
1667 (const char *)dev->name) < 0) {
1668 BT_ERR("Fail to add extra data");
1671 _bt_ug_destroy(ugd, (void *)service);
1673 app_control_destroy(service);
1676 } else if (ugd->bt_launch_mode == BT_LAUNCH_PICK) {
1677 ugd->pick_device = dev;
1678 g_idle_add((GSourceFunc) _bt_idle_destroy_ug, ugd);
1682 ugd->searched_item = item;
1684 if (_bt_util_is_battery_low() == TRUE) {
1685 /* Battery is critical low */
1686 _bt_main_create_information_popup(ugd, BT_STR_LOW_BATTERY);
1690 if (ugd->op_status == BT_SEARCHING) {
1691 if (TIZEN_FEATURE_BT_HOG && ugd->is_le_discovery_started == TRUE) {
1692 ret = bt_adapter_le_stop_scan();
1694 ugd->is_le_discovery_started = FALSE;
1696 ret = bt_adapter_stop_device_discovery();
1697 if (ret != BT_ERROR_NONE)
1698 BT_ERR("Fail to stop discovery");
1701 if (ugd->bt_launch_mode == BT_LAUNCH_SEND_FILE) {
1702 if (__bt_main_request_to_send(ugd, dev) == BT_UG_ERROR_NONE)
1703 BT_DBG("Request file sending");
1705 _bt_ug_destroy(ugd, NULL);
1709 if (!TIZEN_FEATURE_BT_HOG) {
1710 if (_bt_main_request_pairing_with_effect(ugd, item) != BT_UG_ERROR_NONE)
1711 ugd->searched_item = NULL;
1713 if (dev->is_le_device) {
1714 if (_bt_main_request_connect_with_effect(ugd, item) != BT_UG_ERROR_NONE)
1715 ugd->searched_item = NULL;
1718 if (_bt_main_request_pairing_with_effect(ugd, item) != BT_UG_ERROR_NONE)
1719 ugd->searched_item = NULL;
1726 static void __bt_main_gl_highlighted(void *data, Evas_Object *obj,
1733 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
1735 ret_if(item == NULL);
1737 ugd = (bt_ug_data *)data;
1738 ret_if(ugd == NULL);
1740 dev = _bt_main_get_dev_info(ugd->paired_device, item);
1742 dev = _bt_main_get_dev_info(ugd->searched_device, item);
1744 ret_if(dev == NULL);
1746 dev->highlighted = TRUE;
1749 elm_genlist_item_fields_update(item, "*", ELM_GENLIST_ITEM_FIELD_TEXT);
1754 static void __bt_main_gl_unhighlighted(void *data, Evas_Object *obj,
1761 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
1763 ret_if(item == NULL);
1765 ugd = (bt_ug_data *)data;
1766 ret_if(ugd == NULL);
1768 dev = _bt_main_get_dev_info(ugd->paired_device, item);
1770 dev = _bt_main_get_dev_info(ugd->searched_device, item);
1772 ret_if(dev == NULL);
1774 dev->highlighted = FALSE;
1777 elm_genlist_item_fields_update(item, "*", ELM_GENLIST_ITEM_FIELD_TEXT);
1782 void _bt_main_add_device_name_item(bt_ug_data *ugd, Evas_Object *genlist)
1785 retm_if(ugd->op_status == BT_DEACTIVATED, "BT is turned off");
1788 /* IOT common UI don't show the device name */
1792 Elm_Object_Item *git = NULL;
1794 git = elm_genlist_item_insert_after(genlist, ugd->device_name_itc, ugd, NULL,
1795 ugd->onoff_item, ELM_GENLIST_ITEM_NONE, NULL, NULL);
1796 elm_genlist_item_select_mode_set(git, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1798 ugd->device_name_item = git;
1803 static void __bt_main_gl_realized(void *data, Evas_Object *obj, void *event_info)
1805 if (!data || !obj || !event_info)
1808 int group_type = BT_GENLIST_GROUP_MIDDLE;
1809 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
1810 Elm_Object_Item *prev_item = elm_genlist_item_prev_get(item);
1811 Elm_Object_Item *next_item = elm_genlist_item_next_get(item);
1812 bt_ug_data *ugd = (bt_ug_data *)data;
1814 /* onoff / device name item style */
1815 if (item == ugd->onoff_item) {
1817 group_type = BT_GENLIST_GROUP_SINGLE;
1819 group_type = (next_item == NULL) ? BT_GENLIST_GROUP_SINGLE : BT_GENLIST_GROUP_TOP;
1820 } else if (item == ugd->device_name_item) {
1821 group_type = BT_GENLIST_GROUP_BOTTOM;
1823 if (prev_item == ugd->paired_title) {
1824 /* The first paired item */
1825 if (next_item == ugd->searched_title)
1826 group_type = BT_GENLIST_GROUP_SINGLE;
1828 group_type = BT_GENLIST_GROUP_TOP;
1829 } else if (prev_item == ugd->searched_title) {
1830 /* The first searched item */
1831 if (next_item == NULL)
1832 group_type = BT_GENLIST_GROUP_SINGLE;
1834 group_type = BT_GENLIST_GROUP_TOP;
1835 } else if (next_item == ugd->searched_title || next_item == ugd->no_device_item || next_item == NULL) {
1836 group_type = BT_GENLIST_GROUP_BOTTOM;
1840 if (group_type == BT_GENLIST_GROUP_SINGLE)
1841 elm_object_item_signal_emit(item, "elm,state,group,single", "elm");
1842 else if (group_type == BT_GENLIST_GROUP_TOP)
1843 elm_object_item_signal_emit(item, "elm,state,group,top", "elm");
1844 else if (group_type == BT_GENLIST_GROUP_BOTTOM)
1845 elm_object_item_signal_emit(item, "elm,state,group,bottom", "elm");
1847 elm_object_item_signal_emit(item, "elm,state,group,middle", "elm");
1850 static Evas_Object *__bt_main_add_genlist_dialogue(Evas_Object *parent,
1854 retv_if(ugd == NULL, NULL);
1856 Evas_Object *genlist = NULL;
1857 Elm_Object_Item *git = NULL;
1859 genlist = elm_genlist_add(parent);
1860 retv_if(!genlist, NULL);
1861 /* We shoud set the mode to compress
1862 for using dialogue/2text.2icon.3.tb */
1863 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
1864 elm_genlist_homogeneous_set(genlist, EINA_FALSE);
1865 elm_genlist_block_count_set(genlist, 3);
1867 evas_object_smart_callback_add(genlist, "highlighted",
1868 __bt_main_gl_highlighted, ugd);
1870 evas_object_smart_callback_add(genlist, "unhighlighted",
1871 __bt_main_gl_unhighlighted, ugd);
1874 evas_object_smart_callback_add(genlist, "realized", __bt_main_gl_realized, ugd);
1876 ugd->on_itc = elm_genlist_item_class_new();
1877 retv_if(ugd->on_itc == NULL, NULL);
1879 ugd->on_itc->item_style = BT_GENLIST_1LINE_TEXT_ICON_STYLE;
1880 ugd->on_itc->func.text_get = __bt_main_onoff_label_get;
1881 ugd->on_itc->func.content_get = __bt_main_onoff_icon_get;
1882 ugd->on_itc->func.state_get = NULL;
1883 ugd->on_itc->func.del = NULL;
1885 /* Set item class for dialogue seperator */
1886 ugd->off_itc = elm_genlist_item_class_new();
1887 retv_if(ugd->off_itc == NULL, NULL);
1889 ugd->off_itc->item_style = BT_GENLIST_MULTILINE_TEXT_STYLE;
1890 ugd->off_itc->func.text_get = __bt_main_onoff_label_get;
1891 ugd->off_itc->func.content_get = __bt_main_onoff_icon_get;
1892 ugd->off_itc->func.state_get = NULL;
1893 ugd->off_itc->func.del = NULL;
1895 /* Set item class for paired dialogue title */
1896 ugd->device_name_itc = elm_genlist_item_class_new();
1897 retv_if(ugd->device_name_itc == NULL, NULL);
1899 ugd->device_name_itc->item_style = BT_GENLIST_2LINE_BOTTOM_TEXT_STYLE;
1900 ugd->device_name_itc->func.text_get = __bt_main_device_label_get;
1901 ugd->device_name_itc->func.content_get = NULL;
1902 ugd->device_name_itc->func.state_get = NULL;
1903 ugd->device_name_itc->func.del = NULL;
1905 /* Set item class for paired dialogue title */
1906 ugd->paired_title_itc = elm_genlist_item_class_new();
1907 retv_if(ugd->paired_title_itc == NULL, NULL);
1909 ugd->paired_title_itc->item_style = BT_GENLIST_GROUP_INDEX_STYLE;
1910 ugd->paired_title_itc->func.text_get = __bt_main_paired_title_label_get;
1911 ugd->paired_title_itc->func.content_get = NULL;
1912 ugd->paired_title_itc->func.state_get = NULL;
1913 ugd->paired_title_itc->func.del = NULL;
1915 /* Set item class for searched dialogue title */
1916 ugd->searched_title_itc = elm_genlist_item_class_new();
1917 retv_if(ugd->searched_title_itc == NULL, NULL);
1919 ugd->searched_title_itc->item_style = BT_GENLIST_GROUP_INDEX_STYLE;
1920 ugd->searched_title_itc->func.text_get = __bt_main_searched_title_label_get;
1921 ugd->searched_title_itc->func.content_get = __bt_main_searched_title_icon_get;
1922 ugd->searched_title_itc->func.state_get = NULL;
1923 ugd->searched_title_itc->func.del = NULL;
1925 /* Set item class for paired device */
1926 ugd->paired_device_itc = elm_genlist_item_class_new();
1927 retv_if(ugd->paired_device_itc == NULL, NULL);
1929 ugd->paired_device_itc->item_style = BT_GENLIST_2LINE_TOP_TEXT_ICON_STYLE;
1930 ugd->paired_device_itc->func.text_get = __bt_main_paired_device_label_get;
1931 ugd->paired_device_itc->func.content_get = __bt_main_paired_device_icon_get;
1932 ugd->paired_device_itc->func.state_get = NULL;
1933 ugd->paired_device_itc->func.del = NULL;
1935 /* Set item class for searched device */
1936 ugd->searched_device_itc = elm_genlist_item_class_new();
1937 retv_if(ugd->searched_device_itc == NULL, NULL);
1939 ugd->searched_device_itc->item_style = BT_GENLIST_1LINE_TEXT_ICON_STYLE;
1940 ugd->searched_device_itc->func.text_get = __bt_main_searched_label_get;
1941 ugd->searched_device_itc->func.content_get = __bt_main_searched_icon_get;
1942 ugd->searched_device_itc->func.state_get = NULL;
1943 ugd->searched_device_itc->func.del = NULL;
1945 /* Set item class for no device */
1946 ugd->no_device_itc = elm_genlist_item_class_new();
1947 retv_if(ugd->no_device_itc == NULL, NULL);
1949 ugd->no_device_itc->item_style = BT_GENLIST_1LINE_TEXT_STYLE;
1950 ugd->no_device_itc->func.text_get = __bt_main_no_device_label_get;
1951 ugd->no_device_itc->func.content_get = NULL;
1952 ugd->no_device_itc->func.state_get = NULL;
1953 ugd->no_device_itc->func.del = NULL;
1955 if (ugd->op_status == BT_DEACTIVATED ||
1956 ugd->op_status == BT_ACTIVATING)
1957 git = elm_genlist_item_append(genlist, ugd->off_itc, ugd, NULL,
1958 ELM_GENLIST_ITEM_NONE,
1959 __bt_main_onoff_btn_cb, ugd);
1961 git = elm_genlist_item_append(genlist, ugd->on_itc, ugd, NULL,
1962 ELM_GENLIST_ITEM_NONE,
1963 __bt_main_onoff_btn_cb, ugd);
1965 ugd->onoff_item = git;
1967 if (_bt_util_is_dpm_restricted(ugd->dpm_handle) == TRUE)
1968 elm_object_item_disabled_set(ugd->onoff_item, EINA_TRUE);
1970 _bt_main_add_device_name_item(ugd, genlist);
1972 evas_object_show(genlist);
1978 static Evas_Object *__bt_main_add_visibility_dialogue(Evas_Object * parent,
1982 retv_if(ugd == NULL, NULL);
1984 Evas_Object *genlist = NULL;
1985 Elm_Object_Item *git = NULL;
1987 genlist = elm_genlist_add(parent);
1988 /* We shoud set the mode to compress
1989 for using dialogue/2text.2icon.3.tb */
1990 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
1991 elm_genlist_homogeneous_set(genlist, EINA_FALSE);
1992 elm_genlist_block_count_set(genlist, 3);
1994 evas_object_smart_callback_add(genlist, "highlighted",
1995 __bt_main_gl_highlighted, ugd);
1997 evas_object_smart_callback_add(genlist, "unhighlighted",
1998 __bt_main_gl_unhighlighted, ugd);
2000 ugd->on_itc = elm_genlist_item_class_new();
2001 retv_if(ugd->on_itc == NULL, NULL);
2003 ugd->on_itc->item_style = BT_GENLIST_1LINE_TEXT_ICON_STYLE;
2004 ugd->on_itc->func.text_get = __bt_main_onoff_label_get;
2005 ugd->on_itc->func.content_get = __bt_main_onoff_icon_get;
2006 ugd->on_itc->func.state_get = NULL;
2007 ugd->on_itc->func.del = NULL;
2009 /* Set item class for dialogue seperator */
2010 ugd->off_itc = elm_genlist_item_class_new();
2011 retv_if(ugd->off_itc == NULL, NULL);
2013 ugd->off_itc->item_style = BT_GENLIST_MULTILINE_TEXT_STYLE;
2014 ugd->off_itc->func.text_get = __bt_main_onoff_label_get;
2015 ugd->off_itc->func.content_get = __bt_main_onoff_icon_get;
2016 ugd->off_itc->func.state_get = NULL;
2017 ugd->off_itc->func.del = NULL;
2019 /* Set item class for paired dialogue title */
2020 ugd->device_name_itc = elm_genlist_item_class_new();
2021 retv_if(ugd->device_name_itc == NULL, NULL);
2023 ugd->device_name_itc->item_style = BT_GENLIST_2LINE_BOTTOM_TEXT_STYLE;
2024 ugd->device_name_itc->func.text_get = __bt_main_device_label_get;
2025 ugd->device_name_itc->func.content_get = NULL;
2026 ugd->device_name_itc->func.state_get = NULL;
2027 ugd->device_name_itc->func.del = NULL;
2029 if (ugd->op_status == BT_DEACTIVATED ||
2030 ugd->op_status == BT_ACTIVATING)
2031 git = elm_genlist_item_append(genlist, ugd->off_itc, ugd, NULL,
2032 ELM_GENLIST_ITEM_NONE,
2033 __bt_main_onoff_btn_cb, ugd);
2035 git = elm_genlist_item_append(genlist, ugd->on_itc, ugd, NULL,
2036 ELM_GENLIST_ITEM_NONE,
2037 __bt_main_onoff_btn_cb, ugd);
2038 ugd->onoff_item = git;
2040 _bt_main_add_device_name_item(ugd, genlist);
2041 evas_object_show(genlist);
2047 static Evas_Object *__bt_main_add_onoff_dialogue(Evas_Object * parent,
2051 retv_if(ugd == NULL, NULL);
2053 Evas_Object *genlist = NULL;
2054 Elm_Object_Item *git = NULL;
2056 genlist = elm_genlist_add(parent);
2057 /* We shoud set the mode to compress
2058 for using dialogue/2text.2icon.3.tb */
2059 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
2060 elm_genlist_homogeneous_set(genlist, EINA_FALSE);
2061 elm_genlist_block_count_set(genlist, 3);
2063 evas_object_smart_callback_add(genlist, "highlighted",
2064 __bt_main_gl_highlighted, ugd);
2066 evas_object_smart_callback_add(genlist, "unhighlighted",
2067 __bt_main_gl_unhighlighted, ugd);
2069 ugd->on_itc = elm_genlist_item_class_new();
2070 retv_if(ugd->on_itc == NULL, NULL);
2072 ugd->on_itc->item_style = BT_GENLIST_1LINE_TEXT_ICON_STYLE;
2073 ugd->on_itc->func.text_get = __bt_main_onoff_label_get;
2074 ugd->on_itc->func.content_get = __bt_main_onoff_icon_get;
2075 ugd->on_itc->func.state_get = NULL;
2076 ugd->on_itc->func.del = NULL;
2078 /* Set item class for dialogue seperator */
2079 ugd->off_itc = elm_genlist_item_class_new();
2080 retv_if(ugd->off_itc == NULL, NULL);
2082 ugd->off_itc->item_style = BT_GENLIST_MULTILINE_TEXT_STYLE;
2083 ugd->off_itc->func.text_get = __bt_main_onoff_label_get;
2084 ugd->off_itc->func.content_get = __bt_main_onoff_icon_get;
2085 ugd->off_itc->func.state_get = NULL;
2086 ugd->off_itc->func.del = NULL;
2088 /* Set item class for paired dialogue title */
2089 ugd->device_name_itc = elm_genlist_item_class_new();
2090 retv_if(ugd->device_name_itc == NULL, NULL);
2092 ugd->device_name_itc->item_style = BT_GENLIST_2LINE_BOTTOM_TEXT_STYLE;
2093 ugd->device_name_itc->func.text_get = __bt_main_device_label_get;
2094 ugd->device_name_itc->func.content_get = NULL;
2095 ugd->device_name_itc->func.state_get = NULL;
2096 ugd->device_name_itc->func.del = NULL;
2099 if (ugd->op_status == BT_DEACTIVATED ||
2100 ugd->op_status == BT_ACTIVATING)
2101 git = elm_genlist_item_append(genlist, ugd->off_itc, ugd, NULL,
2102 ELM_GENLIST_ITEM_NONE,
2103 __bt_main_onoff_btn_cb, ugd);
2105 git = elm_genlist_item_append(genlist, ugd->on_itc, ugd, NULL,
2106 ELM_GENLIST_ITEM_NONE,
2107 __bt_main_onoff_btn_cb, ugd);
2108 ugd->onoff_item = git;
2110 _bt_main_add_device_name_item(ugd, genlist);
2111 evas_object_show(genlist);
2117 static gboolean __bt_main_system_popup_timer_cb(gpointer user_data)
2125 retv_if(user_data == NULL, FALSE);
2127 ugd = (bt_ug_data *)user_data;
2129 b = ugd->popup_bundle;
2132 BT_ERR("bundle is NULL");
2136 ret = syspopup_launch("bt-syspopup", b);
2138 BT_ERR("Sorry cannot launch popup");
2140 BT_DBG("Finally Popup launched");
2145 return (ret < 0) ? TRUE : FALSE;
2148 static bool __bt_main_get_mime_type(char *file)
2152 char mime_type[BT_FILE_NAME_LEN_MAX] = { 0, };
2153 int len = strlen("image");
2155 retv_if(file == NULL, FALSE);
2157 if (aul_get_mime_from_file(file, mime_type,
2158 BT_FILE_NAME_LEN_MAX) == AUL_R_OK) {
2159 BT_INFO("mime type=[%s]", mime_type);
2160 if (0 != strncmp(mime_type, "image", len))
2163 BT_ERR("Error getting mime type");
2171 static bool __bt_main_is_image_file(app_control_h service)
2176 int number_of_files = 0;
2181 retvm_if(service == NULL, FALSE, "Invalid data bundle");
2183 if (app_control_get_extra_data(service, "filecount", &value) < 0)
2184 BT_ERR("Get data error");
2186 retv_if(value == NULL, FALSE);
2188 number_of_files = atoi(value);
2189 BT_INFO("[%d] files", number_of_files);
2193 if (number_of_files <= 0) {
2198 if (app_control_get_extra_data(service, "files", &value) < 0)
2199 BT_ERR("Get data error");
2201 retv_if(value == NULL, FALSE);
2204 while (((token = strstr(param, "?")) != NULL) && i < number_of_files) {
2206 if (!__bt_main_get_mime_type(param)) {
2211 BT_INFO("File [%d] [%s]", i, param);
2216 if (i == (number_of_files - 1)) {
2217 if (!__bt_main_get_mime_type(param)) {
2221 BT_INFO("File [%d] [%s]", i, param);
2223 BT_ERR("Count not match : [%d] / [%d]", number_of_files, i);
2234 bt_dev_t *_bt_main_create_searched_le_device_item(void *data)
2239 unsigned char bd_addr[BT_ADDRESS_LENGTH_MAX];
2240 bt_dev_t *dev = NULL;
2241 bt_adapter_le_device_scan_result_info_s *dev_info = NULL;
2242 char *remote_name = NULL;
2248 retv_if(data == NULL, NULL);
2250 dev_info = (bt_adapter_le_device_scan_result_info_s *) data;
2251 ret = bt_adapter_le_get_scan_result_device_name(dev_info, BT_ADAPTER_LE_PACKET_ADVERTISING, &remote_name);
2252 if (ret != BT_ERROR_NONE) {
2253 BT_ERR("Fail to get LE device name");
2260 if (strlen(remote_name) == 0) {
2261 g_free(remote_name);
2265 /* only HOG Device will be shown in searched list */
2266 if (bt_adapter_le_get_scan_result_service_uuids(
2267 dev_info, BT_ADAPTER_LE_PACKET_ADVERTISING, &uuids, &count) == BT_ERROR_NONE) {
2268 for (i = 0; i < count; i++) {
2269 BT_DBG("UUID[%d] = %s", i + 1, uuids[i]);
2270 if (g_strcmp0(HOGP_SERVICE_UUID, uuids[i]) == 0)
2276 BT_ERR("Fail to get LE service uuids");
2279 g_free(remote_name);
2283 dev = calloc(1, sizeof(bt_dev_t));
2285 g_free(remote_name);
2289 strncpy(dev->name, remote_name, DEVICE_NAME_MAX_LEN);
2291 dev->rssi = dev_info->rssi;
2292 dev->is_le_device = TRUE;
2294 _bt_util_addr_string_to_addr_type(bd_addr, dev_info->remote_address);
2296 memcpy(dev->addr_str, dev_info->remote_address, BT_ADDRESS_STR_LEN);
2298 memcpy(dev->bd_addr, bd_addr, BT_ADDRESS_LENGTH_MAX);
2300 BT_DBG("device name [%s]", dev->name);
2301 BT_DBG("%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X", dev->bd_addr[0],
2302 dev->bd_addr[1], dev->bd_addr[2], dev->bd_addr[3],
2303 dev->bd_addr[4], dev->bd_addr[5]);
2305 g_free(remote_name);
2310 /**********************************************************************
2312 ***********************************************************************/
2314 void _bt_main_scan_device(bt_ug_data *ugd)
2319 ret_if(ugd == NULL);
2321 if (ugd->op_status != BT_DEACTIVATED && ugd->op_status != BT_ACTIVATED) {
2322 BT_INFO("current bluetooth status [%d]", ugd->op_status);
2326 if (_bt_util_is_battery_low() == TRUE) {
2327 /* Battery is critical low */
2328 _bt_main_create_information_popup(ugd, BT_STR_LOW_BATTERY);
2332 if (ugd->op_status == BT_DEACTIVATED) {
2333 ret = _bt_main_enable_bt((void *)ugd);
2335 elm_object_disabled_set(ugd->scan_btn, EINA_TRUE);
2337 if (TIZEN_FEATURE_BT_HOG) {
2338 ret = bt_adapter_le_start_scan((bt_adapter_le_scan_result_cb)_bt_cb_new_le_device_found, (void *)ugd);
2340 ugd->is_le_discovery_started = TRUE;
2341 BT_DBG("LE Discovery started");
2343 BT_ERR("LE Discovery failed : Error Cause[%d]", ret);
2346 ret = bt_adapter_start_device_discovery();
2348 /* Disable the Scan button till the BLUETOOTH_EVENT_DISCOVERY_STARTED is received */
2349 elm_object_disabled_set(ugd->scan_btn, EINA_TRUE);
2350 _bt_main_remove_all_searched_devices(ugd);
2351 ugd->op_status = BT_SEARCHING;
2352 elm_object_text_set(ugd->scan_btn, BT_STR_STOP);
2354 if (ugd->searched_title == NULL)
2355 _bt_main_add_searched_title(ugd);
2357 BT_ERR("Operation failed : Error Cause[%d]", ret);
2364 int _bt_main_service_request_cb(void *data)
2368 bt_ug_data *ugd = NULL;
2370 retvm_if(data == NULL, BT_UG_FAIL,
2371 "Invalid argument: bt_ug_data is NULL");
2373 ugd = (bt_ug_data *)data;
2375 if (ugd->request_timer) {
2376 ecore_timer_del(ugd->request_timer);
2377 ugd->request_timer = NULL;
2380 /* Need to modify API: Address parameter */
2381 if (ugd->waiting_service_response == TRUE) {
2382 bt_dev_t *dev = NULL;
2384 ugd->waiting_service_response = FALSE;
2385 bt_device_cancel_service_search();
2388 _bt_main_get_dev_info(ugd->paired_device, ugd->paired_item);
2389 retvm_if(dev == NULL, BT_UG_FAIL, "dev is NULL");
2391 dev->status = BT_IDLE;
2392 _bt_update_genlist_item(ugd->paired_item);
2393 _bt_main_connect_device(ugd, dev);
2395 ugd->paired_item = NULL;
2399 return BT_UG_ERROR_NONE;
2402 #ifdef KIRAN_ACCESSIBILITY
2403 char *__bt_main_get_device_string(int major_class, int minor_class)
2406 char *device_type = NULL;
2408 BT_DBG("major_class: 0x%x, minor_class: 0x%x", major_class,
2411 switch (major_class) {
2412 case BT_MAJOR_DEV_CLS_COMPUTER:
2413 device_type = g_strdup(BT_STR_COMPUTER);
2415 case BT_MAJOR_DEV_CLS_PHONE:
2416 device_type = g_strdup(BT_STR_PHONE);
2418 case BT_MAJOR_DEV_CLS_AUDIO:
2419 if (minor_class == BTAPP_MIN_DEV_CLS_HEADPHONES)
2420 device_type = g_strdup(BT_STR_SVC_STEREO);
2422 device_type = g_strdup(BT_STR_SVC_HEADSET);
2424 case BT_MAJOR_DEV_CLS_LAN_ACCESS_POINT:
2425 device_type = g_strdup(BT_STR_LAN_ACCESS_POINT);
2427 case BT_MAJOR_DEV_CLS_IMAGING:
2428 if (minor_class == BTAPP_MIN_DEV_CLS_PRINTER)
2429 device_type = g_strdup(BT_STR_PRINTER);
2430 else if (minor_class == BTAPP_MIN_DEV_CLS_CAMERA)
2431 device_type = g_strdup(BT_STR_CAMERA);
2432 else if (minor_class == BTAPP_MIN_DEV_CLS_DISPLAY)
2433 device_type = g_strdup(BT_STR_DISPLAY);
2435 case BT_MAJOR_DEV_CLS_PERIPHERAL:
2436 if (minor_class == BTAPP_MIN_DEV_CLS_KEY_BOARD)
2437 device_type = g_strdup(BT_STR_KEYBOARD);
2438 else if (minor_class == BTAPP_MIN_DEV_CLS_POINTING_DEVICE)
2439 device_type = g_strdup(BT_STR_MOUSE);
2440 else if (minor_class == BTAPP_MIN_DEV_CLS_GAME_PAD)
2441 device_type = g_strdup(BT_STR_GAMING_DEVICE);
2443 device_type = g_strdup(BT_STR_MOUSE);
2445 case BT_MAJOR_DEV_CLS_HEALTH:
2446 device_type = g_strdup(BT_STR_HEALTH_DEVICE);
2449 device_type = g_strdup(BT_STR_UNKNOWN);
2453 if (device_type == NULL)
2454 device_type = g_strdup(BT_STR_UNKNOWN);
2461 char *_bt_main_get_device_icon(int major_class, int minor_class,
2462 int connected, gboolean highlighted)
2464 char *icon = BT_ICON_UNKNOWN;
2466 switch (major_class) {
2467 case BT_MAJOR_DEV_CLS_COMPUTER:
2470 case BT_MAJOR_DEV_CLS_PHONE:
2471 icon = BT_ICON_PHONE;
2473 case BT_MAJOR_DEV_CLS_AUDIO:
2474 if (minor_class == BTAPP_MIN_DEV_CLS_HEADPHONES)
2475 icon = BT_ICON_HEADPHONE;
2476 else if (minor_class == BTAPP_MIN_DEV_CLS_VIDEO_DISPLAY_AND_LOUD_SPEAKER)
2477 icon = BT_ICON_DISPLAY;
2479 icon = BT_ICON_HEADSET;
2481 case BT_MAJOR_DEV_CLS_LAN_ACCESS_POINT:
2482 icon = BT_ICON_NETWORK;
2484 case BT_MAJOR_DEV_CLS_IMAGING:
2485 if (minor_class == BTAPP_MIN_DEV_CLS_PRINTER)
2486 icon = BT_ICON_PRINTER;
2487 else if (minor_class == BTAPP_MIN_DEV_CLS_CAMERA)
2488 icon = BT_ICON_CAMERA;
2489 else if (minor_class == BTAPP_MIN_DEV_CLS_DISPLAY)
2490 icon = BT_ICON_DISPLAY;
2492 case BT_MAJOR_DEV_CLS_PERIPHERAL:
2493 if (minor_class == BTAPP_MIN_DEV_CLS_KEY_BOARD)
2494 icon = BT_ICON_KEYBOARD;
2495 else if (minor_class == BTAPP_MIN_DEV_CLS_POINTING_DEVICE)
2496 icon = BT_ICON_MOUSE;
2497 else if (minor_class == BTAPP_MIN_DEV_CLS_GAME_PAD)
2498 icon = BT_ICON_GAMING;
2500 icon = BT_ICON_MOUSE;
2502 case BT_MAJOR_DEV_CLS_HEALTH:
2503 icon = BT_ICON_HEALTH;
2506 case BT_MAJOR_DEV_CLS_WEARABLE:
2507 if (minor_class == BTAPP_MIN_DEV_CLS_WRIST_WATCH)
2508 icon = BT_ICON_WATCH;
2510 icon = BT_ICON_UNKNOWN;
2513 icon = BT_ICON_UNKNOWN;
2520 void _bt_main_popup_del_cb(void *data, Evas_Object *obj, void *event_info)
2523 retm_if(data == NULL, "Invalid argument: struct bt_appdata is NULL");
2525 bt_ug_data *ugd = (bt_ug_data *)data;
2528 evas_object_del(ugd->popup);
2531 if (ugd->popup_data.data)
2532 g_free(ugd->popup_data.data);
2533 ugd->popup_data.data = NULL;
2535 ugd->back_cb = NULL;
2540 void _bt_back_btn_popup_del_cb(void *data, Evas_Object *obj, void *event_info)
2543 retm_if(data == NULL, "Invalid argument: struct bt_appdata is NULL");
2545 bt_ug_data *ugd = (bt_ug_data *)data;
2548 BT_DBG("Deleting popup");
2549 evas_object_del(ugd->popup);
2553 ugd->op_status = BT_ACTIVATED;
2558 Elm_Object_Item *_bt_main_add_paired_device_on_bond(bt_ug_data *ugd, bt_dev_t *dev)
2562 Elm_Object_Item *git = NULL;
2564 retvm_if(ugd == NULL, NULL, "Invalid argument: ugd is NULL");
2565 retvm_if(dev == NULL, NULL, "Invalid argument: dev is NULL");
2567 /* Paired device Title */
2568 if (ugd->paired_title == NULL) {
2569 if (ugd->searched_title == NULL) {
2570 git = elm_genlist_item_append(ugd->main_genlist,
2571 ugd->paired_title_itc,
2573 ELM_GENLIST_ITEM_NONE,
2575 elm_genlist_item_select_mode_set(git,
2576 ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
2578 git = elm_genlist_item_insert_before(ugd->main_genlist,
2579 ugd->paired_title_itc,
2581 ugd->searched_title,
2582 ELM_GENLIST_ITEM_NONE,
2584 elm_genlist_item_select_mode_set(git,
2585 ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
2588 ugd->paired_title = git;
2591 dev->ugd = (void *)ugd;
2592 dev->is_bonded = TRUE;
2593 dev->status = BT_IDLE;
2595 /* Add the device item in the list */
2596 if (ugd->paired_device == NULL) {
2597 git = elm_genlist_item_insert_after(ugd->main_genlist,
2598 ugd->paired_device_itc, dev, NULL,
2600 ELM_GENLIST_ITEM_NONE,
2601 __bt_main_paired_item_sel_cb,
2604 bt_dev_t *item_dev = NULL;
2605 Elm_Object_Item *item = NULL;
2606 Elm_Object_Item *next = NULL;
2608 item = elm_genlist_item_next_get(ugd->paired_title);
2610 while (item != NULL || item != ugd->searched_title) {
2611 item_dev = _bt_main_get_dev_info(ugd->paired_device, item);
2613 if (item_dev && item_dev->is_connected > 0) {
2614 next = elm_genlist_item_next_get(item);
2615 if (next == NULL || next == ugd->searched_title) {
2616 git = elm_genlist_item_insert_after(ugd->main_genlist,
2617 ugd->paired_device_itc, dev, NULL, item,
2618 ELM_GENLIST_ITEM_NONE,
2619 __bt_main_paired_item_sel_cb,
2625 git = elm_genlist_item_insert_before(ugd->main_genlist,
2626 ugd->paired_device_itc, dev,
2627 NULL, item, ELM_GENLIST_ITEM_NONE,
2628 __bt_main_paired_item_sel_cb, ugd);
2633 dev->genlist_item = git;
2636 return dev->genlist_item;
2639 void _bt_sort_paired_device_list(bt_ug_data *ugd, bt_dev_t *dev, int connected)
2643 bt_dev_t *item = NULL;
2644 Elm_Object_Item *git = NULL;
2645 Eina_List *l = NULL;
2646 Eina_List *l_next = NULL;
2648 retm_if(ugd == NULL, "Invalid argument: ugd is NULL");
2649 retm_if(dev == NULL, "Invalid argument: dev is NULL");
2651 EINA_LIST_FOREACH_SAFE(ugd->paired_device, l, l_next, item) {
2652 if (item && (item == dev)) {
2654 elm_object_item_del(item->genlist_item);
2655 git = elm_genlist_item_insert_after(ugd->main_genlist,
2656 ugd->paired_device_itc, dev, NULL,
2658 ELM_GENLIST_ITEM_NONE,
2659 __bt_main_paired_item_sel_cb,
2661 dev->genlist_item = git;
2664 if (ugd->searched_title) {
2665 elm_object_item_del(item->genlist_item);
2666 git = elm_genlist_item_insert_before(ugd->main_genlist,
2667 ugd->paired_device_itc, dev, NULL,
2668 ugd->searched_title,
2669 ELM_GENLIST_ITEM_NONE,
2670 __bt_main_paired_item_sel_cb,
2672 dev->genlist_item = git;
2675 elm_object_item_del(item->genlist_item);
2676 git = elm_genlist_item_append(ugd->main_genlist,
2677 ugd->paired_device_itc, dev, NULL,
2678 ELM_GENLIST_ITEM_NONE,
2679 __bt_main_paired_item_sel_cb,
2681 dev->genlist_item = git;
2693 Elm_Object_Item *_bt_main_add_paired_device(bt_ug_data *ugd, bt_dev_t *dev)
2697 Elm_Object_Item *git = NULL;
2699 retvm_if(ugd == NULL, NULL, "Invalid argument: ugd is NULL");
2700 retvm_if(dev == NULL, NULL, "Invalid argument: dev is NULL");
2702 /* Paired device Title */
2703 if (ugd->paired_title == NULL) {
2704 if (ugd->searched_title == NULL) {
2705 git = elm_genlist_item_append(ugd->main_genlist,
2706 ugd->paired_title_itc,
2708 ELM_GENLIST_ITEM_NONE,
2710 elm_genlist_item_select_mode_set(git,
2711 ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
2713 git = elm_genlist_item_insert_before(ugd->main_genlist,
2714 ugd->paired_title_itc,
2716 ugd->searched_title,
2717 ELM_GENLIST_ITEM_NONE,
2719 elm_genlist_item_select_mode_set(git,
2720 ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
2723 ugd->paired_title = git;
2726 dev->ugd = (void *)ugd;
2727 dev->is_bonded = TRUE;
2728 dev->status = BT_IDLE;
2730 /* Add the device item in the list */
2731 if (ugd->paired_device == NULL) {
2732 git = elm_genlist_item_insert_after(ugd->main_genlist,
2733 ugd->paired_device_itc, dev, NULL,
2735 ELM_GENLIST_ITEM_NONE,
2736 __bt_main_paired_item_sel_cb,
2739 if (dev->is_connected > 0) {
2740 git = elm_genlist_item_insert_after(ugd->main_genlist,
2741 ugd->paired_device_itc, dev, NULL,
2743 ELM_GENLIST_ITEM_NONE,
2744 __bt_main_paired_item_sel_cb,
2747 Elm_Object_Item *item = NULL;
2748 Elm_Object_Item *next = NULL;
2750 item = elm_genlist_item_next_get(ugd->paired_title);
2752 while (item != NULL || item != ugd->searched_title) {
2753 next = elm_genlist_item_next_get(item);
2754 if (next == NULL || next == ugd->searched_title) {
2755 git = elm_genlist_item_insert_after(ugd->main_genlist,
2756 ugd->paired_device_itc, dev, NULL, item,
2757 ELM_GENLIST_ITEM_NONE,
2758 __bt_main_paired_item_sel_cb,
2766 dev->genlist_item = git;
2769 return dev->genlist_item;
2772 Elm_Object_Item *_bt_main_add_searched_device(bt_ug_data *ugd, bt_dev_t *dev)
2776 Elm_Object_Item *git = NULL;
2778 retvm_if(ugd == NULL, NULL, "Invalid argument: ugd is NULL");
2779 retvm_if(dev == NULL, NULL, "Invalid argument: dev is NULL");
2781 if (ugd->searched_title == NULL)
2782 _bt_main_add_searched_title(ugd);
2784 retvm_if(ugd->searched_title == NULL, NULL,
2785 "Fail to add searched title genlist item");
2787 /* Searched device Item */
2788 if (ugd->searched_device == NULL) {
2790 elm_genlist_item_insert_after(ugd->main_genlist,
2791 ugd->searched_device_itc, dev, NULL,
2792 ugd->searched_title,
2793 ELM_GENLIST_ITEM_NONE,
2794 __bt_main_searched_item_sel_cb,
2797 bt_dev_t *item_dev = NULL;
2798 Elm_Object_Item *item = NULL;
2799 Elm_Object_Item *next = NULL;
2800 Elm_Object_Item *prev = NULL;
2802 item = elm_genlist_item_next_get(ugd->searched_title);
2804 /* check the RSSI value of searched device list add arrange its order */
2805 while (item != NULL) {
2807 _bt_main_get_dev_info(ugd->searched_device, item);
2808 retv_if(item_dev == NULL, NULL);
2810 if (item_dev->rssi > dev->rssi) {
2811 prev = elm_genlist_item_prev_get(item);
2812 next = elm_genlist_item_next_get(item);
2815 elm_genlist_item_insert_after
2817 ugd->searched_device_itc, dev, NULL, item,
2818 ELM_GENLIST_ITEM_NONE,
2819 __bt_main_searched_item_sel_cb,
2822 if (TIZEN_COMMON && prev == ugd->searched_title)
2823 elm_object_item_signal_emit(item, "elm,state,group,top", "elm");
2829 next = elm_genlist_item_next_get(item);
2832 elm_genlist_item_insert_before
2833 (ugd->main_genlist, ugd->searched_device_itc, dev,
2834 NULL, item, ELM_GENLIST_ITEM_NONE,
2835 __bt_main_searched_item_sel_cb, ugd);
2839 elm_object_item_signal_emit(item, "elm,state,group,bottom", "elm");
2841 elm_object_item_signal_emit(item, "elm,state,group,middle", "elm");
2849 dev->genlist_item = git;
2850 dev->status = BT_IDLE;
2851 dev->ugd = (void *)ugd;
2852 dev->is_bonded = FALSE;
2858 Elm_Object_Item *_bt_main_add_no_device_found(bt_ug_data *ugd)
2862 Elm_Object_Item *git = NULL;
2864 retvm_if(ugd == NULL, NULL, "Invalid argument: ugd is NULL");
2866 if (ugd->searched_title == NULL)
2867 _bt_main_add_searched_title(ugd);
2869 /* No device found Item */
2871 elm_genlist_item_insert_after(ugd->main_genlist, ugd->no_device_itc,
2872 ugd, NULL, ugd->searched_title,
2873 ELM_GENLIST_ITEM_NONE, NULL, NULL);
2875 elm_genlist_item_select_mode_set(git,
2876 ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
2882 static void __bt_move_help_ctxpopup(Evas_Object *ctx, bt_ug_data *ugd)
2888 ret_if(ugd == NULL);
2889 ret_if(ugd->win_main == NULL);
2891 elm_win_screen_size_get(ugd->win_main, NULL, NULL, &w, &h);
2892 pos = elm_win_rotation_get(ugd->win_main);
2897 evas_object_move(ctx, (w/2), h);
2901 evas_object_move(ctx, (h/2), w);
2904 evas_object_move(ctx, (w/2), h);
2910 static void __bt_ctxpopup_rotate_cb(void *data, Evas_Object *obj, void *event_info)
2913 bt_ug_data *ugd = NULL;
2914 ret_if(data == NULL);
2915 ugd = (bt_ug_data *)data;
2917 __bt_move_help_ctxpopup(ugd->help_more_popup, ugd);
2918 evas_object_show(ugd->win_main);
2923 static void __bt_more_popup_del_cb(void *data)
2926 bt_ug_data *ugd = NULL;
2928 ret_if(data == NULL);
2929 ugd = (bt_ug_data *)data;
2931 if (ugd->help_more_popup != NULL) {
2932 evas_object_del(ugd->help_more_popup);
2933 ugd->help_more_popup = NULL;
2939 static void __bt_more_popup_more_cb(void *data,
2940 Evas_Object *obj, void *event_info)
2943 __bt_more_popup_del_cb((bt_ug_data *)data);
2947 static void __bt_more_popup_back_cb(void *data,
2948 Evas_Object *obj, void *event_info)
2951 __bt_more_popup_del_cb((bt_ug_data *)data);
2955 static void __bt_more_popup_dismiss_cb(void *data, Evas_Object *obj,
2961 ugd = (bt_ug_data *)data;
2962 ret_if(ugd == NULL);
2963 ret_if(ugd->help_more_popup == NULL);
2965 evas_object_del(ugd->help_more_popup);
2966 ugd->help_more_popup = NULL;
2971 static void __bt_more_popup_delete_cb(void *data, Evas *e,
2972 Evas_Object *obj, void *event_info)
2975 Evas_Object *navi = (Evas_Object *)data;
2976 Evas_Object *ctx = obj;
2978 ret_if(navi == NULL);
2980 evas_object_smart_callback_del(ctx, "dismissed",
2981 __bt_more_popup_dismiss_cb);
2982 evas_object_event_callback_del_full(ctx, EVAS_CALLBACK_DEL,
2983 __bt_more_popup_delete_cb, navi);
2987 #ifdef TIZEN_REDWOOD
2988 static void __bt_ug_layout_cb(ui_gadget_h ug, enum ug_mode mode, void *priv)
2995 base = ug_get_layout(ug);
2997 BT_ERR("ug_get_layout() return NULL");
3002 evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3003 evas_object_show(base);
3007 static void __bt_ug_destroy_cb(ui_gadget_h ug, void *data)
3017 static void __bt_more_popup_rename_device_item_sel_cb(void *data,
3018 Evas_Object *obj, void *event_inf)
3021 ret_if(data == NULL);
3022 ret_if(event_inf == NULL);
3023 bt_ug_data *ugd = (bt_ug_data *)data;
3026 elm_genlist_item_selected_set((Elm_Object_Item *)event_inf,
3029 ret_if(ugd == NULL);
3030 ret_if(ugd->help_more_popup == NULL);
3031 evas_object_del(ugd->help_more_popup);
3032 ugd->help_more_popup = NULL;
3033 Evas_Object *popup = NULL;
3034 Evas_Object *genlist = NULL;
3035 Evas_Object *button = NULL;
3036 Elm_Object_Item *git = NULL;
3039 popup = elm_popup_add(ugd->base);
3040 eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK,
3041 __bt_rename_device_cancel_cb, ugd);
3042 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3043 evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
3045 elm_object_domain_translatable_part_text_set(popup,
3048 "IDS_ST_HEADER_RENAME_DEVICE");
3050 genlist = elm_genlist_add(popup);
3051 evas_object_size_hint_weight_set(genlist,
3052 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3053 evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
3054 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
3055 elm_scroller_content_min_limit(genlist, EINA_FALSE, EINA_TRUE);
3057 /* Entry genlist item */
3058 ugd->rename_entry_itc = elm_genlist_item_class_new();
3059 /* Fix : NULL_RETURNS */
3060 if (ugd->rename_entry_itc) {
3061 ugd->rename_entry_itc->item_style = BT_GENLIST_FULL_CONTENT_STYLE;
3062 ugd->rename_entry_itc->func.text_get = NULL;
3063 ugd->rename_entry_itc->func.content_get = __bt_main_rename_entry_icon_get;
3064 ugd->rename_entry_itc->func.state_get = NULL;
3065 ugd->rename_entry_itc->func.del = NULL;
3067 ugd->rename_entry_item = elm_genlist_item_append(genlist,
3068 ugd->rename_entry_itc, ugd,
3069 NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
3072 ugd->rename_desc_itc = elm_genlist_item_class_new();
3073 /* Fix : NULL_RETURNS */
3074 if (ugd->rename_desc_itc) {
3075 ugd->rename_desc_itc->item_style = BT_GENLIST_MULTILINE_TEXT_STYLE;
3076 ugd->rename_desc_itc->func.text_get = __bt_main_rename_desc_label_get;
3077 ugd->rename_desc_itc->func.content_get = NULL;
3078 ugd->rename_desc_itc->func.state_get = NULL;
3079 ugd->rename_desc_itc->func.del = NULL;
3081 git = elm_genlist_item_append(genlist, ugd->rename_desc_itc, NULL, NULL,
3082 ELM_GENLIST_ITEM_NONE, NULL, NULL);
3084 elm_genlist_item_select_mode_set(git,
3085 ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
3087 button = elm_button_add(popup);
3088 elm_object_style_set(button, "popup");
3089 elm_object_domain_translatable_text_set(button,
3091 "IDS_BR_SK_CANCEL");
3092 elm_object_part_content_set(popup, "button1", button);
3093 evas_object_smart_callback_add(button, "clicked",
3094 __bt_rename_device_cancel_cb, ugd);
3096 button = elm_button_add(popup);
3097 ugd->rename_button = button;
3098 elm_object_style_set(button, "popup");
3099 elm_object_domain_translatable_text_set(button,
3101 "IDS_BT_OPT_RENAME");
3102 elm_object_part_content_set(popup, "button2", button);
3103 evas_object_smart_callback_add(button, "clicked",
3104 __bt_rename_device_ok_cb, ugd);
3106 evas_object_show(genlist);
3108 elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
3109 elm_object_content_set(popup, genlist);
3110 evas_object_show(popup);
3112 ugd->rename_popup = popup;
3118 #ifdef TIZEN_REDWOOD
3119 static void __bt_more_popup_help_item_sel_cb(void *data,
3120 Evas_Object *obj, void *event_info)
3125 bt_ug_data *ugd = (bt_ug_data *)data;
3126 app_control_h service = NULL;
3127 ui_gadget_h ug_h = NULL;
3128 struct ug_cbs cbs = {0};
3131 BT_DBG("delete popup");
3132 evas_object_del(ugd->popup);
3136 app_control_create(&service);
3137 app_control_add_extra_data(service, "page", "help_settings_bluetooth");
3139 cbs.layout_cb = __bt_ug_layout_cb;
3140 cbs.result_cb = NULL;
3141 cbs.destroy_cb = __bt_ug_destroy_cb;
3144 ug_h = ug_create(NULL, "help-efl", UG_MODE_FULLVIEW, service, &cbs);
3146 BT_ERR("ug_create() Failed");
3148 app_control_destroy(service);
3149 __bt_more_popup_del_cb((bt_ug_data *)data);
3154 static void __bt_more_menu_cb(void *data,
3155 Evas_Object *obj, void *event_info)
3159 Evas_Object *more_ctxpopup = NULL;
3162 ugd = (bt_ug_data *)data;
3163 ret_if(ugd == NULL);
3164 ret_if(ugd->profile_vd != NULL);
3165 ret_if(ugd->op_status == BT_ACTIVATING ||
3166 ugd->op_status == BT_DEACTIVATED ||
3167 ugd->op_status == BT_DEACTIVATING);
3168 ret_if(ugd->bt_launch_mode != BT_LAUNCH_NORMAL);
3170 _bt_main_popup_del_cb(ugd, NULL, NULL);
3172 more_ctxpopup = elm_ctxpopup_add(ugd->win_main);
3173 ugd->help_more_popup = more_ctxpopup;
3174 eext_object_event_callback_add(more_ctxpopup,
3175 EEXT_CALLBACK_BACK, __bt_more_popup_back_cb, ugd);
3176 eext_object_event_callback_add(more_ctxpopup,
3177 EEXT_CALLBACK_MORE, __bt_more_popup_more_cb, ugd);
3178 elm_object_style_set(more_ctxpopup, "more/default");
3179 elm_ctxpopup_auto_hide_disabled_set(more_ctxpopup, EINA_TRUE);
3181 elm_ctxpopup_item_append(more_ctxpopup, BT_STR_RENAME_DEVICE_TITLE,
3182 NULL, __bt_more_popup_rename_device_item_sel_cb, ugd);
3184 evas_object_smart_callback_add(more_ctxpopup, "dismissed",
3185 __bt_more_popup_dismiss_cb, ugd);
3186 evas_object_event_callback_add(more_ctxpopup, EVAS_CALLBACK_DEL,
3187 __bt_more_popup_delete_cb, ugd->navi_bar);
3188 evas_object_smart_callback_add(elm_object_top_widget_get(more_ctxpopup), "rotation,changed",
3189 __bt_ctxpopup_rotate_cb, ugd);
3191 elm_ctxpopup_direction_priority_set(more_ctxpopup, ELM_CTXPOPUP_DIRECTION_UP,
3192 ELM_CTXPOPUP_DIRECTION_DOWN,
3193 ELM_CTXPOPUP_DIRECTION_UNKNOWN,
3194 ELM_CTXPOPUP_DIRECTION_UNKNOWN);
3196 __bt_move_help_ctxpopup(more_ctxpopup, ugd);
3197 evas_object_show(more_ctxpopup);
3202 Evas_Object * _bt_main_create_scan_button(bt_ug_data *ugd)
3204 Evas_Object *scan_button = NULL;
3205 Evas_Object *box = NULL;
3207 box = elm_box_add(ugd->navi_bar);
3209 BT_DBG("Can't create box");
3213 scan_button = elm_button_add(box);
3216 /* Use "border" style button for IOT common */
3217 elm_object_style_set(scan_button, "border");
3219 /* Use "bottom" style button */
3220 elm_object_style_set(scan_button, "bottom");
3223 elm_object_text_set(scan_button, BT_STR_SCAN);
3225 evas_object_size_hint_align_set(scan_button, EVAS_HINT_FILL, EVAS_HINT_FILL);
3226 evas_object_size_hint_weight_set(scan_button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3229 evas_object_size_hint_padding_set(scan_button, 0, 0, 30, 0);
3231 evas_object_smart_callback_add(scan_button, "clicked",
3232 __bt_main_controlbar_btn_cb, ugd);
3234 elm_box_pack_end(box, scan_button);
3236 /* Set box into "toolbar" swallow part */
3237 elm_object_item_part_content_set(ugd->navi_it, "toolbar", box);
3238 evas_object_show(scan_button);
3243 static void __bt_main_back_cb(void *data, Evas_Object *obj, void *event_info)
3245 __bt_main_quit_btn_cb(data, NULL);
3248 int _bt_main_draw_list_view(bt_ug_data *ugd)
3252 Evas_Object *navi = NULL;
3253 Evas_Object *genlist = NULL;
3254 Elm_Object_Item *navi_it = NULL;
3255 Evas_Object *back_button = NULL;
3257 retv_if(ugd == NULL, BT_UG_FAIL);
3259 navi = _bt_create_naviframe(ugd->base);
3260 elm_naviframe_prev_btn_auto_pushed_set(navi, EINA_FALSE);
3261 ugd->navi_bar = navi;
3263 eext_object_event_callback_add(navi, EEXT_CALLBACK_BACK,
3264 eext_naviframe_back_cb, NULL);
3266 if (ugd->bt_launch_mode != BT_LAUNCH_HELP)
3267 eext_object_event_callback_add(navi, EEXT_CALLBACK_MORE,
3268 __bt_more_menu_cb, ugd);
3269 genlist = __bt_main_add_genlist_dialogue(navi, ugd);
3270 ugd->main_genlist = genlist;
3272 back_button = elm_button_add(navi);
3273 elm_object_style_set(back_button, "naviframe/end_btn/default");
3275 navi_it = elm_naviframe_item_push(navi, BT_STR_BLUETOOTH, back_button, NULL,
3277 elm_naviframe_item_pop_cb_set(navi_it, __bt_main_quit_btn_cb, ugd);
3278 ugd->navi_it = navi_it;
3279 evas_object_smart_callback_add(back_button, "clicked", __bt_main_back_cb, ugd);
3281 if (ugd->op_status == BT_ACTIVATED)
3282 ugd->scan_btn = _bt_main_create_scan_button(ugd);
3284 ugd->confirm_req = BT_NONE_REQ;
3287 return BT_UG_ERROR_NONE;
3290 int _bt_main_draw_visibility_view(bt_ug_data *ugd)
3294 Evas_Object *navi = NULL;
3295 Evas_Object *genlist = NULL;
3296 Elm_Object_Item *navi_it;
3298 retv_if(ugd == NULL, BT_UG_FAIL);
3300 navi = _bt_create_naviframe(ugd->base);
3302 elm_naviframe_prev_btn_auto_pushed_set(navi, EINA_FALSE);
3304 eext_object_event_callback_add(navi, EEXT_CALLBACK_BACK,
3305 eext_naviframe_back_cb, NULL);
3307 genlist = __bt_main_add_visibility_dialogue(navi, ugd);
3310 elm_naviframe_item_push(navi, BT_STR_VISIBLE, NULL, NULL, genlist,
3312 elm_naviframe_item_pop_cb_set(navi_it, __bt_main_quit_btn_cb, ugd);
3313 ugd->navi_it = navi_it;
3314 ugd->navi_bar = navi;
3315 ugd->main_genlist = genlist;
3316 ugd->confirm_req = BT_NONE_REQ;
3319 return BT_UG_ERROR_NONE;
3322 int _bt_main_draw_onoff_view(bt_ug_data *ugd)
3326 Evas_Object *navi = NULL;
3327 Evas_Object *genlist = NULL;
3328 Elm_Object_Item *navi_it;
3330 retv_if(ugd == NULL, BT_UG_FAIL);
3332 navi = _bt_create_naviframe(ugd->base);
3334 elm_naviframe_prev_btn_auto_pushed_set(navi, EINA_FALSE);
3336 eext_object_event_callback_add(navi, EEXT_CALLBACK_BACK,
3337 eext_naviframe_back_cb, NULL);
3339 genlist = __bt_main_add_onoff_dialogue(navi, ugd);
3342 elm_naviframe_item_push(navi, BT_STR_BLUETOOTH, NULL, NULL, genlist,
3344 elm_naviframe_item_pop_cb_set(navi_it, __bt_main_quit_btn_cb, ugd);
3345 ugd->navi_it = navi_it;
3346 ugd->navi_bar = navi;
3347 ugd->main_genlist = genlist;
3348 ugd->confirm_req = BT_NONE_REQ;
3351 return BT_UG_ERROR_NONE;
3354 static Eina_Bool __bt_cb_register_net_state_cb(void *data)
3358 bt_dev_t *dev = NULL;
3359 Eina_List *l = NULL;
3360 Eina_List *l2 = NULL;
3361 bt_net_profile_t *profile_data = NULL;
3362 void *profile = NULL;
3363 char net_address[BT_ADDRESS_STR_LEN + 1] = { 0 };
3365 bt_ug_data *ugd = (bt_ug_data *)data;
3366 if (ugd->network_timer) {
3367 ecore_timer_del(ugd->network_timer);
3368 ugd->network_timer = NULL;
3370 retv_if(ugd == NULL, ECORE_CALLBACK_CANCEL);
3371 retv_if(ugd->connection == NULL, ECORE_CALLBACK_CANCEL);
3373 if (ugd->paired_device) {
3374 EINA_LIST_FOREACH(ugd->paired_device, l, dev) {
3376 (dev->service_list & BT_SC_PANU_SERVICE_MASK ||
3377 dev->service_list & BT_SC_NAP_SERVICE_MASK) &&
3378 dev->is_connected && !dev->net_profile) {
3379 if (!ugd->net_profile_list)
3380 ugd->net_profile_list =
3381 _bt_get_registered_net_profile_list(ugd->connection);
3382 retvm_if(!ugd->net_profile_list, ECORE_CALLBACK_CANCEL,
3383 "net_profile_list is NULL!");
3385 EINA_LIST_FOREACH(ugd->net_profile_list, l2, profile_data) {
3387 profile_data->profile_h &&
3388 profile_data->address) {
3389 _bt_util_addr_type_to_addr_net_string(net_address, dev->bd_addr);
3390 if (!g_strcmp0((const char *)profile_data->address, net_address)) {
3391 profile = _bt_get_registered_net_profile(ugd->connection,
3393 _bt_set_profile_state_changed_cb(profile, dev);
3400 if (ugd->net_profile_list) {
3401 _bt_free_net_profile_list(ugd->net_profile_list);
3402 ugd->net_profile_list = NULL;
3408 return ECORE_CALLBACK_CANCEL;
3411 static bool __bt_cb_adapter_bonded_device(bt_device_info_s *device_info,
3414 bt_dev_t *dev = NULL;
3415 bt_ug_data *ugd = NULL;
3416 unsigned int service_class;
3418 retv_if(!user_data, false);
3419 retv_if(!device_info->remote_name || strlen(device_info->remote_name) == 0, false);
3420 retv_if(!device_info->remote_address || strlen(device_info->remote_address) == 0, false);
3422 ugd = (bt_ug_data *)user_data;
3424 if (_bt_main_check_and_update_device(ugd->paired_device,
3425 device_info->remote_address,
3426 device_info->remote_name) >= 0) {
3427 /* Update all realized items */
3428 elm_genlist_realized_items_update(ugd->main_genlist);
3433 dev = _bt_main_create_paired_device_item(device_info);
3435 retv_if(!dev, false);
3437 dev->ugd = (void *)ugd;
3438 if (device_info->is_connected)
3439 dev->is_connected = _bt_util_check_any_profile_connected(dev);
3441 dev->is_connected = device_info->is_connected;
3443 BT_INFO("device state(%d) overriding with profile state(%d)",
3444 device_info->is_connected, dev->is_connected);
3446 service_class = dev->service_class;
3448 /* WORKAROUND for a PLM issue.
3449 For some devices, service class is 0 even if it supports OPP server. So it is
3450 not showing in the device list when user try to share files via bluetooth.
3451 So override service_class with BT_COD_SC_OBJECT_TRANSFER in that case
3453 BT_DBG("overriding");
3454 if (service_class == 0) {
3455 if (dev->service_list & BT_SC_OPP_SERVICE_MASK)
3456 service_class = BT_COD_SC_OBJECT_TRANSFER;
3459 if (_bt_main_is_matched_profile(ugd->search_type,
3463 dev->minor_class) == TRUE) {
3464 BT_INFO("Device count [%d]",
3465 eina_list_count(ugd->paired_device));
3467 if (_bt_main_add_paired_device(ugd, dev) != NULL) {
3468 ugd->paired_device =
3469 eina_list_append(ugd->paired_device, dev);
3471 if ((!TIZEN_FEATURE_BT_HOG && dev->service_list == 0) || (TIZEN_FEATURE_BT_HOG && (dev->service_list == 0) && (!dev->is_le_device))) {
3472 if (bt_device_start_service_search
3473 ((const char *)dev->addr_str) == BT_ERROR_NONE) {
3475 ugd->paired_item = dev->genlist_item;
3476 dev->status = BT_SERVICE_SEARCHING;
3477 ugd->waiting_service_response = TRUE;
3478 ugd->request_timer =
3479 ecore_timer_add(BT_SEARCH_SERVICE_TIMEOUT,
3481 _bt_main_service_request_cb,
3484 BT_ERR("service search error");
3489 BT_ERR("Device class and search type do not match");
3495 void _bt_main_draw_paired_devices(bt_ug_data *ugd)
3499 ret_if(ugd == NULL);
3501 if (bt_adapter_foreach_bonded_device(__bt_cb_adapter_bonded_device,
3502 (void *)ugd) != BT_ERROR_NONE) {
3503 BT_ERR("bt_adapter_foreach_bonded_device() failed");
3507 ugd->network_timer = ecore_timer_add(1, __bt_cb_register_net_state_cb, ugd);
3509 if (!ugd->network_timer)
3510 BT_ERR("network_timer can not be added");
3515 void _bt_main_remove_paired_device(bt_ug_data *ugd, bt_dev_t *dev)
3519 bt_dev_t *item = NULL;
3520 Eina_List *l = NULL;
3521 Eina_List *l_next = NULL;
3523 retm_if(ugd == NULL, "Invalid argument: ugd is NULL");
3524 retm_if(dev == NULL, "Invalid argument: dev is NULL");
3526 EINA_LIST_FOREACH_SAFE(ugd->paired_device, l, l_next, item) {
3527 if (item && (item == dev)) {
3528 elm_object_item_del(item->genlist_item);
3529 ugd->paired_device =
3530 eina_list_remove_list(ugd->paired_device, l);
3534 if (ugd->paired_device == NULL ||
3535 eina_list_count(ugd->paired_device) == 0) {
3536 elm_object_item_del(ugd->paired_title);
3537 ugd->paired_title = NULL;
3543 void _bt_main_remove_all_paired_devices(bt_ug_data *ugd)
3547 bt_dev_t *dev = NULL;
3548 Eina_List *l = NULL;
3549 Eina_List *l_next = NULL;
3550 Elm_Object_Item *item;
3551 Elm_Object_Item *next;
3553 ret_if(ugd == NULL);
3555 if (ugd->paired_title) {
3556 item = elm_genlist_item_next_get(ugd->paired_title);
3558 elm_object_item_del(ugd->paired_title);
3559 ugd->paired_title = NULL;
3561 while (item != NULL && (item != ugd->searched_title)) {
3562 next = elm_genlist_item_next_get(item);
3563 elm_object_item_del(item);
3568 EINA_LIST_FOREACH_SAFE(ugd->paired_device, l, l_next, dev) {
3569 ugd->paired_device =
3570 eina_list_remove_list(ugd->paired_device, l);
3571 _bt_util_free_device_item(dev);
3574 ugd->paired_device = NULL;
3580 void _bt_main_remove_searched_device(bt_ug_data *ugd, bt_dev_t *dev)
3584 bt_dev_t *item = NULL;
3585 Eina_List *l = NULL;
3586 Eina_List *l_next = NULL;
3588 ret_if(ugd == NULL);
3590 EINA_LIST_FOREACH_SAFE(ugd->searched_device, l, l_next, item) {
3591 if (item && (item == dev)) {
3592 if (dev->genlist_item) {
3593 elm_object_item_del(dev->genlist_item);
3594 dev->genlist_item = NULL;
3596 ugd->searched_device =
3597 eina_list_remove_list(ugd->searched_device, l);
3598 _bt_util_free_device_item(item);
3602 if (ugd->searched_device == NULL ||
3603 eina_list_count(ugd->searched_device) == 0) {
3604 elm_object_item_del(ugd->searched_title);
3605 ugd->searched_title = NULL;
3611 void _bt_main_remove_all_searched_devices(bt_ug_data *ugd)
3615 bt_dev_t *dev = NULL;
3616 Eina_List *l = NULL;
3617 Eina_List *l_next = NULL;
3618 Elm_Object_Item *item;
3619 Elm_Object_Item *next;
3621 ret_if(ugd == NULL);
3623 if (ugd->searched_title) {
3624 item = elm_genlist_item_next_get(ugd->searched_title);
3625 elm_object_item_del(ugd->searched_title);
3626 ugd->searched_title = NULL;
3628 while (item != NULL) {
3629 next = elm_genlist_item_next_get(item);
3630 elm_object_item_del(item);
3633 ugd->no_device_item = NULL;
3636 EINA_LIST_FOREACH_SAFE(ugd->searched_device, l, l_next, dev) {
3637 ugd->searched_device =
3638 eina_list_remove_list(ugd->searched_device, l);
3639 _bt_util_free_device_item(dev);
3642 ugd->searched_device = NULL;
3648 void _bt_main_connect_device(bt_ug_data *ugd, bt_dev_t *dev)
3652 int headset_type = BT_AUDIO_PROFILE_TYPE_ALL;
3654 int hfp_restricted = 0x0;
3655 int a2dp_restricted = 0x0;
3657 ret_if(ugd == NULL);
3658 ret_if(dev == NULL);
3660 #ifdef TIZEN_BT_A2DP_SINK_ENABLE
3661 if (dev->service_list & BT_SC_A2DP_SOURCE_SERVICE_MASK) {
3662 if (bt_audio_connect(dev->addr_str,
3663 BT_AUDIO_PROFILE_TYPE_A2DP_SINK) == BT_ERROR_NONE) {
3664 ugd->connect_req = TRUE;
3665 dev->status = BT_CONNECTING;
3667 BT_ERR("Fail to connect BT_AUDIO_PROFILE_TYPE_A2DP_SINK");
3670 #ifndef TELEPHONY_DISABLED
3671 if ((dev->service_list & BT_SC_HFP_SERVICE_MASK) ||
3672 (dev->service_list & BT_SC_HSP_SERVICE_MASK)) {
3673 /* Connect the Headset */
3674 if (dev->service_list & BT_SC_A2DP_SERVICE_MASK)
3675 headset_type = BT_AUDIO_PROFILE_TYPE_ALL;
3677 headset_type = BT_AUDIO_PROFILE_TYPE_HSP_HFP;
3679 BT_INFO("Connection type = %d", headset_type);
3680 if (headset_type == BT_AUDIO_PROFILE_TYPE_ALL) {
3681 /* restriction check */
3682 bt_device_get_profile_restricted(dev->addr_str, BT_RESTRICTED_PROFILE_HFP_HS, &hfp_restricted);
3683 bt_device_get_profile_restricted(dev->addr_str, BT_RESTRICTED_PROFILE_A2DP, &a2dp_restricted);
3684 BT_INFO("Restricted Connection, HFP:%d, A2DP:%d", hfp_restricted, a2dp_restricted);
3686 if ((hfp_restricted == 0x1) && (a2dp_restricted == 0x1)) {
3687 ret = bt_device_set_profile_restricted(dev->addr_str, BT_RESTRICTED_PROFILE_HFP_HS, 0x0);
3688 if (ret != BT_ERROR_NONE)
3689 BT_ERR("Fail to set profile restriction");
3691 ret = bt_device_set_profile_restricted(dev->addr_str, BT_RESTRICTED_PROFILE_A2DP, 0x0);
3692 if (ret != BT_ERROR_NONE)
3693 BT_ERR("Fail to set profile restriction");
3697 if (bt_audio_connect(dev->addr_str,
3698 headset_type) == BT_ERROR_NONE) {
3699 ugd->connect_req = TRUE;
3700 dev->status = BT_CONNECTING;
3702 BT_ERR("Fail to connect Headset device");
3704 } else if (dev->service_list & BT_SC_A2DP_SERVICE_MASK) {
3706 if (dev->service_list & BT_SC_A2DP_SERVICE_MASK) {
3709 if (bt_audio_connect(dev->addr_str,
3710 BT_AUDIO_PROFILE_TYPE_A2DP) ==
3712 ugd->connect_req = TRUE;
3713 dev->status = BT_CONNECTING;
3715 BT_ERR("Fail to connect Headset device");
3717 } else if (dev->service_list & BT_SC_HID_SERVICE_MASK) {
3719 BT_INFO("HID connect request");
3721 if (bt_hid_host_connect(dev->addr_str) == BT_ERROR_NONE) {
3722 ugd->connect_req = TRUE;
3723 dev->status = BT_CONNECTING;
3725 BT_ERR("Fail to connect HID device");
3728 } else if (dev->service_list & BT_SC_NAP_SERVICE_MASK) {
3730 if (dev->net_profile) {
3731 if (_bt_connect_net_profile(ugd->connection,
3733 dev) == BT_UG_ERROR_NONE) {
3734 ugd->connect_req = TRUE;
3735 dev->status = BT_CONNECTING;
3737 BT_ERR("Fail to connect the net profile");
3740 net_profile = _bt_get_registered_net_profile(ugd->connection,
3743 _bt_set_profile_state_changed_cb(net_profile,
3745 if (_bt_connect_net_profile(ugd->connection,
3747 dev) == BT_UG_ERROR_NONE) {
3748 ugd->connect_req = TRUE;
3749 dev->status = BT_CONNECTING;
3751 BT_ERR("Fail to connect the net profile");
3755 } else if (TIZEN_FEATURE_BT_HOG && (dev->is_le_device) && (ugd->connect_req == FALSE)) {
3756 if (bt_gatt_connect(dev->addr_str, false) == BT_ERROR_NONE) {
3757 ugd->connect_req = TRUE;
3758 dev->status = BT_CONNECTING;
3760 BT_ERR("Fail to connect le device");
3764 _bt_update_genlist_item((Elm_Object_Item *) dev->genlist_item);
3769 void _bt_main_disconnect_device(bt_ug_data *ugd, bt_dev_t *dev)
3773 ret_if(ugd == NULL);
3774 ret_if(dev == NULL);
3776 #ifndef TELEPHONY_DISABLED
3777 if (_bt_util_is_profile_connected(BT_HEADSET_CONNECTED,
3778 dev->bd_addr) == TRUE) {
3779 BT_INFO("Disconnecting AG service");
3780 if (bt_audio_disconnect(dev->addr_str,
3781 BT_AUDIO_PROFILE_TYPE_ALL) ==
3783 ugd->disconn_req = true;
3784 dev->status = BT_DISCONNECTING;
3786 BT_ERR("Fail to connect Headset device");
3788 } else if (_bt_util_is_profile_connected(BT_STEREO_HEADSET_CONNECTED,
3789 dev->bd_addr) == TRUE) {
3791 if (_bt_util_is_profile_connected(BT_STEREO_HEADSET_CONNECTED,
3792 dev->bd_addr) == TRUE) {
3794 BT_INFO("Disconnecting AV service");
3795 if (bt_audio_disconnect(dev->addr_str,
3796 BT_AUDIO_PROFILE_TYPE_A2DP) ==
3798 ugd->disconn_req = true;
3799 dev->status = BT_DISCONNECTING;
3801 BT_ERR("Fail to connect Headset device");
3803 #ifdef TIZEN_BT_A2DP_SINK_ENABLE
3804 } else if (_bt_util_is_profile_connected(BT_MUSIC_PLAYER_CONNECTED,
3805 dev->bd_addr) == TRUE) {
3806 BT_INFO("Disconnecting AV service");
3808 if (bt_audio_disconnect(dev->addr_str,
3809 BT_AUDIO_PROFILE_TYPE_A2DP_SINK) ==
3811 ugd->disconn_req = true;
3812 dev->status = BT_DISCONNECTING;
3814 BT_ERR("Fail to connect Headset device");
3817 } else if (_bt_util_is_profile_connected(BT_HID_CONNECTED,
3818 dev->bd_addr) == TRUE) {
3819 BT_INFO("Disconnecting HID service!!");
3821 if (bt_hid_host_disconnect(dev->addr_str) == BT_ERROR_NONE)
3822 dev->status = BT_DISCONNECTING;
3824 BT_ERR("Fail to disconnect HID device");
3827 } else if (_bt_util_is_profile_connected(BT_NETWORK_SERVER_CONNECTED,
3828 dev->bd_addr) == TRUE) {
3829 /* Need to check NAP server */
3830 if (bt_nap_disconnect(dev->addr_str) == BT_UG_ERROR_NONE) {
3831 ugd->connect_req = true;
3832 dev->status = BT_DISCONNECTING;
3834 BT_ERR("Failed to disconnect pan server");
3836 } else if (TIZEN_FEATURE_BT_HOG && dev->is_le_device) {
3837 if (bt_gatt_disconnect(dev->addr_str) == BT_UG_ERROR_NONE) {
3838 ugd->connect_req = true;
3839 dev->status = BT_DISCONNECTING;
3841 BT_ERR("Failed to disconnect gatt");
3845 gboolean connected = FALSE;
3847 connected = _bt_util_is_profile_connected(BT_NETWORK_CONNECTED,
3850 if (dev->net_profile) {
3851 if (_bt_disconnect_net_profile(ugd->connection,
3852 dev->net_profile, dev) ==
3854 ugd->connect_req = true;
3855 dev->status = BT_DISCONNECTING;
3857 BT_ERR("Fail to disconnect the net profile");
3861 _bt_get_registered_net_profile(
3865 if (_bt_disconnect_net_profile(
3867 net_profile, dev) ==
3869 ugd->connect_req = true;
3870 dev->status = BT_DISCONNECTING;
3872 BT_ERR("Fail to disconnect the net profile");
3879 _bt_update_genlist_item((Elm_Object_Item *) dev->genlist_item);
3884 int _bt_main_request_connect_with_effect(bt_ug_data *ugd,
3885 Elm_Object_Item *seleted_item)
3891 retvm_if(ugd == NULL, BT_UG_FAIL, "Invalid argument: ugd is NULL");
3892 retvm_if(seleted_item == NULL, BT_UG_FAIL,
3893 "Invalid argument: object is NULL");
3895 dev = _bt_main_get_dev_info(ugd->searched_device, seleted_item);
3896 retvm_if(dev == NULL, BT_UG_FAIL, "Invalid argument: dev is NULL");
3898 if (bt_gatt_connect(dev->addr_str, false) == BT_ERROR_NONE) {
3899 dev->status = BT_DEV_PAIRING;
3900 ugd->op_status = BT_PAIRING;
3901 ugd->connect_req = TRUE;
3903 elm_object_disabled_set(ugd->scan_btn, EINA_TRUE);
3904 _bt_update_genlist_item(seleted_item);
3910 return BT_UG_ERROR_NONE;
3913 int _bt_main_request_pairing_with_effect(bt_ug_data *ugd,
3914 Elm_Object_Item *seleted_item)
3920 retvm_if(ugd == NULL, BT_UG_FAIL, "Invalid argument: ugd is NULL");
3921 retvm_if(seleted_item == NULL, BT_UG_FAIL,
3922 "Invalid argument: object is NULL");
3924 dev = _bt_main_get_dev_info(ugd->searched_device, seleted_item);
3925 retvm_if(dev == NULL, BT_UG_FAIL, "Invalid argument: dev is NULL");
3927 if (bt_device_create_bond(dev->addr_str) == BT_ERROR_NONE) {
3928 dev->status = BT_DEV_PAIRING;
3929 ugd->op_status = BT_PAIRING;
3931 elm_object_disabled_set(ugd->scan_btn, EINA_TRUE);
3932 _bt_update_genlist_item(seleted_item);
3938 return BT_UG_ERROR_NONE;
3941 void __bt_main_parse_service(bt_ug_data *ugd, app_control_h service)
3943 char *uri_scheme = NULL;;
3944 char *body_text = NULL;
3945 char *launch_type = NULL;
3946 char *operation = NULL;
3948 const char *uri = NULL;
3949 const char *file_path = NULL;
3951 if (TIZEN_PROFILE_TV)
3954 ret_if(ugd == NULL);
3955 ret_if(service == NULL);
3957 if (app_control_get_operation(service, &operation) < 0)
3958 BT_ERR("Get operation error");
3960 BT_INFO("operation: %s", operation);
3962 if (g_strcmp0(operation, APP_CONTROL_OPERATION_SHARE) == 0) {
3965 launch_type = strdup("send");
3967 app_control_get_mime(service, &mime);
3969 if (mime && strcmp(mime, APP_CONTROL_MIME_CONTACT) == 0) {
3970 char *id_str = NULL;
3971 app_control_get_extra_data(service, APP_CONTROL_DATA_ID, &id_str);
3974 bool my_profile = false;
3975 char *data_type = NULL;
3976 int id = atoi(id_str);
3978 app_control_get_extra_data(service, APP_CONTROL_DATA_TYPE, &data_type);
3979 my_profile = data_type && strcmp(data_type, APP_CONTROL_MY_PROFILE_DATA_TYPE) == 0;
3980 file_path = _bt_util_vcard_create_from_id(id, my_profile,
3981 BT_VCF_FOLDER_PATH);
3984 DBG_SECURE("file path: %s", file_path);
3986 if (app_control_add_extra_data(service, "type", "file") < 0)
3987 BT_ERR("Fail to add extra data");
3989 if (app_control_add_extra_data_array
3990 (service, "files", &file_path, 1) < 0)
3991 BT_ERR("Fail to add extra data");
3998 if (app_control_get_uri(service, (char **)&uri) < 0)
3999 BT_ERR("Get uri error");
4002 uri_scheme = g_uri_parse_scheme(uri);
4003 DBG_SECURE("uri_scheme: %s", uri_scheme);
4005 if (uri_scheme == NULL) {
4007 file_path = g_filename_from_uri(uri, NULL, NULL);
4008 if (app_control_add_extra_data(service, "type", "file") < 0)
4009 BT_ERR("Fail to add extra data");
4010 } else if (g_strcmp0(uri_scheme, "file") == 0) {
4012 file_path = g_filename_from_uri(uri, NULL, NULL);
4013 if (file_path == NULL)
4014 file_path = strdup(uri + 7); /* file:// */
4016 if (app_control_add_extra_data(service, "type", "file") < 0)
4017 BT_ERR("Fail to add extra data");
4019 if (app_control_add_extra_data(service, "type", "text") < 0)
4020 BT_ERR("Fail to add extra data");
4023 if (file_path == NULL) {
4024 BT_ERR("Not include URI info");
4025 file_path = strdup(uri);
4032 BT_INFO("url is not set");
4033 if (app_control_get_extra_data(service,
4034 MULTI_SHARE_SERVICE_DATA_PATH, &value) < 0)
4035 BT_ERR("Fail to get extra data");
4038 file_path = g_strdup(value);
4041 DBG_SECURE("file_path: %s", file_path);
4043 if (app_control_add_extra_data(service, "type", "file") < 0)
4044 BT_ERR("Fail to add extra data");
4047 BT_ERR("Not include path info");
4052 if (app_control_add_extra_data_array
4053 (service, "files", &file_path, 1) < 0)
4054 BT_ERR("Fail to add extra data");
4058 } else if (g_strcmp0(operation, APP_CONTROL_OPERATION_SHARE_TEXT) == 0) {
4059 BT_DBG("APP_CONTROL_OPERATION_SHARE_TEXT");
4061 launch_type = strdup("send");
4063 if (app_control_get_uri(service, (char **)&uri) < 0)
4064 BT_ERR("Get uri error");
4067 if (app_control_get_extra_data(service,
4068 APP_CONTROL_DATA_TEXT,
4070 APP_CONTROL_ERROR_NONE) {
4071 BT_ERR("Get uri error");
4074 if (body_text == NULL) {
4077 file_path = g_strdup(body_text);
4081 file_path = g_strdup(uri);
4084 if (file_path == NULL) {
4085 BT_ERR("file path is NULL");
4089 if (app_control_add_extra_data(service, "type", "text") < 0)
4090 BT_ERR("Fail to add extra data");
4092 if (app_control_add_extra_data_array
4093 (service, "files", &file_path, 1) < 0)
4094 BT_ERR("Fail to add extra data");
4096 } else if (g_strcmp0(operation, APP_CONTROL_OPERATION_MULTI_SHARE) == 0) {
4097 char **array_value = NULL;
4102 launch_type = strdup("send");
4104 int *id_list = NULL;
4105 char **person_id = NULL;
4106 int person_id_size = 0;
4107 bool cancel = false;
4109 app_control_get_mime(service, &mime);
4111 if (mime && !strcmp(mime, APP_CONTROL_MIME_CONTACT)) {
4112 if (app_control_get_extra_data_array(service, APP_CONTROL_DATA_ID,
4113 &person_id, &person_id_size) == APP_CONTROL_ERROR_NONE && person_id) {
4115 id_list = calloc(person_id_size, sizeof(int));
4117 for (i = 0; i < person_id_size; i++)
4118 id_list[i] = atoi(person_id[i]);
4120 file_path = _bt_util_vcard_create_from_id_list(id_list,
4121 person_id_size, BT_VCF_FOLDER_PATH, &cancel);
4123 DBG_SECURE("file path: %s", file_path);
4125 if (app_control_add_extra_data(service, "type", "file") < 0)
4126 BT_ERR("Fail to add extra data");
4128 if (app_control_add_extra_data_array
4129 (service, "files", &file_path, 1) < 0)
4130 BT_ERR("Fail to add extra data");
4137 ret = app_control_get_extra_data_array(service,
4138 MULTI_SHARE_SERVICE_DATA_PATH,
4139 &array_value, &array_length);
4140 if (ret != APP_CONTROL_ERROR_NONE) {
4141 BT_ERR("Get data error");
4143 for (i = 0; i < array_length; i++) {
4145 free(array_value[i]);
4152 if (app_control_add_extra_data_array
4153 (service, "files", (const char **)array_value,
4155 BT_ERR("Fail to add extra data");
4157 if (app_control_add_extra_data(service, "type", "file") < 0)
4158 BT_ERR("Fail to add extra data");
4160 for (i = 0; i < array_length; i++) {
4162 free(array_value[i]);
4169 } else if (g_strcmp0(operation, BT_APPCONTROL_PICK_OPERATION) == 0) {
4170 BT_DBG("Pick Operation");
4171 launch_type = strdup("pick");
4172 } else if (g_strcmp0(operation, BT_APPCONTROL_VISIBILITY_OPERATION) == 0 ||
4173 g_strcmp0(operation, APP_CONTROL_OPERATION_SETTING_BT_VISIBILITY) == 0) {
4174 BT_DBG("Visibility Operation");
4175 launch_type = strdup("visibility");
4176 } else if (g_strcmp0(operation, BT_APPCONTROL_ONOFF_OPERATION) == 0 ||
4177 g_strcmp0(operation, APP_CONTROL_OPERATION_SETTING_BT_ENABLE) == 0) {
4178 BT_DBG("onoff Operation");
4179 launch_type = strdup("onoff");
4180 } else if (g_strcmp0(operation, APP_CONTROL_OPERATION_SHARE_CONTACT) == 0) {
4181 BT_DBG("Share Contact Operation");
4182 launch_type = strdup("contact");
4183 } else if (g_strcmp0(operation, BT_APPCONTROL_EDIT_OPERATION) == 0) {
4184 BT_DBG("Edit Operation");
4185 if (app_control_get_mime(service, &mime) < 0)
4186 BT_ERR("Get mime error");
4187 if (g_strcmp0(mime, BT_APPCONTROL_ONOFF_MIME) == 0)
4188 launch_type = strdup("onoff");
4189 else if (g_strcmp0(mime, BT_APPCONTROL_VISIBILITY_MIME) == 0)
4190 launch_type = strdup("visibility");
4191 } else if (app_control_get_extra_data(service, "launch-type",
4192 &launch_type) == APP_CONTROL_ERROR_NONE) {
4193 if (g_strcmp0(launch_type, "call") != 0) {
4194 BT_DBG("launch-type : except call");
4195 if (app_control_add_extra_data(service, "type", "file") < 0)
4196 BT_ERR("Fail to add extra data");
4198 BT_DBG("launch-type : call");
4200 } else if (app_control_get_uri(service, (char **)&uri) == APP_CONTROL_ERROR_NONE &&
4201 g_strcmp0(uri, HELP_SETUP_BLUETOOTH_URI) == 0) {
4202 BT_DBG("Help mode");
4203 launch_type = strdup("help");
4208 BT_INFO("Launch with launch type [%s]", launch_type);
4209 _bt_util_set_value(launch_type, &ugd->search_type,
4210 &ugd->bt_launch_mode);
4212 BT_DBG("launch type is NULL");
4219 free((void *)file_path);
4222 free((void *)launch_type);
4231 void _bt_main_init_status(bt_ug_data *ugd, void *data)
4235 app_control_h service = NULL;
4237 bool status = false;
4238 bt_adapter_state_e bt_state = BT_ADAPTER_DISABLED;
4239 ret_if(ugd == NULL);
4243 if (service != NULL) {
4244 __bt_main_parse_service(ugd, service);
4246 ugd->search_type = MISCELLANEOUS_MAJOR_DEVICE_MASK;
4247 ugd->bt_launch_mode = BT_LAUNCH_NORMAL;
4250 /* currently this is the workaround for relaunching bt-ug by s-finder.
4251 bt-ug is not properly working because of the previous initialization.
4252 If there was no bt-ug then this deinit code doesn't affect at all.*/
4255 if (bt_initialize() != BT_ERROR_NONE)
4256 BT_ERR("bt_initialize() failed");
4258 ret = _bt_util_create_dpm_context(ugd);
4259 if (ret != BT_UG_ERROR_NONE)
4260 BT_ERR("_bt_util_create_dpm_context failed: %d", ret);
4262 if (bt_adapter_get_state(&bt_state) != BT_ERROR_NONE)
4263 BT_ERR("bt_adapter_get_state() failed");
4265 if (bt_state == BT_ADAPTER_DISABLED) {
4266 ugd->op_status = BT_DEACTIVATED;
4268 if (bt_adapter_is_discovering(&status) != BT_ERROR_NONE)
4269 BT_ERR("bt_adapter_is_discovering() failed");
4272 bt_adapter_stop_device_discovery();
4274 ugd->op_status = BT_ACTIVATED;
4280 bt_dev_t *_bt_main_create_paired_device_item(void *data)
4285 unsigned char bd_addr[BT_ADDRESS_LENGTH_MAX];
4286 bt_dev_t *dev = NULL;
4287 bt_device_info_s *dev_info = NULL;
4289 retv_if(data == NULL, NULL);
4291 dev_info = (bt_device_info_s *)data;
4293 retv_if(!dev_info->remote_name || strlen(dev_info->remote_name) == 0, NULL);
4294 retv_if(!dev_info->remote_address || strlen(dev_info->remote_address) == 0, NULL);
4296 dev = malloc(sizeof(bt_dev_t));
4297 retv_if(dev == NULL, NULL);
4299 memset(dev, 0, sizeof(bt_dev_t));
4300 g_strlcpy(dev->name, dev_info->remote_name,
4301 DEVICE_NAME_MAX_LEN + 1);
4303 dev->major_class = dev_info->bt_class.major_device_class;
4304 dev->minor_class = dev_info->bt_class.minor_device_class;
4305 dev->service_class = dev_info->bt_class.major_service_class_mask;
4307 if (dev_info->service_uuid != NULL && dev_info->service_count > 0) {
4308 dev->uuids = g_new0(char *, dev_info->service_count + 1);
4310 for (i = 0; i < dev_info->service_count; i++)
4311 dev->uuids[i] = g_strdup(dev_info->service_uuid[i]);
4313 dev->uuid_count = dev_info->service_count;
4316 _bt_util_addr_string_to_addr_type(bd_addr, dev_info->remote_address);
4318 memcpy(dev->addr_str, dev_info->remote_address, BT_ADDRESS_STR_LEN);
4320 memcpy(dev->bd_addr, bd_addr, BT_ADDRESS_LENGTH_MAX);
4322 bt_device_get_service_mask_from_uuid_list(dev_info->service_uuid,
4323 dev_info->service_count,
4324 &dev->service_list);
4326 BT_DBG("device name [%s]", dev->name);
4327 BT_DBG("device major class [%x]", dev->major_class);
4328 BT_DBG("device minor class [%x]", dev->minor_class);
4329 BT_DBG("device service class [%x]", dev->service_class);
4330 BT_DBG("device service list %x", dev->service_list);
4331 BT_DBG("%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X", dev->bd_addr[0],
4332 dev->bd_addr[1], dev->bd_addr[2], dev->bd_addr[3],
4333 dev->bd_addr[4], dev->bd_addr[5]);
4335 if (dev->major_class == BT_MAJOR_DEV_CLS_MISC &&
4336 dev->service_list != BT_SC_NONE) {
4337 _bt_util_update_class_of_device_by_service_list(dev->service_list,
4338 &dev->major_class, &dev->minor_class);
4341 /* TODO : modify for checking LE device */
4342 if (TIZEN_FEATURE_BT_HOG && (dev->major_class == 0) && (dev->minor_class == 0)) {
4343 BT_DBG("there are no major and minor class");
4344 dev->is_le_device = TRUE;
4351 bt_dev_t *_bt_main_create_searched_device_item(void *data)
4356 unsigned char bd_addr[BT_ADDRESS_LENGTH_MAX];
4357 bt_dev_t *dev = NULL;
4358 bt_adapter_device_discovery_info_s *dev_info = NULL;
4360 retv_if(data == NULL, NULL);
4362 dev_info = (bt_adapter_device_discovery_info_s *) data;
4364 if (strlen(dev_info->remote_name) == 0)
4367 dev = calloc(1, sizeof(bt_dev_t));
4368 retv_if(dev == NULL, NULL);
4370 strncpy(dev->name, dev_info->remote_name, DEVICE_NAME_MAX_LEN);
4372 dev->major_class = dev_info->bt_class.major_device_class;
4373 dev->minor_class = dev_info->bt_class.minor_device_class;
4374 dev->service_class = dev_info->bt_class.major_service_class_mask;
4375 dev->rssi = dev_info->rssi;
4376 if (TIZEN_FEATURE_BT_HOG)
4377 dev->is_le_device = FALSE;
4379 if (dev_info->service_uuid != NULL && dev_info->service_count > 0) {
4380 dev->uuids = g_new0(char *, dev_info->service_count + 1);
4382 for (i = 0; i < dev_info->service_count; i++)
4383 dev->uuids[i] = g_strdup(dev_info->service_uuid[i]);
4385 dev->uuid_count = dev_info->service_count;
4388 _bt_util_addr_string_to_addr_type(bd_addr, dev_info->remote_address);
4390 memcpy(dev->addr_str, dev_info->remote_address, BT_ADDRESS_STR_LEN);
4392 memcpy(dev->bd_addr, bd_addr, BT_ADDRESS_LENGTH_MAX);
4394 BT_DBG("device name [%s]", dev->name);
4395 BT_DBG("device major class [%x]", dev->major_class);
4396 BT_DBG("device minor class [%x]", dev->minor_class);
4397 BT_DBG("device service class [%x]", dev->service_class);
4398 BT_DBG("%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X", dev->bd_addr[0],
4399 dev->bd_addr[1], dev->bd_addr[2], dev->bd_addr[3],
4400 dev->bd_addr[4], dev->bd_addr[5]);
4405 static gboolean _bt_check_minor_class(unsigned int minor_class)
4407 switch (minor_class) {
4408 case BTAPP_MIN_DEV_CLS_VIDEO_DISPLAY_AND_LOUD_SPEAKER:
4410 case BTAPP_MIN_DEV_CLS_VIDEO_CONFERENCING:
4412 case BTAPP_MIN_DEV_CLS_VIDEO_CAMERA:
4414 case BTAPP_MIN_DEV_CLS_SET_TOP_BOX:
4416 case BTAPP_MIN_DEV_CLS_VCR:
4418 case BTAPP_MIN_DEV_CLS_CAM_CORDER:
4425 gboolean _bt_main_is_matched_profile(unsigned int search_type,
4426 unsigned int major_class,
4427 unsigned int service_class,
4428 app_control_h service,
4429 unsigned int minor_class)
4433 bt_device_major_mask_t major_mask = BT_DEVICE_MAJOR_MASK_MISC;
4436 /* P141010-03829 : Kiran doesn't support HID device */
4437 BT_DBG("Kiran doesn't support HID device");
4438 retv_if(major_class == BT_MAJOR_DEV_CLS_PERIPHERAL, FALSE);
4441 if (search_type == 0x000000)
4444 BT_INFO("search_type: %x", search_type);
4445 BT_INFO("service_class: %x", service_class);
4447 /* Check the service_class */
4448 if (service_class & search_type) {
4449 if (search_type & OBJECT_TRANSFER_MAJOR_SERVICE_MASK &&
4450 major_class == BT_MAJOR_DEV_CLS_IMAGING) {
4451 if (__bt_main_is_image_file(service))
4457 BT_INFO("major_class %x", major_class);
4458 BT_INFO("minor_class %x", minor_class);
4459 /* Check the major class */
4460 switch (major_class) {
4461 case BT_MAJOR_DEV_CLS_COMPUTER:
4462 major_mask = BT_DEVICE_MAJOR_MASK_COMPUTER;
4464 case BT_MAJOR_DEV_CLS_PHONE:
4465 major_mask = BT_DEVICE_MAJOR_MASK_PHONE;
4467 case BT_MAJOR_DEV_CLS_LAN_ACCESS_POINT:
4468 major_mask = BT_DEVICE_MAJOR_MASK_LAN_ACCESS_POINT;
4470 case BT_MAJOR_DEV_CLS_AUDIO:
4471 if (_bt_check_minor_class(minor_class) == TRUE)
4472 major_mask = BT_DEVICE_MAJOR_MASK_AUDIO;
4474 major_mask = BT_DEVICE_MAJOR_MASK_MISC;
4476 case BT_MAJOR_DEV_CLS_IMAGING:
4477 major_mask = BT_DEVICE_MAJOR_MASK_IMAGING;
4479 case BT_MAJOR_DEV_CLS_WEARABLE:
4480 major_mask = BT_DEVICE_MAJOR_MASK_WEARABLE;
4482 case BT_MAJOR_DEV_CLS_TOY:
4483 major_mask = BT_DEVICE_MAJOR_MASK_TOY;
4485 case BT_MAJOR_DEV_CLS_HEALTH:
4486 major_mask = BT_DEVICE_MAJOR_MASK_HEALTH;
4488 case BT_MAJOR_DEV_CLS_PERIPHERAL:
4490 major_mask = BT_DEVICE_MAJOR_MASK_PERIPHERAL;
4492 } /* If not, goto default */
4494 major_mask = BT_DEVICE_MAJOR_MASK_MISC;
4498 BT_INFO("major_mask: %x", major_mask);
4500 if (search_type & major_mask)
4507 bt_dev_t *_bt_main_get_dev_info(Eina_List *list,
4508 Elm_Object_Item *genlist_item)
4512 bt_dev_t *item = NULL;
4513 Eina_List *l = NULL;
4515 retvm_if(list == NULL, NULL, "Invalid argument: list is NULL");
4516 retvm_if(genlist_item == NULL, NULL, "Invalid argument: obj is NULL");
4518 EINA_LIST_FOREACH(list, l, item) {
4520 if (item->genlist_item == genlist_item)
4529 bt_dev_t *_bt_main_get_dev_info_by_address(Eina_List *list, char *address)
4533 bt_dev_t *item = NULL;
4534 Eina_List *l = NULL;
4536 retvm_if(list == NULL, NULL, "Invalid argument: list is NULL");
4537 retvm_if(address == NULL, NULL, "Invalid argument: addr is NULL");
4539 EINA_LIST_FOREACH(list, l, item) {
4541 if (memcmp(item->addr_str, address, BT_ADDRESS_STR_LEN)
4551 int _bt_main_check_and_update_device(Eina_List *list, char *addr, char *name)
4555 bt_dev_t *item = NULL;
4556 Eina_List *l = NULL;
4558 retv_if(list == NULL, -1);
4559 retv_if(addr == NULL, -1);
4560 retv_if(name == NULL, -1);
4562 EINA_LIST_FOREACH(list, l, item) {
4564 if (memcmp(item->addr_str, addr, BT_ADDRESS_STR_LEN) ==
4566 memset(item->name, 0x00,
4567 DEVICE_NAME_MAX_LEN+1);
4568 g_strlcpy(item->name, name,
4569 DEVICE_NAME_MAX_LEN);
4580 void _bt_main_launch_syspopup(void *data, char *event_type, char *title,
4586 bt_ug_data *ugd = NULL;
4589 ret_if(event_type == NULL);
4590 ret_if(type == NULL);
4592 ugd = (bt_ug_data *)data;
4594 b = bundle_create();
4598 bundle_add_str(b, "event-type", event_type);
4600 bundle_add_str(b, "title", title);
4602 bundle_add_str(b, "type", type);
4604 ret = syspopup_launch("bt-syspopup", b);
4606 BT_ERR("Popup launch failed...retry %d", ret);
4607 ugd->popup_bundle = b;
4609 g_timeout_add(BT_UG_SYSPOPUP_TIMEOUT_FOR_MULTIPLE_POPUPS,
4610 (GSourceFunc) __bt_main_system_popup_timer_cb,
4618 void _bt_main_create_information_popup(void *data, char *msg)
4621 ret_if(data == NULL);
4622 bt_ug_data *ugd = (bt_ug_data *)data;
4624 _bt_main_popup_del_cb(data, NULL, NULL);
4626 ugd->popup_data.type = BT_POPUP_LOW_BATTERY;
4627 ugd->popup = _bt_create_popup(ugd,
4628 _bt_main_popup_del_cb, ugd, 2);
4629 retm_if(!ugd->popup , "fail to create popup!");
4631 eext_object_event_callback_add(ugd->popup, EEXT_CALLBACK_BACK,
4632 _bt_main_popup_del_cb, ugd);
4634 evas_object_show(ugd->popup);
4638 #ifdef TIZEN_REDWOOD
4639 static gboolean __bt_main_close_help_popup_cb(gpointer data)
4642 retv_if(!data, FALSE);
4643 bt_ug_data *ugd = (bt_ug_data *)data;
4646 evas_object_del(ugd->popup);
4650 _bt_ug_destroy(data, NULL);
4657 void _bt_main_add_searched_title(bt_ug_data *ugd)
4660 Elm_Object_Item *git = NULL;
4662 git = elm_genlist_item_append(ugd->main_genlist,
4663 ugd->searched_title_itc,
4665 ELM_GENLIST_ITEM_NONE, NULL, NULL);
4667 elm_genlist_item_select_mode_set(git,
4668 ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
4669 ugd->searched_title = git;
4671 BT_ERR("fail to append genlist item!");
4677 void _bt_update_device_list(bt_ug_data *ugd)
4679 Eina_List *l = NULL;
4680 bt_dev_t *dev = NULL;
4682 ret_if(ugd == NULL);
4684 EINA_LIST_FOREACH(ugd->paired_device, l, dev) {
4686 _bt_update_genlist_item((Elm_Object_Item *)
4690 EINA_LIST_FOREACH(ugd->searched_device, l, dev) {
4692 _bt_update_genlist_item((Elm_Object_Item *)