diff options
| author | 2009-04-13 08:48:00 -0700 | |
|---|---|---|
| committer | 2009-04-13 08:48:00 -0700 | |
| commit | 6671ca3d6de6a1fd27853e3b1ce7a81d568703f0 (patch) | |
| tree | 735c5ace7ed57cd4e19f2fde423b22e6104eaa98 /dev | |
| parent | bd31783d7fde0b5bd101f4a3f97ca1aca2aa6fab (diff) | |
| parent | 288929f45cb2641690879b52ec514097995cd41a (diff) | |
| download | libimobiledevice-6671ca3d6de6a1fd27853e3b1ce7a81d568703f0.tar.gz libimobiledevice-6671ca3d6de6a1fd27853e3b1ce7a81d568703f0.tar.bz2 | |
Merged in Jonathan's libplist libiphone. [#2 state:resolved]
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 @@ | |||
| 1 | INCLUDES = -I$(top_srcdir)/include | 1 | INCLUDES = -I$(top_srcdir)/include |
| 2 | 2 | ||
| 3 | AM_CFLAGS = $(libxml2_CFLAGS) $(libusb_CFLAGS) $(libglib2_CFLAGS) $(libgnutls_CFLAGS) $(libtasn1_CFLAGS) $(libgthread2_CFLAGS) -g $(LFS_CFLAGS) | 3 | AM_CFLAGS = $(GLOBAL_CFLAGS) $(libusb_CFLAGS) $(libglib2_CFLAGS) $(libgnutls_CFLAGS) $(libtasn1_CFLAGS) $(libgthread2_CFLAGS) $(LFS_CFLAGS) |
| 4 | AM_LDFLAGS = $(libxml2_LIBS) $(libusb_LIBS) $(libglib2_LIBS) $(libgnutls_LIBS) $(libtasn1_LIBS) $(libgthread2_LIBS) | 4 | AM_LDFLAGS = $(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 |
| @@ -17,3 +17,9 @@ 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 | 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 | ||
| 25 | |||
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> |
| @@ -24,10 +24,8 @@ | |||
| 24 | #include <errno.h> | 24 | #include <errno.h> |
| 25 | #include <usb.h> | 25 | #include <usb.h> |
| 26 | 26 | ||
| 27 | #include <libxml/parser.h> | ||
| 28 | #include <libxml/tree.h> | ||
| 29 | |||
| 30 | #include <libiphone/libiphone.h> | 27 | #include <libiphone/libiphone.h> |
| 28 | #include "../src/utils.h" | ||
| 31 | 29 | ||
| 32 | void perform_syncWillStart(iphone_device_t phone, iphone_lckd_client_t control) | 30 | void perform_syncWillStart(iphone_device_t phone, iphone_lckd_client_t control) |
| 33 | { | 31 | { |
| @@ -77,8 +75,10 @@ int main(int argc, char *argv[]) | |||
| 77 | 75 | ||
| 78 | if (argc > 1 && !strcasecmp(argv[1], "--debug")) { | 76 | if (argc > 1 && !strcasecmp(argv[1], "--debug")) { |
| 79 | iphone_set_debug(1); | 77 | iphone_set_debug(1); |
| 78 | iphone_set_debug_mask(DBGMASK_ALL); | ||
| 80 | } else { | 79 | } else { |
| 81 | iphone_set_debug(0); | 80 | iphone_set_debug(0); |
| 81 | iphone_set_debug_mask(DBGMASK_NONE); | ||
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | if (IPHONE_E_SUCCESS != iphone_get_device(&phone)) { | 84 | if (IPHONE_E_SUCCESS != iphone_get_device(&phone)) { |
| @@ -136,7 +136,7 @@ int main(int argc, char *argv[]) | |||
| 136 | iphone_afc_get_file_attr(afc, "/iTunesOnTheGoPlaylist.plist", &stbuf); | 136 | iphone_afc_get_file_attr(afc, "/iTunesOnTheGoPlaylist.plist", &stbuf); |
| 137 | if (IPHONE_E_SUCCESS == | 137 | if (IPHONE_E_SUCCESS == |
| 138 | iphone_afc_open_file(afc, "/iTunesOnTheGoPlaylist.plist", IPHONE_AFC_FILE_READ, &my_file) && my_file) { | 138 | iphone_afc_open_file(afc, "/iTunesOnTheGoPlaylist.plist", IPHONE_AFC_FILE_READ, &my_file) && my_file) { |
| 139 | printf("A file size: %i\n", stbuf.st_size); | 139 | printf("A file size: %i\n", (int) stbuf.st_size); |
| 140 | char *file_data = (char *) malloc(sizeof(char) * stbuf.st_size); | 140 | char *file_data = (char *) malloc(sizeof(char) * stbuf.st_size); |
| 141 | iphone_afc_read_file(afc, my_file, file_data, stbuf.st_size, &bytes); | 141 | iphone_afc_read_file(afc, my_file, file_data, stbuf.st_size, &bytes); |
| 142 | if (bytes >= 0) { | 142 | 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..804e1ed --- /dev/null +++ b/dev/msyncclient.c | |||
| @@ -0,0 +1,69 @@ | |||
| 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 <libiphone/libiphone.h> | ||
| 28 | |||
| 29 | |||
| 30 | int main(int argc, char *argv[]) | ||
| 31 | { | ||
| 32 | int bytes = 0, port = 0, i = 0; | ||
| 33 | iphone_lckd_client_t control = NULL; | ||
| 34 | iphone_device_t phone = NULL; | ||
| 35 | |||
| 36 | if (argc > 1 && !strcasecmp(argv[1], "--debug")) | ||
| 37 | iphone_set_debug_mask(DBGMASK_MOBILESYNC); | ||
| 38 | |||
| 39 | |||
| 40 | if (IPHONE_E_SUCCESS != iphone_get_device(&phone)) { | ||
| 41 | printf("No iPhone found, is it plugged in?\n"); | ||
| 42 | return -1; | ||
| 43 | } | ||
| 44 | |||
| 45 | if (IPHONE_E_SUCCESS != iphone_lckd_new_client(phone, &control)) { | ||
| 46 | iphone_free_device(phone); | ||
| 47 | return -1; | ||
| 48 | } | ||
| 49 | |||
| 50 | iphone_lckd_start_service(control, "com.apple.mobilesync", &port); | ||
| 51 | |||
| 52 | if (port) { | ||
| 53 | iphone_msync_client_t msync = NULL; | ||
| 54 | iphone_msync_new_client(phone, 3432, port, &msync); | ||
| 55 | if (msync) { | ||
| 56 | iphone_msync_get_all_contacts(msync); | ||
| 57 | iphone_msync_free_client(msync); | ||
| 58 | } | ||
| 59 | } else { | ||
| 60 | printf("Start service failure.\n"); | ||
| 61 | } | ||
| 62 | |||
| 63 | printf("All done.\n"); | ||
| 64 | |||
| 65 | iphone_lckd_free_client(control); | ||
| 66 | iphone_free_device(phone); | ||
| 67 | |||
| 68 | return 0; | ||
| 69 | } | ||
