summaryrefslogtreecommitdiffstats
path: root/cython
diff options
context:
space:
mode:
Diffstat (limited to 'cython')
-rw-r--r--cython/Makefile.am96
-rw-r--r--cython/afc.pxi28
-rw-r--r--cython/debugserver.pxi15
-rw-r--r--cython/diagnostics_relay.pxi10
-rw-r--r--cython/heartbeat.pxi4
-rw-r--r--cython/imobiledevice.pxd11
-rw-r--r--cython/imobiledevice.pyx15
-rw-r--r--cython/installation_proxy.pxi2
-rw-r--r--cython/lockdown.pxi26
-rw-r--r--cython/mobilebackup.pxi8
-rw-r--r--cython/mobilebackup2.pxi41
-rw-r--r--cython/mobilesync.pxi14
-rw-r--r--cython/notification_proxy.pxi2
-rw-r--r--cython/restore.pxi16
-rw-r--r--cython/screenshotr.pxi6
-rw-r--r--cython/webinspector.pxi4
16 files changed, 193 insertions, 105 deletions
diff --git a/cython/Makefile.am b/cython/Makefile.am
index fb9a2e4..93ea6ed 100644
--- a/cython/Makefile.am
+++ b/cython/Makefile.am
@@ -1,52 +1,84 @@
-AM_CPPFLAGS = -I$(top_srcdir)/include
+AM_CPPFLAGS = \
+ -I$(top_srcdir)/include
-AM_CFLAGS = $(GLOBAL_CFLAGS) $(libgnutls_CFLAGS) $(libtasn1_CFLAGS) $(openssl_CFLAGS) $(libplist_CFLAGS) $(LFS_CFLAGS)
-AM_LDFLAGS = $(libgnutls_LIBS) $(libtasn1_LIBS) $(openssl_LIBS) $(libplist_LIBS)
+AM_CFLAGS = \
+ $(GLOBAL_CFLAGS) \
+ $(ssl_lib_CFLAGS) \
+ $(LFS_CFLAGS) \
+ $(PTHREAD_CFLAGS) \
+ $(libplist_CFLAGS)
+
+AM_LIBS = \
+ $(ssl_lib_LIBS) \
+ $(PTHREAD_LIBS) \
+ $(libplist_LIBS)
if HAVE_CYTHON
BUILT_SOURCES = imobiledevice.c
-PXDINCLUDES = imobiledevice.pxd $(CYTHON_PLIST_INCLUDE_DIR)/plist.pxd
-PXIINCLUDES = \
- lockdown.pxi \
- mobilesync.pxi \
- notification_proxy.pxi \
- sbservices.pxi \
- mobilebackup.pxi \
- mobilebackup2.pxi \
- afc.pxi \
- file_relay.pxi \
- screenshotr.pxi \
- installation_proxy.pxi \
- webinspector.pxi \
- heartbeat.pxi \
- diagnostics_relay.pxi \
- misagent.pxi \
- house_arrest.pxi \
- restore.pxi \
- mobile_image_mounter.pxi \
+PXDINCLUDES = \
+ imobiledevice.pxd \
+ $(CYTHON_PLIST_INCLUDE_DIR)/plist.pxd
+
+PXIINCLUDES = \
+ lockdown.pxi \
+ mobilesync.pxi \
+ notification_proxy.pxi \
+ sbservices.pxi \
+ mobilebackup.pxi \
+ mobilebackup2.pxi \
+ afc.pxi \
+ file_relay.pxi \
+ screenshotr.pxi \
+ installation_proxy.pxi \
+ webinspector.pxi \
+ heartbeat.pxi \
+ diagnostics_relay.pxi \
+ misagent.pxi \
+ house_arrest.pxi \
+ restore.pxi \
+ mobile_image_mounter.pxi \
debugserver.pxi
-CLEANFILES = \
- *.pyc \
- *.pyo \
+CLEANFILES = \
+ *.pyc \
+ *.pyo \
imobiledevice.c
-EXTRA_DIST = imobiledevice.pyx imobiledevice.pxd $(PXIINCLUDES)
+EXTRA_DIST = \
+ imobiledevice.pyx \
+ imobiledevice.pxd \
+ $(PXIINCLUDES)
imobiledevicedir = $(pyexecdir)
imobiledevice_LTLIBRARIES = imobiledevice.la
imobiledevice_la_SOURCES = imobiledevice.pyx
-imobiledevice_la_CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/src $(PYTHON_CPPFLAGS) $(AM_CFLAGS) -Wno-shadow -Wno-redundant-decls -Wno-switch-default -Wno-strict-aliasing -Wno-implicit-function-declaration -fvisibility=default
-imobiledevice_la_LDFLAGS = -module -avoid-version -L$(libdir) $(PYTHON_LDFLAGS) $(AM_LDFLAGS) -no-undefined
-imobiledevice_la_LIBADD = $(top_builddir)/src/libimobiledevice.la
+imobiledevice_la_CFLAGS = \
+ -I$(top_srcdir)/include \
+ -I$(top_srcdir)/src \
+ $(PYTHON_CPPFLAGS) \
+ $(AM_CFLAGS) \
+ -Wno-shadow \
+ -Wno-redundant-decls \
+ -Wno-switch-default \
+ -Wno-strict-aliasing \
+ -Wno-implicit-function-declaration \
+ -fvisibility=default \
+ $(CYTHON_CFLAGS)
+
+imobiledevice_la_LDFLAGS = \
+ -module \
+ -avoid-version \
+ -L$(libdir) \
+ $(PYTHON_LIBS) \
+ $(AM_LIBS) \
+ -no-undefined
+
+imobiledevice_la_LIBADD = $(top_builddir)/src/libimobiledevice-1.0.la
imobiledevice.c: imobiledevice.pyx $(PXDINCLUDES) $(PXIINCLUDES)
.pyx.c:
$(CYTHON) -I$(CYTHON_PLIST_INCLUDE_DIR) -I$(top_srcdir)/src -o $@ $<
-# imobiledevice_private.c: $(IMOBILEDEVICE_PRIVATE_SOURCES) $(IMOBILEDEVICE_INCLUDES) $(PLIST_INCLUDES)
-# $(CYTHON) $(IMOBILEDEVICE_CPPFLAGS) -I$(top_srcdir)/src -o $@ $<
-
endif
diff --git a/cython/afc.pxi b/cython/afc.pxi
index e34588f..6bd8182 100644
--- a/cython/afc.pxi
+++ b/cython/afc.pxi
@@ -52,6 +52,7 @@ cdef extern from "libimobiledevice/afc.h":
afc_error_t afc_read_directory(afc_client_t client, char *dir, char ***list)
afc_error_t afc_get_file_info(afc_client_t client, char *filename, char ***infolist)
afc_error_t afc_remove_path(afc_client_t client, char *path)
+ afc_error_t afc_remove_path_and_contents(afc_client_t client, char *path)
afc_error_t afc_rename_path(afc_client_t client, char *f, char *to)
afc_error_t afc_make_directory(afc_client_t client, char *dir)
afc_error_t afc_truncate(afc_client_t client, char *path, uint64_t newsize)
@@ -235,17 +236,17 @@ cdef class AfcClient(BaseService):
afc_file_mode_t c_mode
uint64_t handle
AfcFile f
- if mode == <bytes>'r':
+ if mode == b'r':
c_mode = AFC_FOPEN_RDONLY
- elif mode == <bytes>'r+':
+ elif mode == b'r+':
c_mode = AFC_FOPEN_RW
- elif mode == <bytes>'w':
+ elif mode == b'w':
c_mode = AFC_FOPEN_WRONLY
- elif mode == <bytes>'w+':
+ elif mode == b'w+':
c_mode = AFC_FOPEN_WR
- elif mode == <bytes>'a':
+ elif mode == b'a':
c_mode = AFC_FOPEN_APPEND
- elif mode == <bytes>'a+':
+ elif mode == b'a+':
c_mode = AFC_FOPEN_RDAPPEND
else:
raise ValueError("mode string must be 'r', 'r+', 'w', 'w+', 'a', or 'a+'")
@@ -282,6 +283,9 @@ cdef class AfcClient(BaseService):
cpdef remove_path(self, bytes path):
self.handle_error(afc_remove_path(self._c_client, path))
+ cpdef remove_path_and_contents(self, bytes path):
+ self.handle_error(afc_remove_path_and_contents(self._c_client, path))
+
cpdef rename_path(self, bytes f, bytes t):
self.handle_error(afc_rename_path(self._c_client, f, t))
@@ -308,17 +312,17 @@ cdef class Afc2Client(AfcClient):
afc_file_mode_t c_mode
uint64_t handle
AfcFile f
- if mode == <bytes>'r':
+ if mode == b'r':
c_mode = AFC_FOPEN_RDONLY
- elif mode == <bytes>'r+':
+ elif mode == b'r+':
c_mode = AFC_FOPEN_RW
- elif mode == <bytes>'w':
+ elif mode == b'w':
c_mode = AFC_FOPEN_WRONLY
- elif mode == <bytes>'w+':
+ elif mode == b'w+':
c_mode = AFC_FOPEN_WR
- elif mode == <bytes>'a':
+ elif mode == b'a':
c_mode = AFC_FOPEN_APPEND
- elif mode == <bytes>'a+':
+ elif mode == b'a+':
c_mode = AFC_FOPEN_RDAPPEND
else:
raise ValueError("mode string must be 'r', 'r+', 'w', 'w+', 'a', or 'a+'")
diff --git a/cython/debugserver.pxi b/cython/debugserver.pxi
index ddbe066..a3b7d1e 100644
--- a/cython/debugserver.pxi
+++ b/cython/debugserver.pxi
@@ -17,10 +17,10 @@ cdef extern from "libimobiledevice/debugserver.h":
debugserver_error_t debugserver_client_free(debugserver_client_t client)
debugserver_error_t debugserver_client_send(debugserver_client_t client, const char* data, uint32_t size, uint32_t *sent)
- debugserver_error_t debugserver_client_send_command(debugserver_client_t client, debugserver_command_t command, char** response)
+ debugserver_error_t debugserver_client_send_command(debugserver_client_t client, debugserver_command_t command, char** response, size_t* response_size)
debugserver_error_t debugserver_client_receive(debugserver_client_t client, char *data, uint32_t size, uint32_t *received)
debugserver_error_t debugserver_client_receive_with_timeout(debugserver_client_t client, char *data, uint32_t size, uint32_t *received, unsigned int timeout)
- debugserver_error_t debugserver_client_receive_response(debugserver_client_t client, char** response)
+ debugserver_error_t debugserver_client_receive_response(debugserver_client_t client, char** response, size_t* response_size)
debugserver_error_t debugserver_client_set_argv(debugserver_client_t client, int argc, char* argv[], char** response)
debugserver_error_t debugserver_client_set_environment_hex_encoded(debugserver_client_t client, const char* env, char** response)
@@ -44,7 +44,12 @@ cdef class DebugServerError(BaseError):
# from http://stackoverflow.com/a/17511714
-from cpython.string cimport PyString_AsString
+# https://github.com/libimobiledevice/libimobiledevice/pull/198
+from cpython cimport PY_MAJOR_VERSION
+if PY_MAJOR_VERSION <= 2:
+ from cpython.string cimport PyString_AsString
+else:
+ from cpython.bytes cimport PyBytes_AsString as PyString_AsString
cdef char ** to_cstring_array(list_str):
if not list_str:
return NULL
@@ -119,7 +124,7 @@ cdef class DebugServerClient(BaseService):
bytes result
try:
- self.handle_error(debugserver_client_send_command(self._c_client, command._c_command, &c_response))
+ self.handle_error(debugserver_client_send_command(self._c_client, command._c_command, &c_response, NULL))
if c_response:
result = c_response
return result
@@ -166,7 +171,7 @@ cdef class DebugServerClient(BaseService):
bytes result
try:
- self.handle_error(debugserver_client_receive_response(self._c_client, &c_response))
+ self.handle_error(debugserver_client_receive_response(self._c_client, &c_response, NULL))
if c_response:
result = c_response
return result
diff --git a/cython/diagnostics_relay.pxi b/cython/diagnostics_relay.pxi
index 155e5b7..0e6bd20 100644
--- a/cython/diagnostics_relay.pxi
+++ b/cython/diagnostics_relay.pxi
@@ -15,7 +15,7 @@ cdef extern from "libimobiledevice/diagnostics_relay.h":
DIAGNOSTICS_RELAY_E_MUX_ERROR = -3
DIAGNOSTICS_RELAY_E_UNKNOWN_REQUEST = -4
DIAGNOSTICS_RELAY_E_UNKNOWN_ERROR = -256
- cdef enum:
+ ctypedef enum diagnostics_relay_action_t:
DIAGNOSTICS_RELAY_ACTION_FLAG_WAIT_FOR_DISCONNECT = (1 << 1)
DIAGNOSTICS_RELAY_ACTION_FLAG_DISPLAY_PASS = (1 << 2)
DIAGNOSTICS_RELAY_ACTION_FLAG_DISPLAY_FAIL = (1 << 3)
@@ -25,8 +25,8 @@ cdef extern from "libimobiledevice/diagnostics_relay.h":
diagnostics_relay_error_t diagnostics_relay_goodbye(diagnostics_relay_client_t client)
diagnostics_relay_error_t diagnostics_relay_sleep(diagnostics_relay_client_t client)
- diagnostics_relay_error_t diagnostics_relay_restart(diagnostics_relay_client_t client, int flags)
- diagnostics_relay_error_t diagnostics_relay_shutdown(diagnostics_relay_client_t client, int flags)
+ diagnostics_relay_error_t diagnostics_relay_restart(diagnostics_relay_client_t client, diagnostics_relay_action_t flags)
+ diagnostics_relay_error_t diagnostics_relay_shutdown(diagnostics_relay_client_t client, diagnostics_relay_action_t flags)
diagnostics_relay_error_t diagnostics_relay_request_diagnostics(diagnostics_relay_client_t client, char* type, plist.plist_t* diagnostics)
diagnostics_relay_error_t diagnostics_relay_query_mobilegestalt(diagnostics_relay_client_t client, plist.plist_t keys, plist.plist_t* result)
diagnostics_relay_error_t diagnostics_relay_query_ioregistry_entry(diagnostics_relay_client_t client, char* name, char* class_name, plist.plist_t* result)
@@ -66,10 +66,10 @@ cdef class DiagnosticsRelayClient(PropertyListService):
cpdef sleep(self):
self.handle_error(diagnostics_relay_sleep(self._c_client))
- cpdef restart(self, int flags):
+ cpdef restart(self, diagnostics_relay_action_t flags):
self.handle_error(diagnostics_relay_restart(self._c_client, flags))
- cpdef shutdown(self, int flags):
+ cpdef shutdown(self, diagnostics_relay_action_t flags):
self.handle_error(diagnostics_relay_shutdown(self._c_client, flags))
cpdef plist.Node request_diagnostics(self, bytes type):
diff --git a/cython/heartbeat.pxi b/cython/heartbeat.pxi
index b48fb59..2f58909 100644
--- a/cython/heartbeat.pxi
+++ b/cython/heartbeat.pxi
@@ -9,6 +9,8 @@ cdef extern from "libimobiledevice/heartbeat.h":
HEARTBEAT_E_PLIST_ERROR = -2
HEARTBEAT_E_MUX_ERROR = -3
HEARTBEAT_E_SSL_ERROR = -4
+ HEARTBEAT_E_NOT_ENOUGH_DATA = -5
+ HEARTBEAT_E_TIMEOUT = -6
HEARTBEAT_E_UNKNOWN_ERROR = -256
heartbeat_error_t heartbeat_client_new(idevice_t device, lockdownd_service_descriptor_t descriptor, heartbeat_client_t * client)
@@ -26,6 +28,8 @@ cdef class HeartbeatError(BaseError):
HEARTBEAT_E_PLIST_ERROR: "Property list error",
HEARTBEAT_E_MUX_ERROR: "MUX error",
HEARTBEAT_E_SSL_ERROR: "SSL Error",
+ HEARTBEAT_E_NOT_ENOUGH_DATA: 'Not enough data',
+ HEARTBEAT_E_TIMEOUT: 'Connection timeout',
HEARTBEAT_E_UNKNOWN_ERROR: "Unknown error"
}
BaseError.__init__(self, *args, **kwargs)
diff --git a/cython/imobiledevice.pxd b/cython/imobiledevice.pxd
index 8523c94..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 *
@@ -23,13 +26,17 @@ cdef extern from "libimobiledevice/libimobiledevice.h":
cdef struct idevice_connection_private:
pass
ctypedef idevice_connection_private* idevice_connection_t
+ cdef enum idevice_connection_type:
+ CONNECTION_USBMUXD = 1
+ CONNECTION_NETWORK
cdef enum idevice_event_type:
- IDEVICE_DEVICE_ADD = 1,
+ IDEVICE_DEVICE_ADD = 1
IDEVICE_DEVICE_REMOVE
+ IDEVICE_DEVICE_PAIRED
ctypedef struct idevice_event_t:
idevice_event_type event
char *udid
- int conn_type
+ idevice_connection_type conn_type
ctypedef idevice_event_t* const_idevice_event_t "const idevice_event_t*"
cdef class iDeviceEvent:
diff --git a/cython/imobiledevice.pyx b/cython/imobiledevice.pyx
index bc861b3..8da2296 100644
--- a/cython/imobiledevice.pyx
+++ b/cython/imobiledevice.pyx
@@ -38,8 +38,12 @@ cdef extern from "libimobiledevice/libimobiledevice.h":
IDEVICE_E_UNKNOWN_ERROR = -2
IDEVICE_E_NO_DEVICE = -3
IDEVICE_E_NOT_ENOUGH_DATA = -4
- IDEVICE_E_BAD_HEADER = -5
IDEVICE_E_SSL_ERROR = -6
+ IDEVICE_E_TIMEOUT = -7
+ cdef enum idevice_options:
+ IDEVICE_LOOKUP_USBMUX = 1 << 1
+ IDEVICE_LOOKUP_NETWORK = 1 << 2
+ IDEVICE_LOOKUP_PREFER_NETWORK = 1 << 3
ctypedef void (*idevice_event_cb_t) (const_idevice_event_t event, void *user_data)
cdef extern idevice_error_t idevice_event_subscribe(idevice_event_cb_t callback, void *user_data)
cdef extern idevice_error_t idevice_event_unsubscribe()
@@ -47,6 +51,7 @@ cdef extern from "libimobiledevice/libimobiledevice.h":
idevice_error_t idevice_device_list_free(char **devices)
void idevice_set_debug_level(int level)
idevice_error_t idevice_new(idevice_t *device, char *udid)
+ idevice_error_t idevice_new_with_options(idevice_t *device, const char *udid, idevice_options options);
idevice_error_t idevice_free(idevice_t device)
idevice_error_t idevice_get_udid(idevice_t device, char** udid)
idevice_error_t idevice_get_handle(idevice_t device, uint32_t *handle)
@@ -64,8 +69,8 @@ cdef class iDeviceError(BaseError):
IDEVICE_E_UNKNOWN_ERROR: 'Unknown error',
IDEVICE_E_NO_DEVICE: 'No device',
IDEVICE_E_NOT_ENOUGH_DATA: 'Not enough data',
- IDEVICE_E_BAD_HEADER: 'Bad header',
- IDEVICE_E_SSL_ERROR: 'SSL Error'
+ IDEVICE_E_SSL_ERROR: 'SSL Error',
+ IDEVICE_E_TIMEOUT: 'Connection timeout'
}
BaseError.__init__(self, *args, **kwargs)
@@ -89,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)
@@ -171,7 +176,7 @@ from libc.stdlib cimport *
cdef class iDevice(Base):
def __cinit__(self, object udid=None, *args, **kwargs):
cdef char* c_udid = NULL
- if isinstance(udid, basestring):
+ if isinstance(udid, (str, bytes)):
c_udid = <bytes>udid
elif udid is not None:
raise TypeError("iDevice's constructor takes a string or None as the udid argument")
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 f249049..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))
@@ -230,12 +239,13 @@ cdef class LockdownClient(PropertyListService):
if issubclass(service, BaseService) and \
service.__service_name__ is not None \
- and isinstance(service.__service_name__, basestring):
- c_service_name = <bytes>service.__service_name__
- elif isinstance(service, basestring):
- c_service_name = <bytes>service
+ and isinstance(service.__service_name__, (str, bytes)):
+ c_service_name_str = service.__service_name__.encode('utf-8')
+ elif isinstance(service, (str, bytes)):
+ 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))
@@ -253,7 +263,7 @@ cdef class LockdownClient(PropertyListService):
if not hasattr(service_class, '__service_name__') and \
not service_class.__service_name__ is not None \
- and not isinstance(service_class.__service_name__, basestring):
+ and not isinstance(service_class.__service_name__, (str, bytes)):
raise TypeError("LockdownClient.get_service_client() takes a BaseService as its first argument")
descriptor = self.start_service(service_class)
diff --git a/cython/mobilebackup.pxi b/cython/mobilebackup.pxi
index 5a6fea6..f2d58d4 100644
--- a/cython/mobilebackup.pxi
+++ b/cython/mobilebackup.pxi
@@ -8,8 +8,10 @@ cdef extern from "libimobiledevice/mobilebackup.h":
MOBILEBACKUP_E_INVALID_ARG = -1
MOBILEBACKUP_E_PLIST_ERROR = -2
MOBILEBACKUP_E_MUX_ERROR = -3
- MOBILEBACKUP_E_BAD_VERSION = -4
- MOBILEBACKUP_E_REPLY_NOT_OK = -5
+ MOBILEBACKUP_E_SSL_ERROR = -4
+ MOBILEBACKUP_E_RECEIVE_TIMEOUT = -5
+ MOBILEBACKUP_E_BAD_VERSION = -6
+ MOBILEBACKUP_E_REPLY_NOT_OK = -7
MOBILEBACKUP_E_UNKNOWN_ERROR = -256
ctypedef enum mobilebackup_flags_t:
@@ -36,6 +38,8 @@ cdef class MobileBackupError(BaseError):
MOBILEBACKUP_E_INVALID_ARG: "Invalid argument",
MOBILEBACKUP_E_PLIST_ERROR: "Property list error",
MOBILEBACKUP_E_MUX_ERROR: "MUX error",
+ MOBILEBACKUP_E_SSL_ERROR: "SSL error",
+ MOBILEBACKUP_E_RECEIVE_TIMEOUT: "Receive timeout",
MOBILEBACKUP_E_BAD_VERSION: "Bad version",
MOBILEBACKUP_E_REPLY_NOT_OK: "Reply not OK",
MOBILEBACKUP_E_UNKNOWN_ERROR: "Unknown error"
diff --git a/cython/mobilebackup2.pxi b/cython/mobilebackup2.pxi
index aac5358..4b47e5b 100644
--- a/cython/mobilebackup2.pxi
+++ b/cython/mobilebackup2.pxi
@@ -8,9 +8,11 @@ cdef extern from "libimobiledevice/mobilebackup2.h":
MOBILEBACKUP2_E_INVALID_ARG = -1
MOBILEBACKUP2_E_PLIST_ERROR = -2
MOBILEBACKUP2_E_MUX_ERROR = -3
- MOBILEBACKUP2_E_BAD_VERSION = -4
- MOBILEBACKUP2_E_REPLY_NOT_OK = -5
- MOBILEBACKUP2_E_NO_COMMON_VERSION = -6
+ MOBILEBACKUP2_E_SSL_ERROR = -4
+ MOBILEBACKUP2_E_RECEIVE_TIMEOUT = -5
+ MOBILEBACKUP2_E_BAD_VERSION = -6
+ MOBILEBACKUP2_E_REPLY_NOT_OK = -7
+ MOBILEBACKUP2_E_NO_COMMON_VERSION = -8
MOBILEBACKUP2_E_UNKNOWN_ERROR = -256
mobilebackup2_error_t mobilebackup2_client_new(idevice_t device, lockdownd_service_descriptor_t descriptor, mobilebackup2_client_t * client)
@@ -31,6 +33,8 @@ cdef class MobileBackup2Error(BaseError):
MOBILEBACKUP2_E_INVALID_ARG: "Invalid argument",
MOBILEBACKUP2_E_PLIST_ERROR: "Property list error",
MOBILEBACKUP2_E_MUX_ERROR: "MUX error",
+ MOBILEBACKUP2_E_SSL_ERROR: "SSL error",
+ MOBILEBACKUP2_E_RECEIVE_TIMEOUT: "Receive timeout",
MOBILEBACKUP2_E_BAD_VERSION: "Bad version",
MOBILEBACKUP2_E_REPLY_NOT_OK: "Reply not OK",
MOBILEBACKUP2_E_NO_COMMON_VERSION: "No common version",
@@ -54,10 +58,10 @@ cdef class MobileBackup2Client(PropertyListService):
cdef inline BaseError _error(self, int16_t ret):
return MobileBackup2Error(ret)
- cdef send_message(self, bytes message, plist.Node options):
+ cpdef send_message(self, bytes message, plist.Node options):
self.handle_error(mobilebackup2_send_message(self._c_client, message, options._c_node))
- cdef tuple receive_message(self):
+ cpdef tuple receive_message(self):
cdef:
char* dlmessage = NULL
plist.plist_t c_node = NULL
@@ -73,29 +77,34 @@ cdef class MobileBackup2Client(PropertyListService):
free(dlmessage)
raise
- cdef int send_raw(self, bytes data, int length):
+ cpdef int send_raw(self, bytes data, int length):
cdef:
- uint32_t bytes = 0
+ uint32_t bytes_recvd = 0
mobilebackup2_error_t err
- err = mobilebackup2_send_raw(self._c_client, data, length, &bytes)
+ err = mobilebackup2_send_raw(self._c_client, data, length, &bytes_recvd)
try:
self.handle_error(err)
- return <bint>bytes
+ return <bint>bytes_recvd
except BaseError, e:
raise
- cdef int receive_raw(self, bytes data, int length):
+ cpdef int receive_raw(self, bytearray data, int length):
cdef:
- uint32_t bytes = 0
+ uint32_t bytes_recvd = 0
mobilebackup2_error_t err
- err = mobilebackup2_receive_raw(self._c_client, data, length, &bytes)
+ err = mobilebackup2_receive_raw(self._c_client, data, length, &bytes_recvd)
+
+ # Throwing an exception when we test if theres more data to read is excessive
+ if err == -1 and bytes_recvd == 0:
+ return 0
+
try:
self.handle_error(err)
- return <bint>bytes
+ return <bint>bytes_recvd
except BaseError, e:
raise
- cdef float version_exchange(self, double[::1] local_versions):
+ cpdef float version_exchange(self, double[::1] local_versions):
cdef:
double[::1] temp = None
double remote_version = 0.0
@@ -107,8 +116,8 @@ cdef class MobileBackup2Client(PropertyListService):
except BaseError, e:
raise
- cdef send_request(self, bytes request, bytes target_identifier, bytes source_identifier, plist.Node options):
+ cpdef send_request(self, bytes request, bytes target_identifier, bytes source_identifier, plist.Node options):
self.handle_error(mobilebackup2_send_request(self._c_client, request, target_identifier, source_identifier, options._c_node))
- cdef send_status_response(self, int status_code, bytes status1, plist.Node status2):
+ cpdef send_status_response(self, int status_code, bytes status1, plist.Node status2):
self.handle_error(mobilebackup2_send_status_response(self._c_client, status_code, status1, status2._c_node))
diff --git a/cython/mobilesync.pxi b/cython/mobilesync.pxi
index ba9d585..23f0005 100644
--- a/cython/mobilesync.pxi
+++ b/cython/mobilesync.pxi
@@ -7,11 +7,13 @@ cdef extern from "libimobiledevice/mobilesync.h":
MOBILESYNC_E_INVALID_ARG = -1
MOBILESYNC_E_PLIST_ERROR = -2
MOBILESYNC_E_MUX_ERROR = -3
- MOBILESYNC_E_BAD_VERSION = -4
- MOBILESYNC_E_SYNC_REFUSED = -5
- MOBILESYNC_E_CANCELLED = -6
- MOBILESYNC_E_WRONG_DIRECTION = -7
- MOBILESYNC_E_NOT_READY = -8
+ MOBILESYNC_E_SSL_ERROR = -4
+ MOBILESYNC_E_RECEIVE_TIMEOUT = -5
+ MOBILESYNC_E_BAD_VERSION = -6
+ MOBILESYNC_E_SYNC_REFUSED = -7
+ MOBILESYNC_E_CANCELLED = -8
+ MOBILESYNC_E_WRONG_DIRECTION = -9
+ MOBILESYNC_E_NOT_READY = -10
MOBILESYNC_E_UNKNOWN_ERROR = -256
ctypedef enum mobilesync_sync_type_t:
@@ -60,6 +62,8 @@ cdef class MobileSyncError(BaseError):
MOBILESYNC_E_INVALID_ARG: "Invalid argument",
MOBILESYNC_E_PLIST_ERROR: "Property list error",
MOBILESYNC_E_MUX_ERROR: "MUX error",
+ MOBILESYNC_E_SSL_ERROR: "SSL error",
+ MOBILESYNC_E_RECEIVE_TIMEOUT: "Receive timeout",
MOBILESYNC_E_BAD_VERSION: "Bad version",
MOBILESYNC_E_SYNC_REFUSED: "Sync refused",
MOBILESYNC_E_CANCELLED: "Sync cancelled",
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):
diff --git a/cython/restore.pxi b/cython/restore.pxi
index 7d3d80e..9d03935 100644
--- a/cython/restore.pxi
+++ b/cython/restore.pxi
@@ -6,12 +6,10 @@ cdef extern from "libimobiledevice/restore.h":
ctypedef enum restored_error_t:
RESTORE_E_SUCCESS = 0
RESTORE_E_INVALID_ARG = -1
- RESTORE_E_INVALID_CONF = -2
- RESTORE_E_PLIST_ERROR = -3
- RESTORE_E_DICT_ERROR = -4
- RESTORE_E_NOT_ENOUGH_DATA = -5
- RESTORE_E_MUX_ERROR = -6
- RESTORE_E_START_RESTORE_FAILED = -7
+ RESTORE_E_PLIST_ERROR = -2
+ RESTORE_E_MUX_ERROR = -3
+ RESTORE_E_NOT_ENOUGH_DATA = -4
+ RESTORE_E_RECEIVE_TIMEOUT = -5
RESTORE_E_UNKNOWN_ERROR = -256
restored_error_t restored_client_new(idevice_t device, restored_client_t *client, char *label)
@@ -34,12 +32,10 @@ cdef class RestoreError(BaseError):
self._lookup_table = {
RESTORE_E_SUCCESS: "Success",
RESTORE_E_INVALID_ARG: "Invalid argument",
- RESTORE_E_INVALID_CONF: "Invalid configuration",
RESTORE_E_PLIST_ERROR: "Property list error",
- RESTORE_E_DICT_ERROR: "Dict error",
- RESTORE_E_NOT_ENOUGH_DATA: "Not enough data",
RESTORE_E_MUX_ERROR: "MUX Error",
- RESTORE_E_START_RESTORE_FAILED: "Starting restore failed",
+ RESTORE_E_NOT_ENOUGH_DATA: "Not enough data",
+ RESTORE_E_RECEIVE_TIMEOUT: "Receive timeout",
RESTORE_E_UNKNOWN_ERROR: "Unknown error"
}
BaseError.__init__(self, *args, **kwargs)
diff --git a/cython/screenshotr.pxi b/cython/screenshotr.pxi
index 2b2d53d..a1e82e2 100644
--- a/cython/screenshotr.pxi
+++ b/cython/screenshotr.pxi
@@ -8,7 +8,9 @@ cdef extern from "libimobiledevice/screenshotr.h":
SCREENSHOTR_E_INVALID_ARG = -1
SCREENSHOTR_E_PLIST_ERROR = -2
SCREENSHOTR_E_MUX_ERROR = -3
- SCREENSHOTR_E_BAD_VERSION = -4
+ SCREENSHOTR_E_SSL_ERROR = -4
+ SCREENSHOTR_E_RECEIVE_TIMEOUT = 5
+ SCREENSHOTR_E_BAD_VERSION = -6
SCREENSHOTR_E_UNKNOWN_ERROR = -256
screenshotr_error_t screenshotr_client_new(idevice_t device, lockdownd_service_descriptor_t descriptor, screenshotr_client_t * client)
@@ -22,6 +24,8 @@ cdef class ScreenshotrError(BaseError):
SCREENSHOTR_E_INVALID_ARG: "Invalid argument",
SCREENSHOTR_E_PLIST_ERROR: "Property list error",
SCREENSHOTR_E_MUX_ERROR: "MUX error",
+ SCREENSHOTR_E_SSL_ERROR: "SSL error",
+ SCREENSHOTR_E_RECEIVE_TIMEOUT: "Receive timeout",
SCREENSHOTR_E_BAD_VERSION: "Bad version",
SCREENSHOTR_E_UNKNOWN_ERROR: "Unknown error"
}
diff --git a/cython/webinspector.pxi b/cython/webinspector.pxi
index 4622ef5..f77547d 100644
--- a/cython/webinspector.pxi
+++ b/cython/webinspector.pxi
@@ -9,6 +9,8 @@ cdef extern from "libimobiledevice/webinspector.h":
WEBINSPECTOR_E_PLIST_ERROR = -2
WEBINSPECTOR_E_MUX_ERROR = -3
WEBINSPECTOR_E_SSL_ERROR = -4
+ WEBINSPECTOR_E_RECEIVE_TIMEOUT = -5,
+ WEBINSPECTOR_E_NOT_ENOUGH_DATA = -6,
WEBINSPECTOR_E_UNKNOWN_ERROR = -256
webinspector_error_t webinspector_client_new(idevice_t device, lockdownd_service_descriptor_t descriptor, webinspector_client_t * client)
@@ -26,6 +28,8 @@ cdef class WebinspectorError(BaseError):
WEBINSPECTOR_E_PLIST_ERROR: "Property list error",
WEBINSPECTOR_E_MUX_ERROR: "MUX error",
WEBINSPECTOR_E_SSL_ERROR: "SSL Error",
+ WEBINSPECTOR_E_NOT_ENOUGH_DATA: 'Not enough data',
+ WEBINSPECTOR_E_RECEIVE_TIMEOUT: 'Connection timeout',
WEBINSPECTOR_E_UNKNOWN_ERROR: "Unknown error"
}
BaseError.__init__(self, *args, **kwargs)