summaryrefslogtreecommitdiff
path: root/mail/file.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2019-01-21 07:17:56 +0200
committerSergey Poznyakoff <gray@gnu.org>2019-01-21 10:31:37 +0200
commitdb7165424199a473265eda5d35f2399e8816e92d (patch)
treec55a57f21f540c45b93f60543bca8bbb24b9bc3a /mail/file.c
parent29a837b1126c701191affceb092afbb8de5d5ffc (diff)
downloadmailutils-db7165424199a473265eda5d35f2399e8816e92d.tar.gz
mailutils-db7165424199a473265eda5d35f2399e8816e92d.tar.bz2
Improve folder handling and expansion in mail. Add convenience functions to the library.
* configure.ac: Build libmailutils/wicket * libmailutils/Makefile.am: Likewise. * libmailutils/base/wicket.c: Move file wicket stuff to ... * libmailutils/wicket/file.c: ... here * libmailutils/wicket/noauth.c: New file. * libmailutils/wicket/Makefile.am: New file. * include/mailutils/auth.h (mu_noauth_ticket_create) (mu_noauth_wicket_create): New protos. * include/mailutils/folder.h (mu_folder_attach_ticket) (mu_folder_is_local): New protos. * include/mailutils/mailbox.h (mu_mailbox_attach_ticket): New proto. * include/mailutils/sys/folder.h (_mu_folder): Remove flags. Add new member: is_local. * libmailutils/mailbox/folder.c (mu_folder_create_from_record): Set is_local. (mu_folder_attach_ticket): New function. (mu_folder_is_local): New function. * libmailutils/mailbox/mbx_default.c (mu_mailbox_attach_ticket): New function. * libmailutils/url/create.c: Allow for trailing / in url. * libproto/imap/mbox.c (_imap_mbx_open): Do initial scan. (__imap_msg_get_stream): Initialize clos.size. * libproto/imap/tests/imapfolder.c: Attach ticket to the folder. * mail/cd.c (mail_cd): Expand directory name (~, %, + notations) prior to use. * mail/file.c (mail_file): Attach ticket to the mailbox. * mail/copy.c (append_to_mailbox): Likewise. * mail/mailline.c: Rewrite directory expansion. Implement fully functional folder expansion. * mail/util.c (util_folder_path) (util_outfolder_name): Rewrite using mu_mailbox_expand_name.
Diffstat (limited to 'mail/file.c')
-rw-r--r--mail/file.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/mail/file.c b/mail/file.c
index 517a6b7db..bc94f130e 100644
--- a/mail/file.c
+++ b/mail/file.c
@@ -30,7 +30,7 @@ mail_expand_name (const char *name)
{
int status = 0;
char *exp = NULL;
-
+
if (strcmp (name, "#") == 0)
{
if (!prev_name)
@@ -84,9 +84,18 @@ mail_file (int argc, char **argv)
if (!name)
return 1;
-
- if ((status = mu_mailbox_create (&newbox, name)) != 0
- || (status = mu_mailbox_open (newbox, MU_STREAM_RDWR)) != 0)
+
+ status = mu_mailbox_create (&newbox, name);
+ if (status)
+ {
+ mu_error(_("Cannot create mailbox %s: %s"), name,
+ mu_strerror (status));
+ free (name);
+ return 1;
+ }
+ mu_mailbox_attach_ticket (newbox);
+
+ if ((status = mu_mailbox_open (newbox, MU_STREAM_RDWR)) != 0)
{
mu_mailbox_destroy (&newbox);
mu_error(_("Cannot open mailbox %s: %s"), name, mu_strerror (status));
@@ -96,7 +105,7 @@ mail_file (int argc, char **argv)
free (name); /* won't need it any more */
page_invalidate (1); /* Invalidate current page map */
-
+
mu_mailbox_get_url (mbox, &url);
pname = mu_strdup (mu_url_to_string (url));
if (mail_mbox_close ())
@@ -107,11 +116,11 @@ mail_file (int argc, char **argv)
mu_mailbox_destroy (&newbox);
return 1;
}
-
+
if (prev_name)
free (prev_name);
prev_name = pname;
-
+
mbox = newbox;
mu_mailbox_messages_count (mbox, &total);
set_cursor (1);
@@ -128,4 +137,3 @@ mail_file (int argc, char **argv)
}
return 1;
}
-

Return to:

Send suggestions and report system problems to the System administrator.