diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2013-10-20 23:15:41 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2013-10-20 23:15:41 +0800 |
commit | 7a6be11ea62647cba65625b2f65b944f22e65288 (patch) | |
tree | 8f41115a00c37265259b35df7c0a7c7d80736f61 /mail | |
parent | 431d7188c500d2879b015a308513e7388be19b00 (diff) | |
download | gsoc2013-evolution-7a6be11ea62647cba65625b2f65b944f22e65288.tar gsoc2013-evolution-7a6be11ea62647cba65625b2f65b944f22e65288.tar.gz gsoc2013-evolution-7a6be11ea62647cba65625b2f65b944f22e65288.tar.bz2 gsoc2013-evolution-7a6be11ea62647cba65625b2f65b944f22e65288.tar.lz gsoc2013-evolution-7a6be11ea62647cba65625b2f65b944f22e65288.tar.xz gsoc2013-evolution-7a6be11ea62647cba65625b2f65b944f22e65288.tar.zst gsoc2013-evolution-7a6be11ea62647cba65625b2f65b944f22e65288.zip |
Miscellaeous cleanups.
Diffstat (limited to 'mail')
-rw-r--r-- | mail/e-mail-display.c | 30 | ||||
-rw-r--r-- | mail/e-mail-send-account-override.c | 686 | ||||
-rw-r--r-- | mail/e-mail-send-account-override.h | 87 | ||||
-rw-r--r-- | mail/em-composer-utils.c | 10 | ||||
-rw-r--r-- | mail/em-folder-properties.c | 8 | ||||
-rw-r--r-- | mail/em-subscription-editor.c | 20 |
6 files changed, 446 insertions, 395 deletions
diff --git a/mail/e-mail-display.c b/mail/e-mail-display.c index d4a0277d56..624e640cb1 100644 --- a/mail/e-mail-display.c +++ b/mail/e-mail-display.c @@ -825,20 +825,24 @@ toggle_address_visibility (WebKitDOMElement *button, static void add_color_css_rule_for_web_view (EWebView *view, - const char *color_name, - const char *color_value) + const gchar *color_name, + const gchar *color_value) { gchar *selector; gchar *style; selector = g_strconcat (".-e-mail-formatter-", color_name, NULL); - if (g_strstr_len (color_name, -1, "header")) - style = g_strconcat ("color: ", color_value, " !important;", NULL); - else if (g_strstr_len (color_name, -1, "frame")) - style = g_strconcat ("border-color: ", color_value, " !important;", NULL); - else - style = g_strconcat ("background-color: ", color_value, " !important;", NULL); + if (g_strstr_len (color_name, -1, "header")) { + style = g_strconcat ( + "color: ", color_value, " !important;", NULL); + } else if (g_strstr_len (color_name, -1, "frame")) { + style = g_strconcat ( + "border-color: ", color_value, " !important;", NULL); + } else { + style = g_strconcat ( + "background-color: ", color_value, " !important;", NULL); + } e_web_view_add_css_rule_into_style_sheet ( view, @@ -854,10 +858,16 @@ static void initialize_web_view_colors (EMailDisplay *display) { EMailFormatter *formatter; - const gchar *color_names [] = { "body-color", "citation-color", - "frame-color", "header-color", NULL }; gint ii; + const gchar *color_names[] = { + "body-color", + "citation-color", + "frame-color", + "header-color", + NULL + }; + formatter = e_mail_display_get_formatter (display); for (ii = 0; color_names[ii]; ii++) { diff --git a/mail/e-mail-send-account-override.c b/mail/e-mail-send-account-override.c index 8af7227439..8f55d2bbdc 100644 --- a/mail/e-mail-send-account-override.c +++ b/mail/e-mail-send-account-override.c @@ -19,15 +19,16 @@ * */ -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif +#include "e-mail-send-account-override.h" +#include <config.h> #include <string.h> #include <libedataserver/libedataserver.h> -#include "e-mail-send-account-override.h" +#define E_MAIL_SEND_ACCOUNT_OVERRIDE_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_MAIL_SEND_ACCOUNT_OVERRIDE, EMailSendAccountOverridePrivate)) #define FOLDERS_SECTION "Folders" #define RECIPIENTS_SECTION "Recipients" @@ -35,8 +36,7 @@ #define OPTION_PREFER_FOLDER "PreferFolder" -struct _EMailSendAccountOverridePrivate -{ +struct _EMailSendAccountOverridePrivate { GKeyFile *key_file; gchar *config_filename; gboolean prefer_folder; @@ -57,142 +57,34 @@ enum { LAST_SIGNAL }; -static gint signals[LAST_SIGNAL]; - -G_DEFINE_TYPE (EMailSendAccountOverride, e_mail_send_account_override, G_TYPE_OBJECT) - -static void -e_mail_send_account_override_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - EMailSendAccountOverride *account_override = E_MAIL_SEND_ACCOUNT_OVERRIDE (object); - - g_return_if_fail (account_override != NULL); - - switch (property_id) { - case PROP_PREFER_FOLDER: - g_value_set_boolean (value, - e_mail_send_account_override_get_prefer_folder (account_override)); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - -static void -e_mail_send_account_override_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - EMailSendAccountOverride *account_override = E_MAIL_SEND_ACCOUNT_OVERRIDE (object); - - g_return_if_fail (account_override != NULL); +static guint signals[LAST_SIGNAL]; - switch (property_id) { - case PROP_PREFER_FOLDER: - e_mail_send_account_override_set_prefer_folder (account_override, - g_value_get_boolean (value)); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - -static void -e_mail_send_account_override_finalize (GObject *object) -{ - EMailSendAccountOverride *account_override = E_MAIL_SEND_ACCOUNT_OVERRIDE (object); - - g_return_if_fail (account_override != NULL); - - if (account_override->priv->key_file) { - g_key_file_free (account_override->priv->key_file); - account_override->priv->key_file = NULL; - } - - if (account_override->priv->config_filename) { - g_free (account_override->priv->config_filename); - account_override->priv->config_filename = NULL; - } - - g_mutex_clear (&account_override->priv->property_lock); - - G_OBJECT_CLASS (e_mail_send_account_override_parent_class)->finalize (object); -} - -static void -e_mail_send_account_override_class_init (EMailSendAccountOverrideClass *klass) -{ - GObjectClass *object_class; - - g_type_class_add_private (klass, sizeof (EMailSendAccountOverridePrivate)); - - object_class = G_OBJECT_CLASS (klass); - object_class->get_property = e_mail_send_account_override_get_property; - object_class->set_property = e_mail_send_account_override_set_property; - object_class->finalize = e_mail_send_account_override_finalize; - - g_object_class_install_property ( - object_class, - PROP_PREFER_FOLDER, - g_param_spec_boolean ( - "prefer-folder", - "Prefer Folder", - NULL, - TRUE, - G_PARAM_READWRITE)); - - signals[CHANGED] = g_signal_new ( - "changed", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EMailSendAccountOverrideClass, changed), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); -} - -static void -e_mail_send_account_override_init (EMailSendAccountOverride *account_override) -{ - account_override->priv = G_TYPE_INSTANCE_GET_PRIVATE (account_override, - E_TYPE_MAIL_SEND_ACCOUNT_OVERRIDE, EMailSendAccountOverridePrivate); - - g_mutex_init (&account_override->priv->property_lock); - account_override->priv->key_file = g_key_file_new (); - account_override->priv->config_filename = NULL; - account_override->priv->prefer_folder = TRUE; - account_override->priv->need_save = FALSE; - account_override->priv->save_frozen = 0; -} +G_DEFINE_TYPE ( + EMailSendAccountOverride, + e_mail_send_account_override, + G_TYPE_OBJECT) static gboolean -e_mail_send_account_override_save_locked (EMailSendAccountOverride *account_override) +e_mail_send_account_override_save_locked (EMailSendAccountOverride *override) { gchar *contents; GError *error = NULL; - g_return_val_if_fail (account_override->priv->key_file != NULL, FALSE); + g_return_val_if_fail (override->priv->key_file != NULL, FALSE); - account_override->priv->need_save = FALSE; + override->priv->need_save = FALSE; - if (!account_override->priv->config_filename) + if (override->priv->config_filename == NULL) return FALSE; - contents = g_key_file_to_data (account_override->priv->key_file, NULL, NULL); - if (!contents) + contents = g_key_file_to_data (override->priv->key_file, NULL, NULL); + if (contents == NULL) return FALSE; - g_file_set_contents (account_override->priv->config_filename, contents, -1, &error); + g_file_set_contents ( + override->priv->config_filename, contents, -1, &error); - if (error) { + if (error != NULL) { g_warning ("%s: %s", G_STRFUNC, error->message); g_clear_error (&error); } @@ -203,31 +95,32 @@ e_mail_send_account_override_save_locked (EMailSendAccountOverride *account_over } static gboolean -e_mail_send_account_override_maybe_save_locked (EMailSendAccountOverride *account_override) +e_mail_send_account_override_maybe_save_locked (EMailSendAccountOverride *override) { - if (account_override->priv->save_frozen) - account_override->priv->need_save = TRUE; - else - return e_mail_send_account_override_save_locked (account_override); + if (override->priv->save_frozen > 0) { + override->priv->need_save = TRUE; + return FALSE; + } - return FALSE; + return e_mail_send_account_override_save_locked (override); } static gchar * -get_override_for_folder_uri_locked (EMailSendAccountOverride *account_override, - const gchar *folder_uri) +get_override_for_folder_uri_locked (EMailSendAccountOverride *override, + const gchar *folder_uri) { gchar *account_uid; - if (!folder_uri || !*folder_uri) + if (folder_uri == NULL || *folder_uri == '\0') return NULL; - account_uid = g_key_file_get_string (account_override->priv->key_file, FOLDERS_SECTION, folder_uri, NULL); + account_uid = g_key_file_get_string ( + override->priv->key_file, FOLDERS_SECTION, folder_uri, NULL); - if (account_uid) + if (account_uid != NULL) g_strchomp (account_uid); - if (account_uid && !*account_uid) { + if (account_uid != NULL && *account_uid == '\0') { g_free (account_uid); account_uid = NULL; } @@ -236,25 +129,31 @@ get_override_for_folder_uri_locked (EMailSendAccountOverride *account_override, } static gchar * -test_one_recipient (/* const */ gchar **keys, - /* const */ GPtrArray *values, - const gchar *name, - const gchar *address) +test_one_recipient (gchar **keys, + GPtrArray *values, + const gchar *name, + const gchar *address) { gint ii; g_return_val_if_fail (keys != NULL, NULL); g_return_val_if_fail (values != NULL, NULL); - if ((!name || !*name) && (!address || !*address)) + if (name != NULL && *name == '\0') + name = NULL; + + if (address != NULL && *address == '\0') + address = NULL; + + if (name == NULL && address == NULL) return NULL; for (ii = 0; keys[ii] && ii < values->len; ii++) { - if (name && *name && e_util_utf8_strstrcase (name, keys[ii]) != NULL) { + if (name != NULL && e_util_utf8_strstrcase (name, keys[ii]) != NULL) { return g_strdup (values->pdata[ii]); } - if (address && *address && e_util_utf8_strstrcase (address, keys[ii]) != NULL) { + if (address != NULL && e_util_utf8_strstrcase (address, keys[ii]) != NULL) { return g_strdup (values->pdata[ii]); } } @@ -263,8 +162,8 @@ test_one_recipient (/* const */ gchar **keys, } static gchar * -get_override_for_recipients_locked (EMailSendAccountOverride *account_override, - CamelAddress *recipients) +get_override_for_recipients_locked (EMailSendAccountOverride *override, + CamelAddress *recipients) { CamelInternetAddress *iaddress; gchar *account_uid = NULL; @@ -272,17 +171,21 @@ get_override_for_recipients_locked (EMailSendAccountOverride *account_override, gchar **keys; gint ii, len; - if (!recipients || !CAMEL_IS_INTERNET_ADDRESS (recipients)) + if (!CAMEL_IS_INTERNET_ADDRESS (recipients)) return NULL; - keys = g_key_file_get_keys (account_override->priv->key_file, RECIPIENTS_SECTION, NULL, NULL); - if (!keys) + keys = g_key_file_get_keys ( + override->priv->key_file, RECIPIENTS_SECTION, NULL, NULL); + if (keys == NULL) return NULL; values = g_ptr_array_new_full (g_strv_length (keys), g_free); for (ii = 0; keys[ii]; ii++) { - g_ptr_array_add (values, g_key_file_get_string (account_override->priv->key_file, - RECIPIENTS_SECTION, keys[ii], NULL)); + g_ptr_array_add ( + values, + g_key_file_get_string ( + override->priv->key_file, + RECIPIENTS_SECTION, keys[ii], NULL)); } iaddress = CAMEL_INTERNET_ADDRESS (recipients); @@ -293,15 +196,15 @@ get_override_for_recipients_locked (EMailSendAccountOverride *account_override, if (camel_internet_address_get (iaddress, ii, &name, &address)) { account_uid = test_one_recipient (keys, values, name, address); - if (account_uid) + if (account_uid != NULL) g_strchomp (account_uid); - if (account_uid && !*account_uid) { + if (account_uid != NULL && *account_uid == '\0') { g_free (account_uid); account_uid = NULL; } - if (account_uid) + if (account_uid != NULL) break; } } @@ -313,406 +216,527 @@ get_override_for_recipients_locked (EMailSendAccountOverride *account_override, } static void -list_overrides_section_for_account_locked (EMailSendAccountOverride *account_override, - const gchar *account_uid, - const gchar *section, - GSList **overrides) +list_overrides_section_for_account_locked (EMailSendAccountOverride *override, + const gchar *account_uid, + const gchar *section, + GList **overrides) { gchar **keys; g_return_if_fail (account_uid != NULL); g_return_if_fail (section != NULL); - if (!overrides) + if (overrides == NULL) return; *overrides = NULL; - keys = g_key_file_get_keys (account_override->priv->key_file, section, NULL, NULL); - if (keys) { + keys = g_key_file_get_keys ( + override->priv->key_file, section, NULL, NULL); + if (keys != NULL) { gint ii; for (ii = 0; keys[ii]; ii++) { const gchar *key = keys[ii]; gchar *value; - value = g_key_file_get_string (account_override->priv->key_file, section, key, NULL); + value = g_key_file_get_string ( + override->priv->key_file, section, key, NULL); if (g_strcmp0 (value, account_uid) == 0) - *overrides = g_slist_prepend (*overrides, g_strdup (key)); + *overrides = g_list_prepend (*overrides, g_strdup (key)); g_free (value); } } g_strfreev (keys); - *overrides = g_slist_reverse (*overrides); + *overrides = g_list_reverse (*overrides); } static void -list_overrides_for_account_locked (EMailSendAccountOverride *account_override, - const gchar *account_uid, - GSList **folder_overrides, - GSList **recipient_overrides) +list_overrides_for_account_locked (EMailSendAccountOverride *override, + const gchar *account_uid, + GList **folder_overrides, + GList **recipient_overrides) { - if (!account_uid) + if (account_uid == NULL) return; - list_overrides_section_for_account_locked (account_override, account_uid, FOLDERS_SECTION, folder_overrides); - list_overrides_section_for_account_locked (account_override, account_uid, RECIPIENTS_SECTION, recipient_overrides); + list_overrides_section_for_account_locked ( + override, account_uid, FOLDERS_SECTION, folder_overrides); + list_overrides_section_for_account_locked ( + override, account_uid, RECIPIENTS_SECTION, recipient_overrides); +} + +static void +mail_send_account_override_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_PREFER_FOLDER: + e_mail_send_account_override_set_prefer_folder ( + E_MAIL_SEND_ACCOUNT_OVERRIDE (object), + g_value_get_boolean (value)); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +mail_send_account_override_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_PREFER_FOLDER: + g_value_set_boolean ( + value, + e_mail_send_account_override_get_prefer_folder ( + E_MAIL_SEND_ACCOUNT_OVERRIDE (object))); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +mail_send_account_override_finalize (GObject *object) +{ + EMailSendAccountOverridePrivate *priv; + + priv = E_MAIL_SEND_ACCOUNT_OVERRIDE_GET_PRIVATE (object); + + g_key_file_free (priv->key_file); + g_free (priv->config_filename); + + g_mutex_clear (&priv->property_lock); + + /* Chain up to parent's finalize() method. */ + G_OBJECT_CLASS (e_mail_send_account_override_parent_class)-> + finalize (object); +} + +static void +e_mail_send_account_override_class_init (EMailSendAccountOverrideClass *class) +{ + GObjectClass *object_class; + + g_type_class_add_private ( + class, sizeof (EMailSendAccountOverridePrivate)); + + object_class = G_OBJECT_CLASS (class); + object_class->set_property = mail_send_account_override_set_property; + object_class->get_property = mail_send_account_override_get_property; + object_class->finalize = mail_send_account_override_finalize; + + g_object_class_install_property ( + object_class, + PROP_PREFER_FOLDER, + g_param_spec_boolean ( + "prefer-folder", + "Prefer Folder", + NULL, + TRUE, + G_PARAM_READWRITE)); + + signals[CHANGED] = g_signal_new ( + "changed", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (EMailSendAccountOverrideClass, changed), + NULL, NULL, NULL, + G_TYPE_NONE, 0); +} + +static void +e_mail_send_account_override_init (EMailSendAccountOverride *override) +{ + override->priv = E_MAIL_SEND_ACCOUNT_OVERRIDE_GET_PRIVATE (override); + + g_mutex_init (&override->priv->property_lock); + override->priv->key_file = g_key_file_new (); + override->priv->prefer_folder = TRUE; } EMailSendAccountOverride * e_mail_send_account_override_new (const gchar *config_filename) { - EMailSendAccountOverride *account_override; + EMailSendAccountOverride *override; - account_override = g_object_new (E_TYPE_MAIL_SEND_ACCOUNT_OVERRIDE, NULL); + override = g_object_new (E_TYPE_MAIL_SEND_ACCOUNT_OVERRIDE, NULL); - if (config_filename) - e_mail_send_account_override_set_config_filename (account_override, config_filename); + if (config_filename != NULL) + e_mail_send_account_override_set_config_filename ( + override, config_filename); - return account_override; + return override; } void -e_mail_send_account_override_set_config_filename (EMailSendAccountOverride *account_override, - const gchar *config_filename) +e_mail_send_account_override_set_config_filename (EMailSendAccountOverride *override, + const gchar *config_filename) { GError *error = NULL; gboolean old_prefer_folder, prefer_folder_changed; - g_return_if_fail (E_IS_MAIL_SEND_ACCOUNT_OVERRIDE (account_override)); + g_return_if_fail (E_IS_MAIL_SEND_ACCOUNT_OVERRIDE (override)); g_return_if_fail (config_filename != NULL); - g_return_if_fail (*config_filename); + g_return_if_fail (*config_filename != '\0'); - g_mutex_lock (&account_override->priv->property_lock); - if (g_strcmp0 (config_filename, account_override->priv->config_filename) == 0) { - g_mutex_unlock (&account_override->priv->property_lock); + g_mutex_lock (&override->priv->property_lock); + + if (g_strcmp0 (config_filename, override->priv->config_filename) == 0) { + g_mutex_unlock (&override->priv->property_lock); return; } - g_free (account_override->priv->config_filename); - account_override->priv->config_filename = g_strdup (config_filename); + g_free (override->priv->config_filename); + override->priv->config_filename = g_strdup (config_filename); - g_key_file_load_from_file (account_override->priv->key_file, - account_override->priv->config_filename, G_KEY_FILE_NONE, NULL); + g_key_file_load_from_file ( + override->priv->key_file, + override->priv->config_filename, G_KEY_FILE_NONE, NULL); - old_prefer_folder = account_override->priv->prefer_folder; - account_override->priv->prefer_folder = g_key_file_get_boolean (account_override->priv->key_file, + old_prefer_folder = override->priv->prefer_folder; + override->priv->prefer_folder = g_key_file_get_boolean ( + override->priv->key_file, OPTIONS_SECTION, OPTION_PREFER_FOLDER, &error); - if (error) { + if (error != NULL) { /* default value is to prefer the folder override over the recipients */ - account_override->priv->prefer_folder = TRUE; + override->priv->prefer_folder = TRUE; g_clear_error (&error); } - prefer_folder_changed = (account_override->priv->prefer_folder ? 1 : 0) != (old_prefer_folder ? 1 : 0); + prefer_folder_changed = + (override->priv->prefer_folder != old_prefer_folder); - g_mutex_unlock (&account_override->priv->property_lock); + g_mutex_unlock (&override->priv->property_lock); if (prefer_folder_changed) - g_object_notify (G_OBJECT (account_override), "prefer-folder"); + g_object_notify (G_OBJECT (override), "prefer-folder"); } gchar * -e_mail_send_account_override_dup_config_filename (EMailSendAccountOverride *account_override) +e_mail_send_account_override_dup_config_filename (EMailSendAccountOverride *override) { gchar *config_filename; - g_return_val_if_fail (E_IS_MAIL_SEND_ACCOUNT_OVERRIDE (account_override), NULL); + g_return_val_if_fail (E_IS_MAIL_SEND_ACCOUNT_OVERRIDE (override), NULL); - g_mutex_lock (&account_override->priv->property_lock); - config_filename = g_strdup (account_override->priv->config_filename); - g_mutex_unlock (&account_override->priv->property_lock); + g_mutex_lock (&override->priv->property_lock); + config_filename = g_strdup (override->priv->config_filename); + g_mutex_unlock (&override->priv->property_lock); return config_filename; } void -e_mail_send_account_override_set_prefer_folder (EMailSendAccountOverride *account_override, - gboolean prefer_folder) +e_mail_send_account_override_set_prefer_folder (EMailSendAccountOverride *override, + gboolean prefer_folder) { gboolean changed, saved = FALSE; - g_return_if_fail (E_IS_MAIL_SEND_ACCOUNT_OVERRIDE (account_override)); + g_return_if_fail (E_IS_MAIL_SEND_ACCOUNT_OVERRIDE (override)); + + g_mutex_lock (&override->priv->property_lock); - g_mutex_lock (&account_override->priv->property_lock); + changed = (prefer_folder != override->priv->prefer_folder); - changed = (account_override->priv->prefer_folder ? 1 : 0) != (prefer_folder ? 1 : 0); if (changed) { - account_override->priv->prefer_folder = prefer_folder; + override->priv->prefer_folder = prefer_folder; - g_key_file_set_boolean (account_override->priv->key_file, + g_key_file_set_boolean ( + override->priv->key_file, OPTIONS_SECTION, OPTION_PREFER_FOLDER, prefer_folder); - saved = e_mail_send_account_override_maybe_save_locked (account_override); + saved = e_mail_send_account_override_maybe_save_locked (override); } - g_mutex_unlock (&account_override->priv->property_lock); + g_mutex_unlock (&override->priv->property_lock); if (changed) - g_object_notify (G_OBJECT (account_override), "prefer-folder"); + g_object_notify (G_OBJECT (override), "prefer-folder"); if (saved) - g_signal_emit (account_override, signals[CHANGED], 0); + g_signal_emit (override, signals[CHANGED], 0); } gboolean -e_mail_send_account_override_get_prefer_folder (EMailSendAccountOverride *account_override) +e_mail_send_account_override_get_prefer_folder (EMailSendAccountOverride *override) { - gboolean prefer_folder; - - g_return_val_if_fail (E_IS_MAIL_SEND_ACCOUNT_OVERRIDE (account_override), FALSE); + g_return_val_if_fail (E_IS_MAIL_SEND_ACCOUNT_OVERRIDE (override), FALSE); - g_mutex_lock (&account_override->priv->property_lock); - prefer_folder = account_override->priv->prefer_folder; - g_mutex_unlock (&account_override->priv->property_lock); - - return prefer_folder; + return override->priv->prefer_folder; } /* free returned pointer with g_free() */ gchar * -e_mail_send_account_override_get_account_uid (EMailSendAccountOverride *account_override, - const gchar *folder_uri, - const CamelInternetAddress *recipients_to, - const CamelInternetAddress *recipients_cc, - const CamelInternetAddress *recipients_bcc) +e_mail_send_account_override_get_account_uid (EMailSendAccountOverride *override, + const gchar *folder_uri, + CamelInternetAddress *recipients_to, + CamelInternetAddress *recipients_cc, + CamelInternetAddress *recipients_bcc) { gchar *account_uid = NULL; - g_return_val_if_fail (E_IS_MAIL_SEND_ACCOUNT_OVERRIDE (account_override), NULL); - g_return_val_if_fail (account_override->priv->config_filename != NULL, NULL); + g_return_val_if_fail (E_IS_MAIL_SEND_ACCOUNT_OVERRIDE (override), NULL); + g_return_val_if_fail (override->priv->config_filename != NULL, NULL); - g_mutex_lock (&account_override->priv->property_lock); + g_mutex_lock (&override->priv->property_lock); - if (account_override->priv->prefer_folder) - account_uid = get_override_for_folder_uri_locked (account_override, folder_uri); + if (override->priv->prefer_folder) + account_uid = get_override_for_folder_uri_locked ( + override, folder_uri); - if (!account_uid) - account_uid = get_override_for_recipients_locked (account_override, (CamelAddress *) recipients_to); + if (account_uid == NULL) + account_uid = get_override_for_recipients_locked ( + override, CAMEL_ADDRESS (recipients_to)); - if (!account_uid) - account_uid = get_override_for_recipients_locked (account_override, (CamelAddress *) recipients_cc); + if (account_uid == NULL) + account_uid = get_override_for_recipients_locked ( + override, CAMEL_ADDRESS (recipients_cc)); - if (!account_uid) - account_uid = get_override_for_recipients_locked (account_override, (CamelAddress *) recipients_bcc); + if (account_uid == NULL) + account_uid = get_override_for_recipients_locked ( + override, CAMEL_ADDRESS (recipients_bcc)); - if (!account_uid && !account_override->priv->prefer_folder) - account_uid = get_override_for_folder_uri_locked (account_override, folder_uri); + if (account_uid == NULL && !override->priv->prefer_folder) + account_uid = get_override_for_folder_uri_locked ( + override, folder_uri); - g_mutex_unlock (&account_override->priv->property_lock); + g_mutex_unlock (&override->priv->property_lock); return account_uid; } void -e_mail_send_account_override_remove_for_account_uid (EMailSendAccountOverride *account_override, - const gchar *account_uid) +e_mail_send_account_override_remove_for_account_uid (EMailSendAccountOverride *override, + const gchar *account_uid) { - GSList *folders = NULL, *recipients = NULL, *iter; + GList *folders = NULL, *recipients = NULL; gboolean saved = FALSE; - g_return_if_fail (E_IS_MAIL_SEND_ACCOUNT_OVERRIDE (account_override)); + g_return_if_fail (E_IS_MAIL_SEND_ACCOUNT_OVERRIDE (override)); g_return_if_fail (account_uid != NULL); - g_mutex_lock (&account_override->priv->property_lock); - - list_overrides_for_account_locked (account_override, account_uid, &folders, &recipients); + g_mutex_lock (&override->priv->property_lock); + + list_overrides_for_account_locked ( + override, account_uid, &folders, &recipients); - if (folders || recipients) { - for (iter = folders; iter; iter = g_slist_next (iter)) { - const gchar *key = iter->data; + if (folders != NULL || recipients != NULL) { + GList *link; - g_key_file_remove_key (account_override->priv->key_file, FOLDERS_SECTION, key, NULL); + for (link = folders; link != NULL; link = g_list_next (link)) { + const gchar *key = link->data; + + g_key_file_remove_key ( + override->priv->key_file, + FOLDERS_SECTION, key, NULL); } - for (iter = recipients; iter; iter = g_slist_next (iter)) { - const gchar *key = iter->data; + for (link = recipients; link != NULL; link = g_list_next (link)) { + const gchar *key = link->data; - g_key_file_remove_key (account_override->priv->key_file, RECIPIENTS_SECTION, key, NULL); + g_key_file_remove_key ( + override->priv->key_file, + RECIPIENTS_SECTION, key, NULL); } - saved = e_mail_send_account_override_maybe_save_locked (account_override); + saved = e_mail_send_account_override_maybe_save_locked (override); } - g_slist_free_full (folders, g_free); - g_slist_free_full (recipients, g_free); + g_list_free_full (folders, g_free); + g_list_free_full (recipients, g_free); - g_mutex_unlock (&account_override->priv->property_lock); + g_mutex_unlock (&override->priv->property_lock); if (saved) - g_signal_emit (account_override, signals[CHANGED], 0); + g_signal_emit (override, signals[CHANGED], 0); } gchar * -e_mail_send_account_override_get_for_folder (EMailSendAccountOverride *account_override, - const gchar *folder_uri) +e_mail_send_account_override_get_for_folder (EMailSendAccountOverride *override, + const gchar *folder_uri) { gchar *account_uid = NULL; - g_return_val_if_fail (E_IS_MAIL_SEND_ACCOUNT_OVERRIDE (account_override), NULL); + g_return_val_if_fail (E_IS_MAIL_SEND_ACCOUNT_OVERRIDE (override), NULL); - g_mutex_lock (&account_override->priv->property_lock); + g_mutex_lock (&override->priv->property_lock); - account_uid = get_override_for_folder_uri_locked (account_override, folder_uri); + account_uid = get_override_for_folder_uri_locked (override, folder_uri); - g_mutex_unlock (&account_override->priv->property_lock); + g_mutex_unlock (&override->priv->property_lock); return account_uid; } void -e_mail_send_account_override_set_for_folder (EMailSendAccountOverride *account_override, - const gchar *folder_uri, - const gchar *account_uid) +e_mail_send_account_override_set_for_folder (EMailSendAccountOverride *override, + const gchar *folder_uri, + const gchar *account_uid) { gboolean saved; - g_return_if_fail (E_IS_MAIL_SEND_ACCOUNT_OVERRIDE (account_override)); + g_return_if_fail (E_IS_MAIL_SEND_ACCOUNT_OVERRIDE (override)); g_return_if_fail (folder_uri != NULL); g_return_if_fail (account_uid != NULL); - g_mutex_lock (&account_override->priv->property_lock); + g_mutex_lock (&override->priv->property_lock); - g_key_file_set_string (account_override->priv->key_file, FOLDERS_SECTION, folder_uri, account_uid); - saved = e_mail_send_account_override_maybe_save_locked (account_override); + g_key_file_set_string ( + override->priv->key_file, + FOLDERS_SECTION, folder_uri, account_uid); + saved = e_mail_send_account_override_maybe_save_locked (override); - g_mutex_unlock (&account_override->priv->property_lock); + g_mutex_unlock (&override->priv->property_lock); if (saved) - g_signal_emit (account_override, signals[CHANGED], 0); + g_signal_emit (override, signals[CHANGED], 0); } void -e_mail_send_account_override_remove_for_folder (EMailSendAccountOverride *account_override, - const gchar *folder_uri) +e_mail_send_account_override_remove_for_folder (EMailSendAccountOverride *override, + const gchar *folder_uri) { gboolean saved; - g_return_if_fail (E_IS_MAIL_SEND_ACCOUNT_OVERRIDE (account_override)); + g_return_if_fail (E_IS_MAIL_SEND_ACCOUNT_OVERRIDE (override)); g_return_if_fail (folder_uri != NULL); - g_mutex_lock (&account_override->priv->property_lock); + g_mutex_lock (&override->priv->property_lock); - g_key_file_remove_key (account_override->priv->key_file, FOLDERS_SECTION, folder_uri, NULL); - saved = e_mail_send_account_override_maybe_save_locked (account_override); + g_key_file_remove_key ( + override->priv->key_file, FOLDERS_SECTION, folder_uri, NULL); + saved = e_mail_send_account_override_maybe_save_locked (override); - g_mutex_unlock (&account_override->priv->property_lock); + g_mutex_unlock (&override->priv->property_lock); if (saved) - g_signal_emit (account_override, signals[CHANGED], 0); + g_signal_emit (override, signals[CHANGED], 0); } gchar * -e_mail_send_account_override_get_for_recipient (EMailSendAccountOverride *account_override, - const CamelInternetAddress *recipients) +e_mail_send_account_override_get_for_recipient (EMailSendAccountOverride *override, + CamelInternetAddress *recipients) { gchar *account_uid; - g_return_if_fail (E_IS_MAIL_SEND_ACCOUNT_OVERRIDE (account_override)); - g_return_if_fail (recipients != NULL); + g_return_val_if_fail (E_IS_MAIL_SEND_ACCOUNT_OVERRIDE (override), NULL); + g_return_val_if_fail (recipients != NULL, NULL); + + g_mutex_lock (&override->priv->property_lock); - g_mutex_lock (&account_override->priv->property_lock); - account_uid = get_override_for_recipients_locked (account_override, (CamelAddress *) recipients); - g_mutex_unlock (&account_override->priv->property_lock); + account_uid = get_override_for_recipients_locked ( + override, CAMEL_ADDRESS (recipients)); + + g_mutex_unlock (&override->priv->property_lock); return account_uid; } void -e_mail_send_account_override_set_for_recipient (EMailSendAccountOverride *account_override, - const gchar *recipient, - const gchar *account_uid) +e_mail_send_account_override_set_for_recipient (EMailSendAccountOverride *override, + const gchar *recipient, + const gchar *account_uid) { gboolean saved; - g_return_if_fail (E_IS_MAIL_SEND_ACCOUNT_OVERRIDE (account_override)); + g_return_if_fail (E_IS_MAIL_SEND_ACCOUNT_OVERRIDE (override)); g_return_if_fail (recipient != NULL); g_return_if_fail (account_uid != NULL); - g_mutex_lock (&account_override->priv->property_lock); + g_mutex_lock (&override->priv->property_lock); - g_key_file_set_string (account_override->priv->key_file, RECIPIENTS_SECTION, recipient, account_uid); - saved = e_mail_send_account_override_maybe_save_locked (account_override); + g_key_file_set_string ( + override->priv->key_file, + RECIPIENTS_SECTION, recipient, account_uid); + saved = e_mail_send_account_override_maybe_save_locked (override); - g_mutex_unlock (&account_override->priv->property_lock); + g_mutex_unlock (&override->priv->property_lock); if (saved) - g_signal_emit (account_override, signals[CHANGED], 0); + g_signal_emit (override, signals[CHANGED], 0); } void -e_mail_send_account_override_remove_for_recipient (EMailSendAccountOverride *account_override, - const gchar *recipient) +e_mail_send_account_override_remove_for_recipient (EMailSendAccountOverride *override, + const gchar *recipient) { gboolean saved; - g_return_if_fail (E_IS_MAIL_SEND_ACCOUNT_OVERRIDE (account_override)); + g_return_if_fail (E_IS_MAIL_SEND_ACCOUNT_OVERRIDE (override)); g_return_if_fail (recipient != NULL); - g_mutex_lock (&account_override->priv->property_lock); + g_mutex_lock (&override->priv->property_lock); - g_key_file_remove_key (account_override->priv->key_file, RECIPIENTS_SECTION, recipient, NULL); - saved = e_mail_send_account_override_maybe_save_locked (account_override); + g_key_file_remove_key ( + override->priv->key_file, RECIPIENTS_SECTION, recipient, NULL); + saved = e_mail_send_account_override_maybe_save_locked (override); - g_mutex_unlock (&account_override->priv->property_lock); + g_mutex_unlock (&override->priv->property_lock); if (saved) - g_signal_emit (account_override, signals[CHANGED], 0); + g_signal_emit (override, signals[CHANGED], 0); } void -e_mail_send_account_override_list_for_account (EMailSendAccountOverride *account_override, - const gchar *account_uid, - GSList **folder_overrides, - GSList **recipient_overrides) +e_mail_send_account_override_list_for_account (EMailSendAccountOverride *override, + const gchar *account_uid, + GList **folder_overrides, + GList **recipient_overrides) { - g_return_if_fail (E_IS_MAIL_SEND_ACCOUNT_OVERRIDE (account_override)); + g_return_if_fail (E_IS_MAIL_SEND_ACCOUNT_OVERRIDE (override)); g_return_if_fail (account_uid != NULL); - g_mutex_lock (&account_override->priv->property_lock); + g_mutex_lock (&override->priv->property_lock); - list_overrides_for_account_locked (account_override, account_uid, folder_overrides, recipient_overrides); + list_overrides_for_account_locked ( + override, account_uid, folder_overrides, recipient_overrides); - g_mutex_unlock (&account_override->priv->property_lock); + g_mutex_unlock (&override->priv->property_lock); } void -e_mail_send_account_override_freeze_save (EMailSendAccountOverride *account_override) +e_mail_send_account_override_freeze_save (EMailSendAccountOverride *override) { - g_return_if_fail (E_IS_MAIL_SEND_ACCOUNT_OVERRIDE (account_override)); + g_return_if_fail (E_IS_MAIL_SEND_ACCOUNT_OVERRIDE (override)); - g_mutex_lock (&account_override->priv->property_lock); + g_mutex_lock (&override->priv->property_lock); - account_override->priv->save_frozen++; - if (!account_override->priv->save_frozen) { + override->priv->save_frozen++; + if (!override->priv->save_frozen) { g_warn_if_reached (); } - g_mutex_unlock (&account_override->priv->property_lock); + g_mutex_unlock (&override->priv->property_lock); } void -e_mail_send_account_override_thaw_save (EMailSendAccountOverride *account_override) +e_mail_send_account_override_thaw_save (EMailSendAccountOverride *override) { gboolean saved = FALSE; - g_return_if_fail (E_IS_MAIL_SEND_ACCOUNT_OVERRIDE (account_override)); + g_return_if_fail (E_IS_MAIL_SEND_ACCOUNT_OVERRIDE (override)); - g_mutex_lock (&account_override->priv->property_lock); + g_mutex_lock (&override->priv->property_lock); - if (!account_override->priv->save_frozen) { + if (!override->priv->save_frozen) { g_warn_if_reached (); } else { - account_override->priv->save_frozen--; - if (!account_override->priv->save_frozen && - account_override->priv->need_save) - saved = e_mail_send_account_override_save_locked (account_override); + override->priv->save_frozen--; + if (!override->priv->save_frozen && override->priv->need_save) + saved = e_mail_send_account_override_save_locked (override); } - g_mutex_unlock (&account_override->priv->property_lock); + g_mutex_unlock (&override->priv->property_lock); if (saved) - g_signal_emit (account_override, signals[CHANGED], 0); + g_signal_emit (override, signals[CHANGED], 0); } + diff --git a/mail/e-mail-send-account-override.h b/mail/e-mail-send-account-override.h index e89d7b657c..1641bbfbcf 100644 --- a/mail/e-mail-send-account-override.h +++ b/mail/e-mail-send-account-override.h @@ -56,52 +56,65 @@ struct _EMailSendAccountOverride { }; struct _EMailSendAccountOverrideClass { - GObjectClass parent; + GObjectClass parent_class; /* Signals */ - void (* changed) (EMailSendAccountOverride *account_override); + void (*changed) (EMailSendAccountOverride *override); }; -GType e_mail_send_account_override_get_type (void); +GType e_mail_send_account_override_get_type + (void) G_GNUC_CONST; EMailSendAccountOverride * - e_mail_send_account_override_new (const gchar *config_filename); + e_mail_send_account_override_new + (const gchar *config_filename); void e_mail_send_account_override_set_config_filename - (EMailSendAccountOverride *account_override, - const gchar *config_filename); + (EMailSendAccountOverride *override, + const gchar *config_filename); gchar * e_mail_send_account_override_dup_config_filename - (EMailSendAccountOverride *account_override); -void e_mail_send_account_override_set_prefer_folder (EMailSendAccountOverride *account_override, - gboolean prefer_folder); -gboolean e_mail_send_account_override_get_prefer_folder (EMailSendAccountOverride *account_override); -gchar * e_mail_send_account_override_get_account_uid (EMailSendAccountOverride *account_override, - const gchar *folder_uri, - const CamelInternetAddress *recipients_to, - const CamelInternetAddress *recipients_cc, - const CamelInternetAddress *recipients_bcc); + (EMailSendAccountOverride *override); +void e_mail_send_account_override_set_prefer_folder + (EMailSendAccountOverride *override, + gboolean prefer_folder); +gboolean e_mail_send_account_override_get_prefer_folder + (EMailSendAccountOverride *override); +gchar * e_mail_send_account_override_get_account_uid + (EMailSendAccountOverride *override, + const gchar *folder_uri, + CamelInternetAddress *recipients_to, + CamelInternetAddress *recipients_cc, + CamelInternetAddress *recipients_bcc); void e_mail_send_account_override_remove_for_account_uid - (EMailSendAccountOverride *account_override, - const gchar *account_uid); -gchar * e_mail_send_account_override_get_for_folder (EMailSendAccountOverride *account_override, - const gchar *folder_uri); -void e_mail_send_account_override_set_for_folder (EMailSendAccountOverride *account_override, - const gchar *folder_uri, - const gchar *account_uid); -void e_mail_send_account_override_remove_for_folder (EMailSendAccountOverride *account_override, - const gchar *folder_uri); -gchar * e_mail_send_account_override_get_for_recipient (EMailSendAccountOverride *account_override, - const CamelInternetAddress *recipients); -void e_mail_send_account_override_set_for_recipient (EMailSendAccountOverride *account_override, - const gchar *recipient, - const gchar *account_uid); + (EMailSendAccountOverride *override, + const gchar *account_uid); +gchar * e_mail_send_account_override_get_for_folder + (EMailSendAccountOverride *override, + const gchar *folder_uri); +void e_mail_send_account_override_set_for_folder + (EMailSendAccountOverride *override, + const gchar *folder_uri, + const gchar *account_uid); +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); +void e_mail_send_account_override_set_for_recipient + (EMailSendAccountOverride *override, + const gchar *recipient, + const gchar *account_uid); void e_mail_send_account_override_remove_for_recipient - (EMailSendAccountOverride *account_override, - const gchar *recipient); -void e_mail_send_account_override_list_for_account (EMailSendAccountOverride *account_override, - const gchar *account_uid, - GSList **folder_overrides, - GSList **recipient_overrides); -void e_mail_send_account_override_freeze_save (EMailSendAccountOverride *account_override); -void e_mail_send_account_override_thaw_save (EMailSendAccountOverride *account_override); + (EMailSendAccountOverride *override, + const gchar *recipient); +void e_mail_send_account_override_list_for_account + (EMailSendAccountOverride *override, + const gchar *account_uid, + GList **folder_overrides, + GList **recipient_overrides); +void e_mail_send_account_override_freeze_save + (EMailSendAccountOverride *override); +void e_mail_send_account_override_thaw_save + (EMailSendAccountOverride *override); G_END_DECLS diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c index 44e8619e5d..edd33ca846 100644 --- a/mail/em-composer-utils.c +++ b/mail/em-composer-utils.c @@ -3153,8 +3153,8 @@ em_configure_new_composer (EMsgComposer *composer, /* free returned pointer with g_object_unref(), if not NULL */ ESource * em_utils_check_send_account_override (EShell *shell, - CamelMimeMessage *message, - CamelFolder *folder) + CamelMimeMessage *message, + CamelFolder *folder) { EMailBackend *mail_backend; EMailSendAccountOverride *account_override; @@ -3190,7 +3190,7 @@ em_utils_check_send_account_override (EShell *shell, break; /* stored send account override settings contain a reference - to a dropped account, thus cleanup it now */ + * to a dropped account, thus cleanup it now */ e_mail_send_account_override_remove_for_account_uid (account_override, account_uid); g_free (account_uid); @@ -3205,8 +3205,8 @@ em_utils_check_send_account_override (EShell *shell, void em_utils_apply_send_account_override_to_composer (EMsgComposer *composer, - EShell *shell, - CamelFolder *folder) + EShell *shell, + CamelFolder *folder) { CamelMimeMessage *message; EComposerHeaderTable *header_table; diff --git a/mail/em-folder-properties.c b/mail/em-folder-properties.c index b56dffb4bf..a3a9e94875 100644 --- a/mail/em-folder-properties.c +++ b/mail/em-folder-properties.c @@ -83,7 +83,7 @@ emfp_free (EConfig *ec, static void mail_identity_combo_box_changed_cb (GtkComboBox *combo_box, - EMailSendAccountOverride *account_override) + EMailSendAccountOverride *account_override) { const gchar *active_id, *folder_uri; @@ -298,7 +298,8 @@ emfp_get_folder_item (EConfig *ec, GTK_FILL, 0, 0, 0); row++; - widget = g_object_new (E_TYPE_MAIL_IDENTITY_COMBO_BOX, + widget = g_object_new ( + E_TYPE_MAIL_IDENTITY_COMBO_BOX, "registry", registry, "allow-none", TRUE, NULL); @@ -322,7 +323,8 @@ emfp_get_folder_item (EConfig *ec, 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 (widget, "changed", + g_signal_connect ( + widget, "changed", G_CALLBACK (mail_identity_combo_box_changed_cb), account_override); g_free (account_uid); diff --git a/mail/em-subscription-editor.c b/mail/em-subscription-editor.c index 88240e9c9d..e210652d37 100644 --- a/mail/em-subscription-editor.c +++ b/mail/em-subscription-editor.c @@ -1430,17 +1430,18 @@ subscription_editor_add_store (EMSubscriptionEditor *editor, static void emse_notebook_sensitive_changed_cb (GtkWidget *notebook, - GParamSpec *param, - GtkDialog *editor) + GParamSpec *param, + GtkDialog *editor) { - gtk_dialog_set_response_sensitive (editor, - GTK_RESPONSE_CLOSE, gtk_widget_get_sensitive (notebook)); + gtk_dialog_set_response_sensitive ( + editor, GTK_RESPONSE_CLOSE, + gtk_widget_get_sensitive (notebook)); } static gboolean subscription_editor_delete_event_cb (EMSubscriptionEditor *editor, - GdkEvent *event, - gpointer user_data) + GdkEvent *event, + gpointer user_data) { /* stop processing if the button is insensitive */ return !gtk_widget_get_sensitive (editor->priv->notebook); @@ -1448,8 +1449,8 @@ subscription_editor_delete_event_cb (EMSubscriptionEditor *editor, static void subscription_editor_response_cb (EMSubscriptionEditor *editor, - gint response_id, - gpointer user_data) + gint response_id, + gpointer user_data) { if (!gtk_widget_get_sensitive (editor->priv->notebook)) g_signal_stop_emission_by_name (editor, "response"); @@ -1801,7 +1802,8 @@ em_subscription_editor_init (EMSubscriptionEditor *editor) G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); - g_signal_connect (widget, "notify::sensitive", + g_signal_connect ( + widget, "notify::sensitive", G_CALLBACK (emse_notebook_sensitive_changed_cb), editor); widget = gtk_button_box_new (GTK_ORIENTATION_VERTICAL); |