diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mm-at-serial-port.c | 28 | ||||
-rw-r--r-- | src/mm-at-serial-port.h | 4 |
2 files changed, 32 insertions, 0 deletions
diff --git a/src/mm-at-serial-port.c b/src/mm-at-serial-port.c index 346221ab..3b94458f 100644 --- a/src/mm-at-serial-port.c +++ b/src/mm-at-serial-port.c @@ -176,6 +176,7 @@ handle_response (MMSerialPort *port, typedef struct { GRegex *regex; MMAtSerialUnsolicitedMsgFn callback; + gboolean enable; gpointer user_data; GDestroyNotify notify; } MMAtUnsolicitedMsgHandler; @@ -219,10 +220,34 @@ mm_at_serial_port_add_unsolicited_msg_handler (MMAtSerialPort *self, } handler->callback = callback; + handler->enable = TRUE; handler->user_data = user_data; handler->notify = notify; } +void +mm_at_serial_port_enable_disable_unsolicited_msg_handler (MMAtSerialPort *self, + GRegex *regex, + gboolean enable) +{ + GSList *existing; + MMAtUnsolicitedMsgHandler *handler; + MMAtSerialPortPrivate *priv; + + g_return_if_fail (MM_IS_AT_SERIAL_PORT (self)); + g_return_if_fail (regex != NULL); + + priv = MM_AT_SERIAL_PORT_GET_PRIVATE (self); + + existing = g_slist_find_custom (priv->unsolicited_msg_handlers, + regex, + (GCompareFunc)unsolicited_msg_handler_cmp); + if (existing) { + handler = existing->data; + handler->enable = enable; + } +} + static gboolean remove_eval_cb (const GMatchInfo *match_info, GString *result, @@ -254,6 +279,9 @@ parse_unsolicited (MMSerialPort *port, GByteArray *response) GMatchInfo *match_info; gboolean matches; + if (!handler->enable) + continue; + matches = g_regex_match_full (handler->regex, (const char *) response->data, response->len, diff --git a/src/mm-at-serial-port.h b/src/mm-at-serial-port.h index cf960a0f..09706818 100644 --- a/src/mm-at-serial-port.h +++ b/src/mm-at-serial-port.h @@ -89,6 +89,10 @@ void mm_at_serial_port_add_unsolicited_msg_handler (MMAtSerialPort *self, gpointer user_data, GDestroyNotify notify); +void mm_at_serial_port_enable_disable_unsolicited_msg_handler (MMAtSerialPort *self, + GRegex *regex, + gboolean enable); + void mm_at_serial_port_set_response_parser (MMAtSerialPort *self, MMAtSerialResponseParserFn fn, gpointer user_data, |