diff options
Diffstat (limited to 'tools/idevicebackup.c')
| -rw-r--r-- | tools/idevicebackup.c | 54 |
1 files changed, 37 insertions, 17 deletions
diff --git a/tools/idevicebackup.c b/tools/idevicebackup.c index abd269a..95c5694 100644 --- a/tools/idevicebackup.c +++ b/tools/idevicebackup.c | |||
| @@ -745,7 +745,7 @@ static int mobilebackup_check_file_integrity(const char *backup_directory, const | |||
| 745 | 745 | ||
| 746 | static void do_post_notification(const char *notification) | 746 | static void do_post_notification(const char *notification) |
| 747 | { | 747 | { |
| 748 | uint16_t nport = 0; | 748 | lockdownd_service_descriptor_t service = NULL; |
| 749 | np_client_t np; | 749 | np_client_t np; |
| 750 | 750 | ||
| 751 | if (!client) { | 751 | if (!client) { |
| @@ -754,9 +754,9 @@ static void do_post_notification(const char *notification) | |||
| 754 | } | 754 | } |
| 755 | } | 755 | } |
| 756 | 756 | ||
| 757 | lockdownd_start_service(client, NP_SERVICE_NAME, &nport); | 757 | lockdownd_start_service(client, NP_SERVICE_NAME, &service); |
| 758 | if (nport) { | 758 | if (service->port) { |
| 759 | np_client_new(device, nport, &np); | 759 | np_client_new(device, service, &np); |
| 760 | if (np) { | 760 | if (np) { |
| 761 | np_post_notification(np, notification); | 761 | np_post_notification(np, notification); |
| 762 | np_client_free(np); | 762 | np_client_free(np); |
| @@ -764,6 +764,11 @@ static void do_post_notification(const char *notification) | |||
| 764 | } else { | 764 | } else { |
| 765 | printf("Could not start %s\n", NP_SERVICE_NAME); | 765 | printf("Could not start %s\n", NP_SERVICE_NAME); |
| 766 | } | 766 | } |
| 767 | |||
| 768 | if (service) { | ||
| 769 | lockdownd_service_descriptor_free(service); | ||
| 770 | service = NULL; | ||
| 771 | } | ||
| 767 | } | 772 | } |
| 768 | 773 | ||
| 769 | static void print_progress(double progress) | 774 | static void print_progress(double progress) |
| @@ -819,7 +824,7 @@ int main(int argc, char *argv[]) | |||
| 819 | idevice_error_t ret = IDEVICE_E_UNKNOWN_ERROR; | 824 | idevice_error_t ret = IDEVICE_E_UNKNOWN_ERROR; |
| 820 | int i; | 825 | int i; |
| 821 | char* udid = NULL; | 826 | char* udid = NULL; |
| 822 | uint16_t port = 0; | 827 | lockdownd_service_descriptor_t service = NULL; |
| 823 | int cmd = -1; | 828 | int cmd = -1; |
| 824 | int is_full_backup = 0; | 829 | int is_full_backup = 0; |
| 825 | char *backup_directory = NULL; | 830 | char *backup_directory = NULL; |
| @@ -931,9 +936,9 @@ int main(int argc, char *argv[]) | |||
| 931 | 936 | ||
| 932 | /* start notification_proxy */ | 937 | /* start notification_proxy */ |
| 933 | np_client_t np = NULL; | 938 | np_client_t np = NULL; |
| 934 | ret = lockdownd_start_service(client, NP_SERVICE_NAME, &port); | 939 | ret = lockdownd_start_service(client, NP_SERVICE_NAME, &service); |
| 935 | if ((ret == LOCKDOWN_E_SUCCESS) && port) { | 940 | if ((ret == LOCKDOWN_E_SUCCESS) && service->port) { |
| 936 | np_client_new(device, port, &np); | 941 | np_client_new(device, service, &np); |
| 937 | np_set_notify_callback(np, notify_cb, NULL); | 942 | np_set_notify_callback(np, notify_cb, NULL); |
| 938 | const char *noties[5] = { | 943 | const char *noties[5] = { |
| 939 | NP_SYNC_CANCEL_REQUEST, | 944 | NP_SYNC_CANCEL_REQUEST, |
| @@ -947,22 +952,37 @@ int main(int argc, char *argv[]) | |||
| 947 | printf("ERROR: Could not start service %s.\n", NP_SERVICE_NAME); | 952 | printf("ERROR: Could not start service %s.\n", NP_SERVICE_NAME); |
| 948 | } | 953 | } |
| 949 | 954 | ||
| 955 | if (service) { | ||
| 956 | lockdownd_service_descriptor_free(service); | ||
| 957 | service = NULL; | ||
| 958 | } | ||
| 959 | |||
| 950 | afc_client_t afc = NULL; | 960 | afc_client_t afc = NULL; |
| 951 | if (cmd == CMD_BACKUP) { | 961 | if (cmd == CMD_BACKUP) { |
| 952 | /* start AFC, we need this for the lock file */ | 962 | /* start AFC, we need this for the lock file */ |
| 953 | port = 0; | 963 | service->port = 0; |
| 954 | ret = lockdownd_start_service(client, "com.apple.afc", &port); | 964 | service->ssl_enabled = 0; |
| 955 | if ((ret == LOCKDOWN_E_SUCCESS) && port) { | 965 | ret = lockdownd_start_service(client, "com.apple.afc", &service); |
| 956 | afc_client_new(device, port, &afc); | 966 | if ((ret == LOCKDOWN_E_SUCCESS) && service->port) { |
| 967 | afc_client_new(device, service, &afc); | ||
| 957 | } | 968 | } |
| 958 | } | 969 | } |
| 959 | 970 | ||
| 971 | if (service) { | ||
| 972 | lockdownd_service_descriptor_free(service); | ||
| 973 | service = NULL; | ||
| 974 | } | ||
| 975 | |||
| 960 | /* start mobilebackup service and retrieve port */ | 976 | /* start mobilebackup service and retrieve port */ |
| 961 | port = 0; | 977 | ret = lockdownd_start_service(client, MOBILEBACKUP_SERVICE_NAME, &service); |
| 962 | ret = lockdownd_start_service(client, MOBILEBACKUP_SERVICE_NAME, &port); | 978 | if ((ret == LOCKDOWN_E_SUCCESS) && service->port) { |
| 963 | if ((ret == LOCKDOWN_E_SUCCESS) && port) { | 979 | printf("Started \"%s\" service on port %d.\n", MOBILEBACKUP_SERVICE_NAME, service->port); |
| 964 | printf("Started \"%s\" service on port %d.\n", MOBILEBACKUP_SERVICE_NAME, port); | 980 | mobilebackup_client_new(device, service, &mobilebackup); |
| 965 | mobilebackup_client_new(device, port, &mobilebackup); | 981 | |
| 982 | if (service) { | ||
| 983 | lockdownd_service_descriptor_free(service); | ||
| 984 | service = NULL; | ||
| 985 | } | ||
| 966 | 986 | ||
| 967 | /* check abort conditions */ | 987 | /* check abort conditions */ |
| 968 | if (quit_flag > 0) { | 988 | if (quit_flag > 0) { |
