diff options
| author | 2009-07-25 03:26:39 +0200 | |
|---|---|---|
| committer | 2009-07-25 03:26:39 +0200 | |
| commit | 50be30047dbb0d38fd8d61763c13ec75d2b52543 (patch) | |
| tree | 87e021b478c6db6197294e4ef56c47cdad0f5992 /dev | |
| parent | 1cfc2748d38eb97100cabced3b282108898099c2 (diff) | |
| download | libimobiledevice-50be30047dbb0d38fd8d61763c13ec75d2b52543.tar.gz libimobiledevice-50be30047dbb0d38fd8d61763c13ec75d2b52543.tar.bz2 | |
Update AFC API and use error codes from the STATUS operation response
Diffstat (limited to 'dev')
| -rw-r--r-- | dev/afccheck.c | 16 | ||||
| -rw-r--r-- | dev/main.c | 46 |
2 files changed, 31 insertions, 31 deletions
diff --git a/dev/afccheck.c b/dev/afccheck.c index 067dd5b..d06a147 100644 --- a/dev/afccheck.c +++ b/dev/afccheck.c | |||
| @@ -55,18 +55,18 @@ void check_afc(gpointer data) | |||
| 55 | uint64_t file = 0; | 55 | uint64_t file = 0; |
| 56 | char path[50]; | 56 | char path[50]; |
| 57 | sprintf(path, "/Buf%i", ((param *) data)->id); | 57 | sprintf(path, "/Buf%i", ((param *) data)->id); |
| 58 | afc_open_file(((param *) data)->afc, path, AFC_FOPEN_RW, &file); | 58 | afc_file_open(((param *) data)->afc, path, AFC_FOPEN_RW, &file); |
| 59 | afc_write_file(((param *) data)->afc, file, (char *) buf, buffersize, &bytes); | 59 | afc_file_write(((param *) data)->afc, file, (char *) buf, buffersize, &bytes); |
| 60 | afc_close_file(((param *) data)->afc, file); | 60 | afc_file_close(((param *) data)->afc, file); |
| 61 | file = 0; | 61 | file = 0; |
| 62 | if (bytes != buffersize) | 62 | if (bytes != buffersize) |
| 63 | printf("Write operation failed\n"); | 63 | printf("Write operation failed\n"); |
| 64 | 64 | ||
| 65 | //now read it | 65 | //now read it |
| 66 | bytes = 0; | 66 | bytes = 0; |
| 67 | afc_open_file(((param *) data)->afc, path, AFC_FOPEN_RDONLY, &file); | 67 | afc_file_open(((param *) data)->afc, path, AFC_FOPEN_RDONLY, &file); |
| 68 | afc_read_file(((param *) data)->afc, file, (char *) buf2, buffersize, &bytes); | 68 | afc_file_read(((param *) data)->afc, file, (char *) buf2, buffersize, &bytes); |
| 69 | afc_close_file(((param *) data)->afc, file); | 69 | afc_file_close(((param *) data)->afc, file); |
| 70 | if (bytes != buffersize) | 70 | if (bytes != buffersize) |
| 71 | printf("Read operation failed\n"); | 71 | printf("Read operation failed\n"); |
| 72 | 72 | ||
| @@ -79,7 +79,7 @@ void check_afc(gpointer data) | |||
| 79 | } | 79 | } |
| 80 | 80 | ||
| 81 | //cleanup | 81 | //cleanup |
| 82 | afc_delete_file(((param *) data)->afc, path); | 82 | afc_remove_path(((param *) data)->afc, path); |
| 83 | g_thread_exit(0); | 83 | g_thread_exit(0); |
| 84 | } | 84 | } |
| 85 | 85 | ||
| @@ -116,7 +116,7 @@ int main(int argc, char *argv[]) | |||
| 116 | return 1; | 116 | return 1; |
| 117 | } | 117 | } |
| 118 | 118 | ||
| 119 | afc_new_client(phone, port, &afc); | 119 | afc_client_new(phone, port, &afc); |
| 120 | 120 | ||
| 121 | //makes sure thread environment is available | 121 | //makes sure thread environment is available |
| 122 | if (!g_thread_supported()) | 122 | if (!g_thread_supported()) |
| @@ -103,7 +103,7 @@ 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) { |
| @@ -126,18 +126,18 @@ int main(int argc, char *argv[]) | |||
| 126 | 126 | ||
| 127 | perform_notification(phone, client, NP_SYNC_WILL_START); | 127 | perform_notification(phone, client, NP_SYNC_WILL_START); |
| 128 | 128 | ||
| 129 | 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); |
| 130 | if (lockfile) { | 130 | if (lockfile) { |
| 131 | printf("locking file\n"); | 131 | printf("locking file\n"); |
| 132 | afc_lock_file(afc, lockfile, AFC_LOCK_EX); | 132 | afc_file_lock(afc, lockfile, AFC_LOCK_EX); |
| 133 | 133 | ||
| 134 | perform_notification(phone, client, NP_SYNC_DID_START); | 134 | perform_notification(phone, client, NP_SYNC_DID_START); |
| 135 | } | 135 | } |
| 136 | 136 | ||
| 137 | char **dirs = NULL; | 137 | char **dirs = NULL; |
| 138 | afc_get_dir_list(afc, "/eafaedf", &dirs); | 138 | afc_read_directory(afc, "/eafaedf", &dirs); |
| 139 | if (!dirs) | 139 | if (!dirs) |
| 140 | afc_get_dir_list(afc, "/", &dirs); | 140 | afc_read_directory(afc, "/", &dirs); |
| 141 | printf("Directory time.\n"); | 141 | printf("Directory time.\n"); |
| 142 | for (i = 0; dirs[i]; i++) { | 142 | for (i = 0; dirs[i]; i++) { |
| 143 | printf("/%s\n", dirs[i]); | 143 | printf("/%s\n", dirs[i]); |
| @@ -146,7 +146,7 @@ int main(int argc, char *argv[]) | |||
| 146 | g_strfreev(dirs); | 146 | g_strfreev(dirs); |
| 147 | 147 | ||
| 148 | dirs = NULL; | 148 | dirs = NULL; |
| 149 | afc_get_devinfo(afc, &dirs); | 149 | afc_get_device_info(afc, &dirs); |
| 150 | if (dirs) { | 150 | if (dirs) { |
| 151 | for (i = 0; dirs[i]; i += 2) { | 151 | for (i = 0; dirs[i]; i += 2) { |
| 152 | printf("%s: %s\n", dirs[i], dirs[i + 1]); | 152 | printf("%s: %s\n", dirs[i], dirs[i + 1]); |
| @@ -157,7 +157,7 @@ int main(int argc, char *argv[]) | |||
| 157 | uint64_t my_file = 0; | 157 | uint64_t my_file = 0; |
| 158 | char **info = NULL; | 158 | char **info = NULL; |
| 159 | uint64_t fsize = 0; | 159 | uint64_t fsize = 0; |
| 160 | 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) { |
| 161 | for (i = 0; info[i]; i += 2) { | 161 | for (i = 0; info[i]; i += 2) { |
| 162 | printf("%s: %s\n", info[i], info[i+1]); | 162 | printf("%s: %s\n", info[i], info[i+1]); |
| 163 | if (!strcmp(info[i], "st_size")) { | 163 | if (!strcmp(info[i], "st_size")) { |
| @@ -166,59 +166,59 @@ int main(int argc, char *argv[]) | |||
| 166 | } | 166 | } |
| 167 | } | 167 | } |
| 168 | 168 | ||
| 169 | if (IPHONE_E_SUCCESS == | 169 | if (AFC_E_SUCCESS == |
| 170 | afc_open_file(afc, "/readme.libiphone.fx", AFC_FOPEN_RDONLY, &my_file) && my_file) { | 170 | afc_file_open(afc, "/readme.libiphone.fx", AFC_FOPEN_RDONLY, &my_file) && my_file) { |
| 171 | printf("A file size: %llu\n", fsize); | 171 | printf("A file size: %llu\n", fsize); |
| 172 | char *file_data = (char *) malloc(sizeof(char) * fsize); | 172 | char *file_data = (char *) malloc(sizeof(char) * fsize); |
| 173 | afc_read_file(afc, my_file, file_data, fsize, &bytes); | 173 | afc_file_read(afc, my_file, file_data, fsize, &bytes); |
| 174 | if (bytes > 0) { | 174 | if (bytes > 0) { |
| 175 | printf("The file's data:\n"); | 175 | printf("The file's data:\n"); |
| 176 | fwrite(file_data, 1, bytes, stdout); | 176 | fwrite(file_data, 1, bytes, stdout); |
| 177 | } | 177 | } |
| 178 | printf("\nClosing my file.\n"); | 178 | printf("\nClosing my file.\n"); |
| 179 | afc_close_file(afc, my_file); | 179 | afc_file_close(afc, my_file); |
| 180 | free(file_data); | 180 | free(file_data); |
| 181 | } else | 181 | } else |
| 182 | printf("couldn't open a file\n"); | 182 | printf("couldn't open a file\n"); |
| 183 | 183 | ||
| 184 | 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); |
| 185 | if (my_file) { | 185 | if (my_file) { |
| 186 | char *outdatafile = strdup("this is a bitchin text file\n"); | 186 | char *outdatafile = strdup("this is a bitchin text file\n"); |
| 187 | afc_write_file(afc, my_file, outdatafile, strlen(outdatafile), &bytes); | 187 | afc_file_write(afc, my_file, outdatafile, strlen(outdatafile), &bytes); |
| 188 | free(outdatafile); | 188 | free(outdatafile); |
| 189 | if (bytes > 0) | 189 | if (bytes > 0) |
| 190 | printf("Wrote a surprise. ;)\n"); | 190 | printf("Wrote a surprise. ;)\n"); |
| 191 | else | 191 | else |
| 192 | printf("I wanted to write a surprise, but... :(\n"); | 192 | printf("I wanted to write a surprise, but... :(\n"); |
| 193 | afc_close_file(afc, my_file); | 193 | afc_file_close(afc, my_file); |
| 194 | } | 194 | } |
| 195 | printf("Deleting a file...\n"); | 195 | printf("Deleting a file...\n"); |
| 196 | bytes = afc_delete_file(afc, "/delme"); | 196 | bytes = afc_remove_path(afc, "/delme"); |
| 197 | if (bytes) | 197 | if (bytes) |
| 198 | printf("Success.\n"); | 198 | printf("Success.\n"); |
| 199 | else | 199 | else |
| 200 | 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"); |
| 201 | 201 | ||
| 202 | printf("Renaming a file...\n"); | 202 | printf("Renaming a file...\n"); |
| 203 | bytes = afc_rename_file(afc, "/renme", "/renme2"); | 203 | bytes = afc_rename_path(afc, "/renme", "/renme2"); |
| 204 | if (bytes > 0) | 204 | if (bytes > 0) |
| 205 | printf("Success.\n"); | 205 | printf("Success.\n"); |
| 206 | else | 206 | else |
| 207 | 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"); |
| 208 | 208 | ||
| 209 | printf("Seek & read\n"); | 209 | printf("Seek & read\n"); |
| 210 | 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); |
| 211 | 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)) |
| 212 | printf("WARN: SEEK DID NOT WORK\n"); | 212 | printf("WARN: SEEK DID NOT WORK\n"); |
| 213 | char *threeletterword = (char *) malloc(sizeof(char) * 5); | 213 | char *threeletterword = (char *) malloc(sizeof(char) * 5); |
| 214 | afc_read_file(afc, my_file, threeletterword, 3, &bytes); | 214 | afc_file_read(afc, my_file, threeletterword, 3, &bytes); |
| 215 | threeletterword[3] = '\0'; | 215 | threeletterword[3] = '\0'; |
| 216 | if (bytes > 0) | 216 | if (bytes > 0) |
| 217 | printf("Result: %s\n", threeletterword); | 217 | printf("Result: %s\n", threeletterword); |
| 218 | else | 218 | else |
| 219 | printf("Couldn't read!\n"); | 219 | printf("Couldn't read!\n"); |
| 220 | free(threeletterword); | 220 | free(threeletterword); |
| 221 | afc_close_file(afc, my_file); | 221 | afc_file_close(afc, my_file); |
| 222 | } | 222 | } |
| 223 | 223 | ||
| 224 | if (gnp && lockfile) { | 224 | if (gnp && lockfile) { |
| @@ -226,10 +226,10 @@ int main(int argc, char *argv[]) | |||
| 226 | sleep(5); | 226 | sleep(5); |
| 227 | 227 | ||
| 228 | printf("XXX unlocking file\n"); | 228 | printf("XXX unlocking file\n"); |
| 229 | afc_lock_file(afc, lockfile, AFC_LOCK_UN); | 229 | afc_file_lock(afc, lockfile, AFC_LOCK_UN); |
| 230 | 230 | ||
| 231 | printf("XXX closing file\n"); | 231 | printf("XXX closing file\n"); |
| 232 | afc_close_file(afc, lockfile); | 232 | afc_file_close(afc, lockfile); |
| 233 | 233 | ||
| 234 | printf("XXX sleeping\n"); | 234 | printf("XXX sleeping\n"); |
| 235 | sleep(5); | 235 | sleep(5); |
| @@ -241,7 +241,7 @@ int main(int argc, char *argv[]) | |||
| 241 | gnp = NULL; | 241 | gnp = NULL; |
| 242 | } | 242 | } |
| 243 | 243 | ||
| 244 | afc_free_client(afc); | 244 | afc_client_free(afc); |
| 245 | } else { | 245 | } else { |
| 246 | printf("Start service failure.\n"); | 246 | printf("Start service failure.\n"); |
| 247 | } | 247 | } |
