From 424506262d215dfe306aea0d0fe86833d08b82a4 Mon Sep 17 00:00:00 2001 From: Jon Trowbridge Date: Thu, 29 Mar 2001 23:46:55 +0000 Subject: Added #include 2001-03-29 Jon Trowbridge * printing/e-contact-print.c: Added #include * printing/e-contact-print-envelope.c: Added #include and #include * gui/component/select-names/e-select-names-completion.c (match_email): Better handle matching of "nameless" contacts. * backend/ebook/e-destination.c (e_destination_get_string): Better handle the case of a "nameless" contact. 2001-03-29 Jon Trowbridge * camel-filter-driver.c (camel_filter_driver_filter_message): Save the source URL using camel_mime_message_set_source. * camel-mime-message.c (camel_mime_message_set_source): Renamed camel_mime_message_set_identity to this. Sets the X-Evolution-Source header. (camel_mime_message_get_source): Returns the X-Evolution-Source header. 2001-03-29 Jon Trowbridge * mail-callbacks.c: Added #include to get things to compile. * mail-callbacks.c (mail_generate_reply): Look at the X-Evolution-Source header, and try to find a corresponding account. If this works, send the mail from this account. If not, use the default account. * mail-ops.c (send_queue_send): Strip out the X-Evolution-Source header before sending. * mail-config.c (mail_config_get_account_by_source_url): Added. Look up accounts by source URL. svn path=/trunk/; revision=9032 --- mail/ChangeLog | 16 ++++++++++++++++ mail/mail-callbacks.c | 13 +++++++++---- mail/mail-config.c | 32 ++++++++++++++++++++++++++++++++ mail/mail-config.h | 13 +++++++------ mail/mail-ops.c | 3 ++- 5 files changed, 66 insertions(+), 11 deletions(-) (limited to 'mail') diff --git a/mail/ChangeLog b/mail/ChangeLog index 0b785db609..34855d075b 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,19 @@ +2001-03-29 Jon Trowbridge + + * mail-callbacks.c: Added #include to get things + to compile. + + * mail-callbacks.c (mail_generate_reply): Look at the + X-Evolution-Source header, and try to find a corresponding + account. If this works, send the mail from this account. + If not, use the default account. + + * mail-ops.c (send_queue_send): Strip out the X-Evolution-Source + header before sending. + + * mail-config.c (mail_config_get_account_by_source_url): Added. + Look up accounts by source URL. + 2001-03-29 Dan Winship * mail-format.c (call_handler_function): if called with a diff --git a/mail/mail-callbacks.c b/mail/mail-callbacks.c index dee9791098..0fc6596f88 100644 --- a/mail/mail-callbacks.c +++ b/mail/mail-callbacks.c @@ -30,10 +30,12 @@ #endif #include +#include #include #include #include #include +#include #include #include #include @@ -286,7 +288,7 @@ composer_sent_cb(char *uri, CamelMimeMessage *message, gboolean sent, void *data camel_object_unref (CAMEL_OBJECT (message)); } -CamelMimeMessage * +static CamelMimeMessage * composer_get_message (EMsgComposer *composer) { CamelMimeMessage *message; @@ -558,7 +560,7 @@ static EMsgComposer * mail_generate_reply (CamelMimeMessage *message, gboolean to_all) { const CamelInternetAddress *reply_to, *sender, *to_addrs, *cc_addrs; - const char *name = NULL, *address = NULL; + const char *name = NULL, *address = NULL, *source = NULL; const char *message_id, *references; char *text, *subject, *date_str; const MailConfigAccount *me = NULL; @@ -569,8 +571,11 @@ mail_generate_reply (CamelMimeMessage *message, gboolean to_all) gchar *sig_file = NULL; time_t date; int offset; + + source = camel_mime_message_get_source (message); + me = mail_config_get_account_by_source_url (source); - id = mail_config_get_default_identity (); + id = me ? me->id : mail_config_get_default_identity (); if (id) sig_file = id->signature; @@ -607,7 +612,7 @@ mail_generate_reply (CamelMimeMessage *message, gboolean to_all) if (to_all) { cc = list_add_addresses (cc, to_addrs, accounts, &me); cc = list_add_addresses (cc, cc_addrs, accounts, me ? NULL : &me); - } else { + } else if (me == NULL) { me = guess_me (to_addrs, cc_addrs, accounts); } diff --git a/mail/mail-config.c b/mail/mail-config.c index be685ba180..38d84fc0e7 100644 --- a/mail/mail-config.c +++ b/mail/mail-config.c @@ -772,6 +772,38 @@ mail_config_get_account_by_name (const char *account_name) return NULL; } +/* + We do a strncmp on the MIN of the url lengths rather than a straight strcmp because + I've observed extra stuff getting stuck on the end of urls in camel. Hopefully + this work-around won't lead to any weirdness. +*/ + +const MailConfigAccount * +mail_config_get_account_by_source_url (const char *source_url) +{ + const MailConfigAccount *account; + GSList *l; + gint src_len; + + g_return_val_if_fail (source_url != NULL, NULL); + + src_len = strlen (source_url); + + l = config->accounts; + while (l) { + account = l->data; + if (account + && account->source + && account->source->url + && !strncmp (account->source->url, source_url, MIN (src_len, strlen (account->source->url)))) + return account; + + l = l->next; + } + + return NULL; +} + const GSList * mail_config_get_accounts (void) { diff --git a/mail/mail-config.h b/mail/mail-config.h index 60dc23465f..889037012f 100644 --- a/mail/mail-config.h +++ b/mail/mail-config.h @@ -112,12 +112,13 @@ void mail_config_set_pgp_type (gint pgp_type); const char *mail_config_get_pgp_path (void); void mail_config_set_pgp_path (const char *pgp_path); -const MailConfigAccount *mail_config_get_default_account (void); -const MailConfigAccount *mail_config_get_account_by_name (const char *account_name); -const GSList *mail_config_get_accounts (void); -void mail_config_add_account (MailConfigAccount *account); -const GSList *mail_config_remove_account (MailConfigAccount *account); -void mail_config_set_default_account (const MailConfigAccount *account); +const MailConfigAccount *mail_config_get_default_account (void); +const MailConfigAccount *mail_config_get_account_by_name (const char *account_name); +const MailConfigAccount *mail_config_get_account_by_source_url (const char *url); +const GSList *mail_config_get_accounts (void); +void mail_config_add_account (MailConfigAccount *account); +const GSList *mail_config_remove_account (MailConfigAccount *account); +void mail_config_set_default_account (const MailConfigAccount *account); const MailConfigIdentity *mail_config_get_default_identity (void); const MailConfigService *mail_config_get_default_transport (void); diff --git a/mail/mail-ops.c b/mail/mail-ops.c index a0bf80ce92..40f3a72309 100644 --- a/mail/mail-ops.c +++ b/mail/mail-ops.c @@ -495,8 +495,9 @@ mail_send_message(CamelMimeMessage *message, const char *destination, CamelFilte camel_medium_add_header (CAMEL_MEDIUM (message), "X-Mailer", version); camel_mime_message_set_date (message, CAMEL_MESSAGE_DATE_CURRENT, 0); - /* Remove the X-Evolution header so we don't send our flags too ;-) */ + /* Remove the X-Evolution and X-Evolution-Source headers so we don't send our flags & other info too ;-) */ camel_medium_remove_header (CAMEL_MEDIUM (message), "X-Evolution"); + camel_medium_remove_header (CAMEL_MEDIUM (message), "X-Evolution-Source"); /* Get information about the account this was composed by. */ header = camel_medium_get_header (CAMEL_MEDIUM (message), "X-Evolution-Account"); -- cgit