summaryrefslogtreecommitdiffstats
path: root/src
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
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')
-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 @@
33struct np_thread { 33struct np_thread {
34 np_client_t client; 34 np_client_t client;
35 np_notify_cb_t cbfunc; 35 np_notify_cb_t cbfunc;
36 void *userdata;
36}; 37};
37 38
38/** 39/**
@@ -333,7 +334,7 @@ gpointer np_notifier( gpointer arg )
333 while (npt->client->parent) { 334 while (npt->client->parent) {
334 np_get_notification(npt->client, &notification); 335 np_get_notification(npt->client, &notification);
335 if (notification) { 336 if (notification) {
336 npt->cbfunc(notification); 337 npt->cbfunc(notification, npt->userdata);
337 free(notification); 338 free(notification);
338 notification = NULL; 339 notification = NULL;
339 } 340 }
@@ -355,6 +356,8 @@ gpointer np_notifier( gpointer arg )
355 * @param client the NP client 356 * @param client the NP client
356 * @param notify_cb pointer to a callback function or NULL to de-register a 357 * @param notify_cb pointer to a callback function or NULL to de-register a
357 * previously set callback function. 358 * previously set callback function.
359 * @param userdata Pointer that will be passed to the callback function as
360 * userdata. If notify_cb is NULL, this parameter is ignored.
358 * 361 *
359 * @note Only one callback function can be registered at the same time; 362 * @note Only one callback function can be registered at the same time;
360 * any previously set callback function will be removed automatically. 363 * any previously set callback function will be removed automatically.
@@ -363,7 +366,7 @@ gpointer np_notifier( gpointer arg )
363 * NP_E_INVALID_ARG when client is NULL, or NP_E_UNKNOWN_ERROR when 366 * NP_E_INVALID_ARG when client is NULL, or NP_E_UNKNOWN_ERROR when
364 * the callback thread could no be created. 367 * the callback thread could no be created.
365 */ 368 */
366np_error_t np_set_notify_callback( np_client_t client, np_notify_cb_t notify_cb ) 369np_error_t np_set_notify_callback( np_client_t client, np_notify_cb_t notify_cb, void *userdata )
367{ 370{
368 if (!client) 371 if (!client)
369 return NP_E_INVALID_ARG; 372 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
385 if (npt) { 388 if (npt) {
386 npt->client = client; 389 npt->client = client;
387 npt->cbfunc = notify_cb; 390 npt->cbfunc = notify_cb;
391 npt->userdata = userdata;
388 392
389 client->notifier = g_thread_create(np_notifier, npt, TRUE, NULL); 393 client->notifier = g_thread_create(np_notifier, npt, TRUE, NULL);
390 if (client->notifier) { 394 if (client->notifier) {