[TBT][tizen_3.0_wearable][Bluetooth PBAP module added] 25/85125/1
authorJihun Park <jihun87.park@samsung.com>
Wed, 24 Aug 2016 01:24:09 +0000 (10:24 +0900)
committerJihun Park <jihun87.park@samsung.com>
Wed, 24 Aug 2016 01:24:09 +0000 (10:24 +0900)
Change-Id: Id9df5614cac966866ea3c4342c63a773c20808e8
Signed-off-by: Jihun Park <jihun87.park@samsung.com>
tbtcoreapp/inc/model/tbt-info.h
tbtcoreapp/inc/utils/app_module_config.h
tbtcoreapp/res/edje/2.3.1/wearable_360_360/4_part_txt_cnt2_btn_btn.edc
tbtcoreapp/src/model/tbt-list.c
tbtcoreapp/src/view/tbt-bluetooth-view.c
tbtcoreapp/src/view/tbt-genlist-view.c

index 4124ddfde68fe10a93be43d8384e74425e59033a..878fe23a212669b2c69612d40803de79cccaf5b6 100644 (file)
@@ -69,8 +69,10 @@ typedef enum {
     TBT_APP_BT_OOB_PERIPHERAL,
     TBT_APP_BT_OOB_DEVICE,
     TBT_APP_BT_AVRCP,
+    TBT_APP_BT_AVRCP_REMOTE,
     TBT_APP_BT_AG,
     TBT_APP_BT_HDP,
+    TBT_APP_BT_PBAP_ALL_VCARDS,
     
     TBT_APP_BLE_GATT_CLIENT,
 
index 1847cdf55c6cffa70c92c8acfae70d8682251031..259e18197393b35f72e683da5d4ebafa961fe96d 100644 (file)
@@ -37,7 +37,9 @@
 #define TBT_MODULE_APP_BT_HID_CONNECT
 //#define TBT_MODULE_APP_BT_AG
 //#define TBT_MODULE_APP_BT_AVRCP
+//#define TBT_MODULE_APP_BT_AVRCP_REMOTE
 #define TBT_MODULE_APP_BT_HDP
+#define TBT_MODULE_APP_BT_PBAP_ALL_VCARDS
 
 //#define TBT_MODULE_BLE
 //#define TBT_MODULE_BLE_GATT_CLIENT
index ff8d5b9be1cbab068c9352f23fbf3d6fdbd32255..1d2eac707945de200badd2f305b918443bb6599a 100644 (file)
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
+* Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
 collections
 {
-    base_scale: 1.33;
-    group
-    {
-        name: "4_part_txt_cnt_btn_btn";
-        parts{                 
-            part{
-                name: "1txt";
-                type: SWALLOW;
-                description{
-                    state: "default" 0.0;
-                    align: 0.0 0.0;
-                    visible: 1;
-                    rel1 {relative: 0.0 0.0; }
-                    rel2 {relative: 1.0 0.10; }
-                }
+   base_scale: 1.33;
+   group
+   {
+      name: "4_part_txt_cnt_btn_btn";
+      parts{
+         part{
+            name: "1txt";
+            type: SWALLOW;
+            description{
+               state: "default" 0.0;
+               align: 0.0 0.0;
+               visible: 1;
+               rel1 {
+                  relative: 0.0 0.0;
+               }
+               rel2 {
+                  relative: 1.0 0.10;
+               }
             }
-            
-            part{
-                name: "1txt_2cnt";
-                type: SWALLOW;
-                description {
-                    state: "default" 0.0;
-                    rel1 { 
-                                                  relative: 0.0 0.10;
-                                       }
-                    rel2 {
-                                                  relative: 1.0 0.60; 
-                    }
-                    visible: 1;
-                }
+         }
+         part{
+            name: "1txt_2cnt";
+            type: SWALLOW;
+            description {
+               state: "default" 0.0;
+               rel1 {
+                  relative: 0.0 0.10;
+               }
+               rel2 {
+                  relative: 1.0 0.60;
+               }
+               visible: 1;
             }
-            
-                       part { name: "padding";
-                type: SPACER;
-                description {
-                    state: "default" 0.0;
-                    rel1 { relative: 0.0 0.60; }
-                    rel2 { relative: 1.0 0.65; }
-                    fixed: 1 0;
-                }
+         }
+         part { name: "padding";
+            type: SPACER;
+            description {
+               state: "default" 0.0;
+               rel1 {
+                  relative: 0.0 0.60;
+               }
+               rel2 {
+                  relative: 1.0 0.65;
+               }
+               fixed: 1 0;
             }
-        
-                       part{ 
-                               name: "1txt_2cnt_3btn";
-                type: SWALLOW;
-                description {
-                    state: "default" 0.0;
-                    rel1 { 
-                                                  relative: 0.0 0.65;
-                                       }
-                    rel2 {
-                                                  relative: 1.0 0.70; 
-                    }
-                    visible: 1;
-                }
-                       }
-                       
-                       part { name: "padding2";
-                type: SPACER;
-                description {
-                    state: "default" 0.0;
-                    rel1 { relative: 0.0 0.70; }
-                    rel2 { relative: 1.0 1.0; }
-                    fixed: 1 0;
-                }
+         }
+         part{
+            name: "1txt_2cnt_3btn";
+            type: SWALLOW;
+            description {
+               state: "default" 0.0;
+               rel1 {
+                  relative: 0.0 0.65;
+               }
+               rel2 {
+                  relative: 1.0 0.70;
+               }
+               visible: 1;
             }
-
-                       part { name: "wearable_toolbar";
-                               type: SWALLOW;
-                               description {
-                                       state: "default" 0.0;
-                                       rel1 {
-                                               relative: 0.0 1.0;
-                                       }
-                                       rel2 {
-                                               relative: 1.0 1.0;
-                                       }
-                                       visible: 1;
-                               }
-                       }
-               }
-    }
-}
+         }
+         part { name: "padding2";
+            type: SPACER;
+            description {
+               state: "default" 0.0;
+               rel1 {
+                  relative: 0.0 0.70;
+               }
+               rel2 {
+                  relative: 1.0 1.0;
+               }
+               fixed: 1 0;
+            }
+         }
+         part { name: "wearable_toolbar";
+            type: SWALLOW;
+            description {
+               state: "default" 0.0;
+               rel1 {
+                  relative: 0.0 1.0;
+               }
+               rel2 {
+                  relative: 1.0 1.0;
+               }
+               visible: 1;
+            }
+         }
+      }
+   }
+   
+   group
+   {
+      name: "5_part_txt_entry_cnt_btn_btn";
+      parts{
+         part{
+            name: "1txt";
+            type: SWALLOW;
+            description{
+               state: "default" 0.0;
+               align: 0.0 0.0;
+               visible: 1;
+               rel1 {
+                  relative: 0.0 0.0;
+               }
+               rel2 {
+                  relative: 1.0 0.08;
+               }
+            }
+         }
+         
+         
+         part{
+            name: "1entry";
+            type: SWALLOW;
+            description{
+               state: "default" 0.0;
+               align: 0.0 0.0;
+               visible: 1;
+               rel1 {
+                  relative: 0.0 0.08;
+               }
+               rel2 {
+                  relative: 1.0 0.25;
+               }
+            }
+         }
+         
+         
+         part{
+            name: "1txt_2cnt";
+            type: SWALLOW;
+            description {
+               state: "default" 0.0;
+               rel1 {
+                  relative: 0.0 0.25;
+               }
+               rel2 {
+                  relative: 1.0 0.60;
+               }
+               visible: 1;
+            }
+         }
+         part { name: "padding";
+            type: SPACER;
+            description {
+               state: "default" 0.0;
+               rel1 {
+                  relative: 0.0 0.60;
+               }
+               rel2 {
+                  relative: 1.0 0.65;
+               }
+               fixed: 1 0;
+            }
+         }
+         part{
+            name: "1txt_2cnt_3btn";
+            type: SWALLOW;
+            description {
+               state: "default" 0.0;
+               rel1 {
+                  relative: 0.0 0.65;
+               }
+               rel2 {
+                  relative: 1.0 0.70;
+               }
+               visible: 1;
+            }
+         }
+         part { name: "padding2";
+            type: SPACER;
+            description {
+               state: "default" 0.0;
+               rel1 {
+                  relative: 0.0 0.70;
+               }
+               rel2 {
+                  relative: 1.0 1.0;
+               }
+               fixed: 1 0;
+            }
+         }
+         part { name: "wearable_toolbar";
+            type: SWALLOW;
+            description {
+               state: "default" 0.0;
+               rel1 {
+                  relative: 0.0 1.0;
+               }
+               rel2 {
+                  relative: 1.0 1.0;
+               }
+               visible: 1;
+            }
+         }
+      }
+   }
+   
+}
\ No newline at end of file
index de7ae71fe34188495e8cf3511f05cd46b617312e..0e89fd2fdd60576f079e63c0ae5b29c1d96c1e3a 100644 (file)
@@ -408,6 +408,21 @@ static tbt_info tbtapps[] =
                        .features_required = {16, 85}
                },
        #endif
+       #ifdef TBT_MODULE_APP_BT_PBAP_ALL_VCARDS
+
+               // PBAP All Vcards
+               {
+                       .name = "PBAP All Vcards",
+                       .parent = "Bluetooth",
+                       .apptype = TBT_APP_BT_PBAP_ALL_VCARDS,
+                       .icon_name = "dummy",
+                       .info = "Get All Phonebook vcards from PBAP Server",
+                       .result = 0,
+                       .required_features_count = 2,
+                       .features_required = {16, 67}
+
+               },
+       #endif
 
 #endif
 
index e23cb81fb356b56ec80ddddc641c11221a14710c..db31c04cbd55a2afefde7d9f336a4d599cc8babf 100644 (file)
@@ -101,6 +101,7 @@ struct _bluetooth_view
     Evas_Object *bluetooth_check;
     Evas_Object *bluetooth_check_label;
     Evas_Object *bluetooth_check_button;
+    Evas_Object* input_text;
 
     Elm_Object_Item *selected_device_item;
 
@@ -126,6 +127,9 @@ struct _bluetooth_view
     bool hdp_send_data_flag;
 
     player_h bt_player;
+
+    int pbap_phonebook_size;
+
 };
 
 #define BT_ADAPTER_DEVICE_DISCOVERY_NONE -1
@@ -167,7 +171,7 @@ static char *bluetooth_gl_text_get_cb(void *data, Evas_Object *obj, const char *
                {
                        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);
                }
        }
@@ -271,6 +275,14 @@ static void _bt_hdp_connected_cb(int result, const char *remote_address, const c
 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
@@ -318,6 +330,12 @@ bluetooth_view *bluetooth_view_add(Evas_Object *navi, tbt_info *tbt_info, Elm_Ob
        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";
@@ -332,6 +350,15 @@ bluetooth_view *bluetooth_view_add(Evas_Object *navi, tbt_info *tbt_info, Elm_Ob
     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");
@@ -477,7 +504,9 @@ static void setup_state_machine(bluetooth_view *this)
        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");
@@ -569,7 +598,9 @@ static void update_view_controls(bluetooth_view *this)
                                   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
                                   )
 
                                {
@@ -664,7 +695,9 @@ static void update_view_controls(bluetooth_view *this)
                                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");
@@ -774,6 +807,18 @@ static Evas_Object *add_control_layout(bluetooth_view *this, Evas_Object *parent
                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;
 }
@@ -1248,6 +1293,45 @@ static void adapter_device_error(int result)
        }
 }
 
+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
@@ -1336,6 +1420,28 @@ static void _control_button_pressed_cb(void *data, Evas_Object *obj, void *event
 
                }
        }
+       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)
        {
@@ -1433,6 +1539,93 @@ static void _control_button_pressed_cb(void *data, Evas_Object *obj, void *event
 }
 
 
+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
@@ -1762,6 +1955,21 @@ static void _adapter_device_discovery_state_changed_cb(int result, bt_adapter_de
    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
@@ -1981,7 +2189,9 @@ static void _adapter_device_bond_destroyed_cb(int result, char *remote_address,
                   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 &&
@@ -2034,7 +2244,9 @@ static void _adapter_device_bond_created_cb(int result, bt_device_info_s *device
                                   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);
                                }
@@ -2600,6 +2812,21 @@ static void _app_destroy_cb(void* this)
                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)
index 0230eafde2b5df1b6206ab0a00e389ee2da91ba2..89a497c2046875e2e57135ebb00518c7451457c3 100644 (file)
@@ -740,6 +740,9 @@ static void _gl_item_selected_cb(void *data, Evas_Object *obj EINA_UNUSED, void
                        case TBT_APP_BT_HDP:
                                bluetooth_view_add(view->navi, info, it);
                                break;
+                       case TBT_APP_BT_PBAP_ALL_VCARDS:
+                               bluetooth_view_add(view->navi, info, it);
+                               break;
                        #endif
 
                #ifdef TBT_MODULE_BT_OOB