summaryrefslogtreecommitdiff
path: root/src/examples/eldbus/complex-types-client-eina-value.c
diff options
context:
space:
mode:
authorLucas De Marchi <lucas.demarchi@profusion.mobi>2013-04-23 11:40:05 -0300
committerLucas De Marchi <lucas.demarchi@profusion.mobi>2013-04-23 12:36:29 -0300
commit4e3804041f8e865e007b2a6a0d45a05f39500c3b (patch)
treea493b9c8f8a610d2667651f3ba81819ed16fbe8c /src/examples/eldbus/complex-types-client-eina-value.c
parent4cf68bf728b5a858ce1c0efac25ded1a49ba8d9d (diff)
Rename edbus->eldbus
git grep -l edbus2 | while read f; do sed -i 's/edbus2/eldbus/g' "$f"; done find . -name '*edbus2*' -exec rename edbus2 eldbus {} \; git grep -l "EDBUS" | while read f; do sed -i 's/EDBUS/ELDBUS/g' "$f"; done git grep -l "EDBus" | while read f; do sed -i 's/EDBus/Eldbus/g' "$f"; done git grep -l "edbus (v2)" | while read f; do sed -i 's/edbus (v2)/eldbus/g' "$f"; done git grep -l "Edbus" | while read f; do sed -i 's/Edbus/Eldbus/g' "$f"; done git grep -l "edbus" | while read f; do sed -i 's/edbus/eldbus/g' "$f"; done find . -name '*edbus*' -exec rename edbus eldbus {} \; find . -name '*EDBus*' -exec rename EDBus Eldbus {} \;
Diffstat (limited to '')
-rw-r--r--src/examples/eldbus/complex-types-client-eina-value.c (renamed from src/examples/edbus/complex-types-client-eina-value.c)92
1 files changed, 46 insertions, 46 deletions
diff --git a/src/examples/edbus/complex-types-client-eina-value.c b/src/examples/eldbus/complex-types-client-eina-value.c
index 91b3ecca46..3d290ae194 100644
--- a/src/examples/edbus/complex-types-client-eina-value.c
+++ b/src/examples/eldbus/complex-types-client-eina-value.c
@@ -1,7 +1,7 @@
1//Compile with: 1//Compile with:
2// gcc -o complex-types-client-eina-value complex-types-client-eina-value.c `pkg-config --cflags --libs edbus2 ecore eina` 2// gcc -o complex-types-client-eina-value complex-types-client-eina-value.c `pkg-config --cflags --libs eldbus ecore eina`
3 3
4#include "EDBus.h" 4#include "Eldbus.h"
5#include <Ecore.h> 5#include <Ecore.h>
6 6
7#define BUS "com.profusion" 7#define BUS "com.profusion"
@@ -36,7 +36,7 @@ _type_offset(unsigned base, unsigned size)
36} 36}
37 37
38static void 38static void
39_fill_receive_array_of_string_int_with_size(EDBus_Message *msg, int size, const char *array[]) 39_fill_receive_array_of_string_int_with_size(Eldbus_Message *msg, int size, const char *array[])
40{ 40{
41 Eina_Value *value_struct, *value_array; 41 Eina_Value *value_struct, *value_array;
42 int i; 42 int i;
@@ -86,27 +86,27 @@ _fill_receive_array_of_string_int_with_size(EDBus_Message *msg, int size, const
86 } 86 }
87 eina_value_struct_value_set(value_struct, "array", value_array); 87 eina_value_struct_value_set(value_struct, "array", value_array);
88 88
89 edbus_message_from_eina_value("ia(si)", msg, value_struct); 89 eldbus_message_from_eina_value("ia(si)", msg, value_struct);
90 90
91 eina_value_free(value_struct); 91 eina_value_free(value_struct);
92 eina_value_free(value_array); 92 eina_value_free(value_array);
93} 93}
94 94
95static void 95static void
96on_send_array(void *data EINA_UNUSED, const EDBus_Message *msg, EDBus_Pending *pending EINA_UNUSED) 96on_send_array(void *data EINA_UNUSED, const Eldbus_Message *msg, Eldbus_Pending *pending EINA_UNUSED)
97{ 97{
98 Eina_Value *v, array; 98 Eina_Value *v, array;
99 const char *txt; 99 const char *txt;
100 unsigned i; 100 unsigned i;
101 printf("2 - on_send_array()\n"); 101 printf("2 - on_send_array()\n");
102 102
103 if (edbus_message_error_get(msg, NULL, NULL)) 103 if (eldbus_message_error_get(msg, NULL, NULL))
104 { 104 {
105 printf("Message error\n\n"); 105 printf("Message error\n\n");
106 return; 106 return;
107 } 107 }
108 108
109 v = edbus_message_to_eina_value(msg); 109 v = eldbus_message_to_eina_value(msg);
110 eina_value_struct_value_get(v, "arg0", &array); 110 eina_value_struct_value_get(v, "arg0", &array);
111 for (i = 0; i < eina_value_array_count(&array); i++) 111 for (i = 0; i < eina_value_array_count(&array); i++)
112 { 112 {
@@ -119,31 +119,31 @@ on_send_array(void *data EINA_UNUSED, const EDBus_Message *msg, EDBus_Pending *p
119} 119}
120 120
121static void 121static void
122on_receive_array_with_size(void *data EINA_UNUSED, const EDBus_Message *msg, EDBus_Pending *pending EINA_UNUSED) 122on_receive_array_with_size(void *data EINA_UNUSED, const Eldbus_Message *msg, Eldbus_Pending *pending EINA_UNUSED)
123{ 123{
124 const char *errname; 124 const char *errname;
125 const char *errmsg; 125 const char *errmsg;
126 126
127 printf("1 - on_receive_array_with_size()\n"); 127 printf("1 - on_receive_array_with_size()\n");
128 if (edbus_message_error_get(msg, &errname, &errmsg)) 128 if (eldbus_message_error_get(msg, &errname, &errmsg))
129 { 129 {
130 fprintf(stderr, "Error: %s %s\n", errname, errmsg); 130 fprintf(stderr, "Error: %s %s\n", errname, errmsg);
131 } 131 }
132} 132}
133 133
134static void 134static void
135on_plus_one(void *data EINA_UNUSED, const EDBus_Message *msg, EDBus_Pending *pending EINA_UNUSED) 135on_plus_one(void *data EINA_UNUSED, const Eldbus_Message *msg, Eldbus_Pending *pending EINA_UNUSED)
136{ 136{
137 Eina_Value *v; 137 Eina_Value *v;
138 int num2; 138 int num2;
139 139
140 if (edbus_message_error_get(msg, NULL, NULL)) 140 if (eldbus_message_error_get(msg, NULL, NULL))
141 { 141 {
142 printf("Message error\n\n"); 142 printf("Message error\n\n");
143 return; 143 return;
144 } 144 }
145 145
146 v = edbus_message_to_eina_value(msg); 146 v = eldbus_message_to_eina_value(msg);
147 eina_value_struct_get(v, "arg0", &num2); 147 eina_value_struct_get(v, "arg0", &num2);
148 148
149 printf("3 - on_plus_one() %d\n", num2); 149 printf("3 - on_plus_one() %d\n", num2);
@@ -151,19 +151,19 @@ on_plus_one(void *data EINA_UNUSED, const EDBus_Message *msg, EDBus_Pending *pen
151} 151}
152 152
153static void 153static void
154receive_variant_cb(void *data EINA_UNUSED, const EDBus_Message *msg, EDBus_Pending *pending EINA_UNUSED) 154receive_variant_cb(void *data EINA_UNUSED, const Eldbus_Message *msg, Eldbus_Pending *pending EINA_UNUSED)
155{ 155{
156 Eina_Value *v, variant, array; 156 Eina_Value *v, variant, array;
157 unsigned i; 157 unsigned i;
158 158
159 printf("4 - receive a variant with an array of strings\n"); 159 printf("4 - receive a variant with an array of strings\n");
160 if (edbus_message_error_get(msg, NULL, NULL)) 160 if (eldbus_message_error_get(msg, NULL, NULL))
161 { 161 {
162 printf("Message error\n\n"); 162 printf("Message error\n\n");
163 return; 163 return;
164 } 164 }
165 165
166 v = edbus_message_to_eina_value(msg); 166 v = eldbus_message_to_eina_value(msg);
167 167
168 eina_value_struct_value_get(v, "arg0", &variant); 168 eina_value_struct_value_get(v, "arg0", &variant);
169 eina_value_struct_value_get(&variant, "arg0", &array); 169 eina_value_struct_value_get(&variant, "arg0", &array);
@@ -180,17 +180,17 @@ receive_variant_cb(void *data EINA_UNUSED, const EDBus_Message *msg, EDBus_Pendi
180} 180}
181 181
182static void 182static void
183_property_removed(void *data EINA_UNUSED, EDBus_Proxy *proxy EINA_UNUSED, void *event_info) 183_property_removed(void *data EINA_UNUSED, Eldbus_Proxy *proxy EINA_UNUSED, void *event_info)
184{ 184{
185 EDBus_Proxy_Event_Property_Removed *event = event_info; 185 Eldbus_Proxy_Event_Property_Removed *event = event_info;
186 186
187 printf("\nproperty removed: %s", event->name); 187 printf("\nproperty removed: %s", event->name);
188} 188}
189 189
190static void 190static void
191_property_changed(void *data EINA_UNUSED, EDBus_Proxy *proxy EINA_UNUSED, void *event_info) 191_property_changed(void *data EINA_UNUSED, Eldbus_Proxy *proxy EINA_UNUSED, void *event_info)
192{ 192{
193 EDBus_Proxy_Event_Property_Changed *event = event_info; 193 Eldbus_Proxy_Event_Property_Changed *event = event_info;
194 const char *name; 194 const char *name;
195 const Eina_Value *value; 195 const Eina_Value *value;
196 printf("\nproperty changed\n"); 196 printf("\nproperty changed\n");
@@ -223,26 +223,26 @@ _property_changed(void *data EINA_UNUSED, EDBus_Proxy *proxy EINA_UNUSED, void *
223static Eina_Bool 223static Eina_Bool
224_read_cache(void *data) 224_read_cache(void *data)
225{ 225{
226 EDBus_Proxy *proxy = data; 226 Eldbus_Proxy *proxy = data;
227 const char *txt; 227 const char *txt;
228 int num; 228 int num;
229 Eina_Value *v; 229 Eina_Value *v;
230 230
231 v = edbus_proxy_property_local_get(proxy, "text"); 231 v = eldbus_proxy_property_local_get(proxy, "text");
232 if (v) 232 if (v)
233 { 233 {
234 eina_value_get(v, &txt); 234 eina_value_get(v, &txt);
235 printf("Read cache: [txt] = %s\n", txt); 235 printf("Read cache: [txt] = %s\n", txt);
236 } 236 }
237 237
238 v = edbus_proxy_property_local_get(proxy, "int32"); 238 v = eldbus_proxy_property_local_get(proxy, "int32");
239 if (v) 239 if (v)
240 { 240 {
241 eina_value_get(v, &num); 241 eina_value_get(v, &num);
242 printf("Read cache: [int32] = %d\n", num); 242 printf("Read cache: [int32] = %d\n", num);
243 } 243 }
244 244
245 v = edbus_proxy_property_local_get(proxy, "st"); 245 v = eldbus_proxy_property_local_get(proxy, "st");
246 if (v) 246 if (v)
247 { 247 {
248 eina_value_struct_get(v, "arg0", &txt); 248 eina_value_struct_get(v, "arg0", &txt);
@@ -255,7 +255,7 @@ _read_cache(void *data)
255} 255}
256 256
257static void 257static void
258_fill_plus_one(EDBus_Message *msg, int num) 258_fill_plus_one(Eldbus_Message *msg, int num)
259{ 259{
260 Eina_Value *v; 260 Eina_Value *v;
261 Eina_Value_Struct_Member main_members[] = { 261 Eina_Value_Struct_Member main_members[] = {
@@ -271,7 +271,7 @@ _fill_plus_one(EDBus_Message *msg, int num)
271 v = eina_value_struct_new(&desc_struct); 271 v = eina_value_struct_new(&desc_struct);
272 eina_value_struct_set(v, "num", num); 272 eina_value_struct_set(v, "num", num);
273 273
274 edbus_message_from_eina_value("i", msg, v); 274 eldbus_message_from_eina_value("i", msg, v);
275 275
276 eina_value_free(v); 276 eina_value_free(v);
277} 277}
@@ -279,46 +279,46 @@ _fill_plus_one(EDBus_Message *msg, int num)
279int 279int
280main(void) 280main(void)
281{ 281{
282 EDBus_Connection *conn; 282 Eldbus_Connection *conn;
283 EDBus_Object *obj; 283 Eldbus_Object *obj;
284 EDBus_Proxy *proxy; 284 Eldbus_Proxy *proxy;
285 EDBus_Message *msg; 285 Eldbus_Message *msg;
286 286
287 ecore_init(); 287 ecore_init();
288 edbus_init(); 288 eldbus_init();
289 289
290 conn = edbus_connection_get(EDBUS_CONNECTION_TYPE_SESSION); 290 conn = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SESSION);
291 obj = edbus_object_get(conn, BUS, PATH); 291 obj = eldbus_object_get(conn, BUS, PATH);
292 proxy = edbus_proxy_get(obj, IFACE); 292 proxy = eldbus_proxy_get(obj, IFACE);
293 293
294 msg = edbus_proxy_method_call_new(proxy, "ReceiveArrayOfStringIntWithSize"); 294 msg = eldbus_proxy_method_call_new(proxy, "ReceiveArrayOfStringIntWithSize");
295 _fill_receive_array_of_string_int_with_size(msg, size_of_array, array_string); 295 _fill_receive_array_of_string_int_with_size(msg, size_of_array, array_string);
296 edbus_proxy_send(proxy, msg, on_receive_array_with_size, NULL, -1); 296 eldbus_proxy_send(proxy, msg, on_receive_array_with_size, NULL, -1);
297 297
298 edbus_proxy_call(proxy, "SendArray", on_send_array, NULL, -1 , ""); 298 eldbus_proxy_call(proxy, "SendArray", on_send_array, NULL, -1 , "");
299 299
300 msg = edbus_proxy_method_call_new(proxy, "PlusOne"); 300 msg = eldbus_proxy_method_call_new(proxy, "PlusOne");
301 _fill_plus_one(msg, 14); 301 _fill_plus_one(msg, 14);
302 edbus_proxy_send(proxy, msg, on_plus_one, NULL, -1); 302 eldbus_proxy_send(proxy, msg, on_plus_one, NULL, -1);
303 303
304 edbus_proxy_event_callback_add(proxy, 304 eldbus_proxy_event_callback_add(proxy,
305 EDBUS_PROXY_EVENT_PROPERTY_CHANGED, 305 ELDBUS_PROXY_EVENT_PROPERTY_CHANGED,
306 _property_changed, NULL); 306 _property_changed, NULL);
307 edbus_proxy_event_callback_add(proxy, EDBUS_PROXY_EVENT_PROPERTY_REMOVED, 307 eldbus_proxy_event_callback_add(proxy, ELDBUS_PROXY_EVENT_PROPERTY_REMOVED,
308 _property_removed, NULL); 308 _property_removed, NULL);
309 309
310 edbus_proxy_properties_monitor(proxy, EINA_TRUE); 310 eldbus_proxy_properties_monitor(proxy, EINA_TRUE);
311 ecore_timer_add(10, _read_cache, proxy); 311 ecore_timer_add(10, _read_cache, proxy);
312 312
313 edbus_proxy_call(proxy, "ReceiveVariantData", receive_variant_cb, NULL, -1, ""); 313 eldbus_proxy_call(proxy, "ReceiveVariantData", receive_variant_cb, NULL, -1, "");
314 314
315 ecore_main_loop_begin(); 315 ecore_main_loop_begin();
316 316
317 edbus_proxy_event_callback_del(proxy, EDBUS_PROXY_EVENT_PROPERTY_CHANGED, 317 eldbus_proxy_event_callback_del(proxy, ELDBUS_PROXY_EVENT_PROPERTY_CHANGED,
318 _property_changed, NULL); 318 _property_changed, NULL);
319 edbus_connection_unref(conn); 319 eldbus_connection_unref(conn);
320 320
321 edbus_shutdown(); 321 eldbus_shutdown();
322 ecore_shutdown(); 322 ecore_shutdown();
323 return 0; 323 return 0;
324} 324}