return 0;
}
-int _bt_pbap_get_phonebook_size(const bluetooth_device_address_t *address,
- int source, int type)
+int _bt_get_pbab_session_info(GDBusProxy **g_pbap_session_proxy)
{
BT_DBG("+");
GDBusConnection *g_conn;
- GDBusProxy *g_pbap_session_proxy = NULL;
- char address_string[18] = { 0, };
- char *source_string = NULL;
- char *type_string = NULL;
GError *err = NULL;
- bt_pbap_data_t *pbap_data = NULL;
-
- BT_CHECK_PARAMETER(address, return);
/* check if connected */
if (g_pbap_session_path == NULL) {
return BLUETOOTH_ERROR_NOT_CONNECTED;
}
- BT_DBG("BD Address [%2.2X %2.2X %2.2X %2.2X %2.2X %2.2X]",
- address->addr[0], address->addr[1],
- address->addr[2], address->addr[3],
- address->addr[4], address->addr[5]);
-
- _bt_convert_addr_type_to_string(address_string, (unsigned char *)address->addr);
- BT_DBG("Address String: %s", address_string);
- source_string = g_strdup(SOURCE[source]);
- type_string = g_strdup(TYPE[type]);
-
- BT_DBG("Address[%s] Source[%s] Type[%s]",
- address_string, source_string, type_string);
BT_DBG("Session Path = %s\n", g_pbap_session_path);
g_conn = _bt_get_system_gconn();
if (g_conn == NULL) {
BT_ERR("Couldn't connect to session bus");
- g_free(source_string);
- g_free(type_string);
return 0;
}
- g_pbap_session_proxy = g_dbus_proxy_new_sync(g_conn,
+ *g_pbap_session_proxy = g_dbus_proxy_new_sync(g_conn,
G_DBUS_PROXY_FLAGS_NONE, NULL,
PBAP_SESSION_SERVICE, g_pbap_session_path,
PBAP_SESSION_INTERFACE, NULL, &err);
- if (!g_pbap_session_proxy) {
+ if (!*g_pbap_session_proxy) {
BT_ERR("Failed to get a proxy for D-Bus\n");
if (err) {
ERR("Unable to create proxy: %s", err->message);
g_clear_error(&err);
}
+ return -1;
+ }
+ return 0;
+}
+
+int _bt_pbap_get_phonebook_size(const bluetooth_device_address_t *address,
+ int source, int type)
+{
+ BT_DBG("+");
+ GDBusProxy *g_pbap_session_proxy = NULL;
+ char address_string[18] = { 0, };
+ char *source_string = NULL;
+ char *type_string = NULL;
+ bt_pbap_data_t *pbap_data = NULL;
+
+ BT_CHECK_PARAMETER(address, return);
+
+ int ret;
+
+ ret = _bt_get_pbab_session_info(&g_pbap_session_proxy);
+
+ BT_DBG("BD Address [%2.2X %2.2X %2.2X %2.2X %2.2X %2.2X]",
+ address->addr[0], address->addr[1],
+ address->addr[2], address->addr[3],
+ address->addr[4], address->addr[5]);
+
+ _bt_convert_addr_type_to_string(address_string, (unsigned char *)address->addr);
+
+ source_string = g_strdup(SOURCE[source]);
+ type_string = g_strdup(TYPE[type]);
+
+ BT_DBG("Address[%s] Source[%s] Type[%s]",
+ address_string, source_string, type_string);
+
+ if (ret != 0 || !(g_pbap_session_proxy)) {
g_free(source_string);
g_free(type_string);
- return -1;
+ return ret;
}
BT_DBG("Prepare PBAP data");
int source, int type, bt_pbap_pull_parameters_t *app_param)
{
BT_DBG("+");
- GDBusConnection *g_conn;
GDBusProxy *g_pbap_session_proxy = NULL;
char address_string[18] = { 0, };
char *source_string = NULL;
char *type_string = NULL;
- GError *err = NULL;
bt_pbap_data_t *pbap_data = NULL;
bt_pbap_pull_parameters_t *param = NULL;
BT_CHECK_PARAMETER(address, return);
+ int ret;
- /* check if connected */
- if (g_pbap_session_path == NULL) {
- BT_ERR("NOT CONNECTED");
- return BLUETOOTH_ERROR_NOT_CONNECTED;
- }
+ ret = _bt_get_pbab_session_info(&g_pbap_session_proxy);
BT_DBG("BD Address [%2.2X %2.2X %2.2X %2.2X %2.2X %2.2X]",
address->addr[0], address->addr[1],
address->addr[4], address->addr[5]);
_bt_convert_addr_type_to_string(address_string, (unsigned char *)address->addr);
- BT_DBG("Address String: %s", address_string);
source_string = g_strdup(SOURCE[source]);
type_string = g_strdup(TYPE[type]);
BT_DBG("Address[%s] Source[%s] Type[%s]",
- address_string, source_string, type_string);
-
- BT_DBG("Session Path = %s\n", g_pbap_session_path);
-
- g_conn = _bt_get_system_gconn();
- if (g_conn == NULL) {
- BT_ERR("Couldn't connect to session bus");
- g_free(source_string);
- g_free(type_string);
- return 0;
- }
- g_pbap_session_proxy = g_dbus_proxy_new_sync(g_conn,
- G_DBUS_PROXY_FLAGS_NONE, NULL,
- PBAP_SESSION_SERVICE, g_pbap_session_path,
- PBAP_SESSION_INTERFACE, NULL, &err);
+ address_string, source_string, type_string);
- if (!g_pbap_session_proxy) {
- BT_ERR("Failed to get a proxy for D-Bus\n");
- if (err) {
- ERR("Unable to create proxy: %s", err->message);
- g_clear_error(&err);
- }
+ if (ret != 0 || !(g_pbap_session_proxy)) {
g_free(source_string);
g_free(type_string);
- return -1;
+ return ret;
}
pbap_data = g_new0(bt_pbap_data_t, 1);
int source, int type, bt_pbap_pull_vcard_parameters_t *app_param)
{
BT_DBG("+");
- GDBusConnection *g_conn;
GDBusProxy *g_pbap_session_proxy = NULL;
char address_string[18] = { 0, };
char *source_string = NULL;
char *type_string = NULL;
bt_pbap_data_t *pbap_data = NULL;
bt_pbap_pull_vcard_parameters_t *param = NULL;
- GError *err = NULL;
BT_CHECK_PARAMETER(address, return);
+ int ret;
- /* check if connected */
- if (g_pbap_session_path == NULL) {
- BT_ERR("NOT CONNECTED");
- return BLUETOOTH_ERROR_NOT_CONNECTED;
- }
+ ret = _bt_get_pbab_session_info(&g_pbap_session_proxy);
BT_DBG("BD Address [%2.2X %2.2X %2.2X %2.2X %2.2X %2.2X]",
address->addr[0], address->addr[1],
address->addr[4], address->addr[5]);
_bt_convert_addr_type_to_string(address_string, (unsigned char *)address->addr);
- BT_DBG("Address String: %s", address_string);
source_string = g_strdup(SOURCE[source]);
type_string = g_strdup(TYPE[type]);
BT_DBG("Address[%s] Source[%s] Type[%s]",
- address_string, source_string, type_string);
-
- BT_DBG("Session Path = %s\n", g_pbap_session_path);
+ address_string, source_string, type_string);
- g_conn = _bt_get_system_gconn();
- if (g_conn == NULL) {
- BT_ERR("Couldn't connect to session bus");
+ if (ret != 0 || !(g_pbap_session_proxy)) {
g_free(source_string);
g_free(type_string);
- return 0;
- }
- g_pbap_session_proxy = g_dbus_proxy_new_sync(g_conn,
- G_DBUS_PROXY_FLAGS_NONE, NULL,
- PBAP_SESSION_SERVICE, g_pbap_session_path,
- PBAP_SESSION_INTERFACE, NULL, &err);
-
- if (!g_pbap_session_proxy) {
- BT_ERR("Failed to get a proxy for D-Bus\n");
- if (err) {
- ERR("Unable to create proxy: %s", err->message);
- g_clear_error(&err);
- }
- g_free(source_string);
- g_free(type_string);
- return -1;
+ return ret;
}
pbap_data = g_new0(bt_pbap_data_t, 1);
int source, int type, bt_pbap_search_parameters_t *app_param)
{
BT_DBG("+");
- GDBusConnection *g_conn;
GDBusProxy *g_pbap_session_proxy = NULL;
char address_string[18] = { 0, };
char *source_string = NULL;
char *type_string = NULL;
bt_pbap_data_t *pbap_data = NULL;
bt_pbap_search_parameters_t *param = NULL;
- GError *err = NULL;
BT_CHECK_PARAMETER(address, return);
+ int ret;
- /* check if connected */
- if (g_pbap_session_path == NULL) {
- BT_ERR("NOT CONNECTED");
- return BLUETOOTH_ERROR_NOT_CONNECTED;
- }
+ ret = _bt_get_pbab_session_info(&g_pbap_session_proxy);
BT_DBG("BD Address [%2.2X %2.2X %2.2X %2.2X %2.2X %2.2X]",
address->addr[0], address->addr[1],
address->addr[4], address->addr[5]);
_bt_convert_addr_type_to_string(address_string, (unsigned char *)address->addr);
- BT_DBG("Address String: %s", address_string);
source_string = g_strdup(SOURCE[source]);
type_string = g_strdup(TYPE[type]);
BT_DBG("Address[%s] Source[%s] Type[%s]",
- address_string, source_string, type_string);
-
- BT_DBG("Session Path = %s\n", g_pbap_session_path);
+ address_string, source_string, type_string);
- g_conn = _bt_get_system_gconn();
- if (g_conn == NULL) {
- BT_ERR("Couldn't connect to session bus");
- g_free(source_string);
- g_free(type_string);
- return 0;
- }
- g_pbap_session_proxy = g_dbus_proxy_new_sync(g_conn,
- G_DBUS_PROXY_FLAGS_NONE, NULL,
- PBAP_SESSION_SERVICE, g_pbap_session_path,
- PBAP_SESSION_INTERFACE, NULL, &err);
-
- if (!g_pbap_session_proxy) {
- BT_ERR("Failed to get a proxy for D-Bus\n");
- if (err) {
- ERR("Unable to create proxy: %s", err->message);
- g_clear_error(&err);
- }
+ if (ret != 0 || !(g_pbap_session_proxy)) {
g_free(source_string);
g_free(type_string);
- return -1;
+ return ret;
}
pbap_data = g_new0(bt_pbap_data_t, 1);