From 212b291e15021c6ea3d8d23a1f17537a1f426ff6 Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Fri, 17 Dec 2010 16:40:04 -0600 Subject: call-forwarding: Simplify sim_set_cf_indicator --- src/call-forwarding.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) (limited to 'src/call-forwarding.c') diff --git a/src/call-forwarding.c b/src/call-forwarding.c index 809d9d9f..ad140bcb 100644 --- a/src/call-forwarding.c +++ b/src/call-forwarding.c @@ -219,29 +219,37 @@ static void sim_cphs_cff_update_cb(int ok, void *data) ofono_info("Failed to update EFcphs-cff"); } -static void sim_set_cf_indicator(struct ofono_call_forwarding *cf) +static gboolean is_cfu_enabled(struct ofono_call_forwarding *cf, + struct ofono_call_forwarding_condition **out) { - gboolean cfu_voice = FALSE; - struct ofono_call_forwarding_condition *cond = NULL; - GSList *l; - const char *number = NULL; + GSList *l = cf->cf_conditions[CALL_FORWARDING_TYPE_UNCONDITIONAL]; + struct ofono_call_forwarding_condition *cond; /* * For now we only support Voice, although Fax & all Data * basic services are applicable as well. */ - for (l = cf->cf_conditions[0]; l; l = l->next) { + for (; l; l = l->next) { cond = l->data; - if ((cond->cls & BEARER_CLASS_VOICE) && - strlen(cond->phone_number.number) > 0) { - number = phone_number_to_string(&cond->phone_number); - cfu_voice = TRUE; - break; - } + if (cond->cls > BEARER_CLASS_VOICE) + continue; + + if (out) + *out = cond; + + return TRUE; } - cf->status_on_sim = cfu_voice; + return FALSE; +} + +static void sim_set_cf_indicator(struct ofono_call_forwarding *cf) +{ + gboolean cfu_voice; + struct ofono_call_forwarding_condition *cond; + + cfu_voice = is_cfu_enabled(cf, &cond); if (cf->cfis_record_id) { unsigned char data[16]; -- cgit v1.2.3