[evolution] Bug 777208 - Show mail aliases in Send account override
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] Bug 777208 - Show mail aliases in Send account override
- Date: Tue, 17 Jan 2017 12:44:15 +0000 (UTC)
commit e19333671512f5e2d7e5b151191bf34d8329661a
Author: Milan Crha <mcrha redhat com>
Date: Tue Jan 17 13:44:37 2017 +0100
Bug 777208 - Show mail aliases in Send account override
src/composer/e-msg-composer.c | 10 +-
src/composer/e-msg-composer.h | 4 +
src/e-util/e-mail-identity-combo-box.c | 34 ++--
src/e-util/e-mail-identity-combo-box.h | 8 +
src/mail/e-mail-send-account-override.c | 212 +++++++++++++++++++---
src/mail/e-mail-send-account-override.h | 26 ++-
src/mail/em-composer-utils.c | 55 ++++--
src/mail/em-composer-utils.h | 4 +-
src/mail/em-folder-properties.c | 26 ++-
src/modules/composer-autosave/e-autosave-utils.c | 2 +-
src/modules/mail/em-composer-prefs.c | 36 +++-
11 files changed, 324 insertions(+), 93 deletions(-)
---
diff --git a/src/composer/e-msg-composer.c b/src/composer/e-msg-composer.c
index 3ac6eff..eae514c 100644
--- a/src/composer/e-msg-composer.c
+++ b/src/composer/e-msg-composer.c
@@ -3525,6 +3525,8 @@ composer_add_auto_recipients (ESource *source,
* @message: The message to use as the source
* @keep_signature: Keep message signature, if any
* @override_identity_uid: (allow none): Optional identity UID to use, or %NULL
+ * @override_alias_name: (nullable): an alias name to use together with the override_identity_uid, or %NULL
+ * @override_alias_address: (nullable): an alias address to use together with the override_identity_uid, or
%NULL
* @cancellable: optional #GCancellable object, or %NULL
*
* Sets up the message @composer with a specific @message.
@@ -3538,6 +3540,8 @@ e_msg_composer_setup_with_message (EMsgComposer *composer,
CamelMimeMessage *message,
gboolean keep_signature,
const gchar *override_identity_uid,
+ const gchar *override_alias_name,
+ const gchar *override_alias_address,
GCancellable *cancellable)
{
CamelInternetAddress *from, *to, *cc, *bcc;
@@ -3923,6 +3927,8 @@ e_msg_composer_setup_with_message (EMsgComposer *composer,
* @composer: an #EMsgComposer
* @message: The message to use as the source
* @identity_uid: (nullable): an identity UID to use, if any
+ * @alias_name: (nullable): an alias name to use together with the identity_uid, or %NULL
+ * @alias_address: (nullable): an alias address to use together with the identity_uid, or %NULL
* @cancellable: an optional #GCancellable
*
* Sets up the message @composer as a redirect of the @message.
@@ -3933,6 +3939,8 @@ void
e_msg_composer_setup_redirect (EMsgComposer *composer,
CamelMimeMessage *message,
const gchar *identity_uid,
+ const gchar *alias_name,
+ const gchar *alias_address,
GCancellable *cancellable)
{
EComposerHeaderTable *table;
@@ -3943,7 +3951,7 @@ e_msg_composer_setup_redirect (EMsgComposer *composer,
g_return_if_fail (E_IS_MSG_COMPOSER (composer));
g_return_if_fail (CAMEL_IS_MIME_MESSAGE (message));
- e_msg_composer_setup_with_message (composer, message, TRUE, identity_uid, cancellable);
+ e_msg_composer_setup_with_message (composer, message, TRUE, identity_uid, alias_name, alias_address,
cancellable);
table = e_msg_composer_get_header_table (composer);
subject = camel_mime_message_get_subject (message);
diff --git a/src/composer/e-msg-composer.h b/src/composer/e-msg-composer.h
index c0986a5..4625171 100644
--- a/src/composer/e-msg-composer.h
+++ b/src/composer/e-msg-composer.h
@@ -91,12 +91,16 @@ void e_msg_composer_setup_with_message
CamelMimeMessage *message,
gboolean keep_signature,
const gchar *override_identity_uid,
+ const gchar *override_alias_name,
+ const gchar *override_alias_address,
GCancellable *cancellable);
void e_msg_composer_setup_from_url (EMsgComposer *composer,
const gchar *url);
void e_msg_composer_setup_redirect (EMsgComposer *composer,
CamelMimeMessage *message,
const gchar *identity_uid,
+ const gchar *alias_name,
+ const gchar *alias_address,
GCancellable *cancellable);
EHTMLEditor * e_msg_composer_get_editor (EMsgComposer *composer);
EFocusTracker * e_msg_composer_get_focus_tracker
diff --git a/src/e-util/e-mail-identity-combo-box.c b/src/e-util/e-mail-identity-combo-box.c
index eed26b6..7c686c6 100644
--- a/src/e-util/e-mail-identity-combo-box.c
+++ b/src/e-util/e-mail-identity-combo-box.c
@@ -60,14 +60,6 @@ enum {
PROP_REGISTRY
};
-enum {
- COLUMN_DISPLAY_NAME,
- COLUMN_COMBO_ID,
- COLUMN_UID,
- COLUMN_NAME,
- COLUMN_ADDRESS
-};
-
G_DEFINE_TYPE (
EMailIdentityComboBox,
e_mail_identity_combo_box,
@@ -287,13 +279,13 @@ mail_identity_combo_box_constructed (GObject *object)
list_store = gtk_list_store_new (5, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
G_TYPE_STRING);
gtk_combo_box_set_model (combo_box, GTK_TREE_MODEL (list_store));
- gtk_combo_box_set_id_column (combo_box, COLUMN_COMBO_ID);
+ gtk_combo_box_set_id_column (combo_box, E_MAIL_IDENTITY_COMBO_BOX_COLUMN_COMBO_ID);
g_object_unref (list_store);
cell_renderer = gtk_cell_renderer_text_new ();
gtk_cell_layout_pack_start (cell_layout, cell_renderer, TRUE);
gtk_cell_layout_add_attribute (
- cell_layout, cell_renderer, "text", COLUMN_DISPLAY_NAME);
+ cell_layout, cell_renderer, "text", E_MAIL_IDENTITY_COMBO_BOX_COLUMN_DISPLAY_NAME);
e_mail_identity_combo_box_refresh (E_MAIL_IDENTITY_COMBO_BOX (object));
}
@@ -422,11 +414,11 @@ mail_identity_combo_box_add_address (GtkListStore *list_store,
gtk_list_store_append (list_store, &iter);
gtk_list_store_set (list_store, &iter,
- COLUMN_DISPLAY_NAME, string->str,
- COLUMN_COMBO_ID, is_alias_entry ? alias_id : identity_uid,
- COLUMN_UID, identity_uid,
- COLUMN_NAME, is_alias_entry ? name : NULL,
- COLUMN_ADDRESS, is_alias_entry ? address : NULL,
+ E_MAIL_IDENTITY_COMBO_BOX_COLUMN_DISPLAY_NAME, string->str,
+ E_MAIL_IDENTITY_COMBO_BOX_COLUMN_COMBO_ID, is_alias_entry ? alias_id : identity_uid,
+ E_MAIL_IDENTITY_COMBO_BOX_COLUMN_UID, identity_uid,
+ E_MAIL_IDENTITY_COMBO_BOX_COLUMN_NAME, is_alias_entry ? name : NULL,
+ E_MAIL_IDENTITY_COMBO_BOX_COLUMN_ADDRESS, is_alias_entry ? address : NULL,
-1);
g_string_free (string, TRUE);
@@ -602,9 +594,9 @@ e_mail_identity_combo_box_refresh (EMailIdentityComboBox *combo_box)
gtk_list_store_set (
GTK_LIST_STORE (tree_model), &iter,
- COLUMN_DISPLAY_NAME, _("None"),
- COLUMN_UID, "",
- COLUMN_COMBO_ID, "",
+ E_MAIL_IDENTITY_COMBO_BOX_COLUMN_DISPLAY_NAME, _("None"),
+ E_MAIL_IDENTITY_COMBO_BOX_COLUMN_UID, "",
+ E_MAIL_IDENTITY_COMBO_BOX_COLUMN_COMBO_ID, "",
-1);
}
@@ -765,9 +757,9 @@ e_mail_identity_combo_box_get_active_uid (EMailIdentityComboBox *combo_box,
return FALSE;
gtk_tree_model_get (gtk_combo_box_get_model (GTK_COMBO_BOX (combo_box)), &iter,
- COLUMN_UID, identity_uid,
- COLUMN_NAME, &name,
- COLUMN_ADDRESS, &address,
+ E_MAIL_IDENTITY_COMBO_BOX_COLUMN_UID, identity_uid,
+ E_MAIL_IDENTITY_COMBO_BOX_COLUMN_NAME, &name,
+ E_MAIL_IDENTITY_COMBO_BOX_COLUMN_ADDRESS, &address,
-1);
if (alias_name)
diff --git a/src/e-util/e-mail-identity-combo-box.h b/src/e-util/e-mail-identity-combo-box.h
index 5f704e0..36d75e6 100644
--- a/src/e-util/e-mail-identity-combo-box.h
+++ b/src/e-util/e-mail-identity-combo-box.h
@@ -46,6 +46,14 @@
G_BEGIN_DECLS
+enum {
+ E_MAIL_IDENTITY_COMBO_BOX_COLUMN_DISPLAY_NAME,
+ E_MAIL_IDENTITY_COMBO_BOX_COLUMN_COMBO_ID,
+ E_MAIL_IDENTITY_COMBO_BOX_COLUMN_UID,
+ E_MAIL_IDENTITY_COMBO_BOX_COLUMN_NAME,
+ E_MAIL_IDENTITY_COMBO_BOX_COLUMN_ADDRESS
+};
+
typedef struct _EMailIdentityComboBox EMailIdentityComboBox;
typedef struct _EMailIdentityComboBoxClass EMailIdentityComboBoxClass;
typedef struct _EMailIdentityComboBoxPrivate EMailIdentityComboBoxPrivate;
diff --git a/src/mail/e-mail-send-account-override.c b/src/mail/e-mail-send-account-override.c
index ad73f72..4fa3d49 100644
--- a/src/mail/e-mail-send-account-override.c
+++ b/src/mail/e-mail-send-account-override.c
@@ -30,11 +30,15 @@
(G_TYPE_INSTANCE_GET_PRIVATE \
((obj), E_TYPE_MAIL_SEND_ACCOUNT_OVERRIDE, EMailSendAccountOverridePrivate))
-#define FOLDERS_SECTION "Folders"
-#define RECIPIENTS_SECTION "Recipients"
-#define OPTIONS_SECTION "Options"
+#define FOLDERS_SECTION "Folders"
+#define FOLDERS_ALIAS_NAME_SECTION "Folders-Alias-Name"
+#define FOLDERS_ALIAS_ADDRESS_SECTION "Folders-Alias-Address"
+#define RECIPIENTS_SECTION "Recipients"
+#define RECIPIENTS_ALIAS_NAME_SECTION "Recipients-Alias-Name"
+#define RECIPIENTS_ALIAS_ADDRESS_SECTION "Recipients-Alias-Address"
+#define OPTIONS_SECTION "Options"
-#define OPTION_PREFER_FOLDER "PreferFolder"
+#define OPTION_PREFER_FOLDER "PreferFolder"
struct _EMailSendAccountOverridePrivate {
GKeyFile *key_file;
@@ -105,9 +109,75 @@ e_mail_send_account_override_maybe_save_locked (EMailSendAccountOverride *overri
return e_mail_send_account_override_save_locked (override);
}
+static void
+read_alias_info_locked (EMailSendAccountOverride *override,
+ const gchar *alias_name_section,
+ const gchar *alias_address_section,
+ const gchar *key,
+ gchar **out_alias_name,
+ gchar **out_alias_address)
+{
+ if (out_alias_name) {
+ gchar *alias_name;
+
+ alias_name = g_key_file_get_string (
+ override->priv->key_file, alias_name_section, key, NULL);
+
+ if (alias_name)
+ g_strchomp (alias_name);
+
+ if (alias_name && !*alias_name) {
+ g_free (alias_name);
+ alias_name = NULL;
+ }
+
+ *out_alias_name = alias_name;
+ }
+
+ if (out_alias_address) {
+ gchar *alias_address;
+
+ alias_address = g_key_file_get_string (
+ override->priv->key_file, alias_address_section, key, NULL);
+
+ if (alias_address)
+ g_strchomp (alias_address);
+
+ if (alias_address && !*alias_address) {
+ g_free (alias_address);
+ alias_address = NULL;
+ }
+
+ *out_alias_address = alias_address;
+ }
+}
+
+static void
+write_alias_info_locked (EMailSendAccountOverride *override,
+ const gchar *alias_name_section,
+ const gchar *alias_address_section,
+ const gchar *key,
+ const gchar *alias_name,
+ const gchar *alias_address)
+{
+ if (alias_name && *alias_name) {
+ g_key_file_set_string (override->priv->key_file, alias_name_section, key, alias_name);
+ } else {
+ g_key_file_remove_key (override->priv->key_file, alias_name_section, key, NULL);
+ }
+
+ if (alias_address && *alias_address) {
+ g_key_file_set_string (override->priv->key_file, alias_address_section, key, alias_address);
+ } else {
+ g_key_file_remove_key (override->priv->key_file, alias_address_section, key, NULL);
+ }
+}
+
static gchar *
get_override_for_folder_uri_locked (EMailSendAccountOverride *override,
- const gchar *folder_uri)
+ const gchar *folder_uri,
+ gchar **out_alias_name,
+ gchar **out_alias_address)
{
gchar *account_uid;
@@ -125,6 +195,15 @@ get_override_for_folder_uri_locked (EMailSendAccountOverride *override,
account_uid = NULL;
}
+ if (account_uid) {
+ read_alias_info_locked (override,
+ FOLDERS_ALIAS_NAME_SECTION,
+ FOLDERS_ALIAS_ADDRESS_SECTION,
+ folder_uri,
+ out_alias_name,
+ out_alias_address);
+ }
+
return account_uid;
}
@@ -132,12 +211,14 @@ static gchar *
test_one_recipient (gchar **keys,
GPtrArray *values,
const gchar *name,
- const gchar *address)
+ const gchar *address,
+ gint *out_keys_index)
{
gint ii;
g_return_val_if_fail (keys != NULL, NULL);
g_return_val_if_fail (values != NULL, NULL);
+ g_return_val_if_fail (out_keys_index != NULL, NULL);
if (name != NULL && *name == '\0')
name = NULL;
@@ -150,10 +231,14 @@ test_one_recipient (gchar **keys,
for (ii = 0; keys[ii] && ii < values->len; ii++) {
if (name != NULL && e_util_utf8_strstrcase (name, keys[ii]) != NULL) {
+ *out_keys_index = ii;
+
return g_strdup (values->pdata[ii]);
}
if (address != NULL && e_util_utf8_strstrcase (address, keys[ii]) != NULL) {
+ *out_keys_index = ii;
+
return g_strdup (values->pdata[ii]);
}
}
@@ -163,7 +248,9 @@ test_one_recipient (gchar **keys,
static gchar *
get_override_for_recipients_locked (EMailSendAccountOverride *override,
- CamelAddress *recipients)
+ CamelAddress *recipients,
+ gchar **out_alias_name,
+ gchar **out_alias_address)
{
CamelInternetAddress *iaddress;
gchar *account_uid = NULL;
@@ -194,7 +281,9 @@ get_override_for_recipients_locked (EMailSendAccountOverride *override,
const gchar *name, *address;
if (camel_internet_address_get (iaddress, ii, &name, &address)) {
- account_uid = test_one_recipient (keys, values, name, address);
+ gint keys_index = -1;
+
+ account_uid = test_one_recipient (keys, values, name, address, &keys_index);
if (account_uid != NULL)
g_strchomp (account_uid);
@@ -204,8 +293,16 @@ get_override_for_recipients_locked (EMailSendAccountOverride *override,
account_uid = NULL;
}
- if (account_uid != NULL)
+ if (account_uid != NULL) {
+ g_warn_if_fail (keys_index >= 0 && keys_index < g_strv_length (keys));
+ read_alias_info_locked (override,
+ RECIPIENTS_ALIAS_NAME_SECTION,
+ RECIPIENTS_ALIAS_ADDRESS_SECTION,
+ keys[keys_index],
+ out_alias_name,
+ out_alias_address);
break;
+ }
}
}
@@ -218,7 +315,11 @@ get_override_for_recipients_locked (EMailSendAccountOverride *override,
static void
list_overrides_section_for_account_locked (EMailSendAccountOverride *override,
const gchar *account_uid,
+ const gchar *alias_name,
+ const gchar *alias_address,
const gchar *section,
+ const gchar *alias_name_section,
+ const gchar *alias_address_section,
GList **overrides)
{
gchar **keys;
@@ -242,8 +343,20 @@ list_overrides_section_for_account_locked (EMailSendAccountOverride *override,
value = g_key_file_get_string (
override->priv->key_file, section, key, NULL);
- if (g_strcmp0 (value, account_uid) == 0)
- *overrides = g_list_prepend (*overrides, g_strdup (key));
+ if (g_strcmp0 (value, account_uid) == 0) {
+ gchar *stored_alias_name = NULL, *stored_alias_address = NULL;
+
+ read_alias_info_locked (override, alias_name_section, alias_address_section,
+ key, &stored_alias_name, &stored_alias_address);
+
+ if (g_strcmp0 (stored_alias_name, alias_name) == 0 &&
+ g_strcmp0 (stored_alias_address, alias_address) == 0) {
+ *overrides = g_list_prepend (*overrides, g_strdup (key));
+ }
+
+ g_free (stored_alias_name);
+ g_free (stored_alias_address);
+ }
g_free (value);
}
}
@@ -256,6 +369,8 @@ list_overrides_section_for_account_locked (EMailSendAccountOverride *override,
static void
list_overrides_for_account_locked (EMailSendAccountOverride *override,
const gchar *account_uid,
+ const gchar *alias_name,
+ const gchar *alias_address,
GList **folder_overrides,
GList **recipient_overrides)
{
@@ -263,9 +378,12 @@ list_overrides_for_account_locked (EMailSendAccountOverride *override,
return;
list_overrides_section_for_account_locked (
- override, account_uid, FOLDERS_SECTION, folder_overrides);
+ override, account_uid, alias_name, alias_address, FOLDERS_SECTION, FOLDERS_ALIAS_NAME_SECTION,
+ FOLDERS_ALIAS_ADDRESS_SECTION, folder_overrides);
+
list_overrides_section_for_account_locked (
- override, account_uid, RECIPIENTS_SECTION, recipient_overrides);
+ override, account_uid, alias_name, alias_address, RECIPIENTS_SECTION,
RECIPIENTS_ALIAS_NAME_SECTION,
+ RECIPIENTS_ALIAS_ADDRESS_SECTION, recipient_overrides);
}
static void
@@ -473,13 +591,15 @@ e_mail_send_account_override_get_prefer_folder (EMailSendAccountOverride *overri
return override->priv->prefer_folder;
}
-/* free returned pointer with g_free() */
+/* free returned pointers with g_free() */
gchar *
e_mail_send_account_override_get_account_uid (EMailSendAccountOverride *override,
const gchar *folder_uri,
CamelInternetAddress *recipients_to,
CamelInternetAddress *recipients_cc,
- CamelInternetAddress *recipients_bcc)
+ CamelInternetAddress *recipients_bcc,
+ gchar **out_alias_name,
+ gchar **out_alias_address)
{
gchar *account_uid = NULL;
@@ -490,23 +610,23 @@ e_mail_send_account_override_get_account_uid (EMailSendAccountOverride *override
if (override->priv->prefer_folder)
account_uid = get_override_for_folder_uri_locked (
- override, folder_uri);
+ override, folder_uri, out_alias_name, out_alias_address);
if (account_uid == NULL)
account_uid = get_override_for_recipients_locked (
- override, CAMEL_ADDRESS (recipients_to));
+ override, CAMEL_ADDRESS (recipients_to), out_alias_name, out_alias_address);
if (account_uid == NULL)
account_uid = get_override_for_recipients_locked (
- override, CAMEL_ADDRESS (recipients_cc));
+ override, CAMEL_ADDRESS (recipients_cc), out_alias_name, out_alias_address);
if (account_uid == NULL)
account_uid = get_override_for_recipients_locked (
- override, CAMEL_ADDRESS (recipients_bcc));
+ override, CAMEL_ADDRESS (recipients_bcc), out_alias_name, out_alias_address);
if (account_uid == NULL && !override->priv->prefer_folder)
account_uid = get_override_for_folder_uri_locked (
- override, folder_uri);
+ override, folder_uri, out_alias_name, out_alias_address);
g_mutex_unlock (&override->priv->property_lock);
@@ -515,7 +635,9 @@ e_mail_send_account_override_get_account_uid (EMailSendAccountOverride *override
void
e_mail_send_account_override_remove_for_account_uid (EMailSendAccountOverride *override,
- const gchar *account_uid)
+ const gchar *account_uid,
+ const gchar *alias_name,
+ const gchar *alias_address)
{
GList *folders = NULL, *recipients = NULL;
gboolean saved = FALSE;
@@ -526,7 +648,7 @@ e_mail_send_account_override_remove_for_account_uid (EMailSendAccountOverride *o
g_mutex_lock (&override->priv->property_lock);
list_overrides_for_account_locked (
- override, account_uid, &folders, &recipients);
+ override, account_uid, alias_name, alias_address, &folders, &recipients);
if (folders != NULL || recipients != NULL) {
GList *link;
@@ -537,6 +659,9 @@ e_mail_send_account_override_remove_for_account_uid (EMailSendAccountOverride *o
g_key_file_remove_key (
override->priv->key_file,
FOLDERS_SECTION, key, NULL);
+
+ write_alias_info_locked (override, FOLDERS_ALIAS_NAME_SECTION,
+ FOLDERS_ALIAS_ADDRESS_SECTION, key, NULL, NULL);
}
for (link = recipients; link != NULL; link = g_list_next (link)) {
@@ -545,6 +670,9 @@ e_mail_send_account_override_remove_for_account_uid (EMailSendAccountOverride *o
g_key_file_remove_key (
override->priv->key_file,
RECIPIENTS_SECTION, key, NULL);
+
+ write_alias_info_locked (override, RECIPIENTS_ALIAS_NAME_SECTION,
+ RECIPIENTS_ALIAS_ADDRESS_SECTION, key, NULL, NULL);
}
saved = e_mail_send_account_override_maybe_save_locked (override);
@@ -561,7 +689,9 @@ e_mail_send_account_override_remove_for_account_uid (EMailSendAccountOverride *o
gchar *
e_mail_send_account_override_get_for_folder (EMailSendAccountOverride *override,
- const gchar *folder_uri)
+ const gchar *folder_uri,
+ gchar **out_alias_name,
+ gchar **out_alias_address)
{
gchar *account_uid = NULL;
@@ -569,7 +699,7 @@ e_mail_send_account_override_get_for_folder (EMailSendAccountOverride *override,
g_mutex_lock (&override->priv->property_lock);
- account_uid = get_override_for_folder_uri_locked (override, folder_uri);
+ account_uid = get_override_for_folder_uri_locked (override, folder_uri, out_alias_name,
out_alias_address);
g_mutex_unlock (&override->priv->property_lock);
@@ -579,7 +709,9 @@ e_mail_send_account_override_get_for_folder (EMailSendAccountOverride *override,
void
e_mail_send_account_override_set_for_folder (EMailSendAccountOverride *override,
const gchar *folder_uri,
- const gchar *account_uid)
+ const gchar *account_uid,
+ const gchar *alias_name,
+ const gchar *alias_address)
{
gboolean saved;
@@ -592,6 +724,10 @@ e_mail_send_account_override_set_for_folder (EMailSendAccountOverride *override,
g_key_file_set_string (
override->priv->key_file,
FOLDERS_SECTION, folder_uri, account_uid);
+
+ write_alias_info_locked (override, FOLDERS_ALIAS_NAME_SECTION,
+ FOLDERS_ALIAS_ADDRESS_SECTION, folder_uri, alias_name, alias_address);
+
saved = e_mail_send_account_override_maybe_save_locked (override);
g_mutex_unlock (&override->priv->property_lock);
@@ -613,6 +749,10 @@ e_mail_send_account_override_remove_for_folder (EMailSendAccountOverride *overri
g_key_file_remove_key (
override->priv->key_file, FOLDERS_SECTION, folder_uri, NULL);
+
+ write_alias_info_locked (override, FOLDERS_ALIAS_NAME_SECTION,
+ FOLDERS_ALIAS_ADDRESS_SECTION, folder_uri, NULL, NULL);
+
saved = e_mail_send_account_override_maybe_save_locked (override);
g_mutex_unlock (&override->priv->property_lock);
@@ -623,7 +763,9 @@ e_mail_send_account_override_remove_for_folder (EMailSendAccountOverride *overri
gchar *
e_mail_send_account_override_get_for_recipient (EMailSendAccountOverride *override,
- CamelInternetAddress *recipients)
+ CamelInternetAddress *recipients,
+ gchar **out_alias_name,
+ gchar **out_alias_address)
{
gchar *account_uid;
@@ -633,7 +775,7 @@ e_mail_send_account_override_get_for_recipient (EMailSendAccountOverride *overri
g_mutex_lock (&override->priv->property_lock);
account_uid = get_override_for_recipients_locked (
- override, CAMEL_ADDRESS (recipients));
+ override, CAMEL_ADDRESS (recipients), out_alias_name, out_alias_address);
g_mutex_unlock (&override->priv->property_lock);
@@ -643,7 +785,9 @@ e_mail_send_account_override_get_for_recipient (EMailSendAccountOverride *overri
void
e_mail_send_account_override_set_for_recipient (EMailSendAccountOverride *override,
const gchar *recipient,
- const gchar *account_uid)
+ const gchar *account_uid,
+ const gchar *alias_name,
+ const gchar *alias_address)
{
gboolean saved;
@@ -656,6 +800,10 @@ e_mail_send_account_override_set_for_recipient (EMailSendAccountOverride *overri
g_key_file_set_string (
override->priv->key_file,
RECIPIENTS_SECTION, recipient, account_uid);
+
+ write_alias_info_locked (override, RECIPIENTS_ALIAS_NAME_SECTION,
+ RECIPIENTS_ALIAS_ADDRESS_SECTION, recipient, alias_name, alias_address);
+
saved = e_mail_send_account_override_maybe_save_locked (override);
g_mutex_unlock (&override->priv->property_lock);
@@ -677,6 +825,10 @@ e_mail_send_account_override_remove_for_recipient (EMailSendAccountOverride *ove
g_key_file_remove_key (
override->priv->key_file, RECIPIENTS_SECTION, recipient, NULL);
+
+ write_alias_info_locked (override, RECIPIENTS_ALIAS_NAME_SECTION,
+ RECIPIENTS_ALIAS_ADDRESS_SECTION, recipient, NULL, NULL);
+
saved = e_mail_send_account_override_maybe_save_locked (override);
g_mutex_unlock (&override->priv->property_lock);
@@ -688,6 +840,8 @@ e_mail_send_account_override_remove_for_recipient (EMailSendAccountOverride *ove
void
e_mail_send_account_override_list_for_account (EMailSendAccountOverride *override,
const gchar *account_uid,
+ const gchar *alias_name,
+ const gchar *alias_address,
GList **folder_overrides,
GList **recipient_overrides)
{
@@ -697,7 +851,7 @@ e_mail_send_account_override_list_for_account (EMailSendAccountOverride *overrid
g_mutex_lock (&override->priv->property_lock);
list_overrides_for_account_locked (
- override, account_uid, folder_overrides, recipient_overrides);
+ override, account_uid, alias_name, alias_address, folder_overrides, recipient_overrides);
g_mutex_unlock (&override->priv->property_lock);
}
diff --git a/src/mail/e-mail-send-account-override.h b/src/mail/e-mail-send-account-override.h
index 2f1515e..e5ef0d6 100644
--- a/src/mail/e-mail-send-account-override.h
+++ b/src/mail/e-mail-send-account-override.h
@@ -81,33 +81,47 @@ gchar * e_mail_send_account_override_get_account_uid
const gchar *folder_uri,
CamelInternetAddress *recipients_to,
CamelInternetAddress *recipients_cc,
- CamelInternetAddress *recipients_bcc);
+ CamelInternetAddress *recipients_bcc,
+ gchar **out_alias_name,
+ gchar **out_alias_address);
void e_mail_send_account_override_remove_for_account_uid
(EMailSendAccountOverride *override,
- const gchar *account_uid);
+ const gchar *account_uid,
+ const gchar *alias_name,
+ const gchar *alias_address);
gchar * e_mail_send_account_override_get_for_folder
(EMailSendAccountOverride *override,
- const gchar *folder_uri);
+ const gchar *folder_uri,
+ gchar **out_alias_name,
+ gchar **out_alias_address);
void e_mail_send_account_override_set_for_folder
(EMailSendAccountOverride *override,
const gchar *folder_uri,
- const gchar *account_uid);
+ const gchar *account_uid,
+ const gchar *alias_name,
+ const gchar *alias_address);
void e_mail_send_account_override_remove_for_folder
(EMailSendAccountOverride *override,
const gchar *folder_uri);
gchar * e_mail_send_account_override_get_for_recipient
(EMailSendAccountOverride *override,
- CamelInternetAddress *recipients);
+ CamelInternetAddress *recipients,
+ gchar **out_alias_name,
+ gchar **out_alias_address);
void e_mail_send_account_override_set_for_recipient
(EMailSendAccountOverride *override,
const gchar *recipient,
- const gchar *account_uid);
+ const gchar *account_uid,
+ const gchar *alias_name,
+ const gchar *alias_address);
void e_mail_send_account_override_remove_for_recipient
(EMailSendAccountOverride *override,
const gchar *recipient);
void e_mail_send_account_override_list_for_account
(EMailSendAccountOverride *override,
const gchar *account_uid,
+ const gchar *alias_name,
+ const gchar *alias_address,
GList **folder_overrides,
GList **recipient_overrides);
void e_mail_send_account_override_freeze_save
diff --git a/src/mail/em-composer-utils.c b/src/mail/em-composer-utils.c
index 26a1d35..04ab716 100644
--- a/src/mail/em-composer-utils.c
+++ b/src/mail/em-composer-utils.c
@@ -1827,7 +1827,7 @@ em_utils_edit_message (EMsgComposer *composer,
gboolean folder_is_drafts;
gboolean folder_is_outbox;
gboolean folder_is_templates;
- gchar *override_identity_uid = NULL;
+ gchar *override_identity_uid = NULL, *override_alias_name = NULL, *override_alias_address = NULL;
g_return_if_fail (E_IS_MSG_COMPOSER (composer));
g_return_if_fail (CAMEL_IS_MIME_MESSAGE (message));
@@ -1886,7 +1886,7 @@ em_utils_edit_message (EMsgComposer *composer,
}
}
- source = em_utils_check_send_account_override (e_msg_composer_get_shell (composer), message,
folder);
+ source = em_utils_check_send_account_override (e_msg_composer_get_shell (composer), message,
folder, &override_alias_name, &override_alias_address);
if (source) {
g_free (override_identity_uid);
override_identity_uid = e_source_dup_uid (source);
@@ -1894,9 +1894,11 @@ em_utils_edit_message (EMsgComposer *composer,
}
}
- e_msg_composer_setup_with_message (composer, message, keep_signature, override_identity_uid, NULL);
+ e_msg_composer_setup_with_message (composer, message, keep_signature, override_identity_uid,
override_alias_name, override_alias_address, NULL);
g_free (override_identity_uid);
+ g_free (override_alias_name);
+ g_free (override_alias_address);
/* Override PostTo header only if the folder is a regular folder */
if (folder && !folder_is_sent && !folder_is_drafts && !folder_is_outbox && !folder_is_templates) {
@@ -2372,7 +2374,7 @@ em_utils_redirect_message (EMsgComposer *composer,
ESource *source;
EShell *shell;
CamelMedium *medium;
- gchar *identity_uid = NULL;
+ gchar *identity_uid = NULL, *alias_name = NULL, *alias_address = NULL;
g_return_if_fail (E_IS_MSG_COMPOSER (composer));
g_return_if_fail (CAMEL_IS_MIME_MESSAGE (message));
@@ -2395,19 +2397,21 @@ em_utils_redirect_message (EMsgComposer *composer,
registry = e_shell_get_registry (shell);
/* This returns a new ESource reference. */
- source = em_utils_check_send_account_override (shell, message, NULL);
+ source = em_utils_check_send_account_override (shell, message, NULL, &alias_name, &alias_address);
if (!source)
source = em_utils_guess_mail_identity_with_recipients_and_sort (
- registry, message, NULL, NULL, NULL, NULL, sort_sources_by_ui, shell);
+ registry, message, NULL, NULL, &alias_name, &alias_address, sort_sources_by_ui,
shell);
if (source != NULL) {
identity_uid = e_source_dup_uid (source);
g_object_unref (source);
}
- e_msg_composer_setup_redirect (composer, message, identity_uid, NULL);
+ e_msg_composer_setup_redirect (composer, message, identity_uid, alias_name, alias_address, NULL);
g_free (identity_uid);
+ g_free (alias_name);
+ g_free (alias_address);
gtk_widget_show (GTK_WIDGET (composer));
@@ -3361,7 +3365,7 @@ em_utils_reply_to_message (EMsgComposer *composer,
registry = e_shell_get_registry (shell);
/* This returns a new ESource reference. */
- source = em_utils_check_send_account_override (shell, message, folder);
+ source = em_utils_check_send_account_override (shell, message, folder, &identity_name,
&identity_address);
if (!source)
source = em_utils_guess_mail_identity_with_recipients_and_sort (
registry, message, folder, message_uid, &identity_name, &identity_address,
sort_sources_by_ui, shell);
@@ -3627,12 +3631,14 @@ em_configure_new_composer (EMsgComposer *composer,
ESource *
em_utils_check_send_account_override (EShell *shell,
CamelMimeMessage *message,
- CamelFolder *folder)
+ CamelFolder *folder,
+ gchar **out_alias_name,
+ gchar **out_alias_address)
{
EMailBackend *mail_backend;
EMailSendAccountOverride *account_override;
CamelInternetAddress *to = NULL, *cc = NULL, *bcc = NULL;
- gchar *folder_uri = NULL, *account_uid;
+ gchar *folder_uri = NULL, *account_uid, *alias_name = NULL, *alias_address = NULL;
ESource *account_source = NULL;
ESourceRegistry *source_registry;
@@ -3655,7 +3661,7 @@ em_utils_check_send_account_override (EShell *shell,
source_registry = e_shell_get_registry (shell);
account_override = e_mail_backend_get_send_account_override (mail_backend);
- account_uid = e_mail_send_account_override_get_account_uid (account_override, folder_uri, to, cc,
bcc);
+ account_uid = e_mail_send_account_override_get_account_uid (account_override, folder_uri, to, cc,
bcc, &alias_name, &alias_address);
while (account_uid) {
account_source = e_source_registry_ref_source (source_registry, account_uid);
@@ -3664,12 +3670,28 @@ em_utils_check_send_account_override (EShell *shell,
/* stored send account override settings contain a reference
* to a dropped account, thus cleanup it now */
- e_mail_send_account_override_remove_for_account_uid (account_override, account_uid);
+ e_mail_send_account_override_remove_for_account_uid (account_override, account_uid,
alias_name, alias_address);
g_free (account_uid);
- account_uid = e_mail_send_account_override_get_account_uid (account_override, folder_uri, to,
cc, bcc);
+ g_free (alias_name);
+ g_free (alias_address);
+
+ alias_name = NULL;
+ alias_address = NULL;
+
+ account_uid = e_mail_send_account_override_get_account_uid (account_override, folder_uri, to,
cc, bcc, &alias_name, &alias_address);
}
+ if (out_alias_name)
+ *out_alias_name = alias_name;
+ else
+ g_free (alias_name);
+
+ if (out_alias_address)
+ *out_alias_address = alias_address;
+ else
+ g_free (alias_address);
+
g_free (folder_uri);
g_free (account_uid);
@@ -3684,19 +3706,22 @@ em_utils_apply_send_account_override_to_composer (EMsgComposer *composer,
EComposerHeaderTable *header_table;
EShell *shell;
ESource *source;
+ gchar *alias_name = NULL, *alias_address = NULL;
g_return_if_fail (E_IS_MSG_COMPOSER (composer));
shell = e_msg_composer_get_shell (composer);
message = em_utils_get_composer_recipients_as_message (composer);
- source = em_utils_check_send_account_override (shell, message, folder);
+ source = em_utils_check_send_account_override (shell, message, folder, &alias_name, &alias_address);
g_clear_object (&message);
if (!source)
return;
header_table = e_msg_composer_get_header_table (composer);
- e_composer_header_table_set_identity_uid (header_table, e_source_get_uid (source), NULL, NULL);
+ e_composer_header_table_set_identity_uid (header_table, e_source_get_uid (source), alias_name,
alias_address);
g_object_unref (source);
+ g_free (alias_name);
+ g_free (alias_address);
}
diff --git a/src/mail/em-composer-utils.h b/src/mail/em-composer-utils.h
index 1476bfe..d9035ea 100644
--- a/src/mail/em-composer-utils.h
+++ b/src/mail/em-composer-utils.h
@@ -89,7 +89,9 @@ void em_utils_get_real_folder_uri_and_message_uid
ESource * em_utils_check_send_account_override
(EShell *shell,
CamelMimeMessage *message,
- CamelFolder *folder);
+ CamelFolder *folder,
+ gchar **out_alias_name,
+ gchar **out_alias_address);
void em_utils_apply_send_account_override_to_composer
(EMsgComposer *composer,
CamelFolder *folder);
diff --git a/src/mail/em-folder-properties.c b/src/mail/em-folder-properties.c
index 7bea11b..f06aa7e 100644
--- a/src/mail/em-folder-properties.c
+++ b/src/mail/em-folder-properties.c
@@ -89,7 +89,8 @@ static void
mail_identity_combo_box_changed_cb (GtkComboBox *combo_box,
EMailSendAccountOverride *account_override)
{
- const gchar *active_id, *folder_uri;
+ const gchar *folder_uri;
+ gchar *identity_uid = NULL, *alias_name = NULL, *alias_address = NULL;
g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
g_return_if_fail (E_IS_MAIL_SEND_ACCOUNT_OVERRIDE (account_override));
@@ -97,11 +98,17 @@ mail_identity_combo_box_changed_cb (GtkComboBox *combo_box,
folder_uri = g_object_get_data (G_OBJECT (combo_box), "sao-folder-uri");
g_return_if_fail (folder_uri != NULL);
- active_id = gtk_combo_box_get_active_id (combo_box);
- if (!active_id || !*active_id)
+ if (!e_mail_identity_combo_box_get_active_uid (E_MAIL_IDENTITY_COMBO_BOX (combo_box),
+ &identity_uid, &alias_name, &alias_address) ||
+ !identity_uid || !*identity_uid) {
e_mail_send_account_override_remove_for_folder (account_override, folder_uri);
- else
- e_mail_send_account_override_set_for_folder (account_override, folder_uri, active_id);
+ } else {
+ e_mail_send_account_override_set_for_folder (account_override, folder_uri, identity_uid,
alias_name, alias_address);
+ }
+
+ g_free (identity_uid);
+ g_free (alias_name);
+ g_free (alias_address);
}
static gint
@@ -213,7 +220,7 @@ emfp_get_folder_item (EConfig *ec,
EShell *shell;
EMailBackend *mail_backend;
EMailSendAccountOverride *account_override;
- gchar *folder_uri, *account_uid;
+ gchar *folder_uri, *account_uid, *alias_name = NULL, *alias_address = NULL;
GtkWidget *label;
if (old)
@@ -401,6 +408,7 @@ emfp_get_folder_item (EConfig *ec,
E_TYPE_MAIL_IDENTITY_COMBO_BOX,
"registry", registry,
"allow-none", TRUE,
+ "allow-aliases", TRUE,
NULL);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
gtk_widget_set_margin_left (widget, 12);
@@ -417,9 +425,11 @@ emfp_get_folder_item (EConfig *ec,
account_override = e_mail_backend_get_send_account_override (mail_backend);
folder_uri = e_mail_folder_uri_from_folder (context->folder);
- account_uid = e_mail_send_account_override_get_for_folder (account_override, folder_uri);
+ account_uid = e_mail_send_account_override_get_for_folder (account_override, folder_uri, &alias_name,
&alias_address);
+
+ if (!account_uid || !e_mail_identity_combo_box_set_active_uid (E_MAIL_IDENTITY_COMBO_BOX (widget),
account_uid, alias_name, alias_address))
+ gtk_combo_box_set_active_id (GTK_COMBO_BOX (widget), account_uid ? account_uid : "");
- gtk_combo_box_set_active_id (GTK_COMBO_BOX (widget), account_uid ? account_uid : "");
g_object_set_data_full (G_OBJECT (widget), "sao-folder-uri", folder_uri, g_free);
g_signal_connect (
diff --git a/src/modules/composer-autosave/e-autosave-utils.c
b/src/modules/composer-autosave/e-autosave-utils.c
index 4fc6234..e4e307a 100644
--- a/src/modules/composer-autosave/e-autosave-utils.c
+++ b/src/modules/composer-autosave/e-autosave-utils.c
@@ -135,7 +135,7 @@ autosave_composer_created_cb (GObject *source_object,
g_warning ("%s: Failed to create msg composer: %s", G_STRFUNC, error->message);
g_simple_async_result_take_error (ccd->simple, error);
} else {
- e_msg_composer_setup_with_message (composer, ccd->message, TRUE, NULL, NULL);
+ e_msg_composer_setup_with_message (composer, ccd->message, TRUE, NULL, NULL, NULL, NULL);
g_object_set_data_full (
G_OBJECT (composer),
SNAPSHOT_FILE_KEY, g_object_ref (ccd->snapshot_file),
diff --git a/src/modules/mail/em-composer-prefs.c b/src/modules/mail/em-composer-prefs.c
index ed073b3..c393b07 100644
--- a/src/modules/mail/em-composer-prefs.c
+++ b/src/modules/mail/em-composer-prefs.c
@@ -174,7 +174,9 @@ spell_setup (EMComposerPrefs *prefs)
#define MAIL_CAMEL_SESSION_KEY "sao-mail-camel-session"
static gchar *
-sao_dup_account_uid (GtkBuilder *builder)
+sao_dup_account_uid (GtkBuilder *builder,
+ gchar **out_alias_name,
+ gchar **out_alias_address)
{
GtkWidget *widget;
GtkTreeView *tree_view;
@@ -192,7 +194,11 @@ sao_dup_account_uid (GtkBuilder *builder)
if (!gtk_tree_selection_get_selected (selection, &model, &iter))
return NULL;
- gtk_tree_model_get (model, &iter, 1, &account_uid, -1);
+ gtk_tree_model_get (model, &iter,
+ E_MAIL_IDENTITY_COMBO_BOX_COLUMN_UID, &account_uid,
+ E_MAIL_IDENTITY_COMBO_BOX_COLUMN_NAME, out_alias_name,
+ E_MAIL_IDENTITY_COMBO_BOX_COLUMN_ADDRESS, out_alias_address,
+ -1);
return account_uid;
}
@@ -267,9 +273,9 @@ sao_account_treeview_selection_changed_cb (GtkTreeSelection *selection,
gtk_list_store_clear (GTK_LIST_STORE (model));
if (gtk_tree_selection_get_selected (selection, NULL, NULL)) {
- gchar *account_uid;
+ gchar *account_uid, *alias_name = NULL, *alias_address = NULL;
- account_uid = sao_dup_account_uid (builder);
+ account_uid = sao_dup_account_uid (builder, &alias_name, &alias_address);
if (account_uid) {
GList *folder_overrides = NULL;
GList *recipient_overrides = NULL;
@@ -280,7 +286,7 @@ sao_account_treeview_selection_changed_cb (GtkTreeSelection *selection,
g_object_get_data (
G_OBJECT (builder),
MAIL_SEND_ACCOUNT_OVERRIDE_KEY),
- account_uid, &folder_overrides, &recipient_overrides);
+ account_uid, alias_name, alias_address, &folder_overrides,
&recipient_overrides);
sao_fill_overrides (
builder, "sao-folders-treeview",
@@ -292,6 +298,8 @@ sao_account_treeview_selection_changed_cb (GtkTreeSelection *selection,
g_list_free_full (folder_overrides, g_free);
g_list_free_full (recipient_overrides, g_free);
g_free (account_uid);
+ g_free (alias_name);
+ g_free (alias_address);
}
}
@@ -390,12 +398,12 @@ sao_folders_add_button_clicked_cb (GtkButton *button,
EMFolderTree *folder_tree;
GtkWidget *dialog;
GtkWindow *window;
- gchar *account_uid = NULL;
+ gchar *account_uid, *alias_name = NULL, *alias_address = NULL;
g_return_if_fail (GTK_IS_BUTTON (button));
g_return_if_fail (GTK_IS_BUILDER (builder));
- account_uid = sao_dup_account_uid (builder);
+ account_uid = sao_dup_account_uid (builder, &alias_name, &alias_address);
g_return_if_fail (account_uid != NULL);
widget = e_builder_get_widget (builder, "sao-folders-treeview");
@@ -463,7 +471,7 @@ sao_folders_add_button_clicked_cb (GtkButton *button,
sao_block_changed_handler (builder);
account_override = g_object_get_data (G_OBJECT (builder),
MAIL_SEND_ACCOUNT_OVERRIDE_KEY);
- e_mail_send_account_override_set_for_folder (account_override, uri,
account_uid);
+ e_mail_send_account_override_set_for_folder (account_override, uri,
account_uid, alias_name, alias_address);
sao_unblock_changed_handler (builder);
}
@@ -482,6 +490,8 @@ sao_folders_add_button_clicked_cb (GtkButton *button,
gtk_widget_destroy (dialog);
g_free (account_uid);
+ g_free (alias_name);
+ g_free (alias_address);
}
static void
@@ -565,7 +575,7 @@ sao_recipient_edited_cb (GtkCellRendererText *renderer,
GtkTreePath *path;
GtkTreeModel *model;
GtkTreeIter iter;
- gchar *text, *old_text = NULL, *account_uid;
+ gchar *text, *old_text = NULL, *account_uid, *alias_name = NULL, *alias_address = NULL;
GtkWidget *widget;
g_return_if_fail (path_str != NULL);
@@ -577,7 +587,7 @@ sao_recipient_edited_cb (GtkCellRendererText *renderer,
path = gtk_tree_path_new_from_string (path_str);
g_return_if_fail (path != NULL);
- account_uid = sao_dup_account_uid (builder);
+ account_uid = sao_dup_account_uid (builder, &alias_name, &alias_address);
g_return_if_fail (account_uid != NULL);
model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget));
@@ -617,7 +627,7 @@ sao_recipient_edited_cb (GtkCellRendererText *renderer,
if (is_new) {
gtk_list_store_set (GTK_LIST_STORE (model), &new_iter, 0, text, -1);
- e_mail_send_account_override_set_for_recipient (account_override, text, account_uid);
+ e_mail_send_account_override_set_for_recipient (account_override, text, account_uid,
alias_name, alias_address);
} else {
GtkTreeSelection *selection;
GtkTreePath *path1, *path2;
@@ -641,6 +651,8 @@ sao_recipient_edited_cb (GtkCellRendererText *renderer,
sao_unblock_changed_handler (builder);
g_free (account_uid);
+ g_free (alias_name);
+ g_free (alias_address);
g_free (old_text);
g_free (text);
}
@@ -840,6 +852,8 @@ send_account_override_setup (GtkBuilder *builder,
/* use its model to avoid code duplication */
widget = e_mail_identity_combo_box_new (registry);
+ e_mail_identity_combo_box_set_allow_aliases (E_MAIL_IDENTITY_COMBO_BOX (widget), TRUE);
+
identity_combo_box = g_object_ref_sink (widget);
widget = e_builder_get_widget (builder, "sao-account-treeview");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]