diff options
author | Frédéric Danis <frederic.danis@linux.intel.com> | 2011-08-04 16:29:50 +0200 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2011-08-15 00:25:27 -0500 |
commit | 00018661864480419ffbc4072a4e8298a5e5e04b (patch) | |
tree | 889be27cc30248282afa68041cf2cca81321cca2 /src/emulator.c | |
parent | 2867bf724d5578b607226279be80290ea2d46e1b (diff) | |
download | ofono-00018661864480419ffbc4072a4e8298a5e5e04b.tar.bz2 |
emulator: fix indicator notification
Diffstat (limited to 'src/emulator.c')
-rw-r--r-- | src/emulator.c | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/src/emulator.c b/src/emulator.c index deb47800..06ec06cc 100644 --- a/src/emulator.c +++ b/src/emulator.c @@ -59,6 +59,7 @@ struct indicator { int value; int min; int max; + gboolean deferred; }; static void emulator_debug(const char *str, void *data) @@ -345,6 +346,29 @@ static struct ofono_call *find_call_with_status(struct ofono_emulator *em, return __ofono_voicecall_find_call_with_status(vc, status); } +static void notify_deferred_indicators(GAtServer *server, void *user_data) +{ + struct ofono_emulator *em = user_data; + int i; + char buf[20]; + GSList *l; + struct indicator *ind; + + for (i = 1, l = em->indicators; l; l = l->next, i++) { + ind = l->data; + + if (!ind->deferred) + continue; + + if (em->events_mode == 3 && em->events_ind && em->slc) { + sprintf(buf, "+CIEV: %d,%d", i, ind->value); + g_at_server_send_unsolicited(em->server, buf); + } + + ind->deferred = FALSE; + } +} + static gboolean notify_ccwa(void *user_data) { struct ofono_emulator *em = user_data; @@ -832,6 +856,8 @@ void ofono_emulator_register(struct ofono_emulator *em, int fd) g_at_server_set_debug(em->server, emulator_debug, "Server"); g_at_server_set_disconnect_function(em->server, emulator_disconnect, em); + g_at_server_set_finish_callback(em->server, notify_deferred_indicators, + em); if (em->type == OFONO_EMULATOR_TYPE_HFP) { emulator_add_indicator(em, OFONO_EMULATOR_IND_SERVICE, 0, 1, 0); @@ -1124,8 +1150,11 @@ void ofono_emulator_set_indicator(struct ofono_emulator *em, notify_ccwa(em); if (em->events_mode == 3 && em->events_ind && em->slc) { - sprintf(buf, "+CIEV: %d,%d", i, ind->value); - g_at_server_send_unsolicited(em->server, buf); + if (!g_at_server_command_pending(em->server)) { + sprintf(buf, "+CIEV: %d,%d", i, ind->value); + g_at_server_send_unsolicited(em->server, buf); + } else + ind->deferred = TRUE; } /* |