summaryrefslogtreecommitdiffstats
path: root/cython/imobiledevice.pyx
diff options
context:
space:
mode:
Diffstat (limited to 'cython/imobiledevice.pyx')
-rw-r--r--cython/imobiledevice.pyx38
1 files changed, 35 insertions, 3 deletions
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"