linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jose Antonio Santos Cadenas <santoscadenas@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: Jose Antonio Santos Cadenas <santoscadenas@gmail.com>
Subject: [PATCH 11/32] Initial support for connecting instances
Date: Fri,  4 Jun 2010 10:30:04 +0200	[thread overview]
Message-ID: <1275640225-4186-12-git-send-email-santoscadenas@gmail.com> (raw)
In-Reply-To: <1275640225-4186-11-git-send-email-santoscadenas@gmail.com>

---
 health/hdp.c |   62 ++++++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 50 insertions(+), 12 deletions(-)

diff --git a/health/hdp.c b/health/hdp.c
index 8690f0e..8bb6057 100644
--- a/health/hdp.c
+++ b/health/hdp.c
@@ -76,6 +76,16 @@ static struct hdp_device *find_device(GSList *devices, struct btd_device *dev)
 	return NULL;
 }
 
+static int hdp_instance_idcmp(gconstpointer instance, gconstpointer p)
+{
+	const struct hdp_instance *hdpi = instance;
+	const uint32_t *id = p;
+
+	if (hdpi->id == *id)
+		return 0;
+	return -1;
+}
+
 static void append_dict_features(DBusMessageIter *iter, GSList *end_points)
 {
 	DBusMessageIter entry, array;
@@ -225,9 +235,40 @@ static void dev_path_unregister(void *data)
 	health_device_free(device);
 }
 
+static DBusMessage *hdp_connect(DBusConnection *conn,
+					DBusMessage *msg, void *user_data)
+{
+	struct hdp_device *device = user_data;
+	struct hdp_instance *hdpi;
+	uint32_t lid, rid;
+	GSList *l;
+
+	if (!dbus_message_get_args(msg, NULL,
+					DBUS_TYPE_UINT32, &lid,
+					DBUS_TYPE_UINT32, &rid,
+					DBUS_TYPE_INVALID)) {
+		return g_dbus_create_error(msg,
+					ERROR_INTERFACE ".InvalidArguments",
+					"Invalid arguments in method call");
+	}
+
+	l = g_slist_find_custom(device->hdp_adapter->instances, &lid,
+							hdp_instance_idcmp);
+	if (!l)
+		return g_dbus_create_error(msg,
+					   ERROR_INTERFACE ".InvalidArguments",
+					   "Invalid local instance id");
+	hdpi = l->data;
+
+
+	return g_dbus_create_error(msg, ERROR_INTERFACE ".HdpError",
+					"Function is not yet implemented");
+}
+
 static GDBusMethodTable device_methods[] = {
 	{ "GetHealthInstances", "", "aa{sv}", get_health_instances,
 						G_DBUS_METHOD_FLAG_ASYNC },
+	{ "Connect", "uu", "o", hdp_connect, G_DBUS_METHOD_FLAG_ASYNC },
 	{ NULL }
 };
 
@@ -235,33 +276,30 @@ static struct hdp_device *create_health_device(DBusConnection *conn,
 						struct btd_device *device)
 {
 	const gchar *path = device_get_path(device);
+	struct btd_adapter *adapter = device_get_adapter(device);
 	struct hdp_device *dev;
 
 	dev = g_new0(struct hdp_device, 1);
 	dev->conn = dbus_connection_ref(conn);
 	dev->dev = btd_device_ref(device);
+	dev->hdp_adapter = find_adapter(adapters, adapter);
+
+	if (!dev->hdp_adapter)
+		goto fail;
 
 	if (!g_dbus_register_interface(conn, path,
 					HEALTH_DEVICE,
 					device_methods, NULL, NULL,
 					dev, dev_path_unregister)) {
 		error("D-Bus failed to register %s interface", HEALTH_DEVICE);
-		health_device_free(dev);
-		return NULL;
+		goto fail;
 	}
 
 	DBG("Registered interface %s on path %s", HEALTH_DEVICE, path);
 	return dev;
-}
-
-static int hdp_instance_idcmp(gconstpointer instance, gconstpointer p)
-{
-	const struct hdp_instance *hdpi = instance;
-	const uint32_t *id = p;
-
-	if (hdpi->id == *id)
-		return 0;
-	return -1;
+fail:
+	health_device_free(dev);
+	return NULL;
 }
 
 static void hdp_set_instance_id(struct hdp_instance *hdpi)
-- 
1.6.3.3


  reply	other threads:[~2010-06-04  8:30 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-04  8:29 [PATCH 00/32] Health Device Prifile (HDP) -- updated Jose Antonio Santos Cadenas
2010-06-04  8:29 ` [PATCH 01/32] Add Health api description Jose Antonio Santos Cadenas
2010-06-04  8:29   ` [PATCH 02/32] Initial support for HDP Jose Antonio Santos Cadenas
2010-06-04  8:29     ` [PATCH 03/32] Add functions to resiger health instances in SDP Jose Antonio Santos Cadenas
2010-06-04  8:29       ` [PATCH 04/32] Initial support for hdp_device_drivers Jose Antonio Santos Cadenas
2010-06-04  8:29         ` [PATCH 05/32] Register healt_driver interfaces in d-bus Jose Antonio Santos Cadenas
2010-06-04  8:29           ` [PATCH 06/32] Add delete instance petition Jose Antonio Santos Cadenas
2010-06-04  8:30             ` [PATCH 07/32] Add watcher to control client disconections to delete hdp instance Jose Antonio Santos Cadenas
2010-06-04  8:30               ` [PATCH 08/32] Work in getting remote SDP records Jose Antonio Santos Cadenas
2010-06-04  8:30                 ` [PATCH 09/32] Adds functions to get remote suported features from its SDP record Jose Antonio Santos Cadenas
2010-06-04  8:30                   ` [PATCH 10/32] Insert end_point in array returned by get_health_instances Jose Antonio Santos Cadenas
2010-06-04  8:30                     ` Jose Antonio Santos Cadenas [this message]
2010-06-04  8:30                       ` [PATCH 12/32] Complete the response dictionary in GetHealthInstances response Jose Antonio Santos Cadenas
2010-06-04  8:30                         ` [PATCH 13/32] Implement connection of health instances Jose Antonio Santos Cadenas
2010-06-04  8:30                           ` [PATCH 14/32] Manage mcap instances Jose Antonio Santos Cadenas
2010-06-04  8:30                             ` [PATCH 15/32] Implement connect MCL callback in health instances connection Jose Antonio Santos Cadenas
2010-06-04  8:30                               ` [PATCH 16/32] Register Health link int the bus when MCL is connected Jose Antonio Santos Cadenas
2010-06-04  8:30                                 ` [PATCH 17/32] Analize remote record looking for psm Jose Antonio Santos Cadenas
2010-06-04  8:30                                   ` [PATCH 18/32] Unify the creation of health links Jose Antonio Santos Cadenas
2010-06-04  8:30                                     ` [PATCH 19/32] Remove hdp_device pointer from health link struct Jose Antonio Santos Cadenas
2010-06-04  8:30                                       ` [PATCH 20/32] Release health link resources Jose Antonio Santos Cadenas
2010-06-04  8:30                                         ` [PATCH 21/32] Manage mcap disconnections and reconnections Jose Antonio Santos Cadenas
2010-06-04  8:30                                           ` [PATCH 22/32] Initial work for disconnecting health links Jose Antonio Santos Cadenas
2010-06-04  8:30                                             ` [PATCH 23/32] Avoid multiple links with the same device Jose Antonio Santos Cadenas
2010-06-04  8:30                                               ` [PATCH 24/32] Disconnect health link petition Jose Antonio Santos Cadenas
2010-06-04  8:30                                                 ` [PATCH 25/32] Create new structure to manage data channels in HDP Jose Antonio Santos Cadenas
2010-06-04  8:30                                                   ` [PATCH 26/32] Implement connect data channel callback Jose Antonio Santos Cadenas
2010-06-04  8:30                                                     ` [PATCH 27/32] Change function name when retreiving remote SDP records Jose Antonio Santos Cadenas
2010-06-04  8:30                                                       ` [PATCH 28/32] Changed HEALTH_MANAGER_INTERFACE to HEALTH_MANAGER Jose Antonio Santos Cadenas
2010-06-04  8:30                                                         ` [PATCH 29/32] Call the agent when a new Health Link is created Jose Antonio Santos Cadenas
2010-06-04  8:30                                                           ` [PATCH 30/32] Add a test that creates a simple health agent Jose Antonio Santos Cadenas
2010-06-04  8:30                                                             ` [PATCH 31/32] Send MCL disconnect callback to agents Jose Antonio Santos Cadenas
2010-06-04  8:30                                                               ` [PATCH 32/32] Add support for mcl reconnections Jose Antonio Santos Cadenas
  -- strict thread matches above, loose matches on Subject: below --
2010-06-02 13:18 [PATCH 00/32] Health device profile (HDP) Jose Antonio Santos Cadenas
2010-06-02 13:18 ` [PATCH 01/32] Add Health api description Jose Antonio Santos Cadenas
2010-06-02 13:18   ` [PATCH 02/32] Initial support for HDP Jose Antonio Santos Cadenas
2010-06-02 13:18     ` [PATCH 03/32] Add functions to resiger health instances in SDP Jose Antonio Santos Cadenas
2010-06-02 13:19       ` [PATCH 04/32] Initial support for hdp_device_drivers Jose Antonio Santos Cadenas
2010-06-02 13:19         ` [PATCH 05/32] Register healt_driver interfaces in d-bus Jose Antonio Santos Cadenas
2010-06-02 13:19           ` [PATCH 06/32] Add delete instance petition Jose Antonio Santos Cadenas
2010-06-02 13:19             ` [PATCH 07/32] Add watcher to control client disconections to delete hdp instance Jose Antonio Santos Cadenas
2010-06-02 13:19               ` [PATCH 08/32] Work in getting remote SDP records Jose Antonio Santos Cadenas
2010-06-02 13:19                 ` [PATCH 09/32] Adds functions to get remote suported features from its SDP record Jose Antonio Santos Cadenas
2010-06-02 13:19                   ` [PATCH 10/32] Insert end_point in array returned by get_health_instances Jose Antonio Santos Cadenas
2010-06-02 13:19                     ` [PATCH 11/32] Initial support for connecting instances Jose Antonio Santos Cadenas

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=1275640225-4186-12-git-send-email-santoscadenas@gmail.com \
    --to=santoscadenas@gmail.com \
    --cc=linux-bluetooth@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).