summaryrefslogtreecommitdiff
path: root/src/lib/ecore_con
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2019-01-04 17:42:26 -0800
committerCedric BAIL <cedric.bail@free.fr>2019-01-16 14:33:26 -0800
commit563f91eaf98fff474a4858f2d81c6374f0d777b9 (patch)
tree2e3a8abf52d835da7a74d1285ae45a17410cd763 /src/lib/ecore_con
parent40ca3fbe5813dfe0f2d0090f421c22a4cf2d8817 (diff)
ecore: remove data parameters of Efl.Loop_Consumer.promise_new to reduce the risk of inadvertently using the wrong data.
If you need data, use a efl_future_then as done in every case here to get the same feature. Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Differential Revision: https://phab.enlightenment.org/D7577
Diffstat (limited to 'src/lib/ecore_con')
-rw-r--r--src/lib/ecore_con/efl_net_control_access_point-connman.c36
-rw-r--r--src/lib/ecore_con/efl_net_control_technology-connman.c2
2 files changed, 24 insertions, 14 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 32394ab..fdbaa41 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
@@ -726,13 +726,11 @@ static void
726_efl_net_control_access_point_connect_cb(void *data, const Eldbus_Message *msg, Eldbus_Pending *pending) 726_efl_net_control_access_point_connect_cb(void *data, const Eldbus_Message *msg, Eldbus_Pending *pending)
727{ 727{
728 Eina_Promise *promise = data; 728 Eina_Promise *promise = data;
729 Efl_Object *o = eina_promise_data_get(promise); 729 Efl_Net_Control_Access_Point_Data *pd = eldbus_pending_data_get(pending, ".object");
730 Efl_Net_Control_Access_Point_Data *pd = efl_data_scope_get(o, MY_CLASS);
731 const char *err_name, *err_msg; 730 const char *err_name, *err_msg;
732 731
733 EINA_SAFETY_ON_NULL_RETURN(pd); 732 EINA_SAFETY_ON_NULL_RETURN(pd);
734 733
735 pd->pending = eina_list_remove(pd->pending, pending);
736 if (eldbus_message_error_get(msg, &err_name, &err_msg)) 734 if (eldbus_message_error_get(msg, &err_name, &err_msg))
737 { 735 {
738 Eina_Error err = EINVAL; 736 Eina_Error err = EINVAL;
@@ -741,7 +739,7 @@ _efl_net_control_access_point_connect_cb(void *data, const Eldbus_Message *msg,
741 err = EINPROGRESS; 739 err = EINPROGRESS;
742 else if (strcmp(err_name, "net.connman.Error.AlreadyConnected") == 0) 740 else if (strcmp(err_name, "net.connman.Error.AlreadyConnected") == 0)
743 err = EALREADY; 741 err = EALREADY;
744 WRN("Could not Connect %p: %s=%s", o, err_name, err_msg); 742 WRN("Could not Connect: %s=%s", err_name, err_msg);
745 743
746 eina_promise_reject(promise, err); 744 eina_promise_reject(promise, err);
747 return; 745 return;
@@ -750,20 +748,29 @@ _efl_net_control_access_point_connect_cb(void *data, const Eldbus_Message *msg,
750 eina_promise_resolve(promise, EINA_VALUE_EMPTY); 748 eina_promise_resolve(promise, EINA_VALUE_EMPTY);
751} 749}
752 750
751static Eina_Value
752_efl_net_control_access_point_connect_promise_del(Efl_Loop_Consumer *consumer EINA_UNUSED, void *data, Eina_Error error)
753{
754 if (error == ECANCELED)
755 {
756 Eldbus_Pending *p = data;
757
758 DBG("cancel pending connect %p", p);
759 eldbus_pending_cancel(p);
760 }
761
762 return eina_value_error_init(error);
763}
764
753static void 765static void
754_efl_net_control_access_point_connect_promise_del(void *data, Efl_Loop_Consumer *consumer EINA_UNUSED, const Eina_Promise *dead_ptr) 766_efl_net_control_access_point_connect_promise_clean(Eo *o EINA_UNUSED, void *data, const Eina_Future *dead_future EINA_UNUSED)
755{ 767{
756 Eldbus_Pending *p = data;
757 Efl_Net_Control_Access_Point_Data *pd; 768 Efl_Net_Control_Access_Point_Data *pd;
758 769 Eldbus_Pending *p = data;
759 p = eina_promise_data_get(dead_ptr);
760 if (!p) return; /* already gone, nothing to do */
761 770
762 pd = eldbus_pending_data_get(p, ".object"); 771 pd = eldbus_pending_data_get(p, ".object");
763 772
764 pd->pending = eina_list_remove(pd->pending, p); 773 pd->pending = eina_list_remove(pd->pending, p);
765 DBG("cancel pending connect %p", p);
766 eldbus_pending_cancel(p);
767} 774}
768 775
769EOLIAN static Eina_Future * 776EOLIAN static Eina_Future *
@@ -773,7 +780,7 @@ _efl_net_control_access_point_connect(Eo *o, Efl_Net_Control_Access_Point_Data *
773 Eina_Promise *promise; 780 Eina_Promise *promise;
774 Eina_Future *f = NULL; 781 Eina_Future *f = NULL;
775 782
776 promise = efl_loop_promise_new(o, o, _efl_net_control_access_point_connect_promise_del, NULL); 783 promise = efl_loop_promise_new(o);
777 EINA_SAFETY_ON_NULL_RETURN_VAL(promise, NULL); 784 EINA_SAFETY_ON_NULL_RETURN_VAL(promise, NULL);
778 785
779 f = eina_future_new(promise); 786 f = eina_future_new(promise);
@@ -785,7 +792,10 @@ _efl_net_control_access_point_connect(Eo *o, Efl_Net_Control_Access_Point_Data *
785 pd->pending = eina_list_append(pd->pending, p); 792 pd->pending = eina_list_append(pd->pending, p);
786 eldbus_pending_data_set(p, ".object", pd); 793 eldbus_pending_data_set(p, ".object", pd);
787 794
788 return efl_future_then(o, f); 795 return efl_future_then(o, f,
796 .data = p,
797 .error = _efl_net_control_access_point_connect_promise_del,
798 .free = _efl_net_control_access_point_connect_promise_clean);
789 799
790 error_dbus: 800 error_dbus:
791 eina_promise_reject(promise, ENOSYS); 801 eina_promise_reject(promise, ENOSYS);
diff --git a/src/lib/ecore_con/efl_net_control_technology-connman.c b/src/lib/ecore_con/efl_net_control_technology-connman.c
index 5b2af8c..9a73103 100644
--- a/src/lib/ecore_con/efl_net_control_technology-connman.c
+++ b/src/lib/ecore_con/efl_net_control_technology-connman.c
@@ -398,7 +398,7 @@ _efl_net_control_technology_scan(Eo *o, Efl_Net_Control_Technology_Data *pd)
398 Eina_Promise *promise; 398 Eina_Promise *promise;
399 Eina_Future *f = NULL; 399 Eina_Future *f = NULL;
400 400
401 promise = efl_loop_promise_new(o, NULL, NULL, NULL); 401 promise = efl_loop_promise_new(o);
402 EINA_SAFETY_ON_NULL_RETURN_VAL(promise, NULL); 402 EINA_SAFETY_ON_NULL_RETURN_VAL(promise, NULL);
403 403
404 f = eina_future_new(promise); 404 f = eina_future_new(promise);