aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2013-06-02 03:21:53 +0800
committerMatthew Barnes <mbarnes@redhat.com>2013-06-02 03:24:37 +0800
commit8d7a5a1b878015001997a817dda092fd62d54f6e (patch)
treef6311ccc3dca06aeb1e3babd6f5d72db4af90307
parent76af649676439392c3e477fd48de49265bc88910 (diff)
downloadgsoc2013-evolution-8d7a5a1b878015001997a817dda092fd62d54f6e.tar
gsoc2013-evolution-8d7a5a1b878015001997a817dda092fd62d54f6e.tar.gz
gsoc2013-evolution-8d7a5a1b878015001997a817dda092fd62d54f6e.tar.bz2
gsoc2013-evolution-8d7a5a1b878015001997a817dda092fd62d54f6e.tar.lz
gsoc2013-evolution-8d7a5a1b878015001997a817dda092fd62d54f6e.tar.xz
gsoc2013-evolution-8d7a5a1b878015001997a817dda092fd62d54f6e.tar.zst
gsoc2013-evolution-8d7a5a1b878015001997a817dda092fd62d54f6e.zip
Add e_composer_header_table_ref_source().
Convenience function that works like e_source_registry_ref_source(), but spares the caller from digging out the ESourceRegistry from the header table.
-rw-r--r--composer/e-composer-header-table.c46
-rw-r--r--composer/e-composer-header-table.h3
-rw-r--r--composer/e-msg-composer.c62
-rw-r--r--doc/reference/evolution-mail-composer/evolution-mail-composer-sections.txt1
-rw-r--r--mail/em-composer-utils.c18
5 files changed, 53 insertions, 77 deletions
diff --git a/composer/e-composer-header-table.c b/composer/e-composer-header-table.c
index 9db77ce891..8c21af1e24 100644
--- a/composer/e-composer-header-table.c
+++ b/composer/e-composer-header-table.c
@@ -454,8 +454,6 @@ composer_header_table_from_changed_cb (EComposerHeaderTable *table)
{
ESource *source = NULL;
ESource *mail_account = NULL;
- EClientCache *client_cache;
- ESourceRegistry *registry;
EComposerHeader *header;
EComposerHeaderType type;
EComposerPostHeader *post_header;
@@ -469,12 +467,9 @@ composer_header_table_from_changed_cb (EComposerHeaderTable *table)
/* Keep "Post-To" and "Reply-To" synchronized with "From" */
- client_cache = e_composer_header_table_ref_client_cache (table);
- registry = e_client_cache_ref_registry (client_cache);
-
uid = e_composer_header_table_get_identity_uid (table);
if (uid != NULL)
- source = e_source_registry_ref_source (registry, uid);
+ source = e_composer_header_table_ref_source (table, uid);
/* Make sure this is really a mail identity source. */
if (source != NULL) {
@@ -539,9 +534,6 @@ composer_header_table_from_changed_cb (EComposerHeaderTable *table)
composer_header_table_setup_post_headers (table);
else
composer_header_table_setup_mail_headers (table);
-
- g_object_unref (client_cache);
- g_object_unref (registry);
}
static void
@@ -1471,3 +1463,39 @@ e_composer_header_table_set_header_visible (EComposerHeaderTable *table,
}
}
}
+
+/**
+ * e_composer_header_table_ref_source:
+ * @table: an #EComposerHeaderTable
+ * @uid: a unique identifier string
+ *
+ * Convenience function that works just like e_source_registry_ref_source(),
+ * but spares the caller from digging out the #ESourceRegistry from @table.
+ *
+ * The returned #ESource is referenced for thread-safety and must be
+ * unreferenced with g_object_unref() when finished with it.
+ *
+ * Returns: an #ESource, or %NULL if no match was found
+ **/
+ESource *
+e_composer_header_table_ref_source (EComposerHeaderTable *table,
+ const gchar *uid)
+{
+ EClientCache *client_cache;
+ ESourceRegistry *registry;
+ ESource *source;
+
+ g_return_val_if_fail (E_IS_COMPOSER_HEADER_TABLE (table), NULL);
+ g_return_val_if_fail (uid != NULL, NULL);
+
+ client_cache = e_composer_header_table_ref_client_cache (table);
+ registry = e_client_cache_ref_registry (client_cache);
+
+ source = e_source_registry_ref_source (registry, uid);
+
+ g_object_unref (client_cache);
+ g_object_unref (registry);
+
+ return source;
+}
+
diff --git a/composer/e-composer-header-table.h b/composer/e-composer-header-table.h
index d48512d3e8..0a7c0d9d6f 100644
--- a/composer/e-composer-header-table.h
+++ b/composer/e-composer-header-table.h
@@ -138,6 +138,9 @@ void e_composer_header_table_set_header_visible
(EComposerHeaderTable *table,
EComposerHeaderType type,
gboolean visible);
+ESource * e_composer_header_table_ref_source
+ (EComposerHeaderTable *table,
+ const gchar *uid);
G_END_DECLS
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index efb29e0b2e..d247180734 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -532,8 +532,6 @@ build_message_headers (EMsgComposer *composer,
{
EComposerHeaderTable *table;
EComposerHeader *header;
- EClientCache *client_cache;
- ESourceRegistry *registry;
ESource *source;
const gchar *subject;
const gchar *reply_to;
@@ -544,11 +542,8 @@ build_message_headers (EMsgComposer *composer,
table = e_msg_composer_get_header_table (composer);
- client_cache = e_composer_header_table_ref_client_cache (table);
- registry = e_client_cache_ref_registry (client_cache);
-
uid = e_composer_header_table_get_identity_uid (table);
- source = e_source_registry_ref_source (registry, uid);
+ source = e_composer_header_table_ref_source (table, uid);
/* Subject: */
subject = e_composer_header_table_get_subject (table);
@@ -660,9 +655,6 @@ build_message_headers (EMsgComposer *composer,
}
g_list_free (list);
}
-
- g_object_unref (client_cache);
- g_object_unref (registry);
}
static CamelCipherHash
@@ -1086,8 +1078,6 @@ composer_build_message (EMsgComposer *composer,
EComposerHeaderTable *table;
CamelDataWrapper *html;
ESourceMailIdentity *mi;
- EClientCache *client_cache;
- ESourceRegistry *registry;
const gchar *extension_name;
const gchar *iconv_charset = NULL;
const gchar *identity_uid;
@@ -1108,15 +1098,8 @@ composer_build_message (EMsgComposer *composer,
view = e_msg_composer_get_attachment_view (composer);
store = e_attachment_view_get_store (view);
- client_cache = e_composer_header_table_ref_client_cache (table);
- registry = e_client_cache_ref_registry (client_cache);
-
identity_uid = e_composer_header_table_get_identity_uid (table);
- source = e_source_registry_ref_source (registry, identity_uid);
-
- g_clear_object (&client_cache);
- g_clear_object (&registry);
-
+ source = e_composer_header_table_ref_source (table, identity_uid);
g_return_if_fail (source != NULL);
/* Do all the non-blocking work here, and defer
@@ -1581,8 +1564,6 @@ msg_composer_mail_identity_changed_cb (EMsgComposer *composer)
{
EMsgComposerPrivate *p = composer->priv;
EMailSignatureComboBox *combo_box;
- EClientCache *client_cache;
- ESourceRegistry *registry;
ESourceMailComposition *mc;
ESourceOpenPGP *pgp;
ESourceSMIME *smime;
@@ -1603,12 +1584,7 @@ msg_composer_mail_identity_changed_cb (EMsgComposer *composer)
if (uid == NULL)
return;
- client_cache = e_composer_header_table_ref_client_cache (table);
- registry = e_client_cache_ref_registry (client_cache);
- source = e_source_registry_ref_source (registry, uid);
- g_clear_object (&client_cache);
- g_clear_object (&registry);
-
+ source = e_composer_header_table_ref_source (table, uid);
g_return_if_fail (source != NULL);
extension_name = E_SOURCE_EXTENSION_MAIL_COMPOSITION;
@@ -3098,8 +3074,6 @@ e_msg_composer_new_with_message (EShell *shell,
EMsgComposer *composer;
EMsgComposerPrivate *priv;
EComposerHeaderTable *table;
- EClientCache *client_cache;
- ESourceRegistry *registry;
ESource *source = NULL;
GtkToggleAction *action;
struct _camel_header_raw *xev;
@@ -3131,9 +3105,6 @@ e_msg_composer_new_with_message (EShell *shell,
postto = NULL;
}
- client_cache = e_composer_header_table_ref_client_cache (table);
- registry = e_client_cache_ref_registry (client_cache);
-
/* Restore the mail identity preference. */
identity_uid = (gchar *) camel_medium_get_header (
CAMEL_MEDIUM (message), "X-Evolution-Identity");
@@ -3144,12 +3115,10 @@ e_msg_composer_new_with_message (EShell *shell,
}
if (identity_uid != NULL) {
identity_uid = g_strstrip (g_strdup (identity_uid));
- source = e_source_registry_ref_source (registry, identity_uid);
+ source = e_composer_header_table_ref_source (
+ table, identity_uid);
}
- g_clear_object (&client_cache);
- g_clear_object (&registry);
-
if (postto == NULL) {
auto_cc = g_hash_table_new_full (
(GHashFunc) camel_strcase_hash,
@@ -4228,8 +4197,6 @@ e_msg_composer_set_body (EMsgComposer *composer,
EMsgComposerPrivate *priv = composer->priv;
EComposerHeaderTable *table;
EWebViewGtkHTML *web_view;
- EClientCache *client_cache;
- ESourceRegistry *registry;
ESource *source;
const gchar *identity_uid;
gchar *buff;
@@ -4238,14 +4205,8 @@ e_msg_composer_set_body (EMsgComposer *composer,
table = e_msg_composer_get_header_table (composer);
- client_cache = e_composer_header_table_ref_client_cache (table);
- registry = e_client_cache_ref_registry (client_cache);
-
identity_uid = e_composer_header_table_get_identity_uid (table);
- source = e_source_registry_ref_source (registry, identity_uid);
-
- g_clear_object (&client_cache);
- g_clear_object (&registry);
+ source = e_composer_header_table_ref_source (table, identity_uid);
buff = g_markup_printf_escaped (
"<b>%s</b>",
@@ -4789,8 +4750,6 @@ e_msg_composer_get_from (EMsgComposer *composer)
CamelInternetAddress *inet_address = NULL;
ESourceMailIdentity *mail_identity;
EComposerHeaderTable *table;
- EClientCache *client_cache;
- ESourceRegistry *registry;
ESource *source;
const gchar *extension_name;
const gchar *uid;
@@ -4801,15 +4760,8 @@ e_msg_composer_get_from (EMsgComposer *composer)
table = e_msg_composer_get_header_table (composer);
- client_cache = e_composer_header_table_ref_client_cache (table);
- registry = e_client_cache_ref_registry (client_cache);
-
uid = e_composer_header_table_get_identity_uid (table);
- source = e_source_registry_ref_source (registry, uid);
-
- g_clear_object (&client_cache);
- g_clear_object (&registry);
-
+ source = e_composer_header_table_ref_source (table, uid);
g_return_val_if_fail (source != NULL, NULL);
extension_name = E_SOURCE_EXTENSION_MAIL_IDENTITY;
diff --git a/doc/reference/evolution-mail-composer/evolution-mail-composer-sections.txt b/doc/reference/evolution-mail-composer/evolution-mail-composer-sections.txt
index 48b12b81ca..4b286f94ec 100644
--- a/doc/reference/evolution-mail-composer/evolution-mail-composer-sections.txt
+++ b/doc/reference/evolution-mail-composer/evolution-mail-composer-sections.txt
@@ -66,6 +66,7 @@ e_composer_header_table_set_signature_uid
e_composer_header_table_get_subject
e_composer_header_table_set_subject
e_composer_header_table_set_header_visible
+e_composer_header_table_ref_source
<SUBSECTION Standard>
E_COMPOSER_HEADER_TABLE
E_IS_COMPOSER_HEADER_TABLE
diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c
index 0927d6fa90..21961ef573 100644
--- a/mail/em-composer-utils.c
+++ b/mail/em-composer-utils.c
@@ -374,13 +374,13 @@ composer_presend_check_identity (EMsgComposer *composer,
table = e_msg_composer_get_header_table (composer);
- client_cache = e_composer_header_table_ref_client_cache (table);
- registry = e_client_cache_ref_registry (client_cache);
-
uid = e_composer_header_table_get_identity_uid (table);
- source = e_source_registry_ref_source (registry, uid);
+ source = e_composer_header_table_ref_source (table, uid);
g_return_val_if_fail (source != NULL, FALSE);
+ client_cache = e_composer_header_table_ref_client_cache (table);
+ registry = e_client_cache_ref_registry (client_cache);
+
if (!e_source_registry_check_enabled (registry, source)) {
e_alert_submit (
E_ALERT_SINK (composer),
@@ -843,8 +843,6 @@ em_utils_composer_save_to_drafts_cb (EMsgComposer *composer,
{
AsyncContext *context;
EComposerHeaderTable *table;
- EClientCache *client_cache;
- ESourceRegistry *registry;
ESource *source;
const gchar *local_drafts_folder_uri;
const gchar *identity_uid;
@@ -858,14 +856,8 @@ em_utils_composer_save_to_drafts_cb (EMsgComposer *composer,
table = e_msg_composer_get_header_table (composer);
- client_cache = e_composer_header_table_ref_client_cache (table);
- registry = e_client_cache_ref_registry (client_cache);
-
identity_uid = e_composer_header_table_get_identity_uid (table);
- source = e_source_registry_ref_source (registry, identity_uid);
-
- g_clear_object (&client_cache);
- g_clear_object (&registry);
+ source = e_composer_header_table_ref_source (table, identity_uid);
/* Get the selected identity's preferred Drafts folder. */
if (source != NULL) {