summaryrefslogtreecommitdiffstats
path: root/src/emulator.c
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2011-07-01 11:18:56 -0500
committerDenis Kenzior <denkenz@gmail.com>2011-07-06 04:16:16 -0500
commita4cfed9eae11cda96c0a934b8f5afdbf6b44e39c (patch)
tree2f2613a578fa288acc4f24fe185f0b8a3b9ab65d /src/emulator.c
parent8c64487098f3fb0f1724d7ec37f7b45ae0b460ff (diff)
downloadofono-a4cfed9eae11cda96c0a934b8f5afdbf6b44e39c.tar.bz2
emulator: Make the logic a bit more readable
Diffstat (limited to 'src/emulator.c')
-rw-r--r--src/emulator.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/src/emulator.c b/src/emulator.c
index 0826724c..deb47800 100644
--- a/src/emulator.c
+++ b/src/emulator.c
@@ -1110,8 +1110,8 @@ void ofono_emulator_set_indicator(struct ofono_emulator *em,
call_ind = find_indicator(em, OFONO_EMULATOR_IND_CALL, NULL);
cs_ind = find_indicator(em, OFONO_EMULATOR_IND_CALLSETUP, NULL);
- call = (ind == call_ind);
- callsetup = (ind == cs_ind);
+ call = ind == call_ind;
+ callsetup = ind == cs_ind;
/*
* When callsetup indicator goes to Incoming and there is an active
@@ -1137,23 +1137,28 @@ void ofono_emulator_set_indicator(struct ofono_emulator *em,
* In those cases, a first RING should be sent just after the +CIEV
* Ring timer should be stopped for all other values of callsetup
*/
- if (!((callsetup && !waiting) ||
- (call && value == OFONO_EMULATOR_CALL_INACTIVE &&
- cs_ind->value == OFONO_EMULATOR_CALLSETUP_INCOMING)))
+ if (waiting)
return;
- switch (cs_ind->value) {
- case OFONO_EMULATOR_CALLSETUP_INCOMING:
- notify_ring(em);
- em->callsetup_source = g_timeout_add_seconds(RING_TIMEOUT,
- notify_ring, em);
- break;
- default:
+ /* Call state went from active/held + waiting -> incoming */
+ if (call && value == OFONO_EMULATOR_CALL_INACTIVE &&
+ cs_ind->value == OFONO_EMULATOR_CALLSETUP_INCOMING)
+ goto start_ring;
+
+ if (!callsetup)
+ return;
+
+ if (value != OFONO_EMULATOR_CALLSETUP_INCOMING) {
if (em->callsetup_source > 0) {
g_source_remove(em->callsetup_source);
em->callsetup_source = 0;
}
- break;
+ return;
}
+
+start_ring:
+ notify_ring(em);
+ em->callsetup_source = g_timeout_add_seconds(RING_TIMEOUT,
+ notify_ring, em);
}