diff options
| author | 2012-07-04 23:01:21 +0200 | |
|---|---|---|
| committer | 2012-07-04 23:01:21 +0200 | |
| commit | c799d93cfe0a72b451a1ff475b3ea1e639fb843d (patch) | |
| tree | 56bb0a3f6454afbce094b195d74950bd8cfee2aa /libirecovery.c | |
| parent | abcffc26469a8ad6d752f62a39c19107e1a82891 (diff) | |
| download | libirecovery-c799d93cfe0a72b451a1ff475b3ea1e639fb843d.tar.gz libirecovery-c799d93cfe0a72b451a1ff475b3ea1e639fb843d.tar.bz2 | |
implement irecv_set_interface for win32
Diffstat (limited to 'libirecovery.c')
| -rw-r--r-- | libirecovery.c | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/libirecovery.c b/libirecovery.c index 3b839f9..04845ad 100644 --- a/libirecovery.c +++ b/libirecovery.c | |||
| @@ -618,6 +618,21 @@ irecv_error_t irecv_open(irecv_client_t* pclient, unsigned long long ecid) { | |||
| 618 | return IRECV_E_UNABLE_TO_CONNECT; | 618 | return IRECV_E_UNABLE_TO_CONNECT; |
| 619 | #else | 619 | #else |
| 620 | int ret = mobiledevice_connect(pclient, ecid); | 620 | int ret = mobiledevice_connect(pclient, ecid); |
| 621 | if (ret == IRECV_E_SUCCESS) { | ||
| 622 | irecv_client_t client = *pclient; | ||
| 623 | int error = IRECV_E_SUCCESS; | ||
| 624 | if ((client->mode != kDfuMode) && (client->mode != kWTFMode)) { | ||
| 625 | error = irecv_set_interface(client, 0, 0); | ||
| 626 | if (client->mode > kRecoveryMode2) { | ||
| 627 | error = irecv_set_interface(client, 1, 1); | ||
| 628 | } | ||
| 629 | } else { | ||
| 630 | error = irecv_set_interface(client, 0, 0); | ||
| 631 | } | ||
| 632 | if (error != IRECV_E_SUCCESS) { | ||
| 633 | debug("WARNING: set interface failed, error %d\n", error); | ||
| 634 | } | ||
| 635 | } | ||
| 621 | return ret; | 636 | return ret; |
| 622 | #endif | 637 | #endif |
| 623 | } | 638 | } |
| @@ -644,12 +659,12 @@ irecv_error_t irecv_set_configuration(irecv_client_t client, int configuration) | |||
| 644 | 659 | ||
| 645 | irecv_error_t irecv_set_interface(irecv_client_t client, int interface, int alt_interface) { | 660 | irecv_error_t irecv_set_interface(irecv_client_t client, int interface, int alt_interface) { |
| 646 | if (check_context(client) != IRECV_E_SUCCESS) return IRECV_E_NO_DEVICE; | 661 | if (check_context(client) != IRECV_E_SUCCESS) return IRECV_E_NO_DEVICE; |
| 647 | 662 | ||
| 663 | debug("Setting to interface %d:%d\n", interface, alt_interface); | ||
| 648 | #ifndef WIN32 | 664 | #ifndef WIN32 |
| 649 | // pod2g 2011-01-07: we may want to claim multiple interfaces | 665 | // pod2g 2011-01-07: we may want to claim multiple interfaces |
| 650 | //libusb_release_interface(client->handle, client->interface); | 666 | //libusb_release_interface(client->handle, client->interface); |
| 651 | 667 | ||
| 652 | debug("Setting to interface %d:%d\n", interface, alt_interface); | ||
| 653 | if (libusb_claim_interface(client->handle, interface) < 0) { | 668 | if (libusb_claim_interface(client->handle, interface) < 0) { |
| 654 | return IRECV_E_USB_INTERFACE; | 669 | return IRECV_E_USB_INTERFACE; |
| 655 | } | 670 | } |
| @@ -657,10 +672,13 @@ irecv_error_t irecv_set_interface(irecv_client_t client, int interface, int alt_ | |||
| 657 | if (libusb_set_interface_alt_setting(client->handle, interface, alt_interface) < 0) { | 672 | if (libusb_set_interface_alt_setting(client->handle, interface, alt_interface) < 0) { |
| 658 | return IRECV_E_USB_INTERFACE; | 673 | return IRECV_E_USB_INTERFACE; |
| 659 | } | 674 | } |
| 660 | 675 | #else | |
| 676 | if (irecv_control_transfer(client, 0, 0x0B, alt_interface, interface, NULL, 0, USB_TIMEOUT) < 0) { | ||
| 677 | return IRECV_E_USB_INTERFACE; | ||
| 678 | } | ||
| 679 | #endif | ||
| 661 | client->interface = interface; | 680 | client->interface = interface; |
| 662 | client->alt_interface = alt_interface; | 681 | client->alt_interface = alt_interface; |
| 663 | #endif | ||
| 664 | 682 | ||
| 665 | return IRECV_E_SUCCESS; | 683 | return IRECV_E_SUCCESS; |
| 666 | } | 684 | } |
