summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cython/Makefile.am10
-rw-r--r--cython/afc.pxi8
-rw-r--r--cython/file_relay.pxi75
-rw-r--r--cython/imobiledevice.pxd18
-rw-r--r--cython/imobiledevice.pyx38
-rw-r--r--cython/installation_proxy.pxi210
-rw-r--r--cython/mobile_image_mounter.pxi75
-rw-r--r--cython/mobilebackup.pxi10
-rw-r--r--cython/mobilesync.pxi10
-rw-r--r--cython/notification_proxy.pxi13
-rw-r--r--cython/sbservices.pxi10
-rw-r--r--cython/screenshotr.pxi65
12 files changed, 505 insertions, 37 deletions
diff --git a/cython/Makefile.am b/cython/Makefile.am
index c0ebff6..228ec0c 100644
--- a/cython/Makefile.am
+++ b/cython/Makefile.am
@@ -14,7 +14,11 @@ PXIINCLUDES = \
14 sbservices.pxi \ 14 sbservices.pxi \
15 mobilebackup.pxi \ 15 mobilebackup.pxi \
16 property_list_client.pxi \ 16 property_list_client.pxi \
17 afc.pxi 17 afc.pxi \
18 file_relay.pxi \
19 screenshotr.pxi \
20 installation_proxy.pxi \
21 mobile_image_mounter.pxi
18 22
19CLEANFILES = \ 23CLEANFILES = \
20 *.pyc \ 24 *.pyc \
@@ -26,8 +30,8 @@ EXTRA_DIST = imobiledevice.pyx imobiledevice.pxd $(PXIINCLUDES)
26imobiledevicedir = $(pyexecdir) 30imobiledevicedir = $(pyexecdir)
27imobiledevice_LTLIBRARIES = imobiledevice.la 31imobiledevice_LTLIBRARIES = imobiledevice.la
28imobiledevice_la_SOURCES = imobiledevice.pyx 32imobiledevice_la_SOURCES = imobiledevice.pyx
29imobiledevice_la_CFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/src $(PYTHON_CPPFLAGS) 33imobiledevice_la_CFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/src $(PYTHON_CPPFLAGS) $(libglib2_CFLAGS) $(libgthread2_CFLAGS)
30imobiledevice_la_LDFLAGS = -module -avoid-version $(PYTHON_LDFLAGS) 34imobiledevice_la_LDFLAGS = -module -avoid-version $(PYTHON_LDFLAGS) $(libglib2_LIBS) $(libgthread2_LIBS)
31imobiledevice_la_LIBADD = $(top_builddir)/src/libimobiledevice.la 35imobiledevice_la_LIBADD = $(top_builddir)/src/libimobiledevice.la
32 36
33imobiledevice.c: imobiledevice.pyx $(PXDINCLUDES) $(PXIINCLUDES) 37imobiledevice.c: imobiledevice.pyx $(PXDINCLUDES) $(PXIINCLUDES)
diff --git a/cython/afc.pxi b/cython/afc.pxi
index 51251c8..ac9c927 100644
--- a/cython/afc.pxi
+++ b/cython/afc.pxi
@@ -1,7 +1,7 @@
1cdef extern from "libimobiledevice/afc.h": 1cdef extern from "libimobiledevice/afc.h":
2 cdef struct afc_client_int: 2 cdef struct afc_client_private:
3 pass 3 pass
4 ctypedef afc_client_int *afc_client_t 4 ctypedef afc_client_private *afc_client_t
5 ctypedef enum afc_error_t: 5 ctypedef enum afc_error_t:
6 AFC_E_SUCCESS = 0 6 AFC_E_SUCCESS = 0
7 AFC_E_UNKNOWN_ERROR = 1 7 AFC_E_UNKNOWN_ERROR = 1
@@ -10,7 +10,7 @@ cdef extern from "libimobiledevice/afc.h":
10 AFC_E_READ_ERROR = 4 10 AFC_E_READ_ERROR = 4
11 AFC_E_WRITE_ERROR = 5 11 AFC_E_WRITE_ERROR = 5
12 AFC_E_UNKNOWN_PACKET_TYPE = 6 12 AFC_E_UNKNOWN_PACKET_TYPE = 6
13 AFC_E_INVALID_ARGUMENT = 7 13 AFC_E_INVALID_ARG = 7
14 AFC_E_OBJECT_NOT_FOUND = 8 14 AFC_E_OBJECT_NOT_FOUND = 8
15 AFC_E_OBJECT_IS_DIR = 9 15 AFC_E_OBJECT_IS_DIR = 9
16 AFC_E_PERM_DENIED = 10 16 AFC_E_PERM_DENIED = 10
@@ -79,7 +79,7 @@ cdef class AfcError(BaseError):
79 AFC_E_READ_ERROR: "Read error", 79 AFC_E_READ_ERROR: "Read error",
80 AFC_E_WRITE_ERROR: "Write error", 80 AFC_E_WRITE_ERROR: "Write error",
81 AFC_E_UNKNOWN_PACKET_TYPE: "Unknown packet type", 81 AFC_E_UNKNOWN_PACKET_TYPE: "Unknown packet type",
82 AFC_E_INVALID_ARGUMENT: "Invalid argument", 82 AFC_E_INVALID_ARG: "Invalid argument",
83 AFC_E_OBJECT_NOT_FOUND: "Object not found", 83 AFC_E_OBJECT_NOT_FOUND: "Object not found",
84 AFC_E_OBJECT_IS_DIR: "Object is directory", 84 AFC_E_OBJECT_IS_DIR: "Object is directory",
85 AFC_E_PERM_DENIED: "Permission denied", 85 AFC_E_PERM_DENIED: "Permission denied",
diff --git a/cython/file_relay.pxi b/cython/file_relay.pxi
new file mode 100644
index 0000000..05c99f5
--- /dev/null
+++ b/cython/file_relay.pxi
@@ -0,0 +1,75 @@
1cdef extern from "libimobiledevice/file_relay.h":
2 cdef struct file_relay_client_private:
3 pass
4 ctypedef file_relay_client_private *file_relay_client_t
5 ctypedef char** const_sources_t "const char**"
6
7 ctypedef enum file_relay_error_t:
8 FILE_RELAY_E_SUCCESS = 0
9 FILE_RELAY_E_INVALID_ARG = -1
10 FILE_RELAY_E_PLIST_ERROR = -2
11 FILE_RELAY_E_MUX_ERROR = -3
12 FILE_RELAY_E_INVALID_SOURCE = -4
13 FILE_RELAY_E_STAGING_EMPTY = -5
14 FILE_RELAY_E_UNKNOWN_ERROR = -256
15
16 file_relay_error_t file_relay_client_new(idevice_t device, uint16_t port, file_relay_client_t *client)
17 file_relay_error_t file_relay_client_free(file_relay_client_t client)
18
19 file_relay_error_t file_relay_request_sources(file_relay_client_t client, const_sources_t sources, idevice_connection_t *connection)
20
21cdef class FileRelayError(BaseError):
22 def __init__(self, *args, **kwargs):
23 self._lookup_table = {
24 FILE_RELAY_E_SUCCESS: "Success",
25 FILE_RELAY_E_INVALID_ARG: "Invalid argument",
26 FILE_RELAY_E_PLIST_ERROR: "Property list error",
27 FILE_RELAY_E_MUX_ERROR: "MUX error",
28 FILE_RELAY_E_INVALID_SOURCE: "Invalid source",
29 FILE_RELAY_E_STAGING_EMPTY: "Staging empty",
30 FILE_RELAY_E_UNKNOWN_ERROR: "Unknown error"
31 }
32 BaseError.__init__(self, *args, **kwargs)
33
34cimport stdlib
35
36cdef class FileRelayClient(Base):
37 cdef file_relay_client_t _c_client
38
39 def __cinit__(self, iDevice device not None, LockdownClient lockdown=None, *args, **kwargs):
40 cdef:
41 iDevice dev = device
42 LockdownClient lckd
43 file_relay_error_t err
44 if lockdown is None:
45 lckd = LockdownClient(dev)
46 else:
47 lckd = lockdown
48 port = lckd.start_service("com.apple.mobile.file_relay")
49 err = file_relay_client_new(dev._c_dev, port, &self._c_client)
50 self.handle_error(err)
51
52 def __dealloc__(self):
53 cdef file_relay_error_t err
54 if self._c_client is not NULL:
55 err = file_relay_client_free(self._c_client)
56 self.handle_error(err)
57
58 cpdef iDeviceConnection request_sources(self, list sources):
59 cdef:
60 file_relay_error_t err
61 Py_ssize_t count = len(sources)
62 char** c_sources = <char**>stdlib.malloc(sizeof(char*) * (count + 1))
63 iDeviceConnection conn = iDeviceConnection.__new__(iDeviceConnection)
64
65 for i, value in enumerate(sources):
66 c_sources[i] = value
67 c_sources[count] = NULL
68
69 err = file_relay_request_sources(self._c_client, <const_sources_t>c_sources, &conn._c_connection)
70 free(c_sources)
71 self.handle_error(err)
72 return conn
73
74 cdef inline BaseError _error(self, int16_t ret):
75 return FileRelayError(ret)
diff --git a/cython/imobiledevice.pxd b/cython/imobiledevice.pxd
index 8a7d6b2..8efd669 100644
--- a/cython/imobiledevice.pxd
+++ b/cython/imobiledevice.pxd
@@ -17,9 +17,12 @@ cdef class Base:
17cdef class iDeviceError(BaseError): pass 17cdef class iDeviceError(BaseError): pass
18 18
19cdef extern from "libimobiledevice/libimobiledevice.h": 19cdef extern from "libimobiledevice/libimobiledevice.h":
20 cdef struct idevice_int: 20 cdef struct idevice_private:
21 pass 21 pass
22 ctypedef idevice_int* idevice_t 22 ctypedef idevice_private* idevice_t
23 cdef struct idevice_connection_private:
24 pass
25 ctypedef idevice_connection_private* idevice_connection_t
23 cdef enum idevice_event_type: 26 cdef enum idevice_event_type:
24 IDEVICE_DEVICE_ADD = 1, 27 IDEVICE_DEVICE_ADD = 1,
25 IDEVICE_DEVICE_REMOVE 28 IDEVICE_DEVICE_REMOVE
@@ -32,15 +35,22 @@ cdef extern from "libimobiledevice/libimobiledevice.h":
32cdef class iDeviceEvent: 35cdef class iDeviceEvent:
33 cdef const_idevice_event_t _c_event 36 cdef const_idevice_event_t _c_event
34 37
38cdef class iDeviceConnection(Base):
39 cdef idevice_connection_t _c_connection
40
41 cpdef disconnect(self)
42
35cdef class iDevice(Base): 43cdef class iDevice(Base):
36 cdef idevice_t _c_dev 44 cdef idevice_t _c_dev
37 45
46 cpdef iDeviceConnection connect(self, uint16_t port)
47
38cdef class LockdownError(BaseError): pass 48cdef class LockdownError(BaseError): pass
39 49
40cdef extern from "libimobiledevice/lockdown.h": 50cdef extern from "libimobiledevice/lockdown.h":
41 cdef struct lockdownd_client_int: 51 cdef struct lockdownd_client_private:
42 pass 52 pass
43 ctypedef lockdownd_client_int *lockdownd_client_t 53 ctypedef lockdownd_client_private *lockdownd_client_t
44 54
45cdef class LockdownClient(Base): 55cdef class LockdownClient(Base):
46 cdef lockdownd_client_t _c_client 56 cdef lockdownd_client_t _c_client
diff --git a/cython/imobiledevice.pyx b/cython/imobiledevice.pyx
index ecf94e1..b7ec87b 100644
--- a/cython/imobiledevice.pyx
+++ b/cython/imobiledevice.pyx
@@ -48,6 +48,11 @@ cdef extern from "libimobiledevice/libimobiledevice.h":
48 idevice_error_t idevice_free(idevice_t device) 48 idevice_error_t idevice_free(idevice_t device)
49 idevice_error_t idevice_get_uuid(idevice_t device, char** uuid) 49 idevice_error_t idevice_get_uuid(idevice_t device, char** uuid)
50 idevice_error_t idevice_get_handle(idevice_t device, uint32_t *handle) 50 idevice_error_t idevice_get_handle(idevice_t device, uint32_t *handle)
51 idevice_error_t idevice_connect(idevice_t device, uint16_t port, idevice_connection_t *connection)
52 idevice_error_t idevice_disconnect(idevice_connection_t connection)
53 idevice_error_t idevice_connection_send(idevice_connection_t connection, char *data, uint32_t len, uint32_t *sent_bytes)
54 idevice_error_t idevice_connection_receive_timeout(idevice_connection_t connection, char *data, uint32_t len, uint32_t *recv_bytes, unsigned int timeout)
55 idevice_error_t idevice_connection_receive(idevice_connection_t connection, char *data, uint32_t len, uint32_t *recv_bytes)
51 56
52cdef class iDeviceError(BaseError): 57cdef class iDeviceError(BaseError):
53 def __init__(self, *args, **kwargs): 58 def __init__(self, *args, **kwargs):
@@ -99,6 +104,18 @@ cpdef get_device_list():
99 if err: raise err 104 if err: raise err
100 return result 105 return result
101 106
107cdef class iDeviceConnection(Base):
108 def __init__(self, *args, **kwargs):
109 raise TypeError("iDeviceConnection cannot be instantiated. Please use iDevice.connect()")
110
111 cpdef disconnect(self):
112 cdef idevice_error_t err
113 err = idevice_disconnect(self._c_connection)
114 self.handle_error(err)
115
116 cdef inline BaseError _error(self, int16_t ret):
117 return iDeviceError(ret)
118
102cdef class iDevice(Base): 119cdef class iDevice(Base):
103 def __cinit__(self, uuid=None, *args, **kwargs): 120 def __cinit__(self, uuid=None, *args, **kwargs):
104 cdef: 121 cdef:
@@ -116,6 +133,14 @@ cdef class iDevice(Base):
116 cdef inline BaseError _error(self, int16_t ret): 133 cdef inline BaseError _error(self, int16_t ret):
117 return iDeviceError(ret) 134 return iDeviceError(ret)
118 135
136 cpdef iDeviceConnection connect(self, uint16_t port):
137 cdef:
138 idevice_error_t err
139 iDeviceConnection conn = iDeviceConnection.__new__(iDeviceConnection)
140 err = idevice_connect(self._c_dev, port, &conn._c_connection)
141 self.handle_error(err)
142 return conn
143
119 property uuid: 144 property uuid:
120 def __get__(self): 145 def __get__(self):
121 cdef: 146 cdef:
@@ -131,9 +156,9 @@ cdef class iDevice(Base):
131 return handle 156 return handle
132 157
133cdef extern from "libimobiledevice/lockdown.h": 158cdef extern from "libimobiledevice/lockdown.h":
134 cdef struct lockdownd_client_int: 159 cdef struct lockdownd_client_private:
135 pass 160 pass
136 ctypedef lockdownd_client_int *lockdownd_client_t 161 ctypedef lockdownd_client_private *lockdownd_client_t
137 ctypedef enum lockdownd_error_t: 162 ctypedef enum lockdownd_error_t:
138 LOCKDOWN_E_SUCCESS = 0 163 LOCKDOWN_E_SUCCESS = 0
139 LOCKDOWN_E_INVALID_ARG = -1 164 LOCKDOWN_E_INVALID_ARG = -1
@@ -166,7 +191,7 @@ cdef class LockdownError(BaseError):
166 LOCKDOWN_E_SUCCESS: "Success", 191 LOCKDOWN_E_SUCCESS: "Success",
167 LOCKDOWN_E_INVALID_ARG: "Invalid argument", 192 LOCKDOWN_E_INVALID_ARG: "Invalid argument",
168 LOCKDOWN_E_INVALID_CONF: "Invalid configuration", 193 LOCKDOWN_E_INVALID_CONF: "Invalid configuration",
169 LOCKDOWN_E_PLIST_ERROR: "PList error", 194 LOCKDOWN_E_PLIST_ERROR: "Property list error",
170 LOCKDOWN_E_PAIRING_FAILED: "Pairing failed", 195 LOCKDOWN_E_PAIRING_FAILED: "Pairing failed",
171 LOCKDOWN_E_SSL_ERROR: "SSL error", 196 LOCKDOWN_E_SSL_ERROR: "SSL error",
172 LOCKDOWN_E_DICT_ERROR: "Dict error", 197 LOCKDOWN_E_DICT_ERROR: "Dict error",
@@ -213,9 +238,16 @@ cdef class LockdownClient(Base):
213 cpdef goodbye(self): 238 cpdef goodbye(self):
214 pass 239 pass
215 240
241cdef extern from *:
242 ctypedef char* const_char_ptr "const char*"
243
216include "property_list_client.pxi" 244include "property_list_client.pxi"
217include "mobilesync.pxi" 245include "mobilesync.pxi"
218include "notification_proxy.pxi" 246include "notification_proxy.pxi"
219include "sbservices.pxi" 247include "sbservices.pxi"
220include "mobilebackup.pxi" 248include "mobilebackup.pxi"
221include "afc.pxi" 249include "afc.pxi"
250include "file_relay.pxi"
251include "screenshotr.pxi"
252include "installation_proxy.pxi"
253include "mobile_image_mounter.pxi"
diff --git a/cython/installation_proxy.pxi b/cython/installation_proxy.pxi
new file mode 100644
index 0000000..0424a81
--- /dev/null
+++ b/cython/installation_proxy.pxi
@@ -0,0 +1,210 @@
1cdef extern from "libimobiledevice/installation_proxy.h":
2 cdef struct instproxy_client_private:
3 pass
4 ctypedef instproxy_client_private *instproxy_client_t
5 ctypedef void (*instproxy_status_cb_t) (const_char_ptr operation, plist.plist_t status, void *user_data)
6
7 ctypedef enum instproxy_error_t:
8 INSTPROXY_E_SUCCESS = 0
9 INSTPROXY_E_INVALID_ARG = -1
10 INSTPROXY_E_PLIST_ERROR = -2
11 INSTPROXY_E_CONN_FAILED = -3
12 INSTPROXY_E_OP_IN_PROGRESS = -4
13 INSTPROXY_E_OP_FAILED = -5
14 INSTPROXY_E_UNKNOWN_ERROR = -256
15
16 instproxy_error_t instproxy_client_new(idevice_t device, uint16_t port, instproxy_client_t *client)
17 instproxy_error_t instproxy_client_free(instproxy_client_t client)
18
19 instproxy_error_t instproxy_browse(instproxy_client_t client, plist.plist_t client_options, plist.plist_t *result)
20 instproxy_error_t instproxy_install(instproxy_client_t client, char *pkg_path, plist.plist_t client_options, instproxy_status_cb_t status_cb, void *user_data)
21 instproxy_error_t instproxy_upgrade(instproxy_client_t client, char *pkg_path, plist.plist_t client_options, instproxy_status_cb_t status_cb, void *user_data)
22 instproxy_error_t instproxy_uninstall(instproxy_client_t client, char *appid, plist.plist_t client_options, instproxy_status_cb_t status_cb, void *user_data)
23
24 instproxy_error_t instproxy_lookup_archives(instproxy_client_t client, plist.plist_t client_options, plist.plist_t *result)
25 instproxy_error_t instproxy_archive(instproxy_client_t client, char *appid, plist.plist_t client_options, instproxy_status_cb_t status_cb, void *user_data)
26 instproxy_error_t instproxy_restore(instproxy_client_t client, char *appid, plist.plist_t client_options, instproxy_status_cb_t status_cb, void *user_data)
27 instproxy_error_t instproxy_remove_archive(instproxy_client_t client, char *appid, plist.plist_t client_options, instproxy_status_cb_t status_cb, void *user_data)
28
29cdef void instproxy_notify_cb(const_char_ptr operation, plist.plist_t status, void *py_callback):
30 (<object>py_callback)(operation, plist.plist_t_to_node(status, False))
31
32cdef class InstallationProxyError(BaseError):
33 def __init__(self, *args, **kwargs):
34 self._lookup_table = {
35 INSTPROXY_E_SUCCESS: "Success",
36 INSTPROXY_E_INVALID_ARG: "Invalid argument",
37 INSTPROXY_E_PLIST_ERROR: "Property list error",
38 INSTPROXY_E_CONN_FAILED: "Connection failed",
39 INSTPROXY_E_OP_IN_PROGRESS: "Operation in progress",
40 INSTPROXY_E_OP_FAILED: "Operation failed",
41 INSTPROXY_E_UNKNOWN_ERROR: "Unknown error"
42 }
43 BaseError.__init__(self, *args, **kwargs)
44
45cdef class InstallationProxyClient(Base):
46 cdef instproxy_client_t _c_client
47
48 def __cinit__(self, iDevice device not None, LockdownClient lockdown=None, *args, **kwargs):
49 cdef:
50 iDevice dev = device
51 LockdownClient lckd
52 instproxy_error_t err
53 if lockdown is None:
54 lckd = LockdownClient(dev)
55 else:
56 lckd = lockdown
57 port = lckd.start_service("com.apple.mobile.installation_proxy")
58 err = instproxy_client_new(dev._c_dev, port, &self._c_client)
59 self.handle_error(err)
60
61 def __dealloc__(self):
62 cdef instproxy_error_t err
63 if self._c_client is not NULL:
64 err = instproxy_client_free(self._c_client)
65 self.handle_error(err)
66
67 cpdef plist.Node browse(self, object client_options):
68 cdef:
69 plist.Node options
70 plist.plist_t c_options
71 plist.plist_t c_result = NULL
72 instproxy_error_t err
73 if isinstance(client_options, plist.Dict):
74 options = client_options
75 c_options = options._c_node
76 elif isinstance(client_options, dict):
77 c_options = plist.native_to_plist_t(client_options)
78 else:
79 raise InstallationProxyError(INSTPROXY_E_INVALID_ARG)
80 err = instproxy_browse(self._c_client, c_options, &c_result)
81 self.handle_error(err)
82 return plist.plist_t_to_node(c_result)
83
84 cpdef install(self, bytes pkg_path, object client_options, object callback=None):
85 cdef:
86 plist.Node options
87 plist.plist_t c_options
88 instproxy_error_t err
89 if isinstance(client_options, plist.Dict):
90 options = client_options
91 c_options = options._c_node
92 elif isinstance(client_options, dict):
93 c_options = plist.native_to_plist_t(client_options)
94 else:
95 raise InstallationProxyError(INSTPROXY_E_INVALID_ARG)
96 if callback is None:
97 err = instproxy_install(self._c_client, pkg_path, options._c_node, NULL, NULL)
98 else:
99 err = instproxy_install(self._c_client, pkg_path, options._c_node, instproxy_notify_cb, <void*>callback)
100 self.handle_error(err)
101
102 cpdef upgrade(self, bytes pkg_path, object client_options, object callback=None):
103 cdef:
104 plist.Node options
105 plist.plist_t c_options
106 instproxy_error_t err
107 if isinstance(client_options, plist.Dict):
108 options = client_options
109 c_options = options._c_node
110 elif isinstance(client_options, dict):
111 c_options = plist.native_to_plist_t(client_options)
112 else:
113 raise InstallationProxyError(INSTPROXY_E_INVALID_ARG)
114 if callback is None:
115 err = instproxy_upgrade(self._c_client, pkg_path, options._c_node, NULL, NULL)
116 else:
117 err = instproxy_upgrade(self._c_client, pkg_path, options._c_node, instproxy_notify_cb, <void*>callback)
118 self.handle_error(err)
119
120 cpdef uninstall(self, bytes appid, object client_options, object callback=None):
121 cdef:
122 plist.Node options
123 plist.plist_t c_options
124 instproxy_error_t err
125 if isinstance(client_options, plist.Dict):
126 options = client_options
127 c_options = options._c_node
128 elif isinstance(client_options, dict):
129 c_options = plist.native_to_plist_t(client_options)
130 else:
131 raise InstallationProxyError(INSTPROXY_E_INVALID_ARG)
132 if callback is None:
133 err = instproxy_uninstall(self._c_client, appid, options._c_node, NULL, NULL)
134 else:
135 err = instproxy_uninstall(self._c_client, appid, options._c_node, instproxy_notify_cb, <void*>callback)
136 self.handle_error(err)
137
138 cpdef plist.Node lookup_archives(self, object client_options):
139 cdef:
140 plist.Node options
141 plist.plist_t c_options
142 plist.plist_t c_node = NULL
143 instproxy_error_t err
144 if isinstance(client_options, plist.Dict):
145 options = client_options
146 c_options = options._c_node
147 elif isinstance(client_options, dict):
148 c_options = plist.native_to_plist_t(client_options)
149 else:
150 raise InstallationProxyError(INSTPROXY_E_INVALID_ARG)
151 err = instproxy_lookup_archives(self._c_client, options._c_node, &c_node)
152 self.handle_error(err)
153 return plist.plist_t_to_node(c_node)
154
155 cpdef archive(self, bytes appid, object client_options, object callback=None):
156 cdef:
157 plist.Node options
158 plist.plist_t c_options
159 instproxy_error_t err
160 if isinstance(client_options, plist.Dict):
161 options = client_options
162 c_options = options._c_node
163 elif isinstance(client_options, dict):
164 c_options = plist.native_to_plist_t(client_options)
165 else:
166 raise InstallationProxyError(INSTPROXY_E_INVALID_ARG)
167 if callback is None:
168 err = instproxy_archive(self._c_client, appid, options._c_node, NULL, NULL)
169 else:
170 err = instproxy_archive(self._c_client, appid, options._c_node, instproxy_notify_cb, <void*>callback)
171 self.handle_error(err)
172
173 cpdef restore(self, bytes appid, object client_options, object callback=None):
174 cdef:
175 plist.Node options
176 plist.plist_t c_options
177 instproxy_error_t err
178 if isinstance(client_options, plist.Dict):
179 options = client_options
180 c_options = options._c_node
181 elif isinstance(client_options, dict):
182 c_options = plist.native_to_plist_t(client_options)
183 else:
184 raise InstallationProxyError(INSTPROXY_E_INVALID_ARG)
185 if callback is None:
186 err = instproxy_restore(self._c_client, appid, options._c_node, NULL, NULL)
187 else:
188 err = instproxy_restore(self._c_client, appid, options._c_node, instproxy_notify_cb, <void*>callback)
189 self.handle_error(err)
190
191 cpdef remove_archive(self, bytes appid, object client_options, object callback=None):
192 cdef:
193 plist.Node options
194 plist.plist_t c_options
195 instproxy_error_t err
196 if isinstance(client_options, plist.Dict):
197 options = client_options
198 c_options = options._c_node
199 elif isinstance(client_options, dict):
200 c_options = plist.native_to_plist_t(client_options)
201 else:
202 raise InstallationProxyError(INSTPROXY_E_INVALID_ARG)
203 if callback is None:
204 err = instproxy_remove_archive(self._c_client, appid, options._c_node, NULL, NULL)
205 else:
206 err = instproxy_remove_archive(self._c_client, appid, options._c_node, instproxy_notify_cb, <void*>callback)
207 self.handle_error(err)
208
209 cdef inline BaseError _error(self, int16_t ret):
210 return InstallationProxyError(ret)
diff --git a/cython/mobile_image_mounter.pxi b/cython/mobile_image_mounter.pxi
new file mode 100644
index 0000000..8ec30d1
--- /dev/null
+++ b/cython/mobile_image_mounter.pxi
@@ -0,0 +1,75 @@
1cdef extern from "libimobiledevice/mobile_image_mounter.h":
2 cdef struct mobile_image_mounter_client_private:
3 pass
4 ctypedef mobile_image_mounter_client_private *mobile_image_mounter_client_t
5
6 ctypedef enum mobile_image_mounter_error_t:
7 MOBILE_IMAGE_MOUNTER_E_SUCCESS = 0
8 MOBILE_IMAGE_MOUNTER_E_INVALID_ARG = -1
9 MOBILE_IMAGE_MOUNTER_E_PLIST_ERROR = -2
10 MOBILE_IMAGE_MOUNTER_E_CONN_FAILED = -3
11 MOBILE_IMAGE_MOUNTER_E_UNKNOWN_ERROR = -256
12
13 mobile_image_mounter_error_t mobile_image_mounter_new(idevice_t device, uint16_t port, mobile_image_mounter_client_t *client)
14 mobile_image_mounter_error_t mobile_image_mounter_free(mobile_image_mounter_client_t client)
15 mobile_image_mounter_error_t mobile_image_mounter_lookup_image(mobile_image_mounter_client_t client, char *image_type, plist.plist_t *result)
16 mobile_image_mounter_error_t mobile_image_mounter_mount_image(mobile_image_mounter_client_t client, char *image_path, char *image_signature, uint16_t signature_length, char *image_type, plist.plist_t *result)
17 mobile_image_mounter_error_t mobile_image_mounter_hangup(mobile_image_mounter_client_t client)
18
19cdef class MobileImageMounterError(BaseError):
20 def __init__(self, *args, **kwargs):
21 self._lookup_table = {
22 MOBILE_IMAGE_MOUNTER_E_SUCCESS: "Success",
23 MOBILE_IMAGE_MOUNTER_E_INVALID_ARG: "Invalid argument",
24 MOBILE_IMAGE_MOUNTER_E_PLIST_ERROR: "Property list error",
25 MOBILE_IMAGE_MOUNTER_E_CONN_FAILED: "Connection failed",
26 MOBILE_IMAGE_MOUNTER_E_UNKNOWN_ERROR: "Unknown error"
27 }
28 BaseError.__init__(self, *args, **kwargs)
29
30cdef class MobileImageMounterClient(PropertyListClient):
31 cdef mobile_image_mounter_client_t _c_client
32
33 def __cinit__(self, iDevice device not None, LockdownClient lockdown=None, *args, **kwargs):
34 cdef:
35 iDevice dev = device
36 LockdownClient lckd
37 mobile_image_mounter_error_t err
38 if lockdown is None:
39 lckd = LockdownClient(dev)
40 else:
41 lckd = lockdown
42 port = lckd.start_service("com.apple.mobile.mobile_image_mounter")
43 err = mobile_image_mounter_new(dev._c_dev, port, &self._c_client)
44 self.handle_error(err)
45
46 def __dealloc__(self):
47 cdef mobile_image_mounter_error_t err
48 if self._c_client is not NULL:
49 err = mobile_image_mounter_free(self._c_client)
50 self.handle_error(err)
51
52 cdef inline BaseError _error(self, int16_t ret):
53 return MobileImageMounterError(ret)
54
55 cpdef plist.Node lookup_image(self, bytes image_type):
56 cdef:
57 plist.plist_t c_node = NULL
58 mobile_image_mounter_error_t err
59 err = mobile_image_mounter_lookup_image(self._c_client, image_type, &c_node)
60 self.handle_error(err)
61 return plist.plist_t_to_node(c_node)
62
63 cpdef plist.Node mount_image(self, bytes image_path, bytes image_signature, bytes image_type):
64 cdef:
65 plist.plist_t c_node = NULL
66 mobile_image_mounter_error_t err
67 err = mobile_image_mounter_mount_image(self._c_client, image_path, image_signature, len(image_signature),
68 image_type, &c_node)
69 self.handle_error(err)
70 return plist.plist_t_to_node(c_node)
71
72 cpdef hangup(self):
73 cdef mobile_image_mounter_error_t err
74 err = mobile_image_mounter_hangup(self._c_client)
75 self.handle_error(err)
diff --git a/cython/mobilebackup.pxi b/cython/mobilebackup.pxi
index 53a4b6f..330a99d 100644
--- a/cython/mobilebackup.pxi
+++ b/cython/mobilebackup.pxi
@@ -1,7 +1,7 @@
1cdef extern from "libimobiledevice/mobilebackup.h": 1cdef extern from "libimobiledevice/mobilebackup.h":
2 cdef struct mobilebackup_client_int: 2 cdef struct mobilebackup_client_private:
3 pass 3 pass
4 ctypedef mobilebackup_client_int *mobilebackup_client_t 4 ctypedef mobilebackup_client_private *mobilebackup_client_t
5 5
6 ctypedef enum mobilebackup_error_t: 6 ctypedef enum mobilebackup_error_t:
7 MOBILEBACKUP_E_SUCCESS = 0 7 MOBILEBACKUP_E_SUCCESS = 0
@@ -21,9 +21,9 @@ cdef class MobileBackupError(BaseError):
21 self._lookup_table = { 21 self._lookup_table = {
22 MOBILEBACKUP_E_SUCCESS: "Success", 22 MOBILEBACKUP_E_SUCCESS: "Success",
23 MOBILEBACKUP_E_INVALID_ARG: "Invalid argument", 23 MOBILEBACKUP_E_INVALID_ARG: "Invalid argument",
24 MOBILEBACKUP_E_PLIST_ERROR: "PList Error", 24 MOBILEBACKUP_E_PLIST_ERROR: "Property list error",
25 MOBILEBACKUP_E_MUX_ERROR: "MUX Error", 25 MOBILEBACKUP_E_MUX_ERROR: "MUX error",
26 MOBILEBACKUP_E_BAD_VERSION: "Bad Version", 26 MOBILEBACKUP_E_BAD_VERSION: "Bad version",
27 MOBILEBACKUP_E_UNKNOWN_ERROR: "Unknown error" 27 MOBILEBACKUP_E_UNKNOWN_ERROR: "Unknown error"
28 } 28 }
29 BaseError.__init__(self, *args, **kwargs) 29 BaseError.__init__(self, *args, **kwargs)
diff --git a/cython/mobilesync.pxi b/cython/mobilesync.pxi
index 87539d2..d5dacb1 100644
--- a/cython/mobilesync.pxi
+++ b/cython/mobilesync.pxi
@@ -1,7 +1,7 @@
1cdef extern from "libimobiledevice/mobilesync.h": 1cdef extern from "libimobiledevice/mobilesync.h":
2 cdef struct mobilesync_client_int: 2 cdef struct mobilesync_client_private:
3 pass 3 pass
4 ctypedef mobilesync_client_int *mobilesync_client_t 4 ctypedef mobilesync_client_private *mobilesync_client_t
5 5
6 ctypedef enum mobilesync_error_t: 6 ctypedef enum mobilesync_error_t:
7 MOBILESYNC_E_SUCCESS = 0 7 MOBILESYNC_E_SUCCESS = 0
@@ -21,9 +21,9 @@ cdef class MobileSyncError(BaseError):
21 self._lookup_table = { 21 self._lookup_table = {
22 MOBILESYNC_E_SUCCESS: "Success", 22 MOBILESYNC_E_SUCCESS: "Success",
23 MOBILESYNC_E_INVALID_ARG: "Invalid argument", 23 MOBILESYNC_E_INVALID_ARG: "Invalid argument",
24 MOBILESYNC_E_PLIST_ERROR: "PList Error", 24 MOBILESYNC_E_PLIST_ERROR: "Property list error",
25 MOBILESYNC_E_MUX_ERROR: "MUX Error", 25 MOBILESYNC_E_MUX_ERROR: "MUX error",
26 MOBILESYNC_E_BAD_VERSION: "Bad Version", 26 MOBILESYNC_E_BAD_VERSION: "Bad version",
27 MOBILESYNC_E_UNKNOWN_ERROR: "Unknown error" 27 MOBILESYNC_E_UNKNOWN_ERROR: "Unknown error"
28 } 28 }
29 BaseError.__init__(self, *args, **kwargs) 29 BaseError.__init__(self, *args, **kwargs)
diff --git a/cython/notification_proxy.pxi b/cython/notification_proxy.pxi
index 2ca484a..d5f2d25 100644
--- a/cython/notification_proxy.pxi
+++ b/cython/notification_proxy.pxi
@@ -1,10 +1,7 @@
1cdef extern from *:
2 ctypedef char* const_char_ptr "const char*"
3
4cdef extern from "libimobiledevice/notification_proxy.h": 1cdef extern from "libimobiledevice/notification_proxy.h":
5 cdef struct np_client_int: 2 cdef struct np_client_private:
6 pass 3 pass
7 ctypedef np_client_int *np_client_t 4 ctypedef np_client_private *np_client_t
8 ctypedef enum np_error_t: 5 ctypedef enum np_error_t:
9 NP_E_SUCCESS = 0 6 NP_E_SUCCESS = 0
10 NP_E_INVALID_ARG = -1 7 NP_E_INVALID_ARG = -1
@@ -27,9 +24,9 @@ cdef class NotificationProxyError(BaseError):
27 self._lookup_table = { 24 self._lookup_table = {
28 NP_E_SUCCESS: "Success", 25 NP_E_SUCCESS: "Success",
29 NP_E_INVALID_ARG: "Invalid argument", 26 NP_E_INVALID_ARG: "Invalid argument",
30 NP_E_PLIST_ERROR: "PList Error", 27 NP_E_PLIST_ERROR: "Property list error",
31 NP_E_CONN_FAILED: "Connection Failed", 28 NP_E_CONN_FAILED: "Connection failed",
32 NP_E_UNKNOWN_ERROR: "Unknown Error" 29 NP_E_UNKNOWN_ERROR: "Unknown error"
33 } 30 }
34 BaseError.__init__(self, *args, **kwargs) 31 BaseError.__init__(self, *args, **kwargs)
35 32
diff --git a/cython/sbservices.pxi b/cython/sbservices.pxi
index 384c92b..0ad67c7 100644
--- a/cython/sbservices.pxi
+++ b/cython/sbservices.pxi
@@ -1,7 +1,7 @@
1cdef extern from "libimobiledevice/sbservices.h": 1cdef extern from "libimobiledevice/sbservices.h":
2 cdef struct sbservices_client_int: 2 cdef struct sbservices_client_private:
3 pass 3 pass
4 ctypedef sbservices_client_int *sbservices_client_t 4 ctypedef sbservices_client_private *sbservices_client_t
5 ctypedef enum sbservices_error_t: 5 ctypedef enum sbservices_error_t:
6 SBSERVICES_E_SUCCESS = 0 6 SBSERVICES_E_SUCCESS = 0
7 SBSERVICES_E_INVALID_ARG = -1 7 SBSERVICES_E_INVALID_ARG = -1
@@ -19,9 +19,9 @@ cdef class SpringboardServicesError(BaseError):
19 self._lookup_table = { 19 self._lookup_table = {
20 SBSERVICES_E_SUCCESS: "Success", 20 SBSERVICES_E_SUCCESS: "Success",
21 SBSERVICES_E_INVALID_ARG: "Invalid argument", 21 SBSERVICES_E_INVALID_ARG: "Invalid argument",
22 SBSERVICES_E_PLIST_ERROR: "PList Error", 22 SBSERVICES_E_PLIST_ERROR: "Property list error",
23 SBSERVICES_E_CONN_FAILED: "Connection Failed", 23 SBSERVICES_E_CONN_FAILED: "Connection failed",
24 SBSERVICES_E_UNKNOWN_ERROR: "Unknown Error" 24 SBSERVICES_E_UNKNOWN_ERROR: "Unknown error"
25 } 25 }
26 BaseError.__init__(self, *args, **kwargs) 26 BaseError.__init__(self, *args, **kwargs)
27 27
diff --git a/cython/screenshotr.pxi b/cython/screenshotr.pxi
new file mode 100644
index 0000000..92d95b9
--- /dev/null
+++ b/cython/screenshotr.pxi
@@ -0,0 +1,65 @@
1cdef extern from "libimobiledevice/screenshotr.h":
2 cdef struct screenshotr_client_private:
3 pass
4 ctypedef screenshotr_client_private *screenshotr_client_t
5
6 ctypedef enum screenshotr_error_t:
7 SCREENSHOTR_E_SUCCESS = 0
8 SCREENSHOTR_E_INVALID_ARG = -1
9 SCREENSHOTR_E_PLIST_ERROR = -2
10 SCREENSHOTR_E_MUX_ERROR = -3
11 SCREENSHOTR_E_BAD_VERSION = -4
12 SCREENSHOTR_E_UNKNOWN_ERROR = -256
13
14 screenshotr_error_t screenshotr_client_new(idevice_t device, uint16_t port, screenshotr_client_t * client)
15 screenshotr_error_t screenshotr_client_free(screenshotr_client_t client)
16 screenshotr_error_t screenshotr_take_screenshot(screenshotr_client_t client, char **imgdata, uint64_t *imgsize)
17
18cdef class ScreenshotrError(BaseError):
19 def __init__(self, *args, **kwargs):
20 self._lookup_table = {
21 SCREENSHOTR_E_SUCCESS: "Success",
22 SCREENSHOTR_E_INVALID_ARG: "Invalid argument",
23 SCREENSHOTR_E_PLIST_ERROR: "Property list error",
24 SCREENSHOTR_E_MUX_ERROR: "MUX error",
25 SCREENSHOTR_E_BAD_VERSION: "Bad version",
26 SCREENSHOTR_E_UNKNOWN_ERROR: "Unknown error"
27 }
28 BaseError.__init__(self, *args, **kwargs)
29
30cdef class ScreenshotrClient(Base):
31 cdef screenshotr_client_t _c_client
32
33 def __cinit__(self, iDevice device not None, LockdownClient lockdown=None, *args, **kwargs):
34 cdef:
35 iDevice dev = device
36 LockdownClient lckd
37 screenshotr_error_t err
38 if lockdown is None:
39 lckd = LockdownClient(dev)
40 else:
41 lckd = lockdown
42 port = lckd.start_service("com.apple.mobile.screenshotr")
43 err = screenshotr_client_new(dev._c_dev, port, &self._c_client)
44 self.handle_error(err)
45
46 def __dealloc__(self):
47 cdef screenshotr_error_t err
48 if self._c_client is not NULL:
49 err = screenshotr_client_free(self._c_client)
50 self.handle_error(err)
51
52 cpdef bytes take_screenshot(self):
53 cdef:
54 char* c_data
55 uint64_t data_size
56 bytes result
57 screenshotr_error_t err
58
59 err = screenshotr_take_screenshot(self._c_client, &c_data, &data_size)
60 self.handle_error(err)
61 result = c_data[:data_size]
62 return result
63
64 cdef inline BaseError _error(self, int16_t ret):
65 return ScreenshotrError(ret)