summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuilherme Lepsch <lepsch@expertisesolutions.com.br>2015-02-05 15:20:36 +0100
committerCedric BAIL <cedric@osg.samsung.com>2015-02-09 22:03:19 +0100
commitef6456c54193be09536cfb368e57a6e1d53c6911 (patch)
tree5fd4836d1cd9253924006b7811247f4d74f6ce0c
parent2d403151270d074cb10367232ef7109d65e6be00 (diff)
eldbus: refactoring code.
Summary: Code smells: Don't Repeat Yourself Depends on D1927 Reviewers: felipealmeida, larryolj, cedric Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D1928 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
-rw-r--r--src/lib/eldbus/eldbus_proxy.c53
1 files changed, 24 insertions, 29 deletions
diff --git a/src/lib/eldbus/eldbus_proxy.c b/src/lib/eldbus/eldbus_proxy.c
index f43265a4da..e543bb6bfb 100644
--- a/src/lib/eldbus/eldbus_proxy.c
+++ b/src/lib/eldbus/eldbus_proxy.c
@@ -305,34 +305,43 @@ eldbus_proxy_data_del(Eldbus_Proxy *proxy, const char *key)
305 return eldbus_data_del(&(((Eldbus_Proxy *)proxy)->data), key); 305 return eldbus_data_del(&(((Eldbus_Proxy *)proxy)->data), key);
306} 306}
307 307
308static void 308static Eina_Value *
309_property_changed_iter(void *data, const void *key, Eldbus_Message_Iter *var) 309_iter_hash_value_set(Eina_Hash *props, const char *key, Eldbus_Message_Iter *var) EINA_ARG_NONNULL(1, 2, 3)
310{ 310{
311 Eldbus_Proxy *proxy = data; 311 Eina_Value *st_value = _message_iter_struct_to_eina_value(var);
312 const char *skey = key; 312 Eina_Value *value;
313 Eina_Value *st_value, stack_value, *value; 313 Eina_Value stack_value;
314 Eldbus_Proxy_Event_Property_Changed event;
315 314
316 st_value = _message_iter_struct_to_eina_value(var);
317 eina_value_struct_value_get(st_value, "arg0", &stack_value); 315 eina_value_struct_value_get(st_value, "arg0", &stack_value);
318 316
319 value = eina_hash_find(proxy->props, skey); 317 value = eina_hash_find(props, key);
320 if (!value) 318 if (!value)
321 { 319 {
322 value = eina_value_new(eina_value_type_get(&stack_value)); 320 value = eina_value_new(eina_value_type_get(&stack_value));
323 eina_hash_add(proxy->props, skey, value); 321 eina_hash_add(props, key, value);
324 } 322 }
325 323
326 eina_value_flush(value); 324 eina_value_flush(value);
327 eina_value_copy(&stack_value, value); 325 eina_value_copy(&stack_value, value);
328 326
329 event.name = skey; 327 eina_value_flush(&stack_value);
330 event.value = value; 328 eina_value_free(st_value);
331 event.proxy = proxy; 329 return value;
330}
331
332static void
333_property_changed_iter(void *data, const void *key, Eldbus_Message_Iter *var)
334{
335 Eldbus_Proxy *proxy = data;
336 const char *skey = key;
337
338 Eina_Value *value = _iter_hash_value_set(proxy->props, skey, var);
339
340 Eldbus_Proxy_Event_Property_Changed event = {.name = skey,
341 .value = value,
342 .proxy = proxy};
332 _eldbus_proxy_event_callback_call(proxy, ELDBUS_PROXY_EVENT_PROPERTY_CHANGED, 343 _eldbus_proxy_event_callback_call(proxy, ELDBUS_PROXY_EVENT_PROPERTY_CHANGED,
333 &event); 344 &event);
334 eina_value_free(st_value);
335 eina_value_flush(&stack_value);
336} 345}
337 346
338static void 347static void
@@ -743,22 +752,8 @@ _property_iter(void *data, const void *key, Eldbus_Message_Iter *var)
743{ 752{
744 Eldbus_Proxy *proxy = data; 753 Eldbus_Proxy *proxy = data;
745 const char *skey = key; 754 const char *skey = key;
746 Eina_Value *st_value, stack_value, *value;
747
748 st_value = _message_iter_struct_to_eina_value(var);
749 eina_value_struct_value_get(st_value, "arg0", &stack_value);
750
751 value = eina_hash_find(proxy->props, skey);
752 if (!value)
753 {
754 value = eina_value_new(eina_value_type_get(&stack_value));
755 eina_hash_add(proxy->props, skey, value);
756 }
757 eina_value_flush(value);
758 eina_value_copy(&stack_value, value);
759 755
760 eina_value_free(st_value); 756 _iter_hash_value_set(proxy->props, skey, var);
761 eina_value_flush(&stack_value);
762} 757}
763 758
764static void 759static void