summaryrefslogtreecommitdiffstats
path: root/src/preflight.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/preflight.c')
-rw-r--r--src/preflight.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/preflight.c b/src/preflight.c
index 283c6d9..b011344 100644
--- a/src/preflight.c
+++ b/src/preflight.c
@@ -30,11 +30,14 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
30 30
31#include <sys/time.h> 31#include <sys/time.h>
32 32
33#ifdef HAVE_LIBIMOBILEDEVICE
33#include <libimobiledevice/libimobiledevice.h> 34#include <libimobiledevice/libimobiledevice.h>
34#include <libimobiledevice/lockdown.h> 35#include <libimobiledevice/lockdown.h>
35#include <libimobiledevice/notification_proxy.h> 36#include <libimobiledevice/notification_proxy.h>
37#endif
36 38
37#include "preflight.h" 39#include "preflight.h"
40#include "device.h"
38#include "client.h" 41#include "client.h"
39#include "conf.h" 42#include "conf.h"
40#include "log.h" 43#include "log.h"
@@ -65,15 +68,12 @@ static void lockdownd_set_untrusted_host_buid(lockdownd_client_t lockdown)
65 free(system_buid); 68 free(system_buid);
66} 69}
67 70
68static void idevice_callback(const idevice_event_t* event, void* userdata) 71void preflight_device_remove_cb(void *data)
69{ 72{
70 struct cb_data *cbdata = (struct cb_data*)userdata; 73 if (!data)
71 idevice_t dev = cbdata->dev; 74 return;
72 struct idevice_private *_dev = (struct idevice_private*)dev; 75 struct cb_data *cbdata = (struct cb_data*)data;
73 76 cbdata->is_device_connected = 0;
74 if (event->event == IDEVICE_DEVICE_REMOVE && !strcmp(_dev->udid, event->udid)) {
75 cbdata->is_device_connected = 0;
76 }
77} 77}
78 78
79static void np_callback(const char* notification, void* userdata) 79static void np_callback(const char* notification, void* userdata)
@@ -246,7 +246,7 @@ retry:
246 cbdata.is_device_connected = 1; 246 cbdata.is_device_connected = 1;
247 247
248 np_set_notify_callback(np, np_callback, (void*)&cbdata); 248 np_set_notify_callback(np, np_callback, (void*)&cbdata);
249 idevice_event_subscribe(idevice_callback, (void*)&cbdata); 249 device_set_preflight_cb_data(info->id, (void*)&cbdata);
250 250
251 const char* spec[] = { 251 const char* spec[] = {
252 "com.apple.mobile.lockdown.request_pair", 252 "com.apple.mobile.lockdown.request_pair",
@@ -267,8 +267,6 @@ retry:
267 } 267 }
268 usbmuxd_log(LL_INFO, "%s: Finished waiting for notification from device %s, is_device_connected %d", __func__, _dev->udid, cbdata.is_device_connected); 268 usbmuxd_log(LL_INFO, "%s: Finished waiting for notification from device %s, is_device_connected %d", __func__, _dev->udid, cbdata.is_device_connected);
269 269
270 idevice_event_unsubscribe();
271
272 if (cbdata.np) { 270 if (cbdata.np) {
273 np_client_free(cbdata.np); 271 np_client_free(cbdata.np);
274 } 272 }
@@ -326,6 +324,10 @@ leave:
326 324
327 return NULL; 325 return NULL;
328} 326}
327#else
328void preflight_device_remove_cb(void *data)
329{
330}
329#endif 331#endif
330 332
331void preflight_worker_device_add(struct device_info* info) 333void preflight_worker_device_add(struct device_info* info)