BT_EXPORT_API int bluetooth_check_adapter(void)
{
+#ifdef __TIZEN_MOBILE__
int ret;
ret = _bt_get_adapter_path(_bt_get_system_gconn(), NULL);
return ret == BLUETOOTH_ERROR_NONE ? BLUETOOTH_ADAPTER_ENABLED :
BLUETOOTH_ADAPTER_DISABLED;
+#else
+ gboolean powered;
+
+ powered = _bt_get_adapter_power(_bt_get_system_gconn());
+
+ return powered == TRUE ? BLUETOOTH_ADAPTER_ENABLED :
+ BLUETOOTH_ADAPTER_DISABLED;
+#endif
}
BT_EXPORT_API int bluetooth_enable_adapter(void)
}
adapter_proxy = dbus_g_proxy_new_for_name(conn, BT_BLUEZ_NAME,
- adapter_path, BT_ADAPTER_INTERFACE);
+ adapter_path, BT_PROPERTIES_INTERFACE);
return adapter_proxy;
}
+gboolean _bt_get_adapter_power(DBusGConnection *conn)
+{
+ DBusGProxy *proxy = NULL;
+ gboolean powered;
+ GValue powered_v = { 0 };
+ GError *err = NULL;
+
+ BT_DBG("+");
+
+ proxy = _bt_get_adapter_proxy(conn);
+ retv_if(proxy == NULL, FALSE);
+
+ if (!dbus_g_proxy_call(proxy, "Get", &err,
+ G_TYPE_STRING, BT_ADAPTER_INTERFACE,
+ G_TYPE_STRING, "Powered",
+ G_TYPE_INVALID,
+ G_TYPE_VALUE, &powered_v,
+ G_TYPE_INVALID)) {
+ if (err != NULL) {
+ BT_ERR("Getting property failed: [%s]\n", err->message);
+ g_error_free(err);
+ }
+ return FALSE;
+ }
+
+ powered = (gboolean)g_value_get_boolean(&powered_v);
+
+ BT_DBG("powered = %d", powered);
+ BT_DBG("-");
+
+ return powered;
+}
+
void _bt_device_path_to_address(const char *device_path, char *device_address)
{
char address[BT_ADDRESS_STRING_SIZE] = { 0 };
#define BT_ADAPTER_INTERFACE "org.bluez.Adapter1"
#define BT_DEVICE_INTERFACE "org.bluez.Device1"
+#define BT_PROPERTIES_INTERFACE "org.freedesktop.DBus.Properties"
+
#define BT_BLUEZ_NAME "org.bluez"
#define BT_DBUS_NAME "org.projectx.bt"
#define BT_SERVICE_PATH "/org/projectx/bt_service"
int _bt_get_adapter_path(DBusGConnection *g_conn, char *path);
+gboolean _bt_get_adapter_power(DBusGConnection *conn);
+
DBusGProxy *_bt_get_adapter_proxy(DBusGConnection *conn);
void _bt_device_path_to_address(const char *device_path, char *device_address);