When CFU is active be cautious with conditional
call-forward activation/deactivation
---
 src/call-forwarding.c |   46 ++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 40 insertions(+), 6 deletions(-)

diff --git a/src/call-forwarding.c b/src/call-forwarding.c
index 73ce433..eff5e9d 100644
--- a/src/call-forwarding.c
+++ b/src/call-forwarding.c
@@ -504,6 +504,7 @@ static DBusMessage *cf_get_properties_reply(DBusMessage 
*msg,
        DBusMessageIter dict;
        int i;
        dbus_bool_t status;
+       GSList *hidden = NULL;
 
        reply = dbus_message_new_method_return(msg);
        if (reply == NULL)
@@ -515,17 +516,33 @@ static DBusMessage *cf_get_properties_reply(DBusMessage 
*msg,
                                        OFONO_PROPERTIES_ARRAY_SIGNATURE,
                                                &dict);
 
-       for (i = 0; i < 4; i++)
-               property_append_cf_conditions(&dict, cf->cf_conditions[i],
-                                               BEARER_CLASS_VOICE,
-                                               cf_type_lut[i]);
-
        if ((cf->flags & CALL_FORWARDING_FLAG_CPHS_CFF) ||
                        cf->cfis_record_id > 0)
                status = is_cfu_enabled(cf, NULL);
        else
                status = FALSE;
 
+       /*
+        * If unconditional call-forwarding is enabled,
+        * hide conditionnal status
+        */
+       if (status == TRUE) {
+               struct ofono_call_forwarding_condition cd = {0, 0, {"", 0}, 0};
+
+               for (i = 0; i < 4; i++)
+                       hidden = g_slist_prepend(hidden, &cd);
+       }
+
+       for (i = 0; i < 4; i++)
+               property_append_cf_conditions(&dict, (status &&
+                               i != CALL_FORWARDING_TYPE_UNCONDITIONAL) ?
+                               hidden : cf->cf_conditions[i],
+                               BEARER_CLASS_VOICE,
+                               cf_type_lut[i]);
+
+       if (status == TRUE)
+               g_slist_free(hidden);
+
        ofono_dbus_dict_append(&dict, "ForwardingFlagOnSim", DBUS_TYPE_BOOLEAN,
                                        &status);
 
@@ -552,6 +569,13 @@ static void get_query_cf_callback(const struct ofono_error 
*error, int total,
                        cf->flags |= CALL_FORWARDING_FLAG_CACHED;
        }
 
+       if (cf->query_next == CALL_FORWARDING_TYPE_UNCONDITIONAL &&
+                       is_cfu_enabled(cf, NULL) == TRUE) {
+               DBusMessage *reply = cf_get_properties_reply(cf->pending, cf);
+               __ofono_dbus_pending_reply(&cf->pending, reply);
+               return;
+       }
+
        if (cf->query_next == CALL_FORWARDING_TYPE_NOT_REACHABLE) {
                DBusMessage *reply = cf_get_properties_reply(cf->pending, cf);
                __ofono_dbus_pending_reply(&cf->pending, reply);
@@ -575,7 +599,8 @@ static DBusMessage *cf_get_properties(DBusConnection *conn, 
DBusMessage *msg,
        struct ofono_modem *modem = __ofono_atom_get_modem(cf->atom);
 
        if ((cf->flags & CALL_FORWARDING_FLAG_CACHED) ||
-                       ofono_modem_get_online(modem) == FALSE)
+                       ofono_modem_get_online(modem) == FALSE ||
+                       is_cfu_enabled(cf, NULL) == TRUE)
                return cf_get_properties_reply(msg, cf);
 
        if (cf->driver->query == NULL)
@@ -698,6 +723,15 @@ static void set_property_callback(const struct ofono_error 
*error, void *data)
                return;
        }
 
+       if (cf->query_next != CALL_FORWARDING_TYPE_UNCONDITIONAL &&
+                       is_cfu_enabled(cf, NULL) == TRUE) {
+               DBusMessage *reply;
+               cf->flags &= ~CALL_FORWARDING_FLAG_CACHED;
+               reply = dbus_message_new_method_return(cf->pending);
+               __ofono_dbus_pending_reply(&cf->pending, reply);
+               return;
+       }
+
        /* Successfully set, query the entire set just in case */
        set_query_next_cf_cond(cf);
 }
-- 
1.7.1

_______________________________________________
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono

Reply via email to