diff options
Diffstat (limited to 'dev')
-rw-r--r-- | dev/Makefile.am | 12 | ||||
-rw-r--r-- | dev/lckdclient.c | 1 | ||||
-rw-r--r-- | dev/main.c | 8 | ||||
-rwxr-xr-x | dev/msync.py | 40 | ||||
-rw-r--r-- | dev/msyncclient.c | 69 |
5 files changed, 123 insertions, 7 deletions
diff --git a/dev/Makefile.am b/dev/Makefile.am index 5f85ad7..f7d1109 100644 --- a/dev/Makefile.am +++ b/dev/Makefile.am @@ -1,9 +1,9 @@ INCLUDES = -I$(top_srcdir)/include -AM_CFLAGS = $(libxml2_CFLAGS) $(libusb_CFLAGS) $(libglib2_CFLAGS) $(libgnutls_CFLAGS) $(libtasn1_CFLAGS) $(libgthread2_CFLAGS) -g $(LFS_CFLAGS) -AM_LDFLAGS = $(libxml2_LIBS) $(libusb_LIBS) $(libglib2_LIBS) $(libgnutls_LIBS) $(libtasn1_LIBS) $(libgthread2_LIBS) +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 +bin_PROGRAMS = iphoneclient lckd-client afccheck msyncclient iphoneclient_SOURCES = main.c iphoneclient_LDADD = ../src/libiphone.la @@ -17,3 +17,9 @@ afccheck_SOURCES = afccheck.c afccheck_CFLAGS = $(AM_CFLAGS) afccheck_LDFLAGS = $(AM_LDFLAGS) 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> @@ -24,10 +24,8 @@ #include <errno.h> #include <usb.h> -#include <libxml/parser.h> -#include <libxml/tree.h> - #include <libiphone/libiphone.h> +#include "../src/utils.h" void perform_syncWillStart(iphone_device_t phone, iphone_lckd_client_t control) { @@ -77,8 +75,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)) { @@ -136,7 +136,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..804e1ed --- /dev/null +++ b/dev/msyncclient.c @@ -0,0 +1,69 @@ +/* + * 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 <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; +} |