Skip to content

Commit 20265e8

Browse files
Ukalninsshazron
authored andcommitted
Fixup API usage to make ios-deploy work also with wifi connections (#385)
* Fixup API usage to make ios-deploy work also with wifi connections * remove best match logic As previous commit fixes debugging over wifi, it is unnecessary to only fallback to wifi if no valid usb devices are found. * remove the unnecessary !found_device
1 parent 0c20374 commit 20265e8

File tree

2 files changed

+91
-133
lines changed

2 files changed

+91
-133
lines changed

src/ios-deploy/MobileDevice.h

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ typedef unsigned int mach_error_t;
6666
typedef unsigned int afc_error_t;
6767
typedef unsigned int usbmux_error_t;
6868
typedef unsigned int service_conn_t;
69+
typedef service_conn_t * ServiceConnRef;
6970

7071
struct am_recovery_device;
7172

@@ -142,6 +143,8 @@ typedef struct afc_connection {
142143
unsigned int context; /* 40 */
143144
} __attribute__ ((packed)) afc_connection;
144145

146+
typedef struct afc_connection * AFCConnectionRef;
147+
145148
typedef struct afc_directory {
146149
unsigned char unknown[0]; /* size unknown */
147150
} __attribute__ ((packed)) afc_directory;
@@ -258,10 +261,10 @@ mach_error_t AMDeviceStartSession(struct am_device *device);
258261
*/
259262

260263
mach_error_t AMDeviceStartService(struct am_device *device, CFStringRef
261-
service_name, service_conn_t *handle, unsigned int *
264+
service_name, ServiceConnRef handle, unsigned int *
262265
unknown);
263266

264-
mach_error_t AMDeviceStartHouseArrestService(struct am_device *device, CFStringRef identifier, void *unknown, service_conn_t *handle, unsigned int *what);
267+
mach_error_t AMDeviceStartHouseArrestService(struct am_device *device, CFStringRef identifier, void *unknown, ServiceConnRef handle, unsigned int *what);
265268

266269
/* Stops a session. You should do this before accessing services.
267270
*
@@ -281,10 +284,10 @@ mach_error_t AMDeviceStopSession(struct am_device *device);
281284
*/
282285

283286
afc_error_t AFCConnectionOpen(service_conn_t handle, unsigned int io_timeout,
284-
struct afc_connection **conn);
287+
AFCConnectionRef *conn);
285288

