aboutsummaryrefslogtreecommitdiffstats
path: root/attrib
diff options
context:
space:
mode:
authorClaudio Takahasi <claudio.takahasi@openbossa.org>2010-09-17 17:14:50 -0300
committerAnderson Lizardo <anderson.lizardo@openbossa.org>2010-09-22 15:55:18 -0400
commit8545bdc1eae7c4e4a6ef90c74b3e6c070e3bbe9c (patch)
treed06cf890cc70eea989a85e749553fd6ce1924754 /attrib
parenta5e1be914ba5480f9eae7ab9dc31e30524f74182 (diff)
downloadbluez-8545bdc1eae7c4e4a6ef90c74b3e6c070e3bbe9c.tar.gz
bluez-8545bdc1eae7c4e4a6ef90c74b3e6c070e3bbe9c.tar.xz
bluez-8545bdc1eae7c4e4a6ef90c74b3e6c070e3bbe9c.zip
Add g_attrib_set_destroy_function in gattrib
Add a new function to notify the GAttrib "users" when the GAttrib has beed destroyed. The disconnect function is called only for remote initiated disconnections or external events(not unref).
Diffstat (limited to 'attrib')
-rw-r--r--attrib/gattrib.c18
-rw-r--r--attrib/gattrib.h3
2 files changed, 21 insertions, 0 deletions
diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index 405bd741..bcab5cc0 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -44,7 +44,9 @@ struct _GAttrib {
GSList *events;
guint next_cmd_id;
guint next_evt_id;
+ GDestroyNotify destroy;
GAttribDisconnectFunc disconnect;
+ gpointer destroy_user_data;
gpointer disc_user_data;
};
@@ -188,6 +190,10 @@ void g_attrib_unref(GAttrib *attrib)
g_source_remove(attrib->read_watch);
g_io_channel_unref(attrib->io);
+
+ if (attrib->destroy)
+ attrib->destroy(attrib->destroy_user_data);
+
g_free(attrib);
}
@@ -203,6 +209,18 @@ gboolean g_attrib_set_disconnect_function(GAttrib *attrib,
return TRUE;
}
+gboolean g_attrib_set_destroy_function(GAttrib *attrib,
+ GDestroyNotify destroy, gpointer user_data)
+{
+ if (attrib == NULL)
+ return FALSE;
+
+ attrib->destroy = destroy;
+ attrib->destroy_user_data = user_data;
+
+ return TRUE;
+}
+
static void destroy_receiver(gpointer data)
{
struct _GAttrib *attrib = data;
diff --git a/attrib/gattrib.h b/attrib/gattrib.h
index 011b9da3..4306ca4e 100644
--- a/attrib/gattrib.h
+++ b/attrib/gattrib.h
@@ -47,6 +47,9 @@ void g_attrib_unref(GAttrib *attrib);
gboolean g_attrib_set_disconnect_function(GAttrib *attrib,
GAttribDisconnectFunc disconnect, gpointer user_data);
+gboolean g_attrib_set_destroy_function(GAttrib *attrib,
+ GDestroyNotify destroy, gpointer user_data);
+
guint g_attrib_send(GAttrib *attrib, guint8 opcode, const guint8 *pdu,
guint16 len, GAttribResultFunc func,
gpointer user_data, GDestroyNotify notify);