From: Jose Antonio Santos Cadenas <santoscadenas@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: "José Antonio Santos Cadenas" <santoscadenas@gmail.com>
Subject: [PATCH 31/32] Send MCL disconnect callback to agents
Date: Fri, 4 Jun 2010 10:30:24 +0200 [thread overview]
Message-ID: <1275640225-4186-32-git-send-email-santoscadenas@gmail.com> (raw)
In-Reply-To: <1275640225-4186-31-git-send-email-santoscadenas@gmail.com>
From: José Antonio Santos Cadenas <santoscadenas@gmail.com>
Whenever a MCL is discoinnected we shall notify to agents using
D-Bus callback.
---
health/hdp.c | 82 +++++++++++++++++++++++++++++++++++++--------------------
1 files changed, 53 insertions(+), 29 deletions(-)
diff --git a/health/hdp.c b/health/hdp.c
index 1fc1cb9..6a73e05 100644
--- a/health/hdp.c
+++ b/health/hdp.c
@@ -393,10 +393,46 @@ static uint8_t hdp_mcap_mdl_reconn_req_cb(struct mcap_mdl *mdl, void *data)
return MCAP_REQUEST_NOT_SUPPORTED;
}
+static void health_link_free(struct hdp_link *hdpl)
+{
+ /*TODO: Release structures related with Data Channels */
+
+ if (hdpl->mcl) {
+ mcap_close_mcl(hdpl->mcl, FALSE);
+ mcap_mcl_unref(hdpl->mcl);
+ }
+
+ if (hdpl->path)
+ g_free(hdpl->path);
+
+ if (hdpl->ndc)
+ g_free(hdpl->ndc);
+
+ g_free(hdpl);
+}
+
+static gboolean agent_mcl_disconnect_msg(struct hdp_link *hdpl)
+{
+ struct hdp_instance *hdpi = hdpl->hdpi;
+ DBusMessage* message;
+
+ message = dbus_message_new_method_call(hdpi->aname, hdpi->apath,
+ HEALTH_AGENT, "LinkDisconnected");
+ if (!message) {
+ error("Couldn't allocate D-Bus message");
+ return FALSE;
+ }
+
+ dbus_message_append_args(message, DBUS_TYPE_OBJECT_PATH, &hdpl->path,
+ DBUS_TYPE_INVALID);
+ return g_dbus_send_message(hdpi->adapter->conn, message);
+}
+
static uint8_t hdp_mcap_mdl_conn_req_cb(struct mcap_mcl *mcl, uint8_t mdepid,
uint16_t mdlid, uint8_t *conf, void *data)
{
struct hdp_link *hdpl = data;
+ struct hdp_instance *hdpi;
struct hdp_supp_fts *f;
struct hdp_dc *dc;
uint8_t new_conf;
@@ -418,7 +454,7 @@ static uint8_t hdp_mcap_mdl_conn_req_cb(struct mcap_mcl *mcl, uint8_t mdepid,
new_conf = HDP_RELIABLE_DC;
break;
case HDP_STREAMING_DC:
- if (g_slist_length(hdpl->channels) == 0)
+ if (!hdpl->channels)
return MCAP_CONFIGURATION_REJECTED;
case HDP_RELIABLE_DC:
if (f->role == HDP_SOURCE)
@@ -427,13 +463,16 @@ static uint8_t hdp_mcap_mdl_conn_req_cb(struct mcap_mcl *mcl, uint8_t mdepid,
break;
default:
/* Special case defined in HDP spec 3.4. When an invalid
- * configuration is received we need close the MCL when
+ * configuration is received we shall close the MCL when
* we are still processing the callback. When MCL is
* closed in a callback the returned value won't be
* proccesed in MCAP */
- /* TODO: Send MCL disconnection to agent */
- g_dbus_unregister_interface(hdpl->hdpi->adapter->conn,
- hdpl->path, HEALTH_LINK);
+ hdpi = hdpl->hdpi;
+ hdpi->hlink = g_slist_remove(hdpi->hlink, hdpl);
+ agent_mcl_disconnect_msg(hdpl);
+ if (!g_dbus_unregister_interface(hdpi->adapter->conn,
+ hdpl->path, HEALTH_LINK))
+ health_link_free(hdpl);
return MCAP_CONFIGURATION_REJECTED; /* not processed */
}
*conf = new_conf;
@@ -447,25 +486,6 @@ static uint8_t hdp_mcap_mdl_conn_req_cb(struct mcap_mcl *mcl, uint8_t mdepid,
return MCAP_SUCCESS;
}
-static void health_link_free(struct hdp_link *hdpl)
-{
- /*TODO: Release structures related with Data Channels */
-
- if (hdpl->mcl) {
- mcap_close_mcl(hdpl->mcl, FALSE);
- mcap_mcl_unref(hdpl->mcl);
- }
-
- if (hdpl->path)
- g_free(hdpl->path);
-
- if (hdpl->ndc)
- g_free(hdpl->ndc);
-
- hdpl->hdpi->hlink = g_slist_remove(hdpl->hdpi->hlink, hdpl);
- g_free(hdpl);
-}
-
static void health_link_path_unregister(void *data)
{
struct hdp_link *hdpl = data;
@@ -696,8 +716,11 @@ static DBusMessage *hdp_disconnect(DBusConnection *conn,
if (cache) {
mcap_close_mcl(hdpl->mcl, cache);
hdpl->closed = TRUE;
- } else
- g_dbus_unregister_interface(conn, hdpl->path, HEALTH_LINK);
+ } else {
+ hdpl->hdpi->hlink = g_slist_remove(hdpl->hdpi->hlink, hdpl);
+ if (!g_dbus_unregister_interface(conn, hdpl->path, HEALTH_LINK))
+ health_link_free(hdpl);
+ }
return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
}
@@ -788,7 +811,6 @@ static void mcl_connected(struct mcap_mcl *mcl, gpointer data)
}
error("D-Bus send failed");
health_link_free(hdpl);
- dbus_message_unref(message);
}
static void mcl_reconnected(struct mcap_mcl *mcl, gpointer data)
@@ -837,8 +859,10 @@ static void mcl_uncached(struct mcap_mcl *mcl, gpointer data)
hdpl = l->data;
hdpi->hlink = g_slist_remove(hdpi->hlink, hdpl);
- g_dbus_unregister_interface(hdpi->adapter->conn, hdpl->path,
- HEALTH_LINK);
+ agent_mcl_disconnect_msg(hdpl);
+ if (!g_dbus_unregister_interface(hdpi->adapter->conn, hdpl->path,
+ HEALTH_LINK))
+ health_link_free(hdpl);
}
static DBusMessage *hdp_create_instance(DBusConnection *conn,
--
1.6.3.3
next prev parent 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 ` [PATCH 11/32] Initial support for connecting instances Jose Antonio Santos Cadenas
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 ` Jose Antonio Santos Cadenas [this message]
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
2010-06-02 13:19 ` [PATCH 12/32] Complete the response dictionary in GetHealthInstances response Jose Antonio Santos Cadenas
2010-06-02 13:19 ` [PATCH 13/32] Implement connection of health instances Jose Antonio Santos Cadenas
2010-06-02 13:19 ` [PATCH 14/32] Manage mcap instances Jose Antonio Santos Cadenas
2010-06-02 13:19 ` [PATCH 15/32] Implement connect MCL callback in health instances connection Jose Antonio Santos Cadenas
2010-06-02 13:19 ` [PATCH 16/32] Register Health link int the bus when MCL is connected Jose Antonio Santos Cadenas
2010-06-02 13:19 ` [PATCH 17/32] Analize remote record looking for psm Jose Antonio Santos Cadenas
2010-06-02 13:19 ` [PATCH 18/32] Unify the creation of health links Jose Antonio Santos Cadenas
2010-06-02 13:19 ` [PATCH 19/32] Remove hdp_device pointer from health link struct Jose Antonio Santos Cadenas
2010-06-02 13:19 ` [PATCH 20/32] Release health link resources Jose Antonio Santos Cadenas
2010-06-02 13:19 ` [PATCH 21/32] Manage mcap disconnections and reconnections Jose Antonio Santos Cadenas
2010-06-02 13:19 ` [PATCH 22/32] Initial work for disconnecting health links Jose Antonio Santos Cadenas
2010-06-02 13:19 ` [PATCH 23/32] Avoid multiple links with the same device Jose Antonio Santos Cadenas
2010-06-02 13:19 ` [PATCH 24/32] Disconnect health link petition Jose Antonio Santos Cadenas
2010-06-02 13:19 ` [PATCH 25/32] Create new structure to manage data channels in HDP Jose Antonio Santos Cadenas
2010-06-02 13:19 ` [PATCH 26/32] Implement connect data channel callback Jose Antonio Santos Cadenas
2010-06-02 13:19 ` [PATCH 27/32] Change function name when retreiving remote SDP records Jose Antonio Santos Cadenas
2010-06-02 13:19 ` [PATCH 28/32] Changed HEALTH_MANAGER_INTERFACE to HEALTH_MANAGER Jose Antonio Santos Cadenas
2010-06-02 13:19 ` [PATCH 29/32] Call the agent when a new Health Link is created Jose Antonio Santos Cadenas
2010-06-02 13:19 ` [PATCH 30/32] Add a test that creates a simple health agent Jose Antonio Santos Cadenas
2010-06-02 13:19 ` [PATCH 31/32] Send MCL disconnect callback to agents 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-32-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).