summaryrefslogtreecommitdiffstats
path: root/cython/mobilesync.pxi
diff options
context:
space:
mode:
authorGravatar Bryan Forbes2010-03-17 01:12:52 -0500
committerGravatar Martin Szulecki2012-03-20 23:25:54 +0100
commitcfe6244f8954efce4ef12b9b4338cc0d41a9ff40 (patch)
tree8b181941ea31e9f8a16930536b429178ce7d4afe /cython/mobilesync.pxi
parentbc6886898d03d28dc30c90db18c2a5f90f20c746 (diff)
downloadlibimobiledevice-cfe6244f8954efce4ef12b9b4338cc0d41a9ff40.tar.gz
libimobiledevice-cfe6244f8954efce4ef12b9b4338cc0d41a9ff40.tar.bz2
Moved everything but iDevice and LockdownClient to pxi files.
Added MobileBackupClient and PropertyListService.
Diffstat (limited to 'cython/mobilesync.pxi')
-rw-r--r--cython/mobilesync.pxi54
1 files changed, 54 insertions, 0 deletions
diff --git a/cython/mobilesync.pxi b/cython/mobilesync.pxi
new file mode 100644
index 0000000..b9cf951
--- /dev/null
+++ b/cython/mobilesync.pxi
@@ -0,0 +1,54 @@
1cdef extern from "libimobiledevice/mobilesync.h":
2 cdef struct mobilesync_client_int:
3 pass
4 ctypedef mobilesync_client_int *mobilesync_client_t
5
6 ctypedef int16_t mobilesync_error_t
7 int16_t MOBILESYNC_E_SUCCESS
8 int16_t MOBILESYNC_E_INVALID_ARG
9 int16_t MOBILESYNC_E_PLIST_ERROR
10 int16_t MOBILESYNC_E_MUX_ERROR
11 int16_t MOBILESYNC_E_BAD_VERSION
12 int16_t MOBILESYNC_E_UNKNOWN_ERROR
13
14 mobilesync_error_t mobilesync_client_new(idevice_t device, uint16_t port, mobilesync_client_t * client)
15 mobilesync_error_t mobilesync_client_free(mobilesync_client_t client)
16 mobilesync_error_t mobilesync_receive(mobilesync_client_t client, plist.plist_t *plist)
17 mobilesync_error_t mobilesync_send(mobilesync_client_t client, plist.plist_t plist)
18
19cdef class MobileSyncError(BaseError):
20 def __init__(self, *args, **kwargs):
21 self._lookup_table = {
22 MOBILESYNC_E_SUCCESS: "Success",
23 MOBILESYNC_E_INVALID_ARG: "Invalid argument",
24 MOBILESYNC_E_PLIST_ERROR: "PList Error",
25 MOBILESYNC_E_MUX_ERROR: "MUX Error",
26 MOBILESYNC_E_BAD_VERSION: "Bad Version",
27 MOBILESYNC_E_UNKNOWN_ERROR: "Unknown error"
28 }
29 BaseError.__init__(self, *args, **kwargs)
30
31cdef class MobileSyncClient(PropertyListService):
32 cdef mobilesync_client_t _c_client
33
34 def __cinit__(self, iDevice device not None, LockdownClient lockdown=None, *args, **kwargs):
35 cdef iDevice dev = device
36 cdef LockdownClient lckd
37 if lockdown is None:
38 lckd = LockdownClient(dev)
39 else:
40 lckd = lockdown
41 port = lckd.start_service("com.apple.mobilesync")
42 err = MobileSyncError(mobilesync_client_new(dev._c_dev, port, &(self._c_client)))
43 if err: raise err
44
45 def __dealloc__(self):
46 if self._c_client is not NULL:
47 err = MobileSyncError(mobilesync_client_free(self._c_client))
48 if err: raise err
49
50 cdef _send(self, plist.plist_t node):
51 return MobileSyncError(mobilesync_send(self._c_client, node))
52
53 cdef _receive(self, plist.plist_t* node):
54 return MobileSyncError(mobilesync_receive(self._c_client, node))