summaryrefslogtreecommitdiffstats
path: root/cython/mobilesync.pxi
diff options
context:
space:
mode:
authorGravatar Bryan Forbes2010-03-17 10:27:44 -0500
committerGravatar Martin Szulecki2012-03-20 23:25:54 +0100
commit68c63cc1382326e7f0cb4e6bd863427f9069ca05 (patch)
treed4094cb7f98cdb081e614c519f6cf8d0f9080c18 /cython/mobilesync.pxi
parentcfe6244f8954efce4ef12b9b4338cc0d41a9ff40 (diff)
downloadlibimobiledevice-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.pxi28
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):
}
BaseError.__init__(self, *args, **kwargs)
-cdef class MobileSyncClient(PropertyListService):
+cdef class MobileSyncClient(PropertyListClient):
cdef mobilesync_client_t _c_client
def __cinit__(self, iDevice device not None, LockdownClient lockdown=None, *args, **kwargs):
- cdef iDevice dev = device
- cdef LockdownClient lckd
+ cdef:
+ iDevice dev = device
+ LockdownClient lckd
+ mobilesync_error_t err
if lockdown is None:
lckd = LockdownClient(dev)
else:
lckd = lockdown
port = lckd.start_service("com.apple.mobilesync")
- err = MobileSyncError(mobilesync_client_new(dev._c_dev, port, &(self._c_client)))
- if err: raise err
+ err = mobilesync_client_new(dev._c_dev, port, &(self._c_client))
+ self.handle_error(err)
def __dealloc__(self):
+ cdef mobilesync_error_t err
if self._c_client is not NULL:
- err = MobileSyncError(mobilesync_client_free(self._c_client))
- if err: raise err
+ err = mobilesync_client_free(self._c_client)
+ self.handle_error(err)
- cdef _send(self, plist.plist_t node):
- return MobileSyncError(mobilesync_send(self._c_client, node))
+ cdef inline int16_t _send(self, plist.plist_t node):
+ return mobilesync_send(self._c_client, node)
- cdef _receive(self, plist.plist_t* node):
- return MobileSyncError(mobilesync_receive(self._c_client, node))
+ cdef inline int16_t _receive(self, plist.plist_t* node):
+ return mobilesync_receive(self._c_client, node)
+
+ cdef inline BaseError _error(self, int16_t ret):
+ return MobileSyncError(ret)