aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/config.c8
-rw-r--r--src/mail.c78
2 files changed, 33 insertions, 53 deletions
diff --git a/src/config.c b/src/config.c
index e46c2f5..9c75df6 100644
--- a/src/config.c
+++ b/src/config.c
@@ -1152,14 +1152,6 @@ cb_url (enum grecs_callback_command cmd,
value->v.string, mu_strerror (rc));
return rc;
}
- rc = mu_url_parse (url);
- if (rc)
- {
- grecs_error (locus, 0, _("cannot parse URL `%s': %s"),
- value->v.string, mu_strerror (rc));
- mu_url_destroy (&url);
- return rc;
- }
*purl = url;
return 0;
}
diff --git a/src/mail.c b/src/mail.c
index 39dfe08..afcf29e 100644
--- a/src/mail.c
+++ b/src/mail.c
@@ -46,28 +46,20 @@ mail_init ()
}
}
-struct mu_stream_handle
-{
- mu_stream_t str;
- mu_off_t off;
-};
-
static ssize_t
mu_stream_data_read_cb (void *handle, void *buffer, size_t size)
{
- struct mu_stream_handle *mhp = handle;
+ mu_stream_t str = handle;
size_t nread;
int rc;
- rc = mu_stream_read (mhp->str, buffer, size, mhp->off, &nread);
+ rc = mu_stream_read (str, buffer, size, &nread);
if (rc)
{
logmsg (LOG_ERR, "mu_stream_read: %s", mu_strerror (rc));
errno = EIO;
return -1;
}
-
- mhp->off += nread;
return nread;
}
@@ -180,8 +172,7 @@ sign_message (mu_message_t *pmsg, const char *key)
mu_message_t newmsg;
mu_body_t body;
mu_header_t hdr;
- struct mu_stream_handle mhn;
- mu_stream_t istr, ostr;
+ mu_stream_t istr, ostr, bodystr;
int rc;
struct gpgme_data_cbs cbs;
gpgme_data_t input, output;
@@ -207,19 +198,16 @@ sign_message (mu_message_t *pmsg, const char *key)
return 1;
}
- if ((rc = mu_body_get_stream (body, &mhn.str)))
+ if ((rc = mu_body_get_streamref (body, &bodystr)))
{
logmsg (LOG_ERR, "mu_message_get_stream: %s", mu_strerror (rc));
return 1;
}
- mu_stream_seek (mhn.str, 0, SEEK_SET);
- mhn.off = 0;
-
memset (&cbs, 0, sizeof (cbs));
cbs.read = mu_stream_data_read_cb;
- err = gpgme_data_new_from_cbs (&input, &cbs, &mhn);
+ err = gpgme_data_new_from_cbs (&input, &cbs, &bodystr);
if (err)
{
logmsg (LOG_ERR, "gpgme_data_new_from_cbs: %s",
@@ -228,6 +216,7 @@ sign_message (mu_message_t *pmsg, const char *key)
}
rc = gpg_sign (&output, input, key);
+ mu_stream_unref (bodystr);
if (rc)
return 1;
@@ -238,33 +227,23 @@ sign_message (mu_message_t *pmsg, const char *key)
}
mu_message_create (&newmsg, NULL);
- mu_message_get_stream (newmsg, &ostr);
+ mu_message_get_streamref (newmsg, &ostr);
/* Copy headers */
mu_message_get_header (msg, &hdr);
- mu_header_get_stream (hdr, &istr);
- mu_stream_seek (istr, 0, SEEK_SET);
- while ((rc = mu_stream_sequential_getline (istr, &buf, &size, &nread)) == 0
- && nread)
- {
- rc = mu_stream_sequential_write (ostr, buf, nread);
- if (rc)
- {
- logmsg (LOG_ERR, "mu_stream_sequential_write: %s",
- mu_strerror (rc));
- break;
- }
- }
+ mu_header_get_streamref (hdr, &istr);
- if (rc == 0)
+ rc = mu_stream_copy (ostr, istr, 0, NULL);
+ if (rc)
+ logmsg (LOG_ERR, "mu_stream_copy: %s", mu_strerror (rc));
+ else
{
while ((nread = gpgme_data_read (output, buf, size)) > 0)
{
- rc = mu_stream_sequential_write (ostr, buf, nread);
+ rc = mu_stream_write (ostr, buf, nread, NULL);
if (rc)
{
- logmsg (LOG_ERR, "mu_stream_sequential_write: %s",
- mu_strerror (rc));
+ logmsg (LOG_ERR, "mu_stream_write: %s", mu_strerror (rc));
break;
}
}
@@ -275,6 +254,8 @@ sign_message (mu_message_t *pmsg, const char *key)
*pmsg = newmsg;
}
}
+ mu_stream_unref (istr);
+ mu_stream_unref (ostr);
if (rc)
mu_message_destroy (&newmsg, mu_message_get_owner (msg));
@@ -292,16 +273,19 @@ mail_send_message (mu_address_t rcpt, const char *text,
mu_message_t msg;
mu_stream_t stream = NULL;
mu_header_t hdr;
- int mailer_flags = 0;
static char *x_mailer = "wydawca (" PACKAGE_STRING ")";
size_t size;
char *buf;
const char *sval;
-
- mu_message_create (&msg, NULL);
- mu_message_get_stream (msg, &stream);
- mu_stream_write (stream, text, strlen (text), 0, NULL);
+ mu_static_memory_stream_create (&stream, text, strlen (text));
+ rc = mu_stream_to_message (stream, &msg);
+ mu_stream_unref (stream);
+ if (rc)
+ {
+ logmsg (LOG_CRIT, _("cannot create message: %s"), mu_strerror (rc));
+ return;
+ }
mu_message_get_header (msg, &hdr);
mu_header_append (hdr, "X-Mailer", x_mailer);
@@ -326,16 +310,19 @@ mail_send_message (mu_address_t rcpt, const char *text,
if (debug_level > 1)
{
- mu_debug_t debug;
- mu_mailer_get_debug (mailer, &debug);
- mu_debug_set_level (debug, MU_DEBUG_TRACE | MU_DEBUG_PROT);
+ mu_debug_level_t level;
+
+ mu_debug_get_category_level (MU_DEBCAT_MAILER, &level);
+ level |= MU_DEBUG_LEVEL_MASK (MU_DEBUG_TRACE0) |
+ MU_DEBUG_LEVEL_MASK (MU_DEBUG_PROT);
if (debug_level > 2)
- mailer_flags = MAILER_FLAG_DEBUG_DATA;
+ level |= MU_DEBUG_LEVEL_MASK (MU_DEBUG_TRACE7);
+ mu_debug_set_category_level (MU_DEBCAT_MAILER, level);
}
if (!mailer_opened)
{
- if ((rc = mu_mailer_open (mailer, mailer_flags)))
+ if ((rc = mu_mailer_open (mailer, 0)))
{
mu_url_t url = NULL;
mu_mailer_get_url (mailer, &url);
@@ -730,3 +717,4 @@ expand_email_owner (struct metadef *def, void *data)
def->value = "";
return def->value;
}
+

Return to:

Send suggestions and report system problems to the System administrator.