emulator: Make the logic a bit more readable

This commit is contained in:
Denis Kenzior 2011-07-01 11:18:56 -05:00
parent 8c64487098
commit a4cfed9eae
1 changed files with 18 additions and 13 deletions

View File

@ -1110,8 +1110,8 @@ void ofono_emulator_set_indicator(struct ofono_emulator *em,
call_ind = find_indicator(em, OFONO_EMULATOR_IND_CALL, NULL); call_ind = find_indicator(em, OFONO_EMULATOR_IND_CALL, NULL);
cs_ind = find_indicator(em, OFONO_EMULATOR_IND_CALLSETUP, NULL); cs_ind = find_indicator(em, OFONO_EMULATOR_IND_CALLSETUP, NULL);
call = (ind == call_ind); call = ind == call_ind;
callsetup = (ind == cs_ind); callsetup = ind == cs_ind;
/* /*
* When callsetup indicator goes to Incoming and there is an active * 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 * In those cases, a first RING should be sent just after the +CIEV
* Ring timer should be stopped for all other values of callsetup * Ring timer should be stopped for all other values of callsetup
*/ */
if (!((callsetup && !waiting) || if (waiting)
(call && value == OFONO_EMULATOR_CALL_INACTIVE &&
cs_ind->value == OFONO_EMULATOR_CALLSETUP_INCOMING)))
return; return;
switch (cs_ind->value) { /* Call state went from active/held + waiting -> incoming */
case OFONO_EMULATOR_CALLSETUP_INCOMING: if (call && value == OFONO_EMULATOR_CALL_INACTIVE &&
notify_ring(em); cs_ind->value == OFONO_EMULATOR_CALLSETUP_INCOMING)
em->callsetup_source = g_timeout_add_seconds(RING_TIMEOUT, goto start_ring;
notify_ring, em);
break; if (!callsetup)
default: return;
if (value != OFONO_EMULATOR_CALLSETUP_INCOMING) {
if (em->callsetup_source > 0) { if (em->callsetup_source > 0) {
g_source_remove(em->callsetup_source); g_source_remove(em->callsetup_source);
em->callsetup_source = 0; em->callsetup_source = 0;
} }
break; return;
} }
start_ring:
notify_ring(em);
em->callsetup_source = g_timeout_add_seconds(RING_TIMEOUT,
notify_ring, em);
} }