Commit f67a5f3d authored by Matthew Barnes's avatar Matthew Barnes
Browse files

Miscellaneous cleanups.

Reducing diff noise with the account-mgmt branch.

Trying to erode our dependency on EAccount as much as possible, or at
least isolate its usage, to make things easier for me on the branch.
parent 60383e04
......@@ -3141,7 +3141,9 @@ emae_defaults_page (EConfig *ec,
EMFolderSelectionButton *button;
CamelProviderFlags flags;
CamelSettings *settings;
CamelStore *store = NULL;
EMailBackend *backend;
EMailSession *session;
EAccount *account;
GtkWidget *widget;
GtkBuilder *builder;
......@@ -3156,6 +3158,18 @@ emae_defaults_page (EConfig *ec,
account = em_account_editor_get_modified_account (emae);
backend = em_account_editor_get_backend (emae);
session = e_mail_backend_get_session (backend);
if (account != NULL) {
CamelService *service;
service = camel_session_get_service (
CAMEL_SESSION (session), account->uid);
if (CAMEL_IS_STORE (service))
store = CAMEL_STORE (service);
}
settings = emae->priv->source.settings;
/* Make sure we have a valid EMailBackend. */
......@@ -3182,8 +3196,8 @@ emae_defaults_page (EConfig *ec,
widget = e_builder_get_widget (builder, "trash_folder_butt");
button = EM_FOLDER_SELECTION_BUTTON (widget);
em_folder_selection_button_set_account (button, account);
em_folder_selection_button_set_backend (button, backend);
em_folder_selection_button_set_store (button, store);
priv->trash_folder_button = GTK_BUTTON (button);
g_signal_connect (
......@@ -3227,8 +3241,8 @@ emae_defaults_page (EConfig *ec,
widget = e_builder_get_widget (builder, "junk_folder_butt");
button = EM_FOLDER_SELECTION_BUTTON (widget);
em_folder_selection_button_set_account (button, account);
em_folder_selection_button_set_backend (button, backend);
em_folder_selection_button_set_store (button, store);
priv->junk_folder_button = GTK_BUTTON (button);
g_signal_connect (
......
......@@ -1782,27 +1782,27 @@ static EMsgComposer *
redirect_get_composer (EShell *shell,
CamelMimeMessage *message)
{
EMsgComposer *composer;
CamelMedium *medium;
EAccount *account;
medium = CAMEL_MEDIUM (message);
/* QMail will refuse to send a message if it finds one of
it's Delivered-To headers in the message, so remove all
Delivered-To headers. Fixes bug #23635. */
while (camel_medium_get_header (CAMEL_MEDIUM (message), "Delivered-To"))
camel_medium_remove_header (CAMEL_MEDIUM (message), "Delivered-To");
while (camel_medium_get_header (medium, "Delivered-To"))
camel_medium_remove_header (medium, "Delivered-To");
while (camel_medium_get_header (CAMEL_MEDIUM (message), "Bcc"))
camel_medium_remove_header (CAMEL_MEDIUM (message), "Bcc");
while (camel_medium_get_header (medium, "Bcc"))
camel_medium_remove_header (medium, "Bcc");
while (camel_medium_get_header (CAMEL_MEDIUM (message), "Resent-Bcc"))
camel_medium_remove_header (CAMEL_MEDIUM (message), "Resent-Bcc");
while (camel_medium_get_header (medium, "Resent-Bcc"))
camel_medium_remove_header (medium, "Resent-Bcc");
account = em_utils_guess_account_with_recipients (message, NULL);
composer = e_msg_composer_new_redirect (
return e_msg_composer_new_redirect (
shell, message, account ? account->name : NULL, NULL);
return composer;
}
/**
......@@ -1967,9 +1967,10 @@ em_utils_send_receipt (EMailSession *session,
message_date ="";
/* Create toplevel container */
camel_data_wrapper_set_mime_type (CAMEL_DATA_WRAPPER (body),
"multipart/report;"
"report-type=\"disposition-notification\"");
camel_data_wrapper_set_mime_type (
CAMEL_DATA_WRAPPER (body),
"multipart/report;"
"report-type=\"disposition-notification\"");
camel_multipart_set_boundary (body, NULL);
/* Create textual receipt */
......@@ -2036,7 +2037,8 @@ em_utils_send_receipt (EMailSession *session,
g_object_unref (part);
/* Finish creating the message */
camel_medium_set_content (CAMEL_MEDIUM (receipt), CAMEL_DATA_WRAPPER (body));
camel_medium_set_content (
CAMEL_MEDIUM (receipt), CAMEL_DATA_WRAPPER (body));
g_object_unref (body);
/* Translators: %s is the subject of the email message */
......@@ -2052,7 +2054,8 @@ em_utils_send_receipt (EMailSession *session,
addr = camel_internet_address_new ();
camel_address_decode (CAMEL_ADDRESS (addr), receipt_address);
camel_mime_message_set_recipients (receipt, CAMEL_RECIPIENT_TYPE_TO, addr);
camel_mime_message_set_recipients (
receipt, CAMEL_RECIPIENT_TYPE_TO, addr);
g_object_unref (addr);
transport_uid = g_strconcat (account->uid, "-transport", NULL);
......@@ -2139,12 +2142,17 @@ reply_get_composer (EShell *shell,
EDestination **tov, **ccv;
EMsgComposer *composer;
EComposerHeaderTable *table;
CamelMedium *medium;
gchar *subject;
g_return_val_if_fail (E_IS_SHELL (shell), NULL);
g_return_val_if_fail (CAMEL_IS_MIME_MESSAGE (message), NULL);
g_return_val_if_fail (to == NULL || CAMEL_IS_INTERNET_ADDRESS (to), NULL);
g_return_val_if_fail (cc == NULL || CAMEL_IS_INTERNET_ADDRESS (cc), NULL);
if (to != NULL)
g_return_val_if_fail (CAMEL_IS_INTERNET_ADDRESS (to), NULL);
if (cc != NULL)
g_return_val_if_fail (CAMEL_IS_INTERNET_ADDRESS (cc), NULL);
composer = e_msg_composer_new (shell);
......@@ -2207,22 +2215,30 @@ reply_get_composer (EShell *shell,
}
/* Add In-Reply-To and References. */
message_id = camel_medium_get_header (CAMEL_MEDIUM (message), "Message-ID");
references = camel_medium_get_header (CAMEL_MEDIUM (message), "References");
if (message_id) {
medium = CAMEL_MEDIUM (message);
message_id = camel_medium_get_header (medium, "Message-ID");
references = camel_medium_get_header (medium, "References");
if (message_id != NULL) {
gchar *reply_refs;
e_msg_composer_add_header (composer, "In-Reply-To", message_id);
e_msg_composer_add_header (
composer, "In-Reply-To", message_id);
if (references)
reply_refs = g_strdup_printf ("%s %s", references, message_id);
reply_refs = g_strdup_printf (
"%s %s", references, message_id);
else
reply_refs = g_strdup (message_id);
e_msg_composer_add_header (composer, "References", reply_refs);
e_msg_composer_add_header (
composer, "References", reply_refs);
g_free (reply_refs);
} else if (references) {
e_msg_composer_add_header (composer, "References", references);
} else if (references != NULL) {
e_msg_composer_add_header (
composer, "References", references);
}
return composer;
......@@ -2865,7 +2881,7 @@ em_utils_reply_to_message (EShell *shell,
const gchar *message_uid,
EMailReplyType type,
EMailReplyStyle style,
EMFormat *source,
EMFormat *source_formatter,
CamelInternetAddress *address)
{
CamelInternetAddress *to, *cc;
......@@ -2925,7 +2941,7 @@ em_utils_reply_to_message (EShell *shell,
g_object_unref (to);
g_object_unref (cc);
composer_set_body (composer, message, style, source);
composer_set_body (composer, message, style, source_formatter);
if (folder != NULL) {
gchar *folder_uri;
......
......@@ -66,7 +66,7 @@ void em_utils_send_receipt (EMailSession *session,
CamelMimeMessage *message);
gchar * em_utils_construct_composer_text
(CamelMimeMessage *message,
EMFormat *source);
EMFormat *source_formatter);
gboolean em_utils_is_munged_list_message (CamelMimeMessage *message);
void em_utils_get_reply_sender (CamelMimeMessage *message,
CamelInternetAddress *to,
......
......@@ -31,11 +31,11 @@
#include <gtk/gtk.h>
#include <camel/camel.h>
#include <libedataserver/e-sexp.h>
#include <e-util/e-account-utils.h>
#include "filter/e-filter-part.h"
#include <filter/e-filter-part.h>
#define EM_FILTER_SOURCE_ELEMENT_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE \
......@@ -343,18 +343,28 @@ filter_source_element_get_widget (EFilterElement *fe)
for (i = fs->priv->sources; i != NULL; i = g_list_next (i)) {
SourceInfo *info = (SourceInfo *) i->data;
const gchar *display_name;
const gchar *address;
const gchar *name;
const gchar *uid;
gchar *label;
if (g_strcmp0 (info->account_name, info->address) == 0)
uid = info->uid;
display_name = info->account_name;
name = info->name;
address = info->address;
if (g_strcmp0 (display_name, address) == 0)
label = g_strdup_printf (
"%s <%s>", info->name, info->address);
"%s <%s>", name, address);
else
label = g_strdup_printf (
"%s <%s> (%s)", info->name,
info->address, info->account_name);
"%s <%s> (%s)", name,
address, display_name);
gtk_combo_box_text_append (
GTK_COMBO_BOX_TEXT (combo_box), info->uid, label);
GTK_COMBO_BOX_TEXT (combo_box), uid, label);
g_free (label);
}
......
......@@ -27,7 +27,6 @@
#include <string.h>
#include <glib/gi18n.h>
#include <e-util/e-util.h>
#include <e-util/e-account-utils.h>
#include "e-mail-folder-utils.h"
#include "em-folder-tree.h"
......@@ -44,7 +43,7 @@ struct _EMFolderSelectionButtonPrivate {
EMailBackend *backend;
GtkWidget *icon;
GtkWidget *label;
EAccount *account;
CamelStore *store;
gchar *title;
gchar *caption;
......@@ -53,10 +52,10 @@ struct _EMFolderSelectionButtonPrivate {
enum {
PROP_0,
PROP_ACCOUNT,
PROP_BACKEND,
PROP_CAPTION,
PROP_FOLDER_URI,
PROP_STORE,
PROP_TITLE
};
......@@ -87,9 +86,9 @@ folder_selection_button_set_contents (EMFolderSelectionButton *button)
{
EMailBackend *backend;
CamelStore *store = NULL;
EAccount *account;
CamelService *service;
GtkLabel *label;
const gchar *uid;
const gchar *display_name;
gchar *folder_name = NULL;
label = GTK_LABEL (button->priv->label);
......@@ -110,15 +109,14 @@ folder_selection_button_set_contents (EMFolderSelectionButton *button)
return;
}
uid = camel_service_get_uid (CAMEL_SERVICE (store));
account = e_get_account_by_uid (uid);
service = CAMEL_SERVICE (store);
display_name = camel_service_get_display_name (service);
if (account != NULL) {
if (display_name != NULL) {
gchar *text;
text = g_strdup_printf (
"%s/%s", e_account_get_string (
account, E_ACCOUNT_NAME), _(folder_name));
"%s/%s", display_name, _(folder_name));
gtk_label_set_text (label, text);
g_free (text);
} else
......@@ -135,12 +133,6 @@ folder_selection_button_set_property (GObject *object,
GParamSpec *pspec)
{
switch (property_id) {
case PROP_ACCOUNT:
em_folder_selection_button_set_account (
EM_FOLDER_SELECTION_BUTTON (object),
g_value_get_object (value));
return;
case PROP_BACKEND:
em_folder_selection_button_set_backend (
EM_FOLDER_SELECTION_BUTTON (object),
......@@ -159,6 +151,12 @@ folder_selection_button_set_property (GObject *object,
g_value_get_string (value));
return;
case PROP_STORE:
em_folder_selection_button_set_store (
EM_FOLDER_SELECTION_BUTTON (object),
g_value_get_object (value));
return;
case PROP_TITLE:
em_folder_selection_button_set_title (
EM_FOLDER_SELECTION_BUTTON (object),
......@@ -176,13 +174,6 @@ folder_selection_button_get_property (GObject *object,
GParamSpec *pspec)
{
switch (property_id) {
case PROP_ACCOUNT:
g_value_set_object (
value,
em_folder_selection_button_get_account (
EM_FOLDER_SELECTION_BUTTON (object)));
return;
case PROP_BACKEND:
g_value_set_object (
value,
......@@ -204,6 +195,13 @@ folder_selection_button_get_property (GObject *object,
EM_FOLDER_SELECTION_BUTTON (object)));
return;
case PROP_STORE:
g_value_set_object (
value,
em_folder_selection_button_get_store (
EM_FOLDER_SELECTION_BUTTON (object)));
return;
case PROP_TITLE:
g_value_set_string (
value,
......@@ -222,16 +220,16 @@ folder_selection_button_dispose (GObject *object)
priv = EM_FOLDER_SELECTION_BUTTON_GET_PRIVATE (object);
if (priv->account != NULL) {
g_object_unref (priv->account);
priv->account = NULL;
}
if (priv->backend != NULL) {
g_object_unref (priv->backend);
priv->backend = NULL;
}
if (priv->store != NULL) {
g_object_unref (priv->store);
priv->store = NULL;
}
/* Chain up to parent's dispose() method. */
G_OBJECT_CLASS (em_folder_selection_button_parent_class)->
dispose (object);
......@@ -269,21 +267,14 @@ folder_selection_button_clicked (GtkButton *button)
parent = gtk_widget_get_toplevel (GTK_WIDGET (button));
parent = gtk_widget_is_toplevel (parent) ? parent : NULL;
if (priv->account != NULL && priv->account->source != NULL) {
if (priv->store != NULL) {
EMailSession *session;
CamelService *service;
session = e_mail_backend_get_session (priv->backend);
service = camel_session_get_service (
CAMEL_SESSION (session), priv->account->uid);
if (CAMEL_IS_STORE (service)) {
model = em_folder_tree_model_new ();
em_folder_tree_model_set_session (model, session);
em_folder_tree_model_add_store (
model, CAMEL_STORE (service));
}
model = em_folder_tree_model_new ();
em_folder_tree_model_set_session (model, session);
em_folder_tree_model_add_store (model, priv->store);
}
if (model == NULL)
......@@ -340,16 +331,6 @@ em_folder_selection_button_class_init (EMFolderSelectionButtonClass *class)
button_class = GTK_BUTTON_CLASS (class);
button_class->clicked = folder_selection_button_clicked;
g_object_class_install_property (
object_class,
PROP_ACCOUNT,
g_param_spec_object (
"account",
NULL,
NULL,
E_TYPE_ACCOUNT,
G_PARAM_READWRITE));
g_object_class_install_property (
object_class,
PROP_BACKEND,
......@@ -383,6 +364,16 @@ em_folder_selection_button_class_init (EMFolderSelectionButtonClass *class)
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
g_object_class_install_property (
object_class,
PROP_STORE,
g_param_spec_object (
"store",
NULL,
NULL,
CAMEL_TYPE_STORE,
G_PARAM_READWRITE));
g_object_class_install_property (
object_class,
PROP_TITLE,
......@@ -439,33 +430,6 @@ em_folder_selection_button_new (EMailBackend *backend,
"caption", caption, NULL);
}
EAccount *
em_folder_selection_button_get_account (EMFolderSelectionButton *button)
{
g_return_val_if_fail (EM_IS_FOLDER_SELECTION_BUTTON (button), NULL);
return button->priv->account;
}
void
em_folder_selection_button_set_account (EMFolderSelectionButton *button,
EAccount *account)
{
g_return_if_fail (EM_IS_FOLDER_SELECTION_BUTTON (button));
if (account != NULL) {
g_return_if_fail (E_IS_ACCOUNT (account));
g_object_ref (account);
}
if (button->priv->account != NULL)
g_object_unref (button->priv->account);
button->priv->account = account;
g_object_notify (G_OBJECT (button), "account");
}
EMailBackend *
em_folder_selection_button_get_backend (EMFolderSelectionButton *button)
{
......@@ -539,6 +503,33 @@ em_folder_selection_button_set_folder_uri (EMFolderSelectionButton *button,
g_object_notify (G_OBJECT (button), "folder-uri");
}
CamelStore *
em_folder_selection_button_get_store (EMFolderSelectionButton *button)
{
g_return_val_if_fail (EM_IS_FOLDER_SELECTION_BUTTON (button), NULL);
return button->priv->store;
}
void
em_folder_selection_button_set_store (EMFolderSelectionButton *button,
CamelStore *store)
{
g_return_if_fail (EM_IS_FOLDER_SELECTION_BUTTON (button));
if (store != NULL) {
g_return_if_fail (CAMEL_IS_STORE (store));
g_object_ref (store);
}
if (button->priv->store != NULL)
g_object_unref (button->priv->store);
button->priv->store = store;
g_object_notify (G_OBJECT (button), "store");
}
const gchar *
em_folder_selection_button_get_title (EMFolderSelectionButton *button)
{
......
......@@ -26,7 +26,6 @@
#include <gtk/gtk.h>
#include <mail/e-mail-backend.h>
#include <libedataserver/e-account.h>
/* Standard GObject macros */
#define EM_TYPE_FOLDER_SELECTION_BUTTON \
......@@ -71,11 +70,6 @@ GtkWidget * em_folder_selection_button_new
(EMailBackend *backend,
const gchar *title,
const gchar *caption);
EAccount * em_folder_selection_button_get_account
(EMFolderSelectionButton *button);
void em_folder_selection_button_set_account
(EMFolderSelectionButton *button,
EAccount *account);
EMailBackend * em_folder_selection_button_get_backend
(EMFolderSelectionButton *button);
void em_folder_selection_button_set_backend
......@@ -91,6 +85,11 @@ const gchar * em_folder_selection_button_get_folder_uri
void em_folder_selection_button_set_folder_uri
(EMFolderSelectionButton *button,
const gchar *folder_uri);
CamelStore * em_folder_selection_button_get_store
(EMFolderSelectionButton *button);
void em_folder_selection_button_set_store
(EMFolderSelectionButton *button,
CamelStore *store);
const gchar * em_folder_selection_button_get_title
(EMFolderSelectionButton *button);
void em_folder_selection_button_set_title
......
......@@ -55,6 +55,10 @@
#include "e-mail-store.h"
#include "shell/e-shell.h"
#define EM_FOLDER_TREE_MODEL_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE \
((obj), EM_TYPE_FOLDER_TREE_MODEL, EMFolderTreeModelPrivate))
#define d(x)
struct _EMFolderTreeModelPrivate {
......@@ -316,7 +320,7 @@ folder_tree_model_dispose (GObject *object)
{
EMFolderTreeModelPrivate *priv;
priv = EM_FOLDER_TREE_MODEL (object)->priv;
priv = EM_FOLDER_TREE_MODEL_GET_PRIVATE (object);
if (priv->selection != NULL) {
g_object_weak_unref (
......@@ -339,7 +343,7 @@ folder_tree_model_finalize (GObject *object)
{
EMFolderTreeModelPrivate *priv;
priv = EM_FOLDER_TREE_MODEL (object)->priv;
priv = EM_FOLDER_TREE_MODEL_GET_PRIVATE (object);
g_hash_table_destroy (priv->store_index);
g_hash_table_destroy (priv->uri_index);
......@@ -498,8 +502,7 @@ em_folder_tree_model_init (EMFolderTreeModel *model)
(GDestroyNotify) g_free,
(GDestroyNotify) gtk_tree_row_reference_free);
model->priv = G_TYPE_INSTANCE_GET_PRIVATE (
model, EM_TYPE_FOLDER_TREE_MODEL, EMFolderTreeModelPrivate);
model->priv = EM_FOLDER_TREE_MODEL_GET_PRIVATE (model);
model->priv->store_index = store_index;
model->priv->uri_index = uri_index;
......
......@@ -25,7 +25,6 @@
#include <gtk/gtk.h>
#include <camel/camel.h>
#include <libedataserver/e-account-list.h>
#include <mail/e-mail-session.h>
......
......@@ -39,7 +39,6 @@
#include <gdk/gdkkeysyms.h>
#include <glib/gi18n.h>
#include "e-util/e-account-utils.h"
#include "e-util/e-mktemp.h"
#include "e-util/e-icon-factory.h"
#include "e-util/e-alert-dialog.h"
......@@ -496,10 +495,9 @@ folder_tree_expand_node (const gchar *key,
GtkTreeView *tree_view;
GtkTreeModel *model;
GtkTreePath *path;
EAccount *account;
EMailBackend *backend;
EMailSession *session;
CamelStore *store;
CamelService *service;
const gchar *p;
gchar *uid;
gsize n;
......@@ -520,36 +518,21 @@ folder_tree_expand_node (const gchar *key,
backend = em_folder_tree_get_backend (folder_tree);
session = e_mail_backend_get_session (backend);
if ((account = e_get_account_by_uid (uid)) && account->enabled) {
store = (CamelStore *) camel_session_get_service (
CAMEL_SESSION (session), account->uid);
if (store == NULL)
return;
g_object_ref (store);
} else if (!strcmp (uid, "vfolder")) {
if (!(store = vfolder_store))
return;
g_object_ref (store);