aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2017-05-30 20:09:57 +0200
committerAleksander Morgado <aleksander@aleksander.es>2017-06-06 15:21:03 +0200
commitfbfb3d182d9852be1d01004ab31721538d6594d1 (patch)
treea6ea5668305406f20fb230f94c7628724487547f
parent2c19b1f778af9b0e4200b063d3d0ed064c17b6b1 (diff)
port-serial-at: always prepend unsolicited message handlers
The generic modem has several URC handlers for generic messages, like +CIEV. But, there may be cases where the plugins themselves want to provide their own URC handlers to be run before the generic one. This patch enables this setup by always prepending the new URC handlers, so that the last ones added are processed before the ones already in the list. So if a plugin does its own unsolicited messages setup, they can run first the parent setup and then their own. The only thing to consider is that the regex provided by the plugin must be specific enough not to match the specific messages required by the parent implementation.
-rw-r--r--src/mm-port-serial-at.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/mm-port-serial-at.c b/src/mm-port-serial-at.c
index 8e2aa2aa..fb2174da 100644
--- a/src/mm-port-serial-at.c
+++ b/src/mm-port-serial-at.c
@@ -207,9 +207,12 @@ mm_port_serial_at_add_unsolicited_msg_handler (MMPortSerialAt *self,
if (handler->notify)
handler->notify (handler->user_data);
} else {
+ /* The new handler is always PREPENDED, so that e.g. plugins can provide
+ * more specific matches for URCs that are also handled by the generic
+ * plugin. */
handler = g_slice_new (MMAtUnsolicitedMsgHandler);
- self->priv->unsolicited_msg_handlers = g_slist_append (self->priv->unsolicited_msg_handlers, handler);
handler->regex = g_regex_ref (regex);
+ self->priv->unsolicited_msg_handlers = g_slist_prepend (self->priv->unsolicited_msg_handlers, handler);
}
handler->callback = callback;