Re: [RFC PATCH 4/4] voicecall: add emergency call handling
Hi Andras, 2010/11/24 Andras Domokos : > Thanks for the comments, I am going to resend the patch with > the changes I made based on your comments. Can you resend the entire set? At least I've lost track with where each individual patch stands... Cheers, Aki ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[RFC PATCH 4/4] voicecall: add emergency call handling
--- src/voicecall.c | 112 ++- 1 files changed, 111 insertions(+), 1 deletions(-) diff --git a/src/voicecall.c b/src/voicecall.c index 3307db0..882d94f 100644 --- a/src/voicecall.c +++ b/src/voicecall.c @@ -52,6 +52,7 @@ struct ofono_voicecall { struct ofono_sim *sim; unsigned int sim_watch; unsigned int sim_state_watch; + unsigned int modem_online_watch; const struct ofono_voicecall_driver *driver; void *driver_data; struct ofono_atom *atom; @@ -133,6 +134,22 @@ static void add_to_en_list(GSList **l, const char **list) *l = g_slist_prepend(*l, g_strdup(list[i++])); } +static gint number_compare(gconstpointer a, gconstpointer b) +{ + const char *s1 = a, *s2 = b; + return strcmp(s1, s2); +} + +static ofono_bool_t emergency_number(struct ofono_voicecall *vc, + const char *number) +{ + if (number == NULL) + return FALSE; + + return g_slist_find_custom(vc->en_list, + number, number_compare) ? TRUE : FALSE; +} + static const char *disconnect_reason_to_string(enum ofono_disconnect_reason r) { switch (r) { @@ -1125,6 +1142,7 @@ static struct voicecall *dial_handle_result(struct ofono_voicecall *vc, static void manager_dial_callback(const struct ofono_error *error, void *data) { struct ofono_voicecall *vc = data; + struct ofono_modem *modem = __ofono_atom_get_modem(vc->atom); DBusMessage *reply; const char *number; gboolean need_to_emit; @@ -1143,8 +1161,12 @@ static void manager_dial_callback(const struct ofono_error *error, void *data) dbus_message_append_args(reply, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID); - } else + } else { + if (emergency_number(vc, number)) + ofono_modem_dec_emergency(modem); + reply = __ofono_error_failed(vc->pending); + } __ofono_dbus_pending_reply(&vc->pending, reply); @@ -1156,6 +1178,7 @@ static DBusMessage *manager_dial(DBusConnection *conn, DBusMessage *msg, void *data) { struct ofono_voicecall *vc = data; + struct ofono_modem *modem = __ofono_atom_get_modem(vc->atom); const char *number; struct ofono_phone_number ph; const char *clirstr; @@ -1195,6 +1218,15 @@ static DBusMessage *manager_dial(DBusConnection *conn, string_to_phone_number(number, &ph); + if (emergency_number(vc, number)) { + ofono_bool_t online = ofono_modem_get_online(modem); + + ofono_modem_inc_emergency(modem); + + if (online == FALSE) + return NULL; + } + vc->driver->dial(vc, &ph, clir, OFONO_CUG_OPTION_DEFAULT, manager_dial_callback, vc); @@ -1748,6 +1780,7 @@ void ofono_voicecall_disconnected(struct ofono_voicecall *vc, int id, const struct ofono_error *error) { struct ofono_modem *modem = __ofono_atom_get_modem(vc->atom); + const char *number; GSList *l; struct voicecall *call; time_t ts; @@ -1767,6 +1800,7 @@ void ofono_voicecall_disconnected(struct ofono_voicecall *vc, int id, } call = l->data; + number = phone_number_to_string(&call->call->phone_number); ts = time(NULL); prev_status = call->call->status; @@ -1805,6 +1839,9 @@ void ofono_voicecall_disconnected(struct ofono_voicecall *vc, int id, voicecalls_emit_call_removed(vc, call); + if (emergency_number(vc, number)) + ofono_modem_dec_emergency(modem); + voicecall_dbus_unregister(vc, call); vc->call_list = g_slist_remove(vc->call_list, call); @@ -2067,6 +2104,7 @@ static void voicecall_unregister(struct ofono_atom *atom) static void voicecall_remove(struct ofono_atom *atom) { struct ofono_voicecall *vc = __ofono_atom_get_data(atom); + struct ofono_modem *modem = __ofono_atom_get_modem(atom); DBG("atom: %p", atom); @@ -2108,6 +2146,12 @@ static void voicecall_remove(struct ofono_atom *atom) g_queue_free(vc->toneq); } + if (vc->modem_online_watch) { + __ofono_modem_remove_online_watch(modem, + vc->modem_online_watch); + vc->modem_online_watch = 0; + } + g_free(vc); } @@ -2205,6 +2249,7 @@ static void sim_watch(struct ofono_atom *atom, static void dial_request_cb(const struct ofono_error *error, void *data) { struct ofono_voicecall *vc = data; + struct ofono_modem *modem = __ofono_atom_get_modem(vc->atom); gboolean need_to_emit; struct voicecall *v; @@ -2214,6 +2259,10 @@ sta
Re: [RFC PATCH 4/4] voicecall: add emergency call handling
Hi Denis, On 11/23/2010 11:00 AM, ext Denis Kenzior wrote: Hi Andras, On 11/15/2010 10:58 AM, Andras Domokos wrote: --- src/voicecall.c | 111 ++- 1 files changed, 110 insertions(+), 1 deletions(-) diff --git a/src/voicecall.c b/src/voicecall.c index 3af614b..066cdb9 100644 --- a/src/voicecall.c +++ b/src/voicecall.c @@ -52,6 +52,7 @@ struct ofono_voicecall { struct ofono_sim *sim; unsigned int sim_watch; unsigned int sim_state_watch; + unsigned int modem_online_watch; const struct ofono_voicecall_driver *driver; void *driver_data; struct ofono_atom *atom; @@ -133,6 +134,22 @@ static void add_to_en_list(GSList **l, const char **list) *l = g_slist_prepend(*l, g_strdup(list[i++])); } +static gint number_compare(gconstpointer a, gconstpointer b) +{ + const char *s1 = a, *s2 = b; + return strcmp(s1, s2); +} + +static ofono_bool_t emergency_number(struct ofono_voicecall *vc, + const char *number) +{ + if (!number) Just nit picking here, but in general we really prefer this to be written like this: if (number == NULL) This is much easier to read when you don't know if number is a string or an integer. Yes I know we're not always consistent about doing this, particularly in voicecall.c. + return FALSE; + + return g_slist_find_custom(vc->en_list, + number, number_compare) ? TRUE : FALSE; +} + static const char *disconnect_reason_to_string(enum ofono_disconnect_reason r) { switch (r) { @@ -1125,6 +1142,7 @@ static struct voicecall *dial_handle_result(struct ofono_voicecall *vc, static void manager_dial_callback(const struct ofono_error *error, void *data) { struct ofono_voicecall *vc = data; + struct ofono_modem *modem = __ofono_atom_get_modem(vc->atom); DBusMessage *reply; const char *number; gboolean need_to_emit; @@ -1143,8 +1161,12 @@ static void manager_dial_callback(const struct ofono_error *error, void *data) dbus_message_append_args(reply, DBUS_TYPE_OBJECT_PATH,&path, DBUS_TYPE_INVALID); - } else + } else { + if (emergency_number(vc, number)) + ofono_modem_dec_emergency_mode(modem); + reply = __ofono_error_failed(vc->pending); + } __ofono_dbus_pending_reply(&vc->pending, reply); @@ -1156,6 +1178,7 @@ static DBusMessage *manager_dial(DBusConnection *conn, DBusMessage *msg, void *data) { struct ofono_voicecall *vc = data; + struct ofono_modem *modem = __ofono_atom_get_modem(vc->atom); const char *number; struct ofono_phone_number ph; const char *clirstr; @@ -1195,6 +1218,15 @@ static DBusMessage *manager_dial(DBusConnection *conn, string_to_phone_number(number,&ph); + if (emergency_number(vc, number)) { + ofono_bool_t online = ofono_modem_get_online(modem); + + ofono_modem_inc_emergency_mode(modem); + + if (!online) Do me a favor and change this to: if (online == FALSE) + return NULL; + } + vc->driver->dial(vc,&ph, clir, OFONO_CUG_OPTION_DEFAULT, manager_dial_callback, vc); @@ -1748,6 +1780,7 @@ void ofono_voicecall_disconnected(struct ofono_voicecall *vc, int id, const struct ofono_error *error) { struct ofono_modem *modem = __ofono_atom_get_modem(vc->atom); + const char *number; GSList *l; struct voicecall *call; time_t ts; @@ -1767,6 +1800,7 @@ void ofono_voicecall_disconnected(struct ofono_voicecall *vc, int id, } call = l->data; + number = phone_number_to_string(&call->call->phone_number); ts = time(NULL); prev_status = call->call->status; @@ -1805,6 +1839,9 @@ void ofono_voicecall_disconnected(struct ofono_voicecall *vc, int id, voicecalls_emit_call_removed(vc, call); + if (emergency_number(vc, number)) + ofono_modem_dec_emergency_mode(modem); + voicecall_dbus_unregister(vc, call); vc->call_list = g_slist_remove(vc->call_list, call); @@ -2067,6 +2104,7 @@ static void voicecall_unregister(struct ofono_atom *atom) static void voicecall_remove(struct ofono_atom *atom) { struct ofono_voicecall *vc = __ofono_atom_get_data(atom); + struct ofono_modem *modem = __ofono_atom_get_modem(atom); DBG("atom: %p", atom); @@ -2108,6 +2146,12 @@ static void voicecall_remove(struct ofono_atom *atom) g_queue_free(vc->toneq); } + if (vc->modem_online_watch) { + __ofono_modem_remove_online_watch(modem, + vc->modem_online_watch); + vc->modem_online_watch = 0; +
Re: [RFC PATCH 4/4] voicecall: add emergency call handling
Hi Andras, On 11/15/2010 10:58 AM, Andras Domokos wrote: > --- > src/voicecall.c | 111 > ++- > 1 files changed, 110 insertions(+), 1 deletions(-) > > diff --git a/src/voicecall.c b/src/voicecall.c > index 3af614b..066cdb9 100644 > --- a/src/voicecall.c > +++ b/src/voicecall.c > @@ -52,6 +52,7 @@ struct ofono_voicecall { > struct ofono_sim *sim; > unsigned int sim_watch; > unsigned int sim_state_watch; > + unsigned int modem_online_watch; > const struct ofono_voicecall_driver *driver; > void *driver_data; > struct ofono_atom *atom; > @@ -133,6 +134,22 @@ static void add_to_en_list(GSList **l, const char **list) > *l = g_slist_prepend(*l, g_strdup(list[i++])); > } > > +static gint number_compare(gconstpointer a, gconstpointer b) > +{ > + const char *s1 = a, *s2 = b; > + return strcmp(s1, s2); > +} > + > +static ofono_bool_t emergency_number(struct ofono_voicecall *vc, > + const char *number) > +{ > + if (!number) Just nit picking here, but in general we really prefer this to be written like this: if (number == NULL) This is much easier to read when you don't know if number is a string or an integer. Yes I know we're not always consistent about doing this, particularly in voicecall.c. > + return FALSE; > + > + return g_slist_find_custom(vc->en_list, > + number, number_compare) ? TRUE : FALSE; > +} > + > static const char *disconnect_reason_to_string(enum ofono_disconnect_reason > r) > { > switch (r) { > @@ -1125,6 +1142,7 @@ static struct voicecall *dial_handle_result(struct > ofono_voicecall *vc, > static void manager_dial_callback(const struct ofono_error *error, void > *data) > { > struct ofono_voicecall *vc = data; > + struct ofono_modem *modem = __ofono_atom_get_modem(vc->atom); > DBusMessage *reply; > const char *number; > gboolean need_to_emit; > @@ -1143,8 +1161,12 @@ static void manager_dial_callback(const struct > ofono_error *error, void *data) > > dbus_message_append_args(reply, DBUS_TYPE_OBJECT_PATH, &path, > DBUS_TYPE_INVALID); > - } else > + } else { > + if (emergency_number(vc, number)) > + ofono_modem_dec_emergency_mode(modem); > + > reply = __ofono_error_failed(vc->pending); > + } > > __ofono_dbus_pending_reply(&vc->pending, reply); > > @@ -1156,6 +1178,7 @@ static DBusMessage *manager_dial(DBusConnection *conn, > DBusMessage *msg, void *data) > { > struct ofono_voicecall *vc = data; > + struct ofono_modem *modem = __ofono_atom_get_modem(vc->atom); > const char *number; > struct ofono_phone_number ph; > const char *clirstr; > @@ -1195,6 +1218,15 @@ static DBusMessage *manager_dial(DBusConnection *conn, > > string_to_phone_number(number, &ph); > > + if (emergency_number(vc, number)) { > + ofono_bool_t online = ofono_modem_get_online(modem); > + > + ofono_modem_inc_emergency_mode(modem); > + > + if (!online) Do me a favor and change this to: if (online == FALSE) > + return NULL; > + } > + > vc->driver->dial(vc, &ph, clir, OFONO_CUG_OPTION_DEFAULT, > manager_dial_callback, vc); > > @@ -1748,6 +1780,7 @@ void ofono_voicecall_disconnected(struct > ofono_voicecall *vc, int id, > const struct ofono_error *error) > { > struct ofono_modem *modem = __ofono_atom_get_modem(vc->atom); > + const char *number; > GSList *l; > struct voicecall *call; > time_t ts; > @@ -1767,6 +1800,7 @@ void ofono_voicecall_disconnected(struct > ofono_voicecall *vc, int id, > } > > call = l->data; > + number = phone_number_to_string(&call->call->phone_number); > > ts = time(NULL); > prev_status = call->call->status; > @@ -1805,6 +1839,9 @@ void ofono_voicecall_disconnected(struct > ofono_voicecall *vc, int id, > > voicecalls_emit_call_removed(vc, call); > > + if (emergency_number(vc, number)) > + ofono_modem_dec_emergency_mode(modem); > + > voicecall_dbus_unregister(vc, call); > > vc->call_list = g_slist_remove(vc->call_list, call); > @@ -2067,6 +2104,7 @@ static void voicecall_unregister(struct ofono_atom > *atom) > static void voicecall_remove(struct ofono_atom *atom) > { > struct ofono_voicecall *vc = __ofono_atom_get_data(atom); > + struct ofono_modem *modem = __ofono_atom_get_modem(atom); > > DBG("atom: %p", atom); > > @@ -2108,6 +2146,12 @@ static void voicecall_remove(struct ofono_atom *atom) > g_queue_free(vc->toneq); > } > > + if (vc->modem_online_watch) { > + __ofono_mo
[RFC PATCH 4/4] voicecall: add emergency call handling
--- src/voicecall.c | 111 ++- 1 files changed, 110 insertions(+), 1 deletions(-) diff --git a/src/voicecall.c b/src/voicecall.c index 3af614b..066cdb9 100644 --- a/src/voicecall.c +++ b/src/voicecall.c @@ -52,6 +52,7 @@ struct ofono_voicecall { struct ofono_sim *sim; unsigned int sim_watch; unsigned int sim_state_watch; + unsigned int modem_online_watch; const struct ofono_voicecall_driver *driver; void *driver_data; struct ofono_atom *atom; @@ -133,6 +134,22 @@ static void add_to_en_list(GSList **l, const char **list) *l = g_slist_prepend(*l, g_strdup(list[i++])); } +static gint number_compare(gconstpointer a, gconstpointer b) +{ + const char *s1 = a, *s2 = b; + return strcmp(s1, s2); +} + +static ofono_bool_t emergency_number(struct ofono_voicecall *vc, + const char *number) +{ + if (!number) + return FALSE; + + return g_slist_find_custom(vc->en_list, + number, number_compare) ? TRUE : FALSE; +} + static const char *disconnect_reason_to_string(enum ofono_disconnect_reason r) { switch (r) { @@ -1125,6 +1142,7 @@ static struct voicecall *dial_handle_result(struct ofono_voicecall *vc, static void manager_dial_callback(const struct ofono_error *error, void *data) { struct ofono_voicecall *vc = data; + struct ofono_modem *modem = __ofono_atom_get_modem(vc->atom); DBusMessage *reply; const char *number; gboolean need_to_emit; @@ -1143,8 +1161,12 @@ static void manager_dial_callback(const struct ofono_error *error, void *data) dbus_message_append_args(reply, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID); - } else + } else { + if (emergency_number(vc, number)) + ofono_modem_dec_emergency_mode(modem); + reply = __ofono_error_failed(vc->pending); + } __ofono_dbus_pending_reply(&vc->pending, reply); @@ -1156,6 +1178,7 @@ static DBusMessage *manager_dial(DBusConnection *conn, DBusMessage *msg, void *data) { struct ofono_voicecall *vc = data; + struct ofono_modem *modem = __ofono_atom_get_modem(vc->atom); const char *number; struct ofono_phone_number ph; const char *clirstr; @@ -1195,6 +1218,15 @@ static DBusMessage *manager_dial(DBusConnection *conn, string_to_phone_number(number, &ph); + if (emergency_number(vc, number)) { + ofono_bool_t online = ofono_modem_get_online(modem); + + ofono_modem_inc_emergency_mode(modem); + + if (!online) + return NULL; + } + vc->driver->dial(vc, &ph, clir, OFONO_CUG_OPTION_DEFAULT, manager_dial_callback, vc); @@ -1748,6 +1780,7 @@ void ofono_voicecall_disconnected(struct ofono_voicecall *vc, int id, const struct ofono_error *error) { struct ofono_modem *modem = __ofono_atom_get_modem(vc->atom); + const char *number; GSList *l; struct voicecall *call; time_t ts; @@ -1767,6 +1800,7 @@ void ofono_voicecall_disconnected(struct ofono_voicecall *vc, int id, } call = l->data; + number = phone_number_to_string(&call->call->phone_number); ts = time(NULL); prev_status = call->call->status; @@ -1805,6 +1839,9 @@ void ofono_voicecall_disconnected(struct ofono_voicecall *vc, int id, voicecalls_emit_call_removed(vc, call); + if (emergency_number(vc, number)) + ofono_modem_dec_emergency_mode(modem); + voicecall_dbus_unregister(vc, call); vc->call_list = g_slist_remove(vc->call_list, call); @@ -2067,6 +2104,7 @@ static void voicecall_unregister(struct ofono_atom *atom) static void voicecall_remove(struct ofono_atom *atom) { struct ofono_voicecall *vc = __ofono_atom_get_data(atom); + struct ofono_modem *modem = __ofono_atom_get_modem(atom); DBG("atom: %p", atom); @@ -2108,6 +2146,12 @@ static void voicecall_remove(struct ofono_atom *atom) g_queue_free(vc->toneq); } + if (vc->modem_online_watch) { + __ofono_modem_remove_online_watch(modem, + vc->modem_online_watch); + vc->modem_online_watch = 0; + } + g_free(vc); } @@ -2205,6 +2249,7 @@ static void sim_watch(struct ofono_atom *atom, static void dial_request_cb(const struct ofono_error *error, void *data) { struct ofono_voicecall *vc = data; + struct ofono_modem *modem = __ofono_atom_get_modem(vc->atom); gboolean need_to_emit; struct voicecall *v; @@ -2214,6 +2259,9 @@ stat
[RFC PATCH 4/4] voicecall: add emergency call handling
--- src/voicecall.c | 111 ++- 1 files changed, 110 insertions(+), 1 deletions(-) diff --git a/src/voicecall.c b/src/voicecall.c index 3af614b..066cdb9 100644 --- a/src/voicecall.c +++ b/src/voicecall.c @@ -52,6 +52,7 @@ struct ofono_voicecall { struct ofono_sim *sim; unsigned int sim_watch; unsigned int sim_state_watch; + unsigned int modem_online_watch; const struct ofono_voicecall_driver *driver; void *driver_data; struct ofono_atom *atom; @@ -133,6 +134,22 @@ static void add_to_en_list(GSList **l, const char **list) *l = g_slist_prepend(*l, g_strdup(list[i++])); } +static gint number_compare(gconstpointer a, gconstpointer b) +{ + const char *s1 = a, *s2 = b; + return strcmp(s1, s2); +} + +static ofono_bool_t emergency_number(struct ofono_voicecall *vc, + const char *number) +{ + if (!number) + return FALSE; + + return g_slist_find_custom(vc->en_list, + number, number_compare) ? TRUE : FALSE; +} + static const char *disconnect_reason_to_string(enum ofono_disconnect_reason r) { switch (r) { @@ -1125,6 +1142,7 @@ static struct voicecall *dial_handle_result(struct ofono_voicecall *vc, static void manager_dial_callback(const struct ofono_error *error, void *data) { struct ofono_voicecall *vc = data; + struct ofono_modem *modem = __ofono_atom_get_modem(vc->atom); DBusMessage *reply; const char *number; gboolean need_to_emit; @@ -1143,8 +1161,12 @@ static void manager_dial_callback(const struct ofono_error *error, void *data) dbus_message_append_args(reply, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID); - } else + } else { + if (emergency_number(vc, number)) + ofono_modem_dec_emergency_mode(modem); + reply = __ofono_error_failed(vc->pending); + } __ofono_dbus_pending_reply(&vc->pending, reply); @@ -1156,6 +1178,7 @@ static DBusMessage *manager_dial(DBusConnection *conn, DBusMessage *msg, void *data) { struct ofono_voicecall *vc = data; + struct ofono_modem *modem = __ofono_atom_get_modem(vc->atom); const char *number; struct ofono_phone_number ph; const char *clirstr; @@ -1195,6 +1218,15 @@ static DBusMessage *manager_dial(DBusConnection *conn, string_to_phone_number(number, &ph); + if (emergency_number(vc, number)) { + ofono_bool_t online = ofono_modem_get_online(modem); + + ofono_modem_inc_emergency_mode(modem); + + if (!online) + return NULL; + } + vc->driver->dial(vc, &ph, clir, OFONO_CUG_OPTION_DEFAULT, manager_dial_callback, vc); @@ -1748,6 +1780,7 @@ void ofono_voicecall_disconnected(struct ofono_voicecall *vc, int id, const struct ofono_error *error) { struct ofono_modem *modem = __ofono_atom_get_modem(vc->atom); + const char *number; GSList *l; struct voicecall *call; time_t ts; @@ -1767,6 +1800,7 @@ void ofono_voicecall_disconnected(struct ofono_voicecall *vc, int id, } call = l->data; + number = phone_number_to_string(&call->call->phone_number); ts = time(NULL); prev_status = call->call->status; @@ -1805,6 +1839,9 @@ void ofono_voicecall_disconnected(struct ofono_voicecall *vc, int id, voicecalls_emit_call_removed(vc, call); + if (emergency_number(vc, number)) + ofono_modem_dec_emergency_mode(modem); + voicecall_dbus_unregister(vc, call); vc->call_list = g_slist_remove(vc->call_list, call); @@ -2067,6 +2104,7 @@ static void voicecall_unregister(struct ofono_atom *atom) static void voicecall_remove(struct ofono_atom *atom) { struct ofono_voicecall *vc = __ofono_atom_get_data(atom); + struct ofono_modem *modem = __ofono_atom_get_modem(atom); DBG("atom: %p", atom); @@ -2108,6 +2146,12 @@ static void voicecall_remove(struct ofono_atom *atom) g_queue_free(vc->toneq); } + if (vc->modem_online_watch) { + __ofono_modem_remove_online_watch(modem, + vc->modem_online_watch); + vc->modem_online_watch = 0; + } + g_free(vc); } @@ -2205,6 +2249,7 @@ static void sim_watch(struct ofono_atom *atom, static void dial_request_cb(const struct ofono_error *error, void *data) { struct ofono_voicecall *vc = data; + struct ofono_modem *modem = __ofono_atom_get_modem(vc->atom); gboolean need_to_emit; struct voicecall *v; @@ -2214,6 +2259,9 @@ stat