From fbfb3d182d9852be1d01004ab31721538d6594d1 Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Tue, 30 May 2017 20:09:57 +0200 Subject: 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. --- src/mm-port-serial-at.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') 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; -- cgit v1.2.3-70-g09d2