286289
/* Pass in a pointer to an afc_device_info structure. It will be filled. */
287-
afc_error_t AFCDeviceInfoOpen(afc_connection *conn, struct
290+
afc_error_t AFCDeviceInfoOpen(AFCConnectionRef conn, struct
288291
afc_dictionary **info);
289292

290293
/* Turns debug mode on if the environment variable AFCDEBUG is set to a numeric
@@ -300,7 +303,7 @@ afc_error_t AFCDeviceInfoOpen(afc_connection *conn, struct
300303
* MDERR_OK if successful
301304
*/
302305

303-
afc_error_t AFCDirectoryOpen(afc_connection *conn, const char *path,
306+
afc_error_t AFCDirectoryOpen(AFCConnectionRef conn, const char *path,
304307
struct afc_directory **dir);
305308

306309
/* Acquires the next entry in a directory previously opened with
@@ -313,30 +316,30 @@ afc_error_t AFCDirectoryOpen(afc_connection *conn, const char *path,
313316
* MDERR_OK if successful, even if no entries remain
314317
*/
315318

316-
afc_error_t AFCDirectoryRead(afc_connection *conn/*unsigned int unused*/, struct afc_directory *dir,
319+
afc_error_t AFCDirectoryRead(AFCConnectionRef conn/*unsigned int unused*/, struct afc_directory *dir,
317320
char **dirent);
318321

319-
afc_error_t AFCDirectoryClose(afc_connection *conn, struct afc_directory *dir);
320-
afc_error_t AFCDirectoryCreate(afc_connection *conn, const char *dirname);
321-
afc_error_t AFCRemovePath(afc_connection *conn, const char *dirname);
322-
afc_error_t AFCRenamePath(afc_connection *conn, const char *from, const char *to);
323-
afc_error_t AFCLinkPath(afc_connection *conn, long long int linktype, const char *target, const char *linkname);
322+
afc_error_t AFCDirectoryClose(AFCConnectionRef conn, struct afc_directory *dir);
323+
afc_error_t AFCDirectoryCreate(AFCConnectionRef conn, const char *dirname);
324+
afc_error_t AFCRemovePath(AFCConnectionRef conn, const char *dirname);
325+
afc_error_t AFCRenamePath(AFCConnectionRef conn, const char *from, const char *to);
326+
afc_error_t AFCLinkPath(AFCConnectionRef conn, long long int linktype, const char *target, const char *linkname);
324327

325328
/* Returns the context field of the given AFC connection. */
326-
unsigned int AFCConnectionGetContext(afc_connection *conn);
329+
unsigned int AFCConnectionGetContext(AFCConnectionRef conn);
327330

328331
/* Returns the fs_block_size field of the given AFC connection. */
329-
unsigned int AFCConnectionGetFSBlockSize(afc_connection *conn);
332+
unsigned int AFCConnectionGetFSBlockSize(AFCConnectionRef conn);
330333

331334
/* Returns the io_timeout field of the given AFC connection. In iTunes this is
332335
* 0. */
333-
unsigned int AFCConnectionGetIOTimeout(afc_connection *conn);
336+
unsigned int AFCConnectionGetIOTimeout(AFCConnectionRef conn);
334337

335338
/* Returns the sock_block_size field of the given AFC connection. */
336-
unsigned int AFCConnectionGetSocketBlockSize(afc_connection *conn);
339+
unsigned int AFCConnectionGetSocketBlockSize(AFCConnectionRef conn);
337340

338341
/* Closes the given AFC connection. */
339-
afc_error_t AFCConnectionClose(afc_connection *conn);
342+
afc_error_t AFCConnectionClose(AFCConnectionRef conn);
340343

341344
/* Registers for device notifications related to the restore process. unknown0
342345
* is zero when iTunes calls this. In iTunes,
@@ -392,19 +395,19 @@ CFMutableDictionaryRef AMRestoreCreateDefaultOptions(CFAllocatorRef allocator);
392395
* ------------------------------------------------------------------------- */
393396

394397
/* mode 2 = read, mode 3 = write */
395-
afc_error_t AFCFileRefOpen(afc_connection *conn, const char *path,
398+
afc_error_t AFCFileRefOpen(AFCConnectionRef conn, const char *path,
396399
unsigned long long mode, afc_file_ref *ref);
397-
afc_error_t AFCFileRefSeek(afc_connection *conn, afc_file_ref ref,
400+
afc_error_t AFCFileRefSeek(AFCConnectionRef conn, afc_file_ref ref,
398401
unsigned long long offset1, unsigned long long offset2);
399-
afc_error_t AFCFileRefRead(afc_connection *conn, afc_file_ref ref,
402+
afc_error_t AFCFileRefRead(AFCConnectionRef conn, afc_file_ref ref,
400403
void *buf, size_t *len);
401-
afc_error_t AFCFileRefSetFileSize(afc_connection *conn, afc_file_ref ref,
404+
afc_error_t AFCFileRefSetFileSize(AFCConnectionRef conn, afc_file_ref ref,
402405
unsigned long long offset);
403-
afc_error_t AFCFileRefWrite(afc_connection *conn, afc_file_ref ref,
406+
afc_error_t AFCFileRefWrite(AFCConnectionRef conn, afc_file_ref ref,
404407
const void *buf, size_t len);
405-
afc_error_t AFCFileRefClose(afc_connection *conn, afc_file_ref ref);
408+
afc_error_t AFCFileRefClose(AFCConnectionRef conn, afc_file_ref ref);
406409

407-
afc_error_t AFCFileInfoOpen(afc_connection *conn, const char *path, struct
410+
afc_error_t AFCFileInfoOpen(AFCConnectionRef conn, const char *path, struct
408411
afc_dictionary **info);
409412
afc_error_t AFCKeyValueRead(struct afc_dictionary *dict, char **key, char **
410413
val);

0 commit comments

Comments
 (0)