diff options
author | Dan Winship <danw@src.gnome.org> | 2002-03-29 07:20:09 +0800 |
---|---|---|
committer | Dan Winship <danw@src.gnome.org> | 2002-03-29 07:20:09 +0800 |
commit | 93c35349cf39a820d6a41b2da99c2ac19c00ef93 (patch) | |
tree | 67914ba24cad1e21435730942e8e79952d55d885 /camel/providers/sendmail | |
parent | f2724282525af3eae2f52badf8ecddd31a24db70 (diff) | |
download | gsoc2013-evolution-93c35349cf39a820d6a41b2da99c2ac19c00ef93.tar gsoc2013-evolution-93c35349cf39a820d6a41b2da99c2ac19c00ef93.tar.gz gsoc2013-evolution-93c35349cf39a820d6a41b2da99c2ac19c00ef93.tar.bz2 gsoc2013-evolution-93c35349cf39a820d6a41b2da99c2ac19c00ef93.tar.lz gsoc2013-evolution-93c35349cf39a820d6a41b2da99c2ac19c00ef93.tar.xz gsoc2013-evolution-93c35349cf39a820d6a41b2da99c2ac19c00ef93.tar.zst gsoc2013-evolution-93c35349cf39a820d6a41b2da99c2ac19c00ef93.zip |
Change the message arg to a CamelMimeMessage instead of a CamelMedium.
* camel-transport.c (camel_transport_send_to): Change the message
arg to a CamelMimeMessage instead of a CamelMedium. Even the NNTP
provider returns CamelMimeMessages, and we're never going to
support anything more exotic than that. Also do a few more
g_return_if_fails here instead of in the providers.
(camel_transport_can_send): No longer needed.
(camel_transport_send): Remove this too. It wasn't being used any
more, and it doesn't behave exactly the same in sendmail and smtp.
* providers/smtp/camel-smtp-transport.c (smtp_send,
smtp_can_send): Gone.
(smtp_send_to): Update for arg change.
(smtp_data): Make this take a CamelMimeMessage too.
* providers/sendmail/camel-sendmail-transport.c (sendmail_send,
sendmail_can_send): Gone.
(sendmail_send_to): Update for arg change, and merge in the part
that used to be shared with sendmail_send.
svn path=/trunk/; revision=16278
Diffstat (limited to 'camel/providers/sendmail')
-rw-r--r-- | camel/providers/sendmail/camel-sendmail-transport.c | 121 |
1 files changed, 33 insertions, 88 deletions
diff --git a/camel/providers/sendmail/camel-sendmail-transport.c b/camel/providers/sendmail/camel-sendmail-transport.c index 5d5df59a7c..604d7f293d 100644 --- a/camel/providers/sendmail/camel-sendmail-transport.c +++ b/camel/providers/sendmail/camel-sendmail-transport.c @@ -41,10 +41,8 @@ static char *get_name (CamelService *service, gboolean brief); -static gboolean sendmail_can_send (CamelTransport *transport, CamelMedium *message); -static gboolean sendmail_send (CamelTransport *transport, CamelMedium *message, - CamelException *ex); -static gboolean sendmail_send_to (CamelTransport *transport, CamelMedium *message, +static gboolean sendmail_send_to (CamelTransport *transport, + CamelMimeMessage *message, CamelAddress *from, CamelAddress *recipients, CamelException *ex); @@ -59,9 +57,6 @@ camel_sendmail_transport_class_init (CamelSendmailTransportClass *camel_sendmail /* virtual method overload */ camel_service_class->get_name = get_name; - - camel_transport_class->can_send = sendmail_can_send; - camel_transport_class->send = sendmail_send; camel_transport_class->send_to = sendmail_send_to; } @@ -86,22 +81,40 @@ camel_sendmail_transport_get_type (void) static gboolean -sendmail_can_send (CamelTransport *transport, CamelMedium *message) -{ - return CAMEL_IS_MIME_MESSAGE (message); -} - - -static gboolean -sendmail_send_internal (CamelMedium *message, const char **argv, CamelException *ex) +sendmail_send_to (CamelTransport *transport, CamelMimeMessage *message, + CamelAddress *from, CamelAddress *recipients, + CamelException *ex) { - int fd[2], nullfd, wstat; + const char *from_addr, *addr, **argv; + int i, len, fd[2], nullfd, wstat; sigset_t mask, omask; CamelStream *out; pid_t pid; - g_assert (CAMEL_IS_MIME_MESSAGE (message)); - + if (!camel_internet_address_get (CAMEL_INTERNET_ADDRESS (from), 0, NULL, &from_addr)) + return FALSE; + + len = camel_address_length (recipients); + argv = g_malloc ((len + 6) * sizeof (char *)); + argv[0] = "sendmail"; + argv[1] = "-i"; + argv[2] = "-f"; + argv[3] = from_addr; + argv[4] = "--"; + + for (i = 0; i < len; i++) { + if (!camel_internet_address_get (CAMEL_INTERNET_ADDRESS (recipients), i, NULL, &addr)) { + camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, + _("Could not parse recipient list")); + g_free (argv); + return FALSE; + } + + argv[i + 5] = addr; + } + + argv[i + 5] = NULL; + if (pipe (fd) == -1) { camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Could not create pipe to sendmail: " @@ -125,6 +138,7 @@ sendmail_send_internal (CamelMedium *message, const char **argv, CamelException "%s: mail not sent"), g_strerror (errno)); sigprocmask (SIG_SETMASK, &omask, NULL); + g_free (argv); return FALSE; case 0: @@ -139,6 +153,7 @@ sendmail_send_internal (CamelMedium *message, const char **argv, CamelException execv (SENDMAIL_PATH, (char **)argv); _exit (255); } + g_free (argv); /* Parent process. Write the message out. */ close (fd[0]); @@ -182,76 +197,6 @@ sendmail_send_internal (CamelMedium *message, const char **argv, CamelException return TRUE; } -static const char * -get_from (CamelMedium *message, CamelException *ex) -{ - const CamelInternetAddress *from; - const char *name, *address; - - from = camel_mime_message_get_from (CAMEL_MIME_MESSAGE (message)); - if (!from || !camel_internet_address_get (from, 0, &name, &address)) { - camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, - _("Could not find 'From' address in message")); - return NULL; - } - return address; -} - -static gboolean -sendmail_send_to (CamelTransport *transport, CamelMedium *message, - CamelAddress *from, CamelAddress *recipients, - CamelException *ex) -{ - const char *from_addr, *addr, **argv; - gboolean status; - int i, len; - - if (!from) - return FALSE; - - if (!camel_internet_address_get (CAMEL_INTERNET_ADDRESS (from), 0, NULL, &from_addr)) - return FALSE; - - len = camel_address_length (recipients); - argv = g_malloc ((len + 6) * sizeof (char *)); - argv[0] = "sendmail"; - argv[1] = "-i"; - argv[2] = "-f"; - argv[3] = from_addr; - argv[4] = "--"; - - for (i = 0; i < len; i++) { - if (!camel_internet_address_get (CAMEL_INTERNET_ADDRESS (recipients), i, NULL, &addr)) { - camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, - _("Could not parse recipient list")); - g_free (argv); - return FALSE; - } - - argv[i + 5] = addr; - } - - argv[i + 5] = NULL; - - status = sendmail_send_internal (message, argv, ex); - g_free (argv); - - return status; -} - -static gboolean -sendmail_send (CamelTransport *transport, CamelMedium *message, - CamelException *ex) -{ - const char *argv[6] = { "sendmail", "-t", "-i", "-f", NULL, NULL }; - - argv[4] = get_from (message, ex); - if (!argv[4]) - return FALSE; - - return sendmail_send_internal (message, argv, ex); -} - static char * get_name (CamelService *service, gboolean brief) { |