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.
Showing
3 changed files
with
17 additions
and
2 deletions
... | @@ -36,7 +36,7 @@ mu_imap_append_message (mu_imap_t imap, const char *mailbox, int flags, | ... | @@ -36,7 +36,7 @@ mu_imap_append_message (mu_imap_t imap, const char *mailbox, int flags, |
36 | int rc; | 36 | int rc; |
37 | 37 | ||
38 | rc = mu_message_get_streamref (msg, &str); | 38 | rc = mu_message_get_streamref (msg, &str); |
39 | if (rc) | 39 | if (rc == 0) |
40 | { | 40 | { |
41 | rc = mu_imap_append_stream (imap, mailbox, flags, tm, tz, str); | 41 | rc = mu_imap_append_stream (imap, mailbox, flags, tm, tz, str); |
42 | mu_stream_unref (str); | 42 | mu_stream_unref (str); | ... | ... |
... | @@ -1106,6 +1106,8 @@ _imap_mbx_append_message (mu_mailbox_t mbox, mu_message_t msg) | ... | @@ -1106,6 +1106,8 @@ _imap_mbx_append_message (mu_mailbox_t mbox, mu_message_t msg) |
1106 | if (rc) | 1106 | if (rc) |
1107 | return rc; | 1107 | return rc; |
1108 | rc = mu_url_sget_path (url, &mbox_name); | 1108 | rc = mu_url_sget_path (url, &mbox_name); |
1109 | if (rc) | ||
1110 | return rc; | ||
1109 | return mu_imap_append_message (imap, mbox_name, 0, NULL, NULL, msg); | 1111 | return mu_imap_append_message (imap, mbox_name, 0, NULL, NULL, msg); |
1110 | } | 1112 | } |
1111 | 1113 | ... | ... |
... | @@ -29,6 +29,7 @@ | ... | @@ -29,6 +29,7 @@ |
29 | #include <mailutils/sys/registrar.h> | 29 | #include <mailutils/sys/registrar.h> |
30 | #include <mailutils/sys/url.h> | 30 | #include <mailutils/sys/url.h> |
31 | #include <mailutils/sys/imap.h> | 31 | #include <mailutils/sys/imap.h> |
32 | #include <mailutils/util.h> | ||
32 | 33 | ||
33 | static void url_imap_destroy (mu_url_t url); | 34 | static void url_imap_destroy (mu_url_t url); |
34 | 35 | ||
... | @@ -37,6 +38,16 @@ url_imap_destroy (mu_url_t url MU_ARG_UNUSED) | ... | @@ -37,6 +38,16 @@ url_imap_destroy (mu_url_t url MU_ARG_UNUSED) |
37 | { | 38 | { |
38 | } | 39 | } |
39 | 40 | ||
41 | static int | ||
42 | url_imap_get_path (const mu_url_t url, char *bufptr, size_t bufsize, | ||
43 | size_t *rsize) | ||
44 | { | ||
45 | bufsize = mu_cpystr (bufptr, "INBOX", bufsize); | ||
46 | if (rsize) | ||
47 | *rsize = bufsize; | ||
48 | return 0; | ||
49 | } | ||
50 | |||
40 | /* | 51 | /* |
41 | IMAP URLs: | 52 | IMAP URLs: |
42 | imap://[<user>[;AUTH=<auth>]@]<host>[/<mailbox>] | 53 | imap://[<user>[;AUTH=<auth>]@]<host>[/<mailbox>] |
... | @@ -50,7 +61,8 @@ _mu_imap_url_init (mu_url_t url) | ... | @@ -50,7 +61,8 @@ _mu_imap_url_init (mu_url_t url) |
50 | url->port = MU_IMAP_PORT; | 61 | url->port = MU_IMAP_PORT; |
51 | 62 | ||
52 | url->_destroy = url_imap_destroy; | 63 | url->_destroy = url_imap_destroy; |
53 | 64 | url->_get_path = url_imap_get_path; | |
65 | |||
54 | if (!url->host || url->qargc) | 66 | if (!url->host || url->qargc) |
55 | return EINVAL; | 67 | return EINVAL; |
56 | 68 | ||
... | @@ -81,6 +93,7 @@ _mu_imaps_url_init (mu_url_t url) | ... | @@ -81,6 +93,7 @@ _mu_imaps_url_init (mu_url_t url) |
81 | url->port = MU_IMAPS_PORT; | 93 | url->port = MU_IMAPS_PORT; |
82 | 94 | ||
83 | url->_destroy = url_imap_destroy; | 95 | url->_destroy = url_imap_destroy; |
96 | url->_get_path = url_imap_get_path; | ||
84 | 97 | ||
85 | if (!url->host || url->qargc) | 98 | if (!url->host || url->qargc) |
86 | return EINVAL; | 99 | return EINVAL; | ... | ... |
-
Please register or sign in to post a comment