summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dev/msyncclient.c73
1 files changed, 73 insertions, 0 deletions
diff --git a/dev/msyncclient.c b/dev/msyncclient.c
new file mode 100644
index 0000000..55d07c4
--- /dev/null
+++ b/dev/msyncclient.c
@@ -0,0 +1,73 @@
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#include "../src/MobileSync.h"
32
33
34int main(int argc, char *argv[])
35{
36 int bytes = 0, port = 0, i = 0;
37 iphone_lckd_client_t control = NULL;
38 iphone_device_t phone = NULL;
39
40 if (argc > 1 && !strcasecmp(argv[1], "--debug")) {
41 iphone_set_debug(1);
42 } else {
43 iphone_set_debug(0);
44 }
45
46 if (IPHONE_E_SUCCESS != iphone_get_device(&phone)) {
47 printf("No iPhone found, is it plugged in?\n");
48 return -1;
49 }
50
51 if (IPHONE_E_SUCCESS != iphone_lckd_new_client(phone, &control)) {
52 iphone_free_device(phone);
53 return -1;
54 }
55
56 iphone_lckd_start_service(control, "com.apple.mobilesync", &port);
57
58 if (port) {
59 iphone_msync_client_t msync = NULL;
60 iphone_msync_new_client(phone, 3432, port, &msync);
61 if (msync)
62 iphone_msync_free_client(msync);
63 } else {
64 printf("Start service failure.\n");
65 }
66
67 printf("All done.\n");
68
69 iphone_lckd_free_client(control);
70 iphone_free_device(phone);
71
72 return 0;
73}