DevManager::DevManager (QObject *parent) : QObject (parent) { idevice_event_subscribe ([] (const idevice_event_t*, void *mgr) { Util::ExecuteLater ([mgr] { static_cast<DevManager*> (mgr)->refresh (); }); }, this); }
FB::variant ibrowserAPI::setIdeviceEventCallback(const FB::JSObjectPtr& callback,F_ADD) { Callback *cb = new Callback(); cb->set("callback",callback); if(IDEVICE_E_SUCCESS != idevice_event_subscribe(&ibrowserAPI::ideviceEventCallback, (void *)cb)) ERRO("idevice_event_subscribe"); return true; }
DevManager::DevManager (QObject *parent) : QObject (parent) { idevice_event_subscribe ([] (const idevice_event_t*, void *mgr) { QTimer::singleShot (0, static_cast<DevManager*> (mgr), SLOT (refresh ())); }, this); }
int restore_open_with_timeout(const char* uuid, idevice_t* device, restored_client_t* restore) { int i = 0; int attempts = 10; idevice_t context = NULL; restored_client_t client = NULL; idevice_error_t device_error = IDEVICE_E_SUCCESS; restored_error_t restore_error = RESTORE_E_SUCCESS; *device = NULL; *restore = NULL; device_error = idevice_event_subscribe(&restore_device_callback, NULL); if (device_error != IDEVICE_E_SUCCESS) { error("ERROR: Unable to subscribe to device events\n"); return -1; } for (i = 1; i <= attempts; i++) { if (restore_device_connected == 1) { break; } if (i == attempts) { error("ERROR: Unable to connect to device in restore mode\n"); } sleep(2); } device_error = idevice_new(&context, uuid); if (device_error != IDEVICE_E_SUCCESS) { return -1; } restore_error = restored_client_new(context, &client, "idevicerestore"); if (restore_error != RESTORE_E_SUCCESS) { idevice_event_unsubscribe(); idevice_free(context); return -1; } restore_error = restored_query_type(client, NULL, NULL); if (restore_error != RESTORE_E_SUCCESS) { restored_client_free(client); idevice_event_unsubscribe(); idevice_free(context); return -1; } *device = context; *restore = client; return 0; }
SWIGEXPORT jshort JNICALL Java_org_robovm_libimobiledevice_binding_libimobiledeviceJNI_idevice_1event_1subscribe(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2) { jshort jresult = 0 ; idevice_event_cb_t arg1 = (idevice_event_cb_t) 0 ; void *arg2 = (void *) 0 ; idevice_error_t result; (void)jenv; (void)jcls; arg1 = *(idevice_event_cb_t *)&jarg1; arg2 = *(void **)&jarg2; result = (idevice_error_t)idevice_event_subscribe(arg1,arg2); jresult = (jshort)result; return jresult; }
static void idevice_wait_for_operation_to_complete() { struct timespec ts; ts.tv_sec = 0; ts.tv_nsec = 500000000; is_device_connected = 1; /* subscribe to make sure to exit on device removal */ idevice_event_subscribe(idevice_event_callback, NULL); /* wait for operation to complete */ while (wait_for_op_complete && !op_completed && !err_occured && !notified && is_device_connected) { nanosleep(&ts, NULL); } /* wait some time if a notification is expected */ while (notification_expected && !notified && !err_occured && is_device_connected) { nanosleep(&ts, NULL); } idevice_event_unsubscribe(); }
int main(int argc, char *argv[]) { int i; signal(SIGINT, clean_exit); signal(SIGTERM, clean_exit); #ifndef WIN32 signal(SIGQUIT, clean_exit); signal(SIGPIPE, SIG_IGN); #endif /* parse cmdline args */ for (i = 1; i < argc; i++) { if (!strcmp(argv[i], "-d") || !strcmp(argv[i], "--debug")) { idevice_set_debug_level(1); continue; } else if (!strcmp(argv[i], "-u") || !strcmp(argv[i], "--udid")) { i++; if (!argv[i] || (strlen(argv[i]) != 40)) { print_usage(argc, argv); return 0; } udid = _strdup(argv[i]); continue; } else if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) { print_usage(argc, argv); return 0; } else { print_usage(argc, argv); return 0; } } int num = 0; char **devices = NULL; idevice_get_device_list(&devices, &num); idevice_device_list_free(devices); if (num == 0) { if (!udid) { fprintf(stderr, "No device found. Plug in a device or pass UDID with -u to wait for device to be available.\n"); return -1; } else { fprintf(stderr, "Waiting for device with UDID %s to become available...\n", udid); } } idevice_event_subscribe(device_event_cb, NULL); while (!quit_flag) { sleep(1); } idevice_event_unsubscribe(); stop_logging(); if (udid) { free(udid); } return 0; }
void iLister::Init() { idevice_event_subscribe(&EventCallback, reinterpret_cast<void*>(this)); }
int normal_open_with_timeout(struct idevicerestore_client_t* client) { int i = 0; int attempts = 10; idevice_t device = NULL; lockdownd_client_t lockdownd = NULL; idevice_error_t device_error = IDEVICE_E_SUCCESS; lockdownd_error_t lockdownd_error = LOCKDOWN_E_SUCCESS; // no context exists so bail if(client == NULL) { return -1; } // create our normal client if it doesn't yet exist if(client->normal == NULL) { client->normal = (struct normal_client_t*) malloc(sizeof(struct normal_client_t)); if(client->normal == NULL) { error("ERROR: Out of memory\n"); return -1; } } device_error = idevice_event_subscribe(&normal_device_callback, NULL); if (device_error != IDEVICE_E_SUCCESS) { error("ERROR: Unable to subscribe to device events\n"); return -1; } for (i = 1; i <= attempts; i++) { if (normal_device_connected == 1) { break; } if (i == attempts) { error("ERROR: Unable to connect to device in normal mode\n"); return -1; } sleep(2); } device_error = idevice_new(&device, client->uuid); if (device_error != IDEVICE_E_SUCCESS) { return -1; } lockdownd_error = lockdownd_client_new(device, &lockdownd, "idevicerestore"); if (lockdownd_error != LOCKDOWN_E_SUCCESS) { //idevice_event_unsubscribe(); idevice_free(device); return -1; } char* type = NULL; lockdownd_error = lockdownd_query_type(lockdownd, &type); if (lockdownd_error != LOCKDOWN_E_SUCCESS) { lockdownd_client_free(lockdownd); //idevice_event_unsubscribe(); idevice_free(device); return -1; } client->normal->device = device; client->normal->client = lockdownd; return 0; }