Evas_Object *bluetooth_check;
Evas_Object *bluetooth_check_label;
Evas_Object *bluetooth_check_button;
+ Evas_Object* input_text;
Elm_Object_Item *selected_device_item;
bool hdp_send_data_flag;
player_h bt_player;
+
+ int pbap_phonebook_size;
+
};
#define BT_ADAPTER_DEVICE_DISCOVERY_NONE -1
{
DBG("bluetooth_gl_text_get_cb %s", id->text);
char buf[1024];
- snprintf(buf, 1023, id->text);
+ snprintf(buf, 1023,"%s", id->text);
return strdup(buf);
}
}
static void _bt_hdp_disconnected_cb(int result, const char *remote_address, unsigned int channel, void *user_data);
static void _bt_hdp_data_received_cb(unsigned int channel, const char *data, unsigned int size, void *user_data);
+static void _bt_pbap_connection_state_changed_cb(int result, bool connected, const char *remote_address, void *user_data);
+static void _bt_pbap_phone_book_size_cb(int result, const char *remote_address, int size, void *user_data);
+static void _bt_pbap_phone_book_received_cb(int result, const char *remote_address, const char *vcf_file, void *user_data);
+static void _bt_pbap_list_vcards_cb(int result, const char *remote_address, const bt_pbap_vcard_info_s *vcard_info, int count, void *user_data);
+static void _pbap_list_clicked_cb(void* data, Evas_Object *obj, void* event_info);
+static void _pbap_search_button_pressed_cb(void *data, Evas_Object *obj, void *event_info);
+
+static void _bt_avrcp_control_connection_state_changed_cb(bool connected, const char *remote_address, void *user_data);
/**
* @function bluetooth_view_add
tbt_info->layout_file = get_edje_path("5_part_txt_cnt1.5_cnt_btn_btn.edj");
//tbt_info->layout_group = "bluetooth_viewer";
}
+ else if(tbt_info->apptype == TBT_APP_BT_PBAP_ALL_VCARDS)
+ {
+ tbt_info->layout_group = "5_part_txt_entry_cnt_btn_btn";
+ tbt_info->layout_file = get_edje_path("4_part_txt_cnt2_btn_btn.edj");
+ this->pbap_phonebook_size = 0;
+ }
else
{
tbt_info->layout_group = "4_part_txt_cnt_btn_btn";
this->bluetooth_label = ui_utils_label_add(this->view->layout, "Bluetooth");
elm_object_part_content_set(this->view->layout, "1txt", this->bluetooth_label);
+ if(tbt_info->apptype == TBT_APP_BT_PBAP_ALL_VCARDS)
+ {
+ this->input_text = ui_utils_entry_add(this, this->view->layout, ELM_INPUT_PANEL_LAYOUT_NORMAL, "");
+ elm_object_part_text_set(this->input_text, PART_ENTRY_GUIDE, "Enter name:");
+// elm_object_part_content_set(this->view->layout, "1entry", this->input_text);
+
+ }
+
+
#ifndef USE_GENLIST
this->bluetooth_list = elm_list_add(this->view->layout);
RETVM_IF(!this->bluetooth_list, NULL, "elm_list_add failed");
this->view->tbt_info->apptype == TBT_APP_BT_HID_CONNECT ||
this->view->tbt_info->apptype == TBT_APP_BT_AVRCP ||
this->view->tbt_info->apptype == TBT_APP_BT_AG ||
- this->view->tbt_info->apptype == TBT_APP_BT_HDP
+ this->view->tbt_info->apptype == TBT_APP_BT_HDP ||
+ this->view->tbt_info->apptype == TBT_APP_BT_PBAP_ALL_VCARDS ||
+ this->view->tbt_info->apptype == TBT_APP_BT_AVRCP_REMOTE
)
{
this->state_object_bt_client_pair = util_state_object_create("bt_client_pair");
this->view->tbt_info->apptype == TBT_APP_BT_AVRCP ||
this->view->tbt_info->apptype == TBT_APP_BT_SDP ||
this->view->tbt_info->apptype == TBT_APP_BT_AG ||
- this->view->tbt_info->apptype == TBT_APP_BT_HDP
+ this->view->tbt_info->apptype == TBT_APP_BT_HDP ||
+ this->view->tbt_info->apptype == TBT_APP_BT_PBAP_ALL_VCARDS ||
+ this->view->tbt_info->apptype == TBT_APP_BT_AVRCP_REMOTE
)
{
this->view->tbt_info->apptype == TBT_APP_BT_AVRCP ||
this->view->tbt_info->apptype == TBT_APP_BT_AG ||
this->view->tbt_info->apptype == TBT_APP_BT_SDP ||
- this->view->tbt_info->apptype == TBT_APP_BT_HDP)
+ this->view->tbt_info->apptype == TBT_APP_BT_HDP ||
+ this->view->tbt_info->apptype == TBT_APP_BT_PBAP_ALL_VCARDS ||
+ this->view->tbt_info->apptype == TBT_APP_BT_AVRCP_REMOTE)
{
elm_object_text_set(this->bluetooth_btn, ui_utils_text_add("Bluetooth Off", NULL));
ui_utils_label_set_text(this->bluetooth_label, "Bluetooth is Switched On", "left");
this->is_opp_server_accecpt = EINA_FALSE;
this->is_opp_server_push_progress = EINA_FALSE;
}
+ else if(this->view->tbt_info->apptype == TBT_APP_BT_PBAP_ALL_VCARDS)
+ {
+ this->action_btn = ui_utils_push_button_add(this, table, "PBAP Connect", _control_button_pressed_cb);
+ RETVM_IF(NULL == this->action_btn, NULL, "this->action_btn is NULL");
+ elm_table_pack(table, this->action_btn, 1, 0, 1, 1);
+ }
+ else if(this->view->tbt_info->apptype == TBT_APP_BT_AVRCP_REMOTE)
+ {
+ this->action_btn = ui_utils_push_button_add(this, table, "AVRCP Connect", _control_button_pressed_cb);
+ RETVM_IF(NULL == this->action_btn, NULL, "this->action_btn is NULL");
+ elm_table_pack(table, this->action_btn, 1, 0, 1, 1);
+ }
return table;
}
}
}
+static void _bt_avrcp_control_connection_state_changed_cb(bool connected, const char *remote_address, void *user_data)
+{
+ DBG("_bt_avrcp_control_connection_state_changed_cb");
+ int result;
+ bluetooth_view *this = NULL;
+ this = (bluetooth_view*)user_data;
+ RETM_IF(NULL == this, "view is NULL");
+
+ if(connected)
+ {
+ result = bt_avrcp_control_send_player_command(BT_AVRCP_CONTROL_PLAY);
+ RETM_IF(result != BT_ERROR_NONE, "bt_avrcp_control_send_player_command fail > Error = %s", get_bluetooth_error(result));
+
+ DBG("Sent player command successfully");
+ }
+}
+
+static void _pbap_search_button_pressed_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ DBG(" _pbap_search_button_pressed_cb ");
+
+ RETM_IF(NULL == data, "data is NULL");
+
+ int result;
+ bluetooth_view *this = NULL;
+ this = (bluetooth_view*)data;
+ RETM_IF(NULL == this, "view is NULL");
+
+ DBG("%s",elm_object_text_get(this->input_text));
+ const char* search_value = elm_object_text_get(this->input_text);
+
+ result = bt_pbap_client_search_phone_book(
+ this->selected_device_info->remote_address, BT_PBAP_SOURCE_DEVICE,
+ BT_PBAP_FOLDER_PHONE_BOOK, BT_PBAP_SEARCH_NAME, search_value,
+ BT_PBAP_ORDER_INDEXED, 0, this->pbap_phonebook_size,
+ _bt_pbap_list_vcards_cb, this);
+
+ RETM_IF(result != BT_ERROR_NONE, "bt_pbap_client_search_phone_book fail > Error = %s", get_bluetooth_error(result));
+}
/**
* @function _control_button_pressed_cb
}
}
+ else if(this->view->tbt_info->apptype == TBT_APP_BT_PBAP_ALL_VCARDS)
+ {
+ //PBAP Code goes here
+ result = bt_pbap_client_initialize();
+ RETM_IF(result != BT_ERROR_NONE, "bt_pbap_client_initialize fail > Error = %s", get_bluetooth_error(result));
+
+ result = bt_pbap_client_set_connection_state_changed_cb(_bt_pbap_connection_state_changed_cb, this);
+ RETM_IF(result != BT_ERROR_NONE, "bt_pbap_client_set_connection_state_changed_cb fail > Error = %s", get_bluetooth_error(result));
+
+ result = bt_pbap_client_connect(this->selected_device_info->remote_address);
+ RETM_IF(result != BT_ERROR_NONE, "bt_pbap_client_connect fail > Error = %s", get_bluetooth_error(result));
+ }
+
+ else if(this->view->tbt_info->apptype == TBT_APP_BT_AVRCP_REMOTE)
+ {
+ //Avrcp remote goes here
+ result = bt_avrcp_control_initialize(_bt_avrcp_control_connection_state_changed_cb, this);
+ RETM_IF(result != BT_ERROR_NONE, "bt_avrcp_control_initialize fail > Error = %s", get_bluetooth_error(result));
+
+ result = bt_avrcp_control_connect(this->selected_device_info->remote_address);
+ RETM_IF(result != BT_ERROR_NONE, "bt_avrcp_control_connect fail > Error = %s", get_bluetooth_error(result));
+ }
else if(this->view->tbt_info->apptype == TBT_APP_BT_HDP)
{
}
+static void _bt_pbap_connection_state_changed_cb(int result, bool connected, const char *remote_address, void *user_data)
+{
+ DBG("_bt_pbap_connection_state_changed_cb");
+ int ret;
+ bluetooth_view *this = NULL;
+ this = (bluetooth_view*)user_data;
+ RETM_IF(NULL == this, "view is NULL");
+ if(connected)
+ {
+ DBG("remote address %s", remote_address);
+ ret = bt_pbap_client_get_phone_book_size(remote_address,
+ BT_PBAP_SOURCE_DEVICE, BT_PBAP_FOLDER_PHONE_BOOK,
+ _bt_pbap_phone_book_size_cb, this);
+ RETM_IF(ret != BT_ERROR_NONE, "bt_pbap_client_get_phone_book_size fail > Error = %s", get_bluetooth_error(ret));
+
+ }
+}
+
+static void _bt_pbap_phone_book_size_cb(int result, const char *remote_address, int size, void *user_data)
+{
+ DBG("_bt_pbap_phone_book_size_cb size %d", size);
+ bluetooth_view *this = NULL;
+ this = (bluetooth_view*)user_data;
+ RETM_IF(NULL == this, "view is NULL");
+ this->pbap_phonebook_size = size;
+
+ int ret = BT_ERROR_NONE;
+ ret = bt_pbap_client_get_phone_book(remote_address,
+ BT_PBAP_SOURCE_DEVICE, BT_PBAP_FOLDER_PHONE_BOOK,
+ BT_PBAP_VCARD_FORMAT_VCARD21, BT_PBAP_ORDER_INDEXED, 0, this->pbap_phonebook_size,
+ BT_PBAP_FIELD_ALL, _bt_pbap_phone_book_received_cb, this);
+ RETM_IF(ret != BT_ERROR_NONE, "bt_pbap_client_get_phone_book fail > Error = %s", get_bluetooth_error(ret));
+
+ ret = bt_pbap_client_get_list(remote_address, BT_PBAP_SOURCE_DEVICE,
+ BT_PBAP_FOLDER_PHONE_BOOK, BT_PBAP_ORDER_INDEXED, 0, this->pbap_phonebook_size,
+ _bt_pbap_list_vcards_cb, this);
+ RETM_IF(ret != BT_ERROR_NONE, "bt_pbap_client_get_list fail > Error = %s", get_bluetooth_error(ret));
+
+}
+static void _bt_pbap_phone_book_received_cb(int result, const char *remote_address, const char *vcf_file, void *user_data)
+{
+ bluetooth_view *this = NULL;
+ this = (bluetooth_view*)user_data;
+ RETM_IF(NULL == this, "view is NULL");
+ DBG("_bt_pbap_phone_book_received_cb %s", vcf_file);
+
+ char* str = format_string("path: %s", vcf_file);
+ ui_utils_label_set_text(this->bluetooth_label, str, "left");
+ SAFE_DELETE(str);
+}
+
+static void _bt_pbap_list_vcards_cb(int result, const char *remote_address, const bt_pbap_vcard_info_s *vcard_info, int count, void *user_data)
+{
+ DBG("_bt_pbap_list_vcards_cb %d", count);
+ bluetooth_view *this = NULL;
+ this = (bluetooth_view*)user_data;
+ RETM_IF(NULL == this, "view is NULL");
+
+ elm_genlist_clear(this->bluetooth_list);
+
+ for(int i=0; i<count; i++)
+ {
+ if(vcard_info != NULL)
+ {
+ DBG("%d: %s", vcard_info[i].index, vcard_info[i].contact_name);
+ if(vcard_info[i].contact_name != NULL)
+ {
+ bluetooth_elm_genlist_item_append((char*)vcard_info[i].contact_name, _pbap_list_clicked_cb, (void*)(&vcard_info[i]), this);
+ }
+ else
+ {
+ DBG("vcard_info[i].contact_name is NULL");
+ }
+ }
+ else
+ {
+ DBG("vcard_info is NULL");
+ }
+
+ }
+ elm_object_part_content_set(this->view->layout, "1entry", this->input_text);
+ elm_object_disabled_set(this->action_btn, EINA_FALSE);
+ elm_object_text_set(this->action_btn, ui_utils_text_add("Search", NULL));
+ evas_object_smart_callback_del(this->action_btn, "clicked", _control_button_pressed_cb);
+ evas_object_smart_callback_add(this->action_btn, "clicked", _pbap_search_button_pressed_cb, this);
+}
+
/**
* @function _cancel_button_pressed_cb
* @since_tizen 2.3
update_view_controls(this);
}
+static void _pbap_list_clicked_cb(void* data, Evas_Object *obj, void* event_info)
+{
+ DBG("_pbap_list_clicked_cb");
+
+ int ret;
+ bluetooth_view *this ;
+ this = evas_object_data_get(obj, "bluetooth_view");
+ RETM_IF(NULL == this, "view is NULL");
+
+ bt_pbap_vcard_info_s* vcard_info = (bt_pbap_vcard_info_s*)(data);
+
+ ret = bt_pbap_client_pull_vcard(this->selected_device_info->remote_address, BT_PBAP_SOURCE_DEVICE,
+ BT_PBAP_FOLDER_PHONE_BOOK, vcard_info->index, BT_PBAP_VCARD_FORMAT_VCARD21,
+ BT_PBAP_FIELD_ALL, _bt_pbap_phone_book_received_cb, this);
+}
/**
* @function _device_item_selected_cb
this->view->tbt_info->apptype == TBT_APP_BT_HID_CONNECT ||
this->view->tbt_info->apptype == TBT_APP_BT_SDP ||
this->view->tbt_info->apptype == TBT_APP_BT_AVRCP ||
- this->view->tbt_info->apptype == TBT_APP_BT_HDP)
+ this->view->tbt_info->apptype == TBT_APP_BT_HDP ||
+ this->view->tbt_info->apptype == TBT_APP_BT_PBAP_ALL_VCARDS ||
+ this->view->tbt_info->apptype == TBT_APP_BT_AVRCP_REMOTE)
{
if(this->selected_device_info != NULL &&
result == BT_ERROR_NONE &&
this->view->tbt_info->apptype == TBT_APP_BT_AUDIO_CONNECT_HANDSFREE ||
this->view->tbt_info->apptype == TBT_APP_BT_HID_CONNECT ||
this->view->tbt_info->apptype == TBT_APP_BT_AVRCP ||
- this->view->tbt_info->apptype == TBT_APP_BT_HDP)
+ this->view->tbt_info->apptype == TBT_APP_BT_HDP ||
+ this->view->tbt_info->apptype == TBT_APP_BT_PBAP_ALL_VCARDS ||
+ this->view->tbt_info->apptype == TBT_APP_BT_AVRCP_REMOTE)
{
elm_object_disabled_set(this->action_btn, EINA_FALSE);
}
result = bt_device_unset_service_searched_cb();
RETM_IF(result != BT_ERROR_NONE, "bt_device_unset_service_searched_cb Failed");
}
+ else if(view->view->tbt_info->apptype == TBT_APP_BT_PBAP_ALL_VCARDS)
+ {
+ //PBAP deinitialization code goes here
+ result = bt_pbap_client_unset_connection_state_changed_cb();
+ RETM_IF(result != BT_ERROR_NONE, "bt_pbap_client_unset_connection_state_changed_cb fail > Error = %s", get_bluetooth_error(result));
+ result = bt_pbap_client_disconnect(view->selected_device_info->remote_address);
+ RETM_IF(result != BT_ERROR_NONE, "bt_pbap_client_disconnect fail > Error = %s", get_bluetooth_error(result));
+ result = bt_pbap_client_deinitialize();
+ RETM_IF(result != BT_ERROR_NONE, "bt_pbap_client_deinitialize fail > Error = %s", get_bluetooth_error(result));
+ }
+
+ else if(view->view->tbt_info->apptype == TBT_APP_BT_AVRCP_REMOTE)
+ {
+ //AVRCP Remote Deinitialiazation code goes here
+ }
if(view->discovery_state == BT_ADAPTER_DEVICE_DISCOVERY_STARTED || view->discovery_state == BT_ADAPTER_DEVICE_DISCOVERY_FOUND)