+static void bluetooth_remove(struct connman_device *device)
+{
+ DBG("device %p", device);
+}
+
+static void powered_reply(DBusPendingCall *call, void *user_data)
+{
+ DBusError error;
+ DBusMessage *reply;
+
+ DBG("");
+
+ reply = dbus_pending_call_steal_reply(call);
+
+ dbus_error_init(&error);
+
+ if (dbus_set_error_from_message(&error, reply) == TRUE) {
+ connman_error("%s", error.message);
+ dbus_error_free(&error);
+ dbus_message_unref(reply);
+ dbus_pending_call_unref(call);
+ return;
+ }
+
+ dbus_message_unref(reply);
+ dbus_pending_call_unref(call);
+
+ add_adapter(connection, user_data);
+}
+
+static int change_powered(DBusConnection *connection, const char *path,
+ dbus_bool_t powered)
+{
+ DBusMessage *message;
+ DBusMessageIter iter;
+ DBusPendingCall *call;
+
+ DBG("");
+
+ if (path == NULL)
+ return -EINVAL;
+
+ message = dbus_message_new_method_call(BLUEZ_SERVICE, path,
+ BLUEZ_ADAPTER_INTERFACE, SET_PROPERTY);
+ if (message == NULL)
+ return -ENOMEM;
+
+ dbus_message_set_auto_start(message, FALSE);
+
+ dbus_message_iter_init_append(message, &iter);
+ connman_dbus_property_append_basic(&iter, "Powered",
+ DBUS_TYPE_BOOLEAN, &powered);
+
+ if (dbus_connection_send_with_reply(connection, message,
+ &call, TIMEOUT) == FALSE) {
+ connman_error("Failed to change Powered property");
+ dbus_message_unref(message);
+ return -EINVAL;
+ }
+
+ if (call == NULL) {
+ connman_error("D-Bus connection not available");
+ dbus_message_unref(message);
+ return -EINVAL;
+ }
+
+ dbus_pending_call_set_notify(call, powered_reply,
+ g_strdup(path), g_free);
+
+ dbus_message_unref(message);
+
+ return -EINPROGRESS;
+}
+
+static int bluetooth_enable(struct connman_device *device)
+{
+ const char *path = connman_device_get_string(device, "Path");
+
+ DBG("device %p", device);
+
+ return change_powered(connection, path, TRUE);
+}
+
+static int bluetooth_disable(struct connman_device *device)
+{
+ const char *path = connman_device_get_string(device, "Path");
+
+ DBG("device %p", device);
+
+ return change_powered(connection, path, FALSE);
+}
+
+static struct connman_device_driver bluetooth_driver = {
+ .name = "bluetooth",
+ .type = CONNMAN_DEVICE_TYPE_BLUETOOTH,
+ .probe = bluetooth_probe,
+ .remove = bluetooth_remove,
+ .enable = bluetooth_enable,
+ .disable = bluetooth_disable,
+};
+
+static int tech_probe(struct connman_technology *technology)
+{
+ return 0;
+}
+
+static void tech_remove(struct connman_technology *technology)
+{
+}
+
+static void server_register_reply(DBusPendingCall *call, void *user_data)
+{
+ struct connman_technology *technology = user_data;
+ DBusError error;
+ DBusMessage *reply;
+
+ DBG("");
+
+ reply = dbus_pending_call_steal_reply(call);
+
+ dbus_error_init(&error);
+
+ if (dbus_set_error_from_message(&error, reply) == TRUE) {
+ connman_error("%s", error.message);
+ dbus_error_free(&error);
+ dbus_message_unref(reply);
+ dbus_pending_call_unref(call);
+ return;
+ }
+
+ dbus_message_unref(reply);
+ dbus_pending_call_unref(call);
+
+ connman_technology_tethering_notify(technology, TRUE);
+}
+
+static void server_unregister_reply(DBusPendingCall *call, void *user_data)
+{
+ struct connman_technology *technology = user_data;
+ DBusError error;
+ DBusMessage *reply;
+
+ DBG("");
+
+ reply = dbus_pending_call_steal_reply(call);
+
+ dbus_error_init(&error);
+
+ if (dbus_set_error_from_message(&error, reply) == TRUE) {
+ connman_error("%s", error.message);
+ dbus_error_free(&error);
+ dbus_message_unref(reply);
+ dbus_pending_call_unref(call);
+ return;
+ }
+
+ dbus_message_unref(reply);
+ dbus_pending_call_unref(call);
+
+ connman_technology_tethering_notify(technology, FALSE);
+}
+
+
+static void server_register(const char *path, const char *uuid,
+ struct connman_technology *technology,
+ const char *bridge, connman_bool_t enabled)
+{
+ DBusMessage *message;
+ DBusPendingCall *call;
+ char *command;
+
+ DBG("path %s enabled %d", path, enabled);
+
+ command = enabled ? REGISTER : UNREGISTER;
+
+ message = dbus_message_new_method_call(BLUEZ_SERVICE, path,
+ BLUEZ_NETWORK_SERVER, command);
+ if (message == NULL)
+ return;
+
+ dbus_message_set_auto_start(message, FALSE);
+
+ dbus_message_append_args(message, DBUS_TYPE_STRING, &uuid,