summaryrefslogtreecommitdiff
path: root/legacy
diff options
context:
space:
mode:
authorJosé Roberto de Souza <zehortigoza@profusion.mobi>2012-12-03 21:27:40 +0000
committerGustavo Sverzut Barbieri <barbieri@gmail.com>2012-12-03 21:27:40 +0000
commit154041e62e235b9355157a2bfe68845a1917db6b (patch)
tree1a266095f5776bbaa56d36ee4876b8adf59d2d0a /legacy
parent68a34bdd34467f0859345ca472bc935d7318cb96 (diff)
ethumb: Port to edbus v2
Patch by: José Roberto de Souza <zehortigoza@profusion.mobi> SVN revision: 80103
Diffstat (limited to 'legacy')
-rw-r--r--legacy/ethumb/configure.ac2
-rw-r--r--legacy/ethumb/src/bin/Makefile.am1
-rw-r--r--legacy/ethumb/src/bin/ethumbd.c652
-rw-r--r--legacy/ethumb/src/bin/ethumbd_client.c2
-rw-r--r--legacy/ethumb/src/lib/client/Ethumb_Client.h2
-rw-r--r--legacy/ethumb/src/lib/client/ethumb_client.c842
6 files changed, 513 insertions, 988 deletions
diff --git a/legacy/ethumb/configure.ac b/legacy/ethumb/configure.ac
index f5d98d0726..07768acba4 100644
--- a/legacy/ethumb/configure.ac
+++ b/legacy/ethumb/configure.ac
@@ -153,7 +153,7 @@ fi
153AM_CONDITIONAL(HAVE_EDBUS, false) 153AM_CONDITIONAL(HAVE_EDBUS, false)
154define([CHECK_MODULE_ETHUMBD], 154define([CHECK_MODULE_ETHUMBD],
155[ 155[
156 AC_ETH_CHECK_PKG(EDBUS, edbus, [], [ETHUMBD=false]) 156 AC_ETH_CHECK_PKG(EDBUS, edbus2, [], [ETHUMBD=false])
157]) 157])
158 158
159AC_ETH_OPTIONAL_MODULE([ethumbd], true, [CHECK_MODULE_ETHUMBD]) 159AC_ETH_OPTIONAL_MODULE([ethumbd], true, [CHECK_MODULE_ETHUMBD])
diff --git a/legacy/ethumb/src/bin/Makefile.am b/legacy/ethumb/src/bin/Makefile.am
index 2558cfff74..7c856146f8 100644
--- a/legacy/ethumb/src/bin/Makefile.am
+++ b/legacy/ethumb/src/bin/Makefile.am
@@ -48,6 +48,7 @@ ethumbd_client_SOURCES = ethumbd_client.c
48ethumbd_client_LDADD = \ 48ethumbd_client_LDADD = \
49$(top_builddir)/src/lib/client/libethumb_client.la \ 49$(top_builddir)/src/lib/client/libethumb_client.la \
50$(top_builddir)/src/lib/libethumb.la \ 50$(top_builddir)/src/lib/libethumb.la \
51@EDBUS_LIBS@ \
51@ECORE_LIBS@ \ 52@ECORE_LIBS@ \
52@EINA_LIBS@ 53@EINA_LIBS@
53 54
diff --git a/legacy/ethumb/src/bin/ethumbd.c b/legacy/ethumb/src/bin/ethumbd.c
index 4b1bcb3fa4..c35d1ac303 100644
--- a/legacy/ethumb/src/bin/ethumbd.c
+++ b/legacy/ethumb/src/bin/ethumbd.c
@@ -33,7 +33,7 @@
33#include <Eina.h> 33#include <Eina.h>
34#include <Ecore_Getopt.h> 34#include <Ecore_Getopt.h>
35#include <Ecore.h> 35#include <Ecore.h>
36#include <E_DBus.h> 36#include <EDBus.h>
37#include <Ethumb.h> 37#include <Ethumb.h>
38 38
39#include "ethumbd_private.h" 39#include "ethumbd_private.h"
@@ -43,6 +43,8 @@
43#endif 43#endif
44 44
45#define MAX_ID 2000000 45#define MAX_ID 2000000
46#define DAEMON "daemon"
47#define ODATA "odata"
46 48
47#define DBG(...) EINA_LOG_DOM_DBG(_log_domain, __VA_ARGS__) 49#define DBG(...) EINA_LOG_DOM_DBG(_log_domain, __VA_ARGS__)
48#define INF(...) EINA_LOG_DOM_INFO(_log_domain, __VA_ARGS__) 50#define INF(...) EINA_LOG_DOM_INFO(_log_domain, __VA_ARGS__)
@@ -129,7 +131,7 @@ struct _Ethumbd_Object
129 int id_count; 131 int id_count;
130 int max_id; 132 int max_id;
131 int min_id; 133 int min_id;
132 E_DBus_Object *dbus_obj; 134 EDBus_Service_Interface *iface;
133}; 135};
134 136
135struct _Ethumbd_Queue 137struct _Ethumbd_Queue
@@ -153,10 +155,7 @@ struct _Ethumbd_Slave
153 155
154struct _Ethumbd 156struct _Ethumbd
155{ 157{
156 E_DBus_Connection *conn; 158 EDBus_Connection *conn;
157 E_DBus_Signal_Handler *name_owner_changed_handler;
158 E_DBus_Interface *eiface, *objects_iface;
159 E_DBus_Object *dbus_obj;
160 Ecore_Idler *idler; 159 Ecore_Idler *idler;
161 Ethumbd_Request *processing; 160 Ethumbd_Request *processing;
162 Ethumbd_Queue queue; 161 Ethumbd_Queue queue;
@@ -174,20 +173,6 @@ struct _Ethumbd_Object_Data
174 Ethumbd *ed; 173 Ethumbd *ed;
175}; 174};
176 175
177struct _Ethumb_DBus_Method_Table
178{
179 const char *name;
180 const char *signature;
181 const char *reply;
182 E_DBus_Method_Cb function;
183};
184
185struct _Ethumb_DBus_Signal_Table
186{
187 const char *name;
188 const char *signature;
189};
190
191const Ecore_Getopt optdesc = { 176const Ecore_Getopt optdesc = {
192 "ethumbd", 177 "ethumbd",
193 NULL, 178 NULL,
@@ -210,6 +195,44 @@ const Ecore_Getopt optdesc = {
210 } 195 }
211}; 196};
212 197
198static EDBus_Message *_ethumb_dbus_queue_add_cb(const EDBus_Service_Interface *iface, const EDBus_Message *msg);
199static EDBus_Message *_ethumb_dbus_queue_remove_cb(const EDBus_Service_Interface *iface, const EDBus_Message *msg);
200static EDBus_Message *_ethumb_dbus_queue_clear_cb(const EDBus_Service_Interface *iface, const EDBus_Message *msg);
201static EDBus_Message *_ethumb_dbus_ethumb_setup_cb(const EDBus_Service_Interface *iface, const EDBus_Message *msg);
202static EDBus_Message *_ethumb_dbus_delete_cb(const EDBus_Service_Interface *iface, const EDBus_Message *msg);
203
204static const EDBus_Method _ethumb_dbus_objects_methods[] = {
205 {
206 "queue_add",
207 EDBUS_ARGS({"i", "id"}, {"ay", "file"}, {"ay", "key"}, {"ay", "thumb"}, {"ay", "thumb_key"}),
208 EDBUS_ARGS({"i", "queue_id"}), _ethumb_dbus_queue_add_cb, 0
209 },
210 {
211 "queue_remove", EDBUS_ARGS({"i", "queue_id"}), EDBUS_ARGS({"b", "result"}),
212 _ethumb_dbus_queue_remove_cb, 0
213 },
214 {
215 "clear_queue", NULL, NULL, _ethumb_dbus_queue_clear_cb, 0
216 },
217 {
218 "ethumb_setup", EDBUS_ARGS({"a{sv}", "array"}), EDBUS_ARGS({"b", "result"}),
219 _ethumb_dbus_ethumb_setup_cb, 0
220 },
221 {
222 "delete", NULL, NULL, _ethumb_dbus_delete_cb, 0
223 },
224 { }
225};
226
227static const EDBus_Signal _ethumb_dbus_objects_signals[] = {
228 {
229 "generated",
230 EDBUS_ARGS({"i", ""}, {"ay", "array"}, {"ay", "array"}, {"b", "bool"}),
231 0
232 },
233 { }
234};
235
213static void _ethumb_dbus_generated_signal(Ethumbd *ed, int *id, const char *thumb_path, const char *thumb_key, Eina_Bool success); 236static void _ethumb_dbus_generated_signal(Ethumbd *ed, int *id, const char *thumb_path, const char *thumb_key, Eina_Bool success);
214static Eina_Bool _ethumbd_slave_spawn(Ethumbd_Slave *slave, Ethumbd *ed); 237static Eina_Bool _ethumbd_slave_spawn(Ethumbd_Slave *slave, Ethumbd *ed);
215 238
@@ -801,12 +824,13 @@ _get_idx_for_path(const char *path)
801 return i; 824 return i;
802} 825}
803 826
827static void _name_owner_changed_cb(void *context, const char *bus, const char *old_id, const char *new_id);
828
804static void 829static void
805_ethumb_table_del(Ethumbd *ed, int i) 830_ethumb_table_del(Ethumbd *ed, int i)
806{ 831{
807 int j; 832 int j;
808 Eina_List *l; 833 Eina_List *l;
809 const Eina_List *il;
810 Ethumbd_Queue *q = &ed->queue; 834 Ethumbd_Queue *q = &ed->queue;
811 Ethumbd_Object_Data *odata; 835 Ethumbd_Object_Data *odata;
812 836
@@ -825,15 +849,13 @@ _ethumb_table_del(Ethumbd *ed, int i)
825 } 849 }
826 q->nqueue -= q->table[i].nqueue; 850 q->nqueue -= q->table[i].nqueue;
827 851
828 il = e_dbus_object_interfaces_get(q->table[i].dbus_obj); 852 odata = edbus_service_object_data_del(q->table[i].iface, ODATA);
829 while (il) 853 edbus_name_owner_changed_callback_del(ed->conn, ed->queue.table[i].client,
830 { 854 _name_owner_changed_cb, odata);
831 e_dbus_object_interface_detach(q->table[i].dbus_obj, il->data); 855 //this string was not been freed previously
832 il = e_dbus_object_interfaces_get(q->table[i].dbus_obj); 856 eina_stringshare_del(ed->queue.table[i].client);
833 }
834 odata = e_dbus_object_data_get(q->table[i].dbus_obj);
835 free(odata); 857 free(odata);
836 e_dbus_object_free(q->table[i].dbus_obj); 858 edbus_service_object_unregister(q->table[i].iface);
837 859
838 memset(&(q->table[i]), 0, sizeof(Ethumbd_Object)); 860 memset(&(q->table[i]), 0, sizeof(Ethumbd_Object));
839 for (j = 0; j < q->count; j++) 861 for (j = 0; j < q->count; j++)
@@ -859,65 +881,36 @@ _ethumb_table_clear(Ethumbd *ed)
859} 881}
860 882
861static void 883static void
862_name_owner_changed_cb(void *data, DBusMessage *msg) 884_name_owner_changed_cb(void *context, const char *bus, const char *old_id, const char *new_id)
863{ 885{
864 DBusError err; 886 Ethumbd_Object_Data *odata = context;
865 Ethumbd *ed = data; 887 Ethumbd *ed = odata->ed;
866 Ethumbd_Queue *q = &ed->queue; 888 Ethumbd_Queue *q = &ed->queue;
867 const char *name, *from, *to;
868 int i;
869 889
870 dbus_error_init(&err); 890 DBG("NameOwnerChanged: name = %s, from = %s, to = %s", bus, old_id, new_id);
871 if (!dbus_message_get_args(msg, &err, 891 if (new_id[0])
872 DBUS_TYPE_STRING, &name,
873 DBUS_TYPE_STRING, &from,
874 DBUS_TYPE_STRING, &to,
875 DBUS_TYPE_INVALID))
876 {
877 ERR("could not get NameOwnerChanged arguments: %s: %s",
878 err.name, err.message);
879 dbus_error_free(&err);
880 return;
881 }
882
883 DBG("NameOwnerChanged: name = %s, from = %s, to = %s", name, from, to);
884
885 if (from[0] == '\0' || to[0] != '\0')
886 return; 892 return;
887 893 _ethumb_table_del(ed, odata->idx);
888 from = eina_stringshare_add(from);
889 for (i = 0; i < q->max_count; i++)
890 {
891 if (q->table[i].used && q->table[i].client == from)
892 {
893 _ethumb_table_del(ed, i);
894 DBG("deleting [%d] from queue table.", i);
895 }
896 }
897} 894}
898 895
899static void 896static const EDBus_Service_Interface_Desc client_desc = {
900_ethumb_dbus_add_name_owner_changed_cb(Ethumbd *ed) 897 _ethumb_dbus_objects_interface, _ethumb_dbus_objects_methods,
901{ 898 _ethumb_dbus_objects_signals
902 ed->name_owner_changed_handler = e_dbus_signal_handler_add 899};
903 (ed->conn, fdo_bus_name, fdo_path, fdo_interface, "NameOwnerChanged",
904 _name_owner_changed_cb, ed);
905}
906 900
907DBusMessage * 901static EDBus_Message *
908_ethumb_dbus_ethumb_new_cb(E_DBus_Object *object, DBusMessage *msg) 902_ethumb_dbus_ethumb_new_cb(const EDBus_Service_Interface *interface, const EDBus_Message *msg)
909{ 903{
910 DBusMessage *reply; 904 EDBus_Message *reply;
911 DBusMessageIter iter; 905 EDBus_Service_Interface *iface;
912 E_DBus_Object *dbus_object;
913 Ethumbd_Object_Data *odata; 906 Ethumbd_Object_Data *odata;
914 int i; 907 int i;
915 const char *return_path = ""; 908 const char *return_path = "";
916 const char *client; 909 const char *client;
917 Ethumbd *ed; 910 Ethumbd *ed;
918 911
919 ed = e_dbus_object_data_get(object); 912 ed = edbus_service_object_data_get(interface, DAEMON);
920 client = dbus_message_get_sender(msg); 913 client = edbus_message_sender_get(msg);
921 if (!client) 914 if (!client)
922 goto end_new; 915 goto end_new;
923 916
@@ -932,53 +925,48 @@ _ethumb_dbus_ethumb_new_cb(E_DBus_Object *object, DBusMessage *msg)
932 ed->queue.table[i].client = eina_stringshare_add(client); 925 ed->queue.table[i].client = eina_stringshare_add(client);
933 return_path = ed->queue.table[i].path; 926 return_path = ed->queue.table[i].path;
934 927
935 dbus_object = e_dbus_object_add(ed->conn, return_path, odata); 928 iface = edbus_service_interface_register(ed->conn, return_path, &client_desc);
936 if (!dbus_object) 929 if (!iface)
937 { 930 {
938 ERR("could not create dbus_object."); 931 ERR("could not create dbus_object.");
939 free(odata); 932 free(odata);
940 return_path = ""; 933 return_path = "";
941 goto end_new; 934 goto end_new;
942 } 935 }
943 936 edbus_service_object_data_set(iface, ODATA, odata);
944 e_dbus_object_interface_attach(dbus_object, ed->objects_iface); 937 ed->queue.table[i].iface = iface;
945 ed->queue.table[i].dbus_obj = dbus_object; 938 edbus_name_owner_changed_callback_add(ed->conn, client,
946 939 _name_owner_changed_cb, odata,
940 EINA_TRUE);
947 _ethumbd_child_write_op_new(&ed->slave, i); 941 _ethumbd_child_write_op_new(&ed->slave, i);
948 _ethumbd_timeout_stop(ed); 942 _ethumbd_timeout_stop(ed);
949 943
950 end_new: 944 end_new:
951 reply = dbus_message_new_method_return(msg); 945 reply = edbus_message_method_return_new(msg);
952 dbus_message_iter_init_append(reply, &iter); 946 edbus_message_arguments_set(reply, "o", return_path);
953 dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
954 &return_path);
955 return reply; 947 return reply;
956} 948}
957 949
958static struct _Ethumb_DBus_Method_Table _ethumb_dbus_methods[] = 950static const EDBus_Method _ethumb_dbus_methods[] = {
959 { 951 {
960 {"new", "", "o", _ethumb_dbus_ethumb_new_cb}, 952 "new", NULL, EDBUS_ARGS({"o", "path"}), _ethumb_dbus_ethumb_new_cb, 0
961 {NULL, NULL, NULL, NULL} 953 },
962 }; 954 { }
955};
963 956
964static const char * 957static const char *
965_ethumb_dbus_get_bytearray(DBusMessageIter *iter) 958_ethumb_dbus_get_bytearray(EDBus_Message_Iter *iter)
966{ 959{
967 int el_type;
968 int length; 960 int length;
969 DBusMessageIter riter;
970 const char *result; 961 const char *result;
971 962
972 el_type = dbus_message_iter_get_element_type(iter); 963 if (!edbus_message_iter_fixed_array_get(iter, 'y', &result,
973 if (el_type != DBUS_TYPE_BYTE) 964 &length))
974 { 965 {
975 ERR("not an byte array element."); 966 ERR("not an byte array element.");
976 return NULL; 967 return NULL;
977 } 968 }
978 969
979 dbus_message_iter_recurse(iter, &riter);
980 dbus_message_iter_get_fixed_array(&riter, &result, &length);
981
982 if ((length == 0) || (result[0] == '\0')) 970 if ((length == 0) || (result[0] == '\0'))
983 return NULL; 971 return NULL;
984 else 972 else
@@ -986,42 +974,41 @@ _ethumb_dbus_get_bytearray(DBusMessageIter *iter)
986} 974}
987 975
988static void 976static void
989_ethumb_dbus_append_bytearray(DBusMessageIter *iter, const char *string) 977_ethumb_dbus_append_bytearray(EDBus_Message_Iter *parent, EDBus_Message_Iter *array, const char *string)
990{ 978{
991 DBusMessageIter viter; 979 int i, size;
992 980
993 if (!string) 981 if (!string)
994 string = ""; 982 string = "";
995 983
996 dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, "y", &viter); 984 size = strlen(string);
997 dbus_message_iter_append_fixed_array 985 for (i = 0; i < size; i++)
998 (&viter, DBUS_TYPE_BYTE, &string, strlen(string) + 1); 986 edbus_message_iter_basic_append(array, 'y', string[i]);
999 dbus_message_iter_close_container(iter, &viter); 987 edbus_message_iter_container_close(parent, array);
1000} 988}
1001 989
1002DBusMessage * 990static EDBus_Message *
1003_ethumb_dbus_queue_add_cb(E_DBus_Object *object, DBusMessage *msg) 991_ethumb_dbus_queue_add_cb(const EDBus_Service_Interface *iface, const EDBus_Message *msg)
1004{ 992{
1005 DBusMessage *reply; 993 EDBus_Message *reply;
1006 DBusMessageIter iter; 994 const char *file, *key, *thumb, *thumb_key;
1007 const char *file, *key;
1008 const char *thumb, *thumb_key;
1009 Ethumbd_Object_Data *odata; 995 Ethumbd_Object_Data *odata;
1010 Ethumbd_Object *eobject; 996 Ethumbd_Object *eobject;
1011 Ethumbd *ed; 997 Ethumbd *ed;
1012 Ethumbd_Request *request; 998 Ethumbd_Request *request;
1013 dbus_int32_t id = -1; 999 int id = -1;
1014 1000 EDBus_Message_Iter *file_iter, *key_iter, *thumb_iter, *thumb_key_iter;
1015 dbus_message_iter_init(msg, &iter); 1001
1016 dbus_message_iter_get_basic(&iter, &id); 1002 if (!edbus_message_arguments_get(msg, "iayayayay", &id, &file_iter,
1017 dbus_message_iter_next(&iter); 1003 &key_iter, &thumb_iter, &thumb_key_iter))
1018 file = _ethumb_dbus_get_bytearray(&iter); 1004 {
1019 dbus_message_iter_next(&iter); 1005 ERR("Error getting arguments.");
1020 key = _ethumb_dbus_get_bytearray(&iter); 1006 goto end;
1021 dbus_message_iter_next(&iter); 1007 }
1022 thumb = _ethumb_dbus_get_bytearray(&iter); 1008 file = _ethumb_dbus_get_bytearray(file_iter);
1023 dbus_message_iter_next(&iter); 1009 key = _ethumb_dbus_get_bytearray(key_iter);
1024 thumb_key = _ethumb_dbus_get_bytearray(&iter); 1010 thumb = _ethumb_dbus_get_bytearray(thumb_iter);
1011 thumb_key = _ethumb_dbus_get_bytearray(thumb_key_iter);
1025 1012
1026 if (!file) 1013 if (!file)
1027 { 1014 {
@@ -1029,7 +1016,7 @@ _ethumb_dbus_queue_add_cb(E_DBus_Object *object, DBusMessage *msg)
1029 goto end; 1016 goto end;
1030 } 1017 }
1031 1018
1032 odata = e_dbus_object_data_get(object); 1019 odata = edbus_service_object_data_get(iface, ODATA);
1033 if (!odata) 1020 if (!odata)
1034 { 1021 {
1035 ERR("could not get dbus_object data."); 1022 ERR("could not get dbus_object data.");
@@ -1053,30 +1040,30 @@ _ethumb_dbus_queue_add_cb(E_DBus_Object *object, DBusMessage *msg)
1053 1040
1054 _process_queue_start(ed); 1041 _process_queue_start(ed);
1055 1042
1056 end: 1043end:
1057 reply = dbus_message_new_method_return(msg); 1044 reply = edbus_message_method_return_new(msg);
1058 dbus_message_iter_init_append(reply, &iter); 1045 edbus_message_arguments_set(reply, "i", id);
1059 dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &id);
1060 return reply; 1046 return reply;
1061} 1047}
1062 1048
1063DBusMessage * 1049static EDBus_Message *
1064_ethumb_dbus_queue_remove_cb(E_DBus_Object *object, DBusMessage *msg) 1050_ethumb_dbus_queue_remove_cb(const EDBus_Service_Interface *iface, const EDBus_Message *msg)
1065{ 1051{
1066 DBusMessage *reply; 1052 EDBus_Message *reply;
1067 DBusMessageIter iter; 1053 int id;
1068 dbus_int32_t id;
1069 Ethumbd_Object_Data *odata; 1054 Ethumbd_Object_Data *odata;
1070 Ethumbd_Object *eobject; 1055 Ethumbd_Object *eobject;
1071 Ethumbd_Request *request; 1056 Ethumbd_Request *request;
1072 Ethumbd *ed; 1057 Ethumbd *ed;
1073 dbus_bool_t r = 0; 1058 Eina_Bool r = EINA_FALSE;
1074 Eina_List *l; 1059 Eina_List *l;
1075 1060
1076 dbus_message_iter_init(msg, &iter); 1061 if (!edbus_message_arguments_get(msg, "i", &id))
1077 dbus_message_iter_get_basic(&iter, &id); 1062 {
1078 1063 ERR("Error getting arguments.");
1079 odata = e_dbus_object_data_get(object); 1064 goto end;
1065 }
1066 odata = edbus_service_object_data_get(iface, ODATA);
1080 if (!odata) 1067 if (!odata)
1081 { 1068 {
1082 ERR("could not get dbus_object data."); 1069 ERR("could not get dbus_object data.");
@@ -1096,7 +1083,7 @@ _ethumb_dbus_queue_remove_cb(E_DBus_Object *object, DBusMessage *msg)
1096 1083
1097 if (l) 1084 if (l)
1098 { 1085 {
1099 r = 1; 1086 r = EINA_TRUE;
1100 eina_stringshare_del(request->file); 1087 eina_stringshare_del(request->file);
1101 eina_stringshare_del(request->key); 1088 eina_stringshare_del(request->key);
1102 eina_stringshare_del(request->thumb); 1089 eina_stringshare_del(request->thumb);
@@ -1109,22 +1096,20 @@ _ethumb_dbus_queue_remove_cb(E_DBus_Object *object, DBusMessage *msg)
1109 } 1096 }
1110 1097
1111 end: 1098 end:
1112 reply = dbus_message_new_method_return(msg); 1099 reply = edbus_message_method_return_new(msg);
1113 dbus_message_iter_init_append(reply, &iter); 1100 edbus_message_arguments_set(reply, "b", r);
1114 dbus_message_iter_append_basic(&iter, DBUS_TYPE_BOOLEAN, &r);
1115 return reply; 1101 return reply;
1116} 1102}
1117 1103
1118DBusMessage * 1104static EDBus_Message *
1119_ethumb_dbus_queue_clear_cb(E_DBus_Object *object, DBusMessage *msg) 1105_ethumb_dbus_queue_clear_cb(const EDBus_Service_Interface *iface, const EDBus_Message *msg)
1120{ 1106{
1121 DBusMessage *reply;
1122 Ethumbd_Object_Data *odata; 1107 Ethumbd_Object_Data *odata;
1123 Ethumbd_Object *eobject; 1108 Ethumbd_Object *eobject;
1124 Ethumbd *ed; 1109 Ethumbd *ed;
1125 Eina_List *l; 1110 Eina_List *l;
1126 1111
1127 odata = e_dbus_object_data_get(object); 1112 odata = edbus_service_object_data_get(iface, ODATA);
1128 if (!odata) 1113 if (!odata)
1129 { 1114 {
1130 ERR("could not get dbus_object data."); 1115 ERR("could not get dbus_object data.");
@@ -1148,22 +1133,19 @@ _ethumb_dbus_queue_clear_cb(E_DBus_Object *object, DBusMessage *msg)
1148 eobject->nqueue = 0; 1133 eobject->nqueue = 0;
1149 1134
1150 end: 1135 end:
1151 reply = dbus_message_new_method_return(msg); 1136 return edbus_message_method_return_new(msg);
1152 return reply;
1153} 1137}
1154 1138
1155DBusMessage * 1139static EDBus_Message *
1156_ethumb_dbus_delete_cb(E_DBus_Object *object, DBusMessage *msg) 1140_ethumb_dbus_delete_cb(const EDBus_Service_Interface *iface, const EDBus_Message *msg)
1157{ 1141{
1158 DBusMessage *reply; 1142 EDBus_Message *reply;
1159 DBusMessageIter iter;
1160 Ethumbd_Object_Data *odata; 1143 Ethumbd_Object_Data *odata;
1161 Ethumbd *ed; 1144 Ethumbd *ed;
1162 1145
1163 dbus_message_iter_init(msg, &iter); 1146 reply = edbus_message_method_return_new(msg);
1164 reply = dbus_message_new_method_return(msg);
1165 1147
1166 odata = e_dbus_object_data_get(object); 1148 odata = edbus_service_object_data_get(iface, ODATA);
1167 if (!odata) 1149 if (!odata)
1168 { 1150 {
1169 ERR("could not get dbus_object data for del_cb."); 1151 ERR("could not get dbus_object data for del_cb.");
@@ -1177,19 +1159,16 @@ _ethumb_dbus_delete_cb(E_DBus_Object *object, DBusMessage *msg)
1177} 1159}
1178 1160
1179static int 1161static int
1180_ethumb_dbus_fdo_set(Ethumbd_Object *eobject __UNUSED__, DBusMessageIter *iter, Ethumbd_Request *request) 1162_ethumb_dbus_fdo_set(Ethumbd_Object *eobject __UNUSED__, EDBus_Message_Iter *variant, Ethumbd_Request *request)
1181{ 1163{
1182 int type; 1164 int fdo;
1183 dbus_int32_t fdo;
1184 1165
1185 type = dbus_message_iter_get_arg_type(iter); 1166 if (!edbus_message_iter_arguments_get(variant, "i", &fdo))
1186 if (type != DBUS_TYPE_INT32)
1187 { 1167 {
1188 ERR("invalid param for fdo_set."); 1168 ERR("invalid param for fdo_set.");
1189 return 0; 1169 return 0;
1190 } 1170 }
1191 1171
1192 dbus_message_iter_get_basic(iter, &fdo);
1193 DBG("setting fdo to: %d", fdo); 1172 DBG("setting fdo to: %d", fdo);
1194 request->setup.flags.fdo = 1; 1173 request->setup.flags.fdo = 1;
1195 request->setup.fdo = fdo; 1174 request->setup.fdo = fdo;
@@ -1198,23 +1177,18 @@ _ethumb_dbus_fdo_set(Ethumbd_Object *eobject __UNUSED__, DBusMessageIter *iter,
1198} 1177}
1199 1178
1200static int 1179static int
1201_ethumb_dbus_size_set(Ethumbd_Object *eobject __UNUSED__, DBusMessageIter *iter, Ethumbd_Request *request) 1180_ethumb_dbus_size_set(Ethumbd_Object *eobject __UNUSED__, EDBus_Message_Iter *variant, Ethumbd_Request *request)
1202{ 1181{
1203 DBusMessageIter oiter; 1182 EDBus_Message_Iter *st;
1204 int type; 1183 int w, h;
1205 dbus_int32_t w, h;
1206 1184
1207 type = dbus_message_iter_get_arg_type(iter); 1185 if (!edbus_message_iter_arguments_get(variant, "(ii)", &st))
1208 if (type != DBUS_TYPE_STRUCT)
1209 { 1186 {
1210 ERR("invalid param for size_set."); 1187 ERR("invalid param for size_set.");
1211 return 0; 1188 return 0;
1212 } 1189 }
1213 1190
1214 dbus_message_iter_recurse(iter, &oiter); 1191 edbus_message_iter_arguments_get(st, "ii", &w, &h);
1215 dbus_message_iter_get_basic(&oiter, &w);
1216 dbus_message_iter_next(&oiter);
1217 dbus_message_iter_get_basic(&oiter, &h);
1218 DBG("setting size to: %dx%d", w, h); 1192 DBG("setting size to: %dx%d", w, h);
1219 request->setup.flags.size = 1; 1193 request->setup.flags.size = 1;
1220 request->setup.tw = w; 1194 request->setup.tw = w;
@@ -1224,19 +1198,16 @@ _ethumb_dbus_size_set(Ethumbd_Object *eobject __UNUSED__, DBusMessageIter *iter,
1224} 1198}
1225 1199
1226static int 1200static int
1227_ethumb_dbus_format_set(Ethumbd_Object *eobject __UNUSED__, DBusMessageIter *iter, Ethumbd_Request *request) 1201_ethumb_dbus_format_set(Ethumbd_Object *eobject __UNUSED__, EDBus_Message_Iter *variant, Ethumbd_Request *request)
1228{ 1202{
1229 int type; 1203 int format;
1230 dbus_int32_t format;
1231 1204
1232 type = dbus_message_iter_get_arg_type(iter); 1205 if (!edbus_message_iter_arguments_get(variant, "i", &format))
1233 if (type != DBUS_TYPE_INT32)
1234 { 1206 {
1235 ERR("invalid param for format_set."); 1207 ERR("invalid param for format_set.");
1236 return 0; 1208 return 0;
1237 } 1209 }
1238 1210
1239 dbus_message_iter_get_basic(iter, &format);
1240 DBG("setting format to: %d", format); 1211 DBG("setting format to: %d", format);
1241 request->setup.flags.format = 1; 1212 request->setup.flags.format = 1;
1242 request->setup.format = format; 1213 request->setup.format = format;
@@ -1245,19 +1216,16 @@ _ethumb_dbus_format_set(Ethumbd_Object *eobject __UNUSED__, DBusMessageIter *ite
1245} 1216}
1246 1217
1247static int 1218static int
1248_ethumb_dbus_aspect_set(Ethumbd_Object *eobject __UNUSED__, DBusMessageIter *iter, Ethumbd_Request *request) 1219_ethumb_dbus_aspect_set(Ethumbd_Object *eobject __UNUSED__, EDBus_Message_Iter *variant, Ethumbd_Request *request)
1249{ 1220{
1250 int type; 1221 int aspect;
1251 dbus_int32_t aspect;
1252 1222
1253 type = dbus_message_iter_get_arg_type(iter); 1223 if (!edbus_message_iter_arguments_get(variant, "i", &aspect))
1254 if (type != DBUS_TYPE_INT32)
1255 { 1224 {
1256 ERR("invalid param for aspect_set."); 1225 ERR("invalid param for aspect_set.");
1257 return 0; 1226 return 0;
1258 } 1227 }
1259 1228
1260 dbus_message_iter_get_basic(iter, &aspect);
1261 DBG("setting aspect to: %d", aspect); 1229 DBG("setting aspect to: %d", aspect);
1262 request->setup.flags.aspect = 1; 1230 request->setup.flags.aspect = 1;
1263 request->setup.aspect = aspect; 1231 request->setup.aspect = aspect;
@@ -1266,19 +1234,16 @@ _ethumb_dbus_aspect_set(Ethumbd_Object *eobject __UNUSED__, DBusMessageIter *ite
1266} 1234}
1267 1235
1268static int 1236static int
1269_ethumb_dbus_orientation_set(Ethumbd_Object *eobject __UNUSED__, DBusMessageIter *iter, Ethumbd_Request *request) 1237_ethumb_dbus_orientation_set(Ethumbd_Object *eobject __UNUSED__, EDBus_Message_Iter *variant, Ethumbd_Request *request)
1270{ 1238{
1271 int type; 1239 int orientation;
1272 dbus_int32_t orientation;
1273 1240
1274 type = dbus_message_iter_get_arg_type(iter); 1241 if (!edbus_message_iter_arguments_get(variant, "i", &orientation))
1275 if (type != DBUS_TYPE_INT32)
1276 { 1242 {
1277 ERR("invalid param for orientation_set."); 1243 ERR("invalid param for orientation_set.");
1278 return 0; 1244 return 0;
1279 } 1245 }
1280 1246
1281 dbus_message_iter_get_basic(iter, &orientation);
1282 DBG("setting orientation to: %d", orientation); 1247 DBG("setting orientation to: %d", orientation);
1283 request->setup.flags.orientation = 1; 1248 request->setup.flags.orientation = 1;
1284 request->setup.orientation = orientation; 1249 request->setup.orientation = orientation;
@@ -1287,23 +1252,18 @@ _ethumb_dbus_orientation_set(Ethumbd_Object *eobject __UNUSED__, DBusMessageIter
1287} 1252}
1288 1253
1289static int 1254static int
1290_ethumb_dbus_crop_set(Ethumbd_Object *eobject __UNUSED__, DBusMessageIter *iter, Ethumbd_Request *request) 1255_ethumb_dbus_crop_set(Ethumbd_Object *eobject __UNUSED__, EDBus_Message_Iter *variant, Ethumbd_Request *request)
1291{ 1256{
1292 DBusMessageIter oiter; 1257 EDBus_Message_Iter *st;
1293 int type;
1294 double x, y; 1258 double x, y;
1295 1259
1296 type = dbus_message_iter_get_arg_type(iter); 1260 if (!edbus_message_iter_arguments_get(variant, "(dd)", &st))
1297 if (type != DBUS_TYPE_STRUCT)
1298 { 1261 {
1299 ERR("invalid param for crop_set."); 1262 ERR("invalid param for crop_set.");
1300 return 0; 1263 return 0;
1301 } 1264 }
1302 1265
1303 dbus_message_iter_recurse(iter, &oiter); 1266 edbus_message_iter_arguments_get(st, "dd", &x, &y);
1304 dbus_message_iter_get_basic(&oiter, &x);
1305 dbus_message_iter_next(&oiter);
1306 dbus_message_iter_get_basic(&oiter, &y);
1307 DBG("setting crop to: %3.2f,%3.2f", x, y); 1267 DBG("setting crop to: %3.2f,%3.2f", x, y);
1308 request->setup.flags.crop = 1; 1268 request->setup.flags.crop = 1;
1309 request->setup.cx = x; 1269 request->setup.cx = x;
@@ -1313,19 +1273,16 @@ _ethumb_dbus_crop_set(Ethumbd_Object *eobject __UNUSED__, DBusMessageIter *iter,
1313} 1273}
1314 1274
1315static int 1275static int
1316_ethumb_dbus_quality_set(Ethumbd_Object *eobject __UNUSED__, DBusMessageIter *iter, Ethumbd_Request *request) 1276_ethumb_dbus_quality_set(Ethumbd_Object *eobject __UNUSED__, EDBus_Message_Iter *variant, Ethumbd_Request *request)
1317{ 1277{
1318 int type; 1278 int quality;
1319 dbus_int32_t quality;
1320 1279
1321 type = dbus_message_iter_get_arg_type(iter); 1280 if (!edbus_message_iter_arguments_get(variant, "i", &quality))
1322 if (type != DBUS_TYPE_INT32)
1323 { 1281 {
1324 ERR("invalid param for quality_set."); 1282 ERR("invalid param for quality_set.");
1325 return 0; 1283 return 0;
1326 } 1284 }
1327 1285
1328 dbus_message_iter_get_basic(iter, &quality);
1329 DBG("setting quality to: %d", quality); 1286 DBG("setting quality to: %d", quality);
1330 request->setup.flags.quality = 1; 1287 request->setup.flags.quality = 1;
1331 request->setup.quality = quality; 1288 request->setup.quality = quality;
@@ -1335,19 +1292,16 @@ _ethumb_dbus_quality_set(Ethumbd_Object *eobject __UNUSED__, DBusMessageIter *it
1335 1292
1336 1293
1337static int 1294static int
1338_ethumb_dbus_compress_set(Ethumbd_Object *eobject __UNUSED__, DBusMessageIter *iter, Ethumbd_Request *request) 1295_ethumb_dbus_compress_set(Ethumbd_Object *eobject __UNUSED__, EDBus_Message_Iter *variant, Ethumbd_Request *request)
1339{ 1296{
1340 int type; 1297 int compress;
1341 dbus_int32_t compress;
1342 1298
1343 type = dbus_message_iter_get_arg_type(iter); 1299 if (!edbus_message_iter_arguments_get(variant, "i", &compress))
1344 if (type != DBUS_TYPE_INT32)
1345 { 1300 {
1346 ERR("invalid param for compress_set."); 1301 ERR("invalid param for compress_set.");
1347 return 0; 1302 return 0;
1348 } 1303 }
1349 1304
1350 dbus_message_iter_get_basic(iter, &compress);
1351 DBG("setting compress to: %d", compress); 1305 DBG("setting compress to: %d", compress);
1352 request->setup.flags.compress = 1; 1306 request->setup.flags.compress = 1;
1353 request->setup.compress = compress; 1307 request->setup.compress = compress;
@@ -1356,25 +1310,22 @@ _ethumb_dbus_compress_set(Ethumbd_Object *eobject __UNUSED__, DBusMessageIter *i
1356} 1310}
1357 1311
1358static int 1312static int
1359_ethumb_dbus_frame_set(Ethumbd_Object *eobject __UNUSED__, DBusMessageIter *iter, Ethumbd_Request *request) 1313_ethumb_dbus_frame_set(Ethumbd_Object *eobject __UNUSED__, EDBus_Message_Iter *variant, Ethumbd_Request *request)
1360{ 1314{
1361 DBusMessageIter oiter; 1315 EDBus_Message_Iter *_struct, *file_iter, *group_iter, *swallow_iter;
1362 int type;
1363 const char *file, *group, *swallow; 1316 const char *file, *group, *swallow;
1364 1317
1365 type = dbus_message_iter_get_arg_type(iter); 1318 if (!edbus_message_iter_arguments_get(variant, "(ayayay)", &_struct))
1366 if (type != DBUS_TYPE_STRUCT)
1367 { 1319 {
1368 ERR("invalid param for frame_set."); 1320 ERR("invalid param for frame_set.");
1369 return 0; 1321 return 0;
1370 } 1322 }
1371 1323
1372 dbus_message_iter_recurse(iter, &oiter); 1324 edbus_message_iter_arguments_get(_struct, "ayayay", &file_iter, &group_iter, &swallow_iter);
1373 file = _ethumb_dbus_get_bytearray(&oiter); 1325
1374 dbus_message_iter_next(&oiter); 1326 file = _ethumb_dbus_get_bytearray(file_iter);
1375 group = _ethumb_dbus_get_bytearray(&oiter); 1327 group = _ethumb_dbus_get_bytearray(group_iter);
1376 dbus_message_iter_next(&oiter); 1328 swallow = _ethumb_dbus_get_bytearray(swallow_iter);
1377 swallow = _ethumb_dbus_get_bytearray(&oiter);
1378 DBG("setting frame to \"%s:%s:%s\"", file, group, swallow); 1329 DBG("setting frame to \"%s:%s:%s\"", file, group, swallow);
1379 request->setup.flags.frame = 1; 1330 request->setup.flags.frame = 1;
1380 request->setup.theme_file = eina_stringshare_add(file); 1331 request->setup.theme_file = eina_stringshare_add(file);
@@ -1385,19 +1336,18 @@ _ethumb_dbus_frame_set(Ethumbd_Object *eobject __UNUSED__, DBusMessageIter *iter
1385} 1336}
1386 1337
1387static int 1338static int
1388_ethumb_dbus_directory_set(Ethumbd_Object *eobject __UNUSED__, DBusMessageIter *iter, Ethumbd_Request *request) 1339_ethumb_dbus_directory_set(Ethumbd_Object *eobject __UNUSED__, EDBus_Message_Iter *variant, Ethumbd_Request *request)
1389{ 1340{
1390 int type;
1391 const char *directory; 1341 const char *directory;
1342 EDBus_Message_Iter *array;
1392 1343
1393 type = dbus_message_iter_get_arg_type(iter); 1344 if (!edbus_message_iter_arguments_get(variant, "ay", &array))
1394 if (type != DBUS_TYPE_ARRAY)
1395 { 1345 {
1396 ERR("invalid param for dir_path_set."); 1346 ERR("invalid param for dir_path_set.");
1397 return 0; 1347 return 0;
1398 } 1348 }
1399 1349
1400 directory = _ethumb_dbus_get_bytearray(iter); 1350 directory = _ethumb_dbus_get_bytearray(array);
1401 DBG("setting directory to: %s", directory); 1351 DBG("setting directory to: %s", directory);
1402 request->setup.flags.directory = 1; 1352 request->setup.flags.directory = 1;
1403 request->setup.directory = eina_stringshare_add(directory); 1353 request->setup.directory = eina_stringshare_add(directory);
@@ -1406,19 +1356,18 @@ _ethumb_dbus_directory_set(Ethumbd_Object *eobject __UNUSED__, DBusMessageIter *
1406} 1356}
1407 1357
1408static int 1358static int
1409_ethumb_dbus_category_set(Ethumbd_Object *eobject __UNUSED__, DBusMessageIter *iter, Ethumbd_Request *request) 1359_ethumb_dbus_category_set(Ethumbd_Object *eobject __UNUSED__, EDBus_Message_Iter *variant, Ethumbd_Request *request)
1410{ 1360{
1411 int type;
1412 const char *category; 1361 const char *category;
1362 EDBus_Message_Iter *array;
1413 1363
1414 type = dbus_message_iter_get_arg_type(iter); 1364 if (!edbus_message_iter_arguments_get(variant, "ay", &array))
1415 if (type != DBUS_TYPE_ARRAY)
1416 { 1365 {
1417 ERR("invalid param for category."); 1366 ERR("invalid param for category.");
1418 return 0; 1367 return 0;
1419 } 1368 }
1420 1369
1421 category = _ethumb_dbus_get_bytearray(iter); 1370 category = _ethumb_dbus_get_bytearray(array);
1422 DBG("setting category to: %s", category); 1371 DBG("setting category to: %s", category);
1423 request->setup.flags.category = 1; 1372 request->setup.flags.category = 1;
1424 request->setup.category = eina_stringshare_add(category); 1373 request->setup.category = eina_stringshare_add(category);
@@ -1427,19 +1376,16 @@ _ethumb_dbus_category_set(Ethumbd_Object *eobject __UNUSED__, DBusMessageIter *i
1427} 1376}
1428 1377
1429static int 1378static int
1430_ethumb_dbus_video_time_set(Ethumbd_Object *eobject __UNUSED__, DBusMessageIter *iter, Ethumbd_Request *request) 1379_ethumb_dbus_video_time_set(Ethumbd_Object *eobject __UNUSED__, EDBus_Message_Iter *variant, Ethumbd_Request *request)
1431{ 1380{
1432 int type;
1433 double video_time; 1381 double video_time;
1434 1382
1435 type = dbus_message_iter_get_arg_type(iter); 1383 if (!edbus_message_iter_arguments_get(variant, "d", &video_time))
1436 if (type != DBUS_TYPE_DOUBLE)
1437 { 1384 {
1438 ERR("invalid param for video_time_set."); 1385 ERR("invalid param for video_time_set.");
1439 return 0; 1386 return 0;
1440 } 1387 }
1441 1388
1442 dbus_message_iter_get_basic(iter, &video_time);
1443 DBG("setting video_time to: %3.2f", video_time); 1389 DBG("setting video_time to: %3.2f", video_time);
1444 request->setup.flags.video_time = 1; 1390 request->setup.flags.video_time = 1;
1445 request->setup.video_time = video_time; 1391 request->setup.video_time = video_time;
@@ -1448,19 +1394,16 @@ _ethumb_dbus_video_time_set(Ethumbd_Object *eobject __UNUSED__, DBusMessageIter
1448} 1394}
1449 1395
1450static int 1396static int
1451_ethumb_dbus_video_start_set(Ethumbd_Object *eobject __UNUSED__, DBusMessageIter *iter, Ethumbd_Request *request) 1397_ethumb_dbus_video_start_set(Ethumbd_Object *eobject __UNUSED__, EDBus_Message_Iter *variant, Ethumbd_Request *request)
1452{ 1398{
1453 int type;
1454 double video_start; 1399 double video_start;
1455 1400
1456 type = dbus_message_iter_get_arg_type(iter); 1401 if (!edbus_message_iter_arguments_get(variant, "d", &video_start))
1457 if (type != DBUS_TYPE_DOUBLE)
1458 { 1402 {
1459 ERR("invalid param for video_start_set."); 1403 ERR("invalid param for video_start_set.");
1460 return 0; 1404 return 0;
1461 } 1405 }
1462 1406
1463 dbus_message_iter_get_basic(iter, &video_start);
1464 DBG("setting video_start to: %3.2f", video_start); 1407 DBG("setting video_start to: %3.2f", video_start);
1465 request->setup.flags.video_start = 1; 1408 request->setup.flags.video_start = 1;
1466 request->setup.video_start = video_start; 1409 request->setup.video_start = video_start;
@@ -1469,19 +1412,15 @@ _ethumb_dbus_video_start_set(Ethumbd_Object *eobject __UNUSED__, DBusMessageIter
1469} 1412}
1470 1413
1471static int 1414static int
1472_ethumb_dbus_video_interval_set(Ethumbd_Object *eobject __UNUSED__, DBusMessageIter *iter, Ethumbd_Request *request) 1415_ethumb_dbus_video_interval_set(Ethumbd_Object *eobject __UNUSED__, EDBus_Message_Iter *variant, Ethumbd_Request *request)
1473{ 1416{
1474 int type;
1475 double video_interval; 1417 double video_interval;
1476 1418
1477 type = dbus_message_iter_get_arg_type(iter); 1419 if (!edbus_message_iter_arguments_get(variant, "d", &video_interval))
1478 if (type != DBUS_TYPE_DOUBLE)
1479 { 1420 {
1480 ERR("invalid param for video_interval_set."); 1421 ERR("invalid param for video_interval_set.");
1481 return 0; 1422 return 0;
1482 } 1423 }
1483
1484 dbus_message_iter_get_basic(iter, &video_interval);
1485 DBG("setting video_interval to: %3.2f", video_interval); 1424 DBG("setting video_interval to: %3.2f", video_interval);
1486 request->setup.flags.video_interval = 1; 1425 request->setup.flags.video_interval = 1;
1487 request->setup.video_interval = video_interval; 1426 request->setup.video_interval = video_interval;
@@ -1490,19 +1429,16 @@ _ethumb_dbus_video_interval_set(Ethumbd_Object *eobject __UNUSED__, DBusMessageI
1490} 1429}
1491 1430
1492static int 1431static int
1493_ethumb_dbus_video_ntimes_set(Ethumbd_Object *eobject __UNUSED__, DBusMessageIter *iter, Ethumbd_Request *request) 1432_ethumb_dbus_video_ntimes_set(Ethumbd_Object *eobject __UNUSED__, EDBus_Message_Iter *variant, Ethumbd_Request *request)
1494{ 1433{
1495 int type;
1496 unsigned int video_ntimes; 1434 unsigned int video_ntimes;
1497 1435
1498 type = dbus_message_iter_get_arg_type(iter); 1436 if (!edbus_message_iter_arguments_get(variant, "u", &video_ntimes))
1499 if (type != DBUS_TYPE_UINT32)
1500 { 1437 {
1501 ERR("invalid param for video_ntimes_set."); 1438 ERR("invalid param for video_ntimes_set.");
1502 return 0; 1439 return 0;
1503 } 1440 }
1504 1441
1505 dbus_message_iter_get_basic(iter, &video_ntimes);
1506 DBG("setting video_ntimes to: %3.2d", video_ntimes); 1442 DBG("setting video_ntimes to: %3.2d", video_ntimes);
1507 request->setup.flags.video_ntimes = 1; 1443 request->setup.flags.video_ntimes = 1;
1508 request->setup.video_ntimes = video_ntimes; 1444 request->setup.video_ntimes = video_ntimes;
@@ -1511,19 +1447,16 @@ _ethumb_dbus_video_ntimes_set(Ethumbd_Object *eobject __UNUSED__, DBusMessageIte
1511} 1447}
1512 1448
1513static int 1449static int
1514_ethumb_dbus_video_fps_set(Ethumbd_Object *eobject __UNUSED__, DBusMessageIter *iter, Ethumbd_Request *request) 1450_ethumb_dbus_video_fps_set(Ethumbd_Object *eobject __UNUSED__, EDBus_Message_Iter *variant, Ethumbd_Request *request)
1515{ 1451{
1516 int type;
1517 unsigned int video_fps; 1452 unsigned int video_fps;
1518 1453
1519 type = dbus_message_iter_get_arg_type(iter); 1454 if (!edbus_message_iter_arguments_get(variant, "u", &video_fps))
1520 if (type != DBUS_TYPE_UINT32)
1521 { 1455 {
1522 ERR("invalid param for video_fps_set."); 1456 ERR("invalid param for video_fps_set.");
1523 return 0; 1457 return 0;
1524 } 1458 }
1525 1459
1526 dbus_message_iter_get_basic(iter, &video_fps);
1527 DBG("setting video_fps to: %3.2d", video_fps); 1460 DBG("setting video_fps to: %3.2d", video_fps);
1528 request->setup.flags.video_fps = 1; 1461 request->setup.flags.video_fps = 1;
1529 request->setup.video_fps = video_fps; 1462 request->setup.video_fps = video_fps;
@@ -1532,19 +1465,16 @@ _ethumb_dbus_video_fps_set(Ethumbd_Object *eobject __UNUSED__, DBusMessageIter *
1532} 1465}
1533 1466
1534static int 1467static int
1535_ethumb_dbus_document_page_set(Ethumbd_Object *eobject __UNUSED__, DBusMessageIter *iter, Ethumbd_Request *request) 1468_ethumb_dbus_document_page_set(Ethumbd_Object *eobject __UNUSED__, EDBus_Message_Iter *variant, Ethumbd_Request *request)
1536{ 1469{
1537 int type;
1538 unsigned int document_page; 1470 unsigned int document_page;
1539 1471
1540 type = dbus_message_iter_get_arg_type(iter); 1472 if (!edbus_message_iter_arguments_get(variant, "u", &document_page))
1541 if (type != DBUS_TYPE_UINT32)
1542 { 1473 {
1543 ERR("invalid param for document_page_set."); 1474 ERR("invalid param for document_page_set.");
1544 return 0; 1475 return 0;
1545 } 1476 }
1546 1477
1547 dbus_message_iter_get_basic(iter, &document_page);
1548 DBG("setting document_page to: %d", document_page); 1478 DBG("setting document_page to: %d", document_page);
1549 request->setup.flags.document_page = 1; 1479 request->setup.flags.document_page = 1;
1550 request->setup.document_page = document_page; 1480 request->setup.document_page = document_page;
@@ -1555,7 +1485,7 @@ _ethumb_dbus_document_page_set(Ethumbd_Object *eobject __UNUSED__, DBusMessageIt
1555static struct 1485static struct
1556{ 1486{
1557 const char *option; 1487 const char *option;
1558 int (*setup_func)(Ethumbd_Object *eobject, DBusMessageIter *iter, Ethumbd_Request *request); 1488 int (*setup_func)(Ethumbd_Object *eobject, EDBus_Message_Iter *variant, Ethumbd_Request *request);
1559} _option_cbs[] = { 1489} _option_cbs[] = {
1560 {"fdo", _ethumb_dbus_fdo_set}, 1490 {"fdo", _ethumb_dbus_fdo_set},
1561 {"size", _ethumb_dbus_size_set}, 1491 {"size", _ethumb_dbus_size_set},
@@ -1578,15 +1508,13 @@ static struct
1578}; 1508};
1579 1509
1580static int 1510static int
1581_ethumb_dbus_ethumb_setup_parse_element(Ethumbd_Object *eobject, DBusMessageIter *iter, Ethumbd_Request *request) 1511_ethumb_dbus_ethumb_setup_parse_element(Ethumbd_Object *eobject, EDBus_Message_Iter *data, Ethumbd_Request *request)
1582{ 1512{
1583 DBusMessageIter viter, diter; 1513 EDBus_Message_Iter *variant;
1584 const char *option; 1514 const char *option;
1585 int i, r; 1515 int i, r;
1586 1516
1587 dbus_message_iter_recurse(iter, &diter); 1517 edbus_message_iter_arguments_get(data, "sv", &option, &variant);
1588 dbus_message_iter_get_basic(&diter, &option);
1589 dbus_message_iter_next(&diter);
1590 1518
1591 r = 0; 1519 r = 0;
1592 for (i = 0; _option_cbs[i].option; i++) 1520 for (i = 0; _option_cbs[i].option; i++)
@@ -1602,30 +1530,29 @@ _ethumb_dbus_ethumb_setup_parse_element(Ethumbd_Object *eobject, DBusMessageIter
1602 return 0; 1530 return 0;
1603 } 1531 }
1604 1532
1605 dbus_message_iter_recurse(&diter, &viter); 1533 return _option_cbs[i].setup_func(eobject, variant, request);
1606 return _option_cbs[i].setup_func(eobject, &viter, request);
1607} 1534}
1608 1535
1609DBusMessage * 1536static EDBus_Message *
1610_ethumb_dbus_ethumb_setup_cb(E_DBus_Object *object, DBusMessage *msg) 1537_ethumb_dbus_ethumb_setup_cb(const EDBus_Service_Interface *iface, const EDBus_Message *msg)
1611{ 1538{
1612 DBusMessage *reply; 1539 EDBus_Message *reply;
1613 DBusMessageIter iter, aiter;
1614 Ethumbd_Object_Data *odata; 1540 Ethumbd_Object_Data *odata;
1615 Ethumbd *ed; 1541 Ethumbd *ed;
1616 Ethumbd_Object *eobject; 1542 Ethumbd_Object *eobject;
1617 Ethumbd_Request *request; 1543 Ethumbd_Request *request;
1618 dbus_bool_t r = 0; 1544 Eina_Bool r = EINA_FALSE;
1619 int atype; 1545 int atype;
1546 EDBus_Message_Iter *array;
1547 EDBus_Message_Iter *data;
1620 1548
1621 dbus_message_iter_init(msg, &iter); 1549 if (!edbus_message_arguments_get(msg, "a{sv}", &array))
1622 if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY)
1623 { 1550 {
1624 ERR("wrong parameters."); 1551 ERR("could not get dbus_object data for setup_cb.");
1625 goto end; 1552 goto end;
1626 } 1553 }
1627 1554
1628 odata = e_dbus_object_data_get(object); 1555 odata = edbus_service_object_data_get(iface, ODATA);
1629 if (!odata) 1556 if (!odata)
1630 { 1557 {
1631 ERR("could not get dbus_object data for setup_cb."); 1558 ERR("could not get dbus_object data for setup_cb.");
@@ -1637,146 +1564,75 @@ _ethumb_dbus_ethumb_setup_cb(E_DBus_Object *object, DBusMessage *msg)
1637 1564
1638 request = calloc(1, sizeof(*request)); 1565 request = calloc(1, sizeof(*request));
1639 request->id = -1; 1566 request->id = -1;
1640 dbus_message_iter_recurse(&iter, &aiter);
1641 atype = dbus_message_iter_get_arg_type(&aiter);
1642 1567
1643 r = 1; 1568 r = EINA_TRUE;
1644 while (atype != DBUS_TYPE_INVALID) 1569 while (edbus_message_iter_get_and_next(array, 'r', &data) && r)
1645 { 1570 {
1646 if (!_ethumb_dbus_ethumb_setup_parse_element(eobject, &aiter, request)) 1571 if (!_ethumb_dbus_ethumb_setup_parse_element(eobject, data, request));
1647 r = 0; 1572 r = EINA_FALSE;
1648 dbus_message_iter_next(&aiter);
1649 atype = dbus_message_iter_get_arg_type(&aiter);
1650 } 1573 }
1651 1574
1652 eobject->queue = eina_list_append(eobject->queue, request); 1575 eobject->queue = eina_list_append(eobject->queue, request);
1653 eobject->nqueue++; 1576 eobject->nqueue++;
1654 ed->queue.nqueue++; 1577 ed->queue.nqueue++;
1655 1578
1656 end: 1579end:
1657 reply = dbus_message_new_method_return(msg); 1580 reply = edbus_message_method_return_new(msg);
1658 dbus_message_iter_init_append(reply, &iter); 1581 edbus_message_arguments_set(reply, "b", r);
1659 dbus_message_iter_append_basic(&iter, DBUS_TYPE_BOOLEAN, &r);
1660
1661 return reply; 1582 return reply;
1662} 1583}
1663 1584
1664static void 1585static void
1665_ethumb_dbus_generated_signal(Ethumbd *ed, int *id, const char *thumb_path, const char *thumb_key, Eina_Bool success) 1586_ethumb_dbus_generated_signal(Ethumbd *ed, int *id, const char *thumb_path, const char *thumb_key, Eina_Bool success)
1666{ 1587{
1667 DBusMessage *sig; 1588 EDBus_Message *sig;
1668 int current; 1589 int current;
1669 const char *opath; 1590 const char *opath;
1670 DBusMessageIter iter; 1591 EDBus_Message_Iter *iter, *iter_path, *iter_key;
1671 dbus_bool_t value; 1592 int id32;
1672 dbus_int32_t id32;
1673 1593
1674 value = success;
1675 id32 = *id; 1594 id32 = *id;
1676 1595
1677 current = ed->queue.current; 1596 current = ed->queue.current;
1678 opath = ed->queue.table[current].path; 1597 opath = ed->queue.table[current].path;
1679 sig = dbus_message_new_signal 1598 sig = edbus_message_signal_new(opath, _ethumb_dbus_objects_interface,
1680 (opath, _ethumb_dbus_objects_interface, "generated"); 1599 "generated");
1681 1600
1682 dbus_message_iter_init_append(sig, &iter); 1601 iter = edbus_message_iter_get(sig);
1683 dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &id32); 1602 edbus_message_iter_arguments_set(iter, "iay", id32, &iter_path);
1684 _ethumb_dbus_append_bytearray(&iter, thumb_path); 1603 _ethumb_dbus_append_bytearray(iter, iter_path, thumb_path);
1685 _ethumb_dbus_append_bytearray(&iter, thumb_key); 1604 edbus_message_iter_arguments_set(iter, "ay", &iter_key);
1686 dbus_message_iter_append_basic(&iter, DBUS_TYPE_BOOLEAN, &value); 1605 _ethumb_dbus_append_bytearray(iter, iter_key, thumb_key);
1687 1606 edbus_message_iter_arguments_set(iter, "b", success);
1688 e_dbus_message_send(ed->conn, sig, NULL, -1, NULL); 1607
1689 dbus_message_unref(sig); 1608 edbus_connection_send(ed->conn, sig, NULL, NULL, -1);
1609 edbus_message_unref(sig);
1690} 1610}
1691 1611
1692static struct _Ethumb_DBus_Method_Table _ethumb_dbus_objects_methods[] = { 1612static const EDBus_Service_Interface_Desc server_desc = {
1693 {"queue_add", "iayayayay", "i", _ethumb_dbus_queue_add_cb}, 1613 _ethumb_dbus_interface, _ethumb_dbus_methods
1694 {"queue_remove", "i", "b", _ethumb_dbus_queue_remove_cb},
1695 {"clear_queue", "", "", _ethumb_dbus_queue_clear_cb},
1696 {"ethumb_setup", "a{sv}", "b", _ethumb_dbus_ethumb_setup_cb},
1697 {"delete", "", "", _ethumb_dbus_delete_cb},
1698 {NULL, NULL, NULL, NULL}
1699};
1700
1701static struct _Ethumb_DBus_Signal_Table _ethumb_dbus_objects_signals[] = {
1702 {"generated", "iayayb"},
1703 {NULL, NULL}
1704}; 1614};
1705 1615
1706static int
1707_ethumb_dbus_interface_elements_add(E_DBus_Interface *iface, struct _Ethumb_DBus_Method_Table *mtable, struct _Ethumb_DBus_Signal_Table *stable)
1708{
1709 int i = -1;
1710 while (mtable && mtable[++i].name)
1711 if (!e_dbus_interface_method_add(iface,
1712 mtable[i].name,
1713 mtable[i].signature,
1714 mtable[i].reply,
1715 mtable[i].function))
1716 return 0;
1717
1718 i = -1;
1719 while (stable && stable[++i].name)
1720 if (!e_dbus_interface_signal_add(iface,
1721 stable[i].name,
1722 stable[i].signature))
1723 return 0;
1724 return 1;
1725}
1726
1727static void 1616static void
1728_ethumb_dbus_request_name_cb(void *data, DBusMessage *msg __UNUSED__, DBusError *err) 1617_ethumb_dbus_request_name_cb(void *data, const EDBus_Message *msg, EDBus_Pending *pending)
1729{ 1618{
1730 E_DBus_Object *dbus_object; 1619 EDBus_Service_Interface *iface;
1620 const char *errname, *errmsg;
1731 Ethumbd *ed = data; 1621 Ethumbd *ed = data;
1732 int r; 1622 int r;
1733 1623
1734 if (dbus_error_is_set(err)) 1624 if (edbus_message_error_get(msg, &errname, &errmsg))
1735 {
1736 ERR("request name error: %s", err->message);
1737 dbus_error_free(err);
1738 e_dbus_connection_close(ed->conn);
1739 return;
1740 }
1741
1742 dbus_object = e_dbus_object_add(ed->conn, _ethumb_dbus_path, ed);
1743 if (!dbus_object)
1744 return;
1745 ed->dbus_obj = dbus_object;
1746 ed->eiface = e_dbus_interface_new(_ethumb_dbus_interface);
1747 if (!ed->eiface)
1748 {
1749 ERR("could not create interface.");
1750 return;
1751 }
1752 r = _ethumb_dbus_interface_elements_add(ed->eiface,
1753 _ethumb_dbus_methods, NULL);
1754 if (!r)
1755 { 1625 {
1756 ERR("could not add methods to the interface."); 1626 ERR("request name error: %s %s", errname, errmsg);
1757 e_dbus_interface_unref(ed->eiface); 1627 edbus_connection_unref(ed->conn);
1758 return; 1628 return;
1759 } 1629 }
1760 e_dbus_object_interface_attach(dbus_object, ed->eiface);
1761 1630
1762 ed->objects_iface = e_dbus_interface_new(_ethumb_dbus_objects_interface); 1631 iface = edbus_service_interface_register(ed->conn, _ethumb_dbus_path,
1763 if (!ed->objects_iface) 1632 &server_desc);
1764 { 1633 EINA_SAFETY_ON_NULL_RETURN(iface);
1765 ERR("could not create interface.");
1766 return;
1767 }
1768 1634
1769 r = _ethumb_dbus_interface_elements_add(ed->objects_iface, 1635 edbus_service_object_data_set(iface, DAEMON, ed);
1770 _ethumb_dbus_objects_methods,
1771 _ethumb_dbus_objects_signals);
1772 if (!r)
1773 {
1774 ERR("ERROR: could not setup objects interface methods.");
1775 e_dbus_interface_unref(ed->objects_iface);
1776 return;
1777 }
1778
1779 _ethumb_dbus_add_name_owner_changed_cb(ed);
1780 1636
1781 _ethumbd_timeout_start(ed); 1637 _ethumbd_timeout_start(ed);
1782} 1638}
@@ -1784,9 +1640,8 @@ _ethumb_dbus_request_name_cb(void *data, DBusMessage *msg __UNUSED__, DBusError
1784static int 1640static int
1785_ethumb_dbus_setup(Ethumbd *ed) 1641_ethumb_dbus_setup(Ethumbd *ed)
1786{ 1642{
1787 e_dbus_request_name 1643 edbus_name_request(ed->conn, _ethumb_dbus_bus_name, 0,
1788 (ed->conn, _ethumb_dbus_bus_name, 0, _ethumb_dbus_request_name_cb, ed); 1644 _ethumb_dbus_request_name_cb, ed);
1789
1790 return 1; 1645 return 1;
1791} 1646}
1792 1647
@@ -1795,10 +1650,7 @@ _ethumb_dbus_finish(Ethumbd *ed)
1795{ 1650{
1796 _process_queue_stop(ed); 1651 _process_queue_stop(ed);
1797 _ethumb_table_clear(ed); 1652 _ethumb_table_clear(ed);
1798 e_dbus_signal_handler_del(ed->conn, ed->name_owner_changed_handler); 1653 edbus_connection_unref(ed->conn);
1799 e_dbus_interface_unref(ed->objects_iface);
1800 e_dbus_interface_unref(ed->eiface);
1801 e_dbus_object_free(ed->dbus_obj);
1802 free(ed->queue.table); 1654 free(ed->queue.table);
1803 free(ed->queue.list); 1655 free(ed->queue.list);
1804} 1656}
@@ -1866,9 +1718,9 @@ main(int argc, char *argv[])
1866 goto finish; 1718 goto finish;
1867 } 1719 }
1868 1720
1869 if (!e_dbus_init()) 1721 if (!edbus_init())
1870 { 1722 {
1871 ERR("could not init e_dbus."); 1723 ERR("could not init edbus.");
1872 exit_value = -1; 1724 exit_value = -1;
1873 goto finish; 1725 goto finish;
1874 } 1726 }
@@ -1893,7 +1745,7 @@ main(int argc, char *argv[])
1893 if (quit_option) 1745 if (quit_option)
1894 goto finish; 1746 goto finish;
1895 1747
1896 ed.conn = e_dbus_bus_get(DBUS_BUS_SESSION); 1748 ed.conn = edbus_connection_get(EDBUS_CONNECTION_TYPE_SESSION);
1897 if (!ed.conn) 1749 if (!ed.conn)
1898 { 1750 {
1899 ERR("could not connect to session bus."); 1751 ERR("could not connect to session bus.");
@@ -1905,7 +1757,7 @@ main(int argc, char *argv[])
1905 1757
1906 if (!_ethumb_dbus_setup(&ed)) 1758 if (!_ethumb_dbus_setup(&ed))
1907 { 1759 {
1908 e_dbus_connection_close(ed.conn); 1760 edbus_connection_unref(ed.conn);
1909 ERR("could not setup dbus connection."); 1761 ERR("could not setup dbus connection.");
1910 exit_value = -5; 1762 exit_value = -5;
1911 goto finish_edbus; 1763 goto finish_edbus;
@@ -1921,7 +1773,7 @@ main(int argc, char *argv[])
1921 _log_domain = -1; 1773 _log_domain = -1;
1922 } 1774 }
1923 1775
1924 e_dbus_shutdown(); 1776 edbus_shutdown();
1925 finish: 1777 finish:
1926 if (ed.slave.exe) 1778 if (ed.slave.exe)
1927 ecore_exe_quit(ed.slave.exe); 1779 ecore_exe_quit(ed.slave.exe);
diff --git a/legacy/ethumb/src/bin/ethumbd_client.c b/legacy/ethumb/src/bin/ethumbd_client.c
index 54b02c7e90..1dcdf111ed 100644
--- a/legacy/ethumb/src/bin/ethumbd_client.c
+++ b/legacy/ethumb/src/bin/ethumbd_client.c
@@ -232,7 +232,7 @@ main(int argc, char *argv[])
232{ 232{
233 Ethumb_Client *c; 233 Ethumb_Client *c;
234 Eina_Bool quit_option = 0; 234 Eina_Bool quit_option = 0;
235 const char *format_str = NULL, *aspect_str; 235 const char *format_str = NULL, *aspect_str = NULL;
236 struct options opts = { 236 struct options opts = {
237 {-1, -1, -1, -1}, 237 {-1, -1, -1, -1},
238 0, 0, 238 0, 0,
diff --git a/legacy/ethumb/src/lib/client/Ethumb_Client.h b/legacy/ethumb/src/lib/client/Ethumb_Client.h
index 81105aacaf..47fe5ee60f 100644
--- a/legacy/ethumb/src/lib/client/Ethumb_Client.h
+++ b/legacy/ethumb/src/lib/client/Ethumb_Client.h
@@ -127,7 +127,7 @@ typedef void (*Ethumb_Client_Generate_Cancel_Cb)(void *data, Eina_Bool success);
127EAPI int ethumb_client_init(void); 127EAPI int ethumb_client_init(void);
128EAPI int ethumb_client_shutdown(void); 128EAPI int ethumb_client_shutdown(void);
129 129
130EAPI Ethumb_Client * ethumb_client_connect(Ethumb_Client_Connect_Cb connect_cb, const void *data, Eina_Free_Cb free_data); 130EAPI Ethumb_Client *ethumb_client_connect(Ethumb_Client_Connect_Cb connect_cb, const void *data, Eina_Free_Cb free_data);
131EAPI void ethumb_client_disconnect(Ethumb_Client *client); 131EAPI void ethumb_client_disconnect(Ethumb_Client *client);
132EAPI void ethumb_client_on_server_die_callback_set(Ethumb_Client *client, Ethumb_Client_Die_Cb server_die_cb, const void *data, Eina_Free_Cb free_data); 132EAPI void ethumb_client_on_server_die_callback_set(Ethumb_Client *client, Ethumb_Client_Die_Cb server_die_cb, const void *data, Eina_Free_Cb free_data);
133 133
diff --git a/legacy/ethumb/src/lib/client/ethumb_client.c b/legacy/ethumb/src/lib/client/ethumb_client.c
index ee17507cd1..0efcb1beeb 100644
--- a/legacy/ethumb/src/lib/client/ethumb_client.c
+++ b/legacy/ethumb/src/lib/client/ethumb_client.c
@@ -77,7 +77,7 @@
77 77
78#include <Eina.h> 78#include <Eina.h>
79#include <eina_safety_checks.h> 79#include <eina_safety_checks.h>
80#include <E_DBus.h> 80#include <EDBus.h>
81#include <Ethumb.h> 81#include <Ethumb.h>
82#include <Ecore.h> 82#include <Ecore.h>
83 83
@@ -100,15 +100,8 @@ struct _Ethumb_Client
100{ 100{
101 Ethumb *ethumb; 101 Ethumb *ethumb;
102 int id_count; 102 int id_count;
103
104 Ethumb *old_ethumb_conf; 103 Ethumb *old_ethumb_conf;
105 E_DBus_Connection *conn; 104 EDBus_Connection *conn;
106 E_DBus_Signal_Handler *name_owner_changed_handler;
107 E_DBus_Signal_Handler *generated_signal;
108 DBusPendingCall *pending_get_name_owner;
109 DBusPendingCall *pending_start_service_by_name;
110 const char *unique_name;
111 DBusPendingCall *pending_new;
112 struct 105 struct
113 { 106 {
114 Ethumb_Client_Connect_Cb cb; 107 Ethumb_Client_Connect_Cb cb;
@@ -118,25 +111,21 @@ struct _Ethumb_Client
118 Eina_List *pending_add; 111 Eina_List *pending_add;
119 Eina_List *pending_remove; 112 Eina_List *pending_remove;
120 Eina_List *pending_gen; 113 Eina_List *pending_gen;
121 DBusPendingCall *pending_clear;
122 DBusPendingCall *pending_setup;
123 struct 114 struct
124 { 115 {
125 Ethumb_Client_Die_Cb cb; 116 Ethumb_Client_Die_Cb cb;
126 void *data; 117 void *data;
127 Eina_Free_Cb free_data; 118 Eina_Free_Cb free_data;
128 } die; 119 } die;
129 const char *object_path; 120 EDBus_Proxy *proxy;
130
131 EINA_REFCOUNT; 121 EINA_REFCOUNT;
132
133 Eina_Bool connected : 1; 122 Eina_Bool connected : 1;
134 Eina_Bool server_started : 1; 123 Eina_Bool server_started : 1;
135}; 124};
136 125
137struct _ethumb_pending_add 126struct _ethumb_pending_add
138{ 127{
139 dbus_int32_t id; 128 int32_t id;
140 const char *file; 129 const char *file;
141 const char *key; 130 const char *key;
142 const char *thumb; 131 const char *thumb;
@@ -144,23 +133,22 @@ struct _ethumb_pending_add
144 Ethumb_Client_Generate_Cb generated_cb; 133 Ethumb_Client_Generate_Cb generated_cb;
145 void *data; 134 void *data;
146 Eina_Free_Cb free_data; 135 Eina_Free_Cb free_data;
147 DBusPendingCall *pending_call; 136 EDBus_Pending *pending_call;
148 Ethumb_Client *client; 137 Ethumb_Client *client;
149}; 138};
150 139
151struct _ethumb_pending_remove 140struct _ethumb_pending_remove
152{ 141{
153 dbus_int32_t id; 142 int32_t id;
154 Ethumb_Client_Generate_Cancel_Cb cancel_cb; 143 Ethumb_Client_Generate_Cancel_Cb cancel_cb;
155 void *data; 144 void *data;
156 Eina_Free_Cb free_data; 145 Eina_Free_Cb free_data;
157 DBusPendingCall *pending_call;
158 Ethumb_Client *client; 146 Ethumb_Client *client;
159}; 147};
160 148
161struct _ethumb_pending_gen 149struct _ethumb_pending_gen
162{ 150{
163 dbus_int32_t id; 151 int32_t id;
164 const char *file; 152 const char *file;
165 const char *key; 153 const char *key;
166 const char *thumb; 154 const char *thumb;
@@ -203,63 +191,9 @@ static const char fdo_path[] = "/org/freedesktop/DBus";
203static int _initcount = 0; 191static int _initcount = 0;
204static Eina_Hash *_exists_request = NULL; 192static Eina_Hash *_exists_request = NULL;
205 193
206static void _ethumb_client_generated_cb(void *data, DBusMessage *msg); 194static void _ethumb_client_generated_cb(void *data, const EDBus_Message *msg);
207static void _ethumb_client_get_name_owner(void *data, DBusMessage *msg, DBusError *err); 195static void _ethumb_client_call_new(Ethumb_Client *client);
208 196static void _ethumb_client_name_owner_changed(void *context, const char *bus, const char *old_id, const char *new_id);
209static inline bool
210__dbus_callback_check_and_init(const char *file, int line, const char *function, DBusMessage *msg, DBusMessageIter *itr, DBusError *err)
211{
212 if (!msg)
213 {
214 ERR("%s:%d:%s() callback without message arguments!",
215 file, line, function);
216
217 if (err)
218 ERR("%s:%d:%s() an error was reported by server: "
219 "name=\"%s\", message=\"%s\"",
220 file, line, function, err->name, err->message);
221
222 return 0;
223 }
224
225 if (!dbus_message_iter_init(msg, itr))
226 {
227 ERR("%s:%d:%s() could not init iterator.",
228 file, line, function);
229 return 0;
230 }
231
232 return 1;
233}
234
235#define _dbus_callback_check_and_init(msg, itr, err) \
236 __dbus_callback_check_and_init(__FILE__, __LINE__, __FUNCTION__, \
237 msg, itr, err)
238
239static inline bool
240__dbus_iter_type_check(int type, int expected, const char *expected_name)
241{
242 if (type == expected)
243 return 1;
244
245 ERR("expected type %s (%c) but got %c instead!",
246 expected_name, expected, type);
247
248 return 0;
249}
250
251#define _dbus_iter_type_check(t, e) __dbus_iter_type_check(t, e, #e)
252
253#define CHECK_NULL_RETURN(ptr, ...) \
254 do \
255 { \
256 if ((ptr) == NULL) \
257 { \
258 CRITICAL("%s == NULL!", #ptr); \
259 return __VA_ARGS__; \
260 } \
261 } \
262 while (0)
263 197
264static void 198static void
265_ethumb_client_free(Ethumb_Client *client) 199_ethumb_client_free(Ethumb_Client *client)
@@ -272,15 +206,7 @@ _ethumb_client_free(Ethumb_Client *client)
272 EINA_LIST_FREE(client->pending_add, data) 206 EINA_LIST_FREE(client->pending_add, data)
273 { 207 {
274 struct _ethumb_pending_add *pending = data; 208 struct _ethumb_pending_add *pending = data;
275 eina_stringshare_del(pending->file); 209 edbus_pending_cancel(pending->pending_call);
276 eina_stringshare_del(pending->key);
277 eina_stringshare_del(pending->thumb);
278 eina_stringshare_del(pending->thumb_key);
279 dbus_pending_call_cancel(pending->pending_call);
280 dbus_pending_call_unref(pending->pending_call);
281 if (pending->free_data)
282 pending->free_data(pending->data);
283 free(pending);
284 } 210 }
285 211
286 EINA_LIST_FREE(client->pending_gen, data) 212 EINA_LIST_FREE(client->pending_gen, data)
@@ -298,44 +224,21 @@ _ethumb_client_free(Ethumb_Client *client)
298 EINA_LIST_FREE(client->pending_remove, data) 224 EINA_LIST_FREE(client->pending_remove, data)
299 { 225 {
300 struct _ethumb_pending_remove *pending = data; 226 struct _ethumb_pending_remove *pending = data;
301 dbus_pending_call_cancel(pending->pending_call);
302 dbus_pending_call_unref(pending->pending_call);
303 if (pending->free_data) 227 if (pending->free_data)
304 pending->free_data(pending->data); 228 pending->free_data(pending->data);
305 free(pending); 229 free(pending);
306 } 230 }
307 231
308 if (client->pending_clear)
309 {
310 dbus_pending_call_cancel(client->pending_clear);
311 dbus_pending_call_unref(client->pending_clear);
312 }
313
314end_connection: 232end_connection:
315 if (client->object_path)
316 eina_stringshare_del(client->object_path);
317
318 if (client->pending_new)
319 dbus_pending_call_cancel(client->pending_new);
320
321 if (client->unique_name)
322 eina_stringshare_del(client->unique_name);
323
324 if (client->pending_get_name_owner)
325 dbus_pending_call_cancel(client->pending_get_name_owner);
326
327 if (client->pending_start_service_by_name)
328 dbus_pending_call_cancel(client->pending_start_service_by_name);
329
330 if (client->old_ethumb_conf) 233 if (client->old_ethumb_conf)
331 ethumb_free(client->old_ethumb_conf); 234 ethumb_free(client->old_ethumb_conf);
332 235
333 ethumb_free(client->ethumb); 236 ethumb_free(client->ethumb);
334 237
335 e_dbus_signal_handler_del(client->conn, client->name_owner_changed_handler); 238 edbus_name_owner_changed_callback_del(client->conn, _ethumb_dbus_bus_name,
336 if (client->connected) 239 _ethumb_client_name_owner_changed,
337 e_dbus_signal_handler_del(client->conn, client->generated_signal); 240 client);
338 e_dbus_connection_close(client->conn); 241 edbus_connection_unref(client->conn);
339 242
340 if (client->connect.free_data) 243 if (client->connect.free_data)
341 client->connect.free_data(client->connect.data); 244 client->connect.free_data(client->connect.data);
@@ -360,56 +263,32 @@ _ethumb_async_delete(void *data)
360} 263}
361 264
362static void 265static void
363_ethumb_client_name_owner_changed(void *data, DBusMessage *msg) 266_ethumb_client_name_owner_changed(void *context, const char *bus, const char *old_id, const char *new_id)
364{ 267{
365 DBusError err; 268 Ethumb_Client *client = context;
366 const char *name, *from, *to; 269 DBG("NameOwnerChanged from=[%s] to=[%s]", old_id, new_id);
367 Ethumb_Client *client = data; 270 if (new_id[0])
368
369 dbus_error_init(&err);
370 if (!dbus_message_get_args(msg, &err,
371 DBUS_TYPE_STRING, &name,
372 DBUS_TYPE_STRING, &from,
373 DBUS_TYPE_STRING, &to,
374 DBUS_TYPE_INVALID))
375 { 271 {
376 ERR("could not get NameOwnerChanged arguments: %s: %s", 272 if (client->connected)
377 err.name, err.message); 273 return;
378 dbus_error_free(&err); 274
275 client->connected = EINA_TRUE;
276 _ethumb_client_call_new(client);
379 return; 277 return;
380 } 278 }
381 279 ERR("server exit!!!");
382 if (!from || !name) 280 client->connected = EINA_FALSE;
383 return; 281 if (client->die.cb)
384 if (strcmp(name, _ethumb_dbus_bus_name) != 0)
385 return;
386
387 DBG("NameOwnerChanged from=[%s] to=[%s]", from, to);
388
389 if (from[0] != '\0' && to[0] == '\0')
390 { 282 {
391 DBG("exit ethumbd at %s", from); 283 client->die.cb(client->die.data, client);
392 if (client->unique_name && strcmp(client->unique_name, from) != 0) 284 client->die.cb = NULL;
393 WRN("%s was not the known name %s, ignored.", 285 }
394 from, client->unique_name); 286 if (client->die.free_data)
395 else if (client->unique_name) 287 {
396 { 288 client->die.free_data(client->die.data);
397 ERR("server exit!!!"); 289 client->die.free_data = NULL;
398 if (client->die.cb) 290 client->die.data = NULL;
399 {
400 client->die.cb(client->die.data, client);
401 client->die.cb = NULL;
402 }
403 if (client->die.free_data)
404 {
405 client->die.free_data(client->die.data);
406 client->die.free_data = NULL;
407 client->die.data = NULL;
408 }
409 }
410 } 291 }
411 else
412 DBG("unknown change from %s to %s", from, to);
413} 292}
414 293
415static void 294static void
@@ -432,163 +311,42 @@ _ethumb_client_report_connect(Ethumb_Client *client, Eina_Bool success)
432} 311}
433 312
434static void 313static void
435_ethumb_client_new_cb(void *data, DBusMessage *msg, DBusError *error) 314_ethumb_client_new_cb(void *data, const EDBus_Message *msg, EDBus_Pending *pending)
436{ 315{
437 DBusMessageIter iter; 316 const char *errname, *errmsg;
438 const char *opath; 317 const char *opath;
439 int t;
440 Ethumb_Client *client = data; 318 Ethumb_Client *client = data;
319 EDBus_Object *obj;
441 320
442 client->pending_new = NULL; 321 if (edbus_message_error_get(msg, &errname, &errmsg))
443
444 if (!_dbus_callback_check_and_init(msg, &iter, error))
445 goto end_error;
446 t = dbus_message_iter_get_arg_type(&iter);
447 if (!_dbus_iter_type_check(t, DBUS_TYPE_OBJECT_PATH))
448 goto end_error;
449
450 dbus_message_iter_get_basic(&iter, &opath);
451 if (opath[0] == '\0')
452 goto end_error;
453
454 client->object_path = eina_stringshare_add(opath);
455
456 client->generated_signal = e_dbus_signal_handler_add(
457 client->conn, _ethumb_dbus_bus_name, opath,
458 _ethumb_dbus_objects_interface, "generated",
459 _ethumb_client_generated_cb, client);
460
461 _ethumb_client_report_connect(client, 1);
462 return;
463
464end_error:
465 _ethumb_client_report_connect(client, 0);
466}
467
468static void
469_ethumb_client_call_new(Ethumb_Client *client)
470{
471 DBusMessage *msg;
472
473 msg = dbus_message_new_method_call(_ethumb_dbus_bus_name, _ethumb_dbus_path,
474 _ethumb_dbus_interface, "new");
475 client->pending_new = e_dbus_message_send(client->conn, msg,
476 _ethumb_client_new_cb, -1,
477 client);
478 dbus_message_unref(msg);
479}
480
481static void
482_ethumb_client_start_server_cb(void *data, DBusMessage *msg, DBusError *err)
483{
484 Ethumb_Client *client = data;
485 DBusMessageIter iter;
486 dbus_uint32_t ret;
487 int t;
488
489 client->pending_start_service_by_name = NULL;
490
491 if (!_dbus_callback_check_and_init(msg, &iter, err))
492 goto error;
493
494 t = dbus_message_iter_get_arg_type(&iter);
495 if (!_dbus_iter_type_check(t, DBUS_TYPE_UINT32))
496 goto error;
497
498 dbus_message_iter_get_basic(&iter, &ret);
499 if ((ret != 1) && (ret != 2))
500 {
501 ERR("Error starting Ethumbd DBus service by its name: retcode %u",
502 ret);
503 goto error;
504 }
505
506 client->server_started = 1;
507 DBG("Ethumbd DBus service started successfully (%d), now request its name",
508 ret);
509
510 if (client->pending_get_name_owner)
511 { 322 {
512 DBG("already requesting name owner, cancel and try again"); 323 ERR("Error: %s %s", errname, errmsg);
513 dbus_pending_call_cancel(client->pending_get_name_owner);
514 }
515
516 client->pending_get_name_owner = e_dbus_get_name_owner
517 (client->conn, _ethumb_dbus_bus_name, _ethumb_client_get_name_owner,
518 client);
519 if (!client->pending_get_name_owner)
520 {
521 ERR("could not create a get_name_owner request.");
522 goto error;
523 }
524
525 return;
526
527error:
528 ERR("failed to start Ethumbd DBus service by its name.");
529 _ethumb_client_report_connect(client, 0);
530}
531
532static void
533_ethumb_client_start_server(Ethumb_Client *client)
534{
535 if (client->pending_start_service_by_name)
536 {
537 DBG("already pending start service by name.");
538 return; 324 return;
539 } 325 }
540 326
541 client->server_started = 0; 327 if (!edbus_message_arguments_get(msg, "o", &opath))
542 client->pending_start_service_by_name = e_dbus_start_service_by_name
543 (client->conn, _ethumb_dbus_bus_name, 0, _ethumb_client_start_server_cb,
544 client);
545 if (!client->pending_start_service_by_name)
546 { 328 {
547 ERR("could not start service by name!"); 329 ERR("Error: could not get entry contents");
548 _ethumb_client_report_connect(client, 0); 330 _ethumb_client_report_connect(client, 0);
331 return;
549 } 332 }
333
334 obj = edbus_object_get(client->conn, _ethumb_dbus_bus_name, opath);
335 client->proxy = edbus_proxy_get(obj, _ethumb_dbus_objects_interface);
336 edbus_proxy_signal_handler_add(client->proxy, "generated",
337 _ethumb_client_generated_cb, client);
338 _ethumb_client_report_connect(client, 1);
550} 339}
551 340
552static void 341static void
553_ethumb_client_get_name_owner(void *data, DBusMessage *msg, DBusError *err) 342_ethumb_client_call_new(Ethumb_Client *client)
554{ 343{
555 DBusMessageIter iter; 344 EDBus_Message *msg;
556 const char *uid; 345 msg = edbus_message_method_call_new(_ethumb_dbus_bus_name,
557 Ethumb_Client *client = data; 346 _ethumb_dbus_path,
558 int t; 347 _ethumb_dbus_interface, "new");
559 348 edbus_connection_send(client->conn, msg, _ethumb_client_new_cb, client, -1);
560 client->pending_get_name_owner = NULL; 349 edbus_message_unref(msg);
561
562 if (dbus_error_is_set(err) && (!client->server_started))
563 {
564 DBG("could not find server (%s), try to start it...", err->message);
565 _ethumb_client_start_server(client);
566 return;
567 }
568
569 if (!_dbus_callback_check_and_init(msg, &iter, err))
570 goto error;
571
572 t = dbus_message_iter_get_arg_type(&iter);
573 if (!_dbus_iter_type_check(t, DBUS_TYPE_STRING))
574 goto error;
575
576 dbus_message_iter_get_basic(&iter, &uid);
577 if (!uid)
578 {
579 ERR("no name owner!");
580 goto error;
581 }
582
583 DBG("unique name = %s", uid);
584 client->unique_name = eina_stringshare_add(uid);
585
586 _ethumb_client_call_new(client);
587 client->connected = 1;
588 return;
589
590error:
591 _ethumb_client_report_connect(client, 0);
592} 350}
593 351
594static void 352static void
@@ -670,7 +428,7 @@ ethumb_client_init(void)
670 } 428 }
671 429
672 ethumb_init(); 430 ethumb_init();
673 e_dbus_init(); 431 edbus_init();
674 432
675 _exists_request = eina_hash_stringshared_new(_ethumb_async_delete); 433 _exists_request = eina_hash_stringshared_new(_ethumb_async_delete);
676 434
@@ -704,7 +462,7 @@ ethumb_client_shutdown(void)
704 eina_hash_free(_exists_request); 462 eina_hash_free(_exists_request);
705 _exists_request = NULL; 463 _exists_request = NULL;
706 464
707 e_dbus_shutdown(); 465 edbus_shutdown();
708 ethumb_shutdown(); 466 ethumb_shutdown();
709 eina_log_domain_unregister(_log_dom); 467 eina_log_domain_unregister(_log_dom);
710 _log_dom = -1; 468 _log_dom = -1;
@@ -776,26 +534,17 @@ ethumb_client_connect(Ethumb_Client_Connect_Cb connect_cb, const void *data, Ein
776 goto ethumb_new_err; 534 goto ethumb_new_err;
777 } 535 }
778 536
779 eclient->conn = e_dbus_bus_get(DBUS_BUS_SESSION); 537 eclient->conn = edbus_connection_get(EDBUS_CONNECTION_TYPE_SESSION);
780 if (!eclient->conn) 538 if (!eclient->conn)
781 { 539 {
782 ERR("could not connect to session bus."); 540 ERR("could not connect to session bus.");
783 goto connection_err; 541 goto connection_err;
784 } 542 }
785 543
786 eclient->name_owner_changed_handler = e_dbus_signal_handler_add( 544 edbus_name_start(eclient->conn, _ethumb_dbus_bus_name, 0, NULL, NULL);
787 eclient->conn, fdo_bus_name, fdo_path, fdo_interface, 545 edbus_name_owner_changed_callback_add(eclient->conn, _ethumb_dbus_bus_name,
788 "NameOwnerChanged", _ethumb_client_name_owner_changed, eclient); 546 _ethumb_client_name_owner_changed,
789 547 eclient, EINA_TRUE);
790 eclient->pending_get_name_owner = e_dbus_get_name_owner(
791 eclient->conn, _ethumb_dbus_bus_name, _ethumb_client_get_name_owner,
792 eclient);
793 if (!eclient->pending_get_name_owner)
794 {
795 ERR("could not create a get_name_owner request.");
796 goto connection_err;
797 }
798
799 EINA_REFCOUNT_INIT(eclient); 548 EINA_REFCOUNT_INIT(eclient);
800 549
801 return eclient; 550 return eclient;
@@ -868,67 +617,76 @@ ethumb_client_on_server_die_callback_set(Ethumb_Client *client, Ethumb_Client_Di
868 */ 617 */
869 618
870static void 619static void
871_ethumb_client_ethumb_setup_cb(void *data, DBusMessage *msg, DBusError *error) 620_ethumb_client_ethumb_setup_cb(void *data, const EDBus_Message *msg, EDBus_Pending *pending)
872{ 621{
873 DBusMessageIter iter; 622 const char *errname, *errmsg;
874 int t; 623 Eina_Bool result = 0;
875 dbus_bool_t result = 0;
876 Ethumb_Client *client = data;
877
878 client->pending_setup = NULL;
879
880 if (!_dbus_callback_check_and_init(msg, &iter, error))
881 return;
882 624
883 t = dbus_message_iter_get_arg_type(&iter); 625 if (edbus_message_error_get(msg, &errname, &errmsg))
884 if (!_dbus_iter_type_check(t, DBUS_TYPE_BOOLEAN)) 626 {
885 return; 627 ERR("Error: %s %s\n", errname, errmsg);
628 return;
629 }
886 630
887 dbus_message_iter_get_basic(&iter, &result); 631 if (!edbus_message_arguments_get(msg, "b", &result))
632 {
633 ERR("Error getting arguments");
634 return;
635 }
636 EINA_SAFETY_ON_FALSE_RETURN(result);
888} 637}
889 638
890static const char * 639static const char *
891_ethumb_client_dbus_get_bytearray(DBusMessageIter *iter) 640_ethumb_client_dbus_get_bytearray(EDBus_Message_Iter *array)
892{ 641{
893 int el_type;
894 int length; 642 int length;
895 DBusMessageIter riter;
896 const char *result; 643 const char *result;
897 644
898 el_type = dbus_message_iter_get_element_type(iter); 645 if (edbus_message_iter_fixed_array_get(array, 'y', &result, &length))
899 if (el_type != DBUS_TYPE_BYTE)
900 {
901 ERR("not an byte array element.");
902 return NULL;
903 }
904
905 dbus_message_iter_recurse(iter, &riter);
906 dbus_message_iter_get_fixed_array(&riter, &result, &length);
907
908 if (result[0] == '\0')
909 return NULL;
910 else
911 return eina_stringshare_add(result); 646 return eina_stringshare_add(result);
647 else
648 return NULL;
912} 649}
913 650
914static void 651static void
915_ethumb_client_dbus_append_bytearray(DBusMessageIter *iter, const char *string) 652_ethumb_client_dbus_append_bytearray(EDBus_Message_Iter *parent, const char *string)
916{ 653{
917 DBusMessageIter viter; 654 int i, size;
655 EDBus_Message_Iter *array;
918 656
919 if (!string) 657 if (!string)
920 string = ""; 658 string = "";
921 659
922 dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, "y", &viter); 660 array = edbus_message_iter_container_new(parent, 'a', "y");
923 dbus_message_iter_append_fixed_array(&viter, DBUS_TYPE_BYTE, &string, 661 size = strlen(string);
924 strlen(string) + 1); 662 for (i = 0; i < size; i++)
925 dbus_message_iter_close_container(iter, &viter); 663 edbus_message_iter_basic_append(array, 'y', string[i]);
664 edbus_message_iter_container_close(parent, array);
926} 665}
927 666
928/** 667/**
929 * @endcond 668 * @endcond
930 */ 669 */
931 670
671static EDBus_Message_Iter *
672_setup_iterator_open(EDBus_Message_Iter *array, EDBus_Message_Iter **config, const char *key, const char *type)
673{
674 EDBus_Message_Iter *variant, *_struct;
675 edbus_message_iter_arguments_set(array, "{sv}", &_struct);
676 edbus_message_iter_basic_append(_struct, 's', key);
677 variant = edbus_message_iter_container_new(_struct, 'v', type);
678
679 *config = _struct;
680 return variant;
681}
682
683static void
684_setup_iterator_close(EDBus_Message_Iter *array, EDBus_Message_Iter *config, EDBus_Message_Iter *variant)
685{
686 edbus_message_iter_container_close(config, variant);
687 edbus_message_iter_container_close(array, config);
688}
689
932/** 690/**
933 * Send setup to server. 691 * Send setup to server.
934 * 692 *
@@ -941,192 +699,145 @@ _ethumb_client_dbus_append_bytearray(DBusMessageIter *iter, const char *string)
941EAPI void 699EAPI void
942ethumb_client_ethumb_setup(Ethumb_Client *client) 700ethumb_client_ethumb_setup(Ethumb_Client *client)
943{ 701{
944 DBusMessage *msg; 702 EDBus_Message *msg;
945 DBusMessageIter iter, aiter, diter, viter, vaiter; 703 EDBus_Message_Iter *array, *main;
704 EDBus_Message_Iter *config, *variant;
705 EDBus_Message_Iter *sub_struct;
946 Ethumb *e = client->ethumb; 706 Ethumb *e = client->ethumb;
947 const char *entry; 707 const char *entry;
948 dbus_int32_t tw, th, format, aspect, orientation, quality, compress; 708 int tw, th, format, aspect, orientation, quality, compress;
949 float cx, cy; 709 float cx, cy;
950 double t; 710 double t;
951 const char *theme_file, *group, *swallow; 711 const char *theme_file, *group, *swallow;
952 const char *directory, *category; 712 const char *directory, *category;
953 double video_time, video_start, video_interval; 713 double video_time, video_start, video_interval;
954 dbus_int32_t video_ntimes, video_fps, document_page; 714 unsigned int video_ntimes, video_fps, document_page;
955 715
956 EINA_SAFETY_ON_NULL_RETURN(client); 716 EINA_SAFETY_ON_NULL_RETURN(client);
957 EINA_SAFETY_ON_FALSE_RETURN(client->connected); 717 EINA_SAFETY_ON_FALSE_RETURN(client->connected);
958 718
959 msg = dbus_message_new_method_call(_ethumb_dbus_bus_name, 719 msg = edbus_proxy_method_call_new(client->proxy, "ethumb_setup");
960 client->object_path, 720 main = edbus_message_iter_get(msg);
961 _ethumb_dbus_objects_interface, 721 edbus_message_iter_arguments_set(main, "a{sv}", &array);
962 "ethumb_setup");
963 dbus_message_iter_init_append(msg, &iter);
964 dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "{sv}", &aiter);
965
966/**
967 * @cond LOCAL
968 */
969#define _open_variant_iter(str_entry, str_type, end_iter) \
970 entry = str_entry; \
971 dbus_message_iter_open_container(&aiter, DBUS_TYPE_DICT_ENTRY, NULL, &diter); \
972 dbus_message_iter_append_basic(&diter, DBUS_TYPE_STRING, &entry); \
973 dbus_message_iter_open_container(&diter, DBUS_TYPE_VARIANT, str_type, \
974 &end_iter);
975
976#define _close_variant_iter(end_iter) \
977 dbus_message_iter_close_container(&diter, &end_iter); \
978 dbus_message_iter_close_container(&aiter, &diter);
979/**
980 * @endcond
981 */
982 722
983 /* starting array elements */ 723 /* starting array elements */
984 724 variant = _setup_iterator_open(array, &config, "size", "(ii)");
985 _open_variant_iter("size", "(ii)", viter); 725 edbus_message_iter_arguments_set(variant, "(ii)", &sub_struct);
986 dbus_message_iter_open_container(&viter, DBUS_TYPE_STRUCT, NULL, &vaiter);
987 ethumb_thumb_size_get(e, &tw, &th); 726 ethumb_thumb_size_get(e, &tw, &th);
988 dbus_message_iter_append_basic(&vaiter, DBUS_TYPE_INT32, &tw); 727 edbus_message_iter_arguments_set(sub_struct, "ii", tw, th);
989 dbus_message_iter_append_basic(&vaiter, DBUS_TYPE_INT32, &th); 728 edbus_message_iter_container_close(sub_struct, variant);
990 dbus_message_iter_close_container(&viter, &vaiter); 729 _setup_iterator_close(array, config, variant);
991 _close_variant_iter(viter);
992 730
993 _open_variant_iter("format", "i", viter); 731 variant = _setup_iterator_open(array, &config, "format", "i");
994 format = ethumb_thumb_format_get(e); 732 format = ethumb_thumb_format_get(e);
995 dbus_message_iter_append_basic(&viter, DBUS_TYPE_INT32, &format); 733 edbus_message_iter_arguments_set(variant, "i", format);
996 _close_variant_iter(viter); 734 _setup_iterator_close(array, config, variant);
997 735
998 _open_variant_iter("aspect", "i", viter); 736 variant = _setup_iterator_open(array, &config, "aspect", "i");
999 aspect = ethumb_thumb_aspect_get(e); 737 aspect = ethumb_thumb_aspect_get(e);
1000 dbus_message_iter_append_basic(&viter, DBUS_TYPE_INT32, &aspect); 738 edbus_message_iter_arguments_set(variant, "i", aspect);
1001 _close_variant_iter(viter); 739 _setup_iterator_close(array, config, variant);
1002 740
1003 _open_variant_iter("orientation", "i", viter); 741 variant = _setup_iterator_open(array, &config, "orientation", "i");
1004 orientation = ethumb_thumb_orientation_get(e); 742 orientation = ethumb_thumb_orientation_get(e);
1005 dbus_message_iter_append_basic(&viter, DBUS_TYPE_INT32, &orientation); 743 edbus_message_iter_arguments_set(variant, "i", orientation);
1006 _close_variant_iter(viter); 744 _setup_iterator_close(array, config, variant);
1007 745
1008 _open_variant_iter("crop", "(dd)", viter); 746 variant = _setup_iterator_open(array, &config, "crop", "(dd)");
1009 dbus_message_iter_open_container(&viter, DBUS_TYPE_STRUCT, NULL, &vaiter); 747 edbus_message_iter_arguments_set(variant, "(dd)", &sub_struct);
1010 ethumb_thumb_crop_align_get(e, &cx, &cy); 748 ethumb_thumb_crop_align_get(e, &cx, &cy);
1011 t = cx; 749 edbus_message_iter_arguments_set(sub_struct, "dd", (double)cx, (double)cy);
1012 dbus_message_iter_append_basic(&vaiter, DBUS_TYPE_DOUBLE, &t); 750 edbus_message_iter_container_close(sub_struct, variant);
1013 t = cy; 751 _setup_iterator_close(array, config, variant);
1014 dbus_message_iter_append_basic(&vaiter, DBUS_TYPE_DOUBLE, &t); 752
1015 dbus_message_iter_close_container(&viter, &vaiter); 753 variant = _setup_iterator_open(array, &config, "quality", "i");
1016 _close_variant_iter(viter);
1017
1018 _open_variant_iter("quality", "i", viter);
1019 quality = ethumb_thumb_quality_get(e); 754 quality = ethumb_thumb_quality_get(e);
1020 dbus_message_iter_append_basic(&viter, DBUS_TYPE_INT32, &quality); 755 edbus_message_iter_arguments_set(variant, "i", quality);
1021 _close_variant_iter(viter); 756 _setup_iterator_close(array, config, variant);
1022 757
1023 _open_variant_iter("compress", "i", viter); 758 variant = _setup_iterator_open(array, &config, "compress", "i");
1024 compress = ethumb_thumb_compress_get(e); 759 quality = ethumb_thumb_quality_get(e);
1025 dbus_message_iter_append_basic(&viter, DBUS_TYPE_INT32, &compress); 760 edbus_message_iter_arguments_set(variant, "i", compress);
1026 _close_variant_iter(viter); 761 _setup_iterator_close(array, config, variant);
1027 762
1028 _open_variant_iter("frame", "(ayayay)", viter); 763 variant = _setup_iterator_open(array, &config, "frame", "(ayayay)");
1029 dbus_message_iter_open_container(&viter, DBUS_TYPE_STRUCT, NULL, &vaiter); 764 edbus_message_iter_arguments_set(variant, "(ayayay)", &sub_struct);
1030 ethumb_frame_get(e, &theme_file, &group, &swallow); 765 ethumb_frame_get(e, &theme_file, &group, &swallow);
1031 _ethumb_client_dbus_append_bytearray(&vaiter, theme_file); 766 _ethumb_client_dbus_append_bytearray(sub_struct, theme_file);
1032 _ethumb_client_dbus_append_bytearray(&vaiter, group); 767 _ethumb_client_dbus_append_bytearray(sub_struct, group);
1033 _ethumb_client_dbus_append_bytearray(&vaiter, swallow); 768 _ethumb_client_dbus_append_bytearray(sub_struct, swallow);
1034 dbus_message_iter_close_container(&viter, &vaiter); 769 _setup_iterator_close(array, config, variant);
1035 _close_variant_iter(viter);
1036 770
1037 _open_variant_iter("directory", "ay", viter); 771 variant = _setup_iterator_open(array, &config, "directory", "ay");
1038 directory = ethumb_thumb_dir_path_get(e); 772 directory = ethumb_thumb_dir_path_get(e);
1039 _ethumb_client_dbus_append_bytearray(&viter, directory); 773 _ethumb_client_dbus_append_bytearray(variant, directory);
1040 _close_variant_iter(viter); 774 _setup_iterator_close(array, config, variant);
1041 775
1042 _open_variant_iter("category", "ay", viter); 776 variant = _setup_iterator_open(array, &config, "category", "ay");
1043 category = ethumb_thumb_category_get(e); 777 category = ethumb_thumb_category_get(e);
1044 _ethumb_client_dbus_append_bytearray(&viter, category); 778 _ethumb_client_dbus_append_bytearray(variant, category);
1045 _close_variant_iter(viter); 779 _setup_iterator_close(array, config, variant);
1046 780
1047 _open_variant_iter("video_time", "d", viter); 781 variant = _setup_iterator_open(array, &config, "video_time", "d");
1048 video_time = ethumb_video_time_get(e); 782 video_time = ethumb_video_time_get(e);
1049 dbus_message_iter_append_basic(&viter, DBUS_TYPE_DOUBLE, &video_time); 783 edbus_message_iter_arguments_set(variant, "d", video_time);
1050 _close_variant_iter(viter); 784 _setup_iterator_close(array, config, variant);
1051 785
1052 _open_variant_iter("video_start", "d", viter); 786 variant = _setup_iterator_open(array, &config, "video_start", "d");
1053 video_start = ethumb_video_start_get(e); 787 video_start = ethumb_video_start_get(e);
1054 dbus_message_iter_append_basic(&viter, DBUS_TYPE_DOUBLE, &video_start); 788 edbus_message_iter_arguments_set(variant, "d", video_start);
1055 _close_variant_iter(viter); 789 _setup_iterator_close(array, config, variant);
1056 790
1057 _open_variant_iter("video_interval", "d", viter); 791 variant = _setup_iterator_open(array, &config, "video_interval", "d");
1058 video_interval = ethumb_video_interval_get(e); 792 video_interval = ethumb_video_interval_get(e);
1059 dbus_message_iter_append_basic(&viter, DBUS_TYPE_DOUBLE, &video_interval); 793 edbus_message_iter_arguments_set(variant, "d", video_interval);
1060 _close_variant_iter(viter); 794 _setup_iterator_close(array, config, variant);
1061 795
1062 _open_variant_iter("video_ntimes", "u", viter); 796 variant = _setup_iterator_open(array, &config, "video_ntimes", "u");
1063 video_ntimes = ethumb_video_ntimes_get(e); 797 video_ntimes = ethumb_video_ntimes_get(e);
1064 dbus_message_iter_append_basic(&viter, DBUS_TYPE_UINT32, &video_ntimes); 798 edbus_message_iter_arguments_set(variant, "u", video_ntimes);
1065 _close_variant_iter(viter); 799 _setup_iterator_close(array, config, variant);
1066 800
1067 _open_variant_iter("video_fps", "u", viter); 801 variant = _setup_iterator_open(array, &config, "video_fps", "u");
1068 video_fps = ethumb_video_fps_get(e); 802 video_fps = ethumb_video_fps_get(e);
1069 dbus_message_iter_append_basic(&viter, DBUS_TYPE_UINT32, &video_fps); 803 edbus_message_iter_arguments_set(variant, "u", video_fps);
1070 _close_variant_iter(viter); 804 _setup_iterator_close(array, config, variant);
1071 805
1072 _open_variant_iter("document_page", "u", viter); 806 variant = _setup_iterator_open(array, &config, "document_page", "u");
1073 document_page = ethumb_document_page_get(e); 807 document_page = ethumb_document_page_get(e);
1074 dbus_message_iter_append_basic(&viter, DBUS_TYPE_UINT32, &document_page); 808 edbus_message_iter_arguments_set(variant, "u", document_page);
1075 _close_variant_iter(viter); 809 _setup_iterator_close(array, config, variant);
1076
1077#undef _open_variant_iter
1078#undef _close_variant_iter
1079 810
1080 dbus_message_iter_close_container(&iter, &aiter); 811 edbus_message_iter_container_close(main, array);
1081 812
1082 client->pending_setup = e_dbus_message_send(client->conn, msg, 813 edbus_proxy_send(client->proxy, msg, _ethumb_client_ethumb_setup_cb,
1083 _ethumb_client_ethumb_setup_cb, 814 client, -1);
1084 -1, client); 815 edbus_message_unref(msg);
1085 dbus_message_unref(msg);
1086} 816}
1087 817
1088/** 818/**
1089 * @cond LOCAL 819 * @cond LOCAL
1090 */ 820 */
1091
1092static void 821static void
1093_ethumb_client_generated_cb(void *data, DBusMessage *msg) 822_ethumb_client_generated_cb(void *data, const EDBus_Message *msg)
1094{ 823{
1095 DBusMessageIter iter; 824 int id = -1;
1096 dbus_int32_t id = -1; 825 Ethumb_Client *client = data;
826 EDBus_Message_Iter *thumb_iter;
827 EDBus_Message_Iter *thumb_key_iter;
828 Eina_Bool success;
1097 const char *thumb = NULL; 829 const char *thumb = NULL;
1098 const char *thumb_key = NULL; 830 const char *thumb_key = NULL;
1099 Ethumb_Client *client = data;
1100 int t;
1101 dbus_bool_t success;
1102 Eina_List *l;
1103 int found; 831 int found;
1104 struct _ethumb_pending_gen *pending; 832 struct _ethumb_pending_gen *pending;
833 Eina_List *l;
1105 834
1106 dbus_message_iter_init(msg, &iter); 835 if (!edbus_message_arguments_get(msg, "iayayb", &id, &thumb_iter,
1107 836 &thumb_key_iter, &success))
1108 t = dbus_message_iter_get_arg_type(&iter); 837 {
1109 if (!_dbus_iter_type_check(t, DBUS_TYPE_INT32)) 838 ERR("Error getting data from signal.");
1110 goto end; 839 return;
1111 dbus_message_iter_get_basic(&iter, &id); 840 }
1112 dbus_message_iter_next(&iter);
1113
1114 t = dbus_message_iter_get_arg_type(&iter);
1115 if (!_dbus_iter_type_check(t, DBUS_TYPE_ARRAY))
1116 goto end;
1117 thumb = _ethumb_client_dbus_get_bytearray(&iter);
1118 dbus_message_iter_next(&iter);
1119
1120 t = dbus_message_iter_get_arg_type(&iter);
1121 if (!_dbus_iter_type_check(t, DBUS_TYPE_ARRAY))
1122 goto end;
1123 thumb_key = _ethumb_client_dbus_get_bytearray(&iter);
1124 dbus_message_iter_next(&iter);
1125
1126 t = dbus_message_iter_get_arg_type(&iter);
1127 if (!_dbus_iter_type_check(t, DBUS_TYPE_BOOLEAN))
1128 goto end;
1129 dbus_message_iter_get_basic(&iter, &success);
1130 841
1131 found = 0; 842 found = 0;
1132 l = client->pending_gen; 843 l = client->pending_gen;
@@ -1143,6 +854,9 @@ _ethumb_client_generated_cb(void *data, DBusMessage *msg)
1143 854
1144 if (found) 855 if (found)
1145 { 856 {
857 thumb = _ethumb_client_dbus_get_bytearray(thumb_iter);
858 thumb_key = _ethumb_client_dbus_get_bytearray(thumb_key_iter);
859
1146 client->pending_gen = eina_list_remove_list(client->pending_gen, l); 860 client->pending_gen = eina_list_remove_list(client->pending_gen, l);
1147 if (pending->generated_cb) 861 if (pending->generated_cb)
1148 pending->generated_cb(pending->data, client, id, 862 pending->generated_cb(pending->data, client, id,
@@ -1157,32 +871,31 @@ _ethumb_client_generated_cb(void *data, DBusMessage *msg)
1157 eina_stringshare_del(pending->thumb_key); 871 eina_stringshare_del(pending->thumb_key);
1158 free(pending); 872 free(pending);
1159 } 873 }
1160
1161end:
1162 if (thumb) eina_stringshare_del(thumb);
1163 if (thumb_key) eina_stringshare_del(thumb_key);
1164} 874}
1165 875
1166static void 876static void
1167_ethumb_client_queue_add_cb(void *data, DBusMessage *msg, DBusError *error) 877_ethumb_client_queue_add_cb(void *data, const EDBus_Message *msg, EDBus_Pending *edbus_pending)
1168{ 878{
1169 DBusMessageIter iter; 879 const char *errname, *errmsg;
1170 int t; 880 int32_t id;
1171 dbus_int32_t id = -1;
1172 struct _ethumb_pending_add *pending = data; 881 struct _ethumb_pending_add *pending = data;
1173 struct _ethumb_pending_gen *generating; 882 struct _ethumb_pending_gen *generating;
1174 Ethumb_Client *client = pending->client; 883 Ethumb_Client *client = pending->client;
1175 884
1176 client->pending_add = eina_list_remove(client->pending_add, pending); 885 client->pending_add = eina_list_remove(client->pending_add, pending);
1177 886
1178 if (!_dbus_callback_check_and_init(msg, &iter, error)) 887 //in case of error or when user cancel
1179 goto end; 888 if (edbus_message_error_get(msg, &errname, &errmsg))
1180 889 {
1181 t = dbus_message_iter_get_arg_type(&iter); 890 ERR("Error: %s %s\n", errname, errmsg);
1182 if (!_dbus_iter_type_check(t, DBUS_TYPE_INT32)) 891 goto end;
1183 goto end; 892 }
1184 893
1185 dbus_message_iter_get_basic(&iter, &id); 894 if (!edbus_message_arguments_get(msg, "i", &id))
895 {
896 ERR("Error getting arguments.");
897 goto end;
898 }
1186 899
1187 generating = calloc(1, sizeof(*generating)); 900 generating = calloc(1, sizeof(*generating));
1188 generating->id = id; 901 generating->id = id;
@@ -1195,15 +908,24 @@ _ethumb_client_queue_add_cb(void *data, DBusMessage *msg, DBusError *error)
1195 generating->free_data = pending->free_data; 908 generating->free_data = pending->free_data;
1196 client->pending_gen = eina_list_append(client->pending_gen, generating); 909 client->pending_gen = eina_list_append(client->pending_gen, generating);
1197 910
911 free(pending);
912 return;
913
1198end: 914end:
915 eina_stringshare_del(pending->file);
916 eina_stringshare_del(pending->key);
917 eina_stringshare_del(pending->thumb);
918 eina_stringshare_del(pending->thumb_key);
919 if (pending->free_data)
920 pending->free_data(pending->data);
1199 free(pending); 921 free(pending);
1200} 922}
1201 923
1202static int 924static int
1203_ethumb_client_queue_add(Ethumb_Client *client, const char *file, const char *key, const char *thumb, const char *thumb_key, Ethumb_Client_Generate_Cb generated_cb, const void *data, Eina_Free_Cb free_data) 925_ethumb_client_queue_add(Ethumb_Client *client, const char *file, const char *key, const char *thumb, const char *thumb_key, Ethumb_Client_Generate_Cb generated_cb, const void *data, Eina_Free_Cb free_data)
1204{ 926{
1205 DBusMessage *msg; 927 EDBus_Message *msg;
1206 DBusMessageIter iter; 928 EDBus_Message_Iter *main;
1207 struct _ethumb_pending_add *pending; 929 struct _ethumb_pending_add *pending;
1208 930
1209 pending = calloc(1, sizeof(*pending)); 931 pending = calloc(1, sizeof(*pending));
@@ -1219,46 +941,44 @@ _ethumb_client_queue_add(Ethumb_Client *client, const char *file, const char *ke
1219 941
1220 client->id_count = (client->id_count + 1) % MAX_ID; 942 client->id_count = (client->id_count + 1) % MAX_ID;
1221 943
1222 msg = dbus_message_new_method_call(_ethumb_dbus_bus_name, 944 msg = edbus_proxy_method_call_new(client->proxy, "queue_add");
1223 client->object_path, 945 main = edbus_message_iter_get(msg);
1224 _ethumb_dbus_objects_interface, 946 edbus_message_iter_basic_append(main, 'i', pending->id);
1225 "queue_add"); 947 _ethumb_client_dbus_append_bytearray(main, file);
1226 948 _ethumb_client_dbus_append_bytearray(main, key);
1227 dbus_message_iter_init_append(msg, &iter); 949 _ethumb_client_dbus_append_bytearray(main, thumb);
1228 dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &pending->id); 950 _ethumb_client_dbus_append_bytearray(main, thumb_key);
1229 _ethumb_client_dbus_append_bytearray(&iter, file); 951
1230 _ethumb_client_dbus_append_bytearray(&iter, key); 952 pending->pending_call = edbus_proxy_send(client->proxy, msg,
1231 _ethumb_client_dbus_append_bytearray(&iter, thumb); 953 _ethumb_client_queue_add_cb,
1232 _ethumb_client_dbus_append_bytearray(&iter, thumb_key); 954 pending, -1);
1233
1234 pending->pending_call = e_dbus_message_send(client->conn, msg,
1235 _ethumb_client_queue_add_cb,
1236 -1, pending);
1237 client->pending_add = eina_list_append(client->pending_add, pending); 955 client->pending_add = eina_list_append(client->pending_add, pending);
1238 dbus_message_unref(msg); 956 edbus_message_unref(msg);
1239 957
1240 return pending->id; 958 return pending->id;
1241} 959}
1242 960
1243static void 961static void
1244_ethumb_client_queue_remove_cb(void *data, DBusMessage *msg, DBusError *error) 962_ethumb_client_queue_remove_cb(void *data, const EDBus_Message *msg, EDBus_Pending *edbus_pending)
1245{ 963{
1246 DBusMessageIter iter; 964 Eina_Bool success;
1247 int t;
1248 dbus_bool_t success = 0;
1249 struct _ethumb_pending_remove *pending = data; 965 struct _ethumb_pending_remove *pending = data;
1250 Ethumb_Client *client = pending->client; 966 Ethumb_Client *client = pending->client;
967 const char *errname, *errmsg;
1251 968
1252 client->pending_remove = eina_list_remove(client->pending_remove, pending); 969 client->pending_remove = eina_list_remove(client->pending_remove, pending);
1253 970
1254 if (!_dbus_callback_check_and_init(msg, &iter, error)) 971 if (edbus_message_error_get(msg, &errname, &errmsg))
1255 goto end; 972 {
1256 973 ERR("Error: %s %s\n", errname, errmsg);
1257 t = dbus_message_iter_get_arg_type(&iter); 974 goto end;
1258 if (!_dbus_iter_type_check(t, DBUS_TYPE_BOOLEAN)) 975 }
1259 goto end;
1260 976
1261 dbus_message_iter_get_basic(&iter, &success); 977 if (edbus_message_arguments_get(msg, "b", &success))
978 {
979 ERR("Error getting arguments.");
980 goto end;
981 }
1262 982
1263end: 983end:
1264 if (pending->cancel_cb) 984 if (pending->cancel_cb)
@@ -1290,11 +1010,10 @@ end:
1290EAPI void 1010EAPI void
1291ethumb_client_generate_cancel(Ethumb_Client *client, int id, Ethumb_Client_Generate_Cancel_Cb cancel_cb, const void *data, Eina_Free_Cb free_data) 1011ethumb_client_generate_cancel(Ethumb_Client *client, int id, Ethumb_Client_Generate_Cancel_Cb cancel_cb, const void *data, Eina_Free_Cb free_data)
1292{ 1012{
1293 DBusMessage *msg;
1294 struct _ethumb_pending_remove *pending; 1013 struct _ethumb_pending_remove *pending;
1295 Eina_List *l; 1014 Eina_List *l;
1296 int found; 1015 int found;
1297 dbus_int32_t id32 = id; 1016 int32_t id32 = id;
1298 EINA_SAFETY_ON_NULL_RETURN(client); 1017 EINA_SAFETY_ON_NULL_RETURN(client);
1299 EINA_SAFETY_ON_FALSE_RETURN(id >= 0); 1018 EINA_SAFETY_ON_FALSE_RETURN(id >= 0);
1300 1019
@@ -1305,17 +1024,15 @@ ethumb_client_generate_cancel(Ethumb_Client *client, int id, Ethumb_Client_Gener
1305 pending->free_data = free_data; 1024 pending->free_data = free_data;
1306 pending->client = client; 1025 pending->client = client;
1307 1026
1308 msg = dbus_message_new_method_call(_ethumb_dbus_bus_name, 1027 edbus_proxy_call(client->proxy, "queue_remove",
1309 client->object_path, 1028 _ethumb_client_queue_remove_cb, pending, -1, "i", pending->id);
1310 _ethumb_dbus_objects_interface,
1311 "queue_remove");
1312
1313 dbus_message_append_args(msg, DBUS_TYPE_INT32, &id32, DBUS_TYPE_INVALID);
1314 pending->pending_call = e_dbus_message_send(client->conn, msg,
1315 _ethumb_client_queue_remove_cb,
1316 -1, pending);
1317 client->pending_remove = eina_list_append(client->pending_remove, pending); 1029 client->pending_remove = eina_list_append(client->pending_remove, pending);
1318 1030
1031 /*
1032 * Check if answer was not received yet cancel it
1033 * callback of queue_add will be called with a error msg
1034 * and data will be freed
1035 */
1319 found = 0; 1036 found = 0;
1320 l = client->pending_add; 1037 l = client->pending_add;
1321 while (l) 1038 while (l)
@@ -1326,23 +1043,15 @@ ethumb_client_generate_cancel(Ethumb_Client *client, int id, Ethumb_Client_Gener
1326 l = l->next; 1043 l = l->next;
1327 continue; 1044 continue;
1328 } 1045 }
1329 client->pending_add = eina_list_remove_list(client->pending_add, l); 1046 edbus_pending_cancel(pending_add->pending_call);
1330 eina_stringshare_del(pending_add->file);
1331 eina_stringshare_del(pending_add->key);
1332 eina_stringshare_del(pending_add->thumb);
1333 eina_stringshare_del(pending_add->thumb_key);
1334 dbus_pending_call_cancel(pending_add->pending_call);
1335 dbus_pending_call_unref(pending_add->pending_call);
1336 if (pending_add->free_data)
1337 pending_add->free_data(pending_add->data);
1338 free(pending_add);
1339 found = 1; 1047 found = 1;
1340 break; 1048 break;
1341 } 1049 }
1342 1050
1343 if (found) 1051 if (found)
1344 goto end; 1052 return;
1345 1053
1054 //if already received answer only free memory
1346 l = client->pending_gen; 1055 l = client->pending_gen;
1347 while (l) 1056 while (l)
1348 { 1057 {
@@ -1362,20 +1071,6 @@ ethumb_client_generate_cancel(Ethumb_Client *client, int id, Ethumb_Client_Gener
1362 free(pending_gen); 1071 free(pending_gen);
1363 break; 1072 break;
1364 } 1073 }
1365
1366end:
1367 dbus_message_unref(msg);
1368}
1369
1370/**
1371 * @cond LOCAL
1372 */
1373static void
1374_ethumb_client_queue_clear_cb(void *data, DBusMessage *msg __UNUSED__, DBusError *error __UNUSED__)
1375{
1376 Ethumb_Client *client = data;
1377
1378 client->pending_clear = NULL;
1379} 1074}
1380 1075
1381/** 1076/**
@@ -1393,25 +1088,13 @@ _ethumb_client_queue_clear_cb(void *data, DBusMessage *msg __UNUSED__, DBusError
1393EAPI void 1088EAPI void
1394ethumb_client_generate_cancel_all(Ethumb_Client *client) 1089ethumb_client_generate_cancel_all(Ethumb_Client *client)
1395{ 1090{
1396 DBusMessage *msg;
1397 void *data; 1091 void *data;
1398 EINA_SAFETY_ON_NULL_RETURN(client); 1092 EINA_SAFETY_ON_NULL_RETURN(client);
1399 1093
1400 if (client->pending_clear)
1401 return;
1402
1403 EINA_LIST_FREE(client->pending_add, data) 1094 EINA_LIST_FREE(client->pending_add, data)
1404 { 1095 {
1405 struct _ethumb_pending_add *pending = data; 1096 struct _ethumb_pending_add *pending = data;
1406 eina_stringshare_del(pending->file); 1097 edbus_pending_cancel(pending->pending_call);
1407 eina_stringshare_del(pending->key);
1408 eina_stringshare_del(pending->thumb);
1409 eina_stringshare_del(pending->thumb_key);
1410 dbus_pending_call_cancel(pending->pending_call);
1411 dbus_pending_call_unref(pending->pending_call);
1412 if (pending->free_data)
1413 pending->free_data(pending->data);
1414 free(pending);
1415 } 1098 }
1416 1099
1417 EINA_LIST_FREE(client->pending_gen, data) 1100 EINA_LIST_FREE(client->pending_gen, data)
@@ -1426,16 +1109,7 @@ ethumb_client_generate_cancel_all(Ethumb_Client *client)
1426 free(pending); 1109 free(pending);
1427 } 1110 }
1428 1111
1429 msg = dbus_message_new_method_call(_ethumb_dbus_bus_name, 1112 edbus_proxy_call(client->proxy, "queue_clear", NULL, NULL, -1, "");
1430 client->object_path,
1431 _ethumb_dbus_objects_interface,
1432 "queue_clear");
1433
1434 client->pending_clear = e_dbus_message_send(client->conn, msg,
1435 _ethumb_client_queue_clear_cb,
1436 -1, client);
1437
1438 dbus_message_unref(msg);
1439} 1113}
1440 1114
1441/** 1115/**
@@ -2345,7 +2019,6 @@ ethumb_client_generate(Ethumb_Client *client, Ethumb_Client_Generate_Cb generate
2345 } 2019 }
2346 id = _ethumb_client_queue_add(client, file, key, thumb, thumb_key, 2020 id = _ethumb_client_queue_add(client, file, key, thumb, thumb_key,
2347 generated_cb, data, free_data); 2021 generated_cb, data, free_data);
2348
2349 return id; 2022 return id;
2350} 2023}
2351 2024
@@ -2573,4 +2246,3 @@ ethumb_client_thumb_async_cancel(Ethumb_Client *client, Ethumb_Client_Async *req
2573 2246
2574 _ethumb_client_async_free(request); 2247 _ethumb_client_async_free(request);
2575} 2248}
2576