summaryrefslogtreecommitdiff
path: root/unsorted
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2018-04-30 10:33:38 -0700
committerCedric BAIL <cedric@osg.samsung.com>2018-05-01 10:39:01 -0700
commit5e8827afb23542b429da3803a852a86094e17d70 (patch)
tree4ee0079cda3554905c3cc3dbfa9be56a3776805f /unsorted
parent7092eb69d0bd501b99720e4fefc3a5306c0c4097 (diff)
ecore_con: update efl_net_ip_address_example after migration to new Eina_Future.
Diffstat (limited to 'unsorted')
-rw-r--r--unsorted/ecore/efl_net_ip_address_example.c74
1 files changed, 37 insertions, 37 deletions
diff --git a/unsorted/ecore/efl_net_ip_address_example.c b/unsorted/ecore/efl_net_ip_address_example.c
index 2392b23c..2989efbc 100644
--- a/unsorted/ecore/efl_net_ip_address_example.c
+++ b/unsorted/ecore/efl_net_ip_address_example.c
@@ -65,40 +65,48 @@ _print_ip_addr_info(const Eo *o)
65 printf("INFO: - any: %d\n", efl_net_ip_address_any_check(o)); 65 printf("INFO: - any: %d\n", efl_net_ip_address_any_check(o));
66} 66}
67 67
68static void 68static Eina_Value
69_resolved(void *data EINA_UNUSED, const Efl_Event *event) 69_resolved(void *data, const Eina_Value v,
70 const Eina_Future *dead_future)
70{ 71{
71 Efl_Future *future = event->object; 72 const char *address = data;
72 Efl_Future_Event_Success *f = event->info; 73 const char *canonical_name = NULL;
73 Efl_Net_Ip_Address_Resolve_Results *r = f->value; 74 const char *request_address = NULL;
74 Eina_Array_Iterator it; 75 const Eina_Value_Array desc = { 0 };
75 unsigned int i; 76 const Efl_Net_Ip_Address **o = NULL;
76 const Efl_Net_Ip_Address *o; 77
78 if (eina_value_type_get(&v) == EINA_VALUE_TYPE_ERROR)
79 {
80 Eina_Error err = 0;
81
82 eina_value_error_get(&v, &err);
83
84 fprintf(stderr, "ERROR: Failed to resolve '%s': %s\n",
85 address, eina_error_msg_get(err));
86 retval = EXIT_FAILURE;
87 goto end;
88 }
89
90 eina_value_struct_get(&v, "canonical_name", canonical_name);
91 eina_value_struct_get(&v, "request_address", request_address);
92 eina_value_struct_get(&v, "results", &desc);
77 93
78 printf("INFO: resolved '%s' to canonical name '%s':\n", 94 printf("INFO: resolved '%s' to canonical name '%s':\n",
79 r->request_address, r->canonical_name); 95 request_address, canonical_name);
80 96
81 EINA_ARRAY_ITER_NEXT(r->results, i, o, it) 97 EINA_INARRAY_FOREACH(desc.array, o)
82 _print_ip_addr_info(o); 98 if (o) _print_ip_addr_info(*o);
83 99
84 putchar('\n'); 100 putchar('\n');
85 101
86 resolving = eina_list_remove(resolving, future); 102 eina_stringshare_del(canonical_name);
87 if (!resolving) ecore_main_loop_quit(); 103 eina_stringshare_del(request_address);
88}
89 104
90static void 105 end:
91_resolve_failed(void *data, const Efl_Event *event) 106 resolving = eina_list_remove(resolving, dead_future);
92{
93 const char *address = data;
94 Efl_Future *future = event->object;
95 Efl_Future_Event_Failure *f = event->info;
96 fprintf(stderr, "ERROR: Failed to resolve '%s': %s\n",
97 address, eina_error_msg_get(f->error));
98 retval = EXIT_FAILURE;
99
100 resolving = eina_list_remove(resolving, future);
101 if (!resolving) ecore_main_loop_quit(); 107 if (!resolving) ecore_main_loop_quit();
108
109 return v;
102} 110}
103 111
104int 112int
@@ -120,18 +128,10 @@ main(int argc, char *argv[])
120 } 128 }
121 else 129 else
122 { 130 {
123 Efl_Future *f = efl_net_ip_address_resolve(EFL_NET_IP_ADDRESS_CLASS, address, 0, 0); 131 Eina_Future *f = efl_net_ip_address_resolve(EFL_NET_IP_ADDRESS_CLASS, address, 0, 0);
124 if (!f) 132 eina_future_then(f, _resolved, address);
125 { 133 printf("INFO: %s is not numeric, resolving...\n", address);
126 fprintf(stderr, "ERROR: cannot resolve '%s'!\n", address); 134 resolving = eina_list_append(resolving, f);
127 retval = EXIT_FAILURE;
128 }
129 else
130 {
131 printf("INFO: %s is not numeric, resolving...\n", address);
132 efl_future_then(f, _resolved, _resolve_failed, NULL, address);
133 resolving = eina_list_append(resolving, f);
134 }
135 } 135 }
136 } 136 }
137 137