From 9eee3d14d19aaee60c3510c558a22ccb3dc2ce10 Mon Sep 17 00:00:00 2001 From: aymenim Date: Mon, 21 Mar 2016 11:27:26 +0300 Subject: cython: Allow passing null to lockdown set value * added code to handle passing null values to lockdown_set_value, needed for example setting device name . --- cython/lockdown.pxi | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/cython/lockdown.pxi b/cython/lockdown.pxi index 6b88f9d..25edb4c 100644 --- a/cython/lockdown.pxi +++ b/cython/lockdown.pxi @@ -210,14 +210,23 @@ cdef class LockdownClient(PropertyListService): raise cpdef set_value(self, bytes domain, bytes key, object value): - cdef plist.plist_t c_node = plist.native_to_plist_t(value) + cdef: + plist.plist_t c_node = NULL + char* c_domain = NULL + char* c_key = NULL + + c_node = plist.native_to_plist_t(value) + if domain is not None: + c_domain = domain + if key is not None: + c_key = key try: - self.handle_error(lockdownd_set_value(self._c_client, domain, key, c_node)) + self.handle_error(lockdownd_set_value(self._c_client, c_domain, c_key, c_node)) except BaseError, e: raise finally: if c_node != NULL: - plist.plist_free(c_node) + c_node = NULL cpdef remove_value(self, bytes domain, bytes key): self.handle_error(lockdownd_remove_value(self._c_client, domain, key)) -- cgit v1.1-32-gdbae