summaryrefslogtreecommitdiffstats
path: root/dev
diff options
context:
space:
mode:
Diffstat (limited to 'dev')
-rw-r--r--dev/Makefile.am9
-rw-r--r--dev/lckdclient.c1
-rw-r--r--dev/main.c5
-rwxr-xr-xdev/msync.py40
-rw-r--r--dev/msyncclient.c72
5 files changed, 124 insertions, 3 deletions
diff --git a/dev/Makefile.am b/dev/Makefile.am
index 4833728..7ca7e99 100644
--- a/dev/Makefile.am
+++ b/dev/Makefile.am
@@ -3,7 +3,7 @@ INCLUDES = -I$(top_srcdir)/include
AM_CFLAGS = $(libxml2_CFLAGS) $(libusb_CFLAGS) $(libglib2_CFLAGS) $(libgnutls_CFLAGS) $(libtasn1_CFLAGS) $(libgthread2_CFLAGS) -g
AM_LDFLAGS = $(libxml2_LIBS) $(libusb_LIBS) $(libglib2_LIBS) $(libgnutls_LIBS) $(libtasn1_LIBS) $(libgthread2_LIBS)
-bin_PROGRAMS = iphoneclient lckd-client afccheck
+bin_PROGRAMS = iphoneclient lckd-client afccheck msyncclient
iphoneclient_SOURCES = main.c
iphoneclient_LDADD = ../src/libiphone.la
@@ -16,4 +16,9 @@ lckd_client_LDADD = ../src/libiphone.la
afccheck_SOURCES = afccheck.c
afccheck_CFLAGS = $(AM_CFLAGS)
afccheck_LDFLAGS = $(AM_LDFLAGS)
-afccheck_LDADD = ../src/libiphone.la \ No newline at end of file
+afccheck_LDADD = ../src/libiphone.la
+
+msyncclient_SOURCES = msyncclient.c
+msyncclient_CFLAGS = $(AM_CFLAGS)
+msyncclient_LDFLAGS = $(AM_LDFLAGS)
+msyncclient_LDADD = ../src/libiphone.la
diff --git a/dev/lckdclient.c b/dev/lckdclient.c
index 96bc27d..c96f052 100644
--- a/dev/lckdclient.c
+++ b/dev/lckdclient.c
@@ -20,6 +20,7 @@
*/
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <readline/readline.h>
diff --git a/dev/main.c b/dev/main.c
index 2dbfb4a..f865e52 100644
--- a/dev/main.c
+++ b/dev/main.c
@@ -28,6 +28,7 @@
#include <libxml/tree.h>
#include <libiphone/libiphone.h>
+#include "../src/utils.h"
int main(int argc, char *argv[])
@@ -38,8 +39,10 @@ int main(int argc, char *argv[])
if (argc > 1 && !strcasecmp(argv[1], "--debug")) {
iphone_set_debug(1);
+ iphone_set_debug_mask(DBGMASK_ALL);
} else {
iphone_set_debug(0);
+ iphone_set_debug_mask(DBGMASK_NONE);
}
if (IPHONE_E_SUCCESS != iphone_get_device(&phone)) {
@@ -87,7 +90,7 @@ int main(int argc, char *argv[])
iphone_afc_get_file_attr(afc, "/iTunesOnTheGoPlaylist.plist", &stbuf);
if (IPHONE_E_SUCCESS ==
iphone_afc_open_file(afc, "/iTunesOnTheGoPlaylist.plist", IPHONE_AFC_FILE_READ, &my_file) && my_file) {
- printf("A file size: %i\n", stbuf.st_size);
+ printf("A file size: %i\n", (int) stbuf.st_size);
char *file_data = (char *) malloc(sizeof(char) * stbuf.st_size);
iphone_afc_read_file(afc, my_file, file_data, stbuf.st_size, &bytes);
if (bytes >= 0) {
diff --git a/dev/msync.py b/dev/msync.py
new file mode 100755
index 0000000..4170f87
--- /dev/null
+++ b/dev/msync.py
@@ -0,0 +1,40 @@
+#! /usr/bin/env python
+
+from libiphone.iPhone import *
+
+# get msync client
+def GetMobileSyncClient() :
+ phone = iPhone()
+ if not phone.InitDevice() :
+ print "Couldn't find device, is it connected ?\n"
+ return None
+ lckd = phone.GetLockdownClient()
+ if not lckd :
+ print "Failed to start lockdown service.\n"
+ return None
+ msync = lckd.GetMobileSyncClient()
+ if not msync :
+ print "Failed to start mobilesync service.\n"
+ return None
+ return msync
+
+
+msync = GetMobileSyncClient()
+
+if not msync :
+ exit(1)
+
+array = PListNode(PLIST_ARRAY)
+array.AddSubString("SDMessageSyncDataClassWithDevice")
+array.AddSubString("com.apple.Contacts");
+array.AddSubString("---");
+array.AddSubString("2009-01-13 22:25:58 +0100");
+array.AddSubUInt(106);
+array.AddSubString("___EmptyParameterString___");
+
+msync.Send(array)
+array = msync.Receive()
+print array.ToXml()
+
+
+
diff --git a/dev/msyncclient.c b/dev/msyncclient.c
new file mode 100644
index 0000000..2762f04
--- /dev/null
+++ b/dev/msyncclient.c
@@ -0,0 +1,72 @@
+/*
+ * msyncclient.c
+ * Rudimentary interface to the MobileSync iPhone
+ *
+ * Copyright (c) 2009 Jonathan Beck All Rights Reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <usb.h>
+
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+
+#include <libiphone/libiphone.h>
+
+
+int main(int argc, char *argv[])
+{
+ int bytes = 0, port = 0, i = 0;
+ iphone_lckd_client_t control = NULL;
+ iphone_device_t phone = NULL;
+
+ if (argc > 1 && !strcasecmp(argv[1], "--debug"))
+ iphone_set_debug_mask(DBGMASK_MOBILESYNC);
+
+
+ if (IPHONE_E_SUCCESS != iphone_get_device(&phone)) {
+ printf("No iPhone found, is it plugged in?\n");
+ return -1;
+ }
+
+ if (IPHONE_E_SUCCESS != iphone_lckd_new_client(phone, &control)) {
+ iphone_free_device(phone);
+ return -1;
+ }
+
+ iphone_lckd_start_service(control, "com.apple.mobilesync", &port);
+
+ if (port) {
+ iphone_msync_client_t msync = NULL;
+ iphone_msync_new_client(phone, 3432, port, &msync);
+ if (msync) {
+ iphone_msync_get_all_contacts(msync);
+ iphone_msync_free_client(msync);
+ }
+ } else {
+ printf("Start service failure.\n");
+ }
+
+ printf("All done.\n");
+
+ iphone_lckd_free_client(control);
+ iphone_free_device(phone);
+
+ return 0;
+}