diff options
Diffstat (limited to 'dev')
| -rw-r--r-- | dev/Makefile.am | 9 | ||||
| -rw-r--r-- | dev/lckdclient.c | 1 | ||||
| -rw-r--r-- | dev/main.c | 5 | ||||
| -rwxr-xr-x | dev/msync.py | 40 | ||||
| -rw-r--r-- | dev/msyncclient.c | 72 |
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 | |||
| 3 | AM_CFLAGS = $(libxml2_CFLAGS) $(libusb_CFLAGS) $(libglib2_CFLAGS) $(libgnutls_CFLAGS) $(libtasn1_CFLAGS) $(libgthread2_CFLAGS) -g | 3 | AM_CFLAGS = $(libxml2_CFLAGS) $(libusb_CFLAGS) $(libglib2_CFLAGS) $(libgnutls_CFLAGS) $(libtasn1_CFLAGS) $(libgthread2_CFLAGS) -g |
| 4 | AM_LDFLAGS = $(libxml2_LIBS) $(libusb_LIBS) $(libglib2_LIBS) $(libgnutls_LIBS) $(libtasn1_LIBS) $(libgthread2_LIBS) | 4 | AM_LDFLAGS = $(libxml2_LIBS) $(libusb_LIBS) $(libglib2_LIBS) $(libgnutls_LIBS) $(libtasn1_LIBS) $(libgthread2_LIBS) |
| 5 | 5 | ||
| 6 | bin_PROGRAMS = iphoneclient lckd-client afccheck | 6 | bin_PROGRAMS = iphoneclient lckd-client afccheck msyncclient |
| 7 | 7 | ||
| 8 | iphoneclient_SOURCES = main.c | 8 | iphoneclient_SOURCES = main.c |
| 9 | iphoneclient_LDADD = ../src/libiphone.la | 9 | iphoneclient_LDADD = ../src/libiphone.la |
| @@ -16,4 +16,9 @@ lckd_client_LDADD = ../src/libiphone.la | |||
| 16 | afccheck_SOURCES = afccheck.c | 16 | afccheck_SOURCES = afccheck.c |
| 17 | afccheck_CFLAGS = $(AM_CFLAGS) | 17 | afccheck_CFLAGS = $(AM_CFLAGS) |
| 18 | afccheck_LDFLAGS = $(AM_LDFLAGS) | 18 | afccheck_LDFLAGS = $(AM_LDFLAGS) |
| 19 | afccheck_LDADD = ../src/libiphone.la \ No newline at end of file | 19 | afccheck_LDADD = ../src/libiphone.la |
| 20 | |||
| 21 | msyncclient_SOURCES = msyncclient.c | ||
| 22 | msyncclient_CFLAGS = $(AM_CFLAGS) | ||
| 23 | msyncclient_LDFLAGS = $(AM_LDFLAGS) | ||
| 24 | 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 @@ | |||
| 20 | */ | 20 | */ |
| 21 | 21 | ||
| 22 | #include <stdio.h> | 22 | #include <stdio.h> |
| 23 | #include <stdlib.h> | ||
| 23 | #include <string.h> | 24 | #include <string.h> |
| 24 | #include <glib.h> | 25 | #include <glib.h> |
| 25 | #include <readline/readline.h> | 26 | #include <readline/readline.h> |
| @@ -28,6 +28,7 @@ | |||
| 28 | #include <libxml/tree.h> | 28 | #include <libxml/tree.h> |
| 29 | 29 | ||
| 30 | #include <libiphone/libiphone.h> | 30 | #include <libiphone/libiphone.h> |
| 31 | #include "../src/utils.h" | ||
| 31 | 32 | ||
| 32 | 33 | ||
| 33 | int main(int argc, char *argv[]) | 34 | int main(int argc, char *argv[]) |
| @@ -38,8 +39,10 @@ int main(int argc, char *argv[]) | |||
| 38 | 39 | ||
| 39 | if (argc > 1 && !strcasecmp(argv[1], "--debug")) { | 40 | if (argc > 1 && !strcasecmp(argv[1], "--debug")) { |
| 40 | iphone_set_debug(1); | 41 | iphone_set_debug(1); |
| 42 | iphone_set_debug_mask(DBGMASK_ALL); | ||
| 41 | } else { | 43 | } else { |
| 42 | iphone_set_debug(0); | 44 | iphone_set_debug(0); |
| 45 | iphone_set_debug_mask(DBGMASK_NONE); | ||
| 43 | } | 46 | } |
| 44 | 47 | ||
| 45 | if (IPHONE_E_SUCCESS != iphone_get_device(&phone)) { | 48 | if (IPHONE_E_SUCCESS != iphone_get_device(&phone)) { |
| @@ -87,7 +90,7 @@ int main(int argc, char *argv[]) | |||
| 87 | iphone_afc_get_file_attr(afc, "/iTunesOnTheGoPlaylist.plist", &stbuf); | 90 | iphone_afc_get_file_attr(afc, "/iTunesOnTheGoPlaylist.plist", &stbuf); |
| 88 | if (IPHONE_E_SUCCESS == | 91 | if (IPHONE_E_SUCCESS == |
| 89 | iphone_afc_open_file(afc, "/iTunesOnTheGoPlaylist.plist", IPHONE_AFC_FILE_READ, &my_file) && my_file) { | 92 | iphone_afc_open_file(afc, "/iTunesOnTheGoPlaylist.plist", IPHONE_AFC_FILE_READ, &my_file) && my_file) { |
| 90 | printf("A file size: %i\n", stbuf.st_size); | 93 | printf("A file size: %i\n", (int) stbuf.st_size); |
| 91 | char *file_data = (char *) malloc(sizeof(char) * stbuf.st_size); | 94 | char *file_data = (char *) malloc(sizeof(char) * stbuf.st_size); |
| 92 | iphone_afc_read_file(afc, my_file, file_data, stbuf.st_size, &bytes); | 95 | iphone_afc_read_file(afc, my_file, file_data, stbuf.st_size, &bytes); |
| 93 | if (bytes >= 0) { | 96 | 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 @@ | |||
| 1 | #! /usr/bin/env python | ||
| 2 | |||
| 3 | from libiphone.iPhone import * | ||
| 4 | |||
| 5 | # get msync client | ||
| 6 | def GetMobileSyncClient() : | ||
| 7 | phone = iPhone() | ||
| 8 | if not phone.InitDevice() : | ||
| 9 | print "Couldn't find device, is it connected ?\n" | ||
| 10 | return None | ||
| 11 | lckd = phone.GetLockdownClient() | ||
| 12 | if not lckd : | ||
| 13 | print "Failed to start lockdown service.\n" | ||
| 14 | return None | ||
| 15 | msync = lckd.GetMobileSyncClient() | ||
| 16 | if not msync : | ||
| 17 | print "Failed to start mobilesync service.\n" | ||
| 18 | return None | ||
| 19 | return msync | ||
| 20 | |||
| 21 | |||
| 22 | msync = GetMobileSyncClient() | ||
| 23 | |||
| 24 | if not msync : | ||
| 25 | exit(1) | ||
| 26 | |||
| 27 | array = PListNode(PLIST_ARRAY) | ||
| 28 | array.AddSubString("SDMessageSyncDataClassWithDevice") | ||
| 29 | array.AddSubString("com.apple.Contacts"); | ||
| 30 | array.AddSubString("---"); | ||
| 31 | array.AddSubString("2009-01-13 22:25:58 +0100"); | ||
| 32 | array.AddSubUInt(106); | ||
| 33 | array.AddSubString("___EmptyParameterString___"); | ||
| 34 | |||
| 35 | msync.Send(array) | ||
| 36 | array = msync.Receive() | ||
| 37 | print array.ToXml() | ||
| 38 | |||
| 39 | |||
| 40 | |||
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 @@ | |||
| 1 | /* | ||
| 2 | * msyncclient.c | ||
| 3 | * Rudimentary interface to the MobileSync iPhone | ||
| 4 | * | ||
| 5 | * Copyright (c) 2009 Jonathan Beck All Rights Reserved. | ||
| 6 | * | ||
| 7 | * This library is free software; you can redistribute it and/or | ||
| 8 | * modify it under the terms of the GNU Lesser General Public | ||
| 9 | * License as published by the Free Software Foundation; either | ||
| 10 | * version 2.1 of the License, or (at your option) any later version. | ||
| 11 | * | ||
| 12 | * This library is distributed in the hope that it will be useful, | ||
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 15 | * Lesser General Public License for more details. | ||
| 16 | * | ||
| 17 | * You should have received a copy of the GNU Lesser General Public | ||
| 18 | * License along with this library; if not, write to the Free Software | ||
| 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 20 | */ | ||
| 21 | |||
| 22 | #include <stdio.h> | ||
| 23 | #include <string.h> | ||
| 24 | #include <errno.h> | ||
| 25 | #include <usb.h> | ||
| 26 | |||
| 27 | #include <libxml/parser.h> | ||
| 28 | #include <libxml/tree.h> | ||
| 29 | |||
| 30 | #include <libiphone/libiphone.h> | ||
| 31 | |||
| 32 | |||
| 33 | int main(int argc, char *argv[]) | ||
| 34 | { | ||
| 35 | int bytes = 0, port = 0, i = 0; | ||
| 36 | iphone_lckd_client_t control = NULL; | ||
| 37 | iphone_device_t phone = NULL; | ||
| 38 | |||
| 39 | if (argc > 1 && !strcasecmp(argv[1], "--debug")) | ||
| 40 | iphone_set_debug_mask(DBGMASK_MOBILESYNC); | ||
| 41 | |||
| 42 | |||
| 43 | if (IPHONE_E_SUCCESS != iphone_get_device(&phone)) { | ||
| 44 | printf("No iPhone found, is it plugged in?\n"); | ||
| 45 | return -1; | ||
| 46 | } | ||
| 47 | |||
| 48 | if (IPHONE_E_SUCCESS != iphone_lckd_new_client(phone, &control)) { | ||
| 49 | iphone_free_device(phone); | ||
| 50 | return -1; | ||
| 51 | } | ||
| 52 | |||
| 53 | iphone_lckd_start_service(control, "com.apple.mobilesync", &port); | ||
| 54 | |||
| 55 | if (port) { | ||
| 56 | iphone_msync_client_t msync = NULL; | ||
| 57 | iphone_msync_new_client(phone, 3432, port, &msync); | ||
| 58 | if (msync) { | ||
| 59 | iphone_msync_get_all_contacts(msync); | ||
| 60 | iphone_msync_free_client(msync); | ||
| 61 | } | ||
| 62 | } else { | ||
| 63 | printf("Start service failure.\n"); | ||
| 64 | } | ||
| 65 | |||
| 66 | printf("All done.\n"); | ||
| 67 | |||
| 68 | iphone_lckd_free_client(control); | ||
| 69 | iphone_free_device(phone); | ||
| 70 | |||
| 71 | return 0; | ||
| 72 | } | ||
