summaryrefslogtreecommitdiff
path: root/legacy/ethumb/src/bin/ethumbd.c
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/ethumb/src/bin/ethumbd.c
parent68a34bdd34467f0859345ca472bc935d7318cb96 (diff)
ethumb: Port to edbus v2
Patch by: José Roberto de Souza <zehortigoza@profusion.mobi> SVN revision: 80103
Diffstat (limited to '')
-rw-r--r--legacy/ethumb/src/bin/ethumbd.c652
1 files changed, 252 insertions, 400 deletions
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);