diff options
author | Mike Blumenkrantz <michael.blumenkrantz@gmail.com> | 2012-06-15 08:51:07 +0000 |
---|---|---|
committer | Mike Blumenkrantz <michael.blumenkrantz@gmail.com> | 2012-06-15 08:51:07 +0000 |
commit | a7d136e9646d025820d1cd840687a5957b5e8503 (patch) | |
tree | 2e29f8fdc259cd0d261d4d9e0ebea062768368de /legacy/ethumb | |
parent | a3e029c18e3391d7da938a17c821dbbc7734365b (diff) |
formatting
SVN revision: 72176
Diffstat (limited to 'legacy/ethumb')
-rw-r--r-- | legacy/ethumb/src/lib/client/ethumb_client.c | 624 |
1 files changed, 315 insertions, 309 deletions
diff --git a/legacy/ethumb/src/lib/client/ethumb_client.c b/legacy/ethumb/src/lib/client/ethumb_client.c index 46ed3da7c9..ee17507cd1 100644 --- a/legacy/ethumb/src/lib/client/ethumb_client.c +++ b/legacy/ethumb/src/lib/client/ethumb_client.c | |||
@@ -87,107 +87,109 @@ | |||
87 | #define PATH_MAX 4096 | 87 | #define PATH_MAX 4096 |
88 | #endif | 88 | #endif |
89 | 89 | ||
90 | #define MAX_ID 2000000 | 90 | #define MAX_ID 2000000 |
91 | 91 | ||
92 | static int _log_dom = -1; | 92 | static int _log_dom = -1; |
93 | #define DBG(...) EINA_LOG_DOM_DBG(_log_dom, __VA_ARGS__) | 93 | #define DBG(...) EINA_LOG_DOM_DBG(_log_dom, __VA_ARGS__) |
94 | #define INF(...) EINA_LOG_DOM_INFO(_log_dom, __VA_ARGS__) | 94 | #define INF(...) EINA_LOG_DOM_INFO(_log_dom, __VA_ARGS__) |
95 | #define WRN(...) EINA_LOG_DOM_WARN(_log_dom, __VA_ARGS__) | 95 | #define WRN(...) EINA_LOG_DOM_WARN(_log_dom, __VA_ARGS__) |
96 | #define ERR(...) EINA_LOG_DOM_ERR(_log_dom, __VA_ARGS__) | 96 | #define ERR(...) EINA_LOG_DOM_ERR(_log_dom, __VA_ARGS__) |
97 | #define CRITICAL(...) EINA_LOG_DOM_CRIT(_log_dom, __VA_ARGS__) | 97 | #define CRITICAL(...) EINA_LOG_DOM_CRIT(_log_dom, __VA_ARGS__) |
98 | 98 | ||
99 | struct _Ethumb_Client | 99 | struct _Ethumb_Client |
100 | { | 100 | { |
101 | Ethumb *ethumb; | 101 | Ethumb *ethumb; |
102 | int id_count; | 102 | int id_count; |
103 | 103 | ||
104 | Ethumb *old_ethumb_conf; | 104 | Ethumb *old_ethumb_conf; |
105 | E_DBus_Connection *conn; | 105 | E_DBus_Connection *conn; |
106 | E_DBus_Signal_Handler *name_owner_changed_handler; | 106 | E_DBus_Signal_Handler *name_owner_changed_handler; |
107 | E_DBus_Signal_Handler *generated_signal; | 107 | E_DBus_Signal_Handler *generated_signal; |
108 | DBusPendingCall *pending_get_name_owner; | 108 | DBusPendingCall *pending_get_name_owner; |
109 | DBusPendingCall *pending_start_service_by_name; | 109 | DBusPendingCall *pending_start_service_by_name; |
110 | const char *unique_name; | 110 | const char *unique_name; |
111 | DBusPendingCall *pending_new; | 111 | DBusPendingCall *pending_new; |
112 | struct { | 112 | struct |
113 | { | ||
113 | Ethumb_Client_Connect_Cb cb; | 114 | Ethumb_Client_Connect_Cb cb; |
114 | void *data; | 115 | void *data; |
115 | Eina_Free_Cb free_data; | 116 | Eina_Free_Cb free_data; |
116 | } connect; | 117 | } connect; |
117 | Eina_List *pending_add; | 118 | Eina_List *pending_add; |
118 | Eina_List *pending_remove; | 119 | Eina_List *pending_remove; |
119 | Eina_List *pending_gen; | 120 | Eina_List *pending_gen; |
120 | DBusPendingCall *pending_clear; | 121 | DBusPendingCall *pending_clear; |
121 | DBusPendingCall *pending_setup; | 122 | DBusPendingCall *pending_setup; |
122 | struct { | 123 | struct |
124 | { | ||
123 | Ethumb_Client_Die_Cb cb; | 125 | Ethumb_Client_Die_Cb cb; |
124 | void *data; | 126 | void *data; |
125 | Eina_Free_Cb free_data; | 127 | Eina_Free_Cb free_data; |
126 | } die; | 128 | } die; |
127 | const char *object_path; | 129 | const char *object_path; |
128 | 130 | ||
129 | EINA_REFCOUNT; | 131 | EINA_REFCOUNT; |
130 | 132 | ||
131 | Eina_Bool connected : 1; | 133 | Eina_Bool connected : 1; |
132 | Eina_Bool server_started : 1; | 134 | Eina_Bool server_started : 1; |
133 | }; | 135 | }; |
134 | 136 | ||
135 | struct _ethumb_pending_add | 137 | struct _ethumb_pending_add |
136 | { | 138 | { |
137 | dbus_int32_t id; | 139 | dbus_int32_t id; |
138 | const char *file; | 140 | const char *file; |
139 | const char *key; | 141 | const char *key; |
140 | const char *thumb; | 142 | const char *thumb; |
141 | const char *thumb_key; | 143 | const char *thumb_key; |
142 | Ethumb_Client_Generate_Cb generated_cb; | 144 | Ethumb_Client_Generate_Cb generated_cb; |
143 | void *data; | 145 | void *data; |
144 | Eina_Free_Cb free_data; | 146 | Eina_Free_Cb free_data; |
145 | DBusPendingCall *pending_call; | 147 | DBusPendingCall *pending_call; |
146 | Ethumb_Client *client; | 148 | Ethumb_Client *client; |
147 | }; | 149 | }; |
148 | 150 | ||
149 | struct _ethumb_pending_remove | 151 | struct _ethumb_pending_remove |
150 | { | 152 | { |
151 | dbus_int32_t id; | 153 | dbus_int32_t id; |
152 | Ethumb_Client_Generate_Cancel_Cb cancel_cb; | 154 | Ethumb_Client_Generate_Cancel_Cb cancel_cb; |
153 | void *data; | 155 | void *data; |
154 | Eina_Free_Cb free_data; | 156 | Eina_Free_Cb free_data; |
155 | DBusPendingCall *pending_call; | 157 | DBusPendingCall *pending_call; |
156 | Ethumb_Client *client; | 158 | Ethumb_Client *client; |
157 | }; | 159 | }; |
158 | 160 | ||
159 | struct _ethumb_pending_gen | 161 | struct _ethumb_pending_gen |
160 | { | 162 | { |
161 | dbus_int32_t id; | 163 | dbus_int32_t id; |
162 | const char *file; | 164 | const char *file; |
163 | const char *key; | 165 | const char *key; |
164 | const char *thumb; | 166 | const char *thumb; |
165 | const char *thumb_key; | 167 | const char *thumb_key; |
166 | Ethumb_Client_Generate_Cb generated_cb; | 168 | Ethumb_Client_Generate_Cb generated_cb; |
167 | void *data; | 169 | void *data; |
168 | Eina_Free_Cb free_data; | 170 | Eina_Free_Cb free_data; |
169 | }; | 171 | }; |
170 | 172 | ||
171 | typedef struct _Ethumb_Async_Exists Ethumb_Async_Exists; | 173 | typedef struct _Ethumb_Async_Exists Ethumb_Async_Exists; |
172 | 174 | ||
173 | struct _Ethumb_Async_Exists | 175 | struct _Ethumb_Async_Exists |
174 | { | 176 | { |
175 | const char *path; | 177 | const char *path; |
176 | 178 | ||
177 | Ethumb *dup; /* We will work on that one to prevent race and lock */ | 179 | Ethumb *dup; /* We will work on that one to prevent race and lock */ |
178 | 180 | ||
179 | Eina_List *callbacks; | 181 | Eina_List *callbacks; |
180 | Ecore_Thread *thread; | 182 | Ecore_Thread *thread; |
181 | }; | 183 | }; |
182 | 184 | ||
183 | struct _Ethumb_Exists | 185 | struct _Ethumb_Exists |
184 | { | 186 | { |
185 | Ethumb_Async_Exists *parent; | 187 | Ethumb_Async_Exists *parent; |
186 | Ethumb_Client *client; | 188 | Ethumb_Client *client; |
187 | Ethumb *dup; /* We don't want to loose parameters so keep them around */ | 189 | Ethumb *dup; /* We don't want to loose parameters so keep them around */ |
188 | 190 | ||
189 | Ethumb_Client_Thumb_Exists_Cb exists_cb; | 191 | Ethumb_Client_Thumb_Exists_Cb exists_cb; |
190 | const void *data; | 192 | const void *data; |
191 | }; | 193 | }; |
192 | 194 | ||
193 | static const char _ethumb_dbus_bus_name[] = "org.enlightenment.Ethumb"; | 195 | static const char _ethumb_dbus_bus_name[] = "org.enlightenment.Ethumb"; |
@@ -209,30 +211,30 @@ __dbus_callback_check_and_init(const char *file, int line, const char *function, | |||
209 | { | 211 | { |
210 | if (!msg) | 212 | if (!msg) |
211 | { | 213 | { |
212 | ERR("%s:%d:%s() callback without message arguments!", | 214 | ERR("%s:%d:%s() callback without message arguments!", |
213 | file, line, function); | 215 | file, line, function); |
214 | 216 | ||
215 | if (err) | 217 | if (err) |
216 | ERR("%s:%d:%s() an error was reported by server: " | 218 | ERR("%s:%d:%s() an error was reported by server: " |
217 | "name=\"%s\", message=\"%s\"", | 219 | "name=\"%s\", message=\"%s\"", |
218 | file, line, function, err->name, err->message); | 220 | file, line, function, err->name, err->message); |
219 | 221 | ||
220 | return 0; | 222 | return 0; |
221 | } | 223 | } |
222 | 224 | ||
223 | if (!dbus_message_iter_init(msg, itr)) | 225 | if (!dbus_message_iter_init(msg, itr)) |
224 | { | 226 | { |
225 | ERR("%s:%d:%s() could not init iterator.", | 227 | ERR("%s:%d:%s() could not init iterator.", |
226 | file, line, function); | 228 | file, line, function); |
227 | return 0; | 229 | return 0; |
228 | } | 230 | } |
229 | 231 | ||
230 | return 1; | 232 | return 1; |
231 | } | 233 | } |
232 | 234 | ||
233 | #define _dbus_callback_check_and_init(msg, itr, err) \ | 235 | #define _dbus_callback_check_and_init(msg, itr, err) \ |
234 | __dbus_callback_check_and_init(__FILE__, __LINE__, __FUNCTION__, \ | 236 | __dbus_callback_check_and_init(__FILE__, __LINE__, __FUNCTION__, \ |
235 | msg, itr, err) | 237 | msg, itr, err) |
236 | 238 | ||
237 | static inline bool | 239 | static inline bool |
238 | __dbus_iter_type_check(int type, int expected, const char *expected_name) | 240 | __dbus_iter_type_check(int type, int expected, const char *expected_name) |
@@ -241,21 +243,22 @@ __dbus_iter_type_check(int type, int expected, const char *expected_name) | |||
241 | return 1; | 243 | return 1; |
242 | 244 | ||
243 | ERR("expected type %s (%c) but got %c instead!", | 245 | ERR("expected type %s (%c) but got %c instead!", |
244 | expected_name, expected, type); | 246 | expected_name, expected, type); |
245 | 247 | ||
246 | return 0; | 248 | return 0; |
247 | } | 249 | } |
250 | |||
248 | #define _dbus_iter_type_check(t, e) __dbus_iter_type_check(t, e, #e) | 251 | #define _dbus_iter_type_check(t, e) __dbus_iter_type_check(t, e, #e) |
249 | 252 | ||
250 | #define CHECK_NULL_RETURN(ptr, ...) \ | 253 | #define CHECK_NULL_RETURN(ptr, ...) \ |
251 | do \ | 254 | do \ |
252 | { \ | 255 | { \ |
253 | if ((ptr) == NULL) \ | 256 | if ((ptr) == NULL) \ |
254 | { \ | 257 | { \ |
255 | CRITICAL("%s == NULL!", #ptr); \ | 258 | CRITICAL("%s == NULL!", #ptr); \ |
256 | return __VA_ARGS__; \ | 259 | return __VA_ARGS__; \ |
257 | } \ | 260 | } \ |
258 | } \ | 261 | } \ |
259 | while (0) | 262 | while (0) |
260 | 263 | ||
261 | static void | 264 | static void |
@@ -268,44 +271,44 @@ _ethumb_client_free(Ethumb_Client *client) | |||
268 | 271 | ||
269 | EINA_LIST_FREE(client->pending_add, data) | 272 | EINA_LIST_FREE(client->pending_add, data) |
270 | { | 273 | { |
271 | struct _ethumb_pending_add *pending = data; | 274 | struct _ethumb_pending_add *pending = data; |
272 | eina_stringshare_del(pending->file); | 275 | eina_stringshare_del(pending->file); |
273 | eina_stringshare_del(pending->key); | 276 | eina_stringshare_del(pending->key); |
274 | eina_stringshare_del(pending->thumb); | 277 | eina_stringshare_del(pending->thumb); |
275 | eina_stringshare_del(pending->thumb_key); | 278 | eina_stringshare_del(pending->thumb_key); |
276 | dbus_pending_call_cancel(pending->pending_call); | 279 | dbus_pending_call_cancel(pending->pending_call); |
277 | dbus_pending_call_unref(pending->pending_call); | 280 | dbus_pending_call_unref(pending->pending_call); |
278 | if (pending->free_data) | 281 | if (pending->free_data) |
279 | pending->free_data(pending->data); | 282 | pending->free_data(pending->data); |
280 | free(pending); | 283 | free(pending); |
281 | } | 284 | } |
282 | 285 | ||
283 | EINA_LIST_FREE(client->pending_gen, data) | 286 | EINA_LIST_FREE(client->pending_gen, data) |
284 | { | 287 | { |
285 | struct _ethumb_pending_gen *pending = data; | 288 | struct _ethumb_pending_gen *pending = data; |
286 | eina_stringshare_del(pending->file); | 289 | eina_stringshare_del(pending->file); |
287 | eina_stringshare_del(pending->key); | 290 | eina_stringshare_del(pending->key); |
288 | eina_stringshare_del(pending->thumb); | 291 | eina_stringshare_del(pending->thumb); |
289 | eina_stringshare_del(pending->thumb_key); | 292 | eina_stringshare_del(pending->thumb_key); |
290 | if (pending->free_data) | 293 | if (pending->free_data) |
291 | pending->free_data(pending->data); | 294 | pending->free_data(pending->data); |
292 | free(pending); | 295 | free(pending); |
293 | } | 296 | } |
294 | 297 | ||
295 | EINA_LIST_FREE(client->pending_remove, data) | 298 | EINA_LIST_FREE(client->pending_remove, data) |
296 | { | 299 | { |
297 | struct _ethumb_pending_remove *pending = data; | 300 | struct _ethumb_pending_remove *pending = data; |
298 | dbus_pending_call_cancel(pending->pending_call); | 301 | dbus_pending_call_cancel(pending->pending_call); |
299 | dbus_pending_call_unref(pending->pending_call); | 302 | dbus_pending_call_unref(pending->pending_call); |
300 | if (pending->free_data) | 303 | if (pending->free_data) |
301 | pending->free_data(pending->data); | 304 | pending->free_data(pending->data); |
302 | free(pending); | 305 | free(pending); |
303 | } | 306 | } |
304 | 307 | ||
305 | if (client->pending_clear) | 308 | if (client->pending_clear) |
306 | { | 309 | { |
307 | dbus_pending_call_cancel(client->pending_clear); | 310 | dbus_pending_call_cancel(client->pending_clear); |
308 | dbus_pending_call_unref(client->pending_clear); | 311 | dbus_pending_call_unref(client->pending_clear); |
309 | } | 312 | } |
310 | 313 | ||
311 | end_connection: | 314 | end_connection: |
@@ -325,7 +328,7 @@ end_connection: | |||
325 | dbus_pending_call_cancel(client->pending_start_service_by_name); | 328 | dbus_pending_call_cancel(client->pending_start_service_by_name); |
326 | 329 | ||
327 | if (client->old_ethumb_conf) | 330 | if (client->old_ethumb_conf) |
328 | ethumb_free(client->old_ethumb_conf); | 331 | ethumb_free(client->old_ethumb_conf); |
329 | 332 | ||
330 | ethumb_free(client->ethumb); | 333 | ethumb_free(client->ethumb); |
331 | 334 | ||
@@ -365,19 +368,19 @@ _ethumb_client_name_owner_changed(void *data, DBusMessage *msg) | |||
365 | 368 | ||
366 | dbus_error_init(&err); | 369 | dbus_error_init(&err); |
367 | if (!dbus_message_get_args(msg, &err, | 370 | if (!dbus_message_get_args(msg, &err, |
368 | DBUS_TYPE_STRING, &name, | 371 | DBUS_TYPE_STRING, &name, |
369 | DBUS_TYPE_STRING, &from, | 372 | DBUS_TYPE_STRING, &from, |
370 | DBUS_TYPE_STRING, &to, | 373 | DBUS_TYPE_STRING, &to, |
371 | DBUS_TYPE_INVALID)) | 374 | DBUS_TYPE_INVALID)) |
372 | { | 375 | { |
373 | ERR("could not get NameOwnerChanged arguments: %s: %s", | 376 | ERR("could not get NameOwnerChanged arguments: %s: %s", |
374 | err.name, err.message); | 377 | err.name, err.message); |
375 | dbus_error_free(&err); | 378 | dbus_error_free(&err); |
376 | return; | 379 | return; |
377 | } | 380 | } |
378 | 381 | ||
379 | if(!from || !name) | 382 | if (!from || !name) |
380 | return ; | 383 | return; |
381 | if (strcmp(name, _ethumb_dbus_bus_name) != 0) | 384 | if (strcmp(name, _ethumb_dbus_bus_name) != 0) |
382 | return; | 385 | return; |
383 | 386 | ||
@@ -385,25 +388,25 @@ _ethumb_client_name_owner_changed(void *data, DBusMessage *msg) | |||
385 | 388 | ||
386 | if (from[0] != '\0' && to[0] == '\0') | 389 | if (from[0] != '\0' && to[0] == '\0') |
387 | { | 390 | { |
388 | DBG("exit ethumbd at %s", from); | 391 | DBG("exit ethumbd at %s", from); |
389 | if (client->unique_name && strcmp(client->unique_name, from) != 0) | 392 | if (client->unique_name && strcmp(client->unique_name, from) != 0) |
390 | WRN("%s was not the known name %s, ignored.", | 393 | WRN("%s was not the known name %s, ignored.", |
391 | from, client->unique_name); | 394 | from, client->unique_name); |
392 | else if(client->unique_name) | 395 | else if (client->unique_name) |
393 | { | 396 | { |
394 | ERR("server exit!!!"); | 397 | ERR("server exit!!!"); |
395 | if (client->die.cb) | 398 | if (client->die.cb) |
396 | { | 399 | { |
397 | client->die.cb(client->die.data, client); | 400 | client->die.cb(client->die.data, client); |
398 | client->die.cb = NULL; | 401 | client->die.cb = NULL; |
399 | } | 402 | } |
400 | if (client->die.free_data) | 403 | if (client->die.free_data) |
401 | { | 404 | { |
402 | client->die.free_data(client->die.data); | 405 | client->die.free_data(client->die.data); |
403 | client->die.free_data = NULL; | 406 | client->die.free_data = NULL; |
404 | client->die.data = NULL; | 407 | client->die.data = NULL; |
405 | } | 408 | } |
406 | } | 409 | } |
407 | } | 410 | } |
408 | else | 411 | else |
409 | DBG("unknown change from %s to %s", from, to); | 412 | DBG("unknown change from %s to %s", from, to); |
@@ -414,15 +417,15 @@ _ethumb_client_report_connect(Ethumb_Client *client, Eina_Bool success) | |||
414 | { | 417 | { |
415 | if (!client->connect.cb) | 418 | if (!client->connect.cb) |
416 | { | 419 | { |
417 | ERR("already called?!"); | 420 | ERR("already called?!"); |
418 | return; | 421 | return; |
419 | } | 422 | } |
420 | 423 | ||
421 | client->connect.cb(client->connect.data, client, success); | 424 | client->connect.cb(client->connect.data, client, success); |
422 | if (client->connect.free_data) | 425 | if (client->connect.free_data) |
423 | { | 426 | { |
424 | client->connect.free_data(client->connect.data); | 427 | client->connect.free_data(client->connect.data); |
425 | client->connect.free_data = NULL; | 428 | client->connect.free_data = NULL; |
426 | } | 429 | } |
427 | client->connect.cb = NULL; | 430 | client->connect.cb = NULL; |
428 | client->connect.data = NULL; | 431 | client->connect.data = NULL; |
@@ -451,9 +454,9 @@ _ethumb_client_new_cb(void *data, DBusMessage *msg, DBusError *error) | |||
451 | client->object_path = eina_stringshare_add(opath); | 454 | client->object_path = eina_stringshare_add(opath); |
452 | 455 | ||
453 | client->generated_signal = e_dbus_signal_handler_add( | 456 | client->generated_signal = e_dbus_signal_handler_add( |
454 | client->conn, _ethumb_dbus_bus_name, opath, | 457 | client->conn, _ethumb_dbus_bus_name, opath, |
455 | _ethumb_dbus_objects_interface, "generated", | 458 | _ethumb_dbus_objects_interface, "generated", |
456 | _ethumb_client_generated_cb, client); | 459 | _ethumb_client_generated_cb, client); |
457 | 460 | ||
458 | _ethumb_client_report_connect(client, 1); | 461 | _ethumb_client_report_connect(client, 1); |
459 | return; | 462 | return; |
@@ -468,10 +471,10 @@ _ethumb_client_call_new(Ethumb_Client *client) | |||
468 | DBusMessage *msg; | 471 | DBusMessage *msg; |
469 | 472 | ||
470 | msg = dbus_message_new_method_call(_ethumb_dbus_bus_name, _ethumb_dbus_path, | 473 | msg = dbus_message_new_method_call(_ethumb_dbus_bus_name, _ethumb_dbus_path, |
471 | _ethumb_dbus_interface, "new"); | 474 | _ethumb_dbus_interface, "new"); |
472 | client->pending_new = e_dbus_message_send(client->conn, msg, | 475 | client->pending_new = e_dbus_message_send(client->conn, msg, |
473 | _ethumb_client_new_cb, -1, | 476 | _ethumb_client_new_cb, -1, |
474 | client); | 477 | client); |
475 | dbus_message_unref(msg); | 478 | dbus_message_unref(msg); |
476 | } | 479 | } |
477 | 480 | ||
@@ -495,9 +498,9 @@ _ethumb_client_start_server_cb(void *data, DBusMessage *msg, DBusError *err) | |||
495 | dbus_message_iter_get_basic(&iter, &ret); | 498 | dbus_message_iter_get_basic(&iter, &ret); |
496 | if ((ret != 1) && (ret != 2)) | 499 | if ((ret != 1) && (ret != 2)) |
497 | { | 500 | { |
498 | ERR("Error starting Ethumbd DBus service by its name: retcode %u", | 501 | ERR("Error starting Ethumbd DBus service by its name: retcode %u", |
499 | ret); | 502 | ret); |
500 | goto error; | 503 | goto error; |
501 | } | 504 | } |
502 | 505 | ||
503 | client->server_started = 1; | 506 | client->server_started = 1; |
@@ -506,22 +509,22 @@ _ethumb_client_start_server_cb(void *data, DBusMessage *msg, DBusError *err) | |||
506 | 509 | ||
507 | if (client->pending_get_name_owner) | 510 | if (client->pending_get_name_owner) |
508 | { | 511 | { |
509 | DBG("already requesting name owner, cancel and try again"); | 512 | DBG("already requesting name owner, cancel and try again"); |
510 | dbus_pending_call_cancel(client->pending_get_name_owner); | 513 | dbus_pending_call_cancel(client->pending_get_name_owner); |
511 | } | 514 | } |
512 | 515 | ||
513 | client->pending_get_name_owner = e_dbus_get_name_owner | 516 | client->pending_get_name_owner = e_dbus_get_name_owner |
514 | (client->conn, _ethumb_dbus_bus_name, _ethumb_client_get_name_owner, | 517 | (client->conn, _ethumb_dbus_bus_name, _ethumb_client_get_name_owner, |
515 | client); | 518 | client); |
516 | if (!client->pending_get_name_owner) | 519 | if (!client->pending_get_name_owner) |
517 | { | 520 | { |
518 | ERR("could not create a get_name_owner request."); | 521 | ERR("could not create a get_name_owner request."); |
519 | goto error; | 522 | goto error; |
520 | } | 523 | } |
521 | 524 | ||
522 | return; | 525 | return; |
523 | 526 | ||
524 | error: | 527 | error: |
525 | ERR("failed to start Ethumbd DBus service by its name."); | 528 | ERR("failed to start Ethumbd DBus service by its name."); |
526 | _ethumb_client_report_connect(client, 0); | 529 | _ethumb_client_report_connect(client, 0); |
527 | } | 530 | } |
@@ -531,18 +534,18 @@ _ethumb_client_start_server(Ethumb_Client *client) | |||
531 | { | 534 | { |
532 | if (client->pending_start_service_by_name) | 535 | if (client->pending_start_service_by_name) |
533 | { | 536 | { |
534 | DBG("already pending start service by name."); | 537 | DBG("already pending start service by name."); |
535 | return; | 538 | return; |
536 | } | 539 | } |
537 | 540 | ||
538 | client->server_started = 0; | 541 | client->server_started = 0; |
539 | client->pending_start_service_by_name = e_dbus_start_service_by_name | 542 | client->pending_start_service_by_name = e_dbus_start_service_by_name |
540 | (client->conn, _ethumb_dbus_bus_name, 0, _ethumb_client_start_server_cb, | 543 | (client->conn, _ethumb_dbus_bus_name, 0, _ethumb_client_start_server_cb, |
541 | client); | 544 | client); |
542 | if (!client->pending_start_service_by_name) | 545 | if (!client->pending_start_service_by_name) |
543 | { | 546 | { |
544 | ERR("could not start service by name!"); | 547 | ERR("could not start service by name!"); |
545 | _ethumb_client_report_connect(client, 0); | 548 | _ethumb_client_report_connect(client, 0); |
546 | } | 549 | } |
547 | } | 550 | } |
548 | 551 | ||
@@ -558,9 +561,9 @@ _ethumb_client_get_name_owner(void *data, DBusMessage *msg, DBusError *err) | |||
558 | 561 | ||
559 | if (dbus_error_is_set(err) && (!client->server_started)) | 562 | if (dbus_error_is_set(err) && (!client->server_started)) |
560 | { | 563 | { |
561 | DBG("could not find server (%s), try to start it...", err->message); | 564 | DBG("could not find server (%s), try to start it...", err->message); |
562 | _ethumb_client_start_server(client); | 565 | _ethumb_client_start_server(client); |
563 | return; | 566 | return; |
564 | } | 567 | } |
565 | 568 | ||
566 | if (!_dbus_callback_check_and_init(msg, &iter, err)) | 569 | if (!_dbus_callback_check_and_init(msg, &iter, err)) |
@@ -573,8 +576,8 @@ _ethumb_client_get_name_owner(void *data, DBusMessage *msg, DBusError *err) | |||
573 | dbus_message_iter_get_basic(&iter, &uid); | 576 | dbus_message_iter_get_basic(&iter, &uid); |
574 | if (!uid) | 577 | if (!uid) |
575 | { | 578 | { |
576 | ERR("no name owner!"); | 579 | ERR("no name owner!"); |
577 | goto error; | 580 | goto error; |
578 | } | 581 | } |
579 | 582 | ||
580 | DBG("unique name = %s", uid); | 583 | DBG("unique name = %s", uid); |
@@ -610,13 +613,13 @@ _ethumb_client_exists_end(void *data, Ecore_Thread *thread __UNUSED__) | |||
610 | tmp = cb->client->ethumb; | 613 | tmp = cb->client->ethumb; |
611 | cb->client->ethumb = cb->dup; | 614 | cb->client->ethumb = cb->dup; |
612 | 615 | ||
613 | cb->exists_cb((void*) cb->data, | 616 | cb->exists_cb((void *)cb->data, |
614 | cb->client, cb, | 617 | cb->client, cb, |
615 | ethumb_exists(cb->client->ethumb)); | 618 | ethumb_exists(cb->client->ethumb)); |
616 | 619 | ||
617 | cb->client->ethumb = tmp; | 620 | cb->client->ethumb = tmp; |
618 | EINA_REFCOUNT_UNREF(cb->client) | 621 | EINA_REFCOUNT_UNREF(cb->client) |
619 | _ethumb_client_free(cb->client); | 622 | _ethumb_client_free(cb->client); |
620 | ethumb_free(cb->dup); | 623 | ethumb_free(cb->dup); |
621 | free(cb); | 624 | free(cb); |
622 | } | 625 | } |
@@ -655,15 +658,15 @@ ethumb_client_init(void) | |||
655 | 658 | ||
656 | if (!eina_init()) | 659 | if (!eina_init()) |
657 | { | 660 | { |
658 | fprintf(stderr, "ERROR: Could not initialize log module.\n"); | 661 | fprintf(stderr, "ERROR: Could not initialize log module.\n"); |
659 | return 0; | 662 | return 0; |
660 | } | 663 | } |
661 | _log_dom = eina_log_domain_register("ethumb_client", EINA_COLOR_YELLOW); | 664 | _log_dom = eina_log_domain_register("ethumb_client", EINA_COLOR_YELLOW); |
662 | if (_log_dom < 0) | 665 | if (_log_dom < 0) |
663 | { | 666 | { |
664 | EINA_LOG_ERR("Could not register log domain: ethumb_client"); | 667 | EINA_LOG_ERR("Could not register log domain: ethumb_client"); |
665 | eina_shutdown(); | 668 | eina_shutdown(); |
666 | return 0; | 669 | return 0; |
667 | } | 670 | } |
668 | 671 | ||
669 | ethumb_init(); | 672 | ethumb_init(); |
@@ -757,8 +760,8 @@ ethumb_client_connect(Ethumb_Client_Connect_Cb connect_cb, const void *data, Ein | |||
757 | eclient = calloc(1, sizeof(*eclient)); | 760 | eclient = calloc(1, sizeof(*eclient)); |
758 | if (!eclient) | 761 | if (!eclient) |
759 | { | 762 | { |
760 | ERR("could not allocate Ethumb_Client structure."); | 763 | ERR("could not allocate Ethumb_Client structure."); |
761 | goto err; | 764 | goto err; |
762 | } | 765 | } |
763 | 766 | ||
764 | eclient->old_ethumb_conf = NULL; | 767 | eclient->old_ethumb_conf = NULL; |
@@ -769,28 +772,28 @@ ethumb_client_connect(Ethumb_Client_Connect_Cb connect_cb, const void *data, Ein | |||
769 | eclient->ethumb = ethumb_new(); | 772 | eclient->ethumb = ethumb_new(); |
770 | if (!eclient->ethumb) | 773 | if (!eclient->ethumb) |
771 | { | 774 | { |
772 | ERR("could not create ethumb handler."); | 775 | ERR("could not create ethumb handler."); |
773 | goto ethumb_new_err; | 776 | goto ethumb_new_err; |
774 | } | 777 | } |
775 | 778 | ||
776 | eclient->conn = e_dbus_bus_get(DBUS_BUS_SESSION); | 779 | eclient->conn = e_dbus_bus_get(DBUS_BUS_SESSION); |
777 | if (!eclient->conn) | 780 | if (!eclient->conn) |
778 | { | 781 | { |
779 | ERR("could not connect to session bus."); | 782 | ERR("could not connect to session bus."); |
780 | goto connection_err; | 783 | goto connection_err; |
781 | } | 784 | } |
782 | 785 | ||
783 | eclient->name_owner_changed_handler = e_dbus_signal_handler_add( | 786 | eclient->name_owner_changed_handler = e_dbus_signal_handler_add( |
784 | eclient->conn, fdo_bus_name, fdo_path, fdo_interface, | 787 | eclient->conn, fdo_bus_name, fdo_path, fdo_interface, |
785 | "NameOwnerChanged", _ethumb_client_name_owner_changed, eclient); | 788 | "NameOwnerChanged", _ethumb_client_name_owner_changed, eclient); |
786 | 789 | ||
787 | eclient->pending_get_name_owner = e_dbus_get_name_owner( | 790 | eclient->pending_get_name_owner = e_dbus_get_name_owner( |
788 | eclient->conn, _ethumb_dbus_bus_name, _ethumb_client_get_name_owner, | 791 | eclient->conn, _ethumb_dbus_bus_name, _ethumb_client_get_name_owner, |
789 | eclient); | 792 | eclient); |
790 | if (!eclient->pending_get_name_owner) | 793 | if (!eclient->pending_get_name_owner) |
791 | { | 794 | { |
792 | ERR("could not create a get_name_owner request."); | 795 | ERR("could not create a get_name_owner request."); |
793 | goto connection_err; | 796 | goto connection_err; |
794 | } | 797 | } |
795 | 798 | ||
796 | EINA_REFCOUNT_INIT(eclient); | 799 | EINA_REFCOUNT_INIT(eclient); |
@@ -823,7 +826,7 @@ ethumb_client_disconnect(Ethumb_Client *client) | |||
823 | EINA_SAFETY_ON_NULL_RETURN(client); | 826 | EINA_SAFETY_ON_NULL_RETURN(client); |
824 | 827 | ||
825 | EINA_REFCOUNT_UNREF(client) | 828 | EINA_REFCOUNT_UNREF(client) |
826 | _ethumb_client_free(client); | 829 | _ethumb_client_free(client); |
827 | } | 830 | } |
828 | 831 | ||
829 | /** | 832 | /** |
@@ -895,8 +898,8 @@ _ethumb_client_dbus_get_bytearray(DBusMessageIter *iter) | |||
895 | el_type = dbus_message_iter_get_element_type(iter); | 898 | el_type = dbus_message_iter_get_element_type(iter); |
896 | if (el_type != DBUS_TYPE_BYTE) | 899 | if (el_type != DBUS_TYPE_BYTE) |
897 | { | 900 | { |
898 | ERR("not an byte array element."); | 901 | ERR("not an byte array element."); |
899 | return NULL; | 902 | return NULL; |
900 | } | 903 | } |
901 | 904 | ||
902 | dbus_message_iter_recurse(iter, &riter); | 905 | dbus_message_iter_recurse(iter, &riter); |
@@ -918,7 +921,7 @@ _ethumb_client_dbus_append_bytearray(DBusMessageIter *iter, const char *string) | |||
918 | 921 | ||
919 | dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, "y", &viter); | 922 | dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, "y", &viter); |
920 | dbus_message_iter_append_fixed_array(&viter, DBUS_TYPE_BYTE, &string, | 923 | dbus_message_iter_append_fixed_array(&viter, DBUS_TYPE_BYTE, &string, |
921 | strlen(string) + 1); | 924 | strlen(string) + 1); |
922 | dbus_message_iter_close_container(iter, &viter); | 925 | dbus_message_iter_close_container(iter, &viter); |
923 | } | 926 | } |
924 | 927 | ||
@@ -954,25 +957,25 @@ ethumb_client_ethumb_setup(Ethumb_Client *client) | |||
954 | EINA_SAFETY_ON_FALSE_RETURN(client->connected); | 957 | EINA_SAFETY_ON_FALSE_RETURN(client->connected); |
955 | 958 | ||
956 | msg = dbus_message_new_method_call(_ethumb_dbus_bus_name, | 959 | msg = dbus_message_new_method_call(_ethumb_dbus_bus_name, |
957 | client->object_path, | 960 | client->object_path, |
958 | _ethumb_dbus_objects_interface, | 961 | _ethumb_dbus_objects_interface, |
959 | "ethumb_setup"); | 962 | "ethumb_setup"); |
960 | dbus_message_iter_init_append(msg, &iter); | 963 | dbus_message_iter_init_append(msg, &iter); |
961 | dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "{sv}", &aiter); | 964 | dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "{sv}", &aiter); |
962 | 965 | ||
963 | /** | 966 | /** |
964 | * @cond LOCAL | 967 | * @cond LOCAL |
965 | */ | 968 | */ |
966 | #define _open_variant_iter(str_entry, str_type, end_iter) \ | 969 | #define _open_variant_iter(str_entry, str_type, end_iter) \ |
967 | entry = str_entry; \ | 970 | entry = str_entry; \ |
968 | dbus_message_iter_open_container(&aiter, DBUS_TYPE_DICT_ENTRY, NULL, &diter); \ | 971 | dbus_message_iter_open_container(&aiter, DBUS_TYPE_DICT_ENTRY, NULL, &diter); \ |
969 | dbus_message_iter_append_basic(&diter, DBUS_TYPE_STRING, &entry); \ | 972 | dbus_message_iter_append_basic(&diter, DBUS_TYPE_STRING, &entry); \ |
970 | dbus_message_iter_open_container(&diter, DBUS_TYPE_VARIANT, str_type, \ | 973 | dbus_message_iter_open_container(&diter, DBUS_TYPE_VARIANT, str_type, \ |
971 | &end_iter); | 974 | &end_iter); |
972 | 975 | ||
973 | #define _close_variant_iter(end_iter) \ | 976 | #define _close_variant_iter(end_iter) \ |
974 | dbus_message_iter_close_container(&diter, &end_iter); \ | 977 | dbus_message_iter_close_container(&diter, &end_iter); \ |
975 | dbus_message_iter_close_container(&aiter, &diter); | 978 | dbus_message_iter_close_container(&aiter, &diter); |
976 | /** | 979 | /** |
977 | * @endcond | 980 | * @endcond |
978 | */ | 981 | */ |
@@ -1077,8 +1080,8 @@ ethumb_client_ethumb_setup(Ethumb_Client *client) | |||
1077 | dbus_message_iter_close_container(&iter, &aiter); | 1080 | dbus_message_iter_close_container(&iter, &aiter); |
1078 | 1081 | ||
1079 | client->pending_setup = e_dbus_message_send(client->conn, msg, | 1082 | client->pending_setup = e_dbus_message_send(client->conn, msg, |
1080 | _ethumb_client_ethumb_setup_cb, | 1083 | _ethumb_client_ethumb_setup_cb, |
1081 | -1, client); | 1084 | -1, client); |
1082 | dbus_message_unref(msg); | 1085 | dbus_message_unref(msg); |
1083 | } | 1086 | } |
1084 | 1087 | ||
@@ -1129,30 +1132,30 @@ _ethumb_client_generated_cb(void *data, DBusMessage *msg) | |||
1129 | l = client->pending_gen; | 1132 | l = client->pending_gen; |
1130 | while (l) | 1133 | while (l) |
1131 | { | 1134 | { |
1132 | pending = l->data; | 1135 | pending = l->data; |
1133 | if (pending->id == id) | 1136 | if (pending->id == id) |
1134 | { | 1137 | { |
1135 | found = 1; | 1138 | found = 1; |
1136 | break; | 1139 | break; |
1137 | } | 1140 | } |
1138 | l = l->next; | 1141 | l = l->next; |
1139 | } | 1142 | } |
1140 | 1143 | ||
1141 | if (found) | 1144 | if (found) |
1142 | { | 1145 | { |
1143 | client->pending_gen = eina_list_remove_list(client->pending_gen, l); | 1146 | client->pending_gen = eina_list_remove_list(client->pending_gen, l); |
1144 | if (pending->generated_cb) | 1147 | if (pending->generated_cb) |
1145 | pending->generated_cb(pending->data, client, id, | 1148 | pending->generated_cb(pending->data, client, id, |
1146 | pending->file, pending->key, | 1149 | pending->file, pending->key, |
1147 | pending->thumb, pending->thumb_key, | 1150 | pending->thumb, pending->thumb_key, |
1148 | success); | 1151 | success); |
1149 | if (pending->free_data) | 1152 | if (pending->free_data) |
1150 | pending->free_data(pending->data); | 1153 | pending->free_data(pending->data); |
1151 | eina_stringshare_del(pending->file); | 1154 | eina_stringshare_del(pending->file); |
1152 | eina_stringshare_del(pending->key); | 1155 | eina_stringshare_del(pending->key); |
1153 | eina_stringshare_del(pending->thumb); | 1156 | eina_stringshare_del(pending->thumb); |
1154 | eina_stringshare_del(pending->thumb_key); | 1157 | eina_stringshare_del(pending->thumb_key); |
1155 | free(pending); | 1158 | free(pending); |
1156 | } | 1159 | } |
1157 | 1160 | ||
1158 | end: | 1161 | end: |
@@ -1217,9 +1220,9 @@ _ethumb_client_queue_add(Ethumb_Client *client, const char *file, const char *ke | |||
1217 | client->id_count = (client->id_count + 1) % MAX_ID; | 1220 | client->id_count = (client->id_count + 1) % MAX_ID; |
1218 | 1221 | ||
1219 | msg = dbus_message_new_method_call(_ethumb_dbus_bus_name, | 1222 | msg = dbus_message_new_method_call(_ethumb_dbus_bus_name, |
1220 | client->object_path, | 1223 | client->object_path, |
1221 | _ethumb_dbus_objects_interface, | 1224 | _ethumb_dbus_objects_interface, |
1222 | "queue_add"); | 1225 | "queue_add"); |
1223 | 1226 | ||
1224 | dbus_message_iter_init_append(msg, &iter); | 1227 | dbus_message_iter_init_append(msg, &iter); |
1225 | dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &pending->id); | 1228 | dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &pending->id); |
@@ -1229,8 +1232,8 @@ _ethumb_client_queue_add(Ethumb_Client *client, const char *file, const char *ke | |||
1229 | _ethumb_client_dbus_append_bytearray(&iter, thumb_key); | 1232 | _ethumb_client_dbus_append_bytearray(&iter, thumb_key); |
1230 | 1233 | ||
1231 | pending->pending_call = e_dbus_message_send(client->conn, msg, | 1234 | pending->pending_call = e_dbus_message_send(client->conn, msg, |
1232 | _ethumb_client_queue_add_cb, | 1235 | _ethumb_client_queue_add_cb, |
1233 | -1, pending); | 1236 | -1, pending); |
1234 | client->pending_add = eina_list_append(client->pending_add, pending); | 1237 | client->pending_add = eina_list_append(client->pending_add, pending); |
1235 | dbus_message_unref(msg); | 1238 | dbus_message_unref(msg); |
1236 | 1239 | ||
@@ -1264,6 +1267,7 @@ end: | |||
1264 | pending->free_data(pending->data); | 1267 | pending->free_data(pending->data); |
1265 | free(pending); | 1268 | free(pending); |
1266 | } | 1269 | } |
1270 | |||
1267 | /** | 1271 | /** |
1268 | * @endcond | 1272 | * @endcond |
1269 | */ | 1273 | */ |
@@ -1302,38 +1306,38 @@ ethumb_client_generate_cancel(Ethumb_Client *client, int id, Ethumb_Client_Gener | |||
1302 | pending->client = client; | 1306 | pending->client = client; |
1303 | 1307 | ||
1304 | msg = dbus_message_new_method_call(_ethumb_dbus_bus_name, | 1308 | msg = dbus_message_new_method_call(_ethumb_dbus_bus_name, |
1305 | client->object_path, | 1309 | client->object_path, |
1306 | _ethumb_dbus_objects_interface, | 1310 | _ethumb_dbus_objects_interface, |
1307 | "queue_remove"); | 1311 | "queue_remove"); |
1308 | 1312 | ||
1309 | dbus_message_append_args(msg, DBUS_TYPE_INT32, &id32, DBUS_TYPE_INVALID); | 1313 | dbus_message_append_args(msg, DBUS_TYPE_INT32, &id32, DBUS_TYPE_INVALID); |
1310 | pending->pending_call = e_dbus_message_send(client->conn, msg, | 1314 | pending->pending_call = e_dbus_message_send(client->conn, msg, |
1311 | _ethumb_client_queue_remove_cb, | 1315 | _ethumb_client_queue_remove_cb, |
1312 | -1, pending); | 1316 | -1, pending); |
1313 | client->pending_remove = eina_list_append(client->pending_remove, pending); | 1317 | client->pending_remove = eina_list_append(client->pending_remove, pending); |
1314 | 1318 | ||
1315 | found = 0; | 1319 | found = 0; |
1316 | l = client->pending_add; | 1320 | l = client->pending_add; |
1317 | while (l) | 1321 | while (l) |
1318 | { | 1322 | { |
1319 | struct _ethumb_pending_add *pending_add = l->data; | 1323 | struct _ethumb_pending_add *pending_add = l->data; |
1320 | if (pending_add->id != id32) | 1324 | if (pending_add->id != id32) |
1321 | { | 1325 | { |
1322 | l = l->next; | 1326 | l = l->next; |
1323 | continue; | 1327 | continue; |
1324 | } | 1328 | } |
1325 | client->pending_add = eina_list_remove_list(client->pending_add, l); | 1329 | client->pending_add = eina_list_remove_list(client->pending_add, l); |
1326 | eina_stringshare_del(pending_add->file); | 1330 | eina_stringshare_del(pending_add->file); |
1327 | eina_stringshare_del(pending_add->key); | 1331 | eina_stringshare_del(pending_add->key); |
1328 | eina_stringshare_del(pending_add->thumb); | 1332 | eina_stringshare_del(pending_add->thumb); |
1329 | eina_stringshare_del(pending_add->thumb_key); | 1333 | eina_stringshare_del(pending_add->thumb_key); |
1330 | dbus_pending_call_cancel(pending_add->pending_call); | 1334 | dbus_pending_call_cancel(pending_add->pending_call); |
1331 | dbus_pending_call_unref(pending_add->pending_call); | 1335 | dbus_pending_call_unref(pending_add->pending_call); |
1332 | if (pending_add->free_data) | 1336 | if (pending_add->free_data) |
1333 | pending_add->free_data(pending_add->data); | 1337 | pending_add->free_data(pending_add->data); |
1334 | free(pending_add); | 1338 | free(pending_add); |
1335 | found = 1; | 1339 | found = 1; |
1336 | break; | 1340 | break; |
1337 | } | 1341 | } |
1338 | 1342 | ||
1339 | if (found) | 1343 | if (found) |
@@ -1342,21 +1346,21 @@ ethumb_client_generate_cancel(Ethumb_Client *client, int id, Ethumb_Client_Gener | |||
1342 | l = client->pending_gen; | 1346 | l = client->pending_gen; |
1343 | while (l) | 1347 | while (l) |
1344 | { | 1348 | { |
1345 | struct _ethumb_pending_gen *pending_gen = l->data; | 1349 | struct _ethumb_pending_gen *pending_gen = l->data; |
1346 | if (pending_gen->id != id32) | 1350 | if (pending_gen->id != id32) |
1347 | { | 1351 | { |
1348 | l = l->next; | 1352 | l = l->next; |
1349 | continue; | 1353 | continue; |
1350 | } | 1354 | } |
1351 | client->pending_gen = eina_list_remove_list(client->pending_gen, l); | 1355 | client->pending_gen = eina_list_remove_list(client->pending_gen, l); |
1352 | eina_stringshare_del(pending_gen->file); | 1356 | eina_stringshare_del(pending_gen->file); |
1353 | eina_stringshare_del(pending_gen->key); | 1357 | eina_stringshare_del(pending_gen->key); |
1354 | eina_stringshare_del(pending_gen->thumb); | 1358 | eina_stringshare_del(pending_gen->thumb); |
1355 | eina_stringshare_del(pending_gen->thumb_key); | 1359 | eina_stringshare_del(pending_gen->thumb_key); |
1356 | if (pending_gen->free_data) | 1360 | if (pending_gen->free_data) |
1357 | pending_gen->free_data(pending_gen->data); | 1361 | pending_gen->free_data(pending_gen->data); |
1358 | free(pending_gen); | 1362 | free(pending_gen); |
1359 | break; | 1363 | break; |
1360 | } | 1364 | } |
1361 | 1365 | ||
1362 | end: | 1366 | end: |
@@ -1373,6 +1377,7 @@ _ethumb_client_queue_clear_cb(void *data, DBusMessage *msg __UNUSED__, DBusError | |||
1373 | 1377 | ||
1374 | client->pending_clear = NULL; | 1378 | client->pending_clear = NULL; |
1375 | } | 1379 | } |
1380 | |||
1376 | /** | 1381 | /** |
1377 | * @endcond | 1382 | * @endcond |
1378 | */ | 1383 | */ |
@@ -1397,38 +1402,38 @@ ethumb_client_generate_cancel_all(Ethumb_Client *client) | |||
1397 | 1402 | ||
1398 | EINA_LIST_FREE(client->pending_add, data) | 1403 | EINA_LIST_FREE(client->pending_add, data) |
1399 | { | 1404 | { |
1400 | struct _ethumb_pending_add *pending = data; | 1405 | struct _ethumb_pending_add *pending = data; |
1401 | eina_stringshare_del(pending->file); | 1406 | eina_stringshare_del(pending->file); |
1402 | eina_stringshare_del(pending->key); | 1407 | eina_stringshare_del(pending->key); |
1403 | eina_stringshare_del(pending->thumb); | 1408 | eina_stringshare_del(pending->thumb); |
1404 | eina_stringshare_del(pending->thumb_key); | 1409 | eina_stringshare_del(pending->thumb_key); |
1405 | dbus_pending_call_cancel(pending->pending_call); | 1410 | dbus_pending_call_cancel(pending->pending_call); |
1406 | dbus_pending_call_unref(pending->pending_call); | 1411 | dbus_pending_call_unref(pending->pending_call); |
1407 | if (pending->free_data) | 1412 | if (pending->free_data) |
1408 | pending->free_data(pending->data); | 1413 | pending->free_data(pending->data); |
1409 | free(pending); | 1414 | free(pending); |
1410 | } | 1415 | } |
1411 | 1416 | ||
1412 | EINA_LIST_FREE(client->pending_gen, data) | 1417 | EINA_LIST_FREE(client->pending_gen, data) |
1413 | { | 1418 | { |
1414 | struct _ethumb_pending_gen *pending = data; | 1419 | struct _ethumb_pending_gen *pending = data; |
1415 | eina_stringshare_del(pending->file); | 1420 | eina_stringshare_del(pending->file); |
1416 | eina_stringshare_del(pending->key); | 1421 | eina_stringshare_del(pending->key); |
1417 | eina_stringshare_del(pending->thumb); | 1422 | eina_stringshare_del(pending->thumb); |
1418 | eina_stringshare_del(pending->thumb_key); | 1423 | eina_stringshare_del(pending->thumb_key); |
1419 | if (pending->free_data) | 1424 | if (pending->free_data) |
1420 | pending->free_data(pending->data); | 1425 | pending->free_data(pending->data); |
1421 | free(pending); | 1426 | free(pending); |
1422 | } | 1427 | } |
1423 | 1428 | ||
1424 | msg = dbus_message_new_method_call(_ethumb_dbus_bus_name, | 1429 | msg = dbus_message_new_method_call(_ethumb_dbus_bus_name, |
1425 | client->object_path, | 1430 | client->object_path, |
1426 | _ethumb_dbus_objects_interface, | 1431 | _ethumb_dbus_objects_interface, |
1427 | "queue_clear"); | 1432 | "queue_clear"); |
1428 | 1433 | ||
1429 | client->pending_clear = e_dbus_message_send(client->conn, msg, | 1434 | client->pending_clear = e_dbus_message_send(client->conn, msg, |
1430 | _ethumb_client_queue_clear_cb, | 1435 | _ethumb_client_queue_clear_cb, |
1431 | -1, client); | 1436 | -1, client); |
1432 | 1437 | ||
1433 | dbus_message_unref(msg); | 1438 | dbus_message_unref(msg); |
1434 | } | 1439 | } |
@@ -2230,8 +2235,8 @@ ethumb_client_thumb_exists(Ethumb_Client *client, Ethumb_Client_Thumb_Exists_Cb | |||
2230 | 2235 | ||
2231 | return cb; | 2236 | return cb; |
2232 | 2237 | ||
2233 | on_error: | 2238 | on_error: |
2234 | exists_cb((void*) data, client, NULL, EINA_FALSE); | 2239 | exists_cb((void *)data, client, NULL, EINA_FALSE); |
2235 | 2240 | ||
2236 | if (async) | 2241 | if (async) |
2237 | { | 2242 | { |
@@ -2258,7 +2263,7 @@ ethumb_client_thumb_exists_cancel(Ethumb_Exists *exists) | |||
2258 | 2263 | ||
2259 | ethumb_free(exists->dup); | 2264 | ethumb_free(exists->dup); |
2260 | EINA_REFCOUNT_UNREF(exists->client) | 2265 | EINA_REFCOUNT_UNREF(exists->client) |
2261 | _ethumb_client_free(exists->client); | 2266 | _ethumb_client_free(exists->client); |
2262 | free(exists); | 2267 | free(exists); |
2263 | } | 2268 | } |
2264 | 2269 | ||
@@ -2325,8 +2330,8 @@ ethumb_client_generate(Ethumb_Client *client, Ethumb_Client_Generate_Cb generate | |||
2325 | ethumb_file_get(client->ethumb, &file, &key); | 2330 | ethumb_file_get(client->ethumb, &file, &key); |
2326 | if (!file) | 2331 | if (!file) |
2327 | { | 2332 | { |
2328 | ERR("no file set."); | 2333 | ERR("no file set."); |
2329 | return -1; | 2334 | return -1; |
2330 | } | 2335 | } |
2331 | 2336 | ||
2332 | ethumb_thumb_path_get(client->ethumb, &thumb, &thumb_key); | 2337 | ethumb_thumb_path_get(client->ethumb, &thumb, &thumb_key); |
@@ -2334,27 +2339,27 @@ ethumb_client_generate(Ethumb_Client *client, Ethumb_Client_Generate_Cb generate | |||
2334 | if (client->old_ethumb_conf && | 2339 | if (client->old_ethumb_conf && |
2335 | ethumb_cmp(client->old_ethumb_conf, client->ethumb)) | 2340 | ethumb_cmp(client->old_ethumb_conf, client->ethumb)) |
2336 | { | 2341 | { |
2337 | ethumb_client_ethumb_setup(client); | 2342 | ethumb_client_ethumb_setup(client); |
2338 | ethumb_free(client->old_ethumb_conf); | 2343 | ethumb_free(client->old_ethumb_conf); |
2339 | client->old_ethumb_conf = NULL; | 2344 | client->old_ethumb_conf = NULL; |
2340 | } | 2345 | } |
2341 | id = _ethumb_client_queue_add(client, file, key, thumb, thumb_key, | 2346 | id = _ethumb_client_queue_add(client, file, key, thumb, thumb_key, |
2342 | generated_cb, data, free_data); | 2347 | generated_cb, data, free_data); |
2343 | 2348 | ||
2344 | return id; | 2349 | return id; |
2345 | } | 2350 | } |
2346 | 2351 | ||
2347 | struct _Ethumb_Client_Async | 2352 | struct _Ethumb_Client_Async |
2348 | { | 2353 | { |
2349 | Ethumb_Exists *exists; | 2354 | Ethumb_Exists *exists; |
2350 | Ethumb_Client *client; | 2355 | Ethumb_Client *client; |
2351 | Ethumb *dup; | 2356 | Ethumb *dup; |
2352 | 2357 | ||
2353 | Ethumb_Client_Async_Done_Cb done; | 2358 | Ethumb_Client_Async_Done_Cb done; |
2354 | Ethumb_Client_Async_Error_Cb error; | 2359 | Ethumb_Client_Async_Error_Cb error; |
2355 | const void *data; | 2360 | const void *data; |
2356 | 2361 | ||
2357 | int id; | 2362 | int id; |
2358 | }; | 2363 | }; |
2359 | 2364 | ||
2360 | static Ecore_Idler *idler[2] = { NULL, NULL }; | 2365 | static Ecore_Idler *idler[2] = { NULL, NULL }; |
@@ -2365,7 +2370,7 @@ static void | |||
2365 | _ethumb_client_async_free(Ethumb_Client_Async *async) | 2370 | _ethumb_client_async_free(Ethumb_Client_Async *async) |
2366 | { | 2371 | { |
2367 | EINA_REFCOUNT_UNREF(async->client) | 2372 | EINA_REFCOUNT_UNREF(async->client) |
2368 | _ethumb_client_free(async->client); | 2373 | _ethumb_client_free(async->client); |
2369 | ethumb_free(async->dup); | 2374 | ethumb_free(async->dup); |
2370 | free(async); | 2375 | free(async); |
2371 | } | 2376 | } |
@@ -2383,11 +2388,11 @@ _ethumb_client_thumb_finish(void *data, | |||
2383 | 2388 | ||
2384 | if (success) | 2389 | if (success) |
2385 | { | 2390 | { |
2386 | async->done(client, thumb_path, thumb_key, (void*) async->data); | 2391 | async->done(client, thumb_path, thumb_key, (void *)async->data); |
2387 | } | 2392 | } |
2388 | else | 2393 | else |
2389 | { | 2394 | { |
2390 | async->error(client, (void*) async->data); | 2395 | async->error(client, (void *)async->data); |
2391 | } | 2396 | } |
2392 | 2397 | ||
2393 | pending = eina_list_remove(pending, async); | 2398 | pending = eina_list_remove(pending, async); |
@@ -2400,7 +2405,7 @@ _ethumb_client_thumb_generate_idler(void *data __UNUSED__) | |||
2400 | Ethumb_Client_Async *async; | 2405 | Ethumb_Client_Async *async; |
2401 | Eina_List *l1, *l2; | 2406 | Eina_List *l1, *l2; |
2402 | 2407 | ||
2403 | EINA_LIST_FOREACH_SAFE(idle_tasks[1], l1, l2, async) | 2408 | EINA_LIST_FOREACH_SAFE (idle_tasks[1], l1, l2, async) |
2404 | { | 2409 | { |
2405 | Ethumb *tmp; | 2410 | Ethumb *tmp; |
2406 | 2411 | ||
@@ -2412,7 +2417,7 @@ _ethumb_client_thumb_generate_idler(void *data __UNUSED__) | |||
2412 | async->id = ethumb_client_generate(async->client, _ethumb_client_thumb_finish, async, NULL); | 2417 | async->id = ethumb_client_generate(async->client, _ethumb_client_thumb_finish, async, NULL); |
2413 | if (async->id == -1) | 2418 | if (async->id == -1) |
2414 | { | 2419 | { |
2415 | async->error(async->client, (void*) async->data); | 2420 | async->error(async->client, (void *)async->data); |
2416 | async->client->ethumb = tmp; | 2421 | async->client->ethumb = tmp; |
2417 | _ethumb_client_async_free(async); | 2422 | _ethumb_client_async_free(async); |
2418 | } | 2423 | } |
@@ -2437,7 +2442,7 @@ _ethumb_client_thumb_exists(void *data, Ethumb_Client *client, Ethumb_Exists *re | |||
2437 | Ethumb_Client_Async *async = data; | 2442 | Ethumb_Client_Async *async = data; |
2438 | 2443 | ||
2439 | if (request == NULL) | 2444 | if (request == NULL) |
2440 | return ; | 2445 | return; |
2441 | 2446 | ||
2442 | assert(async->exists == request); | 2447 | assert(async->exists == request); |
2443 | 2448 | ||
@@ -2450,7 +2455,7 @@ _ethumb_client_thumb_exists(void *data, Ethumb_Client *client, Ethumb_Exists *re | |||
2450 | const char *thumb_key; | 2455 | const char *thumb_key; |
2451 | 2456 | ||
2452 | ethumb_client_thumb_path_get(client, &thumb_path, &thumb_key); | 2457 | ethumb_client_thumb_path_get(client, &thumb_path, &thumb_key); |
2453 | async->done(client, thumb_path, thumb_key, (void*) async->data); | 2458 | async->done(client, thumb_path, thumb_key, (void *)async->data); |
2454 | _ethumb_client_async_free(async); | 2459 | _ethumb_client_async_free(async); |
2455 | } | 2460 | } |
2456 | else | 2461 | else |
@@ -2468,7 +2473,7 @@ _ethumb_client_thumb_exists_idler(void *data __UNUSED__) | |||
2468 | Ethumb_Client_Async *async; | 2473 | Ethumb_Client_Async *async; |
2469 | Eina_List *l1, *l2; | 2474 | Eina_List *l1, *l2; |
2470 | 2475 | ||
2471 | EINA_LIST_FOREACH_SAFE(idle_tasks[0], l1, l2, async) | 2476 | EINA_LIST_FOREACH_SAFE (idle_tasks[0], l1, l2, async) |
2472 | { | 2477 | { |
2473 | Ethumb *tmp; | 2478 | Ethumb *tmp; |
2474 | 2479 | ||
@@ -2480,10 +2485,10 @@ _ethumb_client_thumb_exists_idler(void *data __UNUSED__) | |||
2480 | async->exists = ethumb_client_thumb_exists(async->client, _ethumb_client_thumb_exists, async); | 2485 | async->exists = ethumb_client_thumb_exists(async->client, _ethumb_client_thumb_exists, async); |
2481 | if (!async->exists) | 2486 | if (!async->exists) |
2482 | { | 2487 | { |
2483 | async->error(async->client, (void*) async->data); | 2488 | async->error(async->client, (void *)async->data); |
2484 | async->client->ethumb = tmp; | 2489 | async->client->ethumb = tmp; |
2485 | _ethumb_client_async_free(async); | 2490 | _ethumb_client_async_free(async); |
2486 | continue ; | 2491 | continue; |
2487 | } | 2492 | } |
2488 | 2493 | ||
2489 | async->client->ethumb = tmp; | 2494 | async->client->ethumb = tmp; |
@@ -2511,7 +2516,7 @@ ethumb_client_thumb_async_get(Ethumb_Client *client, | |||
2511 | async = malloc(sizeof (Ethumb_Client_Async)); | 2516 | async = malloc(sizeof (Ethumb_Client_Async)); |
2512 | if (!async) | 2517 | if (!async) |
2513 | { | 2518 | { |
2514 | error(client, (void*) data); | 2519 | error(client, (void *)data); |
2515 | return NULL; | 2520 | return NULL; |
2516 | } | 2521 | } |
2517 | 2522 | ||
@@ -2568,3 +2573,4 @@ ethumb_client_thumb_async_cancel(Ethumb_Client *client, Ethumb_Client_Async *req | |||
2568 | 2573 | ||
2569 | _ethumb_client_async_free(request); | 2574 | _ethumb_client_async_free(request); |
2570 | } | 2575 | } |
2576 | |||