summaryrefslogtreecommitdiffstats
path: root/cython/mobilebackup.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/mobilebackup.pxi
parentcfe6244f8954efce4ef12b9b4338cc0d41a9ff40 (diff)
downloadlibimobiledevice-68c63cc1382326e7f0cb4e6bd863427f9069ca05.tar.gz
libimobiledevice-68c63cc1382326e7f0cb4e6bd863427f9069ca05.tar.bz2
Added base class for more efficient error handling.
Diffstat (limited to 'cython/mobilebackup.pxi')
-rw-r--r--cython/mobilebackup.pxi28
1 files changed, 17 insertions, 11 deletions
diff --git a/cython/mobilebackup.pxi b/cython/mobilebackup.pxi
index 2bbaebe..f6b13a9 100644
--- a/cython/mobilebackup.pxi
+++ b/cython/mobilebackup.pxi
@@ -28,27 +28,33 @@ cdef class MobileBackupError(BaseError):
}
BaseError.__init__(self, *args, **kwargs)
-cdef class MobileBackupClient(PropertyListService):
+cdef class MobileBackupClient(PropertyListClient):
cdef mobilebackup_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
+ mobilebackup_error_t err
if lockdown is None:
lckd = LockdownClient(dev)
else:
lckd = lockdown
port = lckd.start_service("com.apple.mobilebackup")
- err = MobileBackupError(mobilebackup_client_new(dev._c_dev, port, &self._c_client))
- if err: raise err
+ err = mobilebackup_client_new(dev._c_dev, port, &self._c_client)
+ self.handle_error(err)
def __dealloc__(self):
+ cdef mobilebackup_error_t err
if self._c_client is not NULL:
- err = MobileBackupError(mobilebackup_client_free(self._c_client))
- if err: raise err
+ err = mobilebackup_client_free(self._c_client)
+ self.handle_error(err)
- cdef _send(self, plist.plist_t node):
- return MobileBackupError(mobilebackup_send(self._c_client, node))
+ cdef inline int16_t _send(self, plist.plist_t node):
+ return mobilebackup_send(self._c_client, node)
- cdef _receive(self, plist.plist_t* node):
- return MobileBackupError(mobilebackup_receive(self._c_client, node))
+ cdef inline int16_t _receive(self, plist.plist_t* node):
+ return mobilebackup_receive(self._c_client, node)
+
+ cdef inline BaseError _error(self, int16_t ret):
+ return MobileBackupError(ret)