--- plugins/bluetooth.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 75 insertions(+), 0 deletions(-)
diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c index dcf75e6..0b5a021 100644 --- a/plugins/bluetooth.c +++ b/plugins/bluetooth.c @@ -44,6 +44,43 @@ static GHashTable *adapter_address_hash = NULL; static GSList *server_list = NULL; static gint bluetooth_refcount; +static const gchar *dun_record = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?> \ +<record> \ + <attribute id=\"0x0001\"> \ + <sequence> \ + <uuid value=\"0x1103\"/> \ + </sequence> \ + </attribute> \ + \ + <attribute id=\"0x0004\"> \ + <sequence> \ + <sequence> \ + <uuid value=\"0x0100\"/> \ + </sequence> \ + <sequence> \ + <uuid value=\"0x0003\"/> \ + <uint8 value=\"%u\" name=\"channel\"/> \ + </sequence> \ + <sequence> \ + <uuid value=\"0x0008\"/> \ + </sequence> \ + </sequence> \ + </attribute> \ + \ + <attribute id=\"0x0009\"> \ + <sequence> \ + <sequence> \ + <uuid value=\"0x1103\"/> \ + <uint16 value=\"0x0100\" name=\"version\"/> \ + </sequence> \ + </sequence> \ + </attribute> \ + \ + <attribute id=\"0x0100\"> \ + <text value=\"%s\" name=\"name\"/> \ + </attribute> \ +</record>"; + struct server { guint16 service; gchar *name; @@ -451,12 +488,40 @@ static void new_connection(GIOChannel *io, gpointer user_data) DBG("%p", server); } +static void add_record_cb(DBusPendingCall *call, gpointer user_data) +{ + struct server *server = user_data; + DBusMessage *reply = dbus_pending_call_steal_reply(call); + DBusError derr; + guint32 handle; + + dbus_error_init(&derr); + + if (dbus_set_error_from_message(&derr, reply)) { + ofono_error("Replied with an error: %s, %s", + derr.name, derr.message); + dbus_error_free(&derr); + server_stop(server); + goto done; + } + + dbus_message_get_args(reply, NULL, DBUS_TYPE_UINT32, &handle, + DBUS_TYPE_INVALID); + server->handle = handle; + + ofono_info("Registered: %s, handle: 0x%x", server->name, handle); + +done: + dbus_message_unref(reply); +} + static void server_start(gpointer data, gpointer user_data) { struct server *server = data; char *addr, *path = user_data; bdaddr_t baddr; GError *err = NULL; + gchar *xml; if (server->handle != 0) return; @@ -478,6 +543,16 @@ static void server_start(gpointer data, gpointer user_data) } server->adapter = g_strdup(path); + + xml = g_markup_printf_escaped(dun_record, server->channel, + server->name); + + bluetooth_send_with_reply(path, BLUEZ_SERVICE_INTERFACE, "AddRecord", + add_record_cb, server, NULL, -1, + DBUS_TYPE_STRING, &xml, + DBUS_TYPE_INVALID); + + g_free(xml); } static void adapter_properties_cb(DBusPendingCall *call, gpointer user_data) -- 1.7.4.rc3 _______________________________________________ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono