#include <dlog.h>
#include <string.h>
#include <stdio.h>
-#if !defined(LIBNOTIFY_SUPPORT) && !defined(LIBNOTIFICATION_SUPPORT)
#include <syspopup_caller.h>
-#endif
#include <net_connection.h>
#include "bluetooth-api.h"
if (g_strv_length(split_string) < 3)
continue;
- if (g_ascii_strcasecmp(split_string[2], net_address) == 0) {
+ if (split_string[2] == NULL) {
+ BT_ERR("__bt_get_net_profile Error Parameter are NULL..\n");
+ continue;
+ } else if (g_ascii_strcasecmp(split_string[2], net_address) == 0) {
BT_DBG("matched profile");
g_strfreev(split_string);
return profile_h;
handle = __bt_get_net_profile(connection,
CONNECTION_ITERATOR_TYPE_CONNECTED,
address);
- if(handle)
+ if (handle)
*is_connected = TRUE;
else
*is_connected = FALSE;
g_clear_error(&g_error);
}
result = BLUETOOTH_ERROR_INTERNAL;
+ } else {
+ g_variant_unref(reply);
}
- g_variant_unref(reply);
func_data = user_data;
if (func_data == NULL) {
g_clear_error(&g_error);
}
result = BLUETOOTH_ERROR_INTERNAL;
+ } else {
+ g_variant_unref(reply);
}
- g_variant_unref(reply);
func_data = user_data;
if (func_data == NULL) {
{
int ret = BLUETOOTH_ERROR_NONE;
char *adapter_path;
+ GVariant *result = NULL;
GError *err = NULL;
GDBusConnection *conn;
GDBusProxy *server_proxy;
- conn = _bt_get_system_gconn();
+ conn = _bt_gdbus_get_system_gconn();
retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
adapter_path = _bt_get_adapter_path();
return BLUETOOTH_ERROR_INTERNAL;
}
- g_dbus_proxy_call_sync(server_proxy, "Register",
+ result = g_dbus_proxy_call_sync(server_proxy, "Register",
g_variant_new("(ss)", NAP_UUID_NAME, NET_BRIDGE_INTERFACE),
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL,
&err);
- if (err != NULL) {
- g_dbus_error_strip_remote_error(err);
- BT_ERR("Network server register Error: %s\n", err->message);
- if (g_strcmp0(err->message, "Already Exists") == 0) {
- ret = BLUETOOTH_ERROR_ALREADY_INITIALIZED;
- } else {
- ret = BLUETOOTH_ERROR_INTERNAL;
+ if (result == NULL) {
+ if (err != NULL) {
+ g_dbus_error_strip_remote_error(err);
+ BT_ERR("Network server register Error: %s\n", err->message);
+ if (g_strcmp0(err->message, "Already Exists") == 0)
+ ret = BLUETOOTH_ERROR_ALREADY_INITIALIZED;
+ else
+ ret = BLUETOOTH_ERROR_INTERNAL;
+
+ g_error_free(err);
}
- g_error_free(err);
+ } else {
+ g_variant_unref(result);
}
+
g_object_unref(server_proxy);
return ret;
int _bt_network_deactivate(void)
{
char *adapter_path;
+ GVariant *result = NULL;
GError *err = NULL;
GDBusConnection *conn;
GDBusProxy *server_proxy;
int ret = BLUETOOTH_ERROR_NONE;
- conn = _bt_get_system_gconn();
+ conn = _bt_gdbus_get_system_gconn();
retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
adapter_path = _bt_get_adapter_path();
return BLUETOOTH_ERROR_INTERNAL;
}
- g_dbus_proxy_call_sync(server_proxy, "Unregister",
+ result = g_dbus_proxy_call_sync(server_proxy, "Unregister",
g_variant_new("(s)", NAP_UUID_NAME),
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL,
&err);
- if (err != NULL) {
- g_dbus_error_strip_remote_error(err);
- BT_ERR("Network server unregister Error: %s\n", err->message);
- if (g_strcmp0(err->message,
- "Operation currently not available") == 0) {
- ret = BLUETOOTH_ERROR_ALREADY_DEACTIVATED;
- } else {
- ret = BLUETOOTH_ERROR_INTERNAL;
+ if (result == NULL) {
+ if (err != NULL) {
+ g_dbus_error_strip_remote_error(err);
+ BT_ERR("Network server unregister Error: %s\n", err->message);
+ if (g_strcmp0(err->message,
+ "Operation currently not available") == 0) {
+ ret = BLUETOOTH_ERROR_ALREADY_DEACTIVATED;
+ } else {
+ ret = BLUETOOTH_ERROR_INTERNAL;
+ }
+ g_error_free(err);
}
- g_error_free(err);
+ } else {
+ g_variant_unref(result);
}
+
g_object_unref(server_proxy);
return ret;
int _bt_network_connect(int request_id, int role,
bluetooth_device_address_t *device_address)
{
- const gchar *device_path = NULL;
+ gchar *device_path = NULL;
char address[BT_ADDRESS_STRING_SIZE] = { 0 };
char remote_role[BLUETOOTH_UUID_STRING_MAX] = { 0 };
bt_function_data_t *func_data;
GDBusProxy *adapter_proxy;
GDBusProxy *profile_proxy;
GDBusConnection *conn;
- GVariant *result = NULL;
- GError*err = NULL;
BT_CHECK_PARAMETER(device_address, return);
adapter_proxy = _bt_get_adapter_proxy();
retv_if(adapter_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
- conn = _bt_get_system_gconn();
+ conn = _bt_gdbus_get_system_gconn();
retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
_bt_convert_addr_type_to_string(address, device_address->addr);
- result = g_dbus_proxy_call_sync(adapter_proxy, "FindDevice",
- g_variant_new("(s)", address),
- G_DBUS_CALL_FLAGS_NONE,
- -1, NULL, &err);
- if (result == NULL) {
- BT_ERR("Error occurred in call to FindDevice");
- if (err) {
- BT_ERR("Error: %s", err->message);
- g_clear_error(&err);
- }
- return BLUETOOTH_ERROR_INTERNAL;
- }
-
- device_path = g_variant_get_string(result, NULL);
+ device_path = _bt_get_device_object_path(address);
if (device_path == NULL) {
BT_ERR("No paired device");
- g_variant_unref(result);
return BLUETOOTH_ERROR_NOT_PAIRED;
}
NULL, BT_BLUEZ_NAME,
device_path, BT_NETWORK_CLIENT_INTERFACE, NULL, NULL);
- g_variant_unref(result);
+ g_free(device_path);
retv_if(profile_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
func_data = g_malloc0(sizeof(bt_function_data_t));
-
func_data->address = g_strdup(address);
func_data->req_id = request_id;
int _bt_network_disconnect(int request_id,
bluetooth_device_address_t *device_address)
{
- const gchar *device_path = NULL;
+ gchar *device_path = NULL;
char address[BT_ADDRESS_STRING_SIZE] = { 0 };
bt_function_data_t *func_data;
GDBusProxy *adapter_proxy;
GDBusProxy *profile_proxy;
GDBusConnection *conn;
- GVariant *result = NULL;
- GError*err = NULL;
BT_CHECK_PARAMETER(device_address, return);
adapter_proxy = _bt_get_adapter_proxy();
retv_if(adapter_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
- conn = _bt_get_system_gconn();
+ conn = _bt_gdbus_get_system_gconn();
retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
_bt_convert_addr_type_to_string(address, device_address->addr);
- result = g_dbus_proxy_call_sync(adapter_proxy, "FindDevice",
- g_variant_new("(s)", address),
- G_DBUS_CALL_FLAGS_NONE,
- -1, NULL, &err);
- if (result == NULL) {
- BT_ERR("Error occurred in call to FindDevice");
- if (err) {
- BT_ERR("Error: %s", err->message);
- g_clear_error(&err);
- }
- return BLUETOOTH_ERROR_INTERNAL;
- }
-
- device_path = g_variant_get_string(result, NULL);
+ device_path = _bt_get_device_object_path(address);
if (device_path == NULL) {
BT_ERR("No paired device");
return BLUETOOTH_ERROR_NOT_PAIRED;
NULL, BT_BLUEZ_NAME,
device_path, BT_NETWORK_CLIENT_INTERFACE, NULL, NULL);
- g_variant_unref(result);
+ g_free(device_path);
retv_if(profile_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
func_data = g_malloc0(sizeof(bt_function_data_t));
-
func_data->address = g_strdup(address);
func_data->req_id = request_id;
BT_CHECK_PARAMETER(device_address, return);
- conn = _bt_get_system_gconn();
+ conn = _bt_gdbus_get_system_gconn();
retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
adapter_path = _bt_get_adapter_path();