aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--calendar/gui/itip-utils.c12
-rw-r--r--composer/e-composer-actions.c5
-rw-r--r--composer/e-composer-header-table.c27
-rw-r--r--composer/e-composer-private.c31
-rw-r--r--composer/e-composer-private.h2
-rw-r--r--composer/e-msg-composer.c281
-rw-r--r--composer/e-msg-composer.h19
-rw-r--r--mail/e-mail-folder-pane.c21
-rw-r--r--mail/e-mail-reader-utils.c23
-rw-r--r--mail/e-mail-reader.c49
-rw-r--r--mail/em-composer-utils.c395
-rw-r--r--mail/em-composer-utils.h70
-rw-r--r--modules/addressbook/e-book-shell-content.c11
-rw-r--r--modules/addressbook/e-book-shell-view-actions.c20
-rw-r--r--modules/addressbook/eab-composer-util.c14
-rw-r--r--modules/addressbook/eab-composer-util.h8
-rw-r--r--modules/mail/e-mail-attachment-handler.c18
-rw-r--r--modules/mail/e-mail-shell-backend.c26
-rw-r--r--plugins/mailing-list-actions/mailing-list-actions.c9
-rw-r--r--plugins/templates/templates.c6
20 files changed, 733 insertions, 314 deletions
diff --git a/calendar/gui/itip-utils.c b/calendar/gui/itip-utils.c
index d40a7ac633..28d95ac767 100644
--- a/calendar/gui/itip-utils.c
+++ b/calendar/gui/itip-utils.c
@@ -1273,6 +1273,7 @@ itip_send_comp (ECalComponentItipMethod method, ECalComponent *send_comp,
ECal *client, icalcomponent *zones, GSList *attachments_list, GList *users,
gboolean strip_alarms, gboolean only_new_attendees)
{
+ EShell *shell;
EMsgComposer *composer;
EComposerHeaderTable *table;
EDestination **destinations;
@@ -1321,7 +1322,10 @@ itip_send_comp (ECalComponentItipMethod method, ECalComponent *send_comp,
/* Subject information */
subject = comp_subject (method, comp);
- composer = e_msg_composer_new ();
+ /* FIXME Pass this in. */
+ shell = e_shell_get_default ();
+
+ composer = e_msg_composer_new (shell);
table = e_msg_composer_get_header_table (composer);
setup_from (method, send_comp, client, table);
@@ -1402,6 +1406,7 @@ reply_to_calendar_comp (ECalComponentItipMethod method,
icalcomponent *zones,
GSList *attachments_list)
{
+ EShell *shell;
EMsgComposer *composer;
EComposerHeaderTable *table;
EDestination **destinations;
@@ -1423,7 +1428,10 @@ reply_to_calendar_comp (ECalComponentItipMethod method,
/* Subject information */
subject = comp_subject (method, comp);
- composer = e_msg_composer_new ();
+ /* FIXME Pass this in. */
+ shell = e_shell_get_default ();
+
+ composer = e_msg_composer_new (shell);
table = e_msg_composer_get_header_table (composer);
setup_from (method, send_comp, client, table);
diff --git a/composer/e-composer-actions.c b/composer/e-composer-actions.c
index d028beb56f..a49567cea2 100644
--- a/composer/e-composer-actions.c
+++ b/composer/e-composer-actions.c
@@ -208,8 +208,11 @@ action_new_message_cb (GtkAction *action,
EMsgComposer *composer)
{
EMsgComposer *new_composer;
+ EShell *shell;
- new_composer = e_msg_composer_new ();
+ shell = e_msg_composer_get_shell (composer);
+
+ new_composer = e_msg_composer_new (shell);
gtk_widget_show (GTK_WIDGET (new_composer));
}
diff --git a/composer/e-composer-header-table.c b/composer/e-composer-header-table.c
index b83bcd96db..927408222b 100644
--- a/composer/e-composer-header-table.c
+++ b/composer/e-composer-header-table.c
@@ -168,9 +168,13 @@ static void
composer_header_table_notify_widget (GtkWidget *widget,
const gchar *property_name)
{
+ EShell *shell;
GtkWidget *parent;
- if (e_msg_composer_get_lite ()) {
+ /* FIXME Pass this in somehow. */
+ shell = e_shell_get_default ();
+
+ if (e_shell_get_small_screen_mode (shell)) {
parent = gtk_widget_get_parent (widget);
parent = g_object_get_data (G_OBJECT (parent), "pdata");
} else
@@ -516,17 +520,6 @@ composer_header_table_set_shell (EComposerHeaderTable *table,
table->priv->shell = g_object_ref (shell);
}
-static gint
-get_row_padding (void)
-{
- /* For small screens, make the header-table's rows be packed closely together */
-
- if (e_msg_composer_get_lite ())
- return 0;
- else
- return 3;
-}
-
static GObject *
composer_header_table_constructor (GType type,
guint n_construct_properties,
@@ -536,6 +529,7 @@ composer_header_table_constructor (GType type,
EComposerHeaderTablePrivate *priv;
guint rows, ii;
gint row_padding;
+ gboolean small_screen_mode;
/* Chain up to parent's constructor() method. */
object = G_OBJECT_CLASS (parent_class)->constructor (
@@ -543,6 +537,8 @@ composer_header_table_constructor (GType type,
priv = E_COMPOSER_HEADER_TABLE_GET_PRIVATE (object);
+ small_screen_mode = e_shell_get_small_screen_mode (priv->shell);
+
rows = G_N_ELEMENTS (priv->headers);
gtk_table_resize (GTK_TABLE (object), rows, 4);
gtk_table_set_row_spacings (GTK_TABLE (object), 0);
@@ -551,7 +547,8 @@ composer_header_table_constructor (GType type,
/* Use "ypadding" instead of "row-spacing" because some rows may
* be invisible and we don't want spacing around them. */
- row_padding = get_row_padding ();
+ /* For small screens, pack the table's rows closely together. */
+ row_padding = small_screen_mode ? 0 : 3;
for (ii = 0; ii < rows; ii++) {
gtk_table_attach (
@@ -580,13 +577,13 @@ composer_header_table_constructor (GType type,
priv->signature_combo_box, "visible");
/* Now add the signature stuff. */
- if (!e_msg_composer_get_lite ()) {
+ if (!small_screen_mode) {
gtk_table_attach (
GTK_TABLE (object), priv->signature_label,
2, 3, ii, ii + 1, 0, 0, 0, row_padding);
gtk_table_attach (
GTK_TABLE (object), priv->signature_combo_box,
- 3, 4, ii, ii + 1, e_msg_composer_get_lite () ? GTK_FILL: 0, 0, 0, row_padding);
+ 3, 4, ii, ii + 1, 0, 0, 0, row_padding);
} else {
GtkWidget *box = gtk_hbox_new (FALSE, 0);
diff --git a/composer/e-composer-private.c b/composer/e-composer-private.c
index 2e6dad64ac..ed9e19096f 100644
--- a/composer/e-composer-private.c
+++ b/composer/e-composer-private.c
@@ -138,6 +138,7 @@ e_composer_private_constructed (EMsgComposer *composer)
GtkWindow *window;
GtkHTML *html;
const gchar *path;
+ gboolean small_screen_mode;
gchar *filename;
gint ii;
GError *error = NULL;
@@ -146,16 +147,19 @@ e_composer_private_constructed (EMsgComposer *composer)
html = gtkhtml_editor_get_html (editor);
ui_manager = gtkhtml_editor_get_ui_manager (editor);
- shell = e_shell_get_default ();
+ shell = e_msg_composer_get_shell (composer);
+ small_screen_mode = e_shell_get_small_screen_mode (shell);
- if (e_msg_composer_get_lite ()) {
+ if (small_screen_mode) {
#if 0
- /* In the lite composer, for small screens, we are not ready yet
- * to hide the menubar. It still has useful items like the ones
- * to show/hide the various header fields, plus the security options.
+ /* In the lite composer, for small screens, we are not
+ * ready yet to hide the menubar. It still has useful
+ * items like the ones to show/hide the various header
+ * fields, plus the security options.
*
- * When we move those options out of the menu and into the composer's
- * toplevel, we can probably get rid of the menu.
+ * When we move those options out of the menu and into
+ * the composer's toplevel, we can probably get rid of
+ * the menu.
*/
widget = gtkhtml_editor_get_managed_widget (editor, "/main-menu");
gtk_widget_hide (widget);
@@ -255,7 +259,7 @@ e_composer_private_constructed (EMsgComposer *composer)
widget = e_composer_header_table_new (shell);
gtk_container_set_border_width (GTK_CONTAINER (widget), 6);
gtk_box_pack_start (GTK_BOX (editor->vbox), widget, FALSE, FALSE, 0);
- if (e_msg_composer_get_lite ())
+ if (small_screen_mode)
gtk_box_reorder_child (GTK_BOX (editor->vbox), widget, 1);
else
gtk_box_reorder_child (GTK_BOX (editor->vbox), widget, 2);
@@ -265,7 +269,7 @@ e_composer_private_constructed (EMsgComposer *composer)
/* Construct the attachment paned. */
- if (e_msg_composer_get_lite ()) {
+ if (small_screen_mode) {
e_attachment_paned_set_default_height (75); /* short attachment bar for Anjal */
e_attachment_icon_view_set_default_icon_size (GTK_ICON_SIZE_BUTTON);
}
@@ -274,7 +278,7 @@ e_composer_private_constructed (EMsgComposer *composer)
priv->attachment_paned = g_object_ref (widget);
gtk_widget_show (widget);
- if (e_msg_composer_get_lite ()) {
+ if (small_screen_mode) {
GtkWidget *tmp, *tmp1, *tmp_box, *container;
GtkWidget *combo;
@@ -414,6 +418,13 @@ e_composer_private_dispose (EMsgComposer *composer)
g_array_remove_index_fast (array, 0);
}
+ if (composer->priv->shell != NULL) {
+ g_object_remove_weak_pointer (
+ G_OBJECT (composer->priv->shell),
+ &composer->priv->shell);
+ composer->priv->shell = NULL;
+ }
+
if (composer->priv->header_table != NULL) {
g_object_unref (composer->priv->header_table);
composer->priv->header_table = NULL;
diff --git a/composer/e-composer-private.h b/composer/e-composer-private.h
index 570439530a..85b51c0356 100644
--- a/composer/e-composer-private.h
+++ b/composer/e-composer-private.h
@@ -87,6 +87,8 @@ G_BEGIN_DECLS
struct _EMsgComposerPrivate {
+ gpointer shell; /* weak pointer */
+
/*** UI Management ***/
GtkWidget *html_editor;
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index e56bab9362..4a6c6b267f 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -75,7 +75,8 @@
enum {
PROP_0,
- PROP_FOCUS_TRACKER
+ PROP_FOCUS_TRACKER,
+ PROP_SHELL
};
enum {
@@ -1272,19 +1273,19 @@ is_top_signature (EMsgComposer *composer)
if (priv->is_from_message)
return FALSE;
- shell = e_shell_get_default ();
+ shell = e_msg_composer_get_shell (composer);
shell_settings = e_shell_get_shell_settings (shell);
return e_shell_settings_get_boolean (shell_settings, "composer-top-signature");
}
static gboolean
-add_signature_delim (void)
+add_signature_delim (EMsgComposer *composer)
{
EShell *shell;
EShellSettings *shell_settings;
- shell = e_shell_get_default ();
+ shell = e_msg_composer_get_shell (composer);
shell_settings = e_shell_get_shell_settings (shell);
return !e_shell_settings_get_boolean (shell_settings, "composer-no-signature-delim");
@@ -1313,7 +1314,7 @@ get_signature_html (EMsgComposer *composer)
if (!signature)
return NULL;
- add_delim = add_signature_delim ();
+ add_delim = add_signature_delim (composer);
if (!e_signature_get_autogenerated (signature)) {
const gchar *filename;
@@ -1468,12 +1469,14 @@ autosave_load_draft_cb (EMsgComposer *composer,
}
static EMsgComposer *
-autosave_load_draft (const gchar *filename)
+autosave_load_draft (EShell *shell,
+ const gchar *filename)
{
CamelStream *stream;
- CamelMimeMessage *msg;
+ CamelMimeMessage *message;
EMsgComposer *composer;
+ g_return_val_if_fail (E_IS_SHELL (shell), NULL);
g_return_val_if_fail (filename != NULL, NULL);
stream = camel_stream_fs_new_with_name (
@@ -1481,12 +1484,12 @@ autosave_load_draft (const gchar *filename)
if (stream == NULL)
return NULL;
- msg = camel_mime_message_new ();
+ message = camel_mime_message_new ();
camel_data_wrapper_construct_from_stream (
- CAMEL_DATA_WRAPPER (msg), stream, NULL);
+ CAMEL_DATA_WRAPPER (message), stream, NULL);
g_object_unref (stream);
- composer = e_msg_composer_new_with_message (msg);
+ composer = e_msg_composer_new_with_message (shell, message);
if (composer) {
/* Mark the message as changed so it gets autosaved again,
* then we can safely remove the old autosave file in the
@@ -1708,61 +1711,18 @@ msg_composer_notify_header_cb (EMsgComposer *composer)
gtkhtml_editor_set_changed (editor, TRUE);
}
-static void
-msg_composer_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_FOCUS_TRACKER:
- g_value_set_object (
- value, e_msg_composer_get_focus_tracker (
- E_MSG_COMPOSER (object)));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-msg_composer_dispose (GObject *object)
-{
- EMsgComposer *composer = E_MSG_COMPOSER (object);
-
- e_composer_private_dispose (composer);
-
- /* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (parent_class)->dispose (object);
-}
-
-static void
-msg_composer_finalize (GObject *object)
-{
- EMsgComposer *composer = E_MSG_COMPOSER (object);
-
- e_composer_autosave_unregister (composer);
- e_composer_private_finalize (composer);
-
- /* Chain up to parent's finalize() method. */
- G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
static gboolean
-msg_composer_delete_event_cb (GtkWidget *widget, gpointer user_data)
+msg_composer_delete_event_cb (EMsgComposer *composer)
{
EShell *shell;
- shell = e_shell_get_default ();
+ shell = e_msg_composer_get_shell (composer);
if (g_list_length (e_shell_get_watched_windows (shell)) == 1) {
/* This is the last watched window, use the quit
* mechanism to have a draft saved properly */
e_shell_quit (shell, E_SHELL_QUIT_ACTION);
} else {
- /* This is needed for the ACTION macro. */
- EMsgComposer *composer = E_MSG_COMPOSER (widget);
-
/* There are more watched windows opened,
* invoke only a close action */
gtk_action_activate (ACTION (CLOSE));
@@ -1792,10 +1752,6 @@ msg_composer_quit_requested_cb (EShell *shell,
EMsgComposer *composer)
{
if (e_msg_composer_is_exiting (composer)) {
- EShell *shell;
-
- shell = e_shell_get_default ();
-
g_signal_handlers_disconnect_by_func (
shell, msg_composer_quit_requested_cb, composer);
g_signal_handlers_disconnect_by_func (
@@ -1807,6 +1763,82 @@ msg_composer_quit_requested_cb (EShell *shell,
}
static void
+msg_composer_set_shell (EMsgComposer *composer,
+ EShell *shell)
+{
+ g_return_if_fail (E_IS_SHELL (shell));
+ g_return_if_fail (composer->priv->shell == NULL);
+
+ composer->priv->shell = shell;
+
+ g_object_add_weak_pointer (
+ G_OBJECT (shell), &composer->priv->shell);
+}
+
+static void
+msg_composer_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_SHELL:
+ msg_composer_set_shell (
+ E_MSG_COMPOSER (object),
+ g_value_get_object (value));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+msg_composer_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_FOCUS_TRACKER:
+ g_value_set_object (
+ value, e_msg_composer_get_focus_tracker (
+ E_MSG_COMPOSER (object)));
+ return;
+
+ case PROP_SHELL:
+ g_value_set_object (
+ value, e_msg_composer_get_shell (
+ E_MSG_COMPOSER (object)));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+msg_composer_dispose (GObject *object)
+{
+ EMsgComposer *composer = E_MSG_COMPOSER (object);
+
+ e_composer_private_dispose (composer);
+
+ /* Chain up to parent's dispose() method. */
+ G_OBJECT_CLASS (parent_class)->dispose (object);
+}
+
+static void
+msg_composer_finalize (GObject *object)
+{
+ EMsgComposer *composer = E_MSG_COMPOSER (object);
+
+ e_composer_autosave_unregister (composer);
+ e_composer_private_finalize (composer);
+
+ /* Chain up to parent's finalize() method. */
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static void
msg_composer_constructed (GObject *object)
{
EShell *shell;
@@ -1827,9 +1859,14 @@ msg_composer_constructed (GObject *object)
editor = GTKHTML_EDITOR (object);
composer = E_MSG_COMPOSER (object);
- shell = e_shell_get_default ();
+ shell = e_msg_composer_get_shell (composer);
shell_settings = e_shell_get_shell_settings (shell);
+ if (e_shell_get_express_mode (shell)) {
+ GtkWindow *parent = e_shell_get_active_window (shell);
+ gtk_window_set_transient_for (GTK_WINDOW (composer), parent);
+ }
+
e_composer_private_constructed (composer);
html = gtkhtml_editor_get_html (editor);
@@ -1840,16 +1877,19 @@ msg_composer_constructed (GObject *object)
gtk_window_set_title (GTK_WINDOW (composer), _("Compose Message"));
gtk_window_set_icon_name (GTK_WINDOW (composer), "mail-message-new");
- g_signal_connect (object, "delete-event",
+ g_signal_connect (
+ object, "delete-event",
G_CALLBACK (msg_composer_delete_event_cb), NULL);
e_shell_adapt_window_size (shell, GTK_WINDOW (composer));
e_shell_watch_window (shell, GTK_WINDOW (object));
- g_signal_connect (shell, "quit-requested",
+ g_signal_connect (
+ shell, "quit-requested",
G_CALLBACK (msg_composer_quit_requested_cb), composer);
- g_signal_connect (shell, "prepare-for-quit",
+ g_signal_connect (
+ shell, "prepare-for-quit",
G_CALLBACK (msg_composer_prepare_for_quit_cb), composer);
/* Restore Persistent State */
@@ -1962,6 +2002,7 @@ msg_composer_destroy (GtkObject *object)
composer->priv->address_dialog = NULL;
}
+ /* FIXME Our EShell is already unreferenced. */
shell = e_shell_get_default ();
g_signal_handlers_disconnect_by_func (
@@ -2238,6 +2279,7 @@ msg_composer_class_init (EMsgComposerClass *class)
g_type_class_add_private (class, sizeof (EMsgComposerPrivate));
object_class = G_OBJECT_CLASS (class);
+ object_class->set_property = msg_composer_set_property;
object_class->get_property = msg_composer_get_property;
object_class->dispose = msg_composer_dispose;
object_class->finalize = msg_composer_finalize;
@@ -2271,6 +2313,17 @@ msg_composer_class_init (EMsgComposerClass *class)
E_TYPE_FOCUS_TRACKER,
G_PARAM_READABLE));
+ g_object_class_install_property (
+ object_class,
+ PROP_SHELL,
+ g_param_spec_object (
+ "shell",
+ "Shell",
+ "The EShell singleton",
+ E_TYPE_SHELL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+
signals[SEND] = g_signal_new (
"send",
G_OBJECT_CLASS_TYPE (class),
@@ -2300,14 +2353,7 @@ msg_composer_class_init (EMsgComposerClass *class)
static void
msg_composer_init (EMsgComposer *composer)
{
- EShell *shell = e_shell_get_default ();
-
composer->priv = E_MSG_COMPOSER_GET_PRIVATE (composer);
-
- if (e_shell_get_express_mode (shell)) {
- GtkWindow *window = e_shell_get_active_window(shell);
- gtk_window_set_transient_for (GTK_WINDOW(composer), window);
- }
}
GType
@@ -2340,34 +2386,20 @@ e_msg_composer_get_type (void)
/**
* e_msg_composer_new:
+ * @shell: an #EShell
*
* Create a new message composer widget.
*
* Returns: A pointer to the newly created widget
**/
EMsgComposer *
-e_msg_composer_new (void)
+e_msg_composer_new (EShell *shell)
{
+ g_return_val_if_fail (E_IS_SHELL (shell), NULL);
+
return g_object_new (
E_TYPE_MSG_COMPOSER,
- "html", e_web_view_new (), NULL);
-}
-
-/**
- * e_msg_composer_get_lite:
- *
- * Used within the composer to see if it should be made suitable for small
- * screens.
- *
- * Return value: whether the surrounding #EShell is in small screen mode.
- */
-gboolean
-e_msg_composer_get_lite (void)
-{
- EShell *shell;
-
- shell = e_shell_get_default ();
- return e_shell_get_small_screen_mode (shell);
+ "html", e_web_view_new (), "shell", shell, NULL);
}
EFocusTracker *
@@ -2823,6 +2855,7 @@ set_signature_gui (EMsgComposer *composer)
/**
* e_msg_composer_new_with_message:
+ * @shell: an #EShell
* @message: The message to use as the source
*
* Create a new message composer widget.
@@ -2832,7 +2865,8 @@ set_signature_gui (EMsgComposer *composer)
* Returns: A pointer to the newly created widget
**/
EMsgComposer *
-e_msg_composer_new_with_message (CamelMimeMessage *message)
+e_msg_composer_new_with_message (EShell *shell,
+ CamelMimeMessage *message)
{
CamelInternetAddress *to, *cc, *bcc;
GList *To = NULL, *Cc = NULL, *Bcc = NULL, *postto = NULL;
@@ -2851,12 +2885,14 @@ e_msg_composer_new_with_message (CamelMimeMessage *message)
struct _camel_header_raw *xev;
gint len, i;
+ g_return_val_if_fail (E_IS_SHELL (shell), NULL);
+
for (headers = CAMEL_MIME_PART (message)->headers;headers;headers = headers->next) {
if (!strcmp (headers->name, "X-Evolution-PostTo"))
postto = g_list_append (postto, g_strstrip (g_strdup (headers->value)));
}
- composer = e_msg_composer_new ();
+ composer = e_msg_composer_new (shell);
priv = E_MSG_COMPOSER_GET_PRIVATE (composer);
table = e_msg_composer_get_header_table (composer);
@@ -3154,6 +3190,7 @@ disable_editor (EMsgComposer *composer)
/**
* e_msg_composer_new_redirect:
+ * @shell: an #EShell
* @message: The message to use as the source
*
* Create a new message composer widget.
@@ -3161,16 +3198,18 @@ disable_editor (EMsgComposer *composer)
* Returns: A pointer to the newly created widget
**/
EMsgComposer *
-e_msg_composer_new_redirect (CamelMimeMessage *message,
+e_msg_composer_new_redirect (EShell *shell,
+ CamelMimeMessage *message,
const gchar *resent_from)
{
EMsgComposer *composer;
EComposerHeaderTable *table;
const gchar *subject;
+ g_return_val_if_fail (E_IS_SHELL (shell), NULL);
g_return_val_if_fail (CAMEL_IS_MIME_MESSAGE (message), NULL);
- composer = e_msg_composer_new_with_message (message);
+ composer = e_msg_composer_new_with_message (shell, message);
table = e_msg_composer_get_header_table (composer);
subject = camel_mime_message_get_subject (message);
@@ -3202,11 +3241,9 @@ e_msg_composer_get_session (EMsgComposer *composer)
EShellSettings *shell_settings;
CamelSession *session;
- /* FIXME EMsgComposer should own a reference to EShell. */
-
g_return_val_if_fail (E_IS_MSG_COMPOSER (composer), NULL);
- shell = e_shell_get_default ();
+ shell = e_msg_composer_get_shell (composer);
shell_settings = e_shell_get_shell_settings (shell);
session = e_shell_settings_get_pointer (shell_settings, "mail-session");
@@ -3216,6 +3253,22 @@ e_msg_composer_get_session (EMsgComposer *composer)
}
/**
+ * e_msg_composer_get_shell:
+ * @composer: an #EMsgComposer
+ *
+ * Returns the #EShell that was passed to e_msg_composer_new().
+ *
+ * Returns: the #EShell
+ **/
+EShell *
+e_msg_composer_get_shell (EMsgComposer *composer)
+{
+ g_return_val_if_fail (E_IS_MSG_COMPOSER (composer), NULL);
+
+ return E_SHELL (composer->priv->shell);
+}
+
+/**
* e_msg_composer_send:
* @composer: an #EMsgComposer
*
@@ -3443,21 +3496,22 @@ handle_mailto (EMsgComposer *composer, const gchar *mailto)
/**
* e_msg_composer_new_from_url:
+ * @shell: an #EShell
* @url: a mailto URL
*
* Create a new message composer widget, and fill in fields as
* defined by the provided URL.
**/
EMsgComposer *
-e_msg_composer_new_from_url (const gchar *url)
+e_msg_composer_new_from_url (EShell *shell,
+ const gchar *url)
{
EMsgComposer *composer;
+ g_return_val_if_fail (E_IS_SHELL (shell), NULL);
g_return_val_if_fail (g_ascii_strncasecmp (url, "mailto:", 7) == 0, NULL);
- composer = e_msg_composer_new ();
- if (!composer)
- return NULL;
+ composer = e_msg_composer_new (shell);
handle_mailto (composer, url);
@@ -3815,12 +3869,15 @@ CamelMimeMessage *
e_msg_composer_get_message_print (EMsgComposer *composer,
gboolean save_html_object_data)
{
+ EShell *shell;
GtkhtmlEditor *editor;
EMsgComposer *temp_composer;
CamelMimeMessage *msg;
gboolean html_content;
gchar *flags;
+ g_return_val_if_fail (E_IS_MSG_COMPOSER (composer), NULL);
+
editor = GTKHTML_EDITOR (composer);
html_content = gtkhtml_editor_get_html_mode (editor);
@@ -3828,7 +3885,8 @@ e_msg_composer_get_message_print (EMsgComposer *composer,
if (msg == NULL)
return NULL;
- temp_composer = e_msg_composer_new_with_message (msg);
+ shell = e_msg_composer_get_shell (composer);
+ temp_composer = e_msg_composer_new_with_message (shell, msg);
g_object_unref (msg);
/* Override composer flags. */
@@ -4140,12 +4198,14 @@ e_msg_composer_can_close (EMsgComposer *composer,
}
EMsgComposer *
-e_msg_composer_load_from_file (const gchar *filename)
+e_msg_composer_load_from_file (EShell *shell,
+ const gchar *filename)
{
CamelStream *stream;
- CamelMimeMessage *msg;
+ CamelMimeMessage *message;
EMsgComposer *composer;
+ g_return_val_if_fail (E_IS_SHELL (shell), NULL);
g_return_val_if_fail (filename != NULL, NULL);
stream = camel_stream_fs_new_with_name (
@@ -4153,12 +4213,12 @@ e_msg_composer_load_from_file (const gchar *filename)
if (stream == NULL)
return NULL;
- msg = camel_mime_message_new ();
+ message = camel_mime_message_new ();
camel_data_wrapper_construct_from_stream (
- CAMEL_DATA_WRAPPER (msg), stream, NULL);
+ CAMEL_DATA_WRAPPER (message), stream, NULL);
g_object_unref (stream);
- composer = e_msg_composer_new_with_message (msg);
+ composer = e_msg_composer_new_with_message (shell, message);
if (composer != NULL)
gtk_widget_show (GTK_WIDGET (composer));
@@ -4166,12 +4226,17 @@ e_msg_composer_load_from_file (const gchar *filename)
}
void
-e_msg_composer_check_autosave (GtkWindow *parent)
+e_msg_composer_check_autosave (EShell *shell)
{
+ GtkWindow *parent;
GList *orphans = NULL;
gint response;
GError *error = NULL;
+ g_return_if_fail (E_IS_SHELL (shell));
+
+ parent = e_shell_get_active_window (shell);
+
/* Look for orphaned autosave files. */
orphans = e_composer_autosave_find_orphans (&error);
if (orphans == NULL) {
@@ -4193,7 +4258,7 @@ e_msg_composer_check_autosave (GtkWindow *parent)
if (response == GTK_RESPONSE_YES) {
/* FIXME: composer is never used */
- composer = autosave_load_draft (filename);
+ composer = autosave_load_draft (shell, filename);
} else {
g_unlink (filename);
}
diff --git a/composer/e-msg-composer.h b/composer/e-msg-composer.h
index b10253d6eb..92368a4384 100644
--- a/composer/e-msg-composer.h
+++ b/composer/e-msg-composer.h
@@ -30,6 +30,7 @@
#include <gtkhtml-editor.h>
#include <misc/e-attachment-view.h>
#include <misc/e-focus-tracker.h>
+#include <shell/e-shell.h>
#include "e-composer-header-table.h"
@@ -68,14 +69,17 @@ struct _EMsgComposerClass {
};
GType e_msg_composer_get_type (void);
-EMsgComposer * e_msg_composer_new (void);
-gboolean e_msg_composer_get_lite (void);
-EMsgComposer * e_msg_composer_new_with_message (CamelMimeMessage *msg);
-EMsgComposer * e_msg_composer_new_from_url (const gchar *url);
-EMsgComposer * e_msg_composer_new_redirect (CamelMimeMessage *message,
+EMsgComposer * e_msg_composer_new (EShell *shell);
+EMsgComposer * e_msg_composer_new_with_message (EShell *shell,
+ CamelMimeMessage *msg);
+EMsgComposer * e_msg_composer_new_from_url (EShell *shell,
+ const gchar *url);
+EMsgComposer * e_msg_composer_new_redirect (EShell *shell,
+ CamelMimeMessage *message,
const gchar *resent_from);
EFocusTracker * e_msg_composer_get_focus_tracker(EMsgComposer *composer);
CamelSession * e_msg_composer_get_session (EMsgComposer *composer);
+EShell * e_msg_composer_get_shell (EMsgComposer *composer);
void e_msg_composer_send (EMsgComposer *composer);
void e_msg_composer_save_draft (EMsgComposer *composer);
@@ -137,8 +141,9 @@ void e_msg_composer_request_close (EMsgComposer *composer);
gboolean e_msg_composer_can_close (EMsgComposer *composer,
gboolean can_save_draft);
-EMsgComposer * e_msg_composer_load_from_file (const gchar *filename);
-void e_msg_composer_check_autosave (GtkWindow *parent);
+EMsgComposer * e_msg_composer_load_from_file (EShell *shell,
+ const gchar *filename);
+void e_msg_composer_check_autosave (EShell *shell);
void e_msg_composer_reply_indent (EMsgComposer *composer);
diff --git a/mail/e-mail-folder-pane.c b/mail/e-mail-folder-pane.c
index d12cc48acf..6d2be33a3e 100644
--- a/mail/e-mail-folder-pane.c
+++ b/mail/e-mail-folder-pane.c
@@ -67,6 +67,9 @@ folder_pane_set_preview_visible (EMailView *view,
static guint
mail_paned_view_open_selected_mail (EMailPanedView *view)
{
+ EShell *shell;
+ EShellBackend *shell_backend;
+ EMailReader *reader;
GPtrArray *uids;
gint i;
GtkWindow *window;
@@ -75,19 +78,24 @@ mail_paned_view_open_selected_mail (EMailPanedView *view)
GPtrArray *views;
guint n_views, ii;
- uids = e_mail_reader_get_selected_uids (E_MAIL_READER(view));
- window = e_mail_reader_get_window (E_MAIL_READER(view));
+ reader = E_MAIL_READER (view);
+
+ shell_backend = e_mail_reader_get_shell_backend (reader);
+ shell = e_shell_backend_get_shell (shell_backend);
+
+ uids = e_mail_reader_get_selected_uids (reader);
+ window = e_mail_reader_get_window (reader);
if (!em_utils_ask_open_many (window, uids->len)) {
em_utils_uids_free (uids);
return 0;
}
- folder = e_mail_reader_get_folder (E_MAIL_READER(view));
- folder_uri = e_mail_reader_get_folder_uri (E_MAIL_READER(view));
+ folder = e_mail_reader_get_folder (reader);
+ folder_uri = e_mail_reader_get_folder_uri (reader);
if (em_utils_folder_is_drafts (folder, folder_uri) ||
em_utils_folder_is_outbox (folder, folder_uri) ||
em_utils_folder_is_templates (folder, folder_uri)) {
- em_utils_edit_messages (folder, uids, TRUE);
+ em_utils_edit_messages (shell, folder, uids, TRUE);
return 0;
}
@@ -120,7 +128,8 @@ mail_paned_view_open_selected_mail (EMailPanedView *view)
edits = g_ptr_array_new ();
g_ptr_array_add (edits, real_uid);
- em_utils_edit_messages (real_folder, edits, TRUE);
+ em_utils_edit_messages (
+ shell, real_folder, edits, TRUE);
} else {
g_free (real_uid);
g_ptr_array_add (views, g_strdup (uid));
diff --git a/mail/e-mail-reader-utils.c b/mail/e-mail-reader-utils.c
index bdef954709..a7bddfebd2 100644
--- a/mail/e-mail-reader-utils.c
+++ b/mail/e-mail-reader-utils.c
@@ -188,6 +188,7 @@ e_mail_reader_mark_selected (EMailReader *reader,
guint
e_mail_reader_open_selected (EMailReader *reader)
{
+ EShell *shell;
EShellBackend *shell_backend;
CamelFolder *folder;
GtkWindow *window;
@@ -198,9 +199,11 @@ e_mail_reader_open_selected (EMailReader *reader)
g_return_val_if_fail (E_IS_MAIL_READER (reader), 0);
+ shell_backend = e_mail_reader_get_shell_backend (reader);
+ shell = e_shell_backend_get_shell (shell_backend);
+
folder = e_mail_reader_get_folder (reader);
folder_uri = e_mail_reader_get_folder_uri (reader);
- shell_backend = e_mail_reader_get_shell_backend (reader);
uids = e_mail_reader_get_selected_uids (reader);
window = e_mail_reader_get_window (reader);
@@ -212,7 +215,7 @@ e_mail_reader_open_selected (EMailReader *reader)
if (em_utils_folder_is_drafts (folder, folder_uri) ||
em_utils_folder_is_outbox (folder, folder_uri) ||
em_utils_folder_is_templates (folder, folder_uri)) {
- em_utils_edit_messages (folder, uids, TRUE);
+ em_utils_edit_messages (shell, folder, uids, TRUE);
return uids->len;
}
@@ -246,7 +249,8 @@ e_mail_reader_open_selected (EMailReader *reader)
edits = g_ptr_array_new ();
g_ptr_array_add (edits, real_uid);
- em_utils_edit_messages (real_folder, edits, TRUE);
+ em_utils_edit_messages (
+ shell, real_folder, edits, TRUE);
} else {
g_free (real_uid);
g_ptr_array_add (views, g_strdup (uid));
@@ -357,6 +361,8 @@ e_mail_reader_reply_to_message (EMailReader *reader,
CamelMimeMessage *src_message,
gint reply_mode)
{
+ EShell *shell;
+ EShellBackend *shell_backend;
EMFormatHTML *formatter;
GtkWidget *message_list;
CamelMimeMessage *new_message;
@@ -373,6 +379,9 @@ e_mail_reader_reply_to_message (EMailReader *reader,
g_return_if_fail (E_IS_MAIL_READER (reader));
+ shell_backend = e_mail_reader_get_shell_backend (reader);
+ shell = e_shell_backend_get_shell (shell_backend);
+
formatter = e_mail_reader_get_formatter (reader);
web_view = em_format_html_get_web_view (formatter);
@@ -422,9 +431,10 @@ e_mail_reader_reply_to_message (EMailReader *reader,
CAMEL_MIME_PART (new_message),
selection, length, "text/html");
- g_object_unref(src_message);
+ g_object_unref (src_message);
+
em_utils_reply_to_message (
- folder, uid, new_message, reply_mode, NULL);
+ shell, folder, uid, new_message, reply_mode, NULL);
g_free (selection);
@@ -432,7 +442,8 @@ e_mail_reader_reply_to_message (EMailReader *reader,
whole_message:
em_utils_reply_to_message (
- folder, uid, src_message, reply_mode, EM_FORMAT (formatter));
+ shell, folder, uid, src_message,
+ reply_mode, EM_FORMAT (formatter));
}
void
diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c
index 5a0ef4628d..22dccb96ca 100644
--- a/mail/e-mail-reader.c
+++ b/mail/e-mail-reader.c
@@ -420,11 +420,16 @@ static void
action_mail_forward_cb (GtkAction *action,
EMailReader *reader)
{
+ EShell *shell;
+ EShellBackend *shell_backend;
CamelFolder *folder;
GtkWindow *window;
GPtrArray *uids;
const gchar *folder_uri;
+ shell_backend = e_mail_reader_get_shell_backend (reader);
+ shell = e_shell_backend_get_shell (shell_backend);
+
folder = e_mail_reader_get_folder (reader);
folder_uri = e_mail_reader_get_folder_uri (reader);
uids = e_mail_reader_get_selected_uids (reader);
@@ -433,7 +438,7 @@ action_mail_forward_cb (GtkAction *action,
g_return_if_fail (uids != NULL);
if (em_utils_ask_open_many (window, uids->len))
- em_utils_forward_messages (folder, uids, folder_uri);
+ em_utils_forward_messages (shell, folder, uids, folder_uri);
else
em_utils_uids_free (uids);
}
@@ -442,11 +447,16 @@ static void
action_mail_forward_attached_cb (GtkAction *action,
EMailReader *reader)
{
+ EShell *shell;
+ EShellBackend *shell_backend;
CamelFolder *folder;
GtkWindow *window;
GPtrArray *uids;
const gchar *folder_uri;
+ shell_backend = e_mail_reader_get_shell_backend (reader);
+ shell = e_shell_backend_get_shell (shell_backend);
+
folder = e_mail_reader_get_folder (reader);
folder_uri = e_mail_reader_get_folder_uri (reader);
uids = e_mail_reader_get_selected_uids (reader);
@@ -455,7 +465,7 @@ action_mail_forward_attached_cb (GtkAction *action,
g_return_if_fail (uids != NULL);
if (em_utils_ask_open_many (window, uids->len))
- em_utils_forward_attached (folder, uids, folder_uri);
+ em_utils_forward_attached (shell, folder, uids, folder_uri);
else
em_utils_uids_free (uids);
}
@@ -464,11 +474,16 @@ static void
action_mail_forward_inline_cb (GtkAction *action,
EMailReader *reader)
{
+ EShell *shell;
+ EShellBackend *shell_backend;
CamelFolder *folder;
GtkWindow *window;
GPtrArray *uids;
const gchar *folder_uri;
+ shell_backend = e_mail_reader_get_shell_backend (reader);
+ shell = e_shell_backend_get_shell (shell_backend);
+
folder = e_mail_reader_get_folder (reader);
folder_uri = e_mail_reader_get_folder_uri (reader);
uids = e_mail_reader_get_selected_uids (reader);
@@ -477,7 +492,7 @@ action_mail_forward_inline_cb (GtkAction *action,
g_return_if_fail (uids != NULL);
if (em_utils_ask_open_many (window, uids->len))
- em_utils_forward_inline (folder, uids, folder_uri);
+ em_utils_forward_inline (shell, folder, uids, folder_uri);
else
em_utils_uids_free (uids);
}
@@ -486,11 +501,16 @@ static void
action_mail_forward_quoted_cb (GtkAction *action,
EMailReader *reader)
{
+ EShell *shell;
+ EShellBackend *shell_backend;
CamelFolder *folder;
GtkWindow *window;
GPtrArray *uids;
const gchar *folder_uri;
+ shell_backend = e_mail_reader_get_shell_backend (reader);
+ shell = e_shell_backend_get_shell (shell_backend);
+
folder = e_mail_reader_get_folder (reader);
folder_uri = e_mail_reader_get_folder_uri (reader);
uids = e_mail_reader_get_selected_uids (reader);
@@ -499,7 +519,7 @@ action_mail_forward_quoted_cb (GtkAction *action,
g_return_if_fail (uids != NULL);
if (em_utils_ask_open_many (window, uids->len))
- em_utils_forward_quoted (folder, uids, folder_uri);
+ em_utils_forward_quoted (shell, folder, uids, folder_uri);
else
em_utils_uids_free (uids);
}
@@ -601,24 +621,34 @@ static void
action_mail_message_edit_cb (GtkAction *action,
EMailReader *reader)
{
+ EShell *shell;
+ EShellBackend *shell_backend;
CamelFolder *folder;
GPtrArray *uids;
+ shell_backend = e_mail_reader_get_shell_backend (reader);
+ shell = e_shell_backend_get_shell (shell_backend);
+
folder = e_mail_reader_get_folder (reader);
uids = e_mail_reader_get_selected_uids (reader);
- em_utils_edit_messages (folder, uids, FALSE);
+ em_utils_edit_messages (shell, folder, uids, FALSE);
}
static void
action_mail_message_new_cb (GtkAction *action,
EMailReader *reader)
{
+ EShell *shell;
+ EShellBackend *shell_backend;
const gchar *folder_uri;
+ shell_backend = e_mail_reader_get_shell_backend (reader);
+ shell = e_shell_backend_get_shell (shell_backend);
+
folder_uri = e_mail_reader_get_folder_uri (reader);
- em_utils_compose_new_message (folder_uri);
+ em_utils_compose_new_message (shell, folder_uri);
}
static void
@@ -867,17 +897,22 @@ static void
action_mail_redirect_cb (GtkAction *action,
EMailReader *reader)
{
+ EShell *shell;
+ EShellBackend *shell_backend;
GtkWidget *message_list;
CamelFolder *folder;
const gchar *uid;
+ shell_backend = e_mail_reader_get_shell_backend (reader);
+ shell = e_shell_backend_get_shell (shell_backend);
+
folder = e_mail_reader_get_folder (reader);
message_list = e_mail_reader_get_message_list (reader);
uid = MESSAGE_LIST (message_list)->cursor_uid;
g_return_if_fail (uid != NULL);
- em_utils_redirect_message_by_uid (folder, uid);
+ em_utils_redirect_message_by_uid (shell, folder, uid);
}
static void
diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c
index d01a421013..137b246259 100644
--- a/mail/em-composer-utils.c
+++ b/mail/em-composer-utils.c
@@ -707,22 +707,24 @@ em_utils_composer_print_cb (EMsgComposer *composer,
/* Composing messages... */
static EMsgComposer *
-create_new_composer (const gchar *subject, const gchar *fromuri)
+create_new_composer (EShell *shell,
+ const gchar *subject,
+ const gchar *from_uri)
{
EMsgComposer *composer;
EComposerHeaderTable *table;
EAccount *account = NULL;
- composer = e_msg_composer_new ();
+ composer = e_msg_composer_new (shell);
table = e_msg_composer_get_header_table (composer);
- if (fromuri != NULL) {
+ if (from_uri != NULL) {
GList *list;
- account = mail_config_get_account_by_source_url(fromuri);
+ account = mail_config_get_account_by_source_url(from_uri);
- list = g_list_prepend (NULL, (gpointer) fromuri);
+ list = g_list_prepend (NULL, (gpointer) from_uri);
e_composer_header_table_set_post_to_list (table, list);
g_list_free (list);
}
@@ -735,16 +737,20 @@ create_new_composer (const gchar *subject, const gchar *fromuri)
/**
* em_utils_compose_new_message:
+ * @shell: an #EShell
*
* Opens a new composer window as a child window of @parent's toplevel
* window.
**/
void
-em_utils_compose_new_message (const gchar *fromuri)
+em_utils_compose_new_message (EShell *shell,
+ const gchar *from_uri)
{
GtkWidget *composer;
- composer = (GtkWidget *) create_new_composer ("", fromuri);
+ g_return_if_fail (E_IS_SHELL (shell));
+
+ composer = (GtkWidget *) create_new_composer (shell, "", from_uri);
if (composer == NULL)
return;
@@ -755,6 +761,7 @@ em_utils_compose_new_message (const gchar *fromuri)
/**
* em_utils_compose_new_message_with_mailto:
+ * @shell: an #EShell
* @url: mailto url
*
* Opens a new composer window as a child window of @parent's toplevel
@@ -762,21 +769,25 @@ em_utils_compose_new_message (const gchar *fromuri)
* according to the values in the mailto url.
**/
EMsgComposer *
-em_utils_compose_new_message_with_mailto (const gchar *url, const gchar *fromuri)
+em_utils_compose_new_message_with_mailto (EShell *shell,
+ const gchar *url,
+ const gchar *from_uri)
{
EMsgComposer *composer;
EComposerHeaderTable *table;
EAccount *account = NULL;
+ g_return_val_if_fail (E_IS_SHELL (shell), NULL);
+
if (url != NULL)
- composer = e_msg_composer_new_from_url (url);
+ composer = e_msg_composer_new_from_url (shell, url);
else
- composer = e_msg_composer_new ();
+ composer = e_msg_composer_new (shell);
table = e_msg_composer_get_header_table (composer);
- if (fromuri
- && (account = mail_config_get_account_by_source_url(fromuri)))
+ if (from_uri
+ && (account = mail_config_get_account_by_source_url(from_uri)))
e_composer_header_table_set_account_name (table, account->name);
composer_set_no_change (composer);
@@ -929,7 +940,10 @@ traverse_parts (GSList *clues, CamelMimeMessage *message, CamelDataWrapper *cont
/* Editing messages... */
static GtkWidget *
-edit_message (CamelMimeMessage *message, CamelFolder *drafts, const gchar *uid)
+edit_message (EShell *shell,
+ CamelMimeMessage *message,
+ CamelFolder *drafts,
+ const gchar *uid)
{
EMsgComposer *composer;
@@ -949,7 +963,7 @@ edit_message (CamelMimeMessage *message, CamelFolder *drafts, const gchar *uid)
g_slist_free (clue_list);
}
- composer = e_msg_composer_new_with_message (message);
+ composer = e_msg_composer_new_with_message (shell, message);
if (em_utils_folder_is_drafts (drafts, NULL)) {
struct emcs_t *emcs;
@@ -967,6 +981,7 @@ edit_message (CamelMimeMessage *message, CamelFolder *drafts, const gchar *uid)
/**
* em_utils_edit_message:
+ * @shell: an #EShell
* @message: message to edit
* @folder: used to recognize the templates folder
*
@@ -974,40 +989,61 @@ edit_message (CamelMimeMessage *message, CamelFolder *drafts, const gchar *uid)
* @message.
**/
GtkWidget *
-em_utils_edit_message (CamelMimeMessage *message, CamelFolder *folder)
+em_utils_edit_message (EShell *shell,
+ CamelMimeMessage *message,
+ CamelFolder *folder)
{
- GtkWidget *composer = NULL;
+ g_return_val_if_fail (E_IS_SHELL (shell), NULL);
g_return_val_if_fail (CAMEL_IS_MIME_MESSAGE (message), NULL);
- if (folder)
- composer = edit_message (message, folder, NULL);
- else
- composer = edit_message (message, NULL, NULL);
-
- return composer;
+ return edit_message (shell, message, folder, NULL);
}
static void
-edit_messages (CamelFolder *folder, GPtrArray *uids, GPtrArray *msgs, gpointer user_data)
+edit_messages_replace (CamelFolder *folder,
+ GPtrArray *uids,
+ GPtrArray *msgs,
+ gpointer user_data)
{
- gboolean replace = GPOINTER_TO_INT (user_data);
- gint i;
+ EShell *shell = E_SHELL (user_data);
+ gint ii;
if (msgs == NULL)
return;
- for (i = 0; i < msgs->len; i++) {
- camel_medium_remove_header (CAMEL_MEDIUM (msgs->pdata[i]), "X-Mailer");
+ for (ii = 0; ii < msgs->len; ii++) {
+ camel_medium_remove_header (
+ CAMEL_MEDIUM (msgs->pdata[ii]), "X-Mailer");
+ edit_message (shell, msgs->pdata[ii], folder, uids->pdata[ii]);
+ }
- if (replace)
- edit_message (msgs->pdata[i], folder, uids->pdata[i]);
- else
- edit_message (msgs->pdata[i], NULL, NULL);
+ g_object_unref (shell);
+}
+
+static void
+edit_messages_no_replace (CamelFolder *folder,
+ GPtrArray *uids,
+ GPtrArray *msgs,
+ gpointer user_data)
+{
+ EShell *shell = E_SHELL (user_data);
+ gint ii;
+
+ if (msgs == NULL)
+ return;
+
+ for (ii = 0; ii < msgs->len; ii++) {
+ camel_medium_remove_header (
+ CAMEL_MEDIUM (msgs->pdata[ii]), "X-Mailer");
+ edit_message (shell, msgs->pdata[ii], NULL, NULL);
}
+
+ g_object_unref (shell);
}
/**
* em_utils_edit_messages:
+ * @shell: an #EShell
* @folder: folder containing messages to edit
* @uids: uids of messages to edit
* @replace: replace the existing message(s) when sent or saved.
@@ -1015,12 +1051,23 @@ edit_messages (CamelFolder *folder, GPtrArray *uids, GPtrArray *msgs, gpointer u
* Opens a composer for each message to be edited.
**/
void
-em_utils_edit_messages (CamelFolder *folder, GPtrArray *uids, gboolean replace)
+em_utils_edit_messages (EShell *shell,
+ CamelFolder *folder,
+ GPtrArray *uids,
+ gboolean replace)
{
+ g_return_if_fail (E_IS_SHELL (shell));
g_return_if_fail (CAMEL_IS_FOLDER (folder));
g_return_if_fail (uids != NULL);
- mail_get_messages (folder, uids, edit_messages, GINT_TO_POINTER (replace));
+ if (replace)
+ mail_get_messages (
+ folder, uids, edit_messages_replace,
+ g_object_ref (shell));
+ else
+ mail_get_messages (
+ folder, uids, edit_messages_no_replace,
+ g_object_ref (shell));
}
static void
@@ -1051,9 +1098,10 @@ emu_update_composers_security (EMsgComposer *composer, guint32 validity_found)
/* Forwarding messages... */
struct forward_attached_data
{
+ EShell *shell;
CamelFolder *folder;
GPtrArray *uids;
- gchar *fromuri;
+ gchar *from_uri;
};
static void
@@ -1105,11 +1153,17 @@ setup_forward_attached_callbacks (EMsgComposer *composer, CamelFolder *folder, G
}
static EMsgComposer *
-forward_attached (CamelFolder *folder, GPtrArray *uids, GPtrArray *messages, CamelMimePart *part, gchar *subject, const gchar *fromuri)
+forward_attached (EShell *shell,
+ CamelFolder *folder,
+ GPtrArray *uids,
+ GPtrArray *messages,
+ CamelMimePart *part,
+ gchar *subject,
+ const gchar *from_uri)
{
EMsgComposer *composer;
- composer = create_new_composer (subject, fromuri);
+ composer = create_new_composer (shell, subject, from_uri);
if (composer == NULL)
return NULL;
@@ -1126,22 +1180,30 @@ forward_attached (CamelFolder *folder, GPtrArray *uids, GPtrArray *messages, Cam
}
static void
-forward_attached_cb (CamelFolder *folder, GPtrArray *messages, CamelMimePart *part, gchar *subject, gpointer user_data)
+forward_attached_cb (CamelFolder *folder,
+ GPtrArray *messages,
+ CamelMimePart *part,
+ gchar *subject,
+ gpointer user_data)
{
- struct forward_attached_data *fad = (struct forward_attached_data *) user_data;
+ struct forward_attached_data *fad = user_data;
if (part)
- forward_attached (folder, fad->uids, messages, part, subject, fad->fromuri);
+ forward_attached (
+ fad->shell, folder, fad->uids,
+ messages, part, subject, fad->from_uri);
- g_free (fad->fromuri);
+ g_object_unref (fad->shell);
+ g_free (fad->from_uri);
g_free (fad);
}
/**
* em_utils_forward_attached:
+ * @shell: an #EShell
* @folder: folder containing messages to forward
* @uids: uids of messages to forward
- * @fromuri: from folder uri
+ * @from_uri: from folder uri
*
* If there is more than a single message in @uids, a multipart/digest
* will be constructed and attached to a new composer window preset
@@ -1150,22 +1212,32 @@ forward_attached_cb (CamelFolder *folder, GPtrArray *messages, CamelMimePart *pa
* forwarded as a simple message/rfc822 attachment.
**/
void
-em_utils_forward_attached (CamelFolder *folder, GPtrArray *uids, const gchar *fromuri)
+em_utils_forward_attached (EShell *shell,
+ CamelFolder *folder,
+ GPtrArray *uids,
+ const gchar *from_uri)
{
struct forward_attached_data *fad;
+ g_return_if_fail (E_IS_SHELL (shell));
g_return_if_fail (CAMEL_IS_FOLDER (folder));
g_return_if_fail (uids != NULL);
fad = g_new0 (struct forward_attached_data, 1);
+ fad->shell = g_object_ref (shell);
fad->uids = uids;
- fad->fromuri = g_strdup (fromuri);
+ fad->from_uri = g_strdup (from_uri);
mail_build_attachment (folder, uids, forward_attached_cb, fad);
}
-static struct _EMsgComposer *
-forward_non_attached (CamelFolder *folder, GPtrArray *uids, GPtrArray *messages, gint style, const gchar *fromuri)
+static EMsgComposer *
+forward_non_attached (EShell *shell,
+ CamelFolder *folder,
+ GPtrArray *uids,
+ GPtrArray *messages,
+ gint style,
+ const gchar *from_uri)
{
CamelMimeMessage *message;
EMsgComposer *composer = NULL;
@@ -1190,7 +1262,7 @@ forward_non_attached (CamelFolder *folder, GPtrArray *uids, GPtrArray *messages,
text = em_utils_message_to_html (message, _("-------- Forwarded Message --------"), flags, &len, NULL, NULL, &validity_found);
if (text) {
- composer = create_new_composer (subject, fromuri);
+ composer = create_new_composer (shell, subject, from_uri);
if (composer) {
if (CAMEL_IS_MULTIPART(camel_medium_get_content ((CamelMedium *)message)))
@@ -1218,65 +1290,114 @@ forward_non_attached (CamelFolder *folder, GPtrArray *uids, GPtrArray *messages,
return composer;
}
+typedef struct {
+ EShell *shell;
+ gchar *from_uri;
+} ForwardData;
+
static void
-forward_inline (CamelFolder *folder, GPtrArray *uids, GPtrArray *messages, gpointer user_data)
+forward_inline_cb (CamelFolder *folder,
+ GPtrArray *uids,
+ GPtrArray *messages,
+ gpointer user_data)
{
- forward_non_attached (folder, uids, messages, MAIL_CONFIG_FORWARD_INLINE, (gchar *)user_data);
- g_free(user_data);
+ ForwardData *data = user_data;
+
+ forward_non_attached (
+ data->shell, folder, uids, messages,
+ MAIL_CONFIG_FORWARD_INLINE, data->from_uri);
+
+ g_free (data->from_uri);
+ g_object_unref (data->shell);
+ g_slice_free (ForwardData, data);
}
/**
* em_utils_forward_inline:
+ * @shell: an #EShell
* @folder: folder containing messages to forward
* @uids: uids of messages to forward
- * @fromuri: from folder/account uri
+ * @from_uri: from folder/account uri
*
* Forwards each message in the 'inline' form, each in its own composer window.
**/
void
-em_utils_forward_inline (CamelFolder *folder, GPtrArray *uids, const gchar *fromuri)
+em_utils_forward_inline (EShell *shell,
+ CamelFolder *folder,
+ GPtrArray *uids,
+ const gchar *from_uri)
{
+ ForwardData *data;
+
+ g_return_if_fail (E_IS_SHELL (shell));
g_return_if_fail (CAMEL_IS_FOLDER (folder));
g_return_if_fail (uids != NULL);
- mail_get_messages (folder, uids, forward_inline, g_strdup(fromuri));
+ data = g_slice_new (ForwardData);
+ data->shell = g_object_ref (shell);
+ data->from_uri = g_strdup (from_uri);
+
+ mail_get_messages (folder, uids, forward_inline_cb, data);
}
static void
-forward_quoted (CamelFolder *folder, GPtrArray *uids, GPtrArray *messages, gpointer user_data)
+forward_quoted_cb (CamelFolder *folder,
+ GPtrArray *uids,
+ GPtrArray *messages,
+ gpointer user_data)
{
- forward_non_attached (folder, uids, messages, MAIL_CONFIG_FORWARD_QUOTED, (gchar *)user_data);
- g_free(user_data);
+ ForwardData *data = user_data;
+
+ forward_non_attached (
+ data->shell, folder, uids, messages,
+ MAIL_CONFIG_FORWARD_QUOTED, data->from_uri);
+
+ g_free (data->from_uri);
+ g_object_unref (data->shell);
+ g_slice_free (ForwardData, data);
}
/**
* em_utils_forward_quoted:
+ * @shell: an #EShell
* @folder: folder containing messages to forward
* @uids: uids of messages to forward
- * @fromuri: from folder uri
+ * @from_uri: from folder uri
*
* Forwards each message in the 'quoted' form (each line starting with
* a "> "), each in its own composer window.
**/
void
-em_utils_forward_quoted (CamelFolder *folder, GPtrArray *uids, const gchar *fromuri)
+em_utils_forward_quoted (EShell *shell,
+ CamelFolder *folder,
+ GPtrArray *uids,
+ const gchar *from_uri)
{
+ ForwardData *data;
+
+ g_return_if_fail (E_IS_SHELL (shell));
g_return_if_fail (CAMEL_IS_FOLDER (folder));
g_return_if_fail (uids != NULL);
- mail_get_messages (folder, uids, forward_quoted, g_strdup(fromuri));
+ data = g_slice_new (ForwardData);
+ data->shell = g_object_ref (shell);
+ data->from_uri = g_strdup (from_uri);
+
+ mail_get_messages (folder, uids, forward_quoted_cb, data);
}
/**
* em_utils_forward_message:
- * @parent: parent window
+ * @shell: an #EShell
* @message: message to be forwarded
- * @fromuri: from folder uri
+ * @from_uri: from folder uri
*
* Forwards a message in the user's configured default style.
**/
EMsgComposer *
-em_utils_forward_message (CamelMimeMessage *message, const gchar *fromuri)
+em_utils_forward_message (EShell *shell,
+ CamelMimeMessage *message,
+ const gchar *from_uri)
{
GPtrArray *messages;
CamelMimePart *part;
@@ -1284,6 +1405,9 @@ em_utils_forward_message (CamelMimeMessage *message, const gchar *fromuri)
gchar *subject;
gint mode;
EMsgComposer *composer = NULL;
+
+ g_return_val_if_fail (E_IS_SHELL (shell), NULL);
+
messages = g_ptr_array_new ();
g_ptr_array_add (messages, message);
@@ -1291,22 +1415,30 @@ em_utils_forward_message (CamelMimeMessage *message, const gchar *fromuri)
mode = gconf_client_get_int (gconf, "/apps/evolution/mail/format/forward_style", NULL);
switch (mode) {
- case MAIL_CONFIG_FORWARD_ATTACHED:
- default:
- part = mail_tool_make_message_attachment (message);
+ case MAIL_CONFIG_FORWARD_ATTACHED:
+ default:
+ part = mail_tool_make_message_attachment (message);
+ subject = mail_tool_generate_forward_subject (message);
- subject = mail_tool_generate_forward_subject (message);
+ composer = forward_attached (
+ shell, NULL, NULL, messages,
+ part, subject, from_uri);
- composer = forward_attached (NULL, NULL, messages, part, subject, fromuri);
- g_object_unref (part);
- g_free (subject);
- break;
- case MAIL_CONFIG_FORWARD_INLINE:
- composer = forward_non_attached (NULL, NULL, messages, MAIL_CONFIG_FORWARD_INLINE, fromuri);
- break;
- case MAIL_CONFIG_FORWARD_QUOTED:
- composer = forward_non_attached (NULL, NULL, messages, MAIL_CONFIG_FORWARD_QUOTED, fromuri);
- break;
+ g_object_unref (part);
+ g_free (subject);
+ break;
+
+ case MAIL_CONFIG_FORWARD_INLINE:
+ composer = forward_non_attached (
+ shell, NULL, NULL, messages,
+ MAIL_CONFIG_FORWARD_INLINE, from_uri);
+ break;
+
+ case MAIL_CONFIG_FORWARD_QUOTED:
+ composer = forward_non_attached (
+ shell, NULL, NULL, messages,
+ MAIL_CONFIG_FORWARD_QUOTED, from_uri);
+ break;
}
g_ptr_array_free (messages, TRUE);
@@ -1316,6 +1448,7 @@ em_utils_forward_message (CamelMimeMessage *message, const gchar *fromuri)
/**
* em_utils_forward_messages:
+ * @shell: an #EShell
* @folder: folder containing messages to forward
* @uids: uids of messages to forward
*
@@ -1323,32 +1456,38 @@ em_utils_forward_message (CamelMimeMessage *message, const gchar *fromuri)
* style.
**/
void
-em_utils_forward_messages (CamelFolder *folder, GPtrArray *uids, const gchar *fromuri)
+em_utils_forward_messages (EShell *shell,
+ CamelFolder *folder,
+ GPtrArray *uids,
+ const gchar *from_uri)
{
GConfClient *gconf;
gint mode;
+ g_return_if_fail (E_IS_SHELL (shell));
+
gconf = mail_config_get_gconf_client ();
mode = gconf_client_get_int (gconf, "/apps/evolution/mail/format/forward_style", NULL);
switch (mode) {
- case MAIL_CONFIG_FORWARD_ATTACHED:
- default:
- em_utils_forward_attached (folder, uids, fromuri);
- break;
- case MAIL_CONFIG_FORWARD_INLINE:
- em_utils_forward_inline (folder, uids, fromuri);
- break;
- case MAIL_CONFIG_FORWARD_QUOTED:
- em_utils_forward_quoted (folder, uids, fromuri);
- break;
+ case MAIL_CONFIG_FORWARD_ATTACHED:
+ default:
+ em_utils_forward_attached (shell, folder, uids, from_uri);
+ break;
+ case MAIL_CONFIG_FORWARD_INLINE:
+ em_utils_forward_inline (shell, folder, uids, from_uri);
+ break;
+ case MAIL_CONFIG_FORWARD_QUOTED:
+ em_utils_forward_quoted (shell, folder, uids, from_uri);
+ break;
}
}
/* Redirecting messages... */
static EMsgComposer *
-redirect_get_composer (CamelMimeMessage *message)
+redirect_get_composer (EShell *shell,
+ CamelMimeMessage *message)
{
EMsgComposer *composer;
EAccount *account;
@@ -1361,26 +1500,30 @@ redirect_get_composer (CamelMimeMessage *message)
account = em_utils_guess_account_with_recipients (message, NULL);
- composer = e_msg_composer_new_redirect (message, account ? account->name : NULL);
+ composer = e_msg_composer_new_redirect (
+ shell, message, account ? account->name : NULL);
return composer;
}
/**
* em_utils_redirect_message:
+ * @shell: an #EShell
* @message: message to redirect
*
* Opens a composer to redirect @message (Note: only headers will be
* editable). Adds Resent-From/Resent-To/etc headers.
**/
void
-em_utils_redirect_message (CamelMimeMessage *message)
+em_utils_redirect_message (EShell *shell,
+ CamelMimeMessage *message)
{
EMsgComposer *composer;
+ g_return_if_fail (E_IS_SHELL (shell));
g_return_if_fail (CAMEL_IS_MIME_MESSAGE (message));
- composer = redirect_get_composer (message);
+ composer = redirect_get_composer (shell, message);
gtk_widget_show (GTK_WIDGET (composer));
@@ -1388,16 +1531,24 @@ em_utils_redirect_message (CamelMimeMessage *message)
}
static void
-redirect_msg (CamelFolder *folder, const gchar *uid, CamelMimeMessage *message, gpointer user_data)
+redirect_msg (CamelFolder *folder,
+ const gchar *uid,
+ CamelMimeMessage *message,
+ gpointer user_data)
{
+ EShell *shell = E_SHELL (user_data);
+
if (message == NULL)
return;
- em_utils_redirect_message (message);
+ em_utils_redirect_message (shell, message);
+
+ g_object_unref (shell);
}
/**
* em_utils_redirect_message_by_uid:
+ * @shell: an #EShell
* @folder: folder containing message to be redirected
* @uid: uid of message to be redirected
*
@@ -1405,12 +1556,17 @@ redirect_msg (CamelFolder *folder, const gchar *uid, CamelMimeMessage *message,
* be editable). Adds Resent-From/Resent-To/etc headers.
**/
void
-em_utils_redirect_message_by_uid (CamelFolder *folder, const gchar *uid)
+em_utils_redirect_message_by_uid (EShell *shell,
+ CamelFolder *folder,
+ const gchar *uid)
{
+ g_return_if_fail (E_IS_SHELL (shell));
g_return_if_fail (CAMEL_IS_FOLDER (folder));
g_return_if_fail (uid != NULL);
- mail_get_message (folder, uid, redirect_msg, NULL, mail_msg_unordered_push);
+ mail_get_message (
+ folder, uid, redirect_msg,
+ g_object_ref (shell), mail_msg_unordered_push);
}
static void
@@ -1648,9 +1804,13 @@ em_utils_camel_address_to_destination (CamelInternetAddress *iaddr)
}
static EMsgComposer *
-reply_get_composer (CamelMimeMessage *message, EAccount *account,
- CamelInternetAddress *to, CamelInternetAddress *cc,
- CamelFolder *folder, CamelNNTPAddress *postto)
+reply_get_composer (EShell *shell,
+ CamelMimeMessage *message,
+ EAccount *account,
+ CamelInternetAddress *to,
+ CamelInternetAddress *cc,
+ CamelFolder *folder,
+ CamelNNTPAddress *postto)
{
const gchar *message_id, *references;
EDestination **tov, **ccv;
@@ -1658,11 +1818,12 @@ reply_get_composer (CamelMimeMessage *message, EAccount *account,
EComposerHeaderTable *table;
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);
- composer = e_msg_composer_new ();
+ composer = e_msg_composer_new (shell);
/* construct the tov/ccv */
tov = em_utils_camel_address_to_destination (to);
@@ -2215,6 +2376,7 @@ composer_set_body (EMsgComposer *composer, CamelMimeMessage *message, EMFormat *
}
struct _reply_data {
+ EShell *shell;
EMFormat *source;
gint mode;
};
@@ -2234,7 +2396,10 @@ em_utils_construct_composer_text (CamelMimeMessage *message, EMFormat *source)
}
static void
-reply_to_message(CamelFolder *folder, const gchar *uid, CamelMimeMessage *message, gpointer user_data)
+reply_to_message (CamelFolder *folder,
+ const gchar *uid,
+ CamelMimeMessage *message,
+ gpointer user_data)
{
struct _reply_data *rd = user_data;
@@ -2242,15 +2407,22 @@ reply_to_message(CamelFolder *folder, const gchar *uid, CamelMimeMessage *messag
/* get_message_free() will also unref the message, so we need
an extra ref for em_utils_reply_to_message() to drop. */
g_object_ref(message);
- em_utils_reply_to_message(folder, uid, message, rd->mode, rd->source);
+ em_utils_reply_to_message (
+ rd->shell, folder, uid, message, rd->mode, rd->source);
}
- if (rd->source)
- g_object_unref(rd->source);
- g_free(rd);
+
+ if (rd->shell != NULL)
+ g_object_unref (rd->shell);
+
+ if (rd->source != NULL)
+ g_object_unref (rd->source);
+
+ g_free (rd);
}
/**
* em_utils_reply_to_message:
+ * @shell: an #EShell
* @folder: optional folder
* @uid: optional uid
* @message: message to reply to, optional
@@ -2267,7 +2439,12 @@ reply_to_message(CamelFolder *folder, const gchar *uid, CamelMimeMessage *messag
* been replied to. Note that @message will be unreferenced on completion.
**/
EMsgComposer *
-em_utils_reply_to_message(CamelFolder *folder, const gchar *uid, CamelMimeMessage *message, gint mode, EMFormat *source)
+em_utils_reply_to_message (EShell *shell,
+ CamelFolder *folder,
+ const gchar *uid,
+ CamelMimeMessage *message,
+ gint mode,
+ EMFormat *source)
{
CamelInternetAddress *to, *cc;
CamelNNTPAddress *postto = NULL;
@@ -2276,14 +2453,19 @@ em_utils_reply_to_message(CamelFolder *folder, const gchar *uid, CamelMimeMessag
guint32 flags;
struct emcs_t *emcs;
+ g_return_val_if_fail (E_IS_SHELL (shell), NULL);
+
if (folder && uid && message == NULL) {
struct _reply_data *rd = g_malloc0(sizeof(*rd));
+ rd->shell = g_object_ref (shell);
rd->mode = mode;
rd->source = source;
if (rd->source)
g_object_ref(rd->source);
- mail_get_message(folder, uid, reply_to_message, rd, mail_msg_unordered_push);
+ mail_get_message (
+ folder, uid, reply_to_message,
+ rd, mail_msg_unordered_push);
return NULL;
}
@@ -2323,7 +2505,8 @@ em_utils_reply_to_message(CamelFolder *folder, const gchar *uid, CamelMimeMessag
break;
}
- composer = reply_get_composer (message, account, to, cc, folder, postto);
+ composer = reply_get_composer (
+ shell, message, account, to, cc, folder, postto);
e_msg_composer_add_message_attachments (composer, message, TRUE);
if (postto)
diff --git a/mail/em-composer-utils.h b/mail/em-composer-utils.h
index eaa46d9d20..5bf6924898 100644
--- a/mail/em-composer-utils.h
+++ b/mail/em-composer-utils.h
@@ -29,28 +29,52 @@
G_BEGIN_DECLS
-void em_utils_compose_new_message (const gchar *fromuri);
-
-/* FIXME: mailto? url? should make up its mind what its called. imho use 'uri' */
-EMsgComposer * em_utils_compose_new_message_with_mailto (const gchar *url, const gchar *fromuri);
-
-GtkWidget * em_utils_edit_message (CamelMimeMessage *message, CamelFolder *folder);
-void em_utils_edit_messages (CamelFolder *folder, GPtrArray *uids, gboolean replace);
-
-void em_utils_forward_attached (CamelFolder *folder, GPtrArray *uids, const gchar *fromuri);
-void em_utils_forward_inline (CamelFolder *folder, GPtrArray *uids, const gchar *fromuri);
-void em_utils_forward_quoted (CamelFolder *folder, GPtrArray *uids, const gchar *fromuri);
-
-struct _EMsgComposer * em_utils_forward_message (CamelMimeMessage *msg, const gchar *fromuri);
-void em_utils_forward_messages (CamelFolder *folder, GPtrArray *uids, const gchar *fromuri);
-
-void em_utils_redirect_message (CamelMimeMessage *message);
-void em_utils_redirect_message_by_uid (CamelFolder *folder, const gchar *uid);
-
-void em_utils_forward_message_raw (CamelFolder *folder, CamelMimeMessage *message, const gchar *address, GError **error);
-
-void em_utils_handle_receipt (CamelFolder *folder, const gchar *uid, CamelMimeMessage *msg);
-void em_utils_send_receipt (CamelFolder *folder, CamelMimeMessage *message);
+void em_utils_compose_new_message (EShell *shell,
+ const gchar *from_uri);
+EMsgComposer * em_utils_compose_new_message_with_mailto
+ (EShell *shell,
+ const gchar *url,
+ const gchar *from_uri);
+GtkWidget * em_utils_edit_message (EShell *shell,
+ CamelMimeMessage *message,
+ CamelFolder *folder);
+void em_utils_edit_messages (EShell *shell,
+ CamelFolder *folder,
+ GPtrArray *uids,
+ gboolean replace);
+void em_utils_forward_attached (EShell *shell,
+ CamelFolder *folder,
+ GPtrArray *uids,
+ const gchar *from_uri);
+void em_utils_forward_inline (EShell *shell,
+ CamelFolder *folder,
+ GPtrArray *uids,
+ const gchar *from_uri);
+void em_utils_forward_quoted (EShell *shell,
+ CamelFolder *folder,
+ GPtrArray *uids,
+ const gchar *from_uri);
+EMsgComposer * em_utils_forward_message (EShell *shell,
+ CamelMimeMessage *msg,
+ const gchar *from_uri);
+void em_utils_forward_messages (EShell *shell,
+ CamelFolder *folder,
+ GPtrArray *uids,
+ const gchar *from_uri);
+void em_utils_redirect_message (EShell *shell,
+ CamelMimeMessage *message);
+void em_utils_redirect_message_by_uid(EShell *shell,
+ CamelFolder *folder,
+ const gchar *uid);
+void em_utils_forward_message_raw (CamelFolder *folder,
+ CamelMimeMessage *message,
+ const gchar *address,
+ GError **error);
+void em_utils_handle_receipt (CamelFolder *folder,
+ const gchar *uid,
+ CamelMimeMessage *msg);
+void em_utils_send_receipt (CamelFolder *folder,
+ CamelMimeMessage *message);
enum {
REPLY_MODE_SENDER, /* Reply-To?:From */
@@ -63,7 +87,7 @@ gchar *em_utils_construct_composer_text (CamelMimeMessage *message, EMFormat *so
gboolean em_utils_is_munged_list_message (CamelMimeMessage *message);
void em_utils_get_reply_sender (CamelMimeMessage *message, CamelInternetAddress *to, CamelNNTPAddress *postto);
void em_utils_get_reply_all (CamelMimeMessage *message, CamelInternetAddress *to, CamelInternetAddress *cc, CamelNNTPAddress *postto);
-EMsgComposer * em_utils_reply_to_message (CamelFolder *, const gchar *uid, CamelMimeMessage *message, gint mode, EMFormat *source);
+EMsgComposer * em_utils_reply_to_message (EShell *shell, CamelFolder *, const gchar *uid, CamelMimeMessage *message, gint mode, EMFormat *source);
EDestination ** em_utils_camel_address_to_destination (CamelInternetAddress *iaddr);
void em_configure_new_composer (struct _EMsgComposer *composer);
diff --git a/modules/addressbook/e-book-shell-content.c b/modules/addressbook/e-book-shell-content.c
index bc374079a3..13b9b4bd49 100644
--- a/modules/addressbook/e-book-shell-content.c
+++ b/modules/addressbook/e-book-shell-content.c
@@ -61,9 +61,18 @@ book_shell_content_send_message_cb (EBookShellContent *book_shell_content,
EDestination *destination,
EABContactDisplay *display)
{
+ EShell *shell;
+ EShellContent *shell_content;
+ EShellWindow *shell_window;
+ EShellView *shell_view;
GList node = { destination, NULL, NULL };
- eab_send_as_to (&node);
+ shell_content = E_SHELL_CONTENT (book_shell_content);
+ shell_view = e_shell_content_get_shell_view (shell_content);
+ shell_window = e_shell_view_get_shell_window (shell_view);
+ shell = e_shell_window_get_shell (shell_window);
+
+ eab_send_as_to (shell, &node);
}
static void
diff --git a/modules/addressbook/e-book-shell-view-actions.c b/modules/addressbook/e-book-shell-view-actions.c
index 6bb9d7036b..9008002c33 100644
--- a/modules/addressbook/e-book-shell-view-actions.c
+++ b/modules/addressbook/e-book-shell-view-actions.c
@@ -358,10 +358,17 @@ static void
action_contact_forward_cb (GtkAction *action,
EBookShellView *book_shell_view)
{
+ EShell *shell;
+ EShellView *shell_view;
+ EShellWindow *shell_window;
EBookShellContent *book_shell_content;
EAddressbookView *view;
GList *list, *iter;
+ shell_view = E_SHELL_VIEW (book_shell_view);
+ shell_window = e_shell_view_get_shell_window (shell_view);
+ shell = e_shell_window_get_shell (shell_window);
+
book_shell_content = book_shell_view->priv->book_shell_content;
view = e_book_shell_content_get_current_view (book_shell_content);
g_return_if_fail (view != NULL);
@@ -381,7 +388,8 @@ action_contact_forward_cb (GtkAction *action,
iter->data = destination;
}
- eab_send_as_attachment (list);
+ eab_send_as_attachment (shell, list);
+
g_list_foreach (list, (GFunc) g_object_unref, NULL);
g_list_free (list);
}
@@ -581,10 +589,17 @@ static void
action_contact_send_message_cb (GtkAction *action,
EBookShellView *book_shell_view)
{
+ EShell *shell;
+ EShellView *shell_view;
+ EShellWindow *shell_window;
EBookShellContent *book_shell_content;
EAddressbookView *view;
GList *list, *iter;
+ shell_view = E_SHELL_VIEW (book_shell_view);
+ shell_window = e_shell_view_get_shell_window (shell_view);
+ shell = e_shell_window_get_shell (shell_window);
+
book_shell_content = book_shell_view->priv->book_shell_content;
view = e_book_shell_content_get_current_view (book_shell_content);
g_return_if_fail (view != NULL);
@@ -604,7 +619,8 @@ action_contact_send_message_cb (GtkAction *action,
iter->data = destination;
}
- eab_send_as_to (list);
+ eab_send_as_to (shell, list);
+
g_list_foreach (list, (GFunc) g_object_unref, NULL);
g_list_free (list);
}
diff --git a/modules/addressbook/eab-composer-util.c b/modules/addressbook/eab-composer-util.c
index 968a6b3c06..542e423d4d 100644
--- a/modules/addressbook/eab-composer-util.c
+++ b/modules/addressbook/eab-composer-util.c
@@ -28,7 +28,8 @@
#include "addressbook/gui/widgets/eab-gui-util.h"
void
-eab_send_as_to (GList *destinations)
+eab_send_as_to (EShell *shell,
+ GList *destinations)
{
EMsgComposer *composer;
EComposerHeaderTable *table;
@@ -40,10 +41,12 @@ eab_send_as_to (GList *destinations)
EDestination **destinations;
} convert;
+ g_return_if_fail (E_IS_SHELL (shell));
+
if (destinations == NULL)
return;
- composer = e_msg_composer_new ();
+ composer = e_msg_composer_new (shell);
table = e_msg_composer_get_header_table (composer);
to_array = g_ptr_array_new ();
@@ -107,7 +110,8 @@ get_email (EContact *contact, EContactField field_id, gchar **to_free)
}
void
-eab_send_as_attachment (GList *destinations)
+eab_send_as_attachment (EShell *shell,
+ GList *destinations)
{
EMsgComposer *composer;
EComposerHeaderTable *table;
@@ -115,10 +119,12 @@ eab_send_as_attachment (GList *destinations)
GList *contacts, *iter;
gchar *data;
+ g_return_if_fail (E_IS_SHELL (shell));
+
if (destinations == NULL)
return;
- composer = e_msg_composer_new ();
+ composer = e_msg_composer_new (shell);
table = e_msg_composer_get_header_table (composer);
attachment = camel_mime_part_new ();
diff --git a/modules/addressbook/eab-composer-util.h b/modules/addressbook/eab-composer-util.h
index 4aec23074d..a2feb2f999 100644
--- a/modules/addressbook/eab-composer-util.h
+++ b/modules/addressbook/eab-composer-util.h
@@ -19,12 +19,14 @@
#ifndef EAB_COMPOSER_UTIL_H
#define EAB_COMPOSER_UTIL_H
-#include <gtk/gtk.h>
+#include <shell/e-shell.h>
G_BEGIN_DECLS
-void eab_send_as_to (GList *destinations);
-void eab_send_as_attachment (GList *destinations);
+void eab_send_as_to (EShell *shell,
+ GList *destinations);
+void eab_send_as_attachment (EShell *shell,
+ GList *destinations);
G_END_DECLS
diff --git a/modules/mail/e-mail-attachment-handler.c b/modules/mail/e-mail-attachment-handler.c
index 3240c560de..313dddeac4 100644
--- a/modules/mail/e-mail-attachment-handler.c
+++ b/modules/mail/e-mail-attachment-handler.c
@@ -59,11 +59,15 @@ static void
mail_attachment_handler_forward (GtkAction *action,
EAttachmentView *view)
{
+ EShell *shell;
EAttachment *attachment;
CamelMimePart *mime_part;
CamelDataWrapper *wrapper;
GList *selected;
+ /* FIXME Pass this in somehow. */
+ shell = e_shell_get_default ();
+
selected = e_attachment_view_get_selected_attachments (view);
g_return_if_fail (g_list_length (selected) == 1);
@@ -71,7 +75,7 @@ mail_attachment_handler_forward (GtkAction *action,
mime_part = e_attachment_get_mime_part (attachment);
wrapper = camel_medium_get_content (CAMEL_MEDIUM (mime_part));
- em_utils_forward_message (CAMEL_MIME_MESSAGE (wrapper), NULL);
+ em_utils_forward_message (shell, CAMEL_MIME_MESSAGE (wrapper), NULL);
g_list_foreach (selected, (GFunc) g_object_unref, NULL);
g_list_free (selected);
@@ -81,11 +85,15 @@ static void
mail_attachment_handler_reply_all (GtkAction *action,
EAttachmentView *view)
{
+ EShell *shell;
EAttachment *attachment;
CamelMimePart *mime_part;
CamelDataWrapper *wrapper;
GList *selected;
+ /* FIXME Pass this in somehow. */
+ shell = e_shell_get_default ();
+
selected = e_attachment_view_get_selected_attachments (view);
g_return_if_fail (g_list_length (selected) == 1);
@@ -94,7 +102,7 @@ mail_attachment_handler_reply_all (GtkAction *action,
wrapper = camel_medium_get_content (CAMEL_MEDIUM (mime_part));
em_utils_reply_to_message (
- NULL, NULL, CAMEL_MIME_MESSAGE (wrapper),
+ shell, NULL, NULL, CAMEL_MIME_MESSAGE (wrapper),
REPLY_MODE_ALL, NULL);
g_list_foreach (selected, (GFunc) g_object_unref, NULL);
@@ -105,11 +113,15 @@ static void
mail_attachment_handler_reply_sender (GtkAction *action,
EAttachmentView *view)
{
+ EShell *shell;
EAttachment *attachment;
CamelMimePart *mime_part;
CamelDataWrapper *wrapper;
GList *selected;
+ /* FIXME Pass this in somehow. */
+ shell = e_shell_get_default ();
+
selected = e_attachment_view_get_selected_attachments (view);
g_return_if_fail (g_list_length (selected) == 1);
@@ -118,7 +130,7 @@ mail_attachment_handler_reply_sender (GtkAction *action,
wrapper = camel_medium_get_content (CAMEL_MEDIUM (mime_part));
em_utils_reply_to_message (
- NULL, NULL, CAMEL_MIME_MESSAGE (wrapper),
+ shell, NULL, NULL, CAMEL_MIME_MESSAGE (wrapper),
REPLY_MODE_SENDER, NULL);
g_list_foreach (selected, (GFunc) g_object_unref, NULL);
diff --git a/modules/mail/e-mail-shell-backend.c b/modules/mail/e-mail-shell-backend.c
index 09f5068e82..d740094a15 100644
--- a/modules/mail/e-mail-shell-backend.c
+++ b/modules/mail/e-mail-shell-backend.c
@@ -136,10 +136,13 @@ action_mail_message_new_cb (GtkAction *action,
EMailShellSidebar *mail_shell_sidebar;
EShellSidebar *shell_sidebar;
EShellView *shell_view;
+ EShell *shell;
EMFolderTree *folder_tree;
const gchar *view_name;
gchar *uri = NULL;
+ shell = e_shell_window_get_shell (shell_window);
+
if (!em_utils_check_user_can_send_mail ())
return;
@@ -156,7 +159,7 @@ action_mail_message_new_cb (GtkAction *action,
uri = em_folder_tree_get_selected_uri (folder_tree);
exit:
- em_utils_compose_new_message (uri);
+ em_utils_compose_new_message (shell, uri);
g_free (uri);
}
@@ -235,10 +238,13 @@ mail_shell_backend_handle_email_uri_cb (gchar *folder_uri,
{
EShellBackend *shell_backend = user_data;
CamelURL *url = user_data;
+ EShell *shell;
const gchar *forward;
const gchar *reply;
const gchar *uid;
+ shell = e_shell_backend_get_shell (shell_backend);
+
if (folder == NULL) {
g_warning ("Could not open folder '%s'", folder_uri);
goto exit;
@@ -258,7 +264,8 @@ mail_shell_backend_handle_email_uri_cb (gchar *folder_uri,
else
mode = REPLY_MODE_SENDER;
- em_utils_reply_to_message (folder, uid, NULL, mode, NULL);
+ em_utils_reply_to_message (
+ shell, folder, uid, NULL, mode, NULL);
} else if (forward != NULL) {
GPtrArray *uids;
@@ -267,13 +274,17 @@ mail_shell_backend_handle_email_uri_cb (gchar *folder_uri,
g_ptr_array_add (uids, g_strdup (uid));
if (g_strcmp0 (forward, "attached") == 0)
- em_utils_forward_attached (folder, uids, folder_uri);
+ em_utils_forward_attached (
+ shell, folder, uids, folder_uri);
else if (g_strcmp0 (forward, "inline") == 0)
- em_utils_forward_inline (folder, uids, folder_uri);
+ em_utils_forward_inline (
+ shell, folder, uids, folder_uri);
else if (g_strcmp0 (forward, "quoted") == 0)
- em_utils_forward_quoted (folder, uids, folder_uri);
+ em_utils_forward_quoted (
+ shell, folder, uids, folder_uri);
else
- em_utils_forward_messages (folder, uids, folder_uri);
+ em_utils_forward_messages (
+ shell, folder, uids, folder_uri);
} else {
GtkWidget *browser;
@@ -299,7 +310,8 @@ mail_shell_backend_handle_uri_cb (EShell *shell,
if (g_str_has_prefix (uri, "mailto:")) {
if (em_utils_check_user_can_send_mail ())
- em_utils_compose_new_message_with_mailto (uri, NULL);
+ em_utils_compose_new_message_with_mailto (
+ shell, uri, NULL);
} else if (g_str_has_prefix (uri, "email:")) {
CamelURL *url;
diff --git a/plugins/mailing-list-actions/mailing-list-actions.c b/plugins/mailing-list-actions/mailing-list-actions.c
index ce60275db7..70520e1155 100644
--- a/plugins/mailing-list-actions/mailing-list-actions.c
+++ b/plugins/mailing-list-actions/mailing-list-actions.c
@@ -116,12 +116,17 @@ emla_list_action_do (CamelFolder *folder,
gint t;
EMsgComposer *composer;
gint send_message_response;
+ EShellBackend *shell_backend;
+ EShell *shell;
EAccount *account;
GtkWindow *window;
if (msg == NULL)
return;
+ shell_backend = e_mail_reader_get_shell_backend (action_data->reader);
+ shell = e_shell_backend_get_shell (shell_backend);
+
window = e_mail_reader_get_window (action_data->reader);
for (t = 0; t < G_N_ELEMENTS (emla_action_headers); t++) {
@@ -172,7 +177,7 @@ emla_list_action_do (CamelFolder *folder,
if (send_message_response == GTK_RESPONSE_YES) {
/* directly send message */
- composer = e_msg_composer_new_from_url (url);
+ composer = e_msg_composer_new_from_url (shell, url);
if ((account = mail_config_get_account_by_source_url (action_data->uri)))
e_composer_header_table_set_account (
e_msg_composer_get_header_table (composer),
@@ -180,7 +185,7 @@ emla_list_action_do (CamelFolder *folder,
e_msg_composer_send (composer);
} else if (send_message_response == GTK_RESPONSE_NO) {
/* show composer */
- em_utils_compose_new_message_with_mailto (url, action_data->uri);
+ em_utils_compose_new_message_with_mailto (shell, url, action_data->uri);
}
goto exit;
diff --git a/plugins/templates/templates.c b/plugins/templates/templates.c
index 5bf3eb7e65..04ac8a5748 100644
--- a/plugins/templates/templates.c
+++ b/plugins/templates/templates.c
@@ -470,10 +470,14 @@ create_new_message (CamelFolder *folder, const gchar *uid, CamelMimeMessage *mes
CamelMimeMessage *new, *template;
struct _camel_header_raw *header;
CamelStream *mem;
+ EShell *shell;
g_return_if_fail (data != NULL);
g_return_if_fail (message != NULL);
+ /* FIXME Pass this in somehow. */
+ shell = e_shell_get_default ();
+
folder = e_mail_local_get_folder (E_MAIL_FOLDER_TEMPLATES);
template = g_object_get_data (G_OBJECT (action), "template");
@@ -513,7 +517,7 @@ create_new_message (CamelFolder *folder, const gchar *uid, CamelMimeMessage *mes
camel_mime_message_get_recipients (template, CAMEL_RECIPIENT_TYPE_BCC));
/* Create the composer */
- em_utils_edit_message (new, folder);
+ em_utils_edit_message (shell, new, folder);
g_object_unref (new);
}