diff options
| author | 2009-09-10 13:28:13 +0200 | |
|---|---|---|
| committer | 2009-09-12 11:41:38 +0200 | |
| commit | 1f6282ffddec7012df82fa929dfe72cfc74b063a (patch) | |
| tree | 452c927c07806855f360ee9803111a1f72e05d3c /src/NotificationProxy.c | |
| parent | 26ce10634d277df51c4e9c2bd61b409df3f5b060 (diff) | |
| download | libimobiledevice-1f6282ffddec7012df82fa929dfe72cfc74b063a.tar.gz libimobiledevice-1f6282ffddec7012df82fa929dfe72cfc74b063a.tar.bz2 | |
Public API rework, extension and adaption to latest libusbmuxd-1.0 API.
Diffstat (limited to 'src/NotificationProxy.c')
| -rw-r--r-- | src/NotificationProxy.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/NotificationProxy.c b/src/NotificationProxy.c index e4735cc..da636ab 100644 --- a/src/NotificationProxy.c +++ b/src/NotificationProxy.c | |||
| @@ -83,9 +83,9 @@ static np_error_t np_plist_send(np_client_t client, plist_t dict) | |||
| 83 | } | 83 | } |
| 84 | 84 | ||
| 85 | nlen = htonl(length); | 85 | nlen = htonl(length); |
| 86 | usbmuxd_send(client->sfd, (const char*)&nlen, sizeof(nlen), (uint32_t*)&bytes); | 86 | iphone_device_send(client->connection, (const char*)&nlen, sizeof(nlen), (uint32_t*)&bytes); |
| 87 | if (bytes == sizeof(nlen)) { | 87 | if (bytes == sizeof(nlen)) { |
| 88 | usbmuxd_send(client->sfd, XML_content, length, (uint32_t*)&bytes); | 88 | iphone_device_send(client->connection, XML_content, length, (uint32_t*)&bytes); |
| 89 | if (bytes > 0) { | 89 | if (bytes > 0) { |
| 90 | if ((uint32_t)bytes == length) { | 90 | if ((uint32_t)bytes == length) { |
| 91 | res = NP_E_SUCCESS; | 91 | res = NP_E_SUCCESS; |
| @@ -121,13 +121,13 @@ np_error_t np_client_new(iphone_device_t device, int dst_port, np_client_t *clie | |||
| 121 | return NP_E_INVALID_ARG; | 121 | return NP_E_INVALID_ARG; |
| 122 | 122 | ||
| 123 | /* Attempt connection */ | 123 | /* Attempt connection */ |
| 124 | int sfd = usbmuxd_connect(device->handle, dst_port); | 124 | iphone_connection_t connection = NULL; |
| 125 | if (sfd < 0) { | 125 | if (iphone_device_connect(device, dst_port, &connection) != IPHONE_E_SUCCESS) { |
| 126 | return NP_E_UNKNOWN_ERROR; | 126 | return NP_E_UNKNOWN_ERROR; |
| 127 | } | 127 | } |
| 128 | 128 | ||
| 129 | np_client_t client_loc = (np_client_t) malloc(sizeof(struct np_client_int)); | 129 | np_client_t client_loc = (np_client_t) malloc(sizeof(struct np_client_int)); |
| 130 | client_loc->sfd = sfd; | 130 | client_loc->connection = connection; |
| 131 | 131 | ||
| 132 | client_loc->mutex = g_mutex_new(); | 132 | client_loc->mutex = g_mutex_new(); |
| 133 | 133 | ||
| @@ -146,8 +146,8 @@ np_error_t np_client_free(np_client_t client) | |||
| 146 | if (!client) | 146 | if (!client) |
| 147 | return NP_E_INVALID_ARG; | 147 | return NP_E_INVALID_ARG; |
| 148 | 148 | ||
| 149 | usbmuxd_disconnect(client->sfd); | 149 | iphone_device_disconnect(client->connection); |
| 150 | client->sfd = -1; | 150 | client->connection = NULL; |
| 151 | if (client->notifier) { | 151 | if (client->notifier) { |
| 152 | log_debug_msg("joining np callback\n"); | 152 | log_debug_msg("joining np callback\n"); |
| 153 | g_thread_join(client->notifier); | 153 | g_thread_join(client->notifier); |
| @@ -293,12 +293,12 @@ static int np_get_notification(np_client_t client, char **notification) | |||
| 293 | char *XML_content = NULL; | 293 | char *XML_content = NULL; |
| 294 | plist_t dict = NULL; | 294 | plist_t dict = NULL; |
| 295 | 295 | ||
| 296 | if (!client || client->sfd < 0 || *notification) | 296 | if (!client || !client->connection || *notification) |
| 297 | return -1; | 297 | return -1; |
| 298 | 298 | ||
| 299 | np_lock(client); | 299 | np_lock(client); |
| 300 | 300 | ||
| 301 | usbmuxd_recv_timeout(client->sfd, (char*)&pktlen, sizeof(pktlen), &bytes, 500); | 301 | iphone_device_recv_timeout(client->connection, (char*)&pktlen, sizeof(pktlen), &bytes, 500); |
| 302 | log_debug_msg("NotificationProxy: initial read=%i\n", bytes); | 302 | log_debug_msg("NotificationProxy: initial read=%i\n", bytes); |
| 303 | if (bytes < 4) { | 303 | if (bytes < 4) { |
| 304 | log_debug_msg("NotificationProxy: no notification received!\n"); | 304 | log_debug_msg("NotificationProxy: no notification received!\n"); |
| @@ -310,7 +310,7 @@ static int np_get_notification(np_client_t client, char **notification) | |||
| 310 | XML_content = (char*)malloc(pktlen); | 310 | XML_content = (char*)malloc(pktlen); |
| 311 | log_debug_msg("pointer %p\n", XML_content); | 311 | log_debug_msg("pointer %p\n", XML_content); |
| 312 | 312 | ||
| 313 | usbmuxd_recv_timeout(client->sfd, XML_content, pktlen, &bytes, 1000); | 313 | iphone_device_recv_timeout(client->connection, XML_content, pktlen, &bytes, 1000); |
| 314 | if (bytes <= 0) { | 314 | if (bytes <= 0) { |
| 315 | res = -1; | 315 | res = -1; |
| 316 | } else { | 316 | } else { |
| @@ -390,7 +390,7 @@ gpointer np_notifier( gpointer arg ) | |||
| 390 | if (!npt) return NULL; | 390 | if (!npt) return NULL; |
| 391 | 391 | ||
| 392 | log_debug_msg("%s: starting callback.\n", __func__); | 392 | log_debug_msg("%s: starting callback.\n", __func__); |
| 393 | while (npt->client->sfd >= 0) { | 393 | while (npt->client->connection) { |
| 394 | np_get_notification(npt->client, ¬ification); | 394 | np_get_notification(npt->client, ¬ification); |
| 395 | if (notification) { | 395 | if (notification) { |
| 396 | npt->cbfunc(notification); | 396 | npt->cbfunc(notification); |
| @@ -429,11 +429,11 @@ np_error_t np_set_notify_callback( np_client_t client, np_notify_cb_t notify_cb | |||
| 429 | np_lock(client); | 429 | np_lock(client); |
| 430 | if (client->notifier) { | 430 | if (client->notifier) { |
| 431 | log_debug_msg("%s: callback already set, removing\n"); | 431 | log_debug_msg("%s: callback already set, removing\n"); |
| 432 | int conn = client->sfd; | 432 | iphone_connection_t conn = client->connection; |
| 433 | client->sfd = -1; | 433 | client->connection = NULL; |
| 434 | g_thread_join(client->notifier); | 434 | g_thread_join(client->notifier); |
| 435 | client->notifier = NULL; | 435 | client->notifier = NULL; |
| 436 | client->sfd = conn; | 436 | client->connection = conn; |
| 437 | } | 437 | } |
| 438 | 438 | ||
| 439 | if (notify_cb) { | 439 | if (notify_cb) { |
