BT_ERR("Fail to get the timeout value");
}
- if (timeout == BT_ALWAYS_ON) {
- ugd->visible = TRUE;
- ugd->remain_time = 0;
- ugd->visibility_timeout = timeout;
- ugd->selected_radio = _bt_util_get_timeout_index(timeout);
- }
+ _bt_util_change_discoverable_mode(ugd, TRUE);
_bt_util_set_phone_name();
if(!ugd->device_name_item)
_bt_main_add_device_name_item(ugd, ugd->main_genlist);
- if(!ugd->visible_item)
- _bt_main_add_visible_item(ugd, ugd->main_genlist);
-
if (ugd->empty_status_item) {
elm_object_item_del(ugd->empty_status_item);
ugd->empty_status_item = NULL;
}
- _bt_update_genlist_item(ugd->visible_item);
-
if (ugd->bt_launch_mode == BT_LAUNCH_ONOFF) {
g_idle_add((GSourceFunc) _bt_idle_destroy_ug, ugd);
return;
ugd->popup = NULL;
}
- if (ugd->visibility_popup) {
- evas_object_del(ugd->visibility_popup);
- ugd->visibility_popup = NULL;
- }
-
if (ugd->rename_popup) {
evas_object_del(ugd->rename_popup);
ugd->rename_popup = NULL;
}
ugd->op_status = BT_DEACTIVATED;
- ugd->visible = FALSE;
- ugd->remain_time = 0;
-
- if (ugd->visibility_timeout != BT_ALWAYS_ON) {
- ugd->visibility_timeout = 0;
- ugd->selected_radio = 1;
- }
evas_object_del(ugd->scan_btn);
ugd->scan_btn = NULL;
elm_genlist_item_item_class_update(ugd->onoff_item,
ugd->off_itc);
- if (ugd->visible_item && EINA_TRUE == elm_genlist_item_expanded_get(
- ugd->visible_item)) {
- elm_genlist_item_expanded_set(ugd->visible_item,
- EINA_FALSE);
- }
-
- if(ugd->visible_item) {
- elm_object_item_del(ugd->visible_item);
- ugd->visible_item = NULL;
- }
-
if(ugd->device_name_item) {
elm_object_item_del(ugd->device_name_item);
ugd->device_name_item = NULL;
}
_bt_update_genlist_item(ugd->onoff_item);
- _bt_update_genlist_item(ugd->visible_item);
_bt_update_genlist_item(ugd->paired_title);
_bt_update_genlist_item(ugd->searched_title);
FN_END;
}
-static gboolean __bt_cb_visible_timeout_cb(gpointer user_data)
-{
- FN_START;
-
- bt_ug_data *ugd = NULL;
- time_t current_time;
- int time_diff;
-
- ugd = (bt_ug_data *)user_data;
- /* Get the current time */
- time(¤t_time);
-
- /* Calculate time elapsed from remain_time */
- time_diff = difftime(current_time, ugd->start_time);
- BT_DBG("Time difference in seconds %d", time_diff);
-
- /* Update UI */
- if (ugd->remain_time <= time_diff) {
- g_source_remove(ugd->timeout_id);
- ugd->timeout_id = 0;
- ugd->visibility_timeout = 0;
- ugd->remain_time = 0;
- ugd->selected_radio = 1;
-
- elm_genlist_realized_items_update(ugd->main_genlist);
-
- return FALSE;
- }
-
- elm_genlist_item_fields_update(ugd->visible_item, "elm.text.multiline",
- ELM_GENLIST_ITEM_FIELD_TEXT);
-
- FN_END;
- return TRUE;
-}
-
static void __bt_retry_pairing_cb(void *data,
Evas_Object *obj, void *event_info)
{
(int result, bt_adapter_visibility_mode_e visibility_mode, void *user_data)
{
FN_START;
+ bt_ug_data *ugd = NULL;
- ret_if(user_data == NULL);
- bt_ug_data *ugd = (bt_ug_data *)user_data;
- bt_adapter_state_e bt_state = BT_ADAPTER_DISABLED;
- bt_adapter_visibility_mode_e mode =
- BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE;
- int remain_time = 0;
- int ret = 0;
-
- if(ugd->visibility_changed_by_ug) {
- ugd->visibility_changed_by_ug = FALSE;
- FN_END;
- return;
- }
-BT_DBG("");
- if (bt_adapter_get_state(&bt_state) != BT_ERROR_NONE) {
- BT_ERR("bt_adapter_get_state() failed.");
- return;
- }
-
- if (bt_state != BT_ADAPTER_DISABLED) {
- if (bt_adapter_get_visibility(&mode, &remain_time) !=
- BT_ERROR_NONE) {
- BT_ERR("bt_adapter_get_visibility() failed.");
- return;
- }
- }
-
- if (visibility_mode == BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE) {
- ugd->visible = FALSE;
- ugd->visibility_timeout = 0;
- ugd->selected_radio = 1;
- } else if (visibility_mode == BT_ADAPTER_VISIBILITY_MODE_GENERAL_DISCOVERABLE) {
- ugd->visible = TRUE;
- ugd->visibility_timeout = -1;
- ugd->selected_radio = 5;
- } else {
- /* BT_ADAPTER_VISIBILITY_MODE_LIMITED_DISCOVERABLE */
- /* Need to add the code for getting timeout */
- ret = vconf_get_int(BT_FILE_VISIBLE_TIME, &ugd->visibility_timeout);
- if (ret != 0) {
- BT_ERR("Failt to get the timeout value");
- }
-BT_DBG("");
-
- ugd->remain_time = remain_time;
-
- if (ugd->remain_time > 0) {
-
- if (ugd->timeout_id) {
- g_source_remove(ugd->timeout_id);
- ugd->timeout_id = 0;
- }
- /* Set current time snapshot */
- time(&(ugd->start_time));
- ugd->timeout_id = g_timeout_add(BT_VISIBILITY_TIMEOUT,
- (GSourceFunc)
- __bt_cb_visible_timeout_cb,
- ugd);
- } else {
- ugd->visibility_timeout = 0;
- }
- }
-
-
- if(ugd->visible_item) {
- elm_genlist_item_fields_update(ugd->visible_item,
- "elm.text",
- ELM_GENLIST_ITEM_FIELD_TEXT);
- elm_genlist_item_fields_update(ugd->visible_item,
- "elm.text.multiline",
- ELM_GENLIST_ITEM_FIELD_TEXT);
+ ugd = (bt_ug_data *)user_data;
- elm_radio_value_set(ugd->radio_main, ugd->selected_radio);
+ if (visibility_mode == BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE &&
+ result == BT_ERROR_NONE &&
+ ugd->ug_status != BT_UG_PAUSE &&
+ ugd->ug_status != BT_UG_DESTORY) {
+ BT_DBG("visibility is turned off. turn on again!");
+ _bt_util_change_discoverable_mode(ugd, TRUE);
}
FN_END;
}
static app_control_h __bt_main_get_bt_onoff_result(bt_ug_data *ugd,
gboolean result);
-static app_control_h __bt_main_get_visibility_result(bt_ug_data *ugd,
- gboolean result);
-
static app_control_h __bt_main_get_pick_result(bt_ug_data *ugd, gboolean result);
static int __bt_main_request_to_send(bt_ug_data *ugd, bt_dev_t *dev);
return string;
}
-static char *__bt_main_visible_label_get(void *data, Evas_Object *obj,
- const char *part)
-{
- FN_START;
-
- char *buf = NULL;
- char *text1 = NULL;
- char *text2 = NULL;
- char remain_time[BT_EXTRA_STR_LEN] = { 0 };
- bt_ug_data *ugd = NULL;
-#ifdef KIRAN_ACCESSIBILITY
- Evas_Object *ao = NULL;
- Elm_Object_Item *item = NULL;
- char *text_visibility = NULL;
- Eina_Bool expanded = EINA_FALSE;
- char acc_str[BT_STR_ACCES_INFO_MAX_LEN] = { 0 };
- char formatted_time[BT_BUFFER_LEN] = { 0 };
-#endif
-
- int r = 0, g = 0, b = 0, a = 0;
-
- if (data == NULL)
- return NULL;
-
- ugd = (bt_ug_data *)data;
-
- BT_DBG("%s", part);
-
- if (!strcmp("elm.text", part)) {
- buf = g_strdup(BT_STR_VISIBLE);
- } else if (!strcmp("elm.text.multiline", part)) {
- char *color_code = NULL;
- if (ugd->visibility_timeout <= 0) {
- text1 = _bt_util_get_timeout_string(ugd->visibility_timeout);
-
- r = 20, g = 107, b = 147, a = 255;
- color_code = __bt_convert_rgba_to_hex(r, g, b, a);
-
- if (ugd->visibility_timeout == 0) {
- text2 = strdup(BT_STR_ONLY_VISIBLE_TO_PAIRED_DEVICES);
- } else {
- text2 = strdup(BT_STR_VISIBLE_TO_ALL_NEARBY);
- }
-
- buf = g_strdup_printf("<font_size=30><color=#%s>%s</color><br>%s</font_size>",
- color_code, text1, text2);
-
-#ifdef KIRAN_ACCESSIBILITY
- text_visibility = g_strdup_printf("<color=#%s>%s</color>",
- color_code, text1);
-#endif
- } else {
- time_t current_time;
- int time_diff;
- int minute;
- int second;
-
- /* Get the current time */
- time(¤t_time);
-
- /* Calculate time elapsed from remain_time */
- time_diff = difftime(current_time, ugd->start_time);
-
- /* Display remain timeout */
-#ifdef KIRAN_ACCESSIBILITY
- _bt_util_convert_time_to_string((ugd->remain_time -
- time_diff),
- remain_time, formatted_time,
- sizeof(remain_time), sizeof(formatted_time));
-#else
- _bt_util_convert_time_to_string((ugd->remain_time -
- time_diff),
- remain_time, NULL,
- sizeof(remain_time), 0);
-#endif
- /* Get seconds */
- second = (ugd->remain_time - time_diff) % 60;
- /* Get minutes */
- minute = (ugd->remain_time - time_diff) / 60;
-
- text1 = g_strdup_printf("%d:%02d", minute, second);
-
- r = 20, g = 107, b = 147, a = 255;
- color_code = __bt_convert_rgba_to_hex(r, g, b, a);
-
- text2 = strdup(BT_STR_VISIBLE_TO_ALL_NEARBY);
-
- buf = g_strdup_printf("<font_size=30><color=#%s>%s</color><br>%s</font_size>",
- color_code, text1, text2);
-
- BT_DBG("buf : %s, rgba:%d,%d,%d,%d", buf,r,g,b,a);
-
-#ifdef KIRAN_ACCESSIBILITY
- text_visibility = g_strdup_printf(BT_STR_PS_REMAINING,
- formatted_time);
-#endif
- }
- g_free(color_code);
-
-#ifdef KIRAN_ACCESSIBILITY
- item = ugd->visible_item;
- if (item != NULL) {
- expanded = elm_genlist_item_expanded_get(item);
-
- ao = elm_object_item_access_object_get(item);
- if (expanded == EINA_TRUE) {
- snprintf(acc_str, sizeof(acc_str), "%s, %s, %s", BT_STR_VISIBLE,
- text_visibility, BT_STR_EXP_LIST_CLOSE);
- } else {
- if (elm_object_item_disabled_get(item))
- snprintf(acc_str, sizeof(acc_str), "%s, %s, %s, %s",
- BT_STR_VISIBLE, text_visibility,
- BT_STR_EXP_LIST_OPEN, BT_STR_UNAVAILABLE);
- else
- snprintf(acc_str, sizeof(acc_str), "%s, %s, %s", BT_STR_VISIBLE,
- text_visibility, BT_STR_EXP_LIST_OPEN);
- }
-
- elm_access_info_set(ao, ELM_ACCESS_INFO, acc_str);
- }
-#endif
- } else {
- BT_ERR("empty text for label");
- return NULL;
- }
-
- g_free(text1);
- g_free(text2);
-#ifdef KIRAN_ACCESSIBILITY
- g_free(text_visibility);
-#endif
- FN_END;
- return buf;
-}
-
-static char *__bt_main_timeout_value_label_get(void *data, Evas_Object *obj,
- const char *part)
-{
- FN_START;
-
- char *buf = NULL;
- int timeout = 0;
- bt_radio_item *item = NULL;
-
- retv_if(data == NULL, NULL);
-
- item = (bt_radio_item *)data;
- retv_if(item->ugd == NULL, NULL);
-
- if (!strcmp("elm.text", part)) {
- timeout = _bt_util_get_timeout_value(item->index);
- buf = _bt_util_get_timeout_string(timeout);
- } else {
- BT_ERR("empty text for label");
- return NULL;
- }
-
- FN_END;
- return buf;
-}
-
int _bt_idle_destroy_ug(void *data)
{
FN_START;
retv_if(ugd == NULL, BT_UG_FAIL);
- if (ugd->bt_launch_mode == BT_LAUNCH_VISIBILITY)
- service = __bt_main_get_visibility_result(ugd, TRUE);
- else if (ugd->bt_launch_mode == BT_LAUNCH_PICK)
+ if (ugd->bt_launch_mode == BT_LAUNCH_PICK)
service = __bt_main_get_pick_result(ugd, TRUE);
else if (ugd->bt_launch_mode == BT_LAUNCH_ONOFF)
service = __bt_main_get_bt_onoff_result(ugd, TRUE);
return BT_UG_ERROR_NONE;
}
-static gboolean __bt_main_visible_timeout_cb(gpointer user_data)
-{
- FN_START;
-
- bt_ug_data *ugd = NULL;
- time_t current_time;
- int time_diff;
-
- ugd = (bt_ug_data *)user_data;
- /* Get the current time */
- time(¤t_time);
-
- /* Calculate time elapsed from remain_time */
- time_diff = difftime(current_time, ugd->start_time);
- BT_INFO("Time difference in seconds %d", time_diff);
-
- /* Update UI */
- if (ugd->remain_time <= time_diff) {
- g_source_remove(ugd->timeout_id);
- ugd->timeout_id = 0;
- ugd->visibility_timeout = 0;
- ugd->remain_time = 0;
- ugd->selected_radio = 1;
-
- elm_genlist_realized_items_update(ugd->main_genlist);
-
- return FALSE;
- }
-
- elm_genlist_item_fields_update(ugd->visible_item, "elm.text.multiline",
- ELM_GENLIST_ITEM_FIELD_TEXT);
-
- FN_END;
- return TRUE;
-}
-
-static void __bt_update_visibility_menu(bt_radio_item *item)
-{
- FN_START;
- bt_ug_data *ugd = NULL;
- int ret;
- int timeout;
-
- ret_if(item == NULL);
-
- ugd = (bt_ug_data *)item->ugd;
- ret_if(item->ugd == NULL);
-
- timeout = _bt_util_get_timeout_value(item->index);
-
- if (timeout < 0) {
- ret = bt_adapter_set_visibility(BT_ADAPTER_VISIBILITY_MODE_GENERAL_DISCOVERABLE, 0);
-
- if (ugd->timeout_id) {
- g_source_remove(ugd->timeout_id);
- ugd->timeout_id = 0;
- }
- } else if (timeout == 0) {
- ret = bt_adapter_set_visibility(BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE,
- 0);
- if (ugd->timeout_id) {
- g_source_remove(ugd->timeout_id);
- ugd->timeout_id = 0;
- }
- } else {
- ret = bt_adapter_set_visibility(BT_ADAPTER_VISIBILITY_MODE_LIMITED_DISCOVERABLE,
- timeout);
-
- if (ret == BT_ERROR_NONE) {
- if (ugd->timeout_id) {
- g_source_remove(ugd->timeout_id);
- ugd->timeout_id = 0;
- }
- /* Set current time snapshot */
- time(&(ugd->start_time));
- ugd->remain_time = timeout;
- ugd->timeout_id = g_timeout_add(BT_VISIBILITY_TIMEOUT,
- (GSourceFunc)
- __bt_main_visible_timeout_cb,
- ugd);
- }
- }
-
- if (ret != BT_ERROR_NONE) {
- BT_ERR("bt_adapter_set_visibility() failed");
- return;
- }
-
- ugd->selected_radio = item->index;
- ugd->visibility_timeout = timeout;
-
- _bt_update_genlist_item(ugd->visible_item);
- elm_radio_value_set(ugd->radio_main, ugd->selected_radio);
-
- if (ugd->bt_launch_mode == BT_LAUNCH_VISIBILITY)
- g_idle_add((GSourceFunc) _bt_idle_destroy_ug, ugd);
-
- FN_END;
-}
-
-static void __bt_main_timeout_value_item_sel(void *data, Evas_Object *obj,
- void *event_info)
-{
- FN_START;
-
- bt_radio_item *item = NULL;
-
- ret_if(data == NULL);
-
- item = (bt_radio_item *)data;
-
- if(event_info)
- elm_genlist_item_selected_set((Elm_Object_Item *)event_info,
- EINA_FALSE);
-
- __bt_update_visibility_menu(item);
-
- bt_ug_data *ugd = (bt_ug_data *)item->ugd;
- if (ugd && ugd->visibility_popup) {
- evas_object_del(ugd->visibility_popup);
- ugd->visibility_popup = NULL;
- }
-
- FN_END;
- return;
-}
-
-static Evas_Object *__bt_main_timeout_value_icon_get(void *data,
- Evas_Object *obj,
- const char *part)
-{
- FN_START;
-
- bt_ug_data *ugd = NULL;
- bt_radio_item *item = NULL;
- Evas_Object *btn = NULL;
- retv_if(data == NULL, NULL);
-
- item = (bt_radio_item *)data;
- retv_if(item->ugd == NULL, NULL);
-
- ugd = (bt_ug_data *)item->ugd;
-
- if (!strcmp("elm.swallow.end", part)) {
- btn = elm_radio_add(obj);
- elm_radio_state_value_set(btn, item->index);
- elm_radio_group_add(btn, ugd->radio_main);
-
- elm_radio_value_set(ugd->radio_main, ugd->selected_radio);
-#ifdef KIRAN_ACCESSIBILITY
- elm_access_object_unregister(btn);
-#endif
- evas_object_size_hint_min_set(btn, ELM_SCALE_SIZE(30), ELM_SCALE_SIZE(30));
- evas_object_show(btn);
- }
- FN_END;
- return btn;
-}
-static void __bt_main_timeout_value_del(void *data, Evas_Object *obj)
-{
- FN_START;
-
- bt_radio_item *item = (bt_radio_item *)data;
- if (item)
- free(item);
-
- FN_END;
-}
-
gboolean _bt_main_is_connectable_device(bt_dev_t *dev)
{
FN_START;
return progressbar;
}
-static void __bt_popup_visibility_delete_cb(void *data, Evas_Object *obj, void *event_info)
-{
- bt_ug_data *ugd = (bt_ug_data *)data;
- ret_if(!ugd);
- if (ugd->visibility_popup) {
- evas_object_del(ugd->visibility_popup);
- ugd->visibility_popup = NULL;
- }
-}
-
-static void __bt_main_visible_item_sel(void *data, Evas_Object *obj,
- void *event_info)
-{
- FN_START;
-
- ret_if(data == NULL);
- ret_if(event_info == NULL);
-
- bt_ug_data *ugd = (bt_ug_data *)data;
- if(event_info)
- elm_genlist_item_selected_set((Elm_Object_Item *)event_info,
- EINA_FALSE);
-
- ugd->visibility_changed_by_ug = TRUE;
-
- Evas_Object *popup = NULL;
- Evas_Object *box = NULL;
- Evas_Object *genlist = NULL;
- Elm_Object_Item *git = NULL;
- bt_radio_item *item = NULL;
- int i = 0;
-
- popup = elm_popup_add(ugd->base);
- eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, __bt_popup_visibility_delete_cb, ugd);
- evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_smart_callback_add(popup, "block,clicked", __bt_popup_visibility_delete_cb, ugd);
-
- elm_object_part_text_set(popup, "title,text", BT_STR_VISIBLE);
-
- /* box */
- box = elm_box_add(popup);
- evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-
- /* genlist */
- genlist = elm_genlist_add(box);
- elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
- elm_genlist_homogeneous_set(genlist, EINA_FALSE);
- elm_genlist_block_count_set(genlist, 3);
- evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
-
- /* Set item class for timeout value */
- ugd->timeout_value_itc = elm_genlist_item_class_new();
- ret_if(ugd->timeout_value_itc == NULL);
- ugd->timeout_value_itc->item_style = BT_GENLIST_1LINE_TEXT_ICON_STYLE;
- ugd->timeout_value_itc->func.text_get =
- __bt_main_timeout_value_label_get;
- ugd->timeout_value_itc->func.content_get =
- __bt_main_timeout_value_icon_get;
- ugd->timeout_value_itc->func.state_get = NULL;
- ugd->timeout_value_itc->func.del = __bt_main_timeout_value_del;
-
- for (i = 1; i <= BT_MAX_TIMEOUT_ITEMS; i++) {
- item = calloc(1, sizeof(bt_radio_item));
- ret_if(item == NULL);
-
- item->index = i;
- item->ugd = ugd;
-
- git = elm_genlist_item_append(genlist, ugd->timeout_value_itc,
- (void *)item, NULL,
- ELM_GENLIST_ITEM_NONE,
- __bt_main_timeout_value_item_sel,
- (void *)item);
- if (!git)
- BT_DBG("git is NULL!");
- item->it = git;
- ugd->visible_exp_item[i] = git;
- }
-
- evas_object_show(genlist);
-
- elm_box_pack_end(box, genlist);
-
- evas_object_size_hint_min_set(box, ELM_SCALE_SIZE(100), ELM_SCALE_SIZE(240));
- elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
- elm_object_content_set(popup, box);
- evas_object_show(popup);
- ugd->visibility_popup = popup;
- FN_END;
-}
-
static app_control_h __bt_main_get_bt_onoff_result(bt_ug_data *ugd,
gboolean result)
{
return service;
}
-static app_control_h __bt_main_get_visibility_result(bt_ug_data *ugd,
- gboolean result)
-{
- app_control_h service = NULL;
- char mode_str[BT_RESULT_STR_MAX] = { 0 };
- const char *result_str;
- int visibility = BT_VISIBLE_OFF;
-
- retv_if(ugd == NULL, NULL);
-
- app_control_create(&service);
-
- retv_if(service == NULL, NULL);
-
- if (result == TRUE)
- result_str = BT_RESULT_SUCCESS;
- else
- result_str = BT_RESULT_FAIL;
-
- if (app_control_add_extra_data(service, "result", result_str) < 0) {
- BT_ERR("Fail to add extra data");
- }
-
- /* Original output fields will be removed */
- snprintf(mode_str, BT_RESULT_STR_MAX, "%d", (int)ugd->selected_radio);
-
- if (app_control_add_extra_data(service, "visibility",
- (const char *)mode_str) < 0) {
- BT_ERR("Fail to add extra data");
- }
-
- /* Convert the radio value to result */
- switch (ugd->selected_radio) {
- case 0:
- visibility = BT_VISIBLE_OFF;
- break;
- case 1:
- case 2:
- case 3:
- visibility = BT_VISIBLE_TIME_LIMITED;
- break;
- case 4:
- visibility = BT_VISIBLE_ALWAYS;
- break;
- default:
- visibility = BT_VISIBLE_OFF;
- break;
- }
-
- memset(mode_str, 0x00, BT_RESULT_STR_MAX);
- snprintf(mode_str, BT_RESULT_STR_MAX, "%d", visibility);
-
- if (app_control_add_extra_data(service, BT_APPCONTROL_VISIBILITY,
- (const char *)mode_str) < 0) {
- BT_ERR("Fail to add extra data");
- }
-
- return service;
-}
-
static app_control_h __bt_main_get_pick_result(bt_ug_data *ugd, gboolean result)
{
app_control_h service = NULL;
retv_if(ugd == NULL, EINA_FALSE);
- if (ugd->bt_launch_mode == BT_LAUNCH_VISIBILITY) {
- service = __bt_main_get_visibility_result(ugd, FALSE);
- app_control_create(&reply);
- if (app_control_add_extra_data(reply, "result",
- BT_RESULT_FAIL) < 0) {
- BT_ERR("Fail to add extra data");
- }
- BT_DBG("BT_LAUNCH_VISIBILITY reply to launch request");
- app_control_reply_to_launch_request(reply, service,
- APP_CONTROL_RESULT_FAILED);
-
- _bt_ug_destroy(data, (void *)service);
-
- if (service)
- app_control_destroy(service);
- if (reply)
- app_control_destroy(reply);
- } else if (ugd->bt_launch_mode == BT_LAUNCH_PICK) {
+ if (ugd->bt_launch_mode == BT_LAUNCH_PICK) {
app_control_create(&service);
if (service == NULL) {
FN_END;
}
-void _bt_main_add_visible_item(bt_ug_data *ugd, Evas_Object *genlist)
-{
- FN_START;
- retm_if(ugd->op_status == BT_DEACTIVATED, "BT is turned off");
-
- Elm_Object_Item *git = NULL;
-
- if (ugd->bt_launch_mode == BT_LAUNCH_NORMAL ||
- ugd->bt_launch_mode == BT_LAUNCH_HELP ||
- ugd->bt_launch_mode == BT_LAUNCH_VISIBILITY) {
- /* visibility */
- git = elm_genlist_item_insert_after(genlist, ugd->visible_itc, ugd,
- NULL, ugd->device_name_item,
- ELM_GENLIST_ITEM_NONE,
- __bt_main_visible_item_sel, ugd);
- ugd->visible_item = git;
- }
- FN_END;
-}
-
static Evas_Object *__bt_main_add_genlist_dialogue(Evas_Object *parent,
bt_ug_data *ugd)
{
evas_object_smart_callback_add(genlist, "unhighlighted",
__bt_main_gl_unhighlighted, ugd);
- ugd->radio_main = elm_radio_add(genlist);
- elm_radio_state_value_set(ugd->radio_main, 0);
- elm_radio_value_set(ugd->radio_main, 0);
-
- ugd->selected_radio =
- _bt_util_get_timeout_index(ugd->visibility_timeout);
-
ugd->on_itc = elm_genlist_item_class_new();
retv_if(ugd->on_itc == NULL, NULL);
ugd->device_name_itc->func.state_get = NULL;
ugd->device_name_itc->func.del = NULL;
- if (ugd->bt_launch_mode == BT_LAUNCH_NORMAL ||
- ugd->bt_launch_mode == BT_LAUNCH_HELP) {
- /* Set item class for visibility */
- ugd->visible_itc = elm_genlist_item_class_new();
- retv_if(ugd->visible_itc == NULL, NULL);
-
- ugd->visible_itc->item_style = BT_GENLIST_MULTILINE_TEXT_STYLE;
- ugd->visible_itc->func.text_get = __bt_main_visible_label_get;
- ugd->visible_itc->func.content_get = NULL;
- ugd->visible_itc->func.state_get = NULL;
- ugd->visible_itc->func.del = NULL;
- }
-
/* Set item class for paired dialogue title */
ugd->paired_title_itc = elm_genlist_item_class_new();
retv_if(ugd->paired_title_itc == NULL, NULL);
ugd->no_device_itc->func.state_get = NULL;
ugd->no_device_itc->func.del = NULL;
- /* Set item class for timeout value */
- ugd->timeout_value_itc = elm_genlist_item_class_new();
- retv_if(ugd->timeout_value_itc == NULL, NULL);
-
- ugd->timeout_value_itc->item_style = BT_GENLIST_1LINE_TEXT_ICON_STYLE;
- ugd->timeout_value_itc->func.text_get =
- __bt_main_timeout_value_label_get;
- ugd->timeout_value_itc->func.content_get =
- __bt_main_timeout_value_icon_get;
- ugd->timeout_value_itc->func.state_get = NULL;
- ugd->timeout_value_itc->func.del = __bt_main_timeout_value_del;
-
if (ugd->op_status == BT_DEACTIVATED ||
ugd->op_status == BT_ACTIVATING)
git = elm_genlist_item_append(genlist, ugd->off_itc, ugd, NULL,
elm_object_item_disabled_set(ugd->onoff_item, EINA_TRUE);
_bt_main_add_device_name_item(ugd, genlist);
- _bt_main_add_visible_item(ugd, genlist);
evas_object_show(genlist);
evas_object_smart_callback_add(genlist, "unhighlighted",
__bt_main_gl_unhighlighted, ugd);
- ugd->radio_main = elm_radio_add(genlist);
- elm_radio_state_value_set(ugd->radio_main, 0);
- elm_radio_value_set(ugd->radio_main, 0);
-
- ugd->selected_radio =
- _bt_util_get_timeout_index(ugd->visibility_timeout);
-
ugd->on_itc = elm_genlist_item_class_new();
retv_if(ugd->on_itc == NULL, NULL);
ugd->device_name_itc->func.state_get = NULL;
ugd->device_name_itc->func.del = NULL;
- /* Set item class for visibility */
- ugd->visible_itc = elm_genlist_item_class_new();
- retv_if(ugd->visible_itc == NULL, NULL);
-
- ugd->visible_itc->item_style = BT_GENLIST_MULTILINE_TEXT_STYLE;
- ugd->visible_itc->func.text_get = __bt_main_visible_label_get;
- ugd->visible_itc->func.content_get = NULL;
- ugd->visible_itc->func.state_get = NULL;
- ugd->visible_itc->func.del = NULL;
-
- /* Set item class for timeout value */
- ugd->timeout_value_itc = elm_genlist_item_class_new();
- retv_if(ugd->timeout_value_itc == NULL, NULL);
-
- ugd->timeout_value_itc->item_style = BT_GENLIST_1LINE_TEXT_ICON_STYLE;
- ugd->timeout_value_itc->func.text_get =
- __bt_main_timeout_value_label_get;
- ugd->timeout_value_itc->func.content_get =
- __bt_main_timeout_value_icon_get;
- ugd->timeout_value_itc->func.state_get = NULL;
- ugd->timeout_value_itc->func.del = __bt_main_timeout_value_del;
-
-
if (ugd->op_status == BT_DEACTIVATED ||
ugd->op_status == BT_ACTIVATING)
git = elm_genlist_item_append(genlist, ugd->off_itc, ugd, NULL,
ugd->onoff_item = git;
_bt_main_add_device_name_item(ugd, genlist);
- _bt_main_add_visible_item(ugd, genlist);
evas_object_show(genlist);
FN_END;
g_free(ugd->popup_data.data);
ugd->popup_data.data = NULL;
- if (ugd->visibility_popup) {
- evas_object_del(ugd->visibility_popup);
- ugd->visibility_popup = NULL;
- }
-
ugd->back_cb = NULL;
FN_END;
ugd->confirm_req = BT_NONE_REQ;
- if (ugd->op_status == BT_ACTIVATED || ugd->op_status == BT_SEARCHING) {
- if (ugd->visible_item)
- elm_object_item_disabled_set(ugd->visible_item,
- EINA_FALSE);
- }
-
FN_END;
return BT_UG_ERROR_NONE;
}
ugd->main_genlist = genlist;
ugd->confirm_req = BT_NONE_REQ;
- if (ugd->op_status == BT_ACTIVATED && ugd->visible_item)
- elm_object_item_disabled_set(ugd->visible_item, EINA_FALSE);
-
FN_END;
return BT_UG_ERROR_NONE;
}
app_control_h service = NULL;
int ret;
- int remain_time = 0;
bool status = false;
bt_adapter_state_e bt_state = BT_ADAPTER_DISABLED;
- bt_adapter_visibility_mode_e mode =
- BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE;
ret_if(ugd == NULL);
service = data;
if (bt_state == BT_ADAPTER_DISABLED) {
ugd->op_status = BT_DEACTIVATED;
- mode = BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE;
} else {
if (bt_adapter_is_discovering(&status) != BT_ERROR_NONE)
BT_ERR("bt_adapter_is_discovering() failed");
bt_adapter_stop_device_discovery();
ugd->op_status = BT_ACTIVATED;
-
- if (bt_adapter_get_visibility(&mode, &remain_time) != BT_ERROR_NONE)
- BT_ERR("bt_adapter_get_visibility() failed");
- }
-
- if (mode == BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE) {
- ugd->visible = FALSE;
- ugd->visibility_timeout = 0;
- } else if (mode == BT_ADAPTER_VISIBILITY_MODE_GENERAL_DISCOVERABLE) {
- ugd->visible = TRUE;
- ugd->visibility_timeout = -1;
- } else {
- /* BT_ADAPTER_VISIBILITY_MODE_LIMITED_DISCOVERABLE */
- /* Need to add the code for getting timeout */
- if (vconf_get_int(BT_FILE_VISIBLE_TIME,
- &ugd->visibility_timeout)) {
- BT_DBG("Get the timeout value");
- }
-
- ugd->remain_time = remain_time;
-
- if (ugd->remain_time > 0) {
- /* Set current time snapshot */
- time(&(ugd->start_time));
- ugd->timeout_id = g_timeout_add(BT_VISIBILITY_TIMEOUT,
- (GSourceFunc)
- __bt_main_visible_timeout_cb,
- ugd);
- } else {
- ugd->visibility_timeout = 0;
- }
}
FN_END;