summaryrefslogtreecommitdiffstats
path: root/dev
diff options
context:
space:
mode:
authorGravatar Matt Colyer2009-04-13 08:48:00 -0700
committerGravatar Matt Colyer2009-04-13 08:48:00 -0700
commit6671ca3d6de6a1fd27853e3b1ce7a81d568703f0 (patch)
tree735c5ace7ed57cd4e19f2fde423b22e6104eaa98 /dev
parentbd31783d7fde0b5bd101f4a3f97ca1aca2aa6fab (diff)
parent288929f45cb2641690879b52ec514097995cd41a (diff)
downloadlibimobiledevice-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.am12
-rw-r--r--dev/lckdclient.c1
-rw-r--r--dev/main.c8
-rwxr-xr-xdev/msync.py40
-rw-r--r--dev/msyncclient.c69
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 @@
1INCLUDES = -I$(top_srcdir)/include 1INCLUDES = -I$(top_srcdir)/include
2 2
3AM_CFLAGS = $(libxml2_CFLAGS) $(libusb_CFLAGS) $(libglib2_CFLAGS) $(libgnutls_CFLAGS) $(libtasn1_CFLAGS) $(libgthread2_CFLAGS) -g $(LFS_CFLAGS) 3AM_CFLAGS = $(GLOBAL_CFLAGS) $(libusb_CFLAGS) $(libglib2_CFLAGS) $(libgnutls_CFLAGS) $(libtasn1_CFLAGS) $(libgthread2_CFLAGS) $(LFS_CFLAGS)
4AM_LDFLAGS = $(libxml2_LIBS) $(libusb_LIBS) $(libglib2_LIBS) $(libgnutls_LIBS) $(libtasn1_LIBS) $(libgthread2_LIBS) 4AM_LDFLAGS = $(libusb_LIBS) $(libglib2_LIBS) $(libgnutls_LIBS) $(libtasn1_LIBS) $(libgthread2_LIBS)
5 5
6bin_PROGRAMS = iphoneclient lckd-client afccheck 6bin_PROGRAMS = iphoneclient lckd-client afccheck msyncclient
7 7
8iphoneclient_SOURCES = main.c 8iphoneclient_SOURCES = main.c
9iphoneclient_LDADD = ../src/libiphone.la 9iphoneclient_LDADD = ../src/libiphone.la
@@ -17,3 +17,9 @@ afccheck_SOURCES = afccheck.c
17afccheck_CFLAGS = $(AM_CFLAGS) 17afccheck_CFLAGS = $(AM_CFLAGS)
18afccheck_LDFLAGS = $(AM_LDFLAGS) 18afccheck_LDFLAGS = $(AM_LDFLAGS)
19afccheck_LDADD = ../src/libiphone.la 19afccheck_LDADD = ../src/libiphone.la
20
21msyncclient_SOURCES = msyncclient.c
22msyncclient_CFLAGS = $(AM_CFLAGS)
23msyncclient_LDFLAGS = $(AM_LDFLAGS)
24msyncclient_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>
diff --git a/dev/main.c b/dev/main.c
index c68427b..babcf67 100644
--- a/dev/main.c
+++ b/dev/main.c
@@ -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
32void perform_syncWillStart(iphone_device_t phone, iphone_lckd_client_t control) 30void 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
3from libiphone.iPhone import *
4
5# get msync client
6def 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
22msync = GetMobileSyncClient()
23
24if not msync :
25 exit(1)
26
27array = PListNode(PLIST_ARRAY)
28array.AddSubString("SDMessageSyncDataClassWithDevice")
29array.AddSubString("com.apple.Contacts");
30array.AddSubString("---");
31array.AddSubString("2009-01-13 22:25:58 +0100");
32array.AddSubUInt(106);
33array.AddSubString("___EmptyParameterString___");
34
35msync.Send(array)
36array = msync.Receive()
37print 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
30int 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}