diff options
Diffstat (limited to 'cython/imobiledevice.pyx')
| -rw-r--r-- | cython/imobiledevice.pyx | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/cython/imobiledevice.pyx b/cython/imobiledevice.pyx index e011223..bc861b3 100644 --- a/cython/imobiledevice.pyx +++ b/cython/imobiledevice.pyx | |||
| @@ -128,6 +128,36 @@ cdef class iDeviceConnection(Base): | |||
| 128 | def __init__(self, *args, **kwargs): | 128 | def __init__(self, *args, **kwargs): |
| 129 | raise TypeError("iDeviceConnection cannot be instantiated. Please use iDevice.connect()") | 129 | raise TypeError("iDeviceConnection cannot be instantiated. Please use iDevice.connect()") |
| 130 | 130 | ||
| 131 | cpdef bytes receive_timeout(self, uint32_t max_len, unsigned int timeout): | ||
| 132 | cdef: | ||
| 133 | uint32_t bytes_received | ||
| 134 | char* c_data = <char *>malloc(max_len) | ||
| 135 | bytes result | ||
| 136 | |||
| 137 | try: | ||
| 138 | self.handle_error(idevice_connection_receive_timeout(self._c_connection, c_data, max_len, &bytes_received, timeout)) | ||
| 139 | result = c_data[:bytes_received] | ||
| 140 | return result | ||
| 141 | except BaseError, e: | ||
| 142 | raise | ||
| 143 | finally: | ||
| 144 | free(c_data) | ||
| 145 | |||
| 146 | cpdef bytes receive(self, max_len): | ||
| 147 | cdef: | ||
| 148 | uint32_t bytes_received | ||
| 149 | char* c_data = <char *>malloc(max_len) | ||
| 150 | bytes result | ||
| 151 | |||
| 152 | try: | ||
| 153 | self.handle_error(idevice_connection_receive(self._c_connection, c_data, max_len, &bytes_received)) | ||
| 154 | result = c_data[:bytes_received] | ||
| 155 | return result | ||
| 156 | except BaseError, e: | ||
| 157 | raise | ||
| 158 | finally: | ||
| 159 | free(c_data) | ||
| 160 | |||
| 131 | cpdef disconnect(self): | 161 | cpdef disconnect(self): |
| 132 | cdef idevice_error_t err | 162 | cdef idevice_error_t err |
| 133 | err = idevice_disconnect(self._c_connection) | 163 | err = idevice_disconnect(self._c_connection) |
