summaryrefslogtreecommitdiffstats
path: root/src/notification_proxy.c
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2010-03-06 01:26:19 +0100
committerGravatar Matt Colyer2010-03-08 21:09:35 -0800
commit6ceabe1e0a3c107c4b98d38f59f044b8eb7731a0 (patch)
tree701a591e8cd3df615906dc42000e7fa5ea1fba66 /src/notification_proxy.c
parent1d59d15f3b78f26fb231a9bf401ee40cd7b60463 (diff)
downloadlibimobiledevice-6ceabe1e0a3c107c4b98d38f59f044b8eb7731a0.tar.gz
libimobiledevice-6ceabe1e0a3c107c4b98d38f59f044b8eb7731a0.tar.bz2
Add user data parameter to notification callback function
[#114 state:resolved]
Diffstat (limited to 'src/notification_proxy.c')
-rw-r--r--src/notification_proxy.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/notification_proxy.c b/src/notification_proxy.c
index 827468e..41647c8 100644
--- a/src/notification_proxy.c
+++ b/src/notification_proxy.c
@@ -33,6 +33,7 @@
struct np_thread {
np_client_t client;
np_notify_cb_t cbfunc;
+ void *userdata;
};
/**
@@ -333,7 +334,7 @@ gpointer np_notifier( gpointer arg )
while (npt->client->parent) {
np_get_notification(npt->client, &notification);
if (notification) {
- npt->cbfunc(notification);
+ npt->cbfunc(notification, npt->userdata);
free(notification);
notification = NULL;
}
@@ -355,6 +356,8 @@ gpointer np_notifier( gpointer arg )
* @param client the NP client
* @param notify_cb pointer to a callback function or NULL to de-register a
* previously set callback function.
+ * @param userdata Pointer that will be passed to the callback function as
+ * userdata. If notify_cb is NULL, this parameter is ignored.
*
* @note Only one callback function can be registered at the same time;
* any previously set callback function will be removed automatically.
@@ -363,7 +366,7 @@ gpointer np_notifier( gpointer arg )
* NP_E_INVALID_ARG when client is NULL, or NP_E_UNKNOWN_ERROR when
* the callback thread could no be created.
*/
-np_error_t np_set_notify_callback( np_client_t client, np_notify_cb_t notify_cb )
+np_error_t np_set_notify_callback( np_client_t client, np_notify_cb_t notify_cb, void *userdata )
{
if (!client)
return NP_E_INVALID_ARG;
@@ -385,6 +388,7 @@ np_error_t np_set_notify_callback( np_client_t client, np_notify_cb_t notify_cb
if (npt) {
npt->client = client;
npt->cbfunc = notify_cb;
+ npt->userdata = userdata;
client->notifier = g_thread_create(np_notifier, npt, TRUE, NULL);
if (client->notifier) {