[PATCH v2 3/4] port-serial-at: always prepend unsolicited message handlers

Aleksander Morgado aleksander at aleksander.es
Tue Jun 6 13:27:21 UTC 2017


On 30/05/17 20:09, Aleksander Morgado wrote:
> 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.
> ---

Pushed to git master.

>  src/mm-port-serial-at.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> 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;
> --
> 2.13.0
> 


-- 
Aleksander
https://aleksander.es


More information about the ModemManager-devel mailing list