mirror of git://git.sysmocom.de/ofono
gatchat: Add terminator blacklisting
This commit is contained in:
parent
a1baf7aa82
commit
0471e3ec8d
|
@ -102,6 +102,7 @@ struct at_chat {
|
|||
gboolean in_read_handler; /* Re-entrancy guard */
|
||||
gboolean in_notify;
|
||||
GSList *terminator_list; /* Non-standard terminator */
|
||||
guint16 terminator_blacklist; /* Blacklisted terinators */
|
||||
};
|
||||
|
||||
struct _GAtChat {
|
||||
|
@ -490,6 +491,12 @@ static void at_chat_add_terminator(struct at_chat *chat, char *terminator,
|
|||
chat->terminator_list = g_slist_prepend(chat->terminator_list, info);
|
||||
}
|
||||
|
||||
static void at_chat_blacklist_terminator(struct at_chat *chat,
|
||||
GAtChatTerminator terminator)
|
||||
{
|
||||
chat->terminator_blacklist |= 1 << terminator;
|
||||
}
|
||||
|
||||
static gboolean check_terminator(struct terminator_info *info, char *line)
|
||||
{
|
||||
if (info->len == -1 && !strcmp(line, info->terminator))
|
||||
|
@ -512,7 +519,8 @@ static gboolean at_chat_handle_command_response(struct at_chat *p,
|
|||
|
||||
for (i = 0; i < size; i++) {
|
||||
struct terminator_info *info = &terminator_table[i];
|
||||
if (check_terminator(info, line)) {
|
||||
if (check_terminator(info, line) &&
|
||||
(p->terminator_blacklist & 1 << i) == 0) {
|
||||
at_chat_finish_command(p, info->success, line);
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -1439,6 +1447,15 @@ void g_at_chat_add_terminator(GAtChat *chat, char *terminator,
|
|||
at_chat_add_terminator(chat->parent, terminator, len, success);
|
||||
}
|
||||
|
||||
void g_at_chat_blacklist_terminator(GAtChat *chat,
|
||||
GAtChatTerminator terminator)
|
||||
{
|
||||
if (chat == NULL || chat->group != 0)
|
||||
return;
|
||||
|
||||
at_chat_blacklist_terminator(chat->parent, terminator);
|
||||
}
|
||||
|
||||
gboolean g_at_chat_set_wakeup_command(GAtChat *chat, const char *cmd,
|
||||
unsigned int timeout, unsigned int msec)
|
||||
{
|
||||
|
|
|
@ -39,6 +39,21 @@ typedef void (*GAtResultFunc)(gboolean success, GAtResult *result,
|
|||
gpointer user_data);
|
||||
typedef void (*GAtNotifyFunc)(GAtResult *result, gpointer user_data);
|
||||
|
||||
enum _GAtChatTerminator {
|
||||
G_AT_CHAT_TERMINATOR_OK,
|
||||
G_AT_CHAT_TERMINATOR_ERROR,
|
||||
G_AT_CHAT_TERMINATOR_NO_DIALTONE,
|
||||
G_AT_CHAT_TERMINATOR_BUSY,
|
||||
G_AT_CHAT_TERMINATOR_NO_CARRIER,
|
||||
G_AT_CHAT_TERMINATOR_CONNECT,
|
||||
G_AT_CHAT_TERMINATOR_NO_ANSWER,
|
||||
G_AT_CHAT_TERMINATOR_CMS_ERROR,
|
||||
G_AT_CHAT_TERMINATOR_CME_ERROR,
|
||||
G_AT_CHAT_TERMINATOR_EXT_ERROR,
|
||||
};
|
||||
|
||||
typedef enum _GAtChatTerminator GAtChatTerminator;
|
||||
|
||||
GAtChat *g_at_chat_new(GIOChannel *channel, GAtSyntax *syntax);
|
||||
GAtChat *g_at_chat_new_blocking(GIOChannel *channel, GAtSyntax *syntax);
|
||||
|
||||
|
@ -147,6 +162,8 @@ gboolean g_at_chat_set_wakeup_command(GAtChat *chat, const char *cmd,
|
|||
|
||||
void g_at_chat_add_terminator(GAtChat *chat, char *terminator,
|
||||
int len, gboolean success);
|
||||
void g_at_chat_blacklist_terminator(GAtChat *chat,
|
||||
GAtChatTerminator terminator);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue