summaryrefslogtreecommitdiffstats
path: root/cython/webinspector.pxi
diff options
context:
space:
mode:
Diffstat (limited to 'cython/webinspector.pxi')
-rw-r--r--cython/webinspector.pxi60
1 files changed, 60 insertions, 0 deletions
diff --git a/cython/webinspector.pxi b/cython/webinspector.pxi
new file mode 100644
index 0000000..f77547d
--- /dev/null
+++ b/cython/webinspector.pxi
@@ -0,0 +1,60 @@
1cdef extern from "libimobiledevice/webinspector.h":
2 cdef struct webinspector_client_private:
3 pass
4 ctypedef webinspector_client_private *webinspector_client_t
5
6 ctypedef enum webinspector_error_t:
7 WEBINSPECTOR_E_SUCCESS = 0
8 WEBINSPECTOR_E_INVALID_ARG = -1
9 WEBINSPECTOR_E_PLIST_ERROR = -2
10 WEBINSPECTOR_E_MUX_ERROR = -3
11 WEBINSPECTOR_E_SSL_ERROR = -4
12 WEBINSPECTOR_E_RECEIVE_TIMEOUT = -5,
13 WEBINSPECTOR_E_NOT_ENOUGH_DATA = -6,
14 WEBINSPECTOR_E_UNKNOWN_ERROR = -256
15
16 webinspector_error_t webinspector_client_new(idevice_t device, lockdownd_service_descriptor_t descriptor, webinspector_client_t * client)
17 webinspector_error_t webinspector_client_free(webinspector_client_t client)
18
19 webinspector_error_t webinspector_send(webinspector_client_t client, plist.plist_t plist)
20 webinspector_error_t webinspector_receive(webinspector_client_t client, plist.plist_t * plist)
21 webinspector_error_t webinspector_receive_with_timeout(webinspector_client_t client, plist.plist_t * plist, uint32_t timeout_ms)
22
23cdef class WebinspectorError(BaseError):
24 def __init__(self, *args, **kwargs):
25 self._lookup_table = {
26 WEBINSPECTOR_E_SUCCESS: "Success",
27 WEBINSPECTOR_E_INVALID_ARG: "Invalid argument",
28 WEBINSPECTOR_E_PLIST_ERROR: "Property list error",
29 WEBINSPECTOR_E_MUX_ERROR: "MUX error",
30 WEBINSPECTOR_E_SSL_ERROR: "SSL Error",
31 WEBINSPECTOR_E_NOT_ENOUGH_DATA: 'Not enough data',
32 WEBINSPECTOR_E_RECEIVE_TIMEOUT: 'Connection timeout',
33 WEBINSPECTOR_E_UNKNOWN_ERROR: "Unknown error"
34 }
35 BaseError.__init__(self, *args, **kwargs)
36
37cdef class WebinspectorClient(PropertyListService):
38 __service_name__ = "com.apple.webinspector"
39 cdef webinspector_client_t _c_client
40
41 def __cinit__(self, iDevice device not None, LockdownServiceDescriptor descriptor, *args, **kwargs):
42 self.handle_error(webinspector_client_new(device._c_dev, descriptor._c_service_descriptor, &self._c_client))
43
44 def __dealloc__(self):
45 cdef webinspector_error_t err
46 if self._c_client is not NULL:
47 err = webinspector_client_free(self._c_client)
48 self.handle_error(err)
49
50 cdef inline int16_t _send(self, plist.plist_t node):
51 return webinspector_send(self._c_client, node)
52
53 cdef inline int16_t _receive(self, plist.plist_t* node):
54 return webinspector_receive(self._c_client, node)
55
56 cdef inline int16_t _receive_with_timeout(self, plist.plist_t* node, int timeout_ms):
57 return webinspector_receive_with_timeout(self._c_client, node, timeout_ms)
58
59 cdef inline BaseError _error(self, int16_t ret):
60 return WebinspectorError(ret)