diff options
Diffstat (limited to 'cython')
| -rw-r--r-- | cython/Makefile.am | 1 | ||||
| -rw-r--r-- | cython/afc.pxi | 155 | ||||
| -rw-r--r-- | cython/file_relay.pxi | 11 | ||||
| -rw-r--r-- | cython/imobiledevice.pxd | 39 | ||||
| -rw-r--r-- | cython/imobiledevice.pyx | 117 | ||||
| -rw-r--r-- | cython/installation_proxy.pxi | 9 | ||||
| -rw-r--r-- | cython/lockdown.pxi | 254 | ||||
| -rw-r--r-- | cython/mobile_image_mounter.pxi | 11 | ||||
| -rw-r--r-- | cython/mobilebackup.pxi | 11 | ||||
| -rw-r--r-- | cython/mobilesync.pxi | 11 | ||||
| -rw-r--r-- | cython/notification_proxy.pxi | 9 | ||||
| -rw-r--r-- | cython/property_list_client.pxi | 3 | ||||
| -rw-r--r-- | cython/sbservices.pxi | 19 | ||||
| -rw-r--r-- | cython/screenshotr.pxi | 9 |
14 files changed, 472 insertions, 187 deletions
diff --git a/cython/Makefile.am b/cython/Makefile.am index b1dea79..a8e39d4 100644 --- a/cython/Makefile.am +++ b/cython/Makefile.am | |||
| @@ -9,6 +9,7 @@ BUILT_SOURCES = imobiledevice.c | |||
| 9 | PXDINCLUDES = imobiledevice.pxd stdint.pxi $(CYTHON_PLIST_INCLUDE_DIR)/plist.pxd | 9 | PXDINCLUDES = imobiledevice.pxd stdint.pxi $(CYTHON_PLIST_INCLUDE_DIR)/plist.pxd |
| 10 | PXIINCLUDES = \ | 10 | PXIINCLUDES = \ |
| 11 | stdint.pxi \ | 11 | stdint.pxi \ |
| 12 | lockdown.pxi \ | ||
| 12 | mobilesync.pxi \ | 13 | mobilesync.pxi \ |
| 13 | notification_proxy.pxi \ | 14 | notification_proxy.pxi \ |
| 14 | sbservices.pxi \ | 15 | sbservices.pxi \ |
diff --git a/cython/afc.pxi b/cython/afc.pxi index 1e2617a..ff5c2b0 100644 --- a/cython/afc.pxi +++ b/cython/afc.pxi | |||
| @@ -51,6 +51,13 @@ cdef extern from "libimobiledevice/afc.h": | |||
| 51 | afc_error_t afc_get_device_info(afc_client_t client, char ***infos) | 51 | afc_error_t afc_get_device_info(afc_client_t client, char ***infos) |
| 52 | afc_error_t afc_read_directory(afc_client_t client, char *dir, char ***list) | 52 | afc_error_t afc_read_directory(afc_client_t client, char *dir, char ***list) |
| 53 | afc_error_t afc_get_file_info(afc_client_t client, char *filename, char ***infolist) | 53 | afc_error_t afc_get_file_info(afc_client_t client, char *filename, char ***infolist) |
| 54 | afc_error_t afc_remove_path(afc_client_t client, char *path) | ||
| 55 | afc_error_t afc_rename_path(afc_client_t client, char *f, char *to) | ||
| 56 | afc_error_t afc_make_directory(afc_client_t client, char *dir) | ||
| 57 | afc_error_t afc_truncate(afc_client_t client, char *path, uint64_t newsize) | ||
| 58 | afc_error_t afc_make_link(afc_client_t client, afc_link_type_t linktype, char *target, char *linkname) | ||
| 59 | afc_error_t afc_set_file_time(afc_client_t client, char *path, uint64_t mtime) | ||
| 60 | |||
| 54 | afc_error_t afc_file_open(afc_client_t client, char *filename, afc_file_mode_t file_mode, uint64_t *handle) | 61 | afc_error_t afc_file_open(afc_client_t client, char *filename, afc_file_mode_t file_mode, uint64_t *handle) |
| 55 | afc_error_t afc_file_close(afc_client_t client, uint64_t handle) | 62 | afc_error_t afc_file_close(afc_client_t client, uint64_t handle) |
| 56 | afc_error_t afc_file_lock(afc_client_t client, uint64_t handle, afc_lock_op_t operation) | 63 | afc_error_t afc_file_lock(afc_client_t client, uint64_t handle, afc_lock_op_t operation) |
| @@ -59,12 +66,6 @@ cdef extern from "libimobiledevice/afc.h": | |||
| 59 | afc_error_t afc_file_seek(afc_client_t client, uint64_t handle, int64_t offset, int whence) | 66 | afc_error_t afc_file_seek(afc_client_t client, uint64_t handle, int64_t offset, int whence) |
| 60 | afc_error_t afc_file_tell(afc_client_t client, uint64_t handle, uint64_t *position) | 67 | afc_error_t afc_file_tell(afc_client_t client, uint64_t handle, uint64_t *position) |
| 61 | afc_error_t afc_file_truncate(afc_client_t client, uint64_t handle, uint64_t newsize) | 68 | afc_error_t afc_file_truncate(afc_client_t client, uint64_t handle, uint64_t newsize) |
| 62 | afc_error_t afc_remove_path(afc_client_t client, char *path) | ||
| 63 | afc_error_t afc_rename_path(afc_client_t client, char *f, char *to) | ||
| 64 | afc_error_t afc_make_directory(afc_client_t client, char *dir) | ||
| 65 | afc_error_t afc_truncate(afc_client_t client, char *path, uint64_t newsize) | ||
| 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) | ||
| 68 | 69 | ||
| 69 | cdef class AfcError(BaseError): | 70 | cdef class AfcError(BaseError): |
| 70 | def __init__(self, *args, **kwargs): | 71 | def __init__(self, *args, **kwargs): |
| @@ -100,19 +101,55 @@ cdef class AfcError(BaseError): | |||
| 100 | } | 101 | } |
| 101 | BaseError.__init__(self, *args, **kwargs) | 102 | BaseError.__init__(self, *args, **kwargs) |
| 102 | 103 | ||
| 103 | cdef class AfcClient(Base): | 104 | # forward declaration of AfcClient |
| 105 | cdef class AfcClient(BaseService) | ||
| 106 | |||
| 107 | cdef class AfcFile(Base): | ||
| 108 | cdef uint64_t _c_handle | ||
| 109 | cdef AfcClient _client | ||
| 110 | cdef bytes _filename | ||
| 111 | |||
| 112 | def __init__(self, *args, **kwargs): | ||
| 113 | raise TypeError("AfcFile cannot be instantiated") | ||
| 114 | |||
| 115 | cpdef close(self): | ||
| 116 | self.handle_error(afc_file_close(self._client._c_client, self._c_handle)) | ||
| 117 | |||
| 118 | cpdef seek(self, int64_t offset, int whence): | ||
| 119 | self.handle_error(afc_file_seek(self._client._c_client, self._c_handle, offset, whence)) | ||
| 120 | |||
| 121 | cpdef uint64_t tell(self): | ||
| 122 | cdef uint64_t position | ||
| 123 | self.handle_error(afc_file_tell(self._client._c_client, self._c_handle, &position)) | ||
| 124 | return position | ||
| 125 | |||
| 126 | cpdef truncate(self, uint64_t newsize): | ||
| 127 | self.handle_error(afc_file_truncate(self._client._c_client, self._c_handle, newsize)) | ||
| 128 | |||
| 129 | cpdef uint32_t write(self, bytes data): | ||
| 130 | cdef: | ||
| 131 | uint32_t bytes_written | ||
| 132 | char* c_data = data | ||
| 133 | try: | ||
| 134 | self.handle_error(afc_file_write(self._client._c_client, self._c_handle, c_data, len(data), &bytes_written)) | ||
| 135 | except BaseError, e: | ||
| 136 | raise | ||
| 137 | finally: | ||
| 138 | free(c_data) | ||
| 139 | |||
| 140 | return bytes_written | ||
| 141 | |||
| 142 | cdef inline BaseError _error(self, int16_t ret): | ||
| 143 | return AfcError(ret) | ||
| 144 | |||
| 145 | cdef class AfcClient(BaseService): | ||
| 146 | __service_name__ = "com.apple.afc" | ||
| 104 | cdef afc_client_t _c_client | 147 | cdef afc_client_t _c_client |
| 105 | 148 | ||
| 106 | def __cinit__(self, iDevice device not None, LockdownClient lockdown=None, *args, **kwargs): | 149 | def __cinit__(self, iDevice device not None, int port, *args, **kwargs): |
| 107 | cdef: | 150 | cdef: |
| 108 | iDevice dev = device | 151 | iDevice dev = device |
| 109 | LockdownClient lckd | ||
| 110 | afc_error_t err | 152 | afc_error_t err |
| 111 | if lockdown is None: | ||
| 112 | lckd = LockdownClient(dev) | ||
| 113 | else: | ||
| 114 | lckd = lockdown | ||
| 115 | port = lckd.start_service("com.apple.afc") | ||
| 116 | err = afc_client_new(dev._c_dev, port, &(self._c_client)) | 153 | err = afc_client_new(dev._c_dev, port, &(self._c_client)) |
| 117 | self.handle_error(err) | 154 | self.handle_error(err) |
| 118 | 155 | ||
| @@ -133,13 +170,18 @@ cdef class AfcClient(Base): | |||
| 133 | int i = 0 | 170 | int i = 0 |
| 134 | list result = [] | 171 | list result = [] |
| 135 | err = afc_get_device_info(self._c_client, &infos) | 172 | err = afc_get_device_info(self._c_client, &infos) |
| 136 | self.handle_error(err) | 173 | try: |
| 137 | while infos[i]: | 174 | self.handle_error(err) |
| 138 | info = infos[i] | 175 | except BaseError, e: |
| 139 | result.append(info) | 176 | raise |
| 140 | free(infos[i]) | 177 | finally: |
| 141 | i = i + 1 | 178 | if infos != NULL: |
| 142 | free(infos) | 179 | while infos[i]: |
| 180 | info = infos[i] | ||
| 181 | result.append(info) | ||
| 182 | free(infos[i]) | ||
| 183 | i = i + 1 | ||
| 184 | free(infos) | ||
| 143 | 185 | ||
| 144 | return result | 186 | return result |
| 145 | 187 | ||
| @@ -151,12 +193,69 @@ cdef class AfcClient(Base): | |||
| 151 | int i = 0 | 193 | int i = 0 |
| 152 | list result = [] | 194 | list result = [] |
| 153 | err = afc_read_directory(self._c_client, directory, &dir_list) | 195 | err = afc_read_directory(self._c_client, directory, &dir_list) |
| 154 | self.handle_error(err) | 196 | try: |
| 155 | while dir_list[i]: | 197 | self.handle_error(err) |
| 156 | f = dir_list[i] | 198 | except BaseError, e: |
| 157 | result.append(f) | 199 | raise |
| 158 | free(dir_list[i]) | 200 | finally: |
| 159 | i = i + 1 | 201 | if dir_list != NULL: |
| 160 | free(dir_list) | 202 | while dir_list[i]: |
| 203 | f = dir_list[i] | ||
| 204 | result.append(f) | ||
| 205 | free(dir_list[i]) | ||
| 206 | i = i + 1 | ||
| 207 | free(dir_list) | ||
| 208 | |||
| 209 | return result | ||
| 210 | |||
| 211 | cpdef AfcFile open(self, bytes filename): | ||
| 212 | cdef: | ||
| 213 | str mode = 'r' | ||
| 214 | afc_file_mode_t c_mode | ||
| 215 | uint64_t handle | ||
| 216 | AfcFile f | ||
| 217 | if mode == 'r': | ||
| 218 | c_mode = AFC_FOPEN_RDONLY | ||
| 219 | self.handle_error(afc_file_open(self._c_client, filename, c_mode, &handle)) | ||
| 220 | f = AfcFile.__new__(AfcFile) | ||
| 221 | f._c_handle = handle | ||
| 222 | f._client = self | ||
| 223 | f._filename = filename | ||
| 224 | |||
| 225 | return f | ||
| 226 | |||
| 227 | cpdef get_file_info(self, bytes path): | ||
| 228 | cdef: | ||
| 229 | list result | ||
| 230 | char** c_result | ||
| 231 | int i = 0 | ||
| 232 | bytes info | ||
| 233 | try: | ||
| 234 | self.handle_error(afc_get_file_info(self._c_client, path, &c_result)) | ||
| 235 | except BaseError, e: | ||
| 236 | raise | ||
| 237 | finally: | ||
| 238 | if c_result != NULL: | ||
| 239 | while c_result[i]: | ||
| 240 | info = c_result[i] | ||
| 241 | result.append(info) | ||
| 242 | free(c_result[i]) | ||
| 243 | i = i + 1 | ||
| 244 | free(c_result) | ||
| 161 | 245 | ||
| 162 | return result | 246 | return result |
| 247 | |||
| 248 | cpdef remove_path(self, bytes path): | ||
| 249 | self.handle_error(afc_remove_path(self._c_client, path)) | ||
| 250 | |||
| 251 | cpdef rename_path(self, bytes f, bytes t): | ||
| 252 | self.handle_error(afc_rename_path(self._c_client, f, t)) | ||
| 253 | |||
| 254 | cpdef make_directory(self, bytes d): | ||
| 255 | self.handle_error(afc_make_directory(self._c_client, d)) | ||
| 256 | |||
| 257 | cpdef truncate(self, bytes path, uint64_t newsize): | ||
| 258 | self.handle_error(afc_truncate(self._c_client, path, newsize)) | ||
| 259 | |||
| 260 | cpdef set_file_time(self, bytes path, uint64_t mtime): | ||
| 261 | self.handle_error(afc_set_file_time(self._c_client, path, mtime)) | ||
diff --git a/cython/file_relay.pxi b/cython/file_relay.pxi index 05c99f5..db9932a 100644 --- a/cython/file_relay.pxi +++ b/cython/file_relay.pxi | |||
| @@ -33,19 +33,14 @@ cdef class FileRelayError(BaseError): | |||
| 33 | 33 | ||
| 34 | cimport stdlib | 34 | cimport stdlib |
| 35 | 35 | ||
| 36 | cdef class FileRelayClient(Base): | 36 | cdef class FileRelayClient(PropertyListService): |
| 37 | __service_name__ = "com.apple.mobile.file_relay" | ||
| 37 | cdef file_relay_client_t _c_client | 38 | cdef file_relay_client_t _c_client |
| 38 | 39 | ||
| 39 | def __cinit__(self, iDevice device not None, LockdownClient lockdown=None, *args, **kwargs): | 40 | def __cinit__(self, iDevice device not None, int port, *args, **kwargs): |
| 40 | cdef: | 41 | cdef: |
| 41 | iDevice dev = device | 42 | iDevice dev = device |
| 42 | LockdownClient lckd | ||
| 43 | file_relay_error_t err | 43 | file_relay_error_t err |
| 44 | if lockdown is None: | ||
| 45 | lckd = LockdownClient(dev) | ||
| 46 | else: | ||
| 47 | lckd = lockdown | ||
| 48 | port = lckd.start_service("com.apple.mobile.file_relay") | ||
| 49 | err = file_relay_client_new(dev._c_dev, port, &self._c_client) | 44 | err = file_relay_client_new(dev._c_dev, port, &self._c_client) |
| 50 | self.handle_error(err) | 45 | self.handle_error(err) |
| 51 | 46 | ||
diff --git a/cython/imobiledevice.pxd b/cython/imobiledevice.pxd index 6bf75af..a699138 100644 --- a/cython/imobiledevice.pxd +++ b/cython/imobiledevice.pxd | |||
| @@ -45,14 +45,47 @@ cdef class iDevice(Base): | |||
| 45 | 45 | ||
| 46 | cpdef iDeviceConnection connect(self, uint16_t port) | 46 | cpdef iDeviceConnection connect(self, uint16_t port) |
| 47 | 47 | ||
| 48 | cdef class LockdownError(BaseError): pass | 48 | cdef class BaseService(Base): |
| 49 | pass | ||
| 50 | |||
| 51 | cdef class PropertyListService(BaseService): | ||
| 52 | cpdef send(self, plist.Node node) | ||
| 53 | cpdef object receive(self) | ||
| 54 | cdef inline int16_t _send(self, plist.plist_t node) | ||
| 55 | cdef inline int16_t _receive(self, plist.plist_t* c_node) | ||
| 49 | 56 | ||
| 50 | cdef extern from "libimobiledevice/lockdown.h": | 57 | cdef extern from "libimobiledevice/lockdown.h": |
| 51 | cdef struct lockdownd_client_private: | 58 | cdef struct lockdownd_client_private: |
| 52 | pass | 59 | pass |
| 53 | ctypedef lockdownd_client_private *lockdownd_client_t | 60 | ctypedef lockdownd_client_private *lockdownd_client_t |
| 61 | cdef struct lockdownd_pair_record: | ||
| 62 | char *device_certificate | ||
| 63 | char *host_certificate | ||
| 64 | char *host_id | ||
| 65 | char *root_certificate | ||
| 66 | ctypedef lockdownd_pair_record *lockdownd_pair_record_t | ||
| 67 | |||
| 68 | cdef class LockdownError(BaseError): pass | ||
| 69 | |||
| 70 | cdef class LockdownPairRecord: | ||
| 71 | cdef lockdownd_pair_record_t _c_record | ||
| 54 | 72 | ||
| 55 | cdef class LockdownClient(Base): | 73 | cdef class LockdownClient(PropertyListService): |
| 56 | cdef lockdownd_client_t _c_client | 74 | cdef lockdownd_client_t _c_client |
| 57 | cpdef int start_service(self, bytes service) | 75 | cdef readonly iDevice device |
| 76 | |||
| 77 | cpdef bytes query_type(self) | ||
| 78 | cpdef plist.Node get_value(self, bytes domain=*, bytes key=*) | ||
| 79 | cpdef set_value(self, bytes domain, bytes key, object value) | ||
| 80 | cpdef remove_value(self, bytes domain, bytes key) | ||
| 81 | cpdef uint16_t start_service(self, object service) | ||
| 82 | cpdef object get_service_client(self, object service_class) | ||
| 83 | cpdef tuple start_session(self, bytes host_id) | ||
| 84 | cpdef stop_session(self, bytes session_id) | ||
| 85 | cpdef pair(self, object pair_record=*) | ||
| 86 | cpdef validate_pair(self, object pair_record=*) | ||
| 87 | cpdef unpair(self, object pair_record=*) | ||
| 88 | cpdef activate(self, plist.Node activation_record) | ||
| 89 | cpdef deactivate(self) | ||
| 90 | cpdef enter_recovery(self) | ||
| 58 | cpdef goodbye(self) | 91 | cpdef goodbye(self) |
diff --git a/cython/imobiledevice.pyx b/cython/imobiledevice.pyx index b57db04..77a7a3a 100644 --- a/cython/imobiledevice.pyx +++ b/cython/imobiledevice.pyx | |||
| @@ -170,99 +170,42 @@ cdef class iDevice(Base): | |||
| 170 | self.handle_error(idevice_get_handle(self._c_dev, &handle)) | 170 | self.handle_error(idevice_get_handle(self._c_dev, &handle)) |
| 171 | return handle | 171 | return handle |
| 172 | 172 | ||
| 173 | cdef extern from "libimobiledevice/lockdown.h": | 173 | cdef extern from *: |
| 174 | cdef struct lockdownd_client_private: | 174 | ctypedef char* const_char_ptr "const char*" |
| 175 | pass | 175 | void free(void *ptr) |
| 176 | ctypedef lockdownd_client_private *lockdownd_client_t | 176 | void plist_free(plist.plist_t node) |
| 177 | ctypedef enum lockdownd_error_t: | 177 | |
| 178 | LOCKDOWN_E_SUCCESS = 0 | 178 | cdef class BaseService(Base): |
| 179 | LOCKDOWN_E_INVALID_ARG = -1 | 179 | __service_name__ = None |
| 180 | LOCKDOWN_E_INVALID_CONF = -2 | ||
| 181 | LOCKDOWN_E_PLIST_ERROR = -3 | ||
| 182 | LOCKDOWN_E_PAIRING_FAILED = -4 | ||
| 183 | LOCKDOWN_E_SSL_ERROR = -5 | ||
| 184 | LOCKDOWN_E_DICT_ERROR = -6 | ||
| 185 | LOCKDOWN_E_START_SERVICE_FAILED = -7 | ||
| 186 | LOCKDOWN_E_NOT_ENOUGH_DATA = -8 | ||
| 187 | LOCKDOWN_E_SET_VALUE_PROHIBITED = -9 | ||
| 188 | LOCKDOWN_E_GET_VALUE_PROHIBITED = -10 | ||
| 189 | LOCKDOWN_E_REMOVE_VALUE_PROHIBITED = -11 | ||
| 190 | LOCKDOWN_E_MUX_ERROR = -12 | ||
| 191 | LOCKDOWN_E_ACTIVATION_FAILED = -13 | ||
| 192 | LOCKDOWN_E_PASSWORD_PROTECTED = -14 | ||
| 193 | LOCKDOWN_E_NO_RUNNING_SESSION = -15 | ||
| 194 | LOCKDOWN_E_INVALID_HOST_ID = -16 | ||
| 195 | LOCKDOWN_E_INVALID_SERVICE = -17 | ||
| 196 | LOCKDOWN_E_INVALID_ACTIVATION_RECORD = -18 | ||
| 197 | LOCKDOWN_E_UNKNOWN_ERROR = -256 | ||
| 198 | |||
| 199 | lockdownd_error_t lockdownd_client_new_with_handshake(idevice_t device, lockdownd_client_t *client, char *label) | ||
| 200 | lockdownd_error_t lockdownd_client_free(lockdownd_client_t client) | ||
| 201 | lockdownd_error_t lockdownd_start_service(lockdownd_client_t client, char *service, uint16_t *port) | ||
| 202 | |||
| 203 | cdef class LockdownError(BaseError): | ||
| 204 | def __init__(self, *args, **kwargs): | ||
| 205 | self._lookup_table = { | ||
| 206 | LOCKDOWN_E_SUCCESS: "Success", | ||
| 207 | LOCKDOWN_E_INVALID_ARG: "Invalid argument", | ||
| 208 | LOCKDOWN_E_INVALID_CONF: "Invalid configuration", | ||
| 209 | LOCKDOWN_E_PLIST_ERROR: "Property list error", | ||
| 210 | LOCKDOWN_E_PAIRING_FAILED: "Pairing failed", | ||
| 211 | LOCKDOWN_E_SSL_ERROR: "SSL error", | ||
| 212 | LOCKDOWN_E_DICT_ERROR: "Dict error", | ||
| 213 | LOCKDOWN_E_START_SERVICE_FAILED: "Start service failed", | ||
| 214 | LOCKDOWN_E_NOT_ENOUGH_DATA: "Not enough data", | ||
| 215 | LOCKDOWN_E_SET_VALUE_PROHIBITED: "Set value prohibited", | ||
| 216 | LOCKDOWN_E_GET_VALUE_PROHIBITED: "Get value prohibited", | ||
| 217 | LOCKDOWN_E_REMOVE_VALUE_PROHIBITED: "Remove value prohibited", | ||
| 218 | LOCKDOWN_E_MUX_ERROR: "MUX Error", | ||
| 219 | LOCKDOWN_E_ACTIVATION_FAILED: "Activation failed", | ||
| 220 | LOCKDOWN_E_PASSWORD_PROTECTED: "Password protected", | ||
| 221 | LOCKDOWN_E_NO_RUNNING_SESSION: "No running session", | ||
| 222 | LOCKDOWN_E_INVALID_HOST_ID: "Invalid host ID", | ||
| 223 | LOCKDOWN_E_INVALID_SERVICE: "Invalid service", | ||
| 224 | LOCKDOWN_E_INVALID_ACTIVATION_RECORD: "Invalid activation record", | ||
| 225 | LOCKDOWN_E_UNKNOWN_ERROR: "Unknown error" | ||
| 226 | } | ||
| 227 | BaseError.__init__(self, *args, **kwargs) | ||
| 228 | 180 | ||
| 229 | cdef class LockdownClient(Base): | 181 | cdef class PropertyListService(BaseService): |
| 230 | def __cinit__(self, iDevice device not None, bytes label="", *args, **kwargs): | 182 | cpdef send(self, plist.Node node): |
| 183 | self.handle_error(self._send(node._c_node)) | ||
| 184 | |||
| 185 | cpdef object receive(self): | ||
| 231 | cdef: | 186 | cdef: |
| 232 | iDevice dev = device | 187 | plist.plist_t c_node = NULL |
| 233 | lockdownd_error_t err | 188 | int16_t err |
| 234 | char* c_label = NULL | 189 | err = self._receive(&c_node) |
| 235 | if label: | 190 | try: |
| 236 | c_label = label | ||
| 237 | err = lockdownd_client_new_with_handshake(dev._c_dev, &(self._c_client), c_label) | ||
| 238 | self.handle_error(err) | ||
| 239 | |||
| 240 | def __dealloc__(self): | ||
| 241 | cdef lockdownd_error_t err | ||
| 242 | if self._c_client is not NULL: | ||
| 243 | err = lockdownd_client_free(self._c_client) | ||
| 244 | self.handle_error(err) | 191 | self.handle_error(err) |
| 192 | except BaseError, e: | ||
| 193 | if c_node != NULL: | ||
| 194 | plist_free(c_node) | ||
| 195 | raise | ||
| 245 | 196 | ||
| 246 | cdef inline BaseError _error(self, int16_t ret): | 197 | return plist.plist_t_to_node(c_node) |
| 247 | return LockdownError(ret) | ||
| 248 | |||
| 249 | cpdef int start_service(self, bytes service): | ||
| 250 | cdef: | ||
| 251 | uint16_t port | ||
| 252 | lockdownd_error_t err | ||
| 253 | err = lockdownd_start_service(self._c_client, service, &port) | ||
| 254 | self.handle_error(err) | ||
| 255 | return port | ||
| 256 | |||
| 257 | cpdef goodbye(self): | ||
| 258 | pass | ||
| 259 | 198 | ||
| 260 | cdef extern from *: | 199 | cdef inline int16_t _send(self, plist.plist_t node): |
| 261 | ctypedef char* const_char_ptr "const char*" | 200 | raise NotImplementedError("send is not implemented") |
| 262 | void free(void *ptr) | 201 | |
| 263 | void plist_free(plist.plist_t node) | 202 | cdef inline int16_t _receive(self, plist.plist_t* c_node): |
| 203 | raise NotImplementedError("receive is not implemented") | ||
| 204 | |||
| 205 | cdef class DeviceLinkService(PropertyListService): | ||
| 206 | pass | ||
| 264 | 207 | ||
| 265 | include "property_list_client.pxi" | 208 | include "lockdown.pxi" |
| 266 | include "mobilesync.pxi" | 209 | include "mobilesync.pxi" |
| 267 | include "notification_proxy.pxi" | 210 | include "notification_proxy.pxi" |
| 268 | include "sbservices.pxi" | 211 | include "sbservices.pxi" |
diff --git a/cython/installation_proxy.pxi b/cython/installation_proxy.pxi index a8083d3..f584cbd 100644 --- a/cython/installation_proxy.pxi +++ b/cython/installation_proxy.pxi | |||
| @@ -43,18 +43,13 @@ cdef class InstallationProxyError(BaseError): | |||
| 43 | BaseError.__init__(self, *args, **kwargs) | 43 | BaseError.__init__(self, *args, **kwargs) |
| 44 | 44 | ||
| 45 | cdef class InstallationProxy(Base): | 45 | cdef class InstallationProxy(Base): |
| 46 | __service_name__ = "com.apple.mobile.installation_proxy" | ||
| 46 | cdef instproxy_client_t _c_client | 47 | cdef instproxy_client_t _c_client |
| 47 | 48 | ||
| 48 | def __cinit__(self, iDevice device not None, LockdownClient lockdown=None, *args, **kwargs): | 49 | def __cinit__(self, iDevice device not None, int port, *args, **kwargs): |
| 49 | cdef: | 50 | cdef: |
| 50 | iDevice dev = device | 51 | iDevice dev = device |
| 51 | LockdownClient lckd | ||
| 52 | instproxy_error_t err | 52 | instproxy_error_t err |
| 53 | if lockdown is None: | ||
| 54 | lckd = LockdownClient(dev) | ||
| 55 | else: | ||
| 56 | lckd = lockdown | ||
| 57 | port = lckd.start_service("com.apple.mobile.installation_proxy") | ||
| 58 | err = instproxy_client_new(dev._c_dev, port, &self._c_client) | 53 | err = instproxy_client_new(dev._c_dev, port, &self._c_client) |
| 59 | self.handle_error(err) | 54 | self.handle_error(err) |
| 60 | 55 | ||
diff --git a/cython/lockdown.pxi b/cython/lockdown.pxi new file mode 100644 index 0000000..76f84b1 --- /dev/null +++ b/cython/lockdown.pxi | |||
| @@ -0,0 +1,254 @@ | |||
| 1 | cdef extern from "libimobiledevice/lockdown.h": | ||
| 2 | ctypedef enum lockdownd_error_t: | ||
| 3 | LOCKDOWN_E_SUCCESS = 0 | ||
| 4 | LOCKDOWN_E_INVALID_ARG = -1 | ||
| 5 | LOCKDOWN_E_INVALID_CONF = -2 | ||
| 6 | LOCKDOWN_E_PLIST_ERROR = -3 | ||
| 7 | LOCKDOWN_E_PAIRING_FAILED = -4 | ||
| 8 | LOCKDOWN_E_SSL_ERROR = -5 | ||
| 9 | LOCKDOWN_E_DICT_ERROR = -6 | ||
| 10 | LOCKDOWN_E_START_SERVICE_FAILED = -7 | ||
| 11 | LOCKDOWN_E_NOT_ENOUGH_DATA = -8 | ||
| 12 | LOCKDOWN_E_SET_VALUE_PROHIBITED = -9 | ||
| 13 | LOCKDOWN_E_GET_VALUE_PROHIBITED = -10 | ||
| 14 | LOCKDOWN_E_REMOVE_VALUE_PROHIBITED = -11 | ||
| 15 | LOCKDOWN_E_MUX_ERROR = -12 | ||
| 16 | LOCKDOWN_E_ACTIVATION_FAILED = -13 | ||
| 17 | LOCKDOWN_E_PASSWORD_PROTECTED = -14 | ||
| 18 | LOCKDOWN_E_NO_RUNNING_SESSION = -15 | ||
| 19 | LOCKDOWN_E_INVALID_HOST_ID = -16 | ||
| 20 | LOCKDOWN_E_INVALID_SERVICE = -17 | ||
| 21 | LOCKDOWN_E_INVALID_ACTIVATION_RECORD = -18 | ||
| 22 | LOCKDOWN_E_UNKNOWN_ERROR = -256 | ||
| 23 | |||
| 24 | lockdownd_error_t lockdownd_client_new(idevice_t device, lockdownd_client_t *client, char *label) | ||
| 25 | lockdownd_error_t lockdownd_client_new_with_handshake(idevice_t device, lockdownd_client_t *client, char *label) | ||
| 26 | lockdownd_error_t lockdownd_client_free(lockdownd_client_t client) | ||
| 27 | |||
| 28 | lockdownd_error_t lockdownd_query_type(lockdownd_client_t client, char **tp) | ||
| 29 | lockdownd_error_t lockdownd_get_value(lockdownd_client_t client, char *domain, char *key, plist.plist_t *value) | ||
| 30 | lockdownd_error_t lockdownd_set_value(lockdownd_client_t client, char *domain, char *key, plist.plist_t value) | ||
| 31 | lockdownd_error_t lockdownd_remove_value(lockdownd_client_t client, char *domain, char *key) | ||
| 32 | lockdownd_error_t lockdownd_start_service(lockdownd_client_t client, char *service, uint16_t *port) | ||
| 33 | lockdownd_error_t lockdownd_start_session(lockdownd_client_t client, char *host_id, char **session_id, int *ssl_enabled) | ||
| 34 | lockdownd_error_t lockdownd_stop_session(lockdownd_client_t client, char *session_id) | ||
| 35 | lockdownd_error_t lockdownd_send(lockdownd_client_t client, plist.plist_t plist) | ||
| 36 | lockdownd_error_t lockdownd_receive(lockdownd_client_t client, plist.plist_t *plist) | ||
| 37 | lockdownd_error_t lockdownd_pair(lockdownd_client_t client, lockdownd_pair_record_t pair_record) | ||
| 38 | lockdownd_error_t lockdownd_validate_pair(lockdownd_client_t client, lockdownd_pair_record_t pair_record) | ||
| 39 | lockdownd_error_t lockdownd_unpair(lockdownd_client_t client, lockdownd_pair_record_t pair_record) | ||
| 40 | lockdownd_error_t lockdownd_activate(lockdownd_client_t client, plist.plist_t activation_record) | ||
| 41 | lockdownd_error_t lockdownd_deactivate(lockdownd_client_t client) | ||
| 42 | lockdownd_error_t lockdownd_enter_recovery(lockdownd_client_t client) | ||
| 43 | lockdownd_error_t lockdownd_goodbye(lockdownd_client_t client) | ||
| 44 | |||
| 45 | cdef class LockdownError(BaseError): | ||
| 46 | def __init__(self, *args, **kwargs): | ||
| 47 | self._lookup_table = { | ||
| 48 | LOCKDOWN_E_SUCCESS: "Success", | ||
| 49 | LOCKDOWN_E_INVALID_ARG: "Invalid argument", | ||
| 50 | LOCKDOWN_E_INVALID_CONF: "Invalid configuration", | ||
| 51 | LOCKDOWN_E_PLIST_ERROR: "Property list error", | ||
| 52 | LOCKDOWN_E_PAIRING_FAILED: "Pairing failed", | ||
| 53 | LOCKDOWN_E_SSL_ERROR: "SSL error", | ||
| 54 | LOCKDOWN_E_DICT_ERROR: "Dict error", | ||
| 55 | LOCKDOWN_E_START_SERVICE_FAILED: "Start service failed", | ||
| 56 | LOCKDOWN_E_NOT_ENOUGH_DATA: "Not enough data", | ||
| 57 | LOCKDOWN_E_SET_VALUE_PROHIBITED: "Set value prohibited", | ||
| 58 | LOCKDOWN_E_GET_VALUE_PROHIBITED: "Get value prohibited", | ||
| 59 | LOCKDOWN_E_REMOVE_VALUE_PROHIBITED: "Remove value prohibited", | ||
| 60 | LOCKDOWN_E_MUX_ERROR: "MUX Error", | ||
| 61 | LOCKDOWN_E_ACTIVATION_FAILED: "Activation failed", | ||
| 62 | LOCKDOWN_E_PASSWORD_PROTECTED: "Password protected", | ||
| 63 | LOCKDOWN_E_NO_RUNNING_SESSION: "No running session", | ||
| 64 | LOCKDOWN_E_INVALID_HOST_ID: "Invalid host ID", | ||
| 65 | LOCKDOWN_E_INVALID_SERVICE: "Invalid service", | ||
| 66 | LOCKDOWN_E_INVALID_ACTIVATION_RECORD: "Invalid activation record", | ||
| 67 | LOCKDOWN_E_UNKNOWN_ERROR: "Unknown error" | ||
| 68 | } | ||
| 69 | BaseError.__init__(self, *args, **kwargs) | ||
| 70 | |||
| 71 | cdef class LockdownPairRecord: | ||
| 72 | #def __cinit__(self, bytes device_certificate, bytes host_certificate, bytes host_id, bytes root_certificate, *args, **kwargs): | ||
| 73 | property device_certificate: | ||
| 74 | def __get__(self): | ||
| 75 | cdef bytes result = self._c_record.device_certificate | ||
| 76 | return result | ||
| 77 | property host_certificate: | ||
| 78 | def __get__(self): | ||
| 79 | cdef bytes result = self._c_record.host_certificate | ||
| 80 | return result | ||
| 81 | property host_id: | ||
| 82 | def __get__(self): | ||
| 83 | cdef bytes result = self._c_record.host_id | ||
| 84 | return result | ||
| 85 | property root_certificate: | ||
| 86 | def __get__(self): | ||
| 87 | cdef bytes result = self._c_record.root_certificate | ||
| 88 | return result | ||
| 89 | |||
| 90 | cdef class LockdownClient(PropertyListService): | ||
| 91 | def __cinit__(self, iDevice device not None, bytes label="", bool handshake=True, *args, **kwargs): | ||
| 92 | cdef: | ||
| 93 | iDevice dev = device | ||
| 94 | lockdownd_error_t err | ||
| 95 | char* c_label = NULL | ||
| 96 | if label: | ||
| 97 | c_label = label | ||
| 98 | if handshake: | ||
| 99 | err = lockdownd_client_new_with_handshake(dev._c_dev, &self._c_client, c_label) | ||
| 100 | else: | ||
| 101 | err = lockdownd_client_new(dev._c_dev, &self._c_client, c_label) | ||
| 102 | self.handle_error(err) | ||
| 103 | |||
| 104 | self.device = dev | ||
| 105 | |||
| 106 | def __dealloc__(self): | ||
| 107 | cdef lockdownd_error_t err | ||
| 108 | if self._c_client is not NULL: | ||
| 109 | err = lockdownd_client_free(self._c_client) | ||
| 110 | self.handle_error(err) | ||
| 111 | |||
| 112 | cpdef bytes query_type(self): | ||
| 113 | cdef: | ||
| 114 | lockdownd_error_t err | ||
| 115 | char* c_type = NULL | ||
| 116 | bytes result | ||
| 117 | err = lockdownd_query_type(self._c_client, &c_type) | ||
| 118 | try: | ||
| 119 | self.handle_error(err) | ||
| 120 | except BaseError, e: | ||
| 121 | raise | ||
| 122 | finally: | ||
| 123 | if c_type != NULL: | ||
| 124 | result = c_type | ||
| 125 | free(c_type) | ||
| 126 | |||
| 127 | return result | ||
| 128 | |||
| 129 | cpdef plist.Node get_value(self, bytes domain=None, bytes key=None): | ||
| 130 | cdef: | ||
| 131 | lockdownd_error_t err | ||
| 132 | plist.plist_t c_node = NULL | ||
| 133 | char* c_domain = NULL | ||
| 134 | char* c_key = NULL | ||
| 135 | if domain is not None: | ||
| 136 | c_domain = domain | ||
| 137 | if key is not None: | ||
| 138 | c_key = key | ||
| 139 | err = lockdownd_get_value(self._c_client, c_domain, c_key, &c_node) | ||
| 140 | try: | ||
| 141 | self.handle_error(err) | ||
| 142 | except BaseError, e: | ||
| 143 | if c_node != NULL: | ||
| 144 | plist_free(c_node) | ||
| 145 | raise | ||
| 146 | |||
| 147 | return plist.plist_t_to_node(c_node) | ||
| 148 | |||
| 149 | cpdef set_value(self, bytes domain, bytes key, object value): | ||
| 150 | cdef plist.plist_t c_node = plist.native_to_plist_t(value) | ||
| 151 | try: | ||
| 152 | self.handle_error(lockdownd_set_value(self._c_client, domain, key, c_node)) | ||
| 153 | except BaseError, e: | ||
| 154 | raise | ||
| 155 | finally: | ||
| 156 | if c_node != NULL: | ||
| 157 | plist_free(c_node) | ||
| 158 | |||
| 159 | cpdef remove_value(self, bytes domain, bytes key): | ||
| 160 | self.handle_error(lockdownd_remove_value(self._c_client, domain, key)) | ||
| 161 | |||
| 162 | cpdef uint16_t start_service(self, object service): | ||
| 163 | cdef: | ||
| 164 | char* c_service_name = NULL | ||
| 165 | uint16_t port = 0 | ||
| 166 | |||
| 167 | if hasattr(service, '__service_name__') and \ | ||
| 168 | service.__service_name__ is not None \ | ||
| 169 | and isinstance(service.__service_name__, basestring): | ||
| 170 | c_service_name = <bytes>service.__service_name__ | ||
| 171 | elif isinstance(service, basestring): | ||
| 172 | c_service_name = <bytes>service | ||
| 173 | else: | ||
| 174 | raise TypeError("LockdownClient.start_service() takes a BaseService or string as its first argument") | ||
| 175 | |||
| 176 | try: | ||
| 177 | self.handle_error(lockdownd_start_service(self._c_client, c_service_name, &port)) | ||
| 178 | except BaseError, e: | ||
| 179 | raise | ||
| 180 | |||
| 181 | return port | ||
| 182 | |||
| 183 | cpdef object get_service_client(self, object service_class): | ||
| 184 | cdef: | ||
| 185 | uint16_t port = 0 | ||
| 186 | object result | ||
| 187 | |||
| 188 | if not hasattr(service_class, '__service_name__') and \ | ||
| 189 | not service_class.__service_name__ is not None \ | ||
| 190 | and not isinstance(service_class.__service_name__, basestring): | ||
| 191 | raise TypeError("LockdownClient.get_service_client() takes a BaseService as its first argument") | ||
| 192 | |||
| 193 | port = self.start_service(service_class) | ||
| 194 | return service_class(self.device, port) | ||
| 195 | |||
| 196 | cpdef tuple start_session(self, bytes host_id): | ||
| 197 | cdef: | ||
| 198 | lockdownd_error_t err | ||
| 199 | char* c_session_id = NULL | ||
| 200 | bint ssl_enabled | ||
| 201 | bytes session_id | ||
| 202 | err = lockdownd_start_session(self._c_client, host_id, &c_session_id, &ssl_enabled) | ||
| 203 | try: | ||
| 204 | self.handle_error(err) | ||
| 205 | except BaseError, e: | ||
| 206 | raise | ||
| 207 | finally: | ||
| 208 | if c_session_id != NULL: | ||
| 209 | session_id = c_session_id | ||
| 210 | free(c_session_id) | ||
| 211 | |||
| 212 | return (session_id, ssl_enabled) | ||
| 213 | |||
| 214 | cpdef stop_session(self, bytes session_id): | ||
| 215 | self.handle_error(lockdownd_stop_session(self._c_client, session_id)) | ||
| 216 | |||
| 217 | cpdef pair(self, object pair_record=None): | ||
| 218 | cdef lockdownd_pair_record_t c_pair_record = NULL | ||
| 219 | if pair_record is not None: | ||
| 220 | c_pair_record = (<LockdownPairRecord>pair_record)._c_record | ||
| 221 | self.handle_error(lockdownd_pair(self._c_client, c_pair_record)) | ||
| 222 | |||
| 223 | cpdef validate_pair(self, object pair_record=None): | ||
| 224 | cdef lockdownd_pair_record_t c_pair_record = NULL | ||
| 225 | if pair_record is not None: | ||
| 226 | c_pair_record = (<LockdownPairRecord>pair_record)._c_record | ||
| 227 | self.handle_error(lockdownd_validate_pair(self._c_client, c_pair_record)) | ||
| 228 | |||
| 229 | cpdef unpair(self, object pair_record=None): | ||
| 230 | cdef lockdownd_pair_record_t c_pair_record = NULL | ||
| 231 | if pair_record is not None: | ||
| 232 | c_pair_record = (<LockdownPairRecord>pair_record)._c_record | ||
| 233 | self.handle_error(lockdownd_unpair(self._c_client, c_pair_record)) | ||
| 234 | |||
| 235 | cpdef activate(self, plist.Node activation_record): | ||
| 236 | self.handle_error(lockdownd_activate(self._c_client, activation_record._c_node)) | ||
| 237 | |||
| 238 | cpdef deactivate(self): | ||
| 239 | self.handle_error(lockdownd_deactivate(self._c_client)) | ||
| 240 | |||
| 241 | cpdef enter_recovery(self): | ||
| 242 | self.handle_error(lockdownd_enter_recovery(self._c_client)) | ||
| 243 | |||
| 244 | cpdef goodbye(self): | ||
| 245 | self.handle_error(lockdownd_goodbye(self._c_client)) | ||
| 246 | |||
| 247 | cdef inline int16_t _send(self, plist.plist_t node): | ||
| 248 | return lockdownd_send(self._c_client, node) | ||
| 249 | |||
| 250 | cdef inline int16_t _receive(self, plist.plist_t* node): | ||
| 251 | return lockdownd_receive(self._c_client, node) | ||
| 252 | |||
| 253 | cdef inline BaseError _error(self, int16_t ret): | ||
| 254 | return LockdownError(ret) | ||
diff --git a/cython/mobile_image_mounter.pxi b/cython/mobile_image_mounter.pxi index 9086f2c..e70cff7 100644 --- a/cython/mobile_image_mounter.pxi +++ b/cython/mobile_image_mounter.pxi | |||
| @@ -27,19 +27,14 @@ cdef class MobileImageMounterError(BaseError): | |||
| 27 | } | 27 | } |
| 28 | BaseError.__init__(self, *args, **kwargs) | 28 | BaseError.__init__(self, *args, **kwargs) |
| 29 | 29 | ||
| 30 | cdef class MobileImageMounterClient(Base): | 30 | cdef class MobileImageMounterClient(PropertyListService): |
| 31 | __service_name__ = "com.apple.mobile.mobile_image_mounter" | ||
| 31 | cdef mobile_image_mounter_client_t _c_client | 32 | cdef mobile_image_mounter_client_t _c_client |
| 32 | 33 | ||
| 33 | def __cinit__(self, iDevice device not None, LockdownClient lockdown=None, *args, **kwargs): | 34 | def __cinit__(self, iDevice device not None, int port, *args, **kwargs): |
| 34 | cdef: | 35 | cdef: |
| 35 | iDevice dev = device | 36 | iDevice dev = device |
| 36 | LockdownClient lckd | ||
| 37 | mobile_image_mounter_error_t err | 37 | mobile_image_mounter_error_t err |
| 38 | if lockdown is None: | ||
| 39 | lckd = LockdownClient(dev) | ||
| 40 | else: | ||
| 41 | lckd = lockdown | ||
| 42 | port = lckd.start_service("com.apple.mobile.mobile_image_mounter") | ||
| 43 | err = mobile_image_mounter_new(dev._c_dev, port, &self._c_client) | 38 | err = mobile_image_mounter_new(dev._c_dev, port, &self._c_client) |
| 44 | self.handle_error(err) | 39 | self.handle_error(err) |
| 45 | 40 | ||
diff --git a/cython/mobilebackup.pxi b/cython/mobilebackup.pxi index 330a99d..cb5276e 100644 --- a/cython/mobilebackup.pxi +++ b/cython/mobilebackup.pxi | |||
| @@ -28,19 +28,14 @@ cdef class MobileBackupError(BaseError): | |||
| 28 | } | 28 | } |
| 29 | BaseError.__init__(self, *args, **kwargs) | 29 | BaseError.__init__(self, *args, **kwargs) |
| 30 | 30 | ||
| 31 | cdef class MobileBackupClient(PropertyListClient): | 31 | cdef class MobileBackupClient(PropertyListService): |
| 32 | __service_name__ = "com.apple.mobilebackup" | ||
| 32 | cdef mobilebackup_client_t _c_client | 33 | cdef mobilebackup_client_t _c_client |
| 33 | 34 | ||
| 34 | def __cinit__(self, iDevice device not None, LockdownClient lockdown=None, *args, **kwargs): | 35 | def __cinit__(self, iDevice device not None, int port, *args, **kwargs): |
| 35 | cdef: | 36 | cdef: |
| 36 | iDevice dev = device | 37 | iDevice dev = device |
| 37 | LockdownClient lckd | ||
| 38 | mobilebackup_error_t err | 38 | mobilebackup_error_t err |
| 39 | if lockdown is None: | ||
| 40 | lckd = LockdownClient(dev) | ||
| 41 | else: | ||
| 42 | lckd = lockdown | ||
| 43 | port = lckd.start_service("com.apple.mobilebackup") | ||
| 44 | err = mobilebackup_client_new(dev._c_dev, port, &self._c_client) | 39 | err = mobilebackup_client_new(dev._c_dev, port, &self._c_client) |
| 45 | self.handle_error(err) | 40 | self.handle_error(err) |
| 46 | 41 | ||
diff --git a/cython/mobilesync.pxi b/cython/mobilesync.pxi index d5dacb1..1b36ba7 100644 --- a/cython/mobilesync.pxi +++ b/cython/mobilesync.pxi | |||
| @@ -28,19 +28,14 @@ cdef class MobileSyncError(BaseError): | |||
| 28 | } | 28 | } |
| 29 | BaseError.__init__(self, *args, **kwargs) | 29 | BaseError.__init__(self, *args, **kwargs) |
| 30 | 30 | ||
| 31 | cdef class MobileSyncClient(PropertyListClient): | 31 | cdef class MobileSyncClient(DeviceLinkService): |
| 32 | __service_name__ = "com.apple.mobilesync" | ||
| 32 | cdef mobilesync_client_t _c_client | 33 | cdef mobilesync_client_t _c_client |
| 33 | 34 | ||
| 34 | def __cinit__(self, iDevice device not None, LockdownClient lockdown=None, *args, **kwargs): | 35 | def __cinit__(self, iDevice device not None, int port, *args, **kwargs): |
| 35 | cdef: | 36 | cdef: |
| 36 | iDevice dev = device | 37 | iDevice dev = device |
| 37 | LockdownClient lckd | ||
| 38 | mobilesync_error_t err | 38 | mobilesync_error_t err |
| 39 | if lockdown is None: | ||
| 40 | lckd = LockdownClient(dev) | ||
| 41 | else: | ||
| 42 | lckd = lockdown | ||
| 43 | port = lckd.start_service("com.apple.mobilesync") | ||
| 44 | err = mobilesync_client_new(dev._c_dev, port, &(self._c_client)) | 39 | err = mobilesync_client_new(dev._c_dev, port, &(self._c_client)) |
| 45 | self.handle_error(err) | 40 | self.handle_error(err) |
| 46 | 41 | ||
diff --git a/cython/notification_proxy.pxi b/cython/notification_proxy.pxi index d5f2d25..cc25f2d 100644 --- a/cython/notification_proxy.pxi +++ b/cython/notification_proxy.pxi | |||
| @@ -31,18 +31,13 @@ cdef class NotificationProxyError(BaseError): | |||
| 31 | BaseError.__init__(self, *args, **kwargs) | 31 | BaseError.__init__(self, *args, **kwargs) |
| 32 | 32 | ||
| 33 | cdef class NotificationProxy(Base): | 33 | cdef class NotificationProxy(Base): |
| 34 | __service_name__ = "com.apple.mobile.notification_proxy" | ||
| 34 | cdef np_client_t _c_client | 35 | cdef np_client_t _c_client |
| 35 | 36 | ||
| 36 | def __cinit__(self, iDevice device not None, LockdownClient lockdown=None, *args, **kwargs): | 37 | def __cinit__(self, iDevice device not None, int port, *args, **kwargs): |
| 37 | cdef: | 38 | cdef: |
| 38 | iDevice dev = device | 39 | iDevice dev = device |
| 39 | LockdownClient lckd | ||
| 40 | np_error_t err | 40 | np_error_t err |
| 41 | if lockdown is None: | ||
| 42 | lckd = LockdownClient(dev) | ||
| 43 | else: | ||
| 44 | lckd = lockdown | ||
| 45 | port = lckd.start_service("com.apple.mobile.notification_proxy") | ||
| 46 | err = np_client_new(dev._c_dev, port, &self._c_client) | 41 | err = np_client_new(dev._c_dev, port, &self._c_client) |
| 47 | self.handle_error(err) | 42 | self.handle_error(err) |
| 48 | 43 | ||
diff --git a/cython/property_list_client.pxi b/cython/property_list_client.pxi index 2f9ce76..c137b34 100644 --- a/cython/property_list_client.pxi +++ b/cython/property_list_client.pxi | |||
| @@ -1,7 +1,6 @@ | |||
| 1 | cdef class PropertyListClient(Base): | 1 | cdef class PropertyListClient(Base): |
| 2 | cpdef send(self, plist.Node node): | 2 | cpdef send(self, plist.Node node): |
| 3 | cdef plist.Node n = node | 3 | self.handle_error(self._send(node._c_node)) |
| 4 | self.handle_error(self._send(n._c_node)) | ||
| 5 | 4 | ||
| 6 | cpdef object receive(self): | 5 | cpdef object receive(self): |
| 7 | cdef: | 6 | cdef: |
diff --git a/cython/sbservices.pxi b/cython/sbservices.pxi index 6eece0a..28aa5a5 100644 --- a/cython/sbservices.pxi +++ b/cython/sbservices.pxi | |||
| @@ -26,19 +26,13 @@ cdef class SpringboardServicesError(BaseError): | |||
| 26 | BaseError.__init__(self, *args, **kwargs) | 26 | BaseError.__init__(self, *args, **kwargs) |
| 27 | 27 | ||
| 28 | cdef class SpringboardServicesClient(Base): | 28 | cdef class SpringboardServicesClient(Base): |
| 29 | __service_name__ = "com.apple.springboardservices" | ||
| 29 | cdef sbservices_client_t _c_client | 30 | cdef sbservices_client_t _c_client |
| 30 | 31 | ||
| 31 | def __cinit__(self, iDevice device not None, LockdownClient lockdown=None, *args, **kwargs): | 32 | def __cinit__(self, iDevice device not None, int port, *args, **kwargs): |
| 32 | cdef: | 33 | cdef: |
| 33 | iDevice dev = device | 34 | iDevice dev = device |
| 34 | LockdownClient lckd | 35 | self.handle_error(sbservices_client_new(dev._c_dev, port, &self._c_client)) |
| 35 | if lockdown is None: | ||
| 36 | lckd = LockdownClient(dev) | ||
| 37 | else: | ||
| 38 | lckd = lockdown | ||
| 39 | port = lckd.start_service("com.apple.springboardservices") | ||
| 40 | err = SpringboardServicesError(sbservices_client_new(dev._c_dev, port, &(self._c_client))) | ||
| 41 | if err: raise err | ||
| 42 | 36 | ||
| 43 | def __dealloc__(self): | 37 | def __dealloc__(self): |
| 44 | if self._c_client is not NULL: | 38 | if self._c_client is not NULL: |
| @@ -52,7 +46,6 @@ cdef class SpringboardServicesClient(Base): | |||
| 52 | def __get__(self): | 46 | def __get__(self): |
| 53 | cdef: | 47 | cdef: |
| 54 | plist.plist_t c_node = NULL | 48 | plist.plist_t c_node = NULL |
| 55 | plist.Node node | ||
| 56 | sbservices_error_t err | 49 | sbservices_error_t err |
| 57 | err = sbservices_get_icon_state(self._c_client, &c_node) | 50 | err = sbservices_get_icon_state(self._c_client, &c_node) |
| 58 | try: | 51 | try: |
| @@ -61,11 +54,9 @@ cdef class SpringboardServicesClient(Base): | |||
| 61 | if c_node != NULL: | 54 | if c_node != NULL: |
| 62 | plist_free(c_node) | 55 | plist_free(c_node) |
| 63 | raise | 56 | raise |
| 64 | node = plist.plist_t_to_node(c_node) | 57 | return plist.plist_t_to_node(c_node) |
| 65 | return node | ||
| 66 | def __set__(self, plist.Node newstate not None): | 58 | def __set__(self, plist.Node newstate not None): |
| 67 | cdef plist.Node node = newstate | 59 | self.handle_error(sbservices_set_icon_state(self._c_client, newstate._c_node)) |
| 68 | self.handle_error(sbservices_set_icon_state(self._c_client, node._c_node)) | ||
| 69 | 60 | ||
| 70 | cpdef bytes get_pngdata(self, bytes bundleId): | 61 | cpdef bytes get_pngdata(self, bytes bundleId): |
| 71 | cdef: | 62 | cdef: |
diff --git a/cython/screenshotr.pxi b/cython/screenshotr.pxi index 92d95b9..d3a896f 100644 --- a/cython/screenshotr.pxi +++ b/cython/screenshotr.pxi | |||
| @@ -28,18 +28,13 @@ cdef class ScreenshotrError(BaseError): | |||
| 28 | BaseError.__init__(self, *args, **kwargs) | 28 | BaseError.__init__(self, *args, **kwargs) |
| 29 | 29 | ||
| 30 | cdef class ScreenshotrClient(Base): | 30 | cdef class ScreenshotrClient(Base): |
| 31 | __service_name__ = "com.apple.mobile.screenshotr" | ||
| 31 | cdef screenshotr_client_t _c_client | 32 | cdef screenshotr_client_t _c_client |
| 32 | 33 | ||
| 33 | def __cinit__(self, iDevice device not None, LockdownClient lockdown=None, *args, **kwargs): | 34 | def __cinit__(self, iDevice device not None, int port, *args, **kwargs): |
| 34 | cdef: | 35 | cdef: |
| 35 | iDevice dev = device | 36 | iDevice dev = device |
| 36 | LockdownClient lckd | ||
| 37 | screenshotr_error_t err | 37 | screenshotr_error_t err |
| 38 | if lockdown is None: | ||
| 39 | lckd = LockdownClient(dev) | ||
| 40 | else: | ||
| 41 | lckd = lockdown | ||
| 42 | port = lckd.start_service("com.apple.mobile.screenshotr") | ||
| 43 | err = screenshotr_client_new(dev._c_dev, port, &self._c_client) | 38 | err = screenshotr_client_new(dev._c_dev, port, &self._c_client) |
| 44 | self.handle_error(err) | 39 | self.handle_error(err) |
| 45 | 40 | ||
