char **prefixes;
guint id;
GAtResultFunc callback;
+ GAtNotifyFunc listing;
gpointer user_data;
GDestroyNotify notify;
};
static struct at_command *at_command_create(const char *cmd,
const char **prefix_list,
+ GAtNotifyFunc listing,
GAtResultFunc func,
gpointer user_data,
GDestroyNotify notify)
c->prefixes = prefixes;
c->callback = func;
+ c->listing = listing;
c->user_data = user_data;
c->notify = notify;
if (!(p->flags & G_AT_CHAT_FLAG_NO_LEADING_CRLF))
p->state = PARSER_STATE_GUESS_MULTILINE_RESPONSE;
- p->response_lines = g_slist_prepend(p->response_lines,
- line);
+ if (cmd->listing) {
+ GAtResult result;
+
+ result.lines = g_slist_prepend(NULL, line);
+ result.final_or_pdu = NULL;
+
+ cmd->listing(&result, cmd->user_data);
+
+ g_slist_free(result.lines);
+ g_free(line);
+ } else
+ p->response_lines = g_slist_prepend(p->response_lines, line);
return TRUE;
}
}
if (chat->cmd_bytes_written == 0 && wakeup_first == TRUE) {
- cmd = at_command_create(chat->wakeup, NULL, NULL, NULL, NULL);
+ cmd = at_command_create(chat->wakeup, NULL, NULL, NULL,
+ NULL, NULL);
if (!cmd)
return FALSE;
return TRUE;
}
-guint g_at_chat_send(GAtChat *chat, const char *cmd,
- const char **prefix_list, GAtResultFunc func,
+static guint send_common(GAtChat *chat, const char *cmd,
+ const char **prefix_list,
+ GAtNotifyFunc listing, GAtResultFunc func,
gpointer user_data, GDestroyNotify notify)
{
struct at_command *c;
if (chat == NULL || chat->command_queue == NULL)
return 0;
- c = at_command_create(cmd, prefix_list, func, user_data, notify);
+ c = at_command_create(cmd, prefix_list, listing, func,
+ user_data, notify);
if (!c)
return 0;
return c->id;
}
+guint g_at_chat_send(GAtChat *chat, const char *cmd,
+ const char **prefix_list, GAtResultFunc func,
+ gpointer user_data, GDestroyNotify notify)
+{
+ return send_common(chat, cmd, prefix_list, NULL, func,
+ user_data, notify);
+}
+
+guint g_at_chat_send_listing(GAtChat *chat, const char *cmd,
+ const char **prefix_list,
+ GAtNotifyFunc listing, GAtResultFunc func,
+ gpointer user_data, GDestroyNotify notify)
+{
+ if (listing == NULL)
+ return 0;
+
+ return send_common(chat, cmd, prefix_list, listing, func,
+ user_data, notify);
+}
+
gboolean g_at_chat_cancel(GAtChat *chat, guint id)
{
GList *l;
const char **valid_resp, GAtResultFunc func,
gpointer user_data, GDestroyNotify notify);
+/*!
+ * Same as the above command, except that the caller wishes to receive the
+ * intermediate responses immediately through the GAtNotifyFunc callback.
+ * The final response will still be sent to GAtResultFunc callback. The
+ * final GAtResult will not contain any lines from the intermediate responses.
+ * This is useful for listing commands such as CMGL or CPBR.
+ */
+guint g_at_chat_send_listing(GAtChat *chat, const char *cmd,
+ const char **valid_resp,
+ GAtNotifyFunc listing, GAtResultFunc func,
+ gpointer user_data, GDestroyNotify notify);
+
gboolean g_at_chat_cancel(GAtChat *chat, guint id);
guint g_at_chat_register(GAtChat *chat, const char *prefix,