diff options
| author | 2013-02-27 15:14:01 +0100 | |
|---|---|---|
| committer | 2013-02-27 15:14:01 +0100 | |
| commit | c19978863878a014b5aa2538989b41b864708866 (patch) | |
| tree | 73d40d6cbda5250972239c96b418edeb6fbbbf52 /cython | |
| parent | 0cac547eb79492e04176ad541fe6fb1d1f576824 (diff) | |
| download | libimobiledevice-c19978863878a014b5aa2538989b41b864708866.tar.gz libimobiledevice-c19978863878a014b5aa2538989b41b864708866.tar.bz2 | |
cython: Add all service protocols which brings Python bindings to 100% coverage
Diffstat (limited to 'cython')
| -rw-r--r-- | cython/Makefile.am | 7 | ||||
| -rw-r--r-- | cython/diagnostics_relay.pxi | 128 | ||||
| -rw-r--r-- | cython/heartbeat.pxi | 56 | ||||
| -rw-r--r-- | cython/house_arrest.pxi | 84 | ||||
| -rw-r--r-- | cython/imobiledevice.pyx | 7 | ||||
| -rw-r--r-- | cython/misagent.pxi | 74 | ||||
| -rw-r--r-- | cython/mobilebackup2.pxi | 114 | ||||
| -rw-r--r-- | cython/restore.pxi | 135 | ||||
| -rw-r--r-- | cython/webinspector.pxi | 56 |
9 files changed, 661 insertions, 0 deletions
diff --git a/cython/Makefile.am b/cython/Makefile.am index 64c5c1c..b5090b1 100644 --- a/cython/Makefile.am +++ b/cython/Makefile.am | |||
| @@ -13,10 +13,17 @@ PXIINCLUDES = \ | |||
| 13 | notification_proxy.pxi \ | 13 | notification_proxy.pxi \ |
| 14 | sbservices.pxi \ | 14 | sbservices.pxi \ |
| 15 | mobilebackup.pxi \ | 15 | mobilebackup.pxi \ |
| 16 | mobilebackup2.pxi \ | ||
| 16 | afc.pxi \ | 17 | afc.pxi \ |
| 17 | file_relay.pxi \ | 18 | file_relay.pxi \ |
| 18 | screenshotr.pxi \ | 19 | screenshotr.pxi \ |
| 19 | installation_proxy.pxi \ | 20 | installation_proxy.pxi \ |
| 21 | webinspector.pxi \ | ||
| 22 | heartbeat.pxi \ | ||
| 23 | diagnostics_relay.pxi \ | ||
| 24 | misagent.pxi \ | ||
| 25 | house_arrest.pxi \ | ||
| 26 | restore.pxi \ | ||
| 20 | mobile_image_mounter.pxi | 27 | mobile_image_mounter.pxi |
| 21 | 28 | ||
| 22 | CLEANFILES = \ | 29 | CLEANFILES = \ |
diff --git a/cython/diagnostics_relay.pxi b/cython/diagnostics_relay.pxi new file mode 100644 index 0000000..155e5b7 --- /dev/null +++ b/cython/diagnostics_relay.pxi | |||
| @@ -0,0 +1,128 @@ | |||
| 1 | REQUEST_TYPE_ALL = "All" | ||
| 2 | REQUEST_TYPE_WIFI = "WiFi" | ||
| 3 | REQUEST_TYPE_GAS_GAUGE = "GasGauge" | ||
| 4 | REQUEST_TYPE_NAND = "NAND" | ||
| 5 | |||
| 6 | cdef extern from "libimobiledevice/diagnostics_relay.h": | ||
| 7 | cdef struct diagnostics_relay_client_private: | ||
| 8 | pass | ||
| 9 | ctypedef diagnostics_relay_client_private *diagnostics_relay_client_t | ||
| 10 | |||
| 11 | ctypedef enum diagnostics_relay_error_t: | ||
| 12 | DIAGNOSTICS_RELAY_E_SUCCESS = 0 | ||
| 13 | DIAGNOSTICS_RELAY_E_INVALID_ARG = -1 | ||
| 14 | DIAGNOSTICS_RELAY_E_PLIST_ERROR = -2 | ||
| 15 | DIAGNOSTICS_RELAY_E_MUX_ERROR = -3 | ||
| 16 | DIAGNOSTICS_RELAY_E_UNKNOWN_REQUEST = -4 | ||
| 17 | DIAGNOSTICS_RELAY_E_UNKNOWN_ERROR = -256 | ||
| 18 | cdef enum: | ||
| 19 | DIAGNOSTICS_RELAY_ACTION_FLAG_WAIT_FOR_DISCONNECT = (1 << 1) | ||
| 20 | DIAGNOSTICS_RELAY_ACTION_FLAG_DISPLAY_PASS = (1 << 2) | ||
| 21 | DIAGNOSTICS_RELAY_ACTION_FLAG_DISPLAY_FAIL = (1 << 3) | ||
| 22 | |||
| 23 | diagnostics_relay_error_t diagnostics_relay_client_new(idevice_t device, lockdownd_service_descriptor_t descriptor, diagnostics_relay_client_t * client) | ||
| 24 | diagnostics_relay_error_t diagnostics_relay_client_free(diagnostics_relay_client_t client) | ||
| 25 | |||
| 26 | diagnostics_relay_error_t diagnostics_relay_goodbye(diagnostics_relay_client_t client) | ||
| 27 | diagnostics_relay_error_t diagnostics_relay_sleep(diagnostics_relay_client_t client) | ||
| 28 | diagnostics_relay_error_t diagnostics_relay_restart(diagnostics_relay_client_t client, int flags) | ||
| 29 | diagnostics_relay_error_t diagnostics_relay_shutdown(diagnostics_relay_client_t client, int flags) | ||
| 30 | diagnostics_relay_error_t diagnostics_relay_request_diagnostics(diagnostics_relay_client_t client, char* type, plist.plist_t* diagnostics) | ||
| 31 | diagnostics_relay_error_t diagnostics_relay_query_mobilegestalt(diagnostics_relay_client_t client, plist.plist_t keys, plist.plist_t* result) | ||
| 32 | diagnostics_relay_error_t diagnostics_relay_query_ioregistry_entry(diagnostics_relay_client_t client, char* name, char* class_name, plist.plist_t* result) | ||
| 33 | diagnostics_relay_error_t diagnostics_relay_query_ioregistry_plane(diagnostics_relay_client_t client, char* plane, plist.plist_t* result) | ||
| 34 | |||
| 35 | cdef class DiagnosticsRelayError(BaseError): | ||
| 36 | def __init__(self, *args, **kwargs): | ||
| 37 | self._lookup_table = { | ||
| 38 | DIAGNOSTICS_RELAY_E_SUCCESS: "Success", | ||
| 39 | DIAGNOSTICS_RELAY_E_INVALID_ARG: "Invalid argument", | ||
| 40 | DIAGNOSTICS_RELAY_E_PLIST_ERROR: "Property list error", | ||
| 41 | DIAGNOSTICS_RELAY_E_MUX_ERROR: "MUX error", | ||
| 42 | DIAGNOSTICS_RELAY_E_UNKNOWN_REQUEST: "Unknown request", | ||
| 43 | DIAGNOSTICS_RELAY_E_UNKNOWN_ERROR: "Unknown error" | ||
| 44 | } | ||
| 45 | BaseError.__init__(self, *args, **kwargs) | ||
| 46 | |||
| 47 | cdef class DiagnosticsRelayClient(PropertyListService): | ||
| 48 | __service_name__ = "com.apple.mobile.diagnostics_relay" | ||
| 49 | cdef diagnostics_relay_client_t _c_client | ||
| 50 | |||
| 51 | def __cinit__(self, iDevice device not None, LockdownServiceDescriptor descriptor, *args, **kwargs): | ||
| 52 | self.handle_error(diagnostics_relay_client_new(device._c_dev, descriptor._c_service_descriptor, &self._c_client)) | ||
| 53 | |||
| 54 | def __dealloc__(self): | ||
| 55 | cdef diagnostics_relay_error_t err | ||
| 56 | if self._c_client is not NULL: | ||
| 57 | err = diagnostics_relay_client_free(self._c_client) | ||
| 58 | self.handle_error(err) | ||
| 59 | |||
| 60 | cdef inline BaseError _error(self, int16_t ret): | ||
| 61 | return DiagnosticsRelayError(ret) | ||
| 62 | |||
| 63 | cpdef goodbye(self): | ||
| 64 | self.handle_error(diagnostics_relay_goodbye(self._c_client)) | ||
| 65 | |||
| 66 | cpdef sleep(self): | ||
| 67 | self.handle_error(diagnostics_relay_sleep(self._c_client)) | ||
| 68 | |||
| 69 | cpdef restart(self, int flags): | ||
| 70 | self.handle_error(diagnostics_relay_restart(self._c_client, flags)) | ||
| 71 | |||
| 72 | cpdef shutdown(self, int flags): | ||
| 73 | self.handle_error(diagnostics_relay_shutdown(self._c_client, flags)) | ||
| 74 | |||
| 75 | cpdef plist.Node request_diagnostics(self, bytes type): | ||
| 76 | cdef: | ||
| 77 | plist.plist_t c_node = NULL | ||
| 78 | diagnostics_relay_error_t err | ||
| 79 | err = diagnostics_relay_request_diagnostics(self._c_client, type, &c_node) | ||
| 80 | try: | ||
| 81 | self.handle_error(err) | ||
| 82 | return plist.plist_t_to_node(c_node) | ||
| 83 | except BaseError, e: | ||
| 84 | if c_node != NULL: | ||
| 85 | plist.plist_free(c_node) | ||
| 86 | raise | ||
| 87 | |||
| 88 | cpdef plist.Node query_mobilegestalt(self, plist.Node keys = None): | ||
| 89 | cdef: | ||
| 90 | plist.plist_t c_node = NULL | ||
| 91 | diagnostics_relay_error_t err | ||
| 92 | plist.plist_t keys_c_node = NULL | ||
| 93 | if keys is not None: | ||
| 94 | keys_c_node = keys._c_node | ||
| 95 | err = diagnostics_relay_query_mobilegestalt(self._c_client, keys_c_node, &c_node) | ||
| 96 | try: | ||
| 97 | self.handle_error(err) | ||
| 98 | return plist.plist_t_to_node(c_node) | ||
| 99 | except BaseError, e: | ||
| 100 | if c_node != NULL: | ||
| 101 | plist.plist_free(c_node) | ||
| 102 | raise | ||
| 103 | |||
| 104 | cpdef plist.Node query_ioregistry_entry(self, bytes name, bytes class_name): | ||
| 105 | cdef: | ||
| 106 | plist.plist_t c_node = NULL | ||
| 107 | diagnostics_relay_error_t err | ||
| 108 | err = diagnostics_relay_query_ioregistry_entry(self._c_client, name, class_name, &c_node) | ||
| 109 | try: | ||
| 110 | self.handle_error(err) | ||
| 111 | return plist.plist_t_to_node(c_node) | ||
| 112 | except BaseError, e: | ||
| 113 | if c_node != NULL: | ||
| 114 | plist.plist_free(c_node) | ||
| 115 | raise | ||
| 116 | |||
| 117 | cpdef plist.Node query_ioregistry_plane(self, bytes plane = None): | ||
| 118 | cdef: | ||
| 119 | plist.plist_t c_node = NULL | ||
| 120 | diagnostics_relay_error_t err | ||
| 121 | err = diagnostics_relay_query_ioregistry_plane(self._c_client, plane, &c_node) | ||
| 122 | try: | ||
| 123 | self.handle_error(err) | ||
| 124 | return plist.plist_t_to_node(c_node) | ||
| 125 | except BaseError, e: | ||
| 126 | if c_node != NULL: | ||
| 127 | plist.plist_free(c_node) | ||
| 128 | raise | ||
diff --git a/cython/heartbeat.pxi b/cython/heartbeat.pxi new file mode 100644 index 0000000..b48fb59 --- /dev/null +++ b/cython/heartbeat.pxi | |||
| @@ -0,0 +1,56 @@ | |||
| 1 | cdef extern from "libimobiledevice/heartbeat.h": | ||
| 2 | cdef struct heartbeat_client_private: | ||
| 3 | pass | ||
| 4 | ctypedef heartbeat_client_private *heartbeat_client_t | ||
| 5 | |||
| 6 | ctypedef enum heartbeat_error_t: | ||
| 7 | HEARTBEAT_E_SUCCESS = 0 | ||
| 8 | HEARTBEAT_E_INVALID_ARG = -1 | ||
| 9 | HEARTBEAT_E_PLIST_ERROR = -2 | ||
| 10 | HEARTBEAT_E_MUX_ERROR = -3 | ||
| 11 | HEARTBEAT_E_SSL_ERROR = -4 | ||
| 12 | HEARTBEAT_E_UNKNOWN_ERROR = -256 | ||
| 13 | |||
| 14 | heartbeat_error_t heartbeat_client_new(idevice_t device, lockdownd_service_descriptor_t descriptor, heartbeat_client_t * client) | ||
| 15 | heartbeat_error_t heartbeat_client_free(heartbeat_client_t client) | ||
| 16 | |||
| 17 | heartbeat_error_t heartbeat_send(heartbeat_client_t client, plist.plist_t plist) | ||
| 18 | heartbeat_error_t heartbeat_receive(heartbeat_client_t client, plist.plist_t * plist) | ||
| 19 | heartbeat_error_t heartbeat_receive_with_timeout(heartbeat_client_t client, plist.plist_t * plist, uint32_t timeout_ms) | ||
| 20 | |||
| 21 | cdef class HeartbeatError(BaseError): | ||
| 22 | def __init__(self, *args, **kwargs): | ||
| 23 | self._lookup_table = { | ||
| 24 | HEARTBEAT_E_SUCCESS: "Success", | ||
| 25 | HEARTBEAT_E_INVALID_ARG: "Invalid argument", | ||
| 26 | HEARTBEAT_E_PLIST_ERROR: "Property list error", | ||
| 27 | HEARTBEAT_E_MUX_ERROR: "MUX error", | ||
| 28 | HEARTBEAT_E_SSL_ERROR: "SSL Error", | ||
| 29 | HEARTBEAT_E_UNKNOWN_ERROR: "Unknown error" | ||
| 30 | } | ||
| 31 | BaseError.__init__(self, *args, **kwargs) | ||
| 32 | |||
| 33 | cdef class HeartbeatClient(PropertyListService): | ||
| 34 | __service_name__ = "com.apple.heartbeat" | ||
| 35 | cdef heartbeat_client_t _c_client | ||
| 36 | |||
| 37 | def __cinit__(self, iDevice device not None, LockdownServiceDescriptor descriptor, *args, **kwargs): | ||
| 38 | self.handle_error(heartbeat_client_new(device._c_dev, descriptor._c_service_descriptor, &self._c_client)) | ||
| 39 | |||
| 40 | def __dealloc__(self): | ||
| 41 | cdef heartbeat_error_t err | ||
| 42 | if self._c_client is not NULL: | ||
| 43 | err = heartbeat_client_free(self._c_client) | ||
| 44 | self.handle_error(err) | ||
| 45 | |||
| 46 | cdef inline int16_t _send(self, plist.plist_t node): | ||
| 47 | return heartbeat_send(self._c_client, node) | ||
| 48 | |||
| 49 | cdef inline int16_t _receive(self, plist.plist_t* node): | ||
| 50 | return heartbeat_receive(self._c_client, node) | ||
| 51 | |||
| 52 | cdef inline int16_t _receive_with_timeout(self, plist.plist_t* node, int timeout_ms): | ||
| 53 | return heartbeat_receive_with_timeout(self._c_client, node, timeout_ms) | ||
| 54 | |||
| 55 | cdef inline BaseError _error(self, int16_t ret): | ||
| 56 | return HeartbeatError(ret) | ||
diff --git a/cython/house_arrest.pxi b/cython/house_arrest.pxi new file mode 100644 index 0000000..2a81213 --- /dev/null +++ b/cython/house_arrest.pxi | |||
| @@ -0,0 +1,84 @@ | |||
| 1 | cdef extern from "libimobiledevice/house_arrest.h": | ||
| 2 | cdef struct house_arrest_client_private: | ||
| 3 | pass | ||
| 4 | ctypedef house_arrest_client_private *house_arrest_client_t | ||
| 5 | |||
| 6 | ctypedef enum house_arrest_error_t: | ||
| 7 | HOUSE_ARREST_E_SUCCESS = 0 | ||
| 8 | HOUSE_ARREST_E_INVALID_ARG = -1 | ||
| 9 | HOUSE_ARREST_E_PLIST_ERROR = -2 | ||
| 10 | HOUSE_ARREST_E_CONN_FAILED = -3 | ||
| 11 | HOUSE_ARREST_E_INVALID_MODE = -4 | ||
| 12 | HOUSE_ARREST_E_UNKNOWN_ERROR = -256 | ||
| 13 | |||
| 14 | house_arrest_error_t house_arrest_client_new(idevice_t device, lockdownd_service_descriptor_t descriptor, house_arrest_client_t * client) | ||
| 15 | house_arrest_error_t house_arrest_client_free(house_arrest_client_t client) | ||
| 16 | |||
| 17 | house_arrest_error_t house_arrest_send_request(house_arrest_client_t client, plist.plist_t dict) | ||
| 18 | house_arrest_error_t house_arrest_send_command(house_arrest_client_t client, char *command, char *appid) | ||
| 19 | house_arrest_error_t house_arrest_get_result(house_arrest_client_t client, plist.plist_t *dict) | ||
| 20 | |||
| 21 | afc_error_t afc_client_new_from_house_arrest_client(house_arrest_client_t client, afc_client_t *afc_client) | ||
| 22 | |||
| 23 | cdef class HouseArrestError(BaseError): | ||
| 24 | def __init__(self, *args, **kwargs): | ||
| 25 | self._lookup_table = { | ||
| 26 | HOUSE_ARREST_E_SUCCESS: "Success", | ||
| 27 | HOUSE_ARREST_E_INVALID_ARG: "Invalid argument", | ||
| 28 | HOUSE_ARREST_E_PLIST_ERROR: "Property list error", | ||
| 29 | HOUSE_ARREST_E_CONN_FAILED: "Connection failed", | ||
| 30 | HOUSE_ARREST_E_INVALID_MODE: "Invalid mode", | ||
| 31 | HOUSE_ARREST_E_UNKNOWN_ERROR: "Unknown error" | ||
| 32 | } | ||
| 33 | BaseError.__init__(self, *args, **kwargs) | ||
| 34 | |||
| 35 | cdef class HouseArrestClient(PropertyListService): | ||
| 36 | __service_name__ = "com.apple.mobile.house_arrest" | ||
| 37 | cdef house_arrest_client_t _c_client | ||
| 38 | |||
| 39 | def __cinit__(self, iDevice device not None, LockdownServiceDescriptor descriptor, *args, **kwargs): | ||
| 40 | self.handle_error(house_arrest_client_new(device._c_dev, descriptor._c_service_descriptor, &self._c_client)) | ||
| 41 | |||
| 42 | def __dealloc__(self): | ||
| 43 | cdef house_arrest_error_t err | ||
| 44 | if self._c_client is not NULL: | ||
| 45 | err = house_arrest_client_free(self._c_client) | ||
| 46 | self.handle_error(err) | ||
| 47 | |||
| 48 | cdef inline BaseError _error(self, int16_t ret): | ||
| 49 | return HouseArrestError(ret) | ||
| 50 | |||
| 51 | cdef send_request(self, plist.Node message): | ||
| 52 | self.handle_error(house_arrest_send_request(self._c_client, message._c_node)) | ||
| 53 | |||
| 54 | cdef send_command(self, bytes command, bytes appid): | ||
| 55 | self.handle_error(house_arrest_send_command(self._c_client, command, appid)) | ||
| 56 | |||
| 57 | cpdef plist.Node get_result(self): | ||
| 58 | cdef: | ||
| 59 | plist.plist_t c_node = NULL | ||
| 60 | house_arrest_error_t err | ||
| 61 | err = house_arrest_get_result(self._c_client, &c_node) | ||
| 62 | try: | ||
| 63 | self.handle_error(err) | ||
| 64 | return plist.plist_t_to_node(c_node) | ||
| 65 | except BaseError, e: | ||
| 66 | if c_node != NULL: | ||
| 67 | plist.plist_free(c_node) | ||
| 68 | raise | ||
| 69 | |||
| 70 | cpdef AfcClient to_afc_client(self): | ||
| 71 | cdef: | ||
| 72 | afc_client_t c_afc_client = NULL | ||
| 73 | AfcClient result | ||
| 74 | afc_error_t err | ||
| 75 | err = afc_client_new_from_house_arrest_client(self._c_client, &c_afc_client) | ||
| 76 | try: | ||
| 77 | result = AfcClient.__new__(AfcClient) | ||
| 78 | result._c_client = c_afc_client | ||
| 79 | result.handle_error(err) | ||
| 80 | return result | ||
| 81 | except BaseError, e: | ||
| 82 | if c_afc_client != NULL: | ||
| 83 | afc_client_free(c_afc_client); | ||
| 84 | raise | ||
diff --git a/cython/imobiledevice.pyx b/cython/imobiledevice.pyx index de59456..fa5e7ae 100644 --- a/cython/imobiledevice.pyx +++ b/cython/imobiledevice.pyx | |||
| @@ -241,8 +241,15 @@ include "mobilesync.pxi" | |||
| 241 | include "notification_proxy.pxi" | 241 | include "notification_proxy.pxi" |
| 242 | include "sbservices.pxi" | 242 | include "sbservices.pxi" |
| 243 | include "mobilebackup.pxi" | 243 | include "mobilebackup.pxi" |
| 244 | include "mobilebackup2.pxi" | ||
| 244 | include "afc.pxi" | 245 | include "afc.pxi" |
| 245 | include "file_relay.pxi" | 246 | include "file_relay.pxi" |
| 246 | include "screenshotr.pxi" | 247 | include "screenshotr.pxi" |
| 247 | include "installation_proxy.pxi" | 248 | include "installation_proxy.pxi" |
| 248 | include "mobile_image_mounter.pxi" | 249 | include "mobile_image_mounter.pxi" |
| 250 | include "webinspector.pxi" | ||
| 251 | include "heartbeat.pxi" | ||
| 252 | include "diagnostics_relay.pxi" | ||
| 253 | include "misagent.pxi" | ||
| 254 | include "house_arrest.pxi" | ||
| 255 | include "restore.pxi" | ||
diff --git a/cython/misagent.pxi b/cython/misagent.pxi new file mode 100644 index 0000000..1fee4b9 --- /dev/null +++ b/cython/misagent.pxi | |||
| @@ -0,0 +1,74 @@ | |||
| 1 | cdef extern from "libimobiledevice/misagent.h": | ||
| 2 | cdef struct misagent_client_private: | ||
| 3 | pass | ||
| 4 | ctypedef misagent_client_private *misagent_client_t | ||
| 5 | |||
| 6 | ctypedef enum misagent_error_t: | ||
| 7 | MISAGENT_E_SUCCESS = 0 | ||
| 8 | MISAGENT_E_INVALID_ARG = -1 | ||
| 9 | MISAGENT_E_PLIST_ERROR = -2 | ||
| 10 | MISAGENT_E_CONN_FAILED = -3 | ||
| 11 | MISAGENT_E_REQUEST_FAILED = -4 | ||
| 12 | MISAGENT_E_UNKNOWN_ERROR = -256 | ||
| 13 | |||
| 14 | misagent_error_t misagent_client_new(idevice_t device, lockdownd_service_descriptor_t descriptor, misagent_client_t * client) | ||
| 15 | misagent_error_t misagent_client_free(misagent_client_t client) | ||
| 16 | |||
| 17 | misagent_error_t misagent_install(misagent_client_t client, plist.plist_t profile) | ||
| 18 | misagent_error_t misagent_copy(misagent_client_t client, plist.plist_t* profiles) | ||
| 19 | misagent_error_t misagent_remove(misagent_client_t client, char* profileID) | ||
| 20 | int misagent_get_status_code(misagent_client_t client) | ||
| 21 | |||
| 22 | cdef class MisagentError(BaseError): | ||
| 23 | def __init__(self, *args, **kwargs): | ||
| 24 | self._lookup_table = { | ||
| 25 | MISAGENT_E_SUCCESS: "Success", | ||
| 26 | MISAGENT_E_INVALID_ARG: "Invalid argument", | ||
| 27 | MISAGENT_E_PLIST_ERROR: "Property list error", | ||
| 28 | MISAGENT_E_CONN_FAILED: "Connection failed", | ||
| 29 | MISAGENT_E_REQUEST_FAILED: "Request failed", | ||
| 30 | MISAGENT_E_UNKNOWN_ERROR: "Unknown error" | ||
| 31 | } | ||
| 32 | BaseError.__init__(self, *args, **kwargs) | ||
| 33 | |||
| 34 | cdef class MisagentClient(PropertyListService): | ||
| 35 | __service_name__ = "com.apple.misagent" | ||
| 36 | cdef misagent_client_t _c_client | ||
| 37 | |||
| 38 | def __cinit__(self, iDevice device not None, LockdownServiceDescriptor descriptor, *args, **kwargs): | ||
| 39 | self.handle_error(misagent_client_new(device._c_dev, descriptor._c_service_descriptor, &self._c_client)) | ||
| 40 | |||
| 41 | def __dealloc__(self): | ||
| 42 | cdef misagent_error_t err | ||
| 43 | if self._c_client is not NULL: | ||
| 44 | err = misagent_client_free(self._c_client) | ||
| 45 | self.handle_error(err) | ||
| 46 | |||
| 47 | cdef inline BaseError _error(self, int16_t ret): | ||
| 48 | return MisagentError(ret) | ||
| 49 | |||
| 50 | cpdef install(self, plist.Node profile): | ||
| 51 | cdef misagent_error_t err | ||
| 52 | err = misagent_install(self._c_client, profile._c_node) | ||
| 53 | self.handle_error(err) | ||
| 54 | |||
| 55 | cpdef plist.Node copy(self): | ||
| 56 | cdef: | ||
| 57 | plist.plist_t c_node = NULL | ||
| 58 | misagent_error_t err | ||
| 59 | err = misagent_copy(self._c_client, &c_node) | ||
| 60 | try: | ||
| 61 | self.handle_error(err) | ||
| 62 | return plist.plist_t_to_node(c_node) | ||
| 63 | except BaseError, e: | ||
| 64 | if c_node != NULL: | ||
| 65 | plist.plist_free(c_node) | ||
| 66 | raise | ||
| 67 | |||
| 68 | cpdef remove(self, bytes profile_id): | ||
| 69 | cdef misagent_error_t err | ||
| 70 | err = misagent_remove(self._c_client, profile_id) | ||
| 71 | self.handle_error(err) | ||
| 72 | |||
| 73 | cpdef int get_status_code(self): | ||
| 74 | return misagent_get_status_code(self._c_client) | ||
diff --git a/cython/mobilebackup2.pxi b/cython/mobilebackup2.pxi new file mode 100644 index 0000000..aac5358 --- /dev/null +++ b/cython/mobilebackup2.pxi | |||
| @@ -0,0 +1,114 @@ | |||
| 1 | cdef extern from "libimobiledevice/mobilebackup2.h": | ||
| 2 | cdef struct mobilebackup2_client_private: | ||
| 3 | pass | ||
| 4 | ctypedef mobilebackup2_client_private *mobilebackup2_client_t | ||
| 5 | |||
| 6 | ctypedef enum mobilebackup2_error_t: | ||
| 7 | MOBILEBACKUP2_E_SUCCESS = 0 | ||
| 8 | MOBILEBACKUP2_E_INVALID_ARG = -1 | ||
| 9 | MOBILEBACKUP2_E_PLIST_ERROR = -2 | ||
| 10 | MOBILEBACKUP2_E_MUX_ERROR = -3 | ||
| 11 | MOBILEBACKUP2_E_BAD_VERSION = -4 | ||
| 12 | MOBILEBACKUP2_E_REPLY_NOT_OK = -5 | ||
| 13 | MOBILEBACKUP2_E_NO_COMMON_VERSION = -6 | ||
| 14 | MOBILEBACKUP2_E_UNKNOWN_ERROR = -256 | ||
| 15 | |||
| 16 | mobilebackup2_error_t mobilebackup2_client_new(idevice_t device, lockdownd_service_descriptor_t descriptor, mobilebackup2_client_t * client) | ||
| 17 | mobilebackup2_error_t mobilebackup2_client_free(mobilebackup2_client_t client) | ||
| 18 | |||
| 19 | mobilebackup2_error_t mobilebackup2_send_message(mobilebackup2_client_t client, char *message, plist.plist_t options) | ||
| 20 | mobilebackup2_error_t mobilebackup2_receive_message(mobilebackup2_client_t client, plist.plist_t *msg_plist, char **dlmessage) | ||
| 21 | mobilebackup2_error_t mobilebackup2_send_raw(mobilebackup2_client_t client, char *data, uint32_t length, uint32_t *bytes) | ||
| 22 | mobilebackup2_error_t mobilebackup2_receive_raw(mobilebackup2_client_t client, char *data, uint32_t length, uint32_t *bytes) | ||
| 23 | mobilebackup2_error_t mobilebackup2_version_exchange(mobilebackup2_client_t client, double local_versions[], char count, double *remote_version) | ||
| 24 | mobilebackup2_error_t mobilebackup2_send_request(mobilebackup2_client_t client, char *request, char *target_identifier, char *source_identifier, plist.plist_t options) | ||
| 25 | mobilebackup2_error_t mobilebackup2_send_status_response(mobilebackup2_client_t client, int status_code, char *status1, plist.plist_t status2) | ||
| 26 | |||
| 27 | cdef class MobileBackup2Error(BaseError): | ||
| 28 | def __init__(self, *args, **kwargs): | ||
| 29 | self._lookup_table = { | ||
| 30 | MOBILEBACKUP2_E_SUCCESS: "Success", | ||
| 31 | MOBILEBACKUP2_E_INVALID_ARG: "Invalid argument", | ||
| 32 | MOBILEBACKUP2_E_PLIST_ERROR: "Property list error", | ||
| 33 | MOBILEBACKUP2_E_MUX_ERROR: "MUX error", | ||
| 34 | MOBILEBACKUP2_E_BAD_VERSION: "Bad version", | ||
| 35 | MOBILEBACKUP2_E_REPLY_NOT_OK: "Reply not OK", | ||
| 36 | MOBILEBACKUP2_E_NO_COMMON_VERSION: "No common version", | ||
| 37 | MOBILEBACKUP2_E_UNKNOWN_ERROR: "Unknown error" | ||
| 38 | } | ||
| 39 | BaseError.__init__(self, *args, **kwargs) | ||
| 40 | |||
| 41 | cdef class MobileBackup2Client(PropertyListService): | ||
| 42 | __service_name__ = "com.apple.mobilebackup2" | ||
| 43 | cdef mobilebackup2_client_t _c_client | ||
| 44 | |||
| 45 | def __cinit__(self, iDevice device not None, LockdownServiceDescriptor descriptor, *args, **kwargs): | ||
| 46 | self.handle_error(mobilebackup2_client_new(device._c_dev, descriptor._c_service_descriptor, &self._c_client)) | ||
| 47 | |||
| 48 | def __dealloc__(self): | ||
| 49 | cdef mobilebackup2_error_t err | ||
| 50 | if self._c_client is not NULL: | ||
| 51 | err = mobilebackup2_client_free(self._c_client) | ||
| 52 | self.handle_error(err) | ||
| 53 | |||
| 54 | cdef inline BaseError _error(self, int16_t ret): | ||
| 55 | return MobileBackup2Error(ret) | ||
| 56 | |||
| 57 | cdef send_message(self, bytes message, plist.Node options): | ||
| 58 | self.handle_error(mobilebackup2_send_message(self._c_client, message, options._c_node)) | ||
| 59 | |||
| 60 | cdef tuple receive_message(self): | ||
| 61 | cdef: | ||
| 62 | char* dlmessage = NULL | ||
| 63 | plist.plist_t c_node = NULL | ||
| 64 | mobilebackup2_error_t err | ||
| 65 | err = mobilebackup2_receive_message(self._c_client, &c_node, &dlmessage) | ||
| 66 | try: | ||
| 67 | self.handle_error(err) | ||
| 68 | return (plist.plist_t_to_node(c_node), <bytes>dlmessage) | ||
| 69 | except BaseError, e: | ||
| 70 | if c_node != NULL: | ||
| 71 | plist.plist_free(c_node) | ||
| 72 | if dlmessage != NULL: | ||
| 73 | free(dlmessage) | ||
| 74 | raise | ||
| 75 | |||
| 76 | cdef int send_raw(self, bytes data, int length): | ||
| 77 | cdef: | ||
| 78 | uint32_t bytes = 0 | ||
| 79 | mobilebackup2_error_t err | ||
| 80 | err = mobilebackup2_send_raw(self._c_client, data, length, &bytes) | ||
| 81 | try: | ||
| 82 | self.handle_error(err) | ||
| 83 | return <bint>bytes | ||
| 84 | except BaseError, e: | ||
| 85 | raise | ||
| 86 | |||
| 87 | cdef int receive_raw(self, bytes data, int length): | ||
| 88 | cdef: | ||
| 89 | uint32_t bytes = 0 | ||
| 90 | mobilebackup2_error_t err | ||
| 91 | err = mobilebackup2_receive_raw(self._c_client, data, length, &bytes) | ||
| 92 | try: | ||
| 93 | self.handle_error(err) | ||
| 94 | return <bint>bytes | ||
| 95 | except BaseError, e: | ||
| 96 | raise | ||
| 97 | |||
| 98 | cdef float version_exchange(self, double[::1] local_versions): | ||
| 99 | cdef: | ||
| 100 | double[::1] temp = None | ||
| 101 | double remote_version = 0.0 | ||
| 102 | mobilebackup2_error_t err | ||
| 103 | err = mobilebackup2_version_exchange(self._c_client, &local_versions[0], len(local_versions), &remote_version) | ||
| 104 | try: | ||
| 105 | self.handle_error(err) | ||
| 106 | return <float>remote_version | ||
| 107 | except BaseError, e: | ||
| 108 | raise | ||
| 109 | |||
| 110 | cdef send_request(self, bytes request, bytes target_identifier, bytes source_identifier, plist.Node options): | ||
| 111 | self.handle_error(mobilebackup2_send_request(self._c_client, request, target_identifier, source_identifier, options._c_node)) | ||
| 112 | |||
| 113 | cdef send_status_response(self, int status_code, bytes status1, plist.Node status2): | ||
| 114 | self.handle_error(mobilebackup2_send_status_response(self._c_client, status_code, status1, status2._c_node)) | ||
diff --git a/cython/restore.pxi b/cython/restore.pxi new file mode 100644 index 0000000..7d3d80e --- /dev/null +++ b/cython/restore.pxi | |||
| @@ -0,0 +1,135 @@ | |||
| 1 | cdef extern from "libimobiledevice/restore.h": | ||
| 2 | cdef struct restored_client_private: | ||
| 3 | pass | ||
| 4 | ctypedef restored_client_private *restored_client_t | ||
| 5 | |||
| 6 | ctypedef enum restored_error_t: | ||
| 7 | RESTORE_E_SUCCESS = 0 | ||
| 8 | RESTORE_E_INVALID_ARG = -1 | ||
| 9 | RESTORE_E_INVALID_CONF = -2 | ||
| 10 | RESTORE_E_PLIST_ERROR = -3 | ||
| 11 | RESTORE_E_DICT_ERROR = -4 | ||
| 12 | RESTORE_E_NOT_ENOUGH_DATA = -5 | ||
| 13 | RESTORE_E_MUX_ERROR = -6 | ||
| 14 | RESTORE_E_START_RESTORE_FAILED = -7 | ||
| 15 | RESTORE_E_UNKNOWN_ERROR = -256 | ||
| 16 | |||
| 17 | restored_error_t restored_client_new(idevice_t device, restored_client_t *client, char *label) | ||
| 18 | restored_error_t restored_client_free(restored_client_t client) | ||
| 19 | |||
| 20 | restored_error_t restored_query_type(restored_client_t client, char **tp, uint64_t *version) | ||
| 21 | restored_error_t restored_query_value(restored_client_t client, char *key, plist.plist_t *value) | ||
| 22 | restored_error_t restored_get_value(restored_client_t client, char *key, plist.plist_t *value) | ||
| 23 | restored_error_t restored_send(restored_client_t client, plist.plist_t plist) | ||
| 24 | restored_error_t restored_receive(restored_client_t client, plist.plist_t *plist) | ||
| 25 | restored_error_t restored_goodbye(restored_client_t client) | ||
| 26 | |||
| 27 | restored_error_t restored_start_restore(restored_client_t client, plist.plist_t options, uint64_t version) | ||
| 28 | restored_error_t restored_reboot(restored_client_t client) | ||
| 29 | |||
| 30 | void restored_client_set_label(restored_client_t client, char *label) | ||
| 31 | |||
| 32 | cdef class RestoreError(BaseError): | ||
| 33 | def __init__(self, *args, **kwargs): | ||
| 34 | self._lookup_table = { | ||
| 35 | RESTORE_E_SUCCESS: "Success", | ||
| 36 | RESTORE_E_INVALID_ARG: "Invalid argument", | ||
| 37 | RESTORE_E_INVALID_CONF: "Invalid configuration", | ||
| 38 | RESTORE_E_PLIST_ERROR: "Property list error", | ||
| 39 | RESTORE_E_DICT_ERROR: "Dict error", | ||
| 40 | RESTORE_E_NOT_ENOUGH_DATA: "Not enough data", | ||
| 41 | RESTORE_E_MUX_ERROR: "MUX Error", | ||
| 42 | RESTORE_E_START_RESTORE_FAILED: "Starting restore failed", | ||
| 43 | RESTORE_E_UNKNOWN_ERROR: "Unknown error" | ||
| 44 | } | ||
| 45 | BaseError.__init__(self, *args, **kwargs) | ||
| 46 | |||
| 47 | cdef class RestoreClient(PropertyListService): | ||
| 48 | cdef restored_client_t _c_client | ||
| 49 | |||
| 50 | def __cinit__(self, iDevice device not None, bytes label=b'', *args, **kwargs): | ||
| 51 | cdef: | ||
| 52 | restored_error_t err | ||
| 53 | char* c_label = NULL | ||
| 54 | if label: | ||
| 55 | c_label = label | ||
| 56 | err = restored_client_new(device._c_dev, &self._c_client, c_label) | ||
| 57 | self.handle_error(err) | ||
| 58 | |||
| 59 | self.device = device | ||
| 60 | |||
| 61 | def __dealloc__(self): | ||
| 62 | cdef restored_error_t err | ||
| 63 | if self._c_client is not NULL: | ||
| 64 | err = restored_client_free(self._c_client) | ||
| 65 | self.handle_error(err) | ||
| 66 | |||
| 67 | cdef inline BaseError _error(self, int16_t ret): | ||
| 68 | return RestoreError(ret) | ||
| 69 | |||
| 70 | cdef inline int16_t _send(self, plist.plist_t node): | ||
| 71 | return restored_send(self._c_client, node) | ||
| 72 | |||
| 73 | cdef inline int16_t _receive(self, plist.plist_t* node): | ||
| 74 | return restored_receive(self._c_client, node) | ||
| 75 | |||
| 76 | cpdef tuple query_type(self): | ||
| 77 | cdef: | ||
| 78 | restored_error_t err | ||
| 79 | char* c_type = NULL | ||
| 80 | uint64_t c_version = 0 | ||
| 81 | tuple result | ||
| 82 | err = restored_query_type(self._c_client, &c_type, &c_version) | ||
| 83 | try: | ||
| 84 | self.handle_error(err) | ||
| 85 | result = (c_type, c_version) | ||
| 86 | return result | ||
| 87 | except BaseError, e: | ||
| 88 | raise | ||
| 89 | finally: | ||
| 90 | if c_type != NULL: | ||
| 91 | free(c_type) | ||
| 92 | |||
| 93 | cpdef plist.Node query_value(self, bytes key=None): | ||
| 94 | cdef: | ||
| 95 | restored_error_t err | ||
| 96 | plist.plist_t c_node = NULL | ||
| 97 | char* c_key = NULL | ||
| 98 | if key is not None: | ||
| 99 | c_key = key | ||
| 100 | err = restored_query_value(self._c_client, c_key, &c_node) | ||
| 101 | try: | ||
| 102 | self.handle_error(err) | ||
| 103 | return plist.plist_t_to_node(c_node) | ||
| 104 | except BaseError, e: | ||
| 105 | if c_node != NULL: | ||
| 106 | plist.plist_free(c_node) | ||
| 107 | raise | ||
| 108 | |||
| 109 | cpdef plist.Node get_value(self, bytes key=None): | ||
| 110 | cdef: | ||
| 111 | restored_error_t err | ||
| 112 | plist.plist_t c_node = NULL | ||
| 113 | char* c_key = NULL | ||
| 114 | if key is not None: | ||
| 115 | c_key = key | ||
| 116 | err = restored_get_value(self._c_client, c_key, &c_node) | ||
| 117 | try: | ||
| 118 | self.handle_error(err) | ||
| 119 | return plist.plist_t_to_node(c_node) | ||
| 120 | except BaseError, e: | ||
| 121 | if c_node != NULL: | ||
| 122 | plist.plist_free(c_node) | ||
| 123 | raise | ||
| 124 | |||
| 125 | cpdef goodbye(self): | ||
| 126 | self.handle_error(restored_goodbye(self._c_client)) | ||
| 127 | |||
| 128 | cpdef start_restore(self, plist.Node options, uint64_t version): | ||
| 129 | self.handle_error(restored_start_restore(self._c_client, options._c_node, version)) | ||
| 130 | |||
| 131 | cpdef reboot(self): | ||
| 132 | self.handle_error(restored_reboot(self._c_client)) | ||
| 133 | |||
| 134 | cpdef set_label(self, bytes label): | ||
| 135 | restored_client_set_label(self._c_client, label) | ||
diff --git a/cython/webinspector.pxi b/cython/webinspector.pxi new file mode 100644 index 0000000..4622ef5 --- /dev/null +++ b/cython/webinspector.pxi | |||
| @@ -0,0 +1,56 @@ | |||
| 1 | cdef extern from "libimobiledevice/webinspector.h": | ||
| 2 | cdef struct webinspector_client_private: | ||
| 3 | pass | ||
| 4 | ctypedef webinspector_client_private *webinspector_client_t | ||
| 5 | |||
| 6 | ctypedef enum webinspector_error_t: | ||
| 7 | WEBINSPECTOR_E_SUCCESS = 0 | ||
| 8 | WEBINSPECTOR_E_INVALID_ARG = -1 | ||
| 9 | WEBINSPECTOR_E_PLIST_ERROR = -2 | ||
| 10 | WEBINSPECTOR_E_MUX_ERROR = -3 | ||
| 11 | WEBINSPECTOR_E_SSL_ERROR = -4 | ||
| 12 | WEBINSPECTOR_E_UNKNOWN_ERROR = -256 | ||
| 13 | |||
| 14 | webinspector_error_t webinspector_client_new(idevice_t device, lockdownd_service_descriptor_t descriptor, webinspector_client_t * client) | ||
| 15 | webinspector_error_t webinspector_client_free(webinspector_client_t client) | ||
| 16 | |||
| 17 | webinspector_error_t webinspector_send(webinspector_client_t client, plist.plist_t plist) | ||
| 18 | webinspector_error_t webinspector_receive(webinspector_client_t client, plist.plist_t * plist) | ||
| 19 | webinspector_error_t webinspector_receive_with_timeout(webinspector_client_t client, plist.plist_t * plist, uint32_t timeout_ms) | ||
| 20 | |||
| 21 | cdef class WebinspectorError(BaseError): | ||
| 22 | def __init__(self, *args, **kwargs): | ||
| 23 | self._lookup_table = { | ||
| 24 | WEBINSPECTOR_E_SUCCESS: "Success", | ||
| 25 | WEBINSPECTOR_E_INVALID_ARG: "Invalid argument", | ||
| 26 | WEBINSPECTOR_E_PLIST_ERROR: "Property list error", | ||
| 27 | WEBINSPECTOR_E_MUX_ERROR: "MUX error", | ||
| 28 | WEBINSPECTOR_E_SSL_ERROR: "SSL Error", | ||
| 29 | WEBINSPECTOR_E_UNKNOWN_ERROR: "Unknown error" | ||
| 30 | } | ||
| 31 | BaseError.__init__(self, *args, **kwargs) | ||
| 32 | |||
| 33 | cdef class WebinspectorClient(PropertyListService): | ||
| 34 | __service_name__ = "com.apple.webinspector" | ||
| 35 | cdef webinspector_client_t _c_client | ||
| 36 | |||
| 37 | def __cinit__(self, iDevice device not None, LockdownServiceDescriptor descriptor, *args, **kwargs): | ||
| 38 | self.handle_error(webinspector_client_new(device._c_dev, descriptor._c_service_descriptor, &self._c_client)) | ||
| 39 | |||
| 40 | def __dealloc__(self): | ||
| 41 | cdef webinspector_error_t err | ||
| 42 | if self._c_client is not NULL: | ||
| 43 | err = webinspector_client_free(self._c_client) | ||
| 44 | self.handle_error(err) | ||
| 45 | |||
| 46 | cdef inline int16_t _send(self, plist.plist_t node): | ||
| 47 | return webinspector_send(self._c_client, node) | ||
| 48 | |||
| 49 | cdef inline int16_t _receive(self, plist.plist_t* node): | ||
| 50 | return webinspector_receive(self._c_client, node) | ||
| 51 | |||
| 52 | cdef inline int16_t _receive_with_timeout(self, plist.plist_t* node, int timeout_ms): | ||
| 53 | return webinspector_receive_with_timeout(self._c_client, node, timeout_ms) | ||
| 54 | |||
| 55 | cdef inline BaseError _error(self, int16_t ret): | ||
| 56 | return WebinspectorError(ret) | ||
