diff options
| author | 2009-03-08 12:13:03 -0700 | |
|---|---|---|
| committer | 2009-03-08 12:13:03 -0700 | |
| commit | 774c3ed001a48a52cceb450bca292dd6112d683f (patch) | |
| tree | 98d3d01ecb8bb492d61eaab2dccb90a409bb76ba /dev | |
| parent | 927a6d3d437ca4532f8e9e906089b3a24542ebd3 (diff) | |
| download | libimobiledevice-774c3ed001a48a52cceb450bca292dd6112d683f.tar.gz libimobiledevice-774c3ed001a48a52cceb450bca292dd6112d683f.tar.bz2 | |
Adds ability to show notification screen to the user.
Signed-off-by: Matt Colyer <matt@colyer.name>
Diffstat (limited to 'dev')
| -rw-r--r-- | dev/main.c | 59 |
1 files changed, 59 insertions, 0 deletions
| @@ -29,12 +29,51 @@ | |||
| 29 | 29 | ||
| 30 | #include <libiphone/libiphone.h> | 30 | #include <libiphone/libiphone.h> |
| 31 | 31 | ||
| 32 | void perform_syncWillStart(iphone_device_t phone, iphone_lckd_client_t control) | ||
| 33 | { | ||
| 34 | int nport = 0; | ||
| 35 | iphone_np_client_t np; | ||
| 36 | |||
| 37 | iphone_lckd_start_service(control, "com.apple.mobile.notification_proxy", &nport); | ||
| 38 | if (nport) { | ||
| 39 | printf("::::::::::::::: np was started ::::::::::::\n"); | ||
| 40 | iphone_np_new_client(phone, 3555, nport, &np); | ||
| 41 | if (np) { | ||
| 42 | printf("::::::::: PostNotification com.apple.itunes-mobdev.syncWillStart\n"); | ||
| 43 | iphone_np_post_notification(np, "com.apple.itunes-mobdev.syncWillStart"); | ||
| 44 | iphone_np_free_client(np); | ||
| 45 | } | ||
| 46 | } else { | ||
| 47 | printf("::::::::::::::: np was NOT started ::::::::::::\n"); | ||
| 48 | } | ||
| 49 | } | ||
| 50 | |||
| 51 | void perform_syncDidStart(iphone_device_t phone, iphone_lckd_client_t control) | ||
| 52 | { | ||
| 53 | int nport = 0; | ||
| 54 | iphone_np_client_t np; | ||
| 55 | |||
| 56 | iphone_lckd_start_service(control, "com.apple.mobile.notification_proxy", &nport); | ||
| 57 | if (nport) { | ||
| 58 | printf("::::::::::::::: np was started ::::::::::::\n"); | ||
| 59 | sleep(1); | ||
| 60 | iphone_np_new_client(phone, 3555, nport, &np); | ||
| 61 | if (np) { | ||
| 62 | printf("::::::::: PostNotification com.apple.itunes-mobdev.syncDidStart\n"); | ||
| 63 | iphone_np_post_notification(np, "com.apple.itunes-mobdev.syncDidStart"); | ||
| 64 | iphone_np_free_client(np); | ||
| 65 | } | ||
| 66 | } else { | ||
| 67 | printf("::::::::::::::: np was NOT started ::::::::::::\n"); | ||
| 68 | } | ||
| 69 | } | ||
| 32 | 70 | ||
| 33 | int main(int argc, char *argv[]) | 71 | int main(int argc, char *argv[]) |
| 34 | { | 72 | { |
| 35 | int bytes = 0, port = 0, i = 0; | 73 | int bytes = 0, port = 0, i = 0; |
| 36 | iphone_lckd_client_t control = NULL; | 74 | iphone_lckd_client_t control = NULL; |
| 37 | iphone_device_t phone = NULL; | 75 | iphone_device_t phone = NULL; |
| 76 | iphone_afc_file_t lockfile = NULL; | ||
| 38 | 77 | ||
| 39 | if (argc > 1 && !strcasecmp(argv[1], "--debug")) { | 78 | if (argc > 1 && !strcasecmp(argv[1], "--debug")) { |
| 40 | iphone_set_debug(1); | 79 | 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 { |
