summaryrefslogtreecommitdiffstats
path: root/dev
diff options
context:
space:
mode:
authorGravatar Jonathan Beck2009-03-16 21:40:33 +0100
committerGravatar Jonathan Beck2009-03-16 21:40:33 +0100
commit19992c668afeb53a28e08a1f61572b5379f87590 (patch)
tree4f1784b81afe88a6240889961b5fc3d2b0d6a82e /dev
parent0d05f8de79ee91e9be80c6296eff9ce216582ba4 (diff)
parent201e1ff5bf2054fcb1c0cc3cd7ba1e229dbde3fa (diff)
downloadlibimobiledevice-19992c668afeb53a28e08a1f61572b5379f87590.tar.gz
libimobiledevice-19992c668afeb53a28e08a1f61572b5379f87590.tar.bz2
Merge branch 'master' into contact_sync
Conflicts: configure.ac dev/Makefile.am include/libiphone/libiphone.h src/AFC.c src/AFC.h src/Makefile.am
Diffstat (limited to 'dev')
-rw-r--r--dev/Makefile.am3
-rw-r--r--dev/main.c59
2 files changed, 61 insertions, 1 deletions
diff --git a/dev/Makefile.am b/dev/Makefile.am
index f976ccc..f7d1109 100644
--- a/dev/Makefile.am
+++ b/dev/Makefile.am
@@ -1,6 +1,6 @@
1INCLUDES = -I$(top_srcdir)/include 1INCLUDES = -I$(top_srcdir)/include
2 2
3AM_CFLAGS = $(GLOBAL_CFLAGS) $(libusb_CFLAGS) $(libglib2_CFLAGS) $(libgnutls_CFLAGS) $(libtasn1_CFLAGS) $(libgthread2_CFLAGS) -g 3AM_CFLAGS = $(GLOBAL_CFLAGS) $(libusb_CFLAGS) $(libglib2_CFLAGS) $(libgnutls_CFLAGS) $(libtasn1_CFLAGS) $(libgthread2_CFLAGS) $(LFS_CFLAGS)
4AM_LDFLAGS = $(libusb_LIBS) $(libglib2_LIBS) $(libgnutls_LIBS) $(libtasn1_LIBS) $(libgthread2_LIBS) 4AM_LDFLAGS = $(libusb_LIBS) $(libglib2_LIBS) $(libgnutls_LIBS) $(libtasn1_LIBS) $(libgthread2_LIBS)
5 5
6bin_PROGRAMS = iphoneclient lckd-client afccheck msyncclient 6bin_PROGRAMS = iphoneclient lckd-client afccheck msyncclient
@@ -22,3 +22,4 @@ msyncclient_SOURCES = msyncclient.c
22msyncclient_CFLAGS = $(AM_CFLAGS) 22msyncclient_CFLAGS = $(AM_CFLAGS)
23msyncclient_LDFLAGS = $(AM_LDFLAGS) 23msyncclient_LDFLAGS = $(AM_LDFLAGS)
24msyncclient_LDADD = ../src/libiphone.la 24msyncclient_LDADD = ../src/libiphone.la
25
diff --git a/dev/main.c b/dev/main.c
index 6514bf8..babcf67 100644
--- a/dev/main.c
+++ b/dev/main.c
@@ -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
30void 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
49void 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
31int main(int argc, char *argv[]) 69int 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 {