diff options
| author | 2010-03-17 01:12:52 -0500 | |
|---|---|---|
| committer | 2012-03-20 23:25:54 +0100 | |
| commit | cfe6244f8954efce4ef12b9b4338cc0d41a9ff40 (patch) | |
| tree | 8b181941ea31e9f8a16930536b429178ce7d4afe /cython/sbservices.pxi | |
| parent | bc6886898d03d28dc30c90db18c2a5f90f20c746 (diff) | |
| download | libimobiledevice-cfe6244f8954efce4ef12b9b4338cc0d41a9ff40.tar.gz libimobiledevice-cfe6244f8954efce4ef12b9b4338cc0d41a9ff40.tar.bz2 | |
Moved everything but iDevice and LockdownClient to pxi files.
Added MobileBackupClient and PropertyListService.
Diffstat (limited to 'cython/sbservices.pxi')
| -rw-r--r-- | cython/sbservices.pxi | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/cython/sbservices.pxi b/cython/sbservices.pxi new file mode 100644 index 0000000..cb9de59 --- /dev/null +++ b/cython/sbservices.pxi | |||
| @@ -0,0 +1,57 @@ | |||
| 1 | cdef extern from "libimobiledevice/sbservices.h": | ||
| 2 | cdef struct sbservices_client_int: | ||
| 3 | pass | ||
| 4 | ctypedef sbservices_client_int *sbservices_client_t | ||
| 5 | ctypedef int16_t sbservices_error_t | ||
| 6 | sbservices_error_t sbservices_client_new(idevice_t device, uint16_t port, sbservices_client_t *client) | ||
| 7 | sbservices_error_t sbservices_client_free(sbservices_client_t client) | ||
| 8 | sbservices_error_t sbservices_get_icon_state(sbservices_client_t client, plist.plist_t *state) | ||
| 9 | sbservices_error_t sbservices_set_icon_state(sbservices_client_t client, plist.plist_t newstate) | ||
| 10 | sbservices_error_t sbservices_get_icon_pngdata(sbservices_client_t client, char *bundleId, char **pngdata, uint64_t *pngsize) | ||
| 11 | |||
| 12 | cdef class SpringboardServicesError(BaseError): | ||
| 13 | pass | ||
| 14 | |||
| 15 | cdef class SpringboardServices: | ||
| 16 | cdef sbservices_client_t _c_client | ||
| 17 | |||
| 18 | def __cinit__(self, iDevice device not None, LockdownClient lockdown=None, *args, **kwargs): | ||
| 19 | cdef iDevice dev = device | ||
| 20 | cdef LockdownClient lckd | ||
| 21 | if lockdown is None: | ||
| 22 | lckd = LockdownClient(dev) | ||
| 23 | else: | ||
| 24 | lckd = lockdown | ||
| 25 | port = lockdown.start_service("com.apple.springboardservices") | ||
| 26 | err = SpringboardServicesError(sbservices_client_new(dev._c_dev, port, &(self._c_client))) | ||
| 27 | if err: raise err | ||
| 28 | |||
| 29 | def __dealloc__(self): | ||
| 30 | if self._c_client is not NULL: | ||
| 31 | err = SpringboardServicesError(sbservices_client_free(self._c_client)) | ||
| 32 | if err: raise err | ||
| 33 | |||
| 34 | property icon_state: | ||
| 35 | def __get__(self): | ||
| 36 | cdef plist.plist_t c_node = NULL | ||
| 37 | cdef plist.Node node | ||
| 38 | cdef SpringboardServicesError err = \ | ||
| 39 | SpringboardServicesError(sbservices_get_icon_state(self._c_client, &c_node)) | ||
| 40 | if err: raise err | ||
| 41 | node = plist.plist_t_to_node(c_node) | ||
| 42 | return node | ||
| 43 | def __set__(self, plist.Node newstate not None): | ||
| 44 | cdef plist.Node node = newstate | ||
| 45 | cdef SpringboardServicesError err = \ | ||
| 46 | SpringboardServicesError(sbservices_set_icon_state(self._c_client, node._c_node)) | ||
| 47 | if err: raise err | ||
| 48 | |||
| 49 | cpdef bytes get_pngdata(self, bytes bundleId): | ||
| 50 | cdef bytes result | ||
| 51 | cdef char* pngdata = NULL | ||
| 52 | cdef uint64_t pngsize | ||
| 53 | cdef SpringboardServicesError err = \ | ||
| 54 | SpringboardServicesError(sbservices_get_icon_pngdata(self._c_client, bundleId, &pngdata, &pngsize)) | ||
| 55 | if err: raise err | ||
| 56 | result = pngdata[:pngsize] | ||
| 57 | return result | ||
