summaryrefslogtreecommitdiffstats
path: root/cython
diff options
context:
space:
mode:
Diffstat (limited to 'cython')
-rw-r--r--cython/imobiledevice.pxd3
-rw-r--r--cython/imobiledevice.pyx2
-rw-r--r--cython/installation_proxy.pxi2
-rw-r--r--cython/lockdown.pxi20
-rw-r--r--cython/mobile_image_mounter.pxi43
-rw-r--r--cython/notification_proxy.pxi2
6 files changed, 61 insertions, 11 deletions
diff --git a/cython/imobiledevice.pxd b/cython/imobiledevice.pxd
index b44e444..238df68 100644
--- a/cython/imobiledevice.pxd
+++ b/cython/imobiledevice.pxd
@@ -1,3 +1,6 @@
+#!python
+#cython: language_level=3str
+
cimport plist
from libc.stdint cimport *
diff --git a/cython/imobiledevice.pyx b/cython/imobiledevice.pyx
index 2a125aa..8da2296 100644
--- a/cython/imobiledevice.pyx
+++ b/cython/imobiledevice.pyx
@@ -94,7 +94,7 @@ cdef class iDeviceEvent:
def __get__(self):
return self._c_event.conn_type
-cdef void idevice_event_cb(const_idevice_event_t c_event, void *user_data) with gil:
+cdef void idevice_event_cb(const_idevice_event_t c_event, void *user_data) noexcept:
cdef iDeviceEvent event = iDeviceEvent.__new__(iDeviceEvent)
event._c_event = c_event
(<object>user_data)(event)
diff --git a/cython/installation_proxy.pxi b/cython/installation_proxy.pxi
index bf2c1da..1d3e323 100644
--- a/cython/installation_proxy.pxi
+++ b/cython/installation_proxy.pxi
@@ -27,7 +27,7 @@ cdef extern from "libimobiledevice/installation_proxy.h":
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)
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)
-cdef void instproxy_notify_cb(plist.plist_t command, plist.plist_t status, void *py_callback) with gil:
+cdef void instproxy_notify_cb(plist.plist_t command, plist.plist_t status, void *py_callback) noexcept:
(<object>py_callback)(plist.plist_t_to_node(command, False), plist.plist_t_to_node(status, False))
cdef class InstallationProxyError(BaseError):
diff --git a/cython/lockdown.pxi b/cython/lockdown.pxi
index 1bf7072..25edb4c 100644
--- a/cython/lockdown.pxi
+++ b/cython/lockdown.pxi
@@ -210,14 +210,23 @@ cdef class LockdownClient(PropertyListService):
raise
cpdef set_value(self, bytes domain, bytes key, object value):
- cdef plist.plist_t c_node = plist.native_to_plist_t(value)
+ cdef:
+ plist.plist_t c_node = NULL
+ char* c_domain = NULL
+ char* c_key = NULL
+
+ c_node = plist.native_to_plist_t(value)
+ if domain is not None:
+ c_domain = domain
+ if key is not None:
+ c_key = key
try:
- self.handle_error(lockdownd_set_value(self._c_client, domain, key, c_node))
+ self.handle_error(lockdownd_set_value(self._c_client, c_domain, c_key, c_node))
except BaseError, e:
raise
finally:
if c_node != NULL:
- plist.plist_free(c_node)
+ c_node = NULL
cpdef remove_value(self, bytes domain, bytes key):
self.handle_error(lockdownd_remove_value(self._c_client, domain, key))
@@ -231,11 +240,12 @@ cdef class LockdownClient(PropertyListService):
if issubclass(service, BaseService) and \
service.__service_name__ is not None \
and isinstance(service.__service_name__, (str, bytes)):
- c_service_name = <bytes>service.__service_name__
+ c_service_name_str = service.__service_name__.encode('utf-8')
elif isinstance(service, (str, bytes)):
- c_service_name = <bytes>service
+ c_service_name_str = service.encode('utf-8')
else:
raise TypeError("LockdownClient.start_service() takes a BaseService or string as its first argument")
+ c_service_name = c_service_name_str
try:
self.handle_error(lockdownd_start_service(self._c_client, c_service_name, &c_descriptor))
diff --git a/cython/mobile_image_mounter.pxi b/cython/mobile_image_mounter.pxi
index a23a59b..d9d40d5 100644
--- a/cython/mobile_image_mounter.pxi
+++ b/cython/mobile_image_mounter.pxi
@@ -13,7 +13,9 @@ cdef extern from "libimobiledevice/mobile_image_mounter.h":
mobile_image_mounter_error_t mobile_image_mounter_new(idevice_t device, lockdownd_service_descriptor_t descriptor, mobile_image_mounter_client_t *client)
mobile_image_mounter_error_t mobile_image_mounter_free(mobile_image_mounter_client_t client)
mobile_image_mounter_error_t mobile_image_mounter_lookup_image(mobile_image_mounter_client_t client, char *image_type, plist.plist_t *result)
- 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)
+ mobile_image_mounter_error_t mobile_image_mounter_mount_image_with_options(mobile_image_mounter_client_t client, char *image_path, const unsigned char *signature, unsigned int signature_length, char *image_type, plist.plist_t options, plist.plist_t *result)
+ mobile_image_mounter_error_t mobile_image_mounter_mount_image(mobile_image_mounter_client_t client, char *image_path, const unsigned char *signature, unsigned int signature_length, char *image_type, plist.plist_t *result)
+ mobile_image_mounter_error_t mobile_image_mounter_unmount_image(mobile_image_mounter_client_t client, const char *mount_path);
mobile_image_mounter_error_t mobile_image_mounter_hangup(mobile_image_mounter_client_t client)
cdef class MobileImageMounterError(BaseError):
@@ -57,11 +59,39 @@ cdef class MobileImageMounterClient(PropertyListService):
if c_node != NULL:
plist.plist_free(c_node)
- cpdef plist.Node mount_image(self, bytes image_path, bytes image_signature, bytes image_type):
+ cpdef plist.Node mount_image_with_options(self, bytes image_path, bytes signature, bytes image_type, object options):
cdef:
+ plist.Node n_options
+ plist.plist_t c_options
+ plist.plist_t c_result = NULL
+ bint free_options = False
plist.plist_t c_node = NULL
mobile_image_mounter_error_t err
- err = mobile_image_mounter_mount_image(self._c_client, image_path, image_signature, len(image_signature),
+ if isinstance(options, plist.Dict):
+ n_options = options
+ c_options = n_options._c_node
+ elif isinstance(options, dict):
+ c_options = plist.native_to_plist_t(options)
+ free_options = True
+ else:
+ raise InstallationProxyError(INSTPROXY_E_INVALID_ARG)
+ err = mobile_image_mounter_mount_image_with_options(self._c_client, image_path, signature, len(signature),
+ image_type, c_options, &c_node)
+ if free_options:
+ plist.plist_free(c_options)
+ try:
+ self.handle_error(err)
+
+ return plist.plist_t_to_node(c_node)
+ except Exception, e:
+ if c_node != NULL:
+ plist.plist_free(c_node)
+
+ cpdef plist.Node mount_image(self, bytes image_path, bytes signature, bytes image_type):
+ cdef:
+ plist.plist_t c_node = NULL
+ mobile_image_mounter_error_t err
+ err = mobile_image_mounter_mount_image(self._c_client, image_path, signature, len(signature),
image_type, &c_node)
try:
@@ -72,6 +102,13 @@ cdef class MobileImageMounterClient(PropertyListService):
if c_node != NULL:
plist.plist_free(c_node)
+ cpdef unmount_image(self, bytes mount_path):
+ cdef:
+ mobile_image_mounter_error_t err
+ err = mobile_image_mounter_unmount_image(self._c_client, mount_path)
+
+ self.handle_error(err)
+
cpdef hangup(self):
cdef mobile_image_mounter_error_t err
err = mobile_image_mounter_hangup(self._c_client)
diff --git a/cython/notification_proxy.pxi b/cython/notification_proxy.pxi
index 4ffbf07..261200e 100644
--- a/cython/notification_proxy.pxi
+++ b/cython/notification_proxy.pxi
@@ -70,7 +70,7 @@ NP_ITDBPREP_DID_END = C_NP_ITDBPREP_DID_END
NP_LANGUAGE_CHANGED = C_NP_LANGUAGE_CHANGED
NP_ADDRESS_BOOK_PREF_CHANGED = C_NP_ADDRESS_BOOK_PREF_CHANGED
-cdef void np_notify_cb(const_char_ptr notification, void *py_callback):
+cdef void np_notify_cb(const_char_ptr notification, void *py_callback) noexcept:
(<object>py_callback)(notification)
cdef class NotificationProxyError(BaseError):