diff options
Diffstat (limited to 'dev/main.c')
| -rw-r--r-- | dev/main.c | 59 |
1 files changed, 59 insertions, 0 deletions
| @@ -27,12 +27,51 @@ | |||
| 27 | #include <libiphone/libiphone.h> | 27 | #include <libiphone/libiphone.h> |
| 28 | #include "../src/utils.h" | 28 | #include "../src/utils.h" |
| 29 | 29 | ||
| 30 | void perform_syncWillStart(iphone_device_t phone, iphone_lckd_client_t control) | ||
| 31 | { | ||
| 32 | int nport = 0; | ||
| 33 | iphone_np_client_t np; | ||
| 34 | |||
| 35 | iphone_lckd_start_service(control, "com.apple.mobile.notification_proxy", &nport); | ||
| 36 | if (nport) { | ||
| 37 | printf("::::::::::::::: np was started ::::::::::::\n"); | ||
| 38 | iphone_np_new_client(phone, 3555, nport, &np); | ||
| 39 | if (np) { | ||
| 40 | printf("::::::::: PostNotification com.apple.itunes-mobdev.syncWillStart\n"); | ||
| 41 | iphone_np_post_notification(np, "com.apple.itunes-mobdev.syncWillStart"); | ||
| 42 | iphone_np_free_client(np); | ||
| 43 | } | ||
| 44 | } else { | ||
| 45 | printf("::::::::::::::: np was NOT started ::::::::::::\n"); | ||
| 46 | } | ||
| 47 | } | ||
| 48 | |||
| 49 | void perform_syncDidStart(iphone_device_t phone, iphone_lckd_client_t control) | ||
| 50 | { | ||
| 51 | int nport = 0; | ||
| 52 | iphone_np_client_t np; | ||
| 53 | |||
| 54 | iphone_lckd_start_service(control, "com.apple.mobile.notification_proxy", &nport); | ||
| 55 | if (nport) { | ||
| 56 | printf("::::::::::::::: np was started ::::::::::::\n"); | ||
| 57 | sleep(1); | ||
| 58 | iphone_np_new_client(phone, 3555, nport, &np); | ||
| 59 | if (np) { | ||
| 60 | printf("::::::::: PostNotification com.apple.itunes-mobdev.syncDidStart\n"); | ||
| 61 | iphone_np_post_notification(np, "com.apple.itunes-mobdev.syncDidStart"); | ||
| 62 | iphone_np_free_client(np); | ||
| 63 | } | ||
| 64 | } else { | ||
| 65 | printf("::::::::::::::: np was NOT started ::::::::::::\n"); | ||
| 66 | } | ||
| 67 | } | ||
| 30 | 68 | ||
| 31 | int main(int argc, char *argv[]) | 69 | int main(int argc, char *argv[]) |
| 32 | { | 70 | { |
| 33 | int bytes = 0, port = 0, i = 0; | 71 | int bytes = 0, port = 0, i = 0; |
| 34 | iphone_lckd_client_t control = NULL; | 72 | iphone_lckd_client_t control = NULL; |
| 35 | iphone_device_t phone = NULL; | 73 | iphone_device_t phone = NULL; |
| 74 | iphone_afc_file_t lockfile = NULL; | ||
| 36 | 75 | ||
| 37 | if (argc > 1 && !strcasecmp(argv[1], "--debug")) { | 76 | if (argc > 1 && !strcasecmp(argv[1], "--debug")) { |
| 38 | iphone_set_debug(1); | 77 | iphone_set_debug(1); |
| @@ -64,6 +103,16 @@ int main(int argc, char *argv[]) | |||
| 64 | iphone_afc_client_t afc = NULL; | 103 | iphone_afc_client_t afc = NULL; |
| 65 | iphone_afc_new_client(phone, 3432, port, &afc); | 104 | iphone_afc_new_client(phone, 3432, port, &afc); |
| 66 | if (afc) { | 105 | if (afc) { |
| 106 | perform_syncWillStart(phone, control); | ||
| 107 | |||
| 108 | iphone_afc_open_file(afc, "/com.apple.itunes.lock_sync", IPHONE_AFC_FILE_WRITE, &lockfile); | ||
| 109 | if (lockfile) { | ||
| 110 | printf("locking file\n"); | ||
| 111 | iphone_afc_lock_file(afc, lockfile, 2 | 4); | ||
| 112 | |||
| 113 | perform_syncDidStart(phone, control); | ||
| 114 | } | ||
| 115 | |||
| 67 | char **dirs = NULL; | 116 | char **dirs = NULL; |
| 68 | iphone_afc_get_dir_list(afc, "/eafaedf", &dirs); | 117 | iphone_afc_get_dir_list(afc, "/eafaedf", &dirs); |
| 69 | if (!dirs) | 118 | if (!dirs) |
| @@ -138,7 +187,17 @@ int main(int argc, char *argv[]) | |||
| 138 | printf("Couldn't read!\n"); | 187 | printf("Couldn't read!\n"); |
| 139 | free(threeletterword); | 188 | free(threeletterword); |
| 140 | iphone_afc_close_file(afc, my_file); | 189 | iphone_afc_close_file(afc, my_file); |
| 190 | } | ||
| 191 | |||
| 192 | if (lockfile) { | ||
| 193 | printf("XXX sleeping 2 seconds\n"); | ||
| 194 | sleep(2); | ||
| 195 | |||
| 196 | printf("XXX unlocking file\n"); | ||
| 197 | iphone_afc_lock_file(afc, lockfile, 8 | 4); | ||
| 141 | 198 | ||
| 199 | printf("XXX closing file\n"); | ||
| 200 | iphone_afc_close_file(afc, lockfile); | ||
| 142 | } | 201 | } |
| 143 | iphone_afc_free_client(afc); | 202 | iphone_afc_free_client(afc); |
| 144 | } else { | 203 | } else { |
