aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2009-10-16 03:02:42 +0800
committerMilan Crha <mcrha@redhat.com>2009-10-16 03:02:42 +0800
commitf74a1448947259f52293ba922b64b2b3b8ff726c (patch)
treea85e893277db5a7564ba2857f87b8f256227f06d
parent3766e19a2aafccaae1f662bc8770f074fdcc4a2d (diff)
downloadgsoc2013-evolution-f74a1448947259f52293ba922b64b2b3b8ff726c.tar.gz
gsoc2013-evolution-f74a1448947259f52293ba922b64b2b3b8ff726c.tar.zst
gsoc2013-evolution-f74a1448947259f52293ba922b64b2b3b8ff726c.zip
Bug #322261 - vCalendar replies are sent out using the default account
-rw-r--r--calendar/gui/itip-utils.c37
-rw-r--r--mail/em-composer-utils.c34
-rw-r--r--mail/em-utils.c38
-rw-r--r--mail/em-utils.h2
-rw-r--r--plugins/itip-formatter/itip-formatter.c22
-rw-r--r--plugins/itip-formatter/itip-view.c1
6 files changed, 81 insertions, 53 deletions
diff --git a/calendar/gui/itip-utils.c b/calendar/gui/itip-utils.c
index e9f7bb2d82..2f34d33663 100644
--- a/calendar/gui/itip-utils.c
+++ b/calendar/gui/itip-utils.c
@@ -1205,6 +1205,29 @@ append_cal_attachments (EMsgComposer *composer,
g_slist_free (attach_list);
}
+static void
+setup_from (ECalComponentItipMethod method, ECalComponent *comp, EComposerHeaderTable *table)
+{
+ EAccountList *accounts;
+
+ accounts = e_composer_header_table_get_account_list (table);
+ if (accounts) {
+ EAccount *account = NULL;
+
+ if (!account) {
+ gchar *from = comp_from (method, comp);
+
+ if (from)
+ account = (EAccount *) e_account_list_find (accounts, E_ACCOUNT_FIND_ID_ADDRESS, from);
+
+ g_free (from);
+ }
+
+ if (account)
+ e_composer_header_table_set_account (table, account);
+ }
+}
+
gboolean
itip_send_comp (ECalComponentItipMethod method, ECalComponent *send_comp,
ECal *client, icalcomponent *zones, GSList *attachments_list, GList *users,
@@ -1216,7 +1239,6 @@ itip_send_comp (ECalComponentItipMethod method, ECalComponent *send_comp,
ECalComponent *comp = NULL;
icalcomponent *top_level = NULL;
gchar *ical_string = NULL;
- gchar *from = NULL;
gchar *content_type = NULL;
gchar *subject = NULL;
gboolean retval = FALSE;
@@ -1259,14 +1281,11 @@ itip_send_comp (ECalComponentItipMethod method, ECalComponent *send_comp,
/* Subject information */
subject = comp_subject (method, comp);
- /* From address */
- from = comp_from (method, comp);
-
composer = e_msg_composer_new ();
table = e_msg_composer_get_header_table (composer);
+ setup_from (method, send_comp, table);
e_composer_header_table_set_subject (table, subject);
- e_composer_header_table_set_account_name (table, from);
e_composer_header_table_set_destinations_to (table, destinations);
e_destination_freev (destinations);
@@ -1328,7 +1347,6 @@ itip_send_comp (ECalComponentItipMethod method, ECalComponent *send_comp,
g_list_free (users);
}
- g_free (from);
g_free (content_type);
g_free (subject);
g_free (ical_string);
@@ -1350,7 +1368,6 @@ reply_to_calendar_comp (ECalComponentItipMethod method,
ECalComponent *comp = NULL;
icalcomponent *top_level = NULL;
GList *users = NULL;
- gchar *from = NULL;
gchar *subject = NULL;
gchar *ical_string = NULL;
gboolean retval = FALSE;
@@ -1366,14 +1383,11 @@ reply_to_calendar_comp (ECalComponentItipMethod method,
/* Subject information */
subject = comp_subject (method, comp);
- /* From address */
- from = comp_from (method, comp);
-
composer = e_msg_composer_new ();
table = e_msg_composer_get_header_table (composer);
+ setup_from (method, send_comp, table);
e_composer_header_table_set_subject (table, subject);
- e_composer_header_table_set_account_name (table, from);
e_composer_header_table_set_destinations_to (table, destinations);
e_destination_freev (destinations);
@@ -1488,7 +1502,6 @@ reply_to_calendar_comp (ECalComponentItipMethod method,
g_list_free (users);
}
- g_free (from);
g_free (subject);
g_free (ical_string);
return retval;
diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c
index 33972e1222..81055d1ab0 100644
--- a/mail/em-composer-utils.c
+++ b/mail/em-composer-utils.c
@@ -1844,19 +1844,6 @@ reply_get_composer (CamelMimeMessage *message, EAccount *account,
}
static EAccount *
-guess_account_folder(CamelFolder *folder)
-{
- EAccount *account;
- gchar *tmp;
-
- tmp = camel_url_to_string(CAMEL_SERVICE(folder->parent_store)->url, CAMEL_URL_HIDE_ALL);
- account = mail_config_get_account_by_source_url(tmp);
- g_free(tmp);
-
- return account;
-}
-
-static EAccount *
guess_account (CamelMimeMessage *message, CamelFolder *folder)
{
GHashTable *account_hash = NULL;
@@ -1868,27 +1855,10 @@ guess_account (CamelMimeMessage *message, CamelFolder *folder)
CAMEL_RECIPIENT_TYPE_CC
};
- /* check for newsgroup header */
- if (folder
- && camel_medium_get_header((CamelMedium *)message, "Newsgroups")
- && (account = guess_account_folder(folder)))
+ account = em_utils_guess_account (message, folder);
+ if (account)
return account;
- /* check for source folder */
- if (folder) {
- account = guess_account_folder(folder);
- if (account)
- return account;
- }
-
- /* then message source */
- if (account == NULL
- && (tmp = camel_mime_message_get_source(message))) {
- account = mail_config_get_account_by_source_url(tmp);
- if (account)
- return account;
- }
-
/* finally recipient (to/cc) in account table */
account_hash = generate_account_hash ();
for (j=0;account == NULL && j<2;j++) {
diff --git a/mail/em-utils.c b/mail/em-utils.c
index 79b11bc031..6198fbde40 100644
--- a/mail/em-utils.c
+++ b/mail/em-utils.c
@@ -2254,3 +2254,41 @@ em_utils_url_unescape_amp (const gchar *url)
return buff;
}
+
+static EAccount *
+guess_account_folder (CamelFolder *folder)
+{
+ EAccount *account;
+ gchar *tmp;
+
+ tmp = camel_url_to_string (CAMEL_SERVICE (folder->parent_store)->url, CAMEL_URL_HIDE_ALL);
+ account = mail_config_get_account_by_source_url (tmp);
+ g_free (tmp);
+
+ return account;
+}
+
+EAccount *
+em_utils_guess_account (CamelMimeMessage *message, CamelFolder *folder)
+{
+ EAccount *account = NULL;
+ const gchar *tmp;
+
+ /* check for newsgroup header */
+ if (folder
+ && camel_medium_get_header ((CamelMedium *)message, "Newsgroups")
+ && (account = guess_account_folder (folder)))
+ return account;
+
+ /* check for source folder */
+ if (folder)
+ account = guess_account_folder (folder);
+
+ /* then message source */
+ if (account == NULL
+ && (tmp = camel_mime_message_get_source (message))) {
+ account = mail_config_get_account_by_source_url (tmp);
+ }
+
+ return account;
+}
diff --git a/mail/em-utils.h b/mail/em-utils.h
index 0c6a00bf6c..09a1a5dee0 100644
--- a/mail/em-utils.h
+++ b/mail/em-utils.h
@@ -110,6 +110,8 @@ void em_utils_clear_get_password_canceled_accounts_flag (void);
/* Unescapes &amp; back to a real & in URIs */
gchar *em_utils_url_unescape_amp (const gchar *url);
+struct _EAccount *em_utils_guess_account (CamelMimeMessage *message, CamelFolder *folder);
+
G_END_DECLS
#endif /* __EM_UTILS_H__ */
diff --git a/plugins/itip-formatter/itip-formatter.c b/plugins/itip-formatter/itip-formatter.c
index a0daa6f156..250bbef2d6 100644
--- a/plugins/itip-formatter/itip-formatter.c
+++ b/plugins/itip-formatter/itip-formatter.c
@@ -233,9 +233,20 @@ find_to_address (struct _itip_puri *pitip, icalcomponent *ical_comp, icalparamet
it = e_list_get_iterator((EList *)pitip->accounts);
- /* Look through the list of attendees to find the user's address */
+ if (!pitip->to_address && pitip->msg) {
+ EAccount *account = em_utils_guess_account (pitip->msg, pitip->folder);
+
+ if (account) {
+ pitip->to_address = g_strdup (e_account_get_string (account, E_ACCOUNT_ID_ADDRESS));
+ if (pitip->to_address && !*pitip->to_address) {
+ g_free (pitip->to_address);
+ pitip->to_address = NULL;
+ }
+ }
+ }
- if (!pitip->my_address)
+ /* Look through the list of attendees to find the user's address */
+ if (!pitip->to_address)
while (e_iterator_is_valid(it)) {
const EAccount *account = e_iterator_get(it);
icalproperty *prop = NULL;
@@ -290,8 +301,7 @@ find_to_address (struct _itip_puri *pitip, icalcomponent *ical_comp, icalparamet
* previous loop, but it would hurt the performance for all providers in
* general. Hence, we choose to iterate through the accounts list again.
*/
-
- if (!pitip->my_address)
+ if (!pitip->to_address)
while (e_iterator_is_valid(it)) {
const EAccount *account = e_iterator_get(it);
icalproperty *prop = NULL;
@@ -1923,7 +1933,6 @@ view_response_cb (GtkWidget *widget, ItipViewResponse response, gpointer data)
}
if (!save_schedules && pitip->delete_message) {
- g_message ("Deleting!");
camel_folder_delete_message (pitip->folder, pitip->uid);
}
@@ -2509,14 +2518,12 @@ source_selection_changed (ESourceSelector *selector, gpointer data)
GSList *groups;
/* first we clear all the completion flags from all sources */
- g_message ("Clearing selection");
for (groups = e_source_list_peek_groups (source_list); groups; groups = groups->next) {
ESourceGroup *group = E_SOURCE_GROUP (groups->data);
GSList *sources;
for (sources = e_source_group_peek_sources (group); sources; sources = sources->next) {
ESource *source = E_SOURCE (sources->data);
- g_message ("Unsetting for %s", e_source_peek_name (source));
e_source_set_property (source, "conflict", NULL);
}
}
@@ -2525,7 +2532,6 @@ source_selection_changed (ESourceSelector *selector, gpointer data)
property on those sources */
selection = e_source_selector_get_selection (selector);
for (l = selection; l; l = l->next) {
- g_message ("Setting for %s", e_source_peek_name (E_SOURCE (l->data)));
e_source_set_property (E_SOURCE (l->data), "conflict", "true");
}
e_source_selector_free_selection (selection);
diff --git a/plugins/itip-formatter/itip-view.c b/plugins/itip-formatter/itip-view.c
index a5505597a0..648d35e349 100644
--- a/plugins/itip-formatter/itip-view.c
+++ b/plugins/itip-formatter/itip-view.c
@@ -774,7 +774,6 @@ button_clicked_cb (GtkWidget *widget, gpointer data)
response = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), DATA_RESPONSE_KEY));
- g_message ("Response %d", response);
g_signal_emit (G_OBJECT (data), signals[RESPONSE], 0, response);
}