summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCedric Bail <cedric@osg.samsung.com>2017-12-14 14:56:40 -0800
committerCedric Bail <cedric@osg.samsung.com>2017-12-14 16:42:44 -0800
commitaffd07a11f08610553b12fdee9ac2d510938712c (patch)
treeb8ff64aa729cfffad06180d3a46d8de6929019ce /src/lib
parent9a120e3e7268b0eb398a2302f14a4fd5a4412f3f (diff)
ecore_con: move Efl.Net.Control.Access_Point to use Eina_Future.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/ecore_con/efl_net_control_access_point-connman.c43
-rw-r--r--src/lib/ecore_con/efl_net_control_access_point-none.c5
-rw-r--r--src/lib/ecore_con/efl_net_control_access_point.eo2
3 files changed, 26 insertions, 24 deletions
diff --git a/src/lib/ecore_con/efl_net_control_access_point-connman.c b/src/lib/ecore_con/efl_net_control_access_point-connman.c
index efb4730859..bd8e3d4e34 100644
--- a/src/lib/ecore_con/efl_net_control_access_point-connman.c
+++ b/src/lib/ecore_con/efl_net_control_access_point-connman.c
@@ -724,15 +724,14 @@ _efl_net_control_access_point_configuration_proxy_get(Eo *o EINA_UNUSED, Efl_Net
724static void 724static void
725_efl_net_control_access_point_connect_cb(void *data, const Eldbus_Message *msg, Eldbus_Pending *pending) 725_efl_net_control_access_point_connect_cb(void *data, const Eldbus_Message *msg, Eldbus_Pending *pending)
726{ 726{
727 Efl_Promise *promise = data; 727 Eina_Promise *promise = data;
728 Eo *o = efl_parent_get(promise); 728 Efl_Object *o = eina_promise_data_get(promise);
729 Efl_Net_Control_Access_Point_Data *pd = efl_data_scope_get(o, MY_CLASS); 729 Efl_Net_Control_Access_Point_Data *pd = efl_data_scope_get(o, MY_CLASS);
730 const char *err_name, *err_msg; 730 const char *err_name, *err_msg;
731 731
732 EINA_SAFETY_ON_NULL_RETURN(pd); 732 EINA_SAFETY_ON_NULL_RETURN(pd);
733 733
734 pd->pending = eina_list_remove(pd->pending, pending); 734 pd->pending = eina_list_remove(pd->pending, pending);
735 efl_key_data_set(promise, "eldbus_pending", NULL);
736 if (eldbus_message_error_get(msg, &err_name, &err_msg)) 735 if (eldbus_message_error_get(msg, &err_name, &err_msg))
737 { 736 {
738 Eina_Error err = EINVAL; 737 Eina_Error err = EINVAL;
@@ -742,53 +741,55 @@ _efl_net_control_access_point_connect_cb(void *data, const Eldbus_Message *msg,
742 else if (strcmp(err_name, "net.connman.Error.AlreadyConnected") == 0) 741 else if (strcmp(err_name, "net.connman.Error.AlreadyConnected") == 0)
743 err = EALREADY; 742 err = EALREADY;
744 WRN("Could not Connect %p: %s=%s", o, err_name, err_msg); 743 WRN("Could not Connect %p: %s=%s", o, err_name, err_msg);
745 efl_promise_failed_set(promise, err); 744
745 eina_promise_reject(promise, err);
746 return; 746 return;
747 } 747 }
748 748
749 efl_promise_value_set(promise, o, NULL); 749 eina_promise_resolve(promise, EINA_VALUE_EMPTY);
750 efl_del(promise);
751} 750}
752 751
753static void 752static void
754_efl_net_control_access_point_connect_promise_del(void *data, const Efl_Event *event) 753_efl_net_control_access_point_connect_promise_del(void *data, const Eina_Promise *dead_ptr)
755{ 754{
756 Eldbus_Pending *p; 755 Eldbus_Pending *p = data;
757 Eo *o = data; 756 Efl_Net_Control_Access_Point_Data *pd;
758 Efl_Net_Control_Access_Point_Data *pd = efl_data_scope_get(o, MY_CLASS);
759
760 EINA_SAFETY_ON_NULL_RETURN(pd);
761 757
762 p = efl_key_data_get(event->object, "eldbus_pending"); 758 p = eina_promise_data_get(dead_ptr);
763 if (!p) return; /* already gone, nothing to do */ 759 if (!p) return; /* already gone, nothing to do */
764 760
761 pd = eldbus_pending_data_get(p, ".object");
762
765 pd->pending = eina_list_remove(pd->pending, p); 763 pd->pending = eina_list_remove(pd->pending, p);
766 DBG("cancel pending connect %p", p); 764 DBG("cancel pending connect %p", p);
767 eldbus_pending_cancel(p); 765 eldbus_pending_cancel(p);
768} 766}
769 767
770EOLIAN static Efl_Future * 768EOLIAN static Eina_Future *
771_efl_net_control_access_point_connect(Eo *o, Efl_Net_Control_Access_Point_Data *pd) 769_efl_net_control_access_point_connect(Eo *o, Efl_Net_Control_Access_Point_Data *pd)
772{ 770{
773 Eldbus_Pending *p; 771 Eldbus_Pending *p;
774 Efl_Promise *promise; 772 Eina_Promise *promise;
773 Eina_Future *f = NULL;
775 774
776 promise = efl_add(EFL_PROMISE_CLASS, o, 775 promise = eina_promise_new(efl_loop_future_scheduler_get(o),
777 efl_event_callback_add(efl_added, EFL_EVENT_DEL, _efl_net_control_access_point_connect_promise_del, o)); 776 _efl_net_control_access_point_connect_promise_del, o);
778 EINA_SAFETY_ON_NULL_RETURN_VAL(promise, NULL); 777 EINA_SAFETY_ON_NULL_RETURN_VAL(promise, NULL);
779 778
779 f = eina_future_new(promise);
780
780 p = eldbus_proxy_call(pd->proxy, "Connect", 781 p = eldbus_proxy_call(pd->proxy, "Connect",
781 _efl_net_control_access_point_connect_cb, promise, -1.0, ""); 782 _efl_net_control_access_point_connect_cb, promise, -1.0, "");
782 EINA_SAFETY_ON_NULL_GOTO(p, error_dbus); 783 EINA_SAFETY_ON_NULL_GOTO(p, error_dbus);
783 784
784 pd->pending = eina_list_append(pd->pending, p); 785 pd->pending = eina_list_append(pd->pending, p);
785 efl_key_data_set(promise, "eldbus_pending", p); 786 eldbus_pending_data_set(p, ".object", pd);
786 787
787 return efl_promise_future_get(promise); 788 return efl_future_Eina_FutureXXX_then(o, f);
788 789
789 error_dbus: 790 error_dbus:
790 efl_promise_failed_set(promise, ENOSYS); 791 eina_promise_reject(promise, ENOSYS);
791 return promise; 792 return efl_future_Eina_FutureXXX_then(o, f);
792} 793}
793 794
794static void 795static void
diff --git a/src/lib/ecore_con/efl_net_control_access_point-none.c b/src/lib/ecore_con/efl_net_control_access_point-none.c
index 8eba6dcb18..26353f4f5f 100644
--- a/src/lib/ecore_con/efl_net_control_access_point-none.c
+++ b/src/lib/ecore_con/efl_net_control_access_point-none.c
@@ -189,10 +189,11 @@ _efl_net_control_access_point_configuration_proxy_get(Eo *obj EINA_UNUSED, Efl_N
189{ 189{
190} 190}
191 191
192EOLIAN static Efl_Future * 192EOLIAN static Eina_Future *
193_efl_net_control_access_point_connect(Eo *obj EINA_UNUSED, Efl_Net_Control_Access_Point_Data *pd EINA_UNUSED) 193_efl_net_control_access_point_connect(Eo *obj EINA_UNUSED, Efl_Net_Control_Access_Point_Data *pd EINA_UNUSED)
194{ 194{
195 return NULL; 195 return eina_future_rejected(efl_loop_future_scheduler_get(obj),
196 EINA_ERROR_NOT_IMPLEMENTED);
196} 197}
197 198
198EOLIAN static void 199EOLIAN static void
diff --git a/src/lib/ecore_con/efl_net_control_access_point.eo b/src/lib/ecore_con/efl_net_control_access_point.eo
index 1e52774235..0287b52c57 100644
--- a/src/lib/ecore_con/efl_net_control_access_point.eo
+++ b/src/lib/ecore_con/efl_net_control_access_point.eo
@@ -108,7 +108,7 @@ class Efl.Net.Control.Access_Point (Efl.Loop.Consumer) {
108 EINPROGRESS (the connection was already ongoing) and 108 EINPROGRESS (the connection was already ongoing) and
109 EALREADY (the connection was already established). 109 EALREADY (the connection was already established).
110 ]] 110 ]]
111 return: future<void_ptr>; [[Future for asynchronous connect]] /* NOTE: This should be future<void> */ 111 return: ptr(Eina.Future) @owned; [[Future for asynchronous connect]] /* NOTE: This should be future<void> */
112 } 112 }
113 113
114 disconnect { 114 disconnect {