diff options
| author | 2010-03-17 10:27:44 -0500 | |
|---|---|---|
| committer | 2012-03-20 23:25:54 +0100 | |
| commit | 68c63cc1382326e7f0cb4e6bd863427f9069ca05 (patch) | |
| tree | d4094cb7f98cdb081e614c519f6cf8d0f9080c18 /cython/mobilesync.pxi | |
| parent | cfe6244f8954efce4ef12b9b4338cc0d41a9ff40 (diff) | |
| download | libimobiledevice-68c63cc1382326e7f0cb4e6bd863427f9069ca05.tar.gz libimobiledevice-68c63cc1382326e7f0cb4e6bd863427f9069ca05.tar.bz2 | |
Added base class for more efficient error handling.
Diffstat (limited to 'cython/mobilesync.pxi')
| -rw-r--r-- | cython/mobilesync.pxi | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/cython/mobilesync.pxi b/cython/mobilesync.pxi index b9cf951..abd56b4 100644 --- a/cython/mobilesync.pxi +++ b/cython/mobilesync.pxi | |||
| @@ -28,27 +28,33 @@ cdef class MobileSyncError(BaseError): | |||
| 28 | } | 28 | } |
| 29 | BaseError.__init__(self, *args, **kwargs) | 29 | BaseError.__init__(self, *args, **kwargs) |
| 30 | 30 | ||
| 31 | cdef class MobileSyncClient(PropertyListService): | 31 | cdef class MobileSyncClient(PropertyListClient): |
| 32 | cdef mobilesync_client_t _c_client | 32 | cdef mobilesync_client_t _c_client |
| 33 | 33 | ||
| 34 | def __cinit__(self, iDevice device not None, LockdownClient lockdown=None, *args, **kwargs): | 34 | def __cinit__(self, iDevice device not None, LockdownClient lockdown=None, *args, **kwargs): |
| 35 | cdef iDevice dev = device | 35 | cdef: |
| 36 | cdef LockdownClient lckd | 36 | iDevice dev = device |
| 37 | LockdownClient lckd | ||
| 38 | mobilesync_error_t err | ||
| 37 | if lockdown is None: | 39 | if lockdown is None: |
| 38 | lckd = LockdownClient(dev) | 40 | lckd = LockdownClient(dev) |
| 39 | else: | 41 | else: |
| 40 | lckd = lockdown | 42 | lckd = lockdown |
| 41 | port = lckd.start_service("com.apple.mobilesync") | 43 | port = lckd.start_service("com.apple.mobilesync") |
| 42 | err = MobileSyncError(mobilesync_client_new(dev._c_dev, port, &(self._c_client))) | 44 | err = mobilesync_client_new(dev._c_dev, port, &(self._c_client)) |
| 43 | if err: raise err | 45 | self.handle_error(err) |
| 44 | 46 | ||
| 45 | def __dealloc__(self): | 47 | def __dealloc__(self): |
| 48 | cdef mobilesync_error_t err | ||
| 46 | if self._c_client is not NULL: | 49 | if self._c_client is not NULL: |
| 47 | err = MobileSyncError(mobilesync_client_free(self._c_client)) | 50 | err = mobilesync_client_free(self._c_client) |
| 48 | if err: raise err | 51 | self.handle_error(err) |
| 49 | 52 | ||
| 50 | cdef _send(self, plist.plist_t node): | 53 | cdef inline int16_t _send(self, plist.plist_t node): |
| 51 | return MobileSyncError(mobilesync_send(self._c_client, node)) | 54 | return mobilesync_send(self._c_client, node) |
| 52 | 55 | ||
| 53 | cdef _receive(self, plist.plist_t* node): | 56 | cdef inline int16_t _receive(self, plist.plist_t* node): |
| 54 | return MobileSyncError(mobilesync_receive(self._c_client, node)) | 57 | return mobilesync_receive(self._c_client, node) |
| 58 | |||
| 59 | cdef inline BaseError _error(self, int16_t ret): | ||
| 60 | return MobileSyncError(ret) | ||
