summaryrefslogtreecommitdiffstats
path: root/cython/house_arrest.pxi
diff options
context:
space:
mode:
Diffstat (limited to 'cython/house_arrest.pxi')
-rw-r--r--cython/house_arrest.pxi84
1 files changed, 84 insertions, 0 deletions
diff --git a/cython/house_arrest.pxi b/cython/house_arrest.pxi
new file mode 100644
index 0000000..54eebc1
--- /dev/null
+++ b/cython/house_arrest.pxi
@@ -0,0 +1,84 @@
1cdef extern from "libimobiledevice/house_arrest.h":
2 cdef struct house_arrest_client_private:
3 pass
4 ctypedef house_arrest_client_private *house_arrest_client_t
5
6 ctypedef enum house_arrest_error_t:
7 HOUSE_ARREST_E_SUCCESS = 0
8 HOUSE_ARREST_E_INVALID_ARG = -1
9 HOUSE_ARREST_E_PLIST_ERROR = -2
10 HOUSE_ARREST_E_CONN_FAILED = -3
11 HOUSE_ARREST_E_INVALID_MODE = -4
12 HOUSE_ARREST_E_UNKNOWN_ERROR = -256
13
14 house_arrest_error_t house_arrest_client_new(idevice_t device, lockdownd_service_descriptor_t descriptor, house_arrest_client_t * client)
15 house_arrest_error_t house_arrest_client_free(house_arrest_client_t client)
16
17 house_arrest_error_t house_arrest_send_request(house_arrest_client_t client, plist.plist_t dict)
18 house_arrest_error_t house_arrest_send_command(house_arrest_client_t client, char *command, char *appid)
19 house_arrest_error_t house_arrest_get_result(house_arrest_client_t client, plist.plist_t *dict)
20
21 afc_error_t afc_client_new_from_house_arrest_client(house_arrest_client_t client, afc_client_t *afc_client)
22
23cdef class HouseArrestError(BaseError):
24 def __init__(self, *args, **kwargs):
25 self._lookup_table = {
26 HOUSE_ARREST_E_SUCCESS: "Success",
27 HOUSE_ARREST_E_INVALID_ARG: "Invalid argument",
28 HOUSE_ARREST_E_PLIST_ERROR: "Property list error",
29 HOUSE_ARREST_E_CONN_FAILED: "Connection failed",
30 HOUSE_ARREST_E_INVALID_MODE: "Invalid mode",
31 HOUSE_ARREST_E_UNKNOWN_ERROR: "Unknown error"
32 }
33 BaseError.__init__(self, *args, **kwargs)
34
35cdef class HouseArrestClient(PropertyListService):
36 __service_name__ = "com.apple.mobile.house_arrest"
37 cdef house_arrest_client_t _c_client
38
39 def __cinit__(self, iDevice device not None, LockdownServiceDescriptor descriptor, *args, **kwargs):
40 self.handle_error(house_arrest_client_new(device._c_dev, descriptor._c_service_descriptor, &self._c_client))
41
42 def __dealloc__(self):
43 cdef house_arrest_error_t err
44 if self._c_client is not NULL:
45 err = house_arrest_client_free(self._c_client)
46 self.handle_error(err)
47
48 cdef inline BaseError _error(self, int16_t ret):
49 return HouseArrestError(ret)
50
51 cpdef send_request(self, plist.Node message):
52 self.handle_error(house_arrest_send_request(self._c_client, message._c_node))
53
54 cpdef send_command(self, bytes command, bytes appid):
55 self.handle_error(house_arrest_send_command(self._c_client, command, appid))
56
57 cpdef plist.Node get_result(self):
58 cdef:
59 plist.plist_t c_node = NULL
60 house_arrest_error_t err
61 err = house_arrest_get_result(self._c_client, &c_node)
62 try:
63 self.handle_error(err)
64 return plist.plist_t_to_node(c_node)
65 except BaseError, e:
66 if c_node != NULL:
67 plist.plist_free(c_node)
68 raise
69
70 cpdef AfcClient to_afc_client(self):
71 cdef:
72 afc_client_t c_afc_client = NULL
73 AfcClient result
74 afc_error_t err
75 err = afc_client_new_from_house_arrest_client(self._c_client, &c_afc_client)
76 try:
77 result = AfcClient.__new__(AfcClient)
78 result._c_client = c_afc_client
79 result.handle_error(err)
80 return result
81 except BaseError, e:
82 if c_afc_client != NULL:
83 afc_client_free(c_afc_client);
84 raise