cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=affd07a11f08610553b12fdee9ac2d510938712c

commit affd07a11f08610553b12fdee9ac2d510938712c
Author: Cedric Bail <ced...@osg.samsung.com>
Date:   Thu Dec 14 14:56:40 2017 -0800

    ecore_con: move Efl.Net.Control.Access_Point to use Eina_Future.
---
 .../efl_net_control_access_point-connman.c         | 43 +++++++++++-----------
 .../ecore_con/efl_net_control_access_point-none.c  |  5 ++-
 src/lib/ecore_con/efl_net_control_access_point.eo  |  2 +-
 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
 static void
 _efl_net_control_access_point_connect_cb(void *data, const Eldbus_Message 
*msg, Eldbus_Pending *pending)
 {
-   Efl_Promise *promise = data;
-   Eo *o = efl_parent_get(promise);
+   Eina_Promise *promise = data;
+   Efl_Object *o = eina_promise_data_get(promise);
    Efl_Net_Control_Access_Point_Data *pd = efl_data_scope_get(o, MY_CLASS);
    const char *err_name, *err_msg;
 
    EINA_SAFETY_ON_NULL_RETURN(pd);
 
    pd->pending = eina_list_remove(pd->pending, pending);
-   efl_key_data_set(promise, "eldbus_pending", NULL);
    if (eldbus_message_error_get(msg, &err_name, &err_msg))
      {
         Eina_Error err = EINVAL;
@@ -742,53 +741,55 @@ _efl_net_control_access_point_connect_cb(void *data, 
const Eldbus_Message *msg,
         else if (strcmp(err_name, "net.connman.Error.AlreadyConnected") == 0)
           err = EALREADY;
         WRN("Could not Connect %p: %s=%s", o, err_name, err_msg);
-        efl_promise_failed_set(promise, err);
+
+        eina_promise_reject(promise, err);
         return;
      }
 
-   efl_promise_value_set(promise, o, NULL);
-   efl_del(promise);
+   eina_promise_resolve(promise, EINA_VALUE_EMPTY);
 }
 
 static void
-_efl_net_control_access_point_connect_promise_del(void *data, const Efl_Event 
*event)
+_efl_net_control_access_point_connect_promise_del(void *data, const 
Eina_Promise *dead_ptr)
 {
-   Eldbus_Pending *p;
-   Eo *o = data;
-   Efl_Net_Control_Access_Point_Data *pd = efl_data_scope_get(o, MY_CLASS);
-
-   EINA_SAFETY_ON_NULL_RETURN(pd);
+   Eldbus_Pending *p = data;
+   Efl_Net_Control_Access_Point_Data *pd;
 
-   p = efl_key_data_get(event->object, "eldbus_pending");
+   p = eina_promise_data_get(dead_ptr);
    if (!p) return; /* already gone, nothing to do */
 
+   pd = eldbus_pending_data_get(p, ".object");
+
    pd->pending = eina_list_remove(pd->pending, p);
    DBG("cancel pending connect %p", p);
    eldbus_pending_cancel(p);
 }
 
-EOLIAN static Efl_Future *
+EOLIAN static Eina_Future *
 _efl_net_control_access_point_connect(Eo *o, Efl_Net_Control_Access_Point_Data 
*pd)
 {
    Eldbus_Pending *p;
-   Efl_Promise *promise;
+   Eina_Promise *promise;
+   Eina_Future *f = NULL;
 
-   promise = efl_add(EFL_PROMISE_CLASS, o,
-                     efl_event_callback_add(efl_added, EFL_EVENT_DEL, 
_efl_net_control_access_point_connect_promise_del, o));
+   promise = eina_promise_new(efl_loop_future_scheduler_get(o),
+                              
_efl_net_control_access_point_connect_promise_del, o);
    EINA_SAFETY_ON_NULL_RETURN_VAL(promise, NULL);
 
+   f = eina_future_new(promise);
+
    p = eldbus_proxy_call(pd->proxy, "Connect",
                          _efl_net_control_access_point_connect_cb, promise, 
-1.0, "");
    EINA_SAFETY_ON_NULL_GOTO(p, error_dbus);
 
    pd->pending = eina_list_append(pd->pending, p);
-   efl_key_data_set(promise, "eldbus_pending", p);
+   eldbus_pending_data_set(p, ".object", pd);
 
-   return efl_promise_future_get(promise);
+   return efl_future_Eina_FutureXXX_then(o, f);
 
  error_dbus:
-   efl_promise_failed_set(promise, ENOSYS);
-   return promise;
+   eina_promise_reject(promise, ENOSYS);
+   return efl_future_Eina_FutureXXX_then(o, f);
 }
 
 static 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
 {
 }
 
-EOLIAN static Efl_Future *
+EOLIAN static Eina_Future *
 _efl_net_control_access_point_connect(Eo *obj EINA_UNUSED, 
Efl_Net_Control_Access_Point_Data *pd EINA_UNUSED)
 {
-   return NULL;
+   return eina_future_rejected(efl_loop_future_scheduler_get(obj),
+                               EINA_ERROR_NOT_IMPLEMENTED);
 }
 
 EOLIAN 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) {
               EINPROGRESS (the connection was already ongoing) and
               EALREADY (the connection was already established).
             ]]
-            return: future<void_ptr>; [[Future for asynchronous connect]] /* 
NOTE: This should be future<void> */
+            return: ptr(Eina.Future) @owned; [[Future for asynchronous 
connect]] /* NOTE: This should be future<void> */
         }
 
         disconnect {

-- 


Reply via email to