summaryrefslogtreecommitdiff
path: root/mu
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2011-12-13 22:56:32 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2011-12-13 23:03:27 +0200
commit7e78c6af4aa397ff422db07489850d40a9360a8c (patch)
treeeb7ac133c56c634d3d00826b0ab9c01e3344a0bb /mu
parent85c5f9a8decef2583674bc957caef1818e9628a9 (diff)
downloadmailutils-7e78c6af4aa397ff422db07489850d40a9360a8c.tar.gz
mailutils-7e78c6af4aa397ff422db07489850d40a9360a8c.tar.bz2
Imap client: implement list.
* libmailutils/stdstream/basestr.c (mu_strout): Bugfix: initialize destroy function. * include/mailutils/imap.h (imap_command) (mu_imap_gencom): Move to sys/imap.h (mu_imap_list,mu_imap_list_new): New protos. * include/mailutils/sys/imap.h (imap_command): New struct (from ../imap.h). <handler>: Rename to tagged_handler. (untagged_handler,untagged_handler_data): New members. All uses changed. (mu_imap_gencom): New proto. * libproto/imap/list.c: New file. * libproto/imap/Makefile.am: Add list.c * libproto/imap/gencom.c: Use supplied untagged_handler to analize untagged response. * mu/imap.c: Implement list command.
Diffstat (limited to 'mu')
-rw-r--r--mu/imap.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/mu/imap.c b/mu/imap.c
index 26a3401d9..699e270b6 100644
--- a/mu/imap.c
+++ b/mu/imap.c
@@ -895,6 +895,43 @@ com_append (int argc, char **argv)
return 0;
}
+static int
+print_list_item (void *item, void *data)
+{
+ struct mu_list_response *resp = item;
+ mu_stream_t out = data;
+
+ mu_stream_printf (out,
+ "%c%c %c %4d %s\n",
+ (resp->type & MU_FOLDER_ATTRIBUTE_DIRECTORY) ? 'd' : '-',
+ (resp->type & MU_FOLDER_ATTRIBUTE_FILE) ? 'f' : '-',
+ resp->separator,
+ resp->level,
+ resp->name);
+ return 0;
+}
+
+static int
+com_list (int argc, char **argv)
+{
+ mu_list_t list;
+ int rc;
+ mu_stream_t out;
+
+ rc = mu_imap_list_new (imap, argv[1], argv[2], &list);
+ if (rc)
+ {
+ report_failure ("list", rc);
+ return 0;
+ }
+
+ out = mutool_open_pager ();
+ mu_list_foreach (list, print_list_item, out);
+ mu_stream_unref (out);
+ return 0;
+}
+
+
struct mutool_command imap_comtab[] = {
{ "capability", 1, -1, 0,
com_capability,
@@ -982,6 +1019,10 @@ struct mutool_command imap_comtab[] = {
com_append,
N_("[-time DATETIME] [-flag FLAG] MAILBOX FILE"),
N_("append message text from FILE to MAILBOX") },
+ { "list", 3, 3, 0,
+ com_list,
+ N_("REF MBOX"),
+ N_("List matching mailboxes") },
{ "quit", 1, 1, 0,
com_logout,
NULL,

Return to:

Send suggestions and report system problems to the System administrator.