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 @@
INCLUDES = -I$(top_srcdir)/include
-AM_CFLAGS = $(GLOBAL_CFLAGS) $(libusb_CFLAGS) $(libglib2_CFLAGS) $(libgnutls_CFLAGS) $(libtasn1_CFLAGS) $(libgthread2_CFLAGS) -g
+AM_CFLAGS = $(GLOBAL_CFLAGS) $(libusb_CFLAGS) $(libglib2_CFLAGS) $(libgnutls_CFLAGS) $(libtasn1_CFLAGS) $(libgthread2_CFLAGS) $(LFS_CFLAGS)
AM_LDFLAGS = $(libusb_LIBS) $(libglib2_LIBS) $(libgnutls_LIBS) $(libtasn1_LIBS) $(libgthread2_LIBS)
bin_PROGRAMS = iphoneclient lckd-client afccheck msyncclient
@@ -22,3 +22,4 @@ msyncclient_SOURCES = msyncclient.c
msyncclient_CFLAGS = $(AM_CFLAGS)
msyncclient_LDFLAGS = $(AM_LDFLAGS)
msyncclient_LDADD = ../src/libiphone.la
+
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 @@
#include <libiphone/libiphone.h>
#include "../src/utils.h"
+void perform_syncWillStart(iphone_device_t phone, iphone_lckd_client_t control)
+{
+ int nport = 0;
+ iphone_np_client_t np;
+
+ iphone_lckd_start_service(control, "com.apple.mobile.notification_proxy", &nport);
+ if (nport) {
+ printf("::::::::::::::: np was started ::::::::::::\n");
+ iphone_np_new_client(phone, 3555, nport, &np);
+ if (np) {
+ printf("::::::::: PostNotification com.apple.itunes-mobdev.syncWillStart\n");
+ iphone_np_post_notification(np, "com.apple.itunes-mobdev.syncWillStart");
+ iphone_np_free_client(np);
+ }
+ } else {
+ printf("::::::::::::::: np was NOT started ::::::::::::\n");
+ }
+}
+
+void perform_syncDidStart(iphone_device_t phone, iphone_lckd_client_t control)
+{
+ int nport = 0;
+ iphone_np_client_t np;
+
+ iphone_lckd_start_service(control, "com.apple.mobile.notification_proxy", &nport);
+ if (nport) {
+ printf("::::::::::::::: np was started ::::::::::::\n");
+ sleep(1);
+ iphone_np_new_client(phone, 3555, nport, &np);
+ if (np) {
+ printf("::::::::: PostNotification com.apple.itunes-mobdev.syncDidStart\n");
+ iphone_np_post_notification(np, "com.apple.itunes-mobdev.syncDidStart");
+ iphone_np_free_client(np);
+ }
+ } else {
+ printf("::::::::::::::: np was NOT started ::::::::::::\n");
+ }
+}
int main(int argc, char *argv[])
{
int bytes = 0, port = 0, i = 0;
iphone_lckd_client_t control = NULL;
iphone_device_t phone = NULL;
+ iphone_afc_file_t lockfile = NULL;
if (argc > 1 && !strcasecmp(argv[1], "--debug")) {
iphone_set_debug(1);
@@ -64,6 +103,16 @@ int main(int argc, char *argv[])
iphone_afc_client_t afc = NULL;
iphone_afc_new_client(phone, 3432, port, &afc);
if (afc) {
+ perform_syncWillStart(phone, control);
+
+ iphone_afc_open_file(afc, "/com.apple.itunes.lock_sync", IPHONE_AFC_FILE_WRITE, &lockfile);
+ if (lockfile) {
+ printf("locking file\n");
+ iphone_afc_lock_file(afc, lockfile, 2 | 4);
+
+ perform_syncDidStart(phone, control);
+ }
+
char **dirs = NULL;
iphone_afc_get_dir_list(afc, "/eafaedf", &dirs);
if (!dirs)
@@ -138,7 +187,17 @@ int main(int argc, char *argv[])
printf("Couldn't read!\n");
free(threeletterword);
iphone_afc_close_file(afc, my_file);
+ }
+
+ if (lockfile) {
+ printf("XXX sleeping 2 seconds\n");
+ sleep(2);
+
+ printf("XXX unlocking file\n");
+ iphone_afc_lock_file(afc, lockfile, 8 | 4);
+ printf("XXX closing file\n");
+ iphone_afc_close_file(afc, lockfile);
}
iphone_afc_free_client(afc);
} else {