diff options
| -rw-r--r-- | cython/afc.pxi | 6 | ||||
| -rw-r--r-- | cython/file_relay.pxi | 6 | ||||
| -rw-r--r-- | cython/imobiledevice.pyx | 55 | ||||
| -rw-r--r-- | cython/installation_proxy.pxi | 126 | ||||
| -rw-r--r-- | cython/lockdown.pxi | 29 | ||||
| -rw-r--r-- | cython/mobile_image_mounter.pxi | 26 | ||||
| -rw-r--r-- | cython/mobilebackup.pxi | 6 | ||||
| -rw-r--r-- | cython/mobilesync.pxi | 6 | ||||
| -rw-r--r-- | cython/notification_proxy.pxi | 6 | ||||
| -rw-r--r-- | cython/sbservices.pxi | 14 | ||||
| -rw-r--r-- | cython/screenshotr.pxi | 20 |
11 files changed, 193 insertions, 107 deletions
diff --git a/cython/afc.pxi b/cython/afc.pxi index 9200067..c33dbfd 100644 --- a/cython/afc.pxi +++ b/cython/afc.pxi | |||
| @@ -154,11 +154,7 @@ cdef class AfcClient(BaseService): | |||
| 154 | cdef afc_client_t _c_client | 154 | cdef afc_client_t _c_client |
| 155 | 155 | ||
| 156 | def __cinit__(self, iDevice device not None, int port, *args, **kwargs): | 156 | def __cinit__(self, iDevice device not None, int port, *args, **kwargs): |
| 157 | cdef: | 157 | self.handle_error(afc_client_new(device._c_dev, port, &(self._c_client))) |
| 158 | iDevice dev = device | ||
| 159 | afc_error_t err | ||
| 160 | err = afc_client_new(dev._c_dev, port, &(self._c_client)) | ||
| 161 | self.handle_error(err) | ||
| 162 | 158 | ||
| 163 | def __dealloc__(self): | 159 | def __dealloc__(self): |
| 164 | cdef afc_error_t err | 160 | cdef afc_error_t err |
diff --git a/cython/file_relay.pxi b/cython/file_relay.pxi index fd7b67e..beb429b 100644 --- a/cython/file_relay.pxi +++ b/cython/file_relay.pxi | |||
| @@ -38,11 +38,7 @@ cdef class FileRelayClient(PropertyListService): | |||
| 38 | cdef file_relay_client_t _c_client | 38 | cdef file_relay_client_t _c_client |
| 39 | 39 | ||
| 40 | def __cinit__(self, iDevice device not None, int port, *args, **kwargs): | 40 | def __cinit__(self, iDevice device not None, int port, *args, **kwargs): |
| 41 | cdef: | 41 | self.handle_error(file_relay_client_new(device._c_dev, port, &self._c_client)) |
| 42 | iDevice dev = device | ||
| 43 | file_relay_error_t err | ||
| 44 | err = file_relay_client_new(dev._c_dev, port, &self._c_client) | ||
| 45 | self.handle_error(err) | ||
| 46 | 42 | ||
| 47 | def __dealloc__(self): | 43 | def __dealloc__(self): |
| 48 | cdef file_relay_error_t err | 44 | cdef file_relay_error_t err |
diff --git a/cython/imobiledevice.pyx b/cython/imobiledevice.pyx index bde43d0..7898290 100644 --- a/cython/imobiledevice.pyx +++ b/cython/imobiledevice.pyx | |||
| @@ -102,13 +102,16 @@ def event_unsubscribe(): | |||
| 102 | 102 | ||
| 103 | def get_device_list(): | 103 | def get_device_list(): |
| 104 | cdef: | 104 | cdef: |
| 105 | char** devices | 105 | char** devices = NULL |
| 106 | int count | 106 | int count |
| 107 | list result | 107 | list result |
| 108 | bytes device | 108 | bytes device |
| 109 | iDeviceError err = iDeviceError(idevice_get_device_list(&devices, &count)) | 109 | iDeviceError err = iDeviceError(idevice_get_device_list(&devices, &count)) |
| 110 | 110 | ||
| 111 | if err: raise err | 111 | if err: |
| 112 | if devices != NULL: | ||
| 113 | idevice_device_list_free(devices) | ||
| 114 | raise err | ||
| 112 | 115 | ||
| 113 | result = [] | 116 | result = [] |
| 114 | for i from 0 <= i < count: | 117 | for i from 0 <= i < count: |
| @@ -131,15 +134,16 @@ cdef class iDeviceConnection(Base): | |||
| 131 | cdef inline BaseError _error(self, int16_t ret): | 134 | cdef inline BaseError _error(self, int16_t ret): |
| 132 | return iDeviceError(ret) | 135 | return iDeviceError(ret) |
| 133 | 136 | ||
| 137 | cimport stdlib | ||
| 138 | |||
| 134 | cdef class iDevice(Base): | 139 | cdef class iDevice(Base): |
| 135 | def __cinit__(self, uuid=None, *args, **kwargs): | 140 | def __cinit__(self, object uuid=None, *args, **kwargs): |
| 136 | cdef: | 141 | cdef char* c_uuid = NULL |
| 137 | char* c_uuid = NULL | 142 | if isinstance(uuid, basestring): |
| 138 | idevice_error_t err | 143 | c_uuid = <bytes>uuid |
| 139 | if uuid is not None: | 144 | elif uuid is not None: |
| 140 | c_uuid = uuid | 145 | raise TypeError("iDevice's constructor takes a string or None as the uuid argument") |
| 141 | err = idevice_new(&self._c_dev, c_uuid) | 146 | self.handle_error(idevice_new(&self._c_dev, c_uuid)) |
| 142 | self.handle_error(err) | ||
| 143 | 147 | ||
| 144 | def __dealloc__(self): | 148 | def __dealloc__(self): |
| 145 | if self._c_dev is not NULL: | 149 | if self._c_dev is not NULL: |
| @@ -151,10 +155,19 @@ cdef class iDevice(Base): | |||
| 151 | cpdef iDeviceConnection connect(self, uint16_t port): | 155 | cpdef iDeviceConnection connect(self, uint16_t port): |
| 152 | cdef: | 156 | cdef: |
| 153 | idevice_error_t err | 157 | idevice_error_t err |
| 154 | iDeviceConnection conn = iDeviceConnection.__new__(iDeviceConnection) | 158 | idevice_connection_t c_conn = NULL |
| 155 | err = idevice_connect(self._c_dev, port, &conn._c_connection) | 159 | iDeviceConnection conn |
| 156 | self.handle_error(err) | 160 | err = idevice_connect(self._c_dev, port, &c_conn) |
| 157 | return conn | 161 | try: |
| 162 | self.handle_error(err) | ||
| 163 | |||
| 164 | conn = iDeviceConnection.__new__(iDeviceConnection) | ||
| 165 | conn._c_connection = c_conn | ||
| 166 | |||
| 167 | return conn | ||
| 168 | except Exception, e: | ||
| 169 | if c_conn != NULL: | ||
| 170 | idevice_disconnect(c_conn) | ||
| 158 | 171 | ||
| 159 | property uuid: | 172 | property uuid: |
| 160 | def __get__(self): | 173 | def __get__(self): |
| @@ -162,8 +175,12 @@ cdef class iDevice(Base): | |||
| 162 | char* uuid | 175 | char* uuid |
| 163 | idevice_error_t err | 176 | idevice_error_t err |
| 164 | err = idevice_get_uuid(self._c_dev, &uuid) | 177 | err = idevice_get_uuid(self._c_dev, &uuid) |
| 165 | self.handle_error(err) | 178 | try: |
| 166 | return uuid | 179 | self.handle_error(err) |
| 180 | return uuid | ||
| 181 | except Exception, e: | ||
| 182 | if uuid != NULL: | ||
| 183 | stdlib.free(uuid) | ||
| 167 | property handle: | 184 | property handle: |
| 168 | def __get__(self): | 185 | def __get__(self): |
| 169 | cdef uint32_t handle | 186 | cdef uint32_t handle |
| @@ -173,8 +190,6 @@ cdef class iDevice(Base): | |||
| 173 | cdef extern from *: | 190 | cdef extern from *: |
| 174 | ctypedef char* const_char_ptr "const char*" | 191 | ctypedef char* const_char_ptr "const char*" |
| 175 | 192 | ||
| 176 | cimport stdlib | ||
| 177 | |||
| 178 | cdef class BaseService(Base): | 193 | cdef class BaseService(Base): |
| 179 | __service_name__ = None | 194 | __service_name__ = None |
| 180 | 195 | ||
| @@ -189,13 +204,13 @@ cdef class PropertyListService(BaseService): | |||
| 189 | err = self._receive(&c_node) | 204 | err = self._receive(&c_node) |
| 190 | try: | 205 | try: |
| 191 | self.handle_error(err) | 206 | self.handle_error(err) |
| 207 | |||
| 208 | return plist.plist_t_to_node(c_node) | ||
| 192 | except BaseError, e: | 209 | except BaseError, e: |
| 193 | if c_node != NULL: | 210 | if c_node != NULL: |
| 194 | plist.plist_free(c_node) | 211 | plist.plist_free(c_node) |
| 195 | raise | 212 | raise |
| 196 | 213 | ||
| 197 | return plist.plist_t_to_node(c_node) | ||
| 198 | |||
| 199 | cdef inline int16_t _send(self, plist.plist_t node): | 214 | cdef inline int16_t _send(self, plist.plist_t node): |
| 200 | raise NotImplementedError("send is not implemented") | 215 | raise NotImplementedError("send is not implemented") |
| 201 | 216 | ||
diff --git a/cython/installation_proxy.pxi b/cython/installation_proxy.pxi index cf6662f..3dfb0b1 100644 --- a/cython/installation_proxy.pxi +++ b/cython/installation_proxy.pxi | |||
| @@ -64,71 +64,109 @@ cdef class InstallationProxyClient(PropertyListService): | |||
| 64 | plist.Node options | 64 | plist.Node options |
| 65 | plist.plist_t c_options | 65 | plist.plist_t c_options |
| 66 | plist.plist_t c_result = NULL | 66 | plist.plist_t c_result = NULL |
| 67 | bint free_options = False | ||
| 67 | instproxy_error_t err | 68 | instproxy_error_t err |
| 68 | if isinstance(client_options, plist.Dict): | 69 | if isinstance(client_options, plist.Dict): |
| 69 | options = client_options | 70 | options = client_options |
| 70 | c_options = options._c_node | 71 | c_options = options._c_node |
| 71 | elif isinstance(client_options, dict): | 72 | elif isinstance(client_options, dict): |
| 72 | c_options = plist.native_to_plist_t(client_options) | 73 | c_options = plist.native_to_plist_t(client_options) |
| 74 | free_options = True | ||
| 73 | else: | 75 | else: |
| 74 | raise InstallationProxyError(INSTPROXY_E_INVALID_ARG) | 76 | raise InstallationProxyError(INSTPROXY_E_INVALID_ARG) |
| 75 | err = instproxy_browse(self._c_client, c_options, &c_result) | 77 | err = instproxy_browse(self._c_client, c_options, &c_result) |
| 76 | self.handle_error(err) | 78 | |
| 77 | return plist.plist_t_to_node(c_result) | 79 | try: |
| 80 | self.handle_error(err) | ||
| 81 | return plist.plist_t_to_node(c_result) | ||
| 82 | except Exception, e: | ||
| 83 | if c_result != NULL: | ||
| 84 | plist.plist_free(c_result) | ||
| 85 | raise | ||
| 86 | finally: | ||
| 87 | if free_options: | ||
| 88 | plist.plist_free(c_options) | ||
| 78 | 89 | ||
| 79 | cpdef install(self, bytes pkg_path, object client_options, object callback=None): | 90 | cpdef install(self, bytes pkg_path, object client_options, object callback=None): |
| 80 | cdef: | 91 | cdef: |
| 81 | plist.Node options | 92 | plist.Node options |
| 82 | plist.plist_t c_options | 93 | plist.plist_t c_options |
| 94 | bint free_options = False | ||
| 83 | instproxy_error_t err | 95 | instproxy_error_t err |
| 84 | if isinstance(client_options, plist.Dict): | 96 | if isinstance(client_options, plist.Dict): |
| 85 | options = client_options | 97 | options = client_options |
| 86 | c_options = options._c_node | 98 | c_options = options._c_node |
| 87 | elif isinstance(client_options, dict): | 99 | elif isinstance(client_options, dict): |
| 88 | c_options = plist.native_to_plist_t(client_options) | 100 | c_options = plist.native_to_plist_t(client_options) |
| 101 | free_options = True | ||
| 89 | else: | 102 | else: |
| 90 | raise InstallationProxyError(INSTPROXY_E_INVALID_ARG) | 103 | raise InstallationProxyError(INSTPROXY_E_INVALID_ARG) |
| 91 | if callback is None: | 104 | if callback is None: |
| 92 | err = instproxy_install(self._c_client, pkg_path, options._c_node, NULL, NULL) | 105 | err = instproxy_install(self._c_client, pkg_path, c_options, NULL, NULL) |
| 93 | else: | 106 | else: |
| 94 | err = instproxy_install(self._c_client, pkg_path, options._c_node, instproxy_notify_cb, <void*>callback) | 107 | err = instproxy_install(self._c_client, pkg_path, c_options, instproxy_notify_cb, <void*>callback) |
| 95 | self.handle_error(err) | 108 | |
| 109 | try: | ||
| 110 | self.handle_error(err) | ||
| 111 | except Exception, e: | ||
| 112 | raise | ||
| 113 | finally: | ||
| 114 | if free_options: | ||
| 115 | plist.plist_free(c_options) | ||
| 96 | 116 | ||
| 97 | cpdef upgrade(self, bytes pkg_path, object client_options, object callback=None): | 117 | cpdef upgrade(self, bytes pkg_path, object client_options, object callback=None): |
| 98 | cdef: | 118 | cdef: |
| 99 | plist.Node options | 119 | plist.Node options |
| 100 | plist.plist_t c_options | 120 | plist.plist_t c_options |
| 121 | bint free_options = False | ||
| 101 | instproxy_error_t err | 122 | instproxy_error_t err |
| 102 | if isinstance(client_options, plist.Dict): | 123 | if isinstance(client_options, plist.Dict): |
| 103 | options = client_options | 124 | options = client_options |
| 104 | c_options = options._c_node | 125 | c_options = options._c_node |
| 105 | elif isinstance(client_options, dict): | 126 | elif isinstance(client_options, dict): |
| 106 | c_options = plist.native_to_plist_t(client_options) | 127 | c_options = plist.native_to_plist_t(client_options) |
| 128 | free_options = True | ||
| 107 | else: | 129 | else: |
| 108 | raise InstallationProxyError(INSTPROXY_E_INVALID_ARG) | 130 | raise InstallationProxyError(INSTPROXY_E_INVALID_ARG) |
| 109 | if callback is None: | 131 | if callback is None: |
| 110 | err = instproxy_upgrade(self._c_client, pkg_path, options._c_node, NULL, NULL) | 132 | err = instproxy_upgrade(self._c_client, pkg_path, c_options, NULL, NULL) |
| 111 | else: | 133 | else: |
| 112 | err = instproxy_upgrade(self._c_client, pkg_path, options._c_node, instproxy_notify_cb, <void*>callback) | 134 | err = instproxy_upgrade(self._c_client, pkg_path, c_options, instproxy_notify_cb, <void*>callback) |
| 113 | self.handle_error(err) | 135 | try: |
| 136 | self.handle_error(err) | ||
| 137 | except Exception, e: | ||
| 138 | raise | ||
| 139 | finally: | ||
| 140 | if free_options: | ||
| 141 | plist.plist_free(c_options) | ||
| 114 | 142 | ||
| 115 | cpdef uninstall(self, bytes appid, object client_options, object callback=None): | 143 | cpdef uninstall(self, bytes appid, object client_options, object callback=None): |
| 116 | cdef: | 144 | cdef: |
| 117 | plist.Node options | 145 | plist.Node options |
| 118 | plist.plist_t c_options | 146 | plist.plist_t c_options |
| 119 | instproxy_error_t err | 147 | instproxy_error_t err |
| 148 | bint free_options = False | ||
| 120 | if isinstance(client_options, plist.Dict): | 149 | if isinstance(client_options, plist.Dict): |
| 121 | options = client_options | 150 | options = client_options |
| 122 | c_options = options._c_node | 151 | c_options = options._c_node |
| 123 | elif isinstance(client_options, dict): | 152 | elif isinstance(client_options, dict): |
| 124 | c_options = plist.native_to_plist_t(client_options) | 153 | c_options = plist.native_to_plist_t(client_options) |
| 154 | free_options = True | ||
| 125 | else: | 155 | else: |
| 126 | raise InstallationProxyError(INSTPROXY_E_INVALID_ARG) | 156 | raise InstallationProxyError(INSTPROXY_E_INVALID_ARG) |
| 157 | |||
| 127 | if callback is None: | 158 | if callback is None: |
| 128 | err = instproxy_uninstall(self._c_client, appid, options._c_node, NULL, NULL) | 159 | err = instproxy_uninstall(self._c_client, appid, c_options, NULL, NULL) |
| 129 | else: | 160 | else: |
| 130 | err = instproxy_uninstall(self._c_client, appid, options._c_node, instproxy_notify_cb, <void*>callback) | 161 | err = instproxy_uninstall(self._c_client, appid, c_options, instproxy_notify_cb, <void*>callback) |
| 131 | self.handle_error(err) | 162 | |
| 163 | try: | ||
| 164 | self.handle_error(err) | ||
| 165 | except Exception, e: | ||
| 166 | raise | ||
| 167 | finally: | ||
| 168 | if free_options: | ||
| 169 | plist.plist_free(c_options) | ||
| 132 | 170 | ||
| 133 | cpdef plist.Node lookup_archives(self, object client_options): | 171 | cpdef plist.Node lookup_archives(self, object client_options): |
| 134 | cdef: | 172 | cdef: |
| @@ -136,70 +174,112 @@ cdef class InstallationProxyClient(PropertyListService): | |||
| 136 | plist.plist_t c_options | 174 | plist.plist_t c_options |
| 137 | plist.plist_t c_node = NULL | 175 | plist.plist_t c_node = NULL |
| 138 | instproxy_error_t err | 176 | instproxy_error_t err |
| 177 | bint free_options = False | ||
| 139 | if isinstance(client_options, plist.Dict): | 178 | if isinstance(client_options, plist.Dict): |
| 140 | options = client_options | 179 | options = client_options |
| 141 | c_options = options._c_node | 180 | c_options = options._c_node |
| 142 | elif isinstance(client_options, dict): | 181 | elif isinstance(client_options, dict): |
| 143 | c_options = plist.native_to_plist_t(client_options) | 182 | c_options = plist.native_to_plist_t(client_options) |
| 183 | free_options = True | ||
| 144 | else: | 184 | else: |
| 145 | raise InstallationProxyError(INSTPROXY_E_INVALID_ARG) | 185 | raise InstallationProxyError(INSTPROXY_E_INVALID_ARG) |
| 146 | err = instproxy_lookup_archives(self._c_client, options._c_node, &c_node) | 186 | |
| 147 | self.handle_error(err) | 187 | err = instproxy_lookup_archives(self._c_client, c_options, &c_node) |
| 148 | return plist.plist_t_to_node(c_node) | 188 | |
| 189 | try: | ||
| 190 | self.handle_error(err) | ||
| 191 | return plist.plist_t_to_node(c_node) | ||
| 192 | except Exception, e: | ||
| 193 | if c_node != NULL: | ||
| 194 | plist.plist_free(c_node) | ||
| 195 | raise | ||
| 196 | finally: | ||
| 197 | if free_options: | ||
| 198 | plist.plist_free(c_options) | ||
| 149 | 199 | ||
| 150 | cpdef archive(self, bytes appid, object client_options, object callback=None): | 200 | cpdef archive(self, bytes appid, object client_options, object callback=None): |
| 151 | cdef: | 201 | cdef: |
| 152 | plist.Node options | 202 | plist.Node options |
| 153 | plist.plist_t c_options | 203 | plist.plist_t c_options |
| 204 | bint free_options = False | ||
| 154 | instproxy_error_t err | 205 | instproxy_error_t err |
| 155 | if isinstance(client_options, plist.Dict): | 206 | if isinstance(client_options, plist.Dict): |
| 156 | options = client_options | 207 | options = client_options |
| 157 | c_options = options._c_node | 208 | c_options = options._c_node |
| 158 | elif isinstance(client_options, dict): | 209 | elif isinstance(client_options, dict): |
| 159 | c_options = plist.native_to_plist_t(client_options) | 210 | c_options = plist.native_to_plist_t(client_options) |
| 211 | free_options = True | ||
| 160 | else: | 212 | else: |
| 161 | raise InstallationProxyError(INSTPROXY_E_INVALID_ARG) | 213 | raise InstallationProxyError(INSTPROXY_E_INVALID_ARG) |
| 214 | |||
| 162 | if callback is None: | 215 | if callback is None: |
| 163 | err = instproxy_archive(self._c_client, appid, options._c_node, NULL, NULL) | 216 | err = instproxy_archive(self._c_client, appid, c_options, NULL, NULL) |
| 164 | else: | 217 | else: |
| 165 | err = instproxy_archive(self._c_client, appid, options._c_node, instproxy_notify_cb, <void*>callback) | 218 | err = instproxy_archive(self._c_client, appid, c_options, instproxy_notify_cb, <void*>callback) |
| 166 | self.handle_error(err) | 219 | |
| 220 | try: | ||
| 221 | self.handle_error(err) | ||
| 222 | except Exception, e: | ||
| 223 | raise | ||
| 224 | finally: | ||
| 225 | if free_options: | ||
| 226 | plist.plist_free(c_options) | ||
| 167 | 227 | ||
| 168 | cpdef restore(self, bytes appid, object client_options, object callback=None): | 228 | cpdef restore(self, bytes appid, object client_options, object callback=None): |
| 169 | cdef: | 229 | cdef: |
| 170 | plist.Node options | 230 | plist.Node options |
| 171 | plist.plist_t c_options | 231 | plist.plist_t c_options |
| 232 | bint free_options = False | ||
| 172 | instproxy_error_t err | 233 | instproxy_error_t err |
| 173 | if isinstance(client_options, plist.Dict): | 234 | if isinstance(client_options, plist.Dict): |
| 174 | options = client_options | 235 | options = client_options |
| 175 | c_options = options._c_node | 236 | c_options = options._c_node |
| 176 | elif isinstance(client_options, dict): | 237 | elif isinstance(client_options, dict): |
| 177 | c_options = plist.native_to_plist_t(client_options) | 238 | c_options = plist.native_to_plist_t(client_options) |
| 239 | free_options = True | ||
| 178 | else: | 240 | else: |
| 179 | raise InstallationProxyError(INSTPROXY_E_INVALID_ARG) | 241 | raise InstallationProxyError(INSTPROXY_E_INVALID_ARG) |
| 242 | |||
| 180 | if callback is None: | 243 | if callback is None: |
| 181 | err = instproxy_restore(self._c_client, appid, options._c_node, NULL, NULL) | 244 | err = instproxy_restore(self._c_client, appid, c_options, NULL, NULL) |
| 182 | else: | 245 | else: |
| 183 | err = instproxy_restore(self._c_client, appid, options._c_node, instproxy_notify_cb, <void*>callback) | 246 | err = instproxy_restore(self._c_client, appid, c_options, instproxy_notify_cb, <void*>callback) |
| 184 | self.handle_error(err) | 247 | |
| 248 | try: | ||
| 249 | self.handle_error(err) | ||
| 250 | except Exception, e: | ||
| 251 | raise | ||
| 252 | finally: | ||
| 253 | if free_options: | ||
| 254 | plist.plist_free(c_options) | ||
| 185 | 255 | ||
| 186 | cpdef remove_archive(self, bytes appid, object client_options, object callback=None): | 256 | cpdef remove_archive(self, bytes appid, object client_options, object callback=None): |
| 187 | cdef: | 257 | cdef: |
| 188 | plist.Node options | 258 | plist.Node options |
| 189 | plist.plist_t c_options | 259 | plist.plist_t c_options |
| 260 | bint free_options = False | ||
| 190 | instproxy_error_t err | 261 | instproxy_error_t err |
| 191 | if isinstance(client_options, plist.Dict): | 262 | if isinstance(client_options, plist.Dict): |
| 192 | options = client_options | 263 | options = client_options |
| 193 | c_options = options._c_node | 264 | c_options = options._c_node |
| 194 | elif isinstance(client_options, dict): | 265 | elif isinstance(client_options, dict): |
| 195 | c_options = plist.native_to_plist_t(client_options) | 266 | c_options = plist.native_to_plist_t(client_options) |
| 267 | free_options = True | ||
| 196 | else: | 268 | else: |
| 197 | raise InstallationProxyError(INSTPROXY_E_INVALID_ARG) | 269 | raise InstallationProxyError(INSTPROXY_E_INVALID_ARG) |
| 270 | |||
| 198 | if callback is None: | 271 | if callback is None: |
| 199 | err = instproxy_remove_archive(self._c_client, appid, options._c_node, NULL, NULL) | 272 | err = instproxy_remove_archive(self._c_client, appid, c_options, NULL, NULL) |
| 200 | else: | 273 | else: |
| 201 | err = instproxy_remove_archive(self._c_client, appid, options._c_node, instproxy_notify_cb, <void*>callback) | 274 | err = instproxy_remove_archive(self._c_client, appid, c_options, instproxy_notify_cb, <void*>callback) |
| 202 | self.handle_error(err) | 275 | |
| 276 | try: | ||
| 277 | self.handle_error(err) | ||
| 278 | except Exception, e: | ||
| 279 | raise | ||
| 280 | finally: | ||
| 281 | if free_options: | ||
| 282 | plist.plist_free(c_options) | ||
| 203 | 283 | ||
| 204 | cdef inline BaseError _error(self, int16_t ret): | 284 | cdef inline BaseError _error(self, int16_t ret): |
| 205 | return InstallationProxyError(ret) | 285 | return InstallationProxyError(ret) |
diff --git a/cython/lockdown.pxi b/cython/lockdown.pxi index be9d25f..a904d12 100644 --- a/cython/lockdown.pxi +++ b/cython/lockdown.pxi | |||
| @@ -90,18 +90,17 @@ cdef class LockdownPairRecord: | |||
| 90 | cdef class LockdownClient(PropertyListService): | 90 | cdef class LockdownClient(PropertyListService): |
| 91 | def __cinit__(self, iDevice device not None, bytes label="", bool handshake=True, *args, **kwargs): | 91 | def __cinit__(self, iDevice device not None, bytes label="", bool handshake=True, *args, **kwargs): |
| 92 | cdef: | 92 | cdef: |
| 93 | iDevice dev = device | ||
| 94 | lockdownd_error_t err | 93 | lockdownd_error_t err |
| 95 | char* c_label = NULL | 94 | char* c_label = NULL |
| 96 | if label: | 95 | if label: |
| 97 | c_label = label | 96 | c_label = label |
| 98 | if handshake: | 97 | if handshake: |
| 99 | err = lockdownd_client_new_with_handshake(dev._c_dev, &self._c_client, c_label) | 98 | err = lockdownd_client_new_with_handshake(device._c_dev, &self._c_client, c_label) |
| 100 | else: | 99 | else: |
| 101 | err = lockdownd_client_new(dev._c_dev, &self._c_client, c_label) | 100 | err = lockdownd_client_new(device._c_dev, &self._c_client, c_label) |
| 102 | self.handle_error(err) | 101 | self.handle_error(err) |
| 103 | 102 | ||
| 104 | self.device = dev | 103 | self.device = device |
| 105 | 104 | ||
| 106 | def __dealloc__(self): | 105 | def __dealloc__(self): |
| 107 | cdef lockdownd_error_t err | 106 | cdef lockdownd_error_t err |
| @@ -117,15 +116,15 @@ cdef class LockdownClient(PropertyListService): | |||
| 117 | err = lockdownd_query_type(self._c_client, &c_type) | 116 | err = lockdownd_query_type(self._c_client, &c_type) |
| 118 | try: | 117 | try: |
| 119 | self.handle_error(err) | 118 | self.handle_error(err) |
| 119 | result = c_type | ||
| 120 | |||
| 121 | return result | ||
| 120 | except BaseError, e: | 122 | except BaseError, e: |
| 121 | raise | 123 | raise |
| 122 | finally: | 124 | finally: |
| 123 | if c_type != NULL: | 125 | if c_type != NULL: |
| 124 | result = c_type | ||
| 125 | stdlib.free(c_type) | 126 | stdlib.free(c_type) |
| 126 | 127 | ||
| 127 | return result | ||
| 128 | |||
| 129 | cpdef plist.Node get_value(self, bytes domain=None, bytes key=None): | 128 | cpdef plist.Node get_value(self, bytes domain=None, bytes key=None): |
| 130 | cdef: | 129 | cdef: |
| 131 | lockdownd_error_t err | 130 | lockdownd_error_t err |
| @@ -136,16 +135,18 @@ cdef class LockdownClient(PropertyListService): | |||
| 136 | c_domain = domain | 135 | c_domain = domain |
| 137 | if key is not None: | 136 | if key is not None: |
| 138 | c_key = key | 137 | c_key = key |
| 138 | |||
| 139 | err = lockdownd_get_value(self._c_client, c_domain, c_key, &c_node) | 139 | err = lockdownd_get_value(self._c_client, c_domain, c_key, &c_node) |
| 140 | |||
| 140 | try: | 141 | try: |
| 141 | self.handle_error(err) | 142 | self.handle_error(err) |
| 143 | |||
| 144 | return plist.plist_t_to_node(c_node) | ||
| 142 | except BaseError, e: | 145 | except BaseError, e: |
| 143 | if c_node != NULL: | 146 | if c_node != NULL: |
| 144 | plist.plist_free(c_node) | 147 | plist.plist_free(c_node) |
| 145 | raise | 148 | raise |
| 146 | 149 | ||
| 147 | return plist.plist_t_to_node(c_node) | ||
| 148 | |||
| 149 | cpdef set_value(self, bytes domain, bytes key, object value): | 150 | cpdef set_value(self, bytes domain, bytes key, object value): |
| 150 | cdef plist.plist_t c_node = plist.native_to_plist_t(value) | 151 | cdef plist.plist_t c_node = plist.native_to_plist_t(value) |
| 151 | try: | 152 | try: |
| @@ -175,11 +176,11 @@ cdef class LockdownClient(PropertyListService): | |||
| 175 | 176 | ||
| 176 | try: | 177 | try: |
| 177 | self.handle_error(lockdownd_start_service(self._c_client, c_service_name, &port)) | 178 | self.handle_error(lockdownd_start_service(self._c_client, c_service_name, &port)) |
| 179 | |||
| 180 | return port | ||
| 178 | except BaseError, e: | 181 | except BaseError, e: |
| 179 | raise | 182 | raise |
| 180 | 183 | ||
| 181 | return port | ||
| 182 | |||
| 183 | cpdef object get_service_client(self, object service_class): | 184 | cpdef object get_service_client(self, object service_class): |
| 184 | cdef: | 185 | cdef: |
| 185 | uint16_t port = 0 | 186 | uint16_t port = 0 |
| @@ -202,15 +203,15 @@ cdef class LockdownClient(PropertyListService): | |||
| 202 | err = lockdownd_start_session(self._c_client, host_id, &c_session_id, &ssl_enabled) | 203 | err = lockdownd_start_session(self._c_client, host_id, &c_session_id, &ssl_enabled) |
| 203 | try: | 204 | try: |
| 204 | self.handle_error(err) | 205 | self.handle_error(err) |
| 206 | |||
| 207 | session_id = c_session_id | ||
| 208 | return (session_id, ssl_enabled) | ||
| 205 | except BaseError, e: | 209 | except BaseError, e: |
| 206 | raise | 210 | raise |
| 207 | finally: | 211 | finally: |
| 208 | if c_session_id != NULL: | 212 | if c_session_id != NULL: |
| 209 | session_id = c_session_id | ||
| 210 | stdlib.free(c_session_id) | 213 | stdlib.free(c_session_id) |
| 211 | 214 | ||
| 212 | return (session_id, ssl_enabled) | ||
| 213 | |||
| 214 | cpdef stop_session(self, bytes session_id): | 215 | cpdef stop_session(self, bytes session_id): |
| 215 | self.handle_error(lockdownd_stop_session(self._c_client, session_id)) | 216 | self.handle_error(lockdownd_stop_session(self._c_client, session_id)) |
| 216 | 217 | ||
diff --git a/cython/mobile_image_mounter.pxi b/cython/mobile_image_mounter.pxi index e70cff7..bf304d4 100644 --- a/cython/mobile_image_mounter.pxi +++ b/cython/mobile_image_mounter.pxi | |||
| @@ -32,11 +32,7 @@ cdef class MobileImageMounterClient(PropertyListService): | |||
| 32 | cdef mobile_image_mounter_client_t _c_client | 32 | cdef mobile_image_mounter_client_t _c_client |
| 33 | 33 | ||
| 34 | def __cinit__(self, iDevice device not None, int port, *args, **kwargs): | 34 | def __cinit__(self, iDevice device not None, int port, *args, **kwargs): |
| 35 | cdef: | 35 | self.handle_error(mobile_image_mounter_new(device._c_dev, port, &self._c_client)) |
| 36 | iDevice dev = device | ||
| 37 | mobile_image_mounter_error_t err | ||
| 38 | err = mobile_image_mounter_new(dev._c_dev, port, &self._c_client) | ||
| 39 | self.handle_error(err) | ||
| 40 | 36 | ||
| 41 | def __dealloc__(self): | 37 | def __dealloc__(self): |
| 42 | cdef mobile_image_mounter_error_t err | 38 | cdef mobile_image_mounter_error_t err |
| @@ -52,8 +48,14 @@ cdef class MobileImageMounterClient(PropertyListService): | |||
| 52 | plist.plist_t c_node = NULL | 48 | plist.plist_t c_node = NULL |
| 53 | mobile_image_mounter_error_t err | 49 | mobile_image_mounter_error_t err |
| 54 | err = mobile_image_mounter_lookup_image(self._c_client, image_type, &c_node) | 50 | err = mobile_image_mounter_lookup_image(self._c_client, image_type, &c_node) |
| 55 | self.handle_error(err) | 51 | |
| 56 | return plist.plist_t_to_node(c_node) | 52 | try: |
| 53 | self.handle_error(err) | ||
| 54 | |||
| 55 | return plist.plist_t_to_node(c_node) | ||
| 56 | except Exception, e: | ||
| 57 | if c_node != NULL: | ||
| 58 | plist.plist_free(c_node) | ||
| 57 | 59 | ||
| 58 | cpdef plist.Node mount_image(self, bytes image_path, bytes image_signature, bytes image_type): | 60 | cpdef plist.Node mount_image(self, bytes image_path, bytes image_signature, bytes image_type): |
| 59 | cdef: | 61 | cdef: |
| @@ -61,8 +63,14 @@ cdef class MobileImageMounterClient(PropertyListService): | |||
| 61 | mobile_image_mounter_error_t err | 63 | mobile_image_mounter_error_t err |
| 62 | err = mobile_image_mounter_mount_image(self._c_client, image_path, image_signature, len(image_signature), | 64 | err = mobile_image_mounter_mount_image(self._c_client, image_path, image_signature, len(image_signature), |
| 63 | image_type, &c_node) | 65 | image_type, &c_node) |
| 64 | self.handle_error(err) | 66 | |
| 65 | return plist.plist_t_to_node(c_node) | 67 | try: |
| 68 | self.handle_error(err) | ||
| 69 | |||
| 70 | return plist.plist_t_to_node(c_node) | ||
| 71 | except Exception, e: | ||
| 72 | if c_node != NULL: | ||
| 73 | plist.plist_free(c_node) | ||
| 66 | 74 | ||
| 67 | cpdef hangup(self): | 75 | cpdef hangup(self): |
| 68 | cdef mobile_image_mounter_error_t err | 76 | cdef mobile_image_mounter_error_t err |
diff --git a/cython/mobilebackup.pxi b/cython/mobilebackup.pxi index cb5276e..4f07683 100644 --- a/cython/mobilebackup.pxi +++ b/cython/mobilebackup.pxi | |||
| @@ -33,11 +33,7 @@ cdef class MobileBackupClient(PropertyListService): | |||
| 33 | cdef mobilebackup_client_t _c_client | 33 | cdef mobilebackup_client_t _c_client |
| 34 | 34 | ||
| 35 | def __cinit__(self, iDevice device not None, int port, *args, **kwargs): | 35 | def __cinit__(self, iDevice device not None, int port, *args, **kwargs): |
| 36 | cdef: | 36 | self.handle_error(mobilebackup_client_new(device._c_dev, port, &self._c_client)) |
| 37 | iDevice dev = device | ||
| 38 | mobilebackup_error_t err | ||
| 39 | err = mobilebackup_client_new(dev._c_dev, port, &self._c_client) | ||
| 40 | self.handle_error(err) | ||
| 41 | 37 | ||
| 42 | def __dealloc__(self): | 38 | def __dealloc__(self): |
| 43 | cdef mobilebackup_error_t err | 39 | cdef mobilebackup_error_t err |
diff --git a/cython/mobilesync.pxi b/cython/mobilesync.pxi index 1b36ba7..00b511f 100644 --- a/cython/mobilesync.pxi +++ b/cython/mobilesync.pxi | |||
| @@ -33,11 +33,7 @@ cdef class MobileSyncClient(DeviceLinkService): | |||
| 33 | cdef mobilesync_client_t _c_client | 33 | cdef mobilesync_client_t _c_client |
| 34 | 34 | ||
| 35 | def __cinit__(self, iDevice device not None, int port, *args, **kwargs): | 35 | def __cinit__(self, iDevice device not None, int port, *args, **kwargs): |
| 36 | cdef: | 36 | self.handle_error(mobilesync_client_new(device._c_dev, port, &(self._c_client))) |
| 37 | iDevice dev = device | ||
| 38 | mobilesync_error_t err | ||
| 39 | err = mobilesync_client_new(dev._c_dev, port, &(self._c_client)) | ||
| 40 | self.handle_error(err) | ||
| 41 | 37 | ||
| 42 | def __dealloc__(self): | 38 | def __dealloc__(self): |
| 43 | cdef mobilesync_error_t err | 39 | cdef mobilesync_error_t err |
diff --git a/cython/notification_proxy.pxi b/cython/notification_proxy.pxi index ccc30f8..07a72d9 100644 --- a/cython/notification_proxy.pxi +++ b/cython/notification_proxy.pxi | |||
| @@ -89,11 +89,7 @@ cdef class NotificationProxyClient(PropertyListService): | |||
| 89 | cdef np_client_t _c_client | 89 | cdef np_client_t _c_client |
| 90 | 90 | ||
| 91 | def __cinit__(self, iDevice device not None, int port, *args, **kwargs): | 91 | def __cinit__(self, iDevice device not None, int port, *args, **kwargs): |
| 92 | cdef: | 92 | self.handle_error(np_client_new(device._c_dev, port, &self._c_client)) |
| 93 | iDevice dev = device | ||
| 94 | np_error_t err | ||
| 95 | err = np_client_new(dev._c_dev, port, &self._c_client) | ||
| 96 | self.handle_error(err) | ||
| 97 | 93 | ||
| 98 | def __dealloc__(self): | 94 | def __dealloc__(self): |
| 99 | cdef np_error_t err | 95 | cdef np_error_t err |
diff --git a/cython/sbservices.pxi b/cython/sbservices.pxi index 55c94a5..4d09b71 100644 --- a/cython/sbservices.pxi +++ b/cython/sbservices.pxi | |||
| @@ -30,14 +30,12 @@ cdef class SpringboardServicesClient(PropertyListService): | |||
| 30 | cdef sbservices_client_t _c_client | 30 | cdef sbservices_client_t _c_client |
| 31 | 31 | ||
| 32 | def __cinit__(self, iDevice device not None, int port, *args, **kwargs): | 32 | def __cinit__(self, iDevice device not None, int port, *args, **kwargs): |
| 33 | cdef: | 33 | self.handle_error(sbservices_client_new(device._c_dev, port, &self._c_client)) |
| 34 | iDevice dev = device | ||
| 35 | self.handle_error(sbservices_client_new(dev._c_dev, port, &self._c_client)) | ||
| 36 | 34 | ||
| 37 | def __dealloc__(self): | 35 | def __dealloc__(self): |
| 38 | if self._c_client is not NULL: | 36 | if self._c_client is not NULL: |
| 39 | err = SpringboardServicesError(sbservices_client_free(self._c_client)) | 37 | err = sbservices_client_free(self._c_client) |
| 40 | if err: raise err | 38 | self.handle_error(err) |
| 41 | 39 | ||
| 42 | cdef inline BaseError _error(self, int16_t ret): | 40 | cdef inline BaseError _error(self, int16_t ret): |
| 43 | return SpringboardServicesError(ret) | 41 | return SpringboardServicesError(ret) |
| @@ -50,11 +48,12 @@ cdef class SpringboardServicesClient(PropertyListService): | |||
| 50 | err = sbservices_get_icon_state(self._c_client, &c_node) | 48 | err = sbservices_get_icon_state(self._c_client, &c_node) |
| 51 | try: | 49 | try: |
| 52 | self.handle_error(err) | 50 | self.handle_error(err) |
| 51 | |||
| 52 | return plist.plist_t_to_node(c_node) | ||
| 53 | except BaseError, e: | 53 | except BaseError, e: |
| 54 | if c_node != NULL: | 54 | if c_node != NULL: |
| 55 | plist.plist_free(c_node) | 55 | plist.plist_free(c_node) |
| 56 | raise | 56 | raise |
| 57 | return plist.plist_t_to_node(c_node) | ||
| 58 | def __set__(self, plist.Node newstate not None): | 57 | def __set__(self, plist.Node newstate not None): |
| 59 | self.handle_error(sbservices_set_icon_state(self._c_client, newstate._c_node)) | 58 | self.handle_error(sbservices_set_icon_state(self._c_client, newstate._c_node)) |
| 60 | 59 | ||
| @@ -66,7 +65,8 @@ cdef class SpringboardServicesClient(PropertyListService): | |||
| 66 | err = sbservices_get_icon_pngdata(self._c_client, bundleId, &pngdata, &pngsize) | 65 | err = sbservices_get_icon_pngdata(self._c_client, bundleId, &pngdata, &pngsize) |
| 67 | try: | 66 | try: |
| 68 | self.handle_error(err) | 67 | self.handle_error(err) |
| 68 | |||
| 69 | return pngdata[:pngsize] | ||
| 69 | except BaseError, e: | 70 | except BaseError, e: |
| 70 | stdlib.free(pngdata) | 71 | stdlib.free(pngdata) |
| 71 | raise | 72 | raise |
| 72 | return pngdata[:pngsize] | ||
diff --git a/cython/screenshotr.pxi b/cython/screenshotr.pxi index d7dfc57..9213b64 100644 --- a/cython/screenshotr.pxi +++ b/cython/screenshotr.pxi | |||
| @@ -32,11 +32,7 @@ cdef class ScreenshotrClient(DeviceLinkService): | |||
| 32 | cdef screenshotr_client_t _c_client | 32 | cdef screenshotr_client_t _c_client |
| 33 | 33 | ||
| 34 | def __cinit__(self, iDevice device not None, int port, *args, **kwargs): | 34 | def __cinit__(self, iDevice device not None, int port, *args, **kwargs): |
| 35 | cdef: | 35 | self.handle_error(screenshotr_client_new(device._c_dev, port, &self._c_client)) |
| 36 | iDevice dev = device | ||
| 37 | screenshotr_error_t err | ||
| 38 | err = screenshotr_client_new(dev._c_dev, port, &self._c_client) | ||
| 39 | self.handle_error(err) | ||
| 40 | 36 | ||
| 41 | def __dealloc__(self): | 37 | def __dealloc__(self): |
| 42 | cdef screenshotr_error_t err | 38 | cdef screenshotr_error_t err |
| @@ -46,15 +42,21 @@ cdef class ScreenshotrClient(DeviceLinkService): | |||
| 46 | 42 | ||
| 47 | cpdef bytes take_screenshot(self): | 43 | cpdef bytes take_screenshot(self): |
| 48 | cdef: | 44 | cdef: |
| 49 | char* c_data | 45 | char* c_data = NULL |
| 50 | uint64_t data_size | 46 | uint64_t data_size |
| 51 | bytes result | 47 | bytes result |
| 52 | screenshotr_error_t err | 48 | screenshotr_error_t err |
| 53 | 49 | ||
| 54 | err = screenshotr_take_screenshot(self._c_client, &c_data, &data_size) | 50 | err = screenshotr_take_screenshot(self._c_client, &c_data, &data_size) |
| 55 | self.handle_error(err) | 51 | try: |
| 56 | result = c_data[:data_size] | 52 | self.handle_error(err) |
| 57 | return result | 53 | |
| 54 | result = c_data[:data_size] | ||
| 55 | return result | ||
| 56 | except Exception, e: | ||
| 57 | if c_data != NULL: | ||
| 58 | stdlib.free(c_data) | ||
| 59 | raise | ||
| 58 | 60 | ||
| 59 | cdef inline BaseError _error(self, int16_t ret): | 61 | cdef inline BaseError _error(self, int16_t ret): |
| 60 | return ScreenshotrError(ret) | 62 | return ScreenshotrError(ret) |
