summaryrefslogtreecommitdiffstats
path: root/dev/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'dev/main.c')
-rw-r--r--dev/main.c89
1 files changed, 46 insertions, 43 deletions
diff --git a/dev/main.c b/dev/main.c
index f2d72b1..eb74c89 100644
--- a/dev/main.c
+++ b/dev/main.c
@@ -46,11 +46,11 @@ static void perform_notification(iphone_device_t phone, lockdownd_client_t clien
46 lockdownd_start_service(client, "com.apple.mobile.notification_proxy", &nport); 46 lockdownd_start_service(client, "com.apple.mobile.notification_proxy", &nport);
47 if (nport) { 47 if (nport) {
48 printf("::::::::::::::: np was started ::::::::::::\n"); 48 printf("::::::::::::::: np was started ::::::::::::\n");
49 np_new_client(phone, nport, &np); 49 np_client_new(phone, nport, &np);
50 if (np) { 50 if (np) {
51 printf("::::::::: PostNotification %s\n", notification); 51 printf("::::::::: PostNotification %s\n", notification);
52 np_post_notification(np, notification); 52 np_post_notification(np, notification);
53 np_free_client(np); 53 np_client_free(np);
54 } 54 }
55 } else { 55 } else {
56 printf("::::::::::::::: np was NOT started ::::::::::::\n"); 56 printf("::::::::::::::: np was NOT started ::::::::::::\n");
@@ -68,10 +68,10 @@ int main(int argc, char *argv[])
68 np_client_t gnp = NULL; 68 np_client_t gnp = NULL;
69 69
70 if (argc > 1 && !strcasecmp(argv[1], "--debug")) { 70 if (argc > 1 && !strcasecmp(argv[1], "--debug")) {
71 iphone_set_debug(1); 71 iphone_set_debug_level(1);
72 iphone_set_debug_mask(DBGMASK_ALL); 72 iphone_set_debug_mask(DBGMASK_ALL);
73 } else { 73 } else {
74 iphone_set_debug(0); 74 iphone_set_debug_level(0);
75 iphone_set_debug_mask(DBGMASK_NONE); 75 iphone_set_debug_mask(DBGMASK_NONE);
76 } 76 }
77 77
@@ -80,21 +80,21 @@ int main(int argc, char *argv[])
80 return -1; 80 return -1;
81 } 81 }
82 82
83 if (IPHONE_E_SUCCESS != lockdownd_new_client(phone, &client)) { 83 char *uuid = NULL;
84 iphone_free_device(phone); 84 if (IPHONE_E_SUCCESS == iphone_device_get_uuid(phone, &uuid)) {
85 printf("Exiting.\n"); 85 printf("DeviceUniqueID : %s\n", uuid);
86 return -1;
87 } 86 }
87 if (uuid)
88 free(uuid);
88 89
89 char *uid = NULL; 90 if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client)) {
90 if (IPHONE_E_SUCCESS == lockdownd_get_device_uid(client, &uid)) { 91 iphone_device_free(phone);
91 printf("DeviceUniqueID : %s\n", uid); 92 printf("Exiting.\n");
92 free(uid); 93 return -1;
93 } 94 }
94 95
95
96 char *nnn = NULL; 96 char *nnn = NULL;
97 if (IPHONE_E_SUCCESS == lockdownd_get_device_name(client, &nnn)) { 97 if (LOCKDOWN_E_SUCCESS == lockdownd_get_device_name(client, &nnn)) {
98 printf("DeviceName : %s\n", nnn); 98 printf("DeviceName : %s\n", nnn);
99 free(nnn); 99 free(nnn);
100 } 100 }
@@ -103,20 +103,21 @@ int main(int argc, char *argv[])
103 103
104 if (port) { 104 if (port) {
105 afc_client_t afc = NULL; 105 afc_client_t afc = NULL;
106 afc_new_client(phone, port, &afc); 106 afc_client_new(phone, port, &afc);
107 if (afc) { 107 if (afc) {
108 lockdownd_start_service(client, "com.apple.mobile.notification_proxy", &npp); 108 lockdownd_start_service(client, "com.apple.mobile.notification_proxy", &npp);
109 if (npp) { 109 if (npp) {
110 printf("Notification Proxy started.\n"); 110 printf("Notification Proxy started.\n");
111 np_new_client(phone, npp, &gnp); 111 np_client_new(phone, npp, &gnp);
112 } else { 112 } else {
113 printf("ERROR: Notification proxy could not be started.\n"); 113 printf("ERROR: Notification proxy could not be started.\n");
114 } 114 }
115 if (gnp) { 115 if (gnp) {
116 const char *nspec[4] = { 116 const char *nspec[5] = {
117 NP_SYNC_CANCEL_REQUEST, 117 NP_SYNC_CANCEL_REQUEST,
118 NP_SYNC_SUSPEND_REQUEST, 118 NP_SYNC_SUSPEND_REQUEST,
119 NP_SYNC_RESUME_REQUEST, 119 NP_SYNC_RESUME_REQUEST,
120 NP_ITDBPREP_DID_END,
120 NULL 121 NULL
121 }; 122 };
122 np_observe_notifications(gnp, nspec); 123 np_observe_notifications(gnp, nspec);
@@ -125,18 +126,18 @@ int main(int argc, char *argv[])
125 126
126 perform_notification(phone, client, NP_SYNC_WILL_START); 127 perform_notification(phone, client, NP_SYNC_WILL_START);
127 128
128 afc_open_file(afc, "/com.apple.itunes.lock_sync", AFC_FOPEN_RW, &lockfile); 129 afc_file_open(afc, "/com.apple.itunes.lock_sync", AFC_FOPEN_RW, &lockfile);
129 if (lockfile) { 130 if (lockfile) {
130 printf("locking file\n"); 131 printf("locking file\n");
131 afc_lock_file(afc, lockfile, 2 | 4); 132 afc_file_lock(afc, lockfile, AFC_LOCK_EX);
132 133
133 perform_notification(phone, client, NP_SYNC_DID_START); 134 perform_notification(phone, client, NP_SYNC_DID_START);
134 } 135 }
135 136
136 char **dirs = NULL; 137 char **dirs = NULL;
137 afc_get_dir_list(afc, "/eafaedf", &dirs); 138 afc_read_directory(afc, "/eafaedf", &dirs);
138 if (!dirs) 139 if (!dirs)
139 afc_get_dir_list(afc, "/", &dirs); 140 afc_read_directory(afc, "/", &dirs);
140 printf("Directory time.\n"); 141 printf("Directory time.\n");
141 for (i = 0; dirs[i]; i++) { 142 for (i = 0; dirs[i]; i++) {
142 printf("/%s\n", dirs[i]); 143 printf("/%s\n", dirs[i]);
@@ -145,7 +146,7 @@ int main(int argc, char *argv[])
145 g_strfreev(dirs); 146 g_strfreev(dirs);
146 147
147 dirs = NULL; 148 dirs = NULL;
148 afc_get_devinfo(afc, &dirs); 149 afc_get_device_info(afc, &dirs);
149 if (dirs) { 150 if (dirs) {
150 for (i = 0; dirs[i]; i += 2) { 151 for (i = 0; dirs[i]; i += 2) {
151 printf("%s: %s\n", dirs[i], dirs[i + 1]); 152 printf("%s: %s\n", dirs[i], dirs[i + 1]);
@@ -156,7 +157,7 @@ int main(int argc, char *argv[])
156 uint64_t my_file = 0; 157 uint64_t my_file = 0;
157 char **info = NULL; 158 char **info = NULL;
158 uint64_t fsize = 0; 159 uint64_t fsize = 0;
159 if (IPHONE_E_SUCCESS == afc_get_file_info(afc, "/readme.libiphone.fx", &info) && info) { 160 if (AFC_E_SUCCESS == afc_get_file_info(afc, "/readme.libiphone.fx", &info) && info) {
160 for (i = 0; info[i]; i += 2) { 161 for (i = 0; info[i]; i += 2) {
161 printf("%s: %s\n", info[i], info[i+1]); 162 printf("%s: %s\n", info[i], info[i+1]);
162 if (!strcmp(info[i], "st_size")) { 163 if (!strcmp(info[i], "st_size")) {
@@ -165,88 +166,90 @@ int main(int argc, char *argv[])
165 } 166 }
166 } 167 }
167 168
168 if (IPHONE_E_SUCCESS == 169 if (AFC_E_SUCCESS ==
169 afc_open_file(afc, "/readme.libiphone.fx", AFC_FOPEN_RDONLY, &my_file) && my_file) { 170 afc_open_file(afc, "/readme.libiphone.fx", AFC_FOPEN_RDONLY, &my_file) && my_file) {
170 printf("A file size: %llu\n", (long long)fsize); 171 printf("A file size: %llu\n", (long long)fsize);
171 char *file_data = (char *) malloc(sizeof(char) * fsize); 172 char *file_data = (char *) malloc(sizeof(char) * fsize);
172 afc_read_file(afc, my_file, file_data, fsize, &bytes); 173 afc_file_read(afc, my_file, file_data, fsize, &bytes);
173 if (bytes > 0) { 174 if (bytes > 0) {
174 printf("The file's data:\n"); 175 printf("The file's data:\n");
175 fwrite(file_data, 1, bytes, stdout); 176 fwrite(file_data, 1, bytes, stdout);
176 } 177 }
177 printf("\nClosing my file.\n"); 178 printf("\nClosing my file.\n");
178 afc_close_file(afc, my_file); 179 afc_file_close(afc, my_file);
179 free(file_data); 180 free(file_data);
180 } else 181 } else
181 printf("couldn't open a file\n"); 182 printf("couldn't open a file\n");
182 183
183 afc_open_file(afc, "/readme.libiphone.fx", AFC_FOPEN_WR, &my_file); 184 afc_file_open(afc, "/readme.libiphone.fx", AFC_FOPEN_WR, &my_file);
184 if (my_file) { 185 if (my_file) {
185 char *outdatafile = strdup("this is a bitchin text file\n"); 186 char *outdatafile = strdup("this is a bitchin text file\n");
186 afc_write_file(afc, my_file, outdatafile, strlen(outdatafile), &bytes); 187 afc_file_write(afc, my_file, outdatafile, strlen(outdatafile), &bytes);
187 free(outdatafile); 188 free(outdatafile);
188 if (bytes > 0) 189 if (bytes > 0)
189 printf("Wrote a surprise. ;)\n"); 190 printf("Wrote a surprise. ;)\n");
190 else 191 else
191 printf("I wanted to write a surprise, but... :(\n"); 192 printf("I wanted to write a surprise, but... :(\n");
192 afc_close_file(afc, my_file); 193 afc_file_close(afc, my_file);
193 } 194 }
194 printf("Deleting a file...\n"); 195 printf("Deleting a file...\n");
195 bytes = afc_delete_file(afc, "/delme"); 196 bytes = afc_remove_path(afc, "/delme");
196 if (bytes) 197 if (bytes)
197 printf("Success.\n"); 198 printf("Success.\n");
198 else 199 else
199 printf("Failure. (expected unless you have a /delme file on your phone)\n"); 200 printf("Failure. (expected unless you have a /delme file on your phone)\n");
200 201
201 printf("Renaming a file...\n"); 202 printf("Renaming a file...\n");
202 bytes = afc_rename_file(afc, "/renme", "/renme2"); 203 bytes = afc_rename_path(afc, "/renme", "/renme2");
203 if (bytes > 0) 204 if (bytes > 0)
204 printf("Success.\n"); 205 printf("Success.\n");
205 else 206 else
206 printf("Failure. (expected unless you have a /renme file on your phone)\n"); 207 printf("Failure. (expected unless you have a /renme file on your phone)\n");
207 208
208 printf("Seek & read\n"); 209 printf("Seek & read\n");
209 afc_open_file(afc, "/readme.libiphone.fx", AFC_FOPEN_RDONLY, &my_file); 210 afc_file_open(afc, "/readme.libiphone.fx", AFC_FOPEN_RDONLY, &my_file);
210 if (IPHONE_E_SUCCESS != afc_seek_file(afc, my_file, 5, SEEK_CUR)) 211 if (AFC_E_SUCCESS != afc_file_seek(afc, my_file, 5, SEEK_CUR))
211 printf("WARN: SEEK DID NOT WORK\n"); 212 printf("WARN: SEEK DID NOT WORK\n");
212 char *threeletterword = (char *) malloc(sizeof(char) * 5); 213 char *threeletterword = (char *) malloc(sizeof(char) * 5);
213 afc_read_file(afc, my_file, threeletterword, 3, &bytes); 214 afc_file_read(afc, my_file, threeletterword, 3, &bytes);
214 threeletterword[3] = '\0'; 215 threeletterword[3] = '\0';
215 if (bytes > 0) 216 if (bytes > 0)
216 printf("Result: %s\n", threeletterword); 217 printf("Result: %s\n", threeletterword);
217 else 218 else
218 printf("Couldn't read!\n"); 219 printf("Couldn't read!\n");
219 free(threeletterword); 220 free(threeletterword);
220 afc_close_file(afc, my_file); 221 afc_file_close(afc, my_file);
221 } 222 }
222 223
223 if (gnp && lockfile) { 224 if (gnp && lockfile) {
224 printf("XXX sleeping\n"); 225 printf("XXX sleeping\n");
225 sleep(5); 226 sleep(5);
226 227
227 //perform_notification(phone, control, NP_SYNC_DID_FINISH);
228
229 printf("XXX unlocking file\n"); 228 printf("XXX unlocking file\n");
230 afc_lock_file(afc, lockfile, 8 | 4); 229 afc_file_lock(afc, lockfile, AFC_LOCK_UN);
231 230
232 printf("XXX closing file\n"); 231 printf("XXX closing file\n");
233 afc_close_file(afc, lockfile); 232 afc_file_close(afc, lockfile);
233
234 printf("XXX sleeping\n");
235 sleep(5);
236 //perform_notification(phone, client, NP_SYNC_DID_FINISH);
234 } 237 }
235 238
236 if (gnp) { 239 if (gnp) {
237 np_free_client(gnp); 240 np_client_free(gnp);
238 gnp = NULL; 241 gnp = NULL;
239 } 242 }
240 243
241 afc_free_client(afc); 244 afc_client_free(afc);
242 } else { 245 } else {
243 printf("Start service failure.\n"); 246 printf("Start service failure.\n");
244 } 247 }
245 248
246 printf("All done.\n"); 249 printf("All done.\n");
247 250
248 lockdownd_free_client(client); 251 lockdownd_client_free(client);
249 iphone_free_device(phone); 252 iphone_device_free(phone);
250 253
251 return 0; 254 return 0;
252} 255}