summaryrefslogtreecommitdiffstats
path: root/dev/filerelaytest.c
diff options
context:
space:
mode:
Diffstat (limited to 'dev/filerelaytest.c')
-rw-r--r--dev/filerelaytest.c40
1 files changed, 29 insertions, 11 deletions
diff --git a/dev/filerelaytest.c b/dev/filerelaytest.c
index f045620..1069711 100644
--- a/dev/filerelaytest.c
+++ b/dev/filerelaytest.c
@@ -32,24 +32,25 @@ int main(int argc, char **argv)
32 lockdownd_client_t client = NULL; 32 lockdownd_client_t client = NULL;
33 lockdownd_service_descriptor_t service = NULL; 33 lockdownd_service_descriptor_t service = NULL;
34 file_relay_client_t frc = NULL; 34 file_relay_client_t frc = NULL;
35 file_relay_error_t frc_error = FILE_RELAY_E_SUCCESS;
35 idevice_connection_t dump = NULL; 36 idevice_connection_t dump = NULL;
36 const char **sources; 37 const char **sources;
37 const char *default_sources[] = {"AppleSupport", "Network", "VPN", "WiFi", "UserDatabases", "CrashReporter", "tmp", "SystemConfiguration", NULL}; 38 const char *default_sources[] = {"AppleSupport", "Network", "VPN", "WiFi", "UserDatabases", "CrashReporter", "tmp", "SystemConfiguration", NULL};
38 int i = 0; 39 int i = 0;
39 40
40 if (idevice_new(&dev, NULL) != IDEVICE_E_SUCCESS) { 41 if (idevice_new(&dev, NULL) != IDEVICE_E_SUCCESS) {
41 printf("no device connected?!\n"); 42 printf("No device connected?!\n");
42 goto leave_cleanup; 43 goto leave_cleanup;
43 } 44 }
44 45
45 printf("connecting...\n"); 46 printf("Connecting...\n");
46 if (lockdownd_client_new_with_handshake(dev, &client, NULL) != LOCKDOWN_E_SUCCESS) { 47 if (lockdownd_client_new_with_handshake(dev, &client, NULL) != LOCKDOWN_E_SUCCESS) {
47 printf("could not connect to lockdownd!\n"); 48 printf("Could not connect to lockdownd!\n");
48 goto leave_cleanup; 49 goto leave_cleanup;
49 } 50 }
50 51
51 if (lockdownd_start_service(client, FILE_RELAY_SERVICE_NAME, &service) != LOCKDOWN_E_SUCCESS) { 52 if (lockdownd_start_service(client, FILE_RELAY_SERVICE_NAME, &service) != LOCKDOWN_E_SUCCESS) {
52 printf("could not start file_relay service!\n"); 53 printf("Could not start file_relay service!\n");
53 goto leave_cleanup; 54 goto leave_cleanup;
54 } 55 }
55 56
@@ -59,7 +60,7 @@ int main(int argc, char **argv)
59 } 60 }
60 61
61 if (file_relay_client_new(dev, service, &frc) != FILE_RELAY_E_SUCCESS) { 62 if (file_relay_client_new(dev, service, &frc) != FILE_RELAY_E_SUCCESS) {
62 printf("could not connect to file_relay service!\n"); 63 printf("Could not connect to file_relay service!\n");
63 goto leave_cleanup; 64 goto leave_cleanup;
64 } 65 }
65 66
@@ -80,21 +81,38 @@ int main(int argc, char **argv)
80 sources = default_sources; 81 sources = default_sources;
81 } 82 }
82 83
83 printf("Requesting"); 84 printf("Requesting ");
84 i = 0; 85 i = 0;
85 while (sources[i]) { 86 while (sources[i]) {
86 printf(" %s", sources[i]); 87 printf(" %s", sources[i]);
87 i++; 88 i++;
89 if (sources[i])
90 printf(",");
88 } 91 }
89 printf("\n"); 92 printf("\n");
90 93
91 if (file_relay_request_sources(frc, sources, &dump) != FILE_RELAY_E_SUCCESS) { 94 frc_error = file_relay_request_sources(frc, sources, &dump);
92 printf("could not get sources\n"); 95 if (frc_error != FILE_RELAY_E_SUCCESS) {
96 printf("Could not request sources.\n");
97 switch (frc_error) {
98 case FILE_RELAY_E_INVALID_SOURCE:
99 printf("At least one of the given sources is invalid and was rejected.\n");
100 break;
101 case FILE_RELAY_E_STAGING_EMPTY:
102 printf("Staging is empty. Perhaps there is no data for the requested sources available.\n");
103 break;
104 case FILE_RELAY_E_PERMISSION_DENIED:
105 printf("Permission denied by device. Possibly missing a signed preferences profile.\n");
106 break;
107 default:
108 printf("An unknown error occoured.\n");
109 break;
110 }
93 goto leave_cleanup; 111 goto leave_cleanup;
94 } 112 }
95 113
96 if (!dump) { 114 if (!dump) {
97 printf("did not get connection!\n"); 115 printf("Did not get connection!\n");
98 goto leave_cleanup; 116 goto leave_cleanup;
99 } 117 }
100 118
@@ -107,7 +125,7 @@ int main(int argc, char **argv)
107 return EXIT_FAILURE; 125 return EXIT_FAILURE;
108 } 126 }
109 setbuf(stdout, NULL); 127 setbuf(stdout, NULL);
110 printf("receiving "); 128 printf("Receiving ");
111 while (idevice_connection_receive(dump, buf, 4096, &len) == IDEVICE_E_SUCCESS) { 129 while (idevice_connection_receive(dump, buf, 4096, &len) == IDEVICE_E_SUCCESS) {
112 fwrite(buf, 1, len, f); 130 fwrite(buf, 1, len, f);
113 cnt += len; 131 cnt += len;
@@ -116,7 +134,7 @@ int main(int argc, char **argv)
116 } 134 }
117 printf("\n"); 135 printf("\n");
118 fclose(f); 136 fclose(f);
119 printf("total size received: %d\n", cnt); 137 printf("Total size received: %d\n", cnt);
120 138
121leave_cleanup: 139leave_cleanup:
122 if (frc) { 140 if (frc) {