diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2001-12-21 02:45:22 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2001-12-21 02:45:22 +0800 |
commit | 00903a7e0f235f1825ba2c9b934e607ad77855c4 (patch) | |
tree | e3960027808c3da6f6062415b9483164ed670b38 | |
parent | e97bb59a94aa28b302863c42e35e96fdf086d7cf (diff) | |
download | gsoc2013-evolution-00903a7e0f235f1825ba2c9b934e607ad77855c4.tar gsoc2013-evolution-00903a7e0f235f1825ba2c9b934e607ad77855c4.tar.gz gsoc2013-evolution-00903a7e0f235f1825ba2c9b934e607ad77855c4.tar.bz2 gsoc2013-evolution-00903a7e0f235f1825ba2c9b934e607ad77855c4.tar.lz gsoc2013-evolution-00903a7e0f235f1825ba2c9b934e607ad77855c4.tar.xz gsoc2013-evolution-00903a7e0f235f1825ba2c9b934e607ad77855c4.tar.zst gsoc2013-evolution-00903a7e0f235f1825ba2c9b934e607ad77855c4.zip |
Change the prototype for camel_address_get_type to return a CamelType
2001-12-20 Jeffrey Stedfast <fejj@ximian.com>
* camel-address.h: Change the prototype for camel_address_get_type
to return a CamelType (since internally this is what it returns
and also in case we decide to write a replacement for the current
CamelObject it'd be easier to drop in).
* camel-internet-address.h: Same but for
camel_internet_address_get_type()
* providers/smtp/camel-smtp-transport.c (smtp_send_to): Updated to
use a CamelAddress of recipients.
(smtp_send): Since smtp_send_to now takes a CamelAddress
recipients argument, our lives have been simplified and we can now
just concat To/Cc/Bcc into a recipients addr and send away.
* providers/sendmail/camel-sendmail-transport.c
(sendmail_send_to): Updated to use a CamelAddress of recipients.
* camel-transport.c (camel_transport_send_to): Now takes a
CamelAddress argument for the recipient list rather than a GList.
svn path=/trunk/; revision=15197
-rw-r--r-- | camel/ChangeLog | 28 | ||||
-rw-r--r-- | camel/camel-address.h | 2 | ||||
-rw-r--r-- | camel/camel-internet-address.h | 2 | ||||
-rw-r--r-- | camel/camel-transport.c | 2 | ||||
-rw-r--r-- | camel/camel-transport.h | 7 | ||||
-rw-r--r-- | camel/providers/sendmail/camel-sendmail-transport.c | 37 | ||||
-rw-r--r-- | camel/providers/smtp/camel-smtp-transport.c | 64 |
7 files changed, 83 insertions, 59 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index b82266ff9e..0b8724ddfd 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,31 @@ +2001-12-20 Jeffrey Stedfast <fejj@ximian.com> + + * camel-address.h: Change the prototype for camel_address_get_type + to return a CamelType (since internally this is what it returns + and also in case we decide to write a replacement for the current + CamelObject it'd be easier to drop in). + + * camel-internet-address.h: Same but for + camel_internet_address_get_type() + + * providers/smtp/camel-smtp-transport.c (smtp_send_to): Updated to + use a CamelAddress of recipients. + (smtp_send): Since smtp_send_to now takes a CamelAddress + recipients argument, our lives have been simplified and we can now + just concat To/Cc/Bcc into a recipients addr and send away. + + * providers/sendmail/camel-sendmail-transport.c + (sendmail_send_to): Updated to use a CamelAddress of recipients. + + * camel-transport.c (camel_transport_send_to): Now takes a + CamelAddress argument for the recipient list rather than a GList. + +2001-12-19 Jeffrey Stedfast <fejj@ximian.com> + + * providers/smtp/Makefile.am: Remove the providerdir variable. + + * providers/sendmail/Makefile.am: Same. + 2001-12-17 Jeffrey Stedfast <fejj@ximian.com> * camel-charset-map.c (camel_charset_iso_to_windows): New function diff --git a/camel/camel-address.h b/camel/camel-address.h index 5981c5ef4e..02dfdcd838 100644 --- a/camel/camel-address.h +++ b/camel/camel-address.h @@ -52,7 +52,7 @@ struct _CamelAddressClass { void (*remove) (CamelAddress *, int index); }; -guint camel_address_get_type (void); +CamelType camel_address_get_type (void); CamelAddress *camel_address_new (void); CamelAddress *camel_address_new_clone (const CamelAddress *); int camel_address_length (CamelAddress *); diff --git a/camel/camel-internet-address.h b/camel/camel-internet-address.h index b4212ecd15..1ed14a1ecd 100644 --- a/camel/camel-internet-address.h +++ b/camel/camel-internet-address.h @@ -39,7 +39,7 @@ struct _CamelInternetAddressClass { CamelAddressClass parent_class; }; -guint camel_internet_address_get_type (void); +CamelType camel_internet_address_get_type (void); CamelInternetAddress *camel_internet_address_new (void); int camel_internet_address_add (CamelInternetAddress *, const char *, const char *); diff --git a/camel/camel-transport.c b/camel/camel-transport.c index 0dc56a8d67..00b2a31837 100644 --- a/camel/camel-transport.c +++ b/camel/camel-transport.c @@ -132,7 +132,7 @@ camel_transport_send (CamelTransport *transport, CamelMedium *message, **/ gboolean camel_transport_send_to (CamelTransport *transport, CamelMedium *message, - GList *recipients, CamelException *ex) + CamelAddress *recipients, CamelException *ex) { gboolean sent; diff --git a/camel/camel-transport.h b/camel/camel-transport.h index 5951d1145c..dbe9c54f38 100644 --- a/camel/camel-transport.h +++ b/camel/camel-transport.h @@ -59,9 +59,8 @@ typedef struct { gboolean (*can_send) (CamelTransport *transport, CamelMedium *message); gboolean (*send) (CamelTransport *transport, CamelMedium *message, CamelException *ex); - gboolean (*send_to) (CamelTransport *transport, - CamelMedium *message, GList *recipients, - CamelException *ex); + gboolean (*send_to) (CamelTransport *transport, CamelMedium *message, + CamelAddress *recipients, CamelException *ex); } CamelTransportClass; @@ -76,7 +75,7 @@ gboolean camel_transport_send (CamelTransport *transport, /* FIXME: This should use a camel-address */ gboolean camel_transport_send_to (CamelTransport *transport, CamelMedium *message, - GList *recipients, + CamelAddress *recipients, CamelException *ex); /* Standard Camel function */ diff --git a/camel/providers/sendmail/camel-sendmail-transport.c b/camel/providers/sendmail/camel-sendmail-transport.c index 28bc488c1d..0d51333955 100644 --- a/camel/providers/sendmail/camel-sendmail-transport.c +++ b/camel/providers/sendmail/camel-sendmail-transport.c @@ -45,7 +45,7 @@ static gboolean sendmail_can_send (CamelTransport *transport, CamelMedium *messa static gboolean sendmail_send (CamelTransport *transport, CamelMedium *message, CamelException *ex); static gboolean sendmail_send_to (CamelTransport *transport, CamelMedium *message, - GList *recipients, CamelException *ex); + CamelAddress *recipients, CamelException *ex); static void @@ -198,37 +198,46 @@ get_from (CamelMedium *message, CamelException *ex) static gboolean sendmail_send_to (CamelTransport *transport, CamelMedium *message, - GList *recipients, CamelException *ex) + CamelAddress *recipients, CamelException *ex) { - GList *r; - const char *from, **argv; - int i, len; + const char *from, *addr, **argv; gboolean status; - + int i, len; + from = get_from (message, ex); if (!from) return FALSE; - - len = g_list_length (recipients); + + len = camel_address_length (recipients); argv = g_malloc ((len + 6) * sizeof (char *)); argv[0] = "sendmail"; argv[1] = "-i"; argv[2] = "-f"; argv[3] = from; argv[4] = "--"; - - for (i = 1, r = recipients; i <= len; i++, r = r->next) - argv[i + 4] = r->data; - argv[i + 4] = NULL; - + + 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) + CamelException *ex) { const char *argv[6] = { "sendmail", "-t", "-i", "-f", NULL, NULL }; diff --git a/camel/providers/smtp/camel-smtp-transport.c b/camel/providers/smtp/camel-smtp-transport.c index 78509fad28..71bd1d8776 100644 --- a/camel/providers/smtp/camel-smtp-transport.c +++ b/camel/providers/smtp/camel-smtp-transport.c @@ -69,7 +69,8 @@ /* camel smtp transport class prototypes */ static gboolean smtp_can_send (CamelTransport *transport, CamelMedium *message); static gboolean smtp_send (CamelTransport *transport, CamelMedium *message, CamelException *ex); -static gboolean smtp_send_to (CamelTransport *transport, CamelMedium *message, GList *recipients, CamelException *ex); +static gboolean smtp_send_to (CamelTransport *transport, CamelMedium *message, + CamelAddress *recipients, CamelException *ex); /* support prototypes */ static void smtp_construct (CamelService *service, CamelSession *session, @@ -566,14 +567,13 @@ smtp_can_send (CamelTransport *transport, CamelMedium *message) static gboolean smtp_send_to (CamelTransport *transport, CamelMedium *message, - GList *recipients, CamelException *ex) + CamelAddress *recipients, CamelException *ex) { CamelSmtpTransport *smtp_transport = CAMEL_SMTP_TRANSPORT (transport); const CamelInternetAddress *cia; - char *recipient; - const char *addr; gboolean has_8bit_parts; - GList *r; + const char *addr; + int i, len; cia = camel_mime_message_get_from (CAMEL_MIME_MESSAGE (message)); if (!cia) { @@ -603,18 +603,24 @@ smtp_send_to (CamelTransport *transport, CamelMedium *message, camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot send message: " "no recipients defined.")); - camel_operation_end(NULL); + camel_operation_end (NULL); return FALSE; } - for (r = recipients; r; r = r->next) { - recipient = (char *) r->data; - if (!smtp_rcpt (smtp_transport, recipient, ex)) { - g_free (recipient); + len = camel_address_length (recipients); + cia = CAMEL_INTERNET_ADDRESS (recipients); + for (i = 0; i < len; i++) { + if (!camel_internet_address_get (cia, i, NULL, &addr)) { + camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, + _("Cannot send message: one or more invalid recipients")); + camel_operation_end (NULL); + return FALSE; + } + + if (!smtp_rcpt (smtp_transport, addr, ex)) { camel_operation_end (NULL); return FALSE; } - g_free (recipient); } /* passing in has_8bit_parts saves time as we don't have to @@ -637,41 +643,23 @@ static gboolean smtp_send (CamelTransport *transport, CamelMedium *message, CamelException *ex) { const CamelInternetAddress *to, *cc, *bcc; - GList *recipients = NULL; - guint index, len; + CamelInternetAddress *recipients = NULL; + gboolean status; to = camel_mime_message_get_recipients (CAMEL_MIME_MESSAGE (message), CAMEL_RECIPIENT_TYPE_TO); cc = camel_mime_message_get_recipients (CAMEL_MIME_MESSAGE (message), CAMEL_RECIPIENT_TYPE_CC); bcc = camel_mime_message_get_recipients (CAMEL_MIME_MESSAGE (message), CAMEL_RECIPIENT_TYPE_BCC); - /* get all of the To addresses into our recipient list */ - len = camel_address_length (CAMEL_ADDRESS (to)); - for (index = 0; index < len; index++) { - const char *addr; - - if (camel_internet_address_get (to, index, NULL, &addr)) - recipients = g_list_append (recipients, g_strdup (addr)); - } + recipients = camel_internet_address_new (); + camel_address_cat (CAMEL_ADDRESS (recipients), CAMEL_ADDRESS (to)); + camel_address_cat (CAMEL_ADDRESS (recipients), CAMEL_ADDRESS (cc)); + camel_address_cat (CAMEL_ADDRESS (recipients), CAMEL_ADDRESS (bcc)); - /* get all of the Cc addresses into our recipient list */ - len = camel_address_length (CAMEL_ADDRESS (cc)); - for (index = 0; index < len; index++) { - const char *addr; - - if (camel_internet_address_get (cc, index, NULL, &addr)) - recipients = g_list_append (recipients, g_strdup (addr)); - } + status = smtp_send_to (transport, message, CAMEL_ADDRESS (recipients), ex); - /* get all of the Bcc addresses into our recipient list */ - len = camel_address_length (CAMEL_ADDRESS (bcc)); - for (index = 0; index < len; index++) { - const char *addr; - - if (camel_internet_address_get (bcc, index, NULL, &addr)) - recipients = g_list_append (recipients, g_strdup (addr)); - } + camel_object_unref (CAMEL_OBJECT (recipients)); - return smtp_send_to (transport, message, recipients, ex); + return status; } static gboolean |