diff options
| author | 2010-03-17 01:12:52 -0500 | |
|---|---|---|
| committer | 2012-03-20 23:25:54 +0100 | |
| commit | cfe6244f8954efce4ef12b9b4338cc0d41a9ff40 (patch) | |
| tree | 8b181941ea31e9f8a16930536b429178ce7d4afe /cython/notification_proxy.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/notification_proxy.pxi')
| -rw-r--r-- | cython/notification_proxy.pxi | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/cython/notification_proxy.pxi b/cython/notification_proxy.pxi new file mode 100644 index 0000000..acccf7d --- /dev/null +++ b/cython/notification_proxy.pxi | |||
| @@ -0,0 +1,52 @@ | |||
| 1 | cdef extern from *: | ||
| 2 | ctypedef char* const_char_ptr "const char*" | ||
| 3 | |||
| 4 | cdef extern from "libimobiledevice/notification_proxy.h": | ||
| 5 | cdef struct np_client_int: | ||
| 6 | pass | ||
| 7 | ctypedef np_client_int *np_client_t | ||
| 8 | ctypedef int16_t np_error_t | ||
| 9 | ctypedef void (*np_notify_cb_t) (const_char_ptr notification, void *userdata) | ||
| 10 | np_error_t np_client_new(idevice_t device, uint16_t port, np_client_t *client) | ||
| 11 | np_error_t np_client_free(np_client_t client) | ||
| 12 | np_error_t np_post_notification(np_client_t client, char *notification) | ||
| 13 | np_error_t np_observe_notification(np_client_t client, char *notification) | ||
| 14 | np_error_t np_observe_notifications(np_client_t client, char **notification_spec) | ||
| 15 | np_error_t np_set_notify_callback(np_client_t client, np_notify_cb_t notify_cb, void *userdata) | ||
| 16 | |||
| 17 | cdef void np_notify_cb(const_char_ptr notification, void *py_callback): | ||
| 18 | (<object>py_callback)(notification) | ||
| 19 | |||
| 20 | cdef class NotificationProxyError(BaseError): | ||
| 21 | pass | ||
| 22 | |||
| 23 | cdef class NotificationProxy: | ||
| 24 | cdef np_client_t _c_client | ||
| 25 | |||
| 26 | def __cinit__(self, iDevice device not None, LockdownClient lockdown=None, *args, **kwargs): | ||
| 27 | cdef iDevice dev = device | ||
| 28 | cdef LockdownClient lckd | ||
| 29 | if lockdown is None: | ||
| 30 | lckd = LockdownClient(dev) | ||
| 31 | else: | ||
| 32 | lckd = lockdown | ||
| 33 | port = lckd.start_service("com.apple.mobile.notification_proxy") | ||
| 34 | err = NotificationProxyError(np_client_new(dev._c_dev, port, &(self._c_client))) | ||
| 35 | if err: raise err | ||
| 36 | |||
| 37 | def __dealloc__(self): | ||
| 38 | if self._c_client is not NULL: | ||
| 39 | err = NotificationProxyError(np_client_free(self._c_client)) | ||
| 40 | if err: raise err | ||
| 41 | |||
| 42 | cpdef set_notify_callback(self, object callback): | ||
| 43 | err = NotificationProxyError(np_set_notify_callback(self._c_client, np_notify_cb, <void*>callback)) | ||
| 44 | if err: raise err | ||
| 45 | |||
| 46 | cpdef observe_notification(self, bytes notification): | ||
| 47 | err = NotificationProxyError(np_observe_notification(self._c_client, notification)) | ||
| 48 | if err: raise err | ||
| 49 | |||
| 50 | cpdef post_notification(self, bytes notification): | ||
| 51 | err = NotificationProxyError(np_post_notification(self._c_client, notification)) | ||
| 52 | if err: raise err | ||
