summaryrefslogtreecommitdiffstats
path: root/dev/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'dev/main.c')
-rw-r--r--dev/main.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/dev/main.c b/dev/main.c
index 2dbfb4a..c68427b 100644
--- a/dev/main.c
+++ b/dev/main.c
@@ -29,12 +29,51 @@
29 29
30#include <libiphone/libiphone.h> 30#include <libiphone/libiphone.h>
31 31
32void 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
51void 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
33int main(int argc, char *argv[]) 71int 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 {