All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gustavo F. Padovan <padovan@profusion.mobi>
To: ofono@ofono.org
Subject: [PATCH 2/8] bluetooth: add support to register Bluetooth Service
Date: Mon, 31 Jan 2011 18:51:56 -0200	[thread overview]
Message-ID: <1296507122-10936-2-git-send-email-padovan@profusion.mobi> (raw)
In-Reply-To: <1296507122-10936-1-git-send-email-padovan@profusion.mobi>

[-- Attachment #1: Type: text/plain, Size: 3219 bytes --]

---
 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


  reply	other threads:[~2011-01-31 20:51 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-31 20:51 [PATCH 1/8] bluetooth: add server support Gustavo F. Padovan
2011-01-31 20:51 ` Gustavo F. Padovan [this message]
2011-01-31 20:51   ` [PATCH 3/8] bluetooth: add Request auth code for new connections Gustavo F. Padovan
2011-01-31 20:51     ` [PATCH 4/8] include: add public headed to emulator atom Gustavo F. Padovan
2011-01-31 20:51       ` [PATCH 5/8] emulator: Add emulator atom in oFono Gustavo F. Padovan
2011-01-31 20:52         ` [PATCH 6/8] dun_gw: Add DUN server plugin for oFono Gustavo F. Padovan
2011-01-31 20:52           ` [PATCH 7/8] emulator: Implement dialing up for DUN Gustavo F. Padovan
2011-01-31 20:52             ` [PATCH 8/8] gsmdial: add option for Bluetooth DUN dialing Gustavo F. Padovan
2011-02-01 14:25   ` [PATCH 2/8] bluetooth: add support to register Bluetooth Service Frederic Danis
2011-02-01 14:17 ` [PATCH 1/8] bluetooth: add server support Frederic Danis
2011-02-02 18:21   ` Gustavo F. Padovan
2011-02-03 15:56     ` Frederic Danis
2011-02-03 16:30       ` Gustavo F. Padovan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1296507122-10936-2-git-send-email-padovan@profusion.mobi \
    --to=padovan@profusion.mobi \
    --cc=ofono@ofono.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.