diff options
Diffstat (limited to 'cython')
| -rw-r--r-- | cython/Makefile.am | 10 | ||||
| -rw-r--r-- | cython/afc.pxi | 3 | ||||
| -rw-r--r-- | cython/imobiledevice.pxd | 7 | ||||
| -rw-r--r-- | cython/imobiledevice.pyx | 35 | ||||
| -rw-r--r-- | cython/installation_proxy.pxi | 2 | ||||
| -rw-r--r-- | cython/property_list_client.pxi | 12 | ||||
| -rw-r--r-- | cython/sbservices.pxi | 30 |
7 files changed, 67 insertions, 32 deletions
diff --git a/cython/Makefile.am b/cython/Makefile.am index 228ec0c..b1dea79 100644 --- a/cython/Makefile.am +++ b/cython/Makefile.am | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | AM_CPPFLAGS = -I$(top_srcdir)/include | 1 | AM_CPPFLAGS = -I$(top_srcdir)/include |
| 2 | 2 | ||
| 3 | AM_CFLAGS = $(GLOBAL_CFLAGS) $(libusbmuxd_CFLAGS) $(libglib2_CFLAGS) $(libgnutls_CFLAGS) $(libtasn1_CFLAGS) $(libgthread2_CFLAGS) $(libplist_CFLAGS) $(LFS_CFLAGS) | 3 | AM_CFLAGS = $(libglib2_CFLAGS) $(libgnutls_CFLAGS) $(libtasn1_CFLAGS) $(libgthread2_CFLAGS) $(LFS_CFLAGS) |
| 4 | AM_LDFLAGS = $(libglib2_LIBS) $(libgnutls_LIBS) $(libtasn1_LIBS) $(libgthread2_LIBS) $(libplist_LIBS) $(libusbmuxd_LIBS) $(libgcrypt_LIBS) | 4 | AM_LDFLAGS = $(libglib2_LIBS) $(libgnutls_LIBS) $(libtasn1_LIBS) $(libgthread2_LIBS) |
| 5 | 5 | ||
| 6 | if HAVE_CYTHON | 6 | if HAVE_CYTHON |
| 7 | 7 | ||
| @@ -30,9 +30,9 @@ EXTRA_DIST = imobiledevice.pyx imobiledevice.pxd $(PXIINCLUDES) | |||
| 30 | imobiledevicedir = $(pyexecdir) | 30 | imobiledevicedir = $(pyexecdir) |
| 31 | imobiledevice_LTLIBRARIES = imobiledevice.la | 31 | imobiledevice_LTLIBRARIES = imobiledevice.la |
| 32 | imobiledevice_la_SOURCES = imobiledevice.pyx | 32 | imobiledevice_la_SOURCES = imobiledevice.pyx |
| 33 | imobiledevice_la_CFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/src $(PYTHON_CPPFLAGS) $(libglib2_CFLAGS) $(libgthread2_CFLAGS) | 33 | imobiledevice_la_CFLAGS = -I../include -I../src $(PYTHON_CPPFLAGS) $(AM_CFLAGS) |
| 34 | imobiledevice_la_LDFLAGS = -module -avoid-version $(PYTHON_LDFLAGS) $(libglib2_LIBS) $(libgthread2_LIBS) | 34 | imobiledevice_la_LDFLAGS = -module -avoid-version -L$(libdir) $(PYTHON_LDFLAGS) $(AM_LDFLAGS) |
| 35 | imobiledevice_la_LIBADD = $(top_builddir)/src/libimobiledevice.la | 35 | imobiledevice_la_LIBADD = ../src/libimobiledevice.la |
| 36 | 36 | ||
| 37 | imobiledevice.c: imobiledevice.pyx $(PXDINCLUDES) $(PXIINCLUDES) | 37 | imobiledevice.c: imobiledevice.pyx $(PXDINCLUDES) $(PXIINCLUDES) |
| 38 | 38 | ||
diff --git a/cython/afc.pxi b/cython/afc.pxi index ac9c927..1e2617a 100644 --- a/cython/afc.pxi +++ b/cython/afc.pxi | |||
| @@ -66,9 +66,6 @@ cdef extern from "libimobiledevice/afc.h": | |||
| 66 | afc_error_t afc_make_link(afc_client_t client, afc_link_type_t linktype, char *target, char *linkname) | 66 | afc_error_t afc_make_link(afc_client_t client, afc_link_type_t linktype, char *target, char *linkname) |
| 67 | afc_error_t afc_set_file_time(afc_client_t client, char *path, uint64_t mtime) | 67 | afc_error_t afc_set_file_time(afc_client_t client, char *path, uint64_t mtime) |
| 68 | 68 | ||
| 69 | cdef extern from *: | ||
| 70 | void free(void *ptr) | ||
| 71 | |||
| 72 | cdef class AfcError(BaseError): | 69 | cdef class AfcError(BaseError): |
| 73 | def __init__(self, *args, **kwargs): | 70 | def __init__(self, *args, **kwargs): |
| 74 | self._lookup_table = { | 71 | self._lookup_table = { |
diff --git a/cython/imobiledevice.pxd b/cython/imobiledevice.pxd index 8efd669..6bf75af 100644 --- a/cython/imobiledevice.pxd +++ b/cython/imobiledevice.pxd | |||
| @@ -54,10 +54,5 @@ cdef extern from "libimobiledevice/lockdown.h": | |||
| 54 | 54 | ||
| 55 | cdef class LockdownClient(Base): | 55 | cdef class LockdownClient(Base): |
| 56 | cdef lockdownd_client_t _c_client | 56 | cdef lockdownd_client_t _c_client |
| 57 | cpdef int start_service(self, service) | 57 | cpdef int start_service(self, bytes service) |
| 58 | cpdef goodbye(self) | 58 | cpdef goodbye(self) |
| 59 | |||
| 60 | cpdef set_debug_level(int level) | ||
| 61 | cpdef event_subscribe(object callback) | ||
| 62 | cpdef event_unsubscribe() | ||
| 63 | cpdef get_device_list() | ||
diff --git a/cython/imobiledevice.pyx b/cython/imobiledevice.pyx index dc0fb88..b57db04 100644 --- a/cython/imobiledevice.pyx +++ b/cython/imobiledevice.pyx | |||
| @@ -67,27 +67,40 @@ cdef class iDeviceError(BaseError): | |||
| 67 | } | 67 | } |
| 68 | BaseError.__init__(self, *args, **kwargs) | 68 | BaseError.__init__(self, *args, **kwargs) |
| 69 | 69 | ||
| 70 | cpdef set_debug_level(int level): | 70 | def set_debug_level(int level): |
| 71 | idevice_set_debug_level(level) | 71 | idevice_set_debug_level(level) |
| 72 | 72 | ||
| 73 | cdef class iDeviceEvent: | 73 | cdef class iDeviceEvent: |
| 74 | def __init__(self, *args, **kwargs): | 74 | def __init__(self, *args, **kwargs): |
| 75 | raise TypeError("iDeviceEvent cannot be instantiated") | 75 | raise TypeError("iDeviceEvent cannot be instantiated") |
| 76 | 76 | ||
| 77 | cdef void idevice_event_cb(const_idevice_event_t c_event, void *user_data): | 77 | def __str__(self): |
| 78 | return 'iDeviceEvent: %s (%s)' % (self.event == IDEVICE_DEVICE_ADD and 'Add' or 'Remove', self.uuid) | ||
| 79 | |||
| 80 | property event: | ||
| 81 | def __get__(self): | ||
| 82 | return self._c_event.event | ||
| 83 | property uuid: | ||
| 84 | def __get__(self): | ||
| 85 | return self._c_event.uuid | ||
| 86 | property conn_type: | ||
| 87 | def __get__(self): | ||
| 88 | return self._c_event.conn_type | ||
| 89 | |||
| 90 | cdef void idevice_event_cb(const_idevice_event_t c_event, void *user_data) with gil: | ||
| 78 | cdef iDeviceEvent event = iDeviceEvent.__new__(iDeviceEvent) | 91 | cdef iDeviceEvent event = iDeviceEvent.__new__(iDeviceEvent) |
| 79 | event._c_event = c_event | 92 | event._c_event = c_event |
| 80 | (<object>user_data)(event) | 93 | (<object>user_data)(event) |
| 81 | 94 | ||
| 82 | cpdef event_subscribe(object callback): | 95 | def event_subscribe(object callback): |
| 83 | cdef iDeviceError err = iDeviceError(idevice_event_subscribe(idevice_event_cb, <void*>callback)) | 96 | cdef iDeviceError err = iDeviceError(idevice_event_subscribe(idevice_event_cb, <void*>callback)) |
| 84 | if err: raise err | 97 | if err: raise err |
| 85 | 98 | ||
| 86 | cpdef event_unsubscribe(): | 99 | def event_unsubscribe(): |
| 87 | cdef iDeviceError err = iDeviceError(idevice_event_unsubscribe()) | 100 | cdef iDeviceError err = iDeviceError(idevice_event_unsubscribe()) |
| 88 | if err: raise err | 101 | if err: raise err |
| 89 | 102 | ||
| 90 | cpdef get_device_list(): | 103 | def get_device_list(): |
| 91 | cdef: | 104 | cdef: |
| 92 | char** devices | 105 | char** devices |
| 93 | int count | 106 | int count |
| @@ -214,10 +227,14 @@ cdef class LockdownError(BaseError): | |||
| 214 | BaseError.__init__(self, *args, **kwargs) | 227 | BaseError.__init__(self, *args, **kwargs) |
| 215 | 228 | ||
| 216 | cdef class LockdownClient(Base): | 229 | cdef class LockdownClient(Base): |
| 217 | def __cinit__(self, iDevice device not None, char *label=NULL, *args, **kwargs): | 230 | def __cinit__(self, iDevice device not None, bytes label="", *args, **kwargs): |
| 218 | cdef: | 231 | cdef: |
| 219 | iDevice dev = device | 232 | iDevice dev = device |
| 220 | lockdownd_error_t err = lockdownd_client_new_with_handshake(dev._c_dev, &(self._c_client), label) | 233 | lockdownd_error_t err |
| 234 | char* c_label = NULL | ||
| 235 | if label: | ||
| 236 | c_label = label | ||
| 237 | err = lockdownd_client_new_with_handshake(dev._c_dev, &(self._c_client), c_label) | ||
| 221 | self.handle_error(err) | 238 | self.handle_error(err) |
| 222 | 239 | ||
| 223 | def __dealloc__(self): | 240 | def __dealloc__(self): |
| @@ -229,7 +246,7 @@ cdef class LockdownClient(Base): | |||
| 229 | cdef inline BaseError _error(self, int16_t ret): | 246 | cdef inline BaseError _error(self, int16_t ret): |
| 230 | return LockdownError(ret) | 247 | return LockdownError(ret) |
| 231 | 248 | ||
| 232 | cpdef int start_service(self, service): | 249 | cpdef int start_service(self, bytes service): |
| 233 | cdef: | 250 | cdef: |
| 234 | uint16_t port | 251 | uint16_t port |
| 235 | lockdownd_error_t err | 252 | lockdownd_error_t err |
| @@ -242,6 +259,8 @@ cdef class LockdownClient(Base): | |||
| 242 | 259 | ||
| 243 | cdef extern from *: | 260 | cdef extern from *: |
| 244 | ctypedef char* const_char_ptr "const char*" | 261 | ctypedef char* const_char_ptr "const char*" |
| 262 | void free(void *ptr) | ||
| 263 | void plist_free(plist.plist_t node) | ||
| 245 | 264 | ||
| 246 | include "property_list_client.pxi" | 265 | include "property_list_client.pxi" |
| 247 | include "mobilesync.pxi" | 266 | include "mobilesync.pxi" |
diff --git a/cython/installation_proxy.pxi b/cython/installation_proxy.pxi index 22e7e38..a8083d3 100644 --- a/cython/installation_proxy.pxi +++ b/cython/installation_proxy.pxi | |||
| @@ -26,7 +26,7 @@ cdef extern from "libimobiledevice/installation_proxy.h": | |||
| 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) | 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) | 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 | 28 | ||
| 29 | cdef void instproxy_notify_cb(const_char_ptr operation, plist.plist_t status, void *py_callback): | 29 | cdef void instproxy_notify_cb(const_char_ptr operation, plist.plist_t status, void *py_callback) with gil: |
| 30 | (<object>py_callback)(operation, plist.plist_t_to_node(status, False)) | 30 | (<object>py_callback)(operation, plist.plist_t_to_node(status, False)) |
| 31 | 31 | ||
| 32 | cdef class InstallationProxyError(BaseError): | 32 | cdef class InstallationProxyError(BaseError): |
diff --git a/cython/property_list_client.pxi b/cython/property_list_client.pxi index 874f2b5..2f9ce76 100644 --- a/cython/property_list_client.pxi +++ b/cython/property_list_client.pxi | |||
| @@ -4,8 +4,16 @@ cdef class PropertyListClient(Base): | |||
| 4 | self.handle_error(self._send(n._c_node)) | 4 | self.handle_error(self._send(n._c_node)) |
| 5 | 5 | ||
| 6 | cpdef object receive(self): | 6 | cpdef object receive(self): |
| 7 | cdef plist.plist_t c_node = NULL | 7 | cdef: |
| 8 | self.handle_error(self._receive(&c_node)) | 8 | plist.plist_t c_node = NULL |
| 9 | int16_t err | ||
| 10 | err = self._receive(&c_node) | ||
| 11 | try: | ||
| 12 | self.handle_error(err) | ||
| 13 | except BaseError, e: | ||
| 14 | if c_node != NULL: | ||
| 15 | plist_free(c_node) | ||
| 16 | raise | ||
| 9 | 17 | ||
| 10 | return plist.plist_t_to_node(c_node) | 18 | return plist.plist_t_to_node(c_node) |
| 11 | 19 | ||
diff --git a/cython/sbservices.pxi b/cython/sbservices.pxi index f458bec..6eece0a 100644 --- a/cython/sbservices.pxi +++ b/cython/sbservices.pxi | |||
| @@ -29,14 +29,16 @@ cdef class SpringboardServicesClient(Base): | |||
| 29 | cdef sbservices_client_t _c_client | 29 | cdef sbservices_client_t _c_client |
| 30 | 30 | ||
| 31 | def __cinit__(self, iDevice device not None, LockdownClient lockdown=None, *args, **kwargs): | 31 | def __cinit__(self, iDevice device not None, LockdownClient lockdown=None, *args, **kwargs): |
| 32 | cdef iDevice dev = device | 32 | cdef: |
| 33 | cdef LockdownClient lckd | 33 | iDevice dev = device |
| 34 | LockdownClient lckd | ||
| 34 | if lockdown is None: | 35 | if lockdown is None: |
| 35 | lckd = LockdownClient(dev) | 36 | lckd = LockdownClient(dev) |
| 36 | else: | 37 | else: |
| 37 | lckd = lockdown | 38 | lckd = lockdown |
| 38 | port = lockdown.start_service("com.apple.springboardservices") | 39 | port = lckd.start_service("com.apple.springboardservices") |
| 39 | self.handle_error(sbservices_client_new(dev._c_dev, port, &(self._c_client))) | 40 | err = SpringboardServicesError(sbservices_client_new(dev._c_dev, port, &(self._c_client))) |
| 41 | if err: raise err | ||
| 40 | 42 | ||
| 41 | def __dealloc__(self): | 43 | def __dealloc__(self): |
| 42 | if self._c_client is not NULL: | 44 | if self._c_client is not NULL: |
| @@ -51,7 +53,14 @@ cdef class SpringboardServicesClient(Base): | |||
| 51 | cdef: | 53 | cdef: |
| 52 | plist.plist_t c_node = NULL | 54 | plist.plist_t c_node = NULL |
| 53 | plist.Node node | 55 | plist.Node node |
| 54 | self.handle_error(sbservices_get_icon_state(self._c_client, &c_node)) | 56 | sbservices_error_t err |
| 57 | err = sbservices_get_icon_state(self._c_client, &c_node) | ||
| 58 | try: | ||
| 59 | self.handle_error(err) | ||
| 60 | except BaseError, e: | ||
| 61 | if c_node != NULL: | ||
| 62 | plist_free(c_node) | ||
| 63 | raise | ||
| 55 | node = plist.plist_t_to_node(c_node) | 64 | node = plist.plist_t_to_node(c_node) |
| 56 | return node | 65 | return node |
| 57 | def __set__(self, plist.Node newstate not None): | 66 | def __set__(self, plist.Node newstate not None): |
| @@ -63,6 +72,13 @@ cdef class SpringboardServicesClient(Base): | |||
| 63 | bytes result | 72 | bytes result |
| 64 | char* pngdata = NULL | 73 | char* pngdata = NULL |
| 65 | uint64_t pngsize | 74 | uint64_t pngsize |
| 66 | self.handle_error(sbservices_get_icon_pngdata(self._c_client, bundleId, &pngdata, &pngsize)) | 75 | sbservices_error_t err |
| 67 | result = pngdata[:pngsize] | 76 | err = sbservices_get_icon_pngdata(self._c_client, bundleId, &pngdata, &pngsize) |
| 77 | try: | ||
| 78 | self.handle_error(err) | ||
| 79 | except BaseError, e: | ||
| 80 | raise | ||
| 81 | finally: | ||
| 82 | result = pngdata[:pngsize] | ||
| 83 | free(pngdata) | ||
| 68 | return result | 84 | return result |
