summaryrefslogtreecommitdiffstats
path: root/cython
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2012-03-20 22:56:33 +0100
committerGravatar Martin Szulecki2012-03-20 23:25:56 +0100
commit2d9ecc3d805e616b2bf85c0b8e99737e9b30c89d (patch)
tree48e924795c6bf3c217de61efe6048f6bb6573244 /cython
parent3e9d17ccd5212c110db9cfb5daa2d889d0a1aee4 (diff)
downloadlibimobiledevice-2d9ecc3d805e616b2bf85c0b8e99737e9b30c89d.tar.gz
libimobiledevice-2d9ecc3d805e616b2bf85c0b8e99737e9b30c89d.tar.bz2
cython: Update to latest API and fix deprecation warnings with cython 0.13+
Diffstat (limited to 'cython')
-rw-r--r--cython/afc.pxi18
-rw-r--r--cython/file_relay.pxi6
-rw-r--r--cython/imobiledevice.pyx4
-rw-r--r--cython/lockdown.pxi6
-rw-r--r--cython/mobilesync.pxi10
-rw-r--r--cython/sbservices.pxi6
-rw-r--r--cython/screenshotr.pxi2
7 files changed, 27 insertions, 25 deletions
diff --git a/cython/afc.pxi b/cython/afc.pxi
index c33dbfd..cf72b69 100644
--- a/cython/afc.pxi
+++ b/cython/afc.pxi
@@ -142,7 +142,7 @@ cdef class AfcFile(Base):
142 except BaseError, e: 142 except BaseError, e:
143 raise 143 raise
144 finally: 144 finally:
145 stdlib.free(c_data) 145 free(c_data)
146 146
147 return bytes_written 147 return bytes_written
148 148
@@ -182,9 +182,9 @@ cdef class AfcClient(BaseService):
182 while infos[i]: 182 while infos[i]:
183 info = infos[i] 183 info = infos[i]
184 result.append(info) 184 result.append(info)
185 stdlib.free(infos[i]) 185 free(infos[i])
186 i = i + 1 186 i = i + 1
187 stdlib.free(infos) 187 free(infos)
188 188
189 return result 189 return result
190 190
@@ -205,13 +205,13 @@ cdef class AfcClient(BaseService):
205 while dir_list[i]: 205 while dir_list[i]:
206 f = dir_list[i] 206 f = dir_list[i]
207 result.append(f) 207 result.append(f)
208 stdlib.free(dir_list[i]) 208 free(dir_list[i])
209 i = i + 1 209 i = i + 1
210 stdlib.free(dir_list) 210 free(dir_list)
211 211
212 return result 212 return result
213 213
214 cpdef AfcFile open(self, bytes filename, bytes mode='r'): 214 cpdef AfcFile open(self, bytes filename, bytes mode=b'r'):
215 cdef: 215 cdef:
216 afc_file_mode_t c_mode 216 afc_file_mode_t c_mode
217 uint64_t handle 217 uint64_t handle
@@ -241,7 +241,7 @@ cdef class AfcClient(BaseService):
241 241
242 cpdef get_file_info(self, bytes path): 242 cpdef get_file_info(self, bytes path):
243 cdef: 243 cdef:
244 list result 244 list result = []
245 char** c_result 245 char** c_result
246 int i = 0 246 int i = 0
247 bytes info 247 bytes info
@@ -254,9 +254,9 @@ cdef class AfcClient(BaseService):
254 while c_result[i]: 254 while c_result[i]:
255 info = c_result[i] 255 info = c_result[i]
256 result.append(info) 256 result.append(info)
257 stdlib.free(c_result[i]) 257 free(c_result[i])
258 i = i + 1 258 i = i + 1
259 stdlib.free(c_result) 259 free(c_result)
260 260
261 return result 261 return result
262 262
diff --git a/cython/file_relay.pxi b/cython/file_relay.pxi
index beb429b..450b030 100644
--- a/cython/file_relay.pxi
+++ b/cython/file_relay.pxi
@@ -31,7 +31,7 @@ cdef class FileRelayError(BaseError):
31 } 31 }
32 BaseError.__init__(self, *args, **kwargs) 32 BaseError.__init__(self, *args, **kwargs)
33 33
34cimport stdlib 34from libc.stdlib cimport *
35 35
36cdef class FileRelayClient(PropertyListService): 36cdef class FileRelayClient(PropertyListService):
37 __service_name__ = "com.apple.mobile.file_relay" 37 __service_name__ = "com.apple.mobile.file_relay"
@@ -50,7 +50,7 @@ cdef class FileRelayClient(PropertyListService):
50 cdef: 50 cdef:
51 file_relay_error_t err 51 file_relay_error_t err
52 Py_ssize_t count = len(sources) 52 Py_ssize_t count = len(sources)
53 char** c_sources = <char**>stdlib.malloc(sizeof(char*) * (count + 1)) 53 char** c_sources = <char**>malloc(sizeof(char*) * (count + 1))
54 iDeviceConnection conn = iDeviceConnection.__new__(iDeviceConnection) 54 iDeviceConnection conn = iDeviceConnection.__new__(iDeviceConnection)
55 55
56 for i, value in enumerate(sources): 56 for i, value in enumerate(sources):
@@ -58,7 +58,7 @@ cdef class FileRelayClient(PropertyListService):
58 c_sources[count] = NULL 58 c_sources[count] = NULL
59 59
60 err = file_relay_request_sources(self._c_client, <const_sources_t>c_sources, &conn._c_connection) 60 err = file_relay_request_sources(self._c_client, <const_sources_t>c_sources, &conn._c_connection)
61 stdlib.free(c_sources) 61 free(c_sources)
62 self.handle_error(err) 62 self.handle_error(err)
63 return conn 63 return conn
64 64
diff --git a/cython/imobiledevice.pyx b/cython/imobiledevice.pyx
index 7898290..654288e 100644
--- a/cython/imobiledevice.pyx
+++ b/cython/imobiledevice.pyx
@@ -134,7 +134,7 @@ cdef class iDeviceConnection(Base):
134 cdef inline BaseError _error(self, int16_t ret): 134 cdef inline BaseError _error(self, int16_t ret):
135 return iDeviceError(ret) 135 return iDeviceError(ret)
136 136
137cimport stdlib 137from libc.stdlib cimport *
138 138
139cdef class iDevice(Base): 139cdef class iDevice(Base):
140 def __cinit__(self, object uuid=None, *args, **kwargs): 140 def __cinit__(self, object uuid=None, *args, **kwargs):
@@ -180,7 +180,7 @@ cdef class iDevice(Base):
180 return uuid 180 return uuid
181 except Exception, e: 181 except Exception, e:
182 if uuid != NULL: 182 if uuid != NULL:
183 stdlib.free(uuid) 183 free(uuid)
184 property handle: 184 property handle:
185 def __get__(self): 185 def __get__(self):
186 cdef uint32_t handle 186 cdef uint32_t handle
diff --git a/cython/lockdown.pxi b/cython/lockdown.pxi
index 8463738..b5207e8 100644
--- a/cython/lockdown.pxi
+++ b/cython/lockdown.pxi
@@ -90,7 +90,7 @@ cdef class LockdownPairRecord:
90 return result 90 return result
91 91
92cdef class LockdownClient(PropertyListService): 92cdef class LockdownClient(PropertyListService):
93 def __cinit__(self, iDevice device not None, bytes label="", bool handshake=True, *args, **kwargs): 93 def __cinit__(self, iDevice device not None, bytes label=b'', bint handshake=True, *args, **kwargs):
94 cdef: 94 cdef:
95 lockdownd_error_t err 95 lockdownd_error_t err
96 char* c_label = NULL 96 char* c_label = NULL
@@ -125,7 +125,7 @@ cdef class LockdownClient(PropertyListService):
125 raise 125 raise
126 finally: 126 finally:
127 if c_type != NULL: 127 if c_type != NULL:
128 stdlib.free(c_type) 128 free(c_type)
129 129
130 cpdef plist.Node get_value(self, bytes domain=None, bytes key=None): 130 cpdef plist.Node get_value(self, bytes domain=None, bytes key=None):
131 cdef: 131 cdef:
@@ -212,7 +212,7 @@ cdef class LockdownClient(PropertyListService):
212 raise 212 raise
213 finally: 213 finally:
214 if c_session_id != NULL: 214 if c_session_id != NULL:
215 stdlib.free(c_session_id) 215 free(c_session_id)
216 216
217 cpdef stop_session(self, bytes session_id): 217 cpdef stop_session(self, bytes session_id):
218 self.handle_error(lockdownd_stop_session(self._c_client, session_id)) 218 self.handle_error(lockdownd_stop_session(self._c_client, session_id))
diff --git a/cython/mobilesync.pxi b/cython/mobilesync.pxi
index aef13f9..beafe10 100644
--- a/cython/mobilesync.pxi
+++ b/cython/mobilesync.pxi
@@ -35,7 +35,7 @@ cdef extern from "libimobiledevice/mobilesync.h":
35 35
36 mobilesync_error_t mobilesync_get_all_records_from_device(mobilesync_client_t client) 36 mobilesync_error_t mobilesync_get_all_records_from_device(mobilesync_client_t client)
37 mobilesync_error_t mobilesync_get_changes_from_device(mobilesync_client_t client) 37 mobilesync_error_t mobilesync_get_changes_from_device(mobilesync_client_t client)
38 mobilesync_error_t mobilesync_receive_changes(mobilesync_client_t client, plist.plist_t *entities, uint8_t *is_last_record) 38 mobilesync_error_t mobilesync_receive_changes(mobilesync_client_t client, plist.plist_t *entities, uint8_t *is_last_record, plist.plist_t *actions)
39 mobilesync_error_t mobilesync_acknowledge_changes_from_device(mobilesync_client_t client) 39 mobilesync_error_t mobilesync_acknowledge_changes_from_device(mobilesync_client_t client)
40 40
41 mobilesync_error_t mobilesync_ready_to_send_changes_from_computer(mobilesync_client_t client) 41 mobilesync_error_t mobilesync_ready_to_send_changes_from_computer(mobilesync_client_t client)
@@ -114,13 +114,15 @@ cdef class MobileSyncClient(DeviceLinkService):
114 cdef: 114 cdef:
115 plist.plist_t entities = NULL 115 plist.plist_t entities = NULL
116 uint8_t is_last_record = 0 116 uint8_t is_last_record = 0
117 117 plist.plist_t actions = NULL
118 try: 118 try:
119 self.handle_error(mobilesync_receive_changes(self._c_client, &entities, &is_last_record)) 119 self.handle_error(mobilesync_receive_changes(self._c_client, &entities, &is_last_record, &actions))
120 return (plist.plist_t_to_node(entities), <bint>is_last_record) 120 return (plist.plist_t_to_node(entities), <bint>is_last_record, plist.plist_t_to_node(actions))
121 except Exception, e: 121 except Exception, e:
122 if entities != NULL: 122 if entities != NULL:
123 plist.plist_free(entities) 123 plist.plist_free(entities)
124 if actions != NULL:
125 plist.plist_free(actions)
124 raise 126 raise
125 127
126 cpdef acknowledge_changes_from_device(self): 128 cpdef acknowledge_changes_from_device(self):
diff --git a/cython/sbservices.pxi b/cython/sbservices.pxi
index 4d09b71..e826b2a 100644
--- a/cython/sbservices.pxi
+++ b/cython/sbservices.pxi
@@ -10,7 +10,7 @@ cdef extern from "libimobiledevice/sbservices.h":
10 SBSERVICES_E_UNKNOWN_ERROR = -256 10 SBSERVICES_E_UNKNOWN_ERROR = -256
11 sbservices_error_t sbservices_client_new(idevice_t device, uint16_t port, sbservices_client_t *client) 11 sbservices_error_t sbservices_client_new(idevice_t device, uint16_t port, sbservices_client_t *client)
12 sbservices_error_t sbservices_client_free(sbservices_client_t client) 12 sbservices_error_t sbservices_client_free(sbservices_client_t client)
13 sbservices_error_t sbservices_get_icon_state(sbservices_client_t client, plist.plist_t *state) 13 sbservices_error_t sbservices_get_icon_state(sbservices_client_t client, plist.plist_t *state, char *format_version)
14 sbservices_error_t sbservices_set_icon_state(sbservices_client_t client, plist.plist_t newstate) 14 sbservices_error_t sbservices_set_icon_state(sbservices_client_t client, plist.plist_t newstate)
15 sbservices_error_t sbservices_get_icon_pngdata(sbservices_client_t client, char *bundleId, char **pngdata, uint64_t *pngsize) 15 sbservices_error_t sbservices_get_icon_pngdata(sbservices_client_t client, char *bundleId, char **pngdata, uint64_t *pngsize)
16 16
@@ -45,7 +45,7 @@ cdef class SpringboardServicesClient(PropertyListService):
45 cdef: 45 cdef:
46 plist.plist_t c_node = NULL 46 plist.plist_t c_node = NULL
47 sbservices_error_t err 47 sbservices_error_t err
48 err = sbservices_get_icon_state(self._c_client, &c_node) 48 err = sbservices_get_icon_state(self._c_client, &c_node, NULL)
49 try: 49 try:
50 self.handle_error(err) 50 self.handle_error(err)
51 51
@@ -68,5 +68,5 @@ cdef class SpringboardServicesClient(PropertyListService):
68 68
69 return pngdata[:pngsize] 69 return pngdata[:pngsize]
70 except BaseError, e: 70 except BaseError, e:
71 stdlib.free(pngdata) 71 free(pngdata)
72 raise 72 raise
diff --git a/cython/screenshotr.pxi b/cython/screenshotr.pxi
index 9213b64..a53fab2 100644
--- a/cython/screenshotr.pxi
+++ b/cython/screenshotr.pxi
@@ -55,7 +55,7 @@ cdef class ScreenshotrClient(DeviceLinkService):
55 return result 55 return result
56 except Exception, e: 56 except Exception, e:
57 if c_data != NULL: 57 if c_data != NULL:
58 stdlib.free(c_data) 58 free(c_data)
59 raise 59 raise
60 60
61 cdef inline BaseError _error(self, int16_t ret): 61 cdef inline BaseError _error(self, int16_t ret):