path: root/cython/imobiledevice.pyx
diff options
authorGravatar Bryan Forbes2010-04-01 01:09:52 -0500
committerGravatar Martin Szulecki2012-03-20 23:25:55 +0100
commitacac4f819ccafa6f6bb945626f2e21ec2b75074b (patch)
treefc6881c387ee1e4527ed2b3ca73d1059bc8fc4f2 /cython/imobiledevice.pyx
parentaf06ff22149191c056804e7fec9c1a6880a06872 (diff)
Cleaned up
Added the cython m4 files. Cleaned up afc.pxi. Make sure the event callback and installation proxy callback aquire the GIL. Implemented some cleanup before the error handlers raise.
Diffstat (limited to 'cython/imobiledevice.pyx')
1 files changed, 27 insertions, 8 deletions
diff --git a/cython/imobiledevice.pyx b/cython/imobiledevice.pyx
index dc0fb88..b57db04 100644
--- a/cython/imobiledevice.pyx
+++ b/cython/imobiledevice.pyx
@@ -67,27 +67,40 @@ cdef class iDeviceError(BaseError):
BaseError.__init__(self, *args, **kwargs)
-cpdef set_debug_level(int level):
+def set_debug_level(int level):
cdef class iDeviceEvent:
def __init__(self, *args, **kwargs):
raise TypeError("iDeviceEvent cannot be instantiated")
-cdef void idevice_event_cb(const_idevice_event_t c_event, void *user_data):
+ def __str__(self):
+ return 'iDeviceEvent: %s (%s)' % (self.event == IDEVICE_DEVICE_ADD and 'Add' or 'Remove', self.uuid)
+ property event:
+ def __get__(self):
+ return self._c_event.event
+ property uuid:
+ def __get__(self):
+ return self._c_event.uuid
+ property conn_type:
+ def __get__(self):
+ return self._c_event.conn_type
+cdef void idevice_event_cb(const_idevice_event_t c_event, void *user_data) with gil:
cdef iDeviceEvent event = iDeviceEvent.__new__(iDeviceEvent)
event._c_event = c_event
-cpdef event_subscribe(object callback):
+def event_subscribe(object callback):
cdef iDeviceError err = iDeviceError(idevice_event_subscribe(idevice_event_cb, <void*>callback))
if err: raise err
-cpdef event_unsubscribe():
+def event_unsubscribe():
cdef iDeviceError err = iDeviceError(idevice_event_unsubscribe())
if err: raise err
-cpdef get_device_list():
+def get_device_list():
char** devices
int count
@@ -214,10 +227,14 @@ cdef class LockdownError(BaseError):
BaseError.__init__(self, *args, **kwargs)
cdef class LockdownClient(Base):
- def __cinit__(self, iDevice device not None, char *label=NULL, *args, **kwargs):
+ def __cinit__(self, iDevice device not None, bytes label="", *args, **kwargs):
iDevice dev = device
- lockdownd_error_t err = lockdownd_client_new_with_handshake(dev._c_dev, &(self._c_client), label)
+ lockdownd_error_t err
+ char* c_label = NULL
+ if label:
+ c_label = label
+ err = lockdownd_client_new_with_handshake(dev._c_dev, &(self._c_client), c_label)
def __dealloc__(self):
@@ -229,7 +246,7 @@ cdef class LockdownClient(Base):
cdef inline BaseError _error(self, int16_t ret):
return LockdownError(ret)
- cpdef int start_service(self, service):
+ cpdef int start_service(self, bytes service):
uint16_t port
lockdownd_error_t err
@@ -242,6 +259,8 @@ cdef class LockdownClient(Base):
cdef extern from *:
ctypedef char* const_char_ptr "const char*"
+ void free(void *ptr)
+ void plist_free(plist.plist_t node)
include "property_list_client.pxi"
include "mobilesync.pxi"