aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--camel/ChangeLog15
-rw-r--r--camel/camel-mime-filter-smtp.c96
-rw-r--r--camel/providers/imap/.cvsignore7
-rw-r--r--camel/providers/smtp/camel-smtp-provider.c3
-rw-r--r--camel/providers/smtp/camel-smtp-transport.c47
5 files changed, 105 insertions, 63 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index dfcebd00d1..a3e99f3d23 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -3,9 +3,22 @@
* providers/imap: Added some initial code to the camel tree
for IMAPv4
+ * providers/imap/.cvsignore: Added to repository
+
+ * providers/smtp/camel-smtp-transport.c: Added debug fprintf's
+ so that testers can provide more information. Tested with simple
+ messages and a reply to the hello@helixcode.com default message
+ but should really be tested more.
+ (smtp_data): Fixed to use data_wrapper_write_to_stream.
+
+ * camel-mime-filter-smtp.c (filter): Modified to escape all lines
+ beginning with a '.' and to place a \r before each \n if one did
+ not previously exist. Removed code to escape "From " as it was
+ found to not be needed for SMTP.
+
2000-05-22 Jeffrey Stedfast <fejj@helixcode.com>
- * providers/smtp/camel-smtp-transport.c: smtp_data: Fixed the
+ * providers/smtp/camel-smtp-transport.c (smtp_data): Fixed the
filtered stream. Fixes for stream changes, updated to use
camel-mime-filter-smtp.
diff --git a/camel/camel-mime-filter-smtp.c b/camel/camel-mime-filter-smtp.c
index 137b38689d..fca4b1684d 100644
--- a/camel/camel-mime-filter-smtp.c
+++ b/camel/camel-mime-filter-smtp.c
@@ -23,6 +23,8 @@
#include "camel-mime-filter-smtp.h"
#include <string.h>
+#include <stdio.h>
+
#define d(x)
struct _CamelMimeFilterSmtpPrivate {
@@ -64,7 +66,7 @@ camel_mime_filter_smtp_get_type (void)
return type;
}
-typedef enum { EOLN_NODE, FROM_NODE, DOT_NODE } node_t;
+typedef enum { EOLN_NODE, DOT_NODE } node_t;
struct smtpnode {
struct smtpnode *next;
@@ -80,26 +82,23 @@ complete(CamelMimeFilter *mf, char *in, size_t len, size_t prespace, char **out,
*outprespace = prespace;
}
+
/* Yes, it is complicated ... */
static void
filter(CamelMimeFilter *mf, char *in, size_t len, size_t prespace, char **out, size_t *outlen, size_t *outprespace)
{
CamelMimeFilterSmtp *f = (CamelMimeFilterSmtp *)mf;
register gchar *inptr, *inend;
+ guint linecount = 0;
+ guint dotcount = 0;
gint left;
gint midline = f->midline;
- gint fromcount = 0;
- gint dotcount = 0;
- gint linecount = 0;
struct smtpnode *head = NULL, *tail = (struct smtpnode *)&head, *node;
- gchar *outptr;
+ gchar *outptr = NULL;
inptr = in;
inend = inptr + len;
- d(printf("Filtering '%.*s'\n", len, in));
-
- /* first, see if we need to escape any from's */
while (inptr < inend) {
register gint c = -1;
@@ -109,7 +108,7 @@ filter(CamelMimeFilter *mf, char *in, size_t len, size_t prespace, char **out, s
if (c == '\n' || !midline) {
/* if there isn't already a carriage-return before the line-feed, count it */
- if (*(inptr-1) != '\r') {
+ if (*(inptr-1) == '\n' && *(inptr-2) != '\r') {
linecount++;
node = alloca(sizeof(*node));
node->type = EOLN_NODE;
@@ -120,68 +119,51 @@ filter(CamelMimeFilter *mf, char *in, size_t len, size_t prespace, char **out, s
}
left = inend - inptr;
- if (left > 0) {
- midline = TRUE;
- if (left < 5) {
- /* MUST check for upper and lower case F, since our "From " has no case guarentee */
- if (*inptr == 'F' || *inptr == '.') {
- camel_mime_filter_backup(mf, inptr, left);
- midline = FALSE;
- inend = inptr;
- break;
- }
- } else {
- if (!strncmp(inptr, "From ", 5)) {
- fromcount++;
- /* yes, we do alloc them on the stack ... at most we're going to get
- len / 7 of them anyway */
- node = alloca(sizeof(*node));
- node->type = FROM_NODE;
- node->pointer = inptr;
- node->next = NULL;
- tail->next = node;
- tail = node;
- inptr += 5;
- } else {
- if (!strncmp(inptr, ".\n", 2) || !strncmp(inptr, ".\r\n", 3)) {
- dotcount++;
- node = alloca(sizeof(*node));
- node->type = DOT_NODE;
- node->pointer = inptr;
- node->next = NULL;
- tail->next = node;
- tail = node;
- if (inptr[1] == '\n')
- inptr += 2;
- else
- inptr += 3;
- }
- }
+ if (left < 2) {
+ if (*inptr == '.') {
+ camel_mime_filter_backup(mf, inptr, left);
+ midline = FALSE;
+ inend = inptr;
+ break;
}
} else {
- /* \n is at end of line, check next buffer */
- midline = FALSE;
+ /* we only need to escape dots if they start the line */
+ if (left > 0 && *inptr == '.' && *(inptr+1) != '.') {
+ midline = TRUE;
+ dotcount++;
+ node = alloca(sizeof(*node));
+ node->type = DOT_NODE;
+ node->pointer = inptr;
+ node->next = NULL;
+ tail->next = node;
+ tail = node;
+ inptr++;
+ } else {
+ midline = TRUE;
+ }
}
+ } else {
+ /* \n is at end of line, check next buffer */
+ midline = FALSE;
}
}
f->midline = midline;
- if (fromcount > 0 || dotcount > 0 || linecount > 0) {
- camel_mime_filter_set_size(mf, len + fromcount + dotcount + linecount, FALSE);
+ if (dotcount > 0 || linecount > 0) {
+ camel_mime_filter_set_size(mf, len + dotcount + linecount, FALSE);
node = head;
inptr = in;
outptr = mf->outbuf;
while (node) {
- memcpy(outptr, inptr, node->pointer - inptr);
- outptr += node->pointer - inptr;
if (node->type == EOLN_NODE) {
+ memcpy(outptr, inptr, node->pointer - inptr);
+ outptr += node->pointer - inptr;
*outptr++ = '\r';
- *outptr++ = '\n';
} else {
- if (node->type == FROM_NODE) {
- *outptr++ = '>';
- } else {
+ if (node->type == DOT_NODE) {
+ memcpy(outptr, inptr, node->pointer - inptr);
+ outptr += node->pointer - inptr;
*outptr++ = '.';
}
}
@@ -249,7 +231,7 @@ camel_mime_filter_smtp_new (void)
return new;
}
-#if 0
+#ifdef TEST_PROGRAM
#include <stdio.h>
diff --git a/camel/providers/imap/.cvsignore b/camel/providers/imap/.cvsignore
new file mode 100644
index 0000000000..fd6b811c68
--- /dev/null
+++ b/camel/providers/imap/.cvsignore
@@ -0,0 +1,7 @@
+.deps
+Makefile
+Makefile.in
+.libs
+.deps
+*.lo
+*.la
diff --git a/camel/providers/smtp/camel-smtp-provider.c b/camel/providers/smtp/camel-smtp-provider.c
index c82755d481..d93b03edc4 100644
--- a/camel/providers/smtp/camel-smtp-provider.c
+++ b/camel/providers/smtp/camel-smtp-provider.c
@@ -32,8 +32,7 @@ static CamelProvider smtp_provider = {
"smtp",
"SMTP",
- "For delivering mail by connecting to a remote mailhub using SMTP."
- "(NOT YET TESTED!)",
+ "For delivering mail by connecting to a remote mailhub using SMTP.",
0,
diff --git a/camel/providers/smtp/camel-smtp-transport.c b/camel/providers/smtp/camel-smtp-transport.c
index 79cd5e51e7..3386e00e73 100644
--- a/camel/providers/smtp/camel-smtp-transport.c
+++ b/camel/providers/smtp/camel-smtp-transport.c
@@ -192,12 +192,14 @@ smtp_connect (CamelService *service, CamelException *ex)
/* check to see if AUTH is required, if so...then AUTH ourselves */
if (smtp_is_esmtp && esmtp_supported_authtypes) {
/* not really supported yet, but we can at least show what auth types are supported */
- fprintf(stderr, "camel-smtp-transport: %s requires AUTH\n", service->url->host);
+ fprintf(stderr, "camel-smtp-transport::connect(): %s requires AUTH\n", service->url->host);
num = g_list_length(esmtp_supported_authtypes);
for (i = 0; i < num; i++)
- fprintf(stderr, "Supported AUTH: %s\n", (gchar *) g_list_nth_data(esmtp_supported_authtypes, i));
+ fprintf(stderr, "\nSupported AUTH: %s\n\n", (gchar *) g_list_nth_data(esmtp_supported_authtypes, i));
g_list_free(esmtp_supported_authtypes);
esmtp_supported_authtypes = NULL;
+ } else {
+ fprintf(stderr, "\ncamel-smtp-transport::connect(): provider does not use AUTH\n\n");
}
return TRUE;
@@ -479,6 +481,8 @@ smtp_helo (CamelSmtpTransport *transport, CamelException *ex)
cmdbuf = g_strdup_printf ("EHLO %s\r\n", host && host->h_name ? host->h_name : inet_ntoa(localaddr.sin_addr));
else
cmdbuf = g_strdup_printf ("HELO %s\r\n", host && host->h_name ? host->h_name : inet_ntoa(localaddr.sin_addr));
+
+ fprintf(stderr, "sending : %s", cmdbuf);
if ( camel_stream_write (transport->ostream, cmdbuf, strlen(cmdbuf)) == -1) {
g_free(cmdbuf);
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
@@ -501,6 +505,8 @@ smtp_helo (CamelSmtpTransport *transport, CamelException *ex)
return FALSE;
}
+ fprintf(stderr, "received: %s\n", respbuf);
+
if (smtp_is_esmtp && strstr(respbuf, "AUTH")) {
/* parse for supported AUTH types */
g_strchomp(respbuf);
@@ -520,6 +526,9 @@ smtp_mail (CamelSmtpTransport *transport, gchar *sender, CamelException *ex)
/* enclose address in <>'s since some SMTP daemons *require* that */
cmdbuf = g_strdup_printf("MAIL FROM: <%s>\r\n", sender);
+
+ fprintf(stderr, "sending : %s", cmdbuf);
+
if ( camel_stream_write (transport->ostream, cmdbuf, strlen(cmdbuf)) == -1) {
g_free(cmdbuf);
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
@@ -541,6 +550,9 @@ smtp_mail (CamelSmtpTransport *transport, gchar *sender, CamelException *ex)
g_strerror (errno));
return FALSE;
}
+
+ fprintf(stderr, "received: %s\n", respbuf);
+
} while ( *(respbuf+3) == '-' ); /* if we got "250-" then loop again */
g_free(respbuf);
@@ -556,6 +568,9 @@ smtp_rcpt (CamelSmtpTransport *transport, gchar *recipient, CamelException *ex)
/* enclose address in <>'s since some SMTP daemons *require* that */
cmdbuf = g_strdup_printf("RCPT TO: <%s>\r\n", recipient);
+
+ fprintf(stderr, "sending : %s", cmdbuf);
+
if ( camel_stream_write (transport->ostream, cmdbuf, strlen(cmdbuf)) == -1) {
g_free(cmdbuf);
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
@@ -577,6 +592,9 @@ smtp_rcpt (CamelSmtpTransport *transport, gchar *recipient, CamelException *ex)
g_strerror (errno));
return FALSE;
}
+
+ fprintf(stderr, "received: %s\n", respbuf);
+
} while ( *(respbuf+3) == '-' ); /* if we got "250-" then loop again */
g_free(respbuf);
@@ -594,6 +612,9 @@ smtp_data (CamelSmtpTransport *transport, CamelMedium *message, CamelException *
/* enclose address in <>'s since some SMTP daemons *require* that */
cmdbuf = g_strdup("DATA\r\n");
+
+ fprintf(stderr, "sending : %s", cmdbuf);
+
if ( camel_stream_write (transport->ostream, cmdbuf, strlen(cmdbuf)) == -1) {
g_free(cmdbuf);
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
@@ -616,13 +637,15 @@ smtp_data (CamelSmtpTransport *transport, CamelMedium *message, CamelException *
g_strerror (errno));
return FALSE;
}
+
+ fprintf(stderr, "received: %s\n", respbuf);
/* setup stream filtering */
mimefilter = camel_mime_filter_smtp_new();
filtered_stream = camel_stream_filter_new_with_stream(transport->ostream);
id = camel_stream_filter_add(filtered_stream, CAMEL_MIME_FILTER(mimefilter));
- if (camel_stream_write_to_stream(transport->ostream, CAMEL_STREAM(filtered_stream)) == -1) {
+ if (camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER(message), CAMEL_STREAM(filtered_stream)) == -1) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
"DATA send timed out: message termination: "
"%s: mail not sent",
@@ -635,6 +658,9 @@ smtp_data (CamelSmtpTransport *transport, CamelMedium *message, CamelException *
gtk_object_unref(GTK_OBJECT(filtered_stream));
/* terminate the message body */
+
+ fprintf(stderr, "sending : \\r\\n.\\r\\n\n");
+
if ( camel_stream_write (transport->ostream, "\r\n.\r\n", 5) == -1) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
"DATA send timed out: message termination: "
@@ -654,6 +680,9 @@ smtp_data (CamelSmtpTransport *transport, CamelMedium *message, CamelException *
g_strerror (errno));
return FALSE;
}
+
+ fprintf(stderr, "received: %s\n", respbuf);
+
} while ( *(respbuf+3) == '-' ); /* if we got "250-" then loop again */
g_free(respbuf);
@@ -667,6 +696,9 @@ smtp_rset (CamelSmtpTransport *transport, CamelException *ex)
gchar *cmdbuf, *respbuf = NULL;
cmdbuf = g_strdup ("RSET\r\n");
+
+ fprintf(stderr, "sending : %s", cmdbuf);
+
if ( camel_stream_write (transport->ostream, cmdbuf, strlen(cmdbuf)) == -1) {
g_free(cmdbuf);
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
@@ -688,6 +720,9 @@ smtp_rset (CamelSmtpTransport *transport, CamelException *ex)
g_strerror (errno));
return FALSE;
}
+
+ fprintf(stderr, "received: %s\n", respbuf);
+
} while ( *(respbuf+3) == '-' ); /* if we got "250-" then loop again */
g_free(respbuf);
@@ -701,6 +736,9 @@ smtp_quit (CamelSmtpTransport *transport, CamelException *ex)
gchar *cmdbuf, *respbuf = NULL;
cmdbuf = g_strdup ("QUIT\r\n");
+
+ fprintf(stderr, "sending : %s", cmdbuf);
+
if ( camel_stream_write (transport->ostream, cmdbuf, strlen(cmdbuf)) == -1) {
g_free(cmdbuf);
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
@@ -722,6 +760,9 @@ smtp_quit (CamelSmtpTransport *transport, CamelException *ex)
g_strerror (errno));
return FALSE;
}
+
+ fprintf(stderr, "received: %s\n", respbuf);
+
} while ( *(respbuf+3) == '-' ); /* if we got "221-" then loop again */
g_free(respbuf);