diff options
| author | 2010-04-01 01:09:52 -0500 | |
|---|---|---|
| committer | 2012-03-20 23:25:55 +0100 | |
| commit | acac4f819ccafa6f6bb945626f2e21ec2b75074b (patch) | |
| tree | fc6881c387ee1e4527ed2b3ca73d1059bc8fc4f2 /cython/sbservices.pxi | |
| parent | af06ff22149191c056804e7fec9c1a6880a06872 (diff) | |
| download | libimobiledevice-acac4f819ccafa6f6bb945626f2e21ec2b75074b.tar.gz libimobiledevice-acac4f819ccafa6f6bb945626f2e21ec2b75074b.tar.bz2 | |
Cleaned up Makefile.am.
Added the cython m4 files.
Cleaned up afc.pxi.
Make sure the event callback and installation proxy callback aquire the GIL.
Implemented some cleanup before the error handlers raise.
Diffstat (limited to 'cython/sbservices.pxi')
| -rw-r--r-- | cython/sbservices.pxi | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/cython/sbservices.pxi b/cython/sbservices.pxi index f458bec..6eece0a 100644 --- a/cython/sbservices.pxi +++ b/cython/sbservices.pxi | |||
| @@ -29,14 +29,16 @@ cdef class SpringboardServicesClient(Base): | |||
| 29 | cdef sbservices_client_t _c_client | 29 | cdef sbservices_client_t _c_client |
| 30 | 30 | ||
| 31 | def __cinit__(self, iDevice device not None, LockdownClient lockdown=None, *args, **kwargs): | 31 | def __cinit__(self, iDevice device not None, LockdownClient lockdown=None, *args, **kwargs): |
| 32 | cdef iDevice dev = device | 32 | cdef: |
| 33 | cdef LockdownClient lckd | 33 | iDevice dev = device |
| 34 | LockdownClient lckd | ||
| 34 | if lockdown is None: | 35 | if lockdown is None: |
| 35 | lckd = LockdownClient(dev) | 36 | lckd = LockdownClient(dev) |
| 36 | else: | 37 | else: |
| 37 | lckd = lockdown | 38 | lckd = lockdown |
| 38 | port = lockdown.start_service("com.apple.springboardservices") | 39 | port = lckd.start_service("com.apple.springboardservices") |
| 39 | self.handle_error(sbservices_client_new(dev._c_dev, port, &(self._c_client))) | 40 | err = SpringboardServicesError(sbservices_client_new(dev._c_dev, port, &(self._c_client))) |
| 41 | if err: raise err | ||
| 40 | 42 | ||
| 41 | def __dealloc__(self): | 43 | def __dealloc__(self): |
| 42 | if self._c_client is not NULL: | 44 | if self._c_client is not NULL: |
| @@ -51,7 +53,14 @@ cdef class SpringboardServicesClient(Base): | |||
| 51 | cdef: | 53 | cdef: |
| 52 | plist.plist_t c_node = NULL | 54 | plist.plist_t c_node = NULL |
| 53 | plist.Node node | 55 | plist.Node node |
| 54 | self.handle_error(sbservices_get_icon_state(self._c_client, &c_node)) | 56 | sbservices_error_t err |
| 57 | err = sbservices_get_icon_state(self._c_client, &c_node) | ||
| 58 | try: | ||
| 59 | self.handle_error(err) | ||
| 60 | except BaseError, e: | ||
| 61 | if c_node != NULL: | ||
| 62 | plist_free(c_node) | ||
| 63 | raise | ||
| 55 | node = plist.plist_t_to_node(c_node) | 64 | node = plist.plist_t_to_node(c_node) |
| 56 | return node | 65 | return node |
| 57 | def __set__(self, plist.Node newstate not None): | 66 | def __set__(self, plist.Node newstate not None): |
| @@ -63,6 +72,13 @@ cdef class SpringboardServicesClient(Base): | |||
| 63 | bytes result | 72 | bytes result |
| 64 | char* pngdata = NULL | 73 | char* pngdata = NULL |
| 65 | uint64_t pngsize | 74 | uint64_t pngsize |
| 66 | self.handle_error(sbservices_get_icon_pngdata(self._c_client, bundleId, &pngdata, &pngsize)) | 75 | sbservices_error_t err |
| 67 | result = pngdata[:pngsize] | 76 | err = sbservices_get_icon_pngdata(self._c_client, bundleId, &pngdata, &pngsize) |
| 77 | try: | ||
| 78 | self.handle_error(err) | ||
| 79 | except BaseError, e: | ||
| 80 | raise | ||
| 81 | finally: | ||
| 82 | result = pngdata[:pngsize] | ||
| 83 | free(pngdata) | ||
| 68 | return result | 84 | return result |
