diff options
| -rw-r--r-- | dev/ideviceclient.c | 4 | ||||
| -rw-r--r-- | include/libimobiledevice/notification_proxy.h | 4 | ||||
| -rw-r--r-- | src/notification_proxy.c | 8 | ||||
| -rw-r--r-- | tools/idevicebackup.c | 4 |
4 files changed, 12 insertions, 8 deletions
diff --git a/dev/ideviceclient.c b/dev/ideviceclient.c index 2ed93d2..d952594 100644 --- a/dev/ideviceclient.c +++ b/dev/ideviceclient.c | |||
| @@ -30,7 +30,7 @@ | |||
| 30 | #include <libimobiledevice/afc.h> | 30 | #include <libimobiledevice/afc.h> |
| 31 | #include <libimobiledevice/notification_proxy.h> | 31 | #include <libimobiledevice/notification_proxy.h> |
| 32 | 32 | ||
| 33 | static void notifier(const char *notification) | 33 | static void notifier(const char *notification, void *userdata) |
| 34 | { | 34 | { |
| 35 | printf("---------------------------------------------------------\n"); | 35 | printf("---------------------------------------------------------\n"); |
| 36 | printf("------> Notification received: %s\n", notification); | 36 | printf("------> Notification received: %s\n", notification); |
| @@ -118,7 +118,7 @@ int main(int argc, char *argv[]) | |||
| 118 | NULL | 118 | NULL |
| 119 | }; | 119 | }; |
| 120 | np_observe_notifications(gnp, nspec); | 120 | np_observe_notifications(gnp, nspec); |
| 121 | np_set_notify_callback(gnp, notifier); | 121 | np_set_notify_callback(gnp, notifier, NULL); |
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | perform_notification(phone, client, NP_SYNC_WILL_START); | 124 | perform_notification(phone, client, NP_SYNC_WILL_START); |
diff --git a/include/libimobiledevice/notification_proxy.h b/include/libimobiledevice/notification_proxy.h index adbb4cc..4f4c1fd 100644 --- a/include/libimobiledevice/notification_proxy.h +++ b/include/libimobiledevice/notification_proxy.h | |||
| @@ -71,7 +71,7 @@ typedef int16_t np_error_t; | |||
| 71 | struct np_client_int; | 71 | struct np_client_int; |
| 72 | typedef struct np_client_int *np_client_t; | 72 | typedef struct np_client_int *np_client_t; |
| 73 | 73 | ||
| 74 | typedef void (*np_notify_cb_t) (const char *notification); | 74 | typedef void (*np_notify_cb_t) (const char *notification, void *userdata); |
| 75 | 75 | ||
| 76 | /* Interface */ | 76 | /* Interface */ |
| 77 | np_error_t np_client_new(idevice_t device, uint16_t port, np_client_t *client); | 77 | np_error_t np_client_new(idevice_t device, uint16_t port, np_client_t *client); |
| @@ -79,7 +79,7 @@ np_error_t np_client_free(np_client_t client); | |||
| 79 | np_error_t np_post_notification(np_client_t client, const char *notification); | 79 | np_error_t np_post_notification(np_client_t client, const char *notification); |
| 80 | np_error_t np_observe_notification(np_client_t client, const char *notification); | 80 | np_error_t np_observe_notification(np_client_t client, const char *notification); |
| 81 | np_error_t np_observe_notifications(np_client_t client, const char **notification_spec); | 81 | np_error_t np_observe_notifications(np_client_t client, const char **notification_spec); |
| 82 | np_error_t np_set_notify_callback(np_client_t client, np_notify_cb_t notify_cb); | 82 | np_error_t np_set_notify_callback(np_client_t client, np_notify_cb_t notify_cb, void *userdata); |
| 83 | 83 | ||
| 84 | #ifdef __cplusplus | 84 | #ifdef __cplusplus |
| 85 | } | 85 | } |
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 @@ | |||
| 33 | struct np_thread { | 33 | struct 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, ¬ification); | 335 | np_get_notification(npt->client, ¬ification); |
| 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 | */ |
| 366 | np_error_t np_set_notify_callback( np_client_t client, np_notify_cb_t notify_cb ) | 369 | np_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) { |
diff --git a/tools/idevicebackup.c b/tools/idevicebackup.c index d3b3ccc..1984833 100644 --- a/tools/idevicebackup.c +++ b/tools/idevicebackup.c | |||
| @@ -59,7 +59,7 @@ enum device_link_file_status_t { | |||
| 59 | DEVICE_LINK_FILE_STATUS_LAST_HUNK | 59 | DEVICE_LINK_FILE_STATUS_LAST_HUNK |
| 60 | }; | 60 | }; |
| 61 | 61 | ||
| 62 | static void notify_cb(const char *notification) | 62 | static void notify_cb(const char *notification, void *userdata) |
| 63 | { | 63 | { |
| 64 | if (!strcmp(notification, NP_SYNC_CANCEL_REQUEST)) { | 64 | if (!strcmp(notification, NP_SYNC_CANCEL_REQUEST)) { |
| 65 | printf("User has aborted on-device\n"); | 65 | printf("User has aborted on-device\n"); |
| @@ -543,7 +543,7 @@ int main(int argc, char *argv[]) | |||
| 543 | ret = lockdownd_start_service(client, NP_SERVICE_NAME, &port); | 543 | ret = lockdownd_start_service(client, NP_SERVICE_NAME, &port); |
| 544 | if ((ret == LOCKDOWN_E_SUCCESS) && port) { | 544 | if ((ret == LOCKDOWN_E_SUCCESS) && port) { |
| 545 | np_client_new(phone, port, &np); | 545 | np_client_new(phone, port, &np); |
| 546 | np_set_notify_callback(np, notify_cb); | 546 | np_set_notify_callback(np, notify_cb, NULL); |
| 547 | const char *noties[5] = { | 547 | const char *noties[5] = { |
| 548 | NP_SYNC_CANCEL_REQUEST, | 548 | NP_SYNC_CANCEL_REQUEST, |
| 549 | NP_SYNC_SUSPEND_REQUEST, | 549 | NP_SYNC_SUSPEND_REQUEST, |
