[evolution/webkit] EMConfigTargetAccount: Add original_account member.
- From: Dan VrÃtil <dvratil src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/webkit] EMConfigTargetAccount: Add original_account member.
- Date: Mon, 11 Jul 2011 14:33:20 +0000 (UTC)
commit ccc3dab0e9427de94d77ff2c8ce33650b9f0a8db
Author: Matthew Barnes <mbarnes redhat com>
Date: Mon May 2 15:34:56 2011 -0400
EMConfigTargetAccount: Add original_account member.
Rename the existing 'account' member to 'modified_account' and add an
'original_account' member so plugins have direct access to both.
Mostly of benefit to the imap-features plugin.
mail/em-account-editor.c | 13 +++++++++----
mail/em-config.c | 29 ++++++++++++++++++++++-------
mail/em-config.h | 8 ++++----
plugins/groupwise-features/proxy.c | 6 +++---
plugins/groupwise-features/send-options.c | 2 +-
plugins/imap-features/imap-headers.c | 26 +++++++++++++++-----------
6 files changed, 54 insertions(+), 30 deletions(-)
---
diff --git a/mail/em-account-editor.c b/mail/em-account-editor.c
index a0083ec..e720fb8 100644
--- a/mail/em-account-editor.c
+++ b/mail/em-account-editor.c
@@ -3885,10 +3885,13 @@ set_provider_defaults_on_url (EMAccountEditor *emae, CamelProvider *provider, Ca
}
static void
-em_account_editor_construct (EMAccountEditor *emae, EMAccountEditorType type, const gchar *id)
+em_account_editor_construct (EMAccountEditor *emae,
+ EMAccountEditorType type,
+ const gchar *id)
{
EMAccountEditorPrivate *priv = emae->priv;
- EAccount *account;
+ EAccount *original_account;
+ EAccount *modified_account;
gint i, index;
GSList *l;
GList *prov;
@@ -3976,8 +3979,10 @@ em_account_editor_construct (EMAccountEditor *emae, EMAccountEditorType type, co
e_config_add_page_check ((EConfig *)ec, NULL, emae_check_complete, emae);
- account = em_account_editor_get_modified_account (emae);
- target = em_config_target_new_account (ec, account);
+ original_account = em_account_editor_get_original_account (emae);
+ modified_account = em_account_editor_get_modified_account (emae);
+ target = em_config_target_new_account (
+ ec, original_account, modified_account);
e_config_set_target ((EConfig *)ec, (EConfigTarget *)target);
}
diff --git a/mail/em-config.c b/mail/em-config.c
index bc1c0e5..e6ed1d5 100644
--- a/mail/em-config.c
+++ b/mail/em-config.c
@@ -83,7 +83,7 @@ em_config_set_target (EConfig *ep,
EMConfig *config = (EMConfig *) ep;
config->priv->account_changed_id = g_signal_connect (
- s->account, "changed",
+ s->modified_account, "changed",
G_CALLBACK(emp_account_changed), ep);
break; }
}
@@ -106,7 +106,7 @@ em_config_target_free (EConfig *ep,
if (config->priv->account_changed_id > 0) {
g_signal_handler_disconnect (
- s->account,
+ s->modified_account,
config->priv->account_changed_id);
config->priv->account_changed_id = 0;
}
@@ -130,7 +130,10 @@ em_config_target_free (EConfig *ep,
case EM_CONFIG_TARGET_ACCOUNT: {
EMConfigTargetAccount *s = (EMConfigTargetAccount *)t;
- g_object_unref (s->account);
+ if (s->original_account != NULL)
+ g_object_unref (s->original_account);
+ if (s->modified_account != NULL)
+ g_object_unref (s->modified_account);
break; }
}
@@ -204,12 +207,24 @@ em_config_target_new_prefs (EMConfig *emp,
}
EMConfigTargetAccount *
-em_config_target_new_account (EMConfig *emp, struct _EAccount *account)
+em_config_target_new_account (EMConfig *emp,
+ EAccount *original_account,
+ EAccount *modified_account)
{
- EMConfigTargetAccount *t = e_config_target_new (&emp->config, EM_CONFIG_TARGET_ACCOUNT, sizeof (*t));
+ EMConfigTargetAccount *t;
- t->account = account;
- g_object_ref (account);
+ t = e_config_target_new (
+ &emp->config, EM_CONFIG_TARGET_ACCOUNT, sizeof (*t));
+
+ if (original_account != NULL)
+ t->original_account = g_object_ref (original_account);
+ else
+ t->original_account = NULL;
+
+ if (modified_account != NULL)
+ t->modified_account = g_object_ref (modified_account);
+ else
+ t->modified_account = NULL;
return t;
}
diff --git a/mail/em-config.h b/mail/em-config.h
index bd39a47..f52dcf8 100644
--- a/mail/em-config.h
+++ b/mail/em-config.h
@@ -64,9 +64,8 @@ struct _EMConfigTargetPrefs {
struct _EMConfigTargetAccount {
EConfigTarget target;
- EAccount *account;
- /* Need also: working account, not just real account, so changes can be propagated around
- And some mechamism for controlling the gui if we're running inside an assistant, e.g. enabling 'next' */
+ EAccount *original_account;
+ EAccount *modified_account;
};
typedef struct _EConfigItem EMConfigItem;
@@ -92,7 +91,8 @@ EMConfigTargetPrefs *
GConfClient *gconf);
EMConfigTargetAccount *
em_config_target_new_account (EMConfig *emp,
- EAccount *account);
+ EAccount *original_account,
+ EAccount *modified_account);
G_END_DECLS
diff --git a/plugins/groupwise-features/proxy.c b/plugins/groupwise-features/proxy.c
index 849d4ea..1db2953 100644
--- a/plugins/groupwise-features/proxy.c
+++ b/plugins/groupwise-features/proxy.c
@@ -519,7 +519,7 @@ proxy_abort (GtkWidget *button, EConfigHookItemFactoryData *data)
proxyDialog *prd = NULL;
target_account = (EMConfigTargetAccount *)data->config->target;
- account = target_account->account;
+ account = target_account->modified_account;
prd = g_object_get_data ((GObject *)account, "prd");
if (!prd || !prd->priv || !prd->priv->proxy_list)
@@ -540,7 +540,7 @@ proxy_commit (GtkWidget *button, EConfigHookItemFactoryData *data)
proxyDialog *prd = NULL;
target_account = (EMConfigTargetAccount *)data->config->target;
- account = target_account->account;
+ account = target_account->modified_account;
prd = g_object_get_data ((GObject *)account, "prd");
/* In case of non-GroupWise preferences edit, "prd" will be NULL. */
@@ -653,7 +653,7 @@ org_gnome_proxy (EPlugin *epl, EConfigHookItemFactoryData *data)
session = e_mail_backend_get_session (E_MAIL_BACKEND (shell_backend));
target_account = (EMConfigTargetAccount *)data->config->target;
- account = target_account->account;
+ account = target_account->modified_account;
/* We are using some g_object_set on this. We shuold also avoid double-free later. So reffing */
g_object_ref (account);
diff --git a/plugins/groupwise-features/send-options.c b/plugins/groupwise-features/send-options.c
index 8b0aa48..1e6ef39 100644
--- a/plugins/groupwise-features/send-options.c
+++ b/plugins/groupwise-features/send-options.c
@@ -201,7 +201,7 @@ org_gnome_send_options (EPlugin *epl, EConfigHookItemFactoryData *data)
gchar *markup;
target_account = (EMConfigTargetAccount *)data->config->target;
- account = target_account->account;
+ account = target_account->modified_account;
if (!g_strrstr (account->source->url, "groupwise://"))
return NULL;
diff --git a/plugins/imap-features/imap-headers.c b/plugins/imap-features/imap-headers.c
index dd4032e..35fbeca 100644
--- a/plugins/imap-features/imap-headers.c
+++ b/plugins/imap-features/imap-headers.c
@@ -76,15 +76,16 @@ void
imap_headers_commit (EPlugin *efp, EConfigHookItemFactoryData *data)
{
EMConfigTargetAccount *target_account;
- EAccount *account;
+ EAccount *original_account;
+ EAccount *modified_account;
gboolean use_imap = g_getenv ("USE_IMAP") != NULL;
target_account = (EMConfigTargetAccount *)data->config->target;
- account = target_account->account;
+ original_account = target_account->original_account;
+ modified_account = target_account->modified_account;
- if (g_str_has_prefix (account->source->url, "imap://") ||
- (use_imap && g_str_has_prefix (account->source->url, "groupwise://"))) {
- EAccount *temp = NULL;
+ if (g_str_has_prefix (modified_account->source->url, "imap://") ||
+ (use_imap && g_str_has_prefix (modified_account->source->url, "groupwise://"))) {
EAccountList *accounts = e_get_account_list ();
CamelURL *url = NULL;
GtkTreeModel *model;
@@ -94,9 +95,9 @@ imap_headers_commit (EPlugin *efp, EConfigHookItemFactoryData *data)
str = g_string_new("");
- temp = e_get_account_by_source_url (account->source->url);
-
- url = camel_url_new (e_account_get_string (account, E_ACCOUNT_SOURCE_URL), NULL);
+ url = camel_url_new (
+ e_account_get_string (
+ modified_account, E_ACCOUNT_SOURCE_URL), NULL);
model = gtk_tree_view_get_model (ui->custom_headers_tree);
if (gtk_tree_model_get_iter_first (model, &iter)) {
@@ -125,10 +126,13 @@ imap_headers_commit (EPlugin *efp, EConfigHookItemFactoryData *data)
camel_url_set_param (url, "basic_headers", NULL);
}
- e_account_set_string (temp, E_ACCOUNT_SOURCE_URL, camel_url_to_string (url, 0));
+ /* FIXME Leaking URL string? */
+ e_account_set_string (
+ original_account, E_ACCOUNT_SOURCE_URL,
+ camel_url_to_string (url, 0));
camel_url_free (url);
g_string_free (str, TRUE);
- e_account_list_change (accounts, temp);
+ e_account_list_change (accounts, original_account);
e_account_list_save (accounts);
}
}
@@ -269,7 +273,7 @@ org_gnome_imap_headers (EPlugin *epl, EConfigHookItemFactoryData *data)
ui = g_new0 (EPImapFeaturesData, 1);
target_account = (EMConfigTargetAccount *)data->config->target;
- account = target_account->account;
+ account = target_account->modified_account;
if (!g_str_has_prefix (account->source->url, "imap://") && !(use_imap && g_str_has_prefix (account->source->url, "groupwise://")))
return NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]