From 27cb260d07d20b7d1e9bd126d667fea61a38a733 Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Fri, 13 Nov 2009 16:03:33 -0600 Subject: Refactor: Simplify code and add have_incoming --- src/voicecall.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/voicecall.c b/src/voicecall.c index 9107cd09..5fe8a0a9 100644 --- a/src/voicecall.c +++ b/src/voicecall.c @@ -575,7 +575,7 @@ static gboolean voicecalls_can_dtmf(struct ofono_voicecall *vc) return FALSE; } -static gboolean voicecalls_have_held(struct ofono_voicecall *vc) +static gboolean voicecalls_have_with_status(struct ofono_voicecall *vc, int status) { GSList *l; struct voicecall *v; @@ -583,13 +583,18 @@ static gboolean voicecalls_have_held(struct ofono_voicecall *vc) for (l = vc->call_list; l; l = l->next) { v = l->data; - if (v->call->status == CALL_STATUS_HELD) + if (v->call->status == status) return TRUE; } return FALSE; } +static gboolean voicecalls_have_held(struct ofono_voicecall *vc) +{ + return voicecalls_have_with_status(vc, CALL_STATUS_HELD); +} + static int voicecalls_num_with_status(struct ofono_voicecall *vc, int status) { @@ -669,17 +674,12 @@ static GSList *voicecalls_active_list(struct ofono_voicecall *vc) static gboolean voicecalls_have_waiting(struct ofono_voicecall *vc) { - GSList *l; - struct voicecall *v; - - for (l = vc->call_list; l; l = l->next) { - v = l->data; - - if (v->call->status == CALL_STATUS_WAITING) - return TRUE; - } + return voicecalls_have_with_status(vc, CALL_STATUS_WAITING); +} - return FALSE; +static gboolean voicecalls_have_incoming(struct ofono_voicecall *vc) +{ + return voicecalls_have_with_status(vc, CALL_STATUS_INCOMING); } static gboolean real_emit_call_list_changed(void *data) -- cgit v1.2.3