summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Georg <mail@jensge.org>2013-11-30 16:04:09 +0100
committerJens Georg <mail@jensge.org>2014-05-24 18:08:46 +0200
commit9ffedf49b5793429c27ca0e8aa124b6438dbfc33 (patch)
tree187ca41bc1385a17a64d7adcb3c6451d92da5832
parentc186160360358eeee069766bcf65447996cf6e25 (diff)
downloadgupnp-9ffedf49b5793429c27ca0e8aa124b6438dbfc33.tar.gz
Add _add_notify_full variant with a GDestroyNotify
This is to help introspection with the call-back. https://bugzilla.gnome.org/show_bug.cgi?id=701446
-rw-r--r--doc/gupnp-sections.txt1
-rw-r--r--libgupnp/gupnp-service-proxy.c44
-rw-r--r--libgupnp/gupnp-service-proxy.h8
-rw-r--r--vala/GUPnP-1.0.metadata1
4 files changed, 52 insertions, 2 deletions
diff --git a/doc/gupnp-sections.txt b/doc/gupnp-sections.txt
index 70f2c37..7b3ff1c 100644
--- a/doc/gupnp-sections.txt
+++ b/doc/gupnp-sections.txt
@@ -85,6 +85,7 @@ gupnp_service_proxy_end_action_hash
gupnp_service_proxy_end_action_list
gupnp_service_proxy_cancel_action
gupnp_service_proxy_add_notify
+gupnp_service_proxy_add_notify_full
gupnp_service_proxy_remove_notify
gupnp_service_proxy_set_subscribed
gupnp_service_proxy_get_subscribed
diff --git a/libgupnp/gupnp-service-proxy.c b/libgupnp/gupnp-service-proxy.c
index ed8cc6c..c0bbcfe 100644
--- a/libgupnp/gupnp-service-proxy.c
+++ b/libgupnp/gupnp-service-proxy.c
@@ -102,6 +102,7 @@ typedef struct {
typedef struct {
GUPnPServiceProxyNotifyCallback callback;
+ GDestroyNotify notify;
gpointer user_data;
} CallbackData;
@@ -136,6 +137,9 @@ gupnp_service_proxy_action_free (GUPnPServiceProxyAction *action)
static void
callback_data_free (CallbackData *data)
{
+ if (data->notify)
+ data->notify (data->user_data);
+
g_slice_free (CallbackData, data);
}
@@ -1575,7 +1579,7 @@ gupnp_service_proxy_cancel_action (GUPnPServiceProxy *proxy,
}
/**
- * gupnp_service_proxy_add_notify:
+ * gupnp_service_proxy_add_notify: (skip)
* @proxy: A #GUPnPServiceProxy
* @variable: The variable to add notification for
* @type: The type of the variable
@@ -1593,6 +1597,40 @@ gupnp_service_proxy_add_notify (GUPnPServiceProxy *proxy,
GType type,
GUPnPServiceProxyNotifyCallback callback,
gpointer user_data)
+
+{
+ return gupnp_service_proxy_add_notify_full (proxy,
+ variable,
+ type,
+ callback,
+ user_data,
+ NULL);
+}
+
+/**
+ * gupnp_service_proxy_add_notify_full:
+ * @proxy: A #GUPnPServiceProxy
+ * @variable: The variable to add notification for
+ * @type: The type of the variable
+ * @callback: (scope notified): The callback to call when @variable changes
+ * @user_data: User data for @callback
+ * @notify: (allow-none): Function to call when the notification is removed, or %NULL
+ *
+ * Sets up @callback to be called whenever a change notification for
+ * @variable is recieved.
+ *
+ * Since: 0.20.9
+ *
+ * Return value: %TRUE on success.
+ * Rename to: gupnp_service_proxy_add_notify
+ **/
+gboolean
+gupnp_service_proxy_add_notify_full (GUPnPServiceProxy *proxy,
+ const char *variable,
+ GType type,
+ GUPnPServiceProxyNotifyCallback callback,
+ gpointer user_data,
+ GDestroyNotify notify)
{
NotifyData *data;
CallbackData *callback_data;
@@ -1633,6 +1671,7 @@ gupnp_service_proxy_add_notify (GUPnPServiceProxy *proxy,
callback_data->callback = callback;
callback_data->user_data = user_data;
+ callback_data->notify = notify;
data->callbacks = g_list_append (data->callbacks, callback_data);
@@ -1691,8 +1730,9 @@ gupnp_service_proxy_remove_notify (GUPnPServiceProxy *proxy,
if (callback_data->callback == callback &&
callback_data->user_data == user_data) {
+
/* Gotcha! */
- g_slice_free (CallbackData, callback_data);
+ callback_data_free (callback_data);
if (data->next_emit == l)
data->next_emit = data->next_emit->next;
diff --git a/libgupnp/gupnp-service-proxy.h b/libgupnp/gupnp-service-proxy.h
index 6444c3f..47bf442 100644
--- a/libgupnp/gupnp-service-proxy.h
+++ b/libgupnp/gupnp-service-proxy.h
@@ -227,6 +227,14 @@ gupnp_service_proxy_add_notify (GUPnPServiceProxy *proxy,
gpointer user_data);
gboolean
+gupnp_service_proxy_add_notify_full (GUPnPServiceProxy *proxy,
+ const char *variable,
+ GType type,
+ GUPnPServiceProxyNotifyCallback callback,
+ gpointer user_data,
+ GDestroyNotify notify);
+
+gboolean
gupnp_service_proxy_remove_notify (GUPnPServiceProxy *proxy,
const char *variable,
GUPnPServiceProxyNotifyCallback callback,
diff --git a/vala/GUPnP-1.0.metadata b/vala/GUPnP-1.0.metadata
index a8ab94c..ee4dc8c 100644
--- a/vala/GUPnP-1.0.metadata
+++ b/vala/GUPnP-1.0.metadata
@@ -23,6 +23,7 @@ ServiceIntrospection
.get_state_variable nullable=true unowned=true
.scpd skip
ServiceProxy
+ .add_notify skip=false
.begin_action skip=false
.end_action_hash skip
.end_action_list skip