Commit 1f9e808f 1f9e808fa3e458c0331f3ef2b065fa70dcc46b25 by Sergey Poznyakoff

Fix appending to IMAP[S] mailboxes

* libproto/imap/appmsg.c (mu_imap_append_message): Fix conditional.
* libproto/imap/mbox.c (_imap_mbx_append_message): Fix error checking.
* libproto/imap/url.c (_mu_imap_url_init)
(_mu_imaps_url_init): Set _get_path member.  This allows the user
to specify an URL without explicit path, implying INBOX.
1 parent 7585f48f
......@@ -36,7 +36,7 @@ mu_imap_append_message (mu_imap_t imap, const char *mailbox, int flags,
int rc;
rc = mu_message_get_streamref (msg, &str);
if (rc)
if (rc == 0)
{
rc = mu_imap_append_stream (imap, mailbox, flags, tm, tz, str);
mu_stream_unref (str);
......
......@@ -1106,6 +1106,8 @@ _imap_mbx_append_message (mu_mailbox_t mbox, mu_message_t msg)
if (rc)
return rc;
rc = mu_url_sget_path (url, &mbox_name);
if (rc)
return rc;
return mu_imap_append_message (imap, mbox_name, 0, NULL, NULL, msg);
}
......
......@@ -29,6 +29,7 @@
#include <mailutils/sys/registrar.h>
#include <mailutils/sys/url.h>
#include <mailutils/sys/imap.h>
#include <mailutils/util.h>
static void url_imap_destroy (mu_url_t url);
......@@ -37,6 +38,16 @@ url_imap_destroy (mu_url_t url MU_ARG_UNUSED)
{
}
static int
url_imap_get_path (const mu_url_t url, char *bufptr, size_t bufsize,
size_t *rsize)
{
bufsize = mu_cpystr (bufptr, "INBOX", bufsize);
if (rsize)
*rsize = bufsize;
return 0;
}
/*
IMAP URLs:
imap://[<user>[;AUTH=<auth>]@]<host>[/<mailbox>]
......@@ -50,7 +61,8 @@ _mu_imap_url_init (mu_url_t url)
url->port = MU_IMAP_PORT;
url->_destroy = url_imap_destroy;
url->_get_path = url_imap_get_path;
if (!url->host || url->qargc)
return EINVAL;
......@@ -81,6 +93,7 @@ _mu_imaps_url_init (mu_url_t url)
url->port = MU_IMAPS_PORT;
url->_destroy = url_imap_destroy;
url->_get_path = url_imap_get_path;
if (!url->host || url->qargc)
return EINVAL;
......