summaryrefslogtreecommitdiffstats
path: root/dev/msyncclient.c
diff options
context:
space:
mode:
Diffstat (limited to 'dev/msyncclient.c')
-rw-r--r--dev/msyncclient.c69
1 files changed, 69 insertions, 0 deletions
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}