aboutsummaryrefslogtreecommitdiffstats
path: root/composer
diff options
context:
space:
mode:
Diffstat (limited to 'composer')
-rw-r--r--composer/Makefile.am7
-rw-r--r--composer/e-composer-actions.c33
-rw-r--r--composer/e-composer-header-table.c1
-rw-r--r--composer/e-composer-header.c6
-rw-r--r--composer/e-composer-header.h6
-rw-r--r--composer/e-composer-name-header.c35
-rw-r--r--composer/e-composer-post-header.c91
-rw-r--r--composer/e-composer-post-header.h5
-rw-r--r--composer/e-composer-private.c14
-rw-r--r--composer/e-composer-private.h4
-rw-r--r--composer/e-msg-composer.c575
-rw-r--r--composer/e-msg-composer.h16
12 files changed, 358 insertions, 435 deletions
diff --git a/composer/Makefile.am b/composer/Makefile.am
index 97debe59d0..12ad680bcf 100644
--- a/composer/Makefile.am
+++ b/composer/Makefile.am
@@ -38,8 +38,6 @@ INCLUDES = \
$(EVOLUTION_MAIL_CFLAGS)
libcomposer_la_SOURCES = \
- $(IDL_GENERATED) \
- $(HTML_EDITOR_GENERATED) \
$(libcomposerinclude_HEADERS) \
e-composer-actions.c \
e-composer-autosave.c \
@@ -52,6 +50,9 @@ libcomposer_la_SOURCES = \
e-composer-text-header.c \
e-msg-composer.c
+libcomposer_la_LIBADD = \
+ $(top_builddir)/widgets/misc/libemiscwidgets.la \
+ $(top_builddir)/em-format/libemformat.la
uidir = $(evolutionuidir)
ui_DATA = evolution-composer.ui
@@ -61,7 +62,7 @@ EXTRA_DIST = \
mail-composer.error.xml \
ChangeLog.pre-1-4
-BUILT_SOURCES = $(IDL_GENERATED) $(HTML_EDITOR_GENERATED) $(error_DATA)
+BUILT_SOURCES = $(error_DATA)
CLEANFILES = $(BUILT_SOURCES)
dist-hook:
diff --git a/composer/e-composer-actions.c b/composer/e-composer-actions.c
index 3b40d270f0..1ef7e610ad 100644
--- a/composer/e-composer-actions.c
+++ b/composer/e-composer-actions.c
@@ -21,9 +21,6 @@
#include <errno.h>
#include <fcntl.h>
#include <e-util/e-error.h>
-#include <mail/em-event.h>
-#include <mail/em-format-html-print.h>
-#include <mail/em-composer-utils.h>
#include "misc/e-charset-picker.h"
@@ -50,7 +47,7 @@ action_charset_cb (GtkRadioAction *action,
if (action != current)
return;
- charset = gtk_action_get_name (GTK_ACTION (current));
+ charset = g_object_get_data (G_OBJECT (action), "charset");
g_free (composer->priv->charset);
composer->priv->charset = g_strdup (charset);
@@ -128,15 +125,9 @@ action_print_cb (GtkAction *action,
EMsgComposer *composer)
{
GtkPrintOperationAction print_action;
- CamelMimeMessage *message;
- EMFormatHTMLPrint *efhp;
print_action = GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG;
- message = e_msg_composer_get_message (composer, 1);
-
- efhp = em_format_html_print_new (NULL, print_action);
- em_format_html_print_raw_message (efhp, message);
- g_object_unref (efhp);
+ e_msg_composer_print (composer, print_action);
}
static void
@@ -144,15 +135,9 @@ action_print_preview_cb (GtkAction *action,
EMsgComposer *composer)
{
GtkPrintOperationAction print_action;
- CamelMimeMessage *message;
- EMFormatHTMLPrint *efhp;
print_action = GTK_PRINT_OPERATION_ACTION_PREVIEW;
- message = e_msg_composer_get_message_print (composer, 1);
-
- efhp = em_format_html_print_new (NULL, print_action);
- em_format_html_print_raw_message (efhp, message);
- g_object_unref (efhp);
+ e_msg_composer_print (composer, print_action);
}
static void
@@ -263,6 +248,8 @@ static void
action_send_options_cb (GtkAction *action,
EMsgComposer *composer)
{
+ /* FIXME: KILL-BONOBO - should this be here when -no-undefined removed? */
+ /*
EMEvent *event = em_event_peek ();
EMEventTargetComposer *target;
@@ -274,6 +261,7 @@ action_send_options_cb (GtkAction *action,
(EEvent *) event,
"composer.selectsendoption",
(EEventTarget *) target);
+ */
if (!composer->priv->send_invoked)
e_error_run (
@@ -283,9 +271,12 @@ action_send_options_cb (GtkAction *action,
static void
action_new_message_cb (GtkAction *action,
- EMsgComposer *composer)
+ EMsgComposer *composer)
{
- em_utils_compose_new_message (NULL);
+ EMsgComposer *new_composer;
+
+ new_composer = e_msg_composer_new ();
+ gtk_widget_show (GTK_WIDGET (new_composer));
}
static void
@@ -508,7 +499,7 @@ e_composer_actions_init (EMsgComposer *composer)
gtk_action_group_set_translation_domain (
action_group, GETTEXT_PACKAGE);
e_charset_add_radio_actions (
- action_group, composer->priv->charset,
+ action_group, "charset-", composer->priv->charset,
G_CALLBACK (action_charset_cb), composer);
gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
diff --git a/composer/e-composer-header-table.c b/composer/e-composer-header-table.c
index f25c3b722c..d883d8ecb2 100644
--- a/composer/e-composer-header-table.c
+++ b/composer/e-composer-header-table.c
@@ -514,7 +514,6 @@ composer_header_table_constructor (GType type,
if (composer_lite)
gtk_widget_show_all ((GtkWidget *)priv->actions_container);
-
ii = E_COMPOSER_HEADER_FROM;
/* Leave room in the "From" row for signature stuff. */
diff --git a/composer/e-composer-header.c b/composer/e-composer-header.c
index 7b7cb9bcf2..63894f43c1 100644
--- a/composer/e-composer-header.c
+++ b/composer/e-composer-header.c
@@ -326,7 +326,8 @@ composer_header_class_init (EComposerHeaderClass *class)
"changed",
G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST,
- 0, NULL, NULL,
+ G_STRUCT_OFFSET (EComposerHeaderClass, changed),
+ NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
@@ -334,7 +335,8 @@ composer_header_class_init (EComposerHeaderClass *class)
"clicked",
G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST,
- 0, NULL, NULL,
+ G_STRUCT_OFFSET (EComposerHeaderClass, clicked),
+ NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
}
diff --git a/composer/e-composer-header.h b/composer/e-composer-header.h
index eb339d647c..c136e996a9 100644
--- a/composer/e-composer-header.h
+++ b/composer/e-composer-header.h
@@ -28,7 +28,7 @@
((obj), E_TYPE_COMPOSER_HEADER, EComposerHeader))
#define E_COMPOSER_HEADER_CLASS(cls) \
(G_TYPE_CHECK_CLASS_CAST \
- ((obj), E_TYPE_COMPOSER_HEADER, EComposerHeaderClass))
+ ((cls), E_TYPE_COMPOSER_HEADER, EComposerHeaderClass))
#define E_IS_COMPOSER_HEADER(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE \
((obj), E_TYPE_COMPOSER_HEADER))
@@ -55,6 +55,10 @@ struct _EComposerHeader {
struct _EComposerHeaderClass {
GObjectClass parent_class;
+
+ /* Signals */
+ void (*changed) (EComposerHeader *header);
+ void (*clicked) (EComposerHeader *header);
};
GType e_composer_header_get_type (void);
diff --git a/composer/e-composer-name-header.c b/composer/e-composer-name-header.c
index bfc9441fb7..7184bbec89 100644
--- a/composer/e-composer-name-header.c
+++ b/composer/e-composer-name-header.c
@@ -47,18 +47,6 @@ struct _EComposerNameHeaderPrivate {
static gpointer parent_class;
static void
-composer_name_header_clicked_cb (EComposerNameHeader *header)
-{
- ENameSelectorDialog *dialog;
-
- dialog = e_name_selector_peek_dialog (header->priv->name_selector);
- e_name_selector_dialog_set_destination_index (
- dialog, header->priv->destination_index);
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_hide (GTK_WIDGET (dialog));
-}
-
-static void
composer_name_header_entry_changed_cb (ENameSelectorEntry *entry,
EComposerNameHeader *header)
{
@@ -132,10 +120,6 @@ composer_name_header_constructor (GType type,
NULL);
E_COMPOSER_HEADER (object)->input_widget = g_object_ref_sink (entry);
- g_signal_connect (
- object, "clicked",
- G_CALLBACK (composer_name_header_clicked_cb), NULL);
-
return object;
}
@@ -194,9 +178,25 @@ composer_name_header_dispose (GObject *object)
}
static void
+composer_name_header_clicked (EComposerHeader *header)
+{
+ EComposerNameHeaderPrivate *priv;
+ ENameSelectorDialog *dialog;
+
+ priv = E_COMPOSER_NAME_HEADER_GET_PRIVATE (header);
+
+ dialog = e_name_selector_peek_dialog (priv->name_selector);
+ e_name_selector_dialog_set_destination_index (
+ dialog, priv->destination_index);
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_hide (GTK_WIDGET (dialog));
+}
+
+static void
composer_name_header_class_init (EComposerNameHeaderClass *class)
{
GObjectClass *object_class;
+ EComposerHeaderClass *header_class;
parent_class = g_type_class_peek_parent (class);
g_type_class_add_private (class, sizeof (EComposerNameHeaderPrivate));
@@ -207,6 +207,9 @@ composer_name_header_class_init (EComposerNameHeaderClass *class)
object_class->get_property = composer_name_header_get_property;
object_class->dispose = composer_name_header_dispose;
+ header_class = E_COMPOSER_HEADER_CLASS (class);
+ header_class->clicked = composer_name_header_clicked;
+
g_object_class_install_property (
object_class,
PROP_NAME_SELECTOR,
diff --git a/composer/e-composer-post-header.c b/composer/e-composer-post-header.c
index 59d81b80ac..cb297fe375 100644
--- a/composer/e-composer-post-header.c
+++ b/composer/e-composer-post-header.c
@@ -22,9 +22,7 @@
#include <string.h>
#include <glib/gi18n.h>
-
-#include "mail/em-folder-selector.h"
-#include "mail/em-folder-tree.h"
+#include <camel/camel-url.h>
#define E_COMPOSER_POST_HEADER_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE \
@@ -43,10 +41,6 @@ struct _EComposerPostHeaderPrivate {
static gpointer parent_class;
-/* Forward Declarations (to avoid pulling in Bonobo stuff) */
-struct _MailComponent *mail_component_peek (void);
-struct _EMFolderTreeModel *mail_component_peek_tree_model (struct _MailComponent *component);
-
static gchar *
composer_post_header_folder_name_to_string (EComposerPostHeader *header,
const gchar *url)
@@ -106,56 +100,6 @@ composer_post_header_split_csv (const gchar *csv)
return g_list_reverse (list);
}
-static void
-composer_post_header_changed_cb (EComposerPostHeader *header)
-{
- header->priv->custom = TRUE;
-}
-
-static void
-composer_post_header_clicked_cb (EComposerPostHeader *header)
-{
- EMFolderTreeModel *model;
- GtkWidget *folder_tree;
- GtkWidget *dialog;
- GList *list;
-
- model = mail_component_peek_tree_model (mail_component_peek ());
- folder_tree = em_folder_tree_new_with_model (model);
-
- em_folder_tree_set_multiselect (
- EM_FOLDER_TREE (folder_tree), TRUE);
- em_folder_tree_set_excluded (
- EM_FOLDER_TREE (folder_tree),
- EMFT_EXCLUDE_NOSELECT |
- EMFT_EXCLUDE_VIRTUAL |
- EMFT_EXCLUDE_VTRASH);
-
- dialog = em_folder_selector_new (
- EM_FOLDER_TREE (folder_tree),
- EM_FOLDER_SELECTOR_CAN_CREATE,
- _("Posting destination"),
- _("Choose folders to post the message to."),
- NULL);
-
- list = e_composer_post_header_get_folders (header);
- em_folder_selector_set_selected_list (
- EM_FOLDER_SELECTOR (dialog), list);
- g_list_foreach (list, (GFunc) g_free, NULL);
- g_list_free (list);
-
- if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) {
- list = em_folder_selector_get_selected_uris (
- EM_FOLDER_SELECTOR (dialog));
- e_composer_post_header_set_folders (header, list);
- header->priv->custom = FALSE;
- g_list_foreach (list, (GFunc) g_free, NULL);
- g_list_free (list);
- }
-
- gtk_widget_destroy (dialog);
-}
-
static GObject *
composer_post_header_constructor (GType type,
guint n_construct_properties,
@@ -171,14 +115,6 @@ composer_post_header_constructor (GType type,
E_COMPOSER_HEADER (object),
_("Click here to select folders to post to"));
- g_signal_connect (
- object, "changed",
- G_CALLBACK (composer_post_header_changed_cb), NULL);
-
- g_signal_connect (
- object, "clicked",
- G_CALLBACK (composer_post_header_clicked_cb), NULL);
-
return object;
}
@@ -246,9 +182,30 @@ composer_post_header_finalize (GObject *object)
}
static void
+composer_post_header_changed (EComposerHeader *header)
+{
+ EComposerPostHeaderPrivate *priv;
+
+ priv = E_COMPOSER_POST_HEADER_GET_PRIVATE (header);
+
+ priv->custom = TRUE;
+}
+
+static void
+composer_post_header_clicked (EComposerHeader *header)
+{
+ EComposerPostHeaderPrivate *priv;
+
+ priv = E_COMPOSER_POST_HEADER_GET_PRIVATE (header);
+
+ priv->custom = FALSE;
+}
+
+static void
composer_post_header_class_init (EComposerPostHeaderClass *class)
{
GObjectClass *object_class;
+ EComposerHeaderClass *header_class;
parent_class = g_type_class_peek_parent (class);
g_type_class_add_private (class, sizeof (EComposerPostHeaderPrivate));
@@ -260,6 +217,10 @@ composer_post_header_class_init (EComposerPostHeaderClass *class)
object_class->dispose = composer_post_header_dispose;
object_class->finalize = composer_post_header_finalize;
+ header_class = E_COMPOSER_HEADER_CLASS (class);
+ header_class->changed = composer_post_header_changed;
+ header_class->clicked = composer_post_header_clicked;
+
g_object_class_install_property (
object_class,
PROP_ACCOUNT,
diff --git a/composer/e-composer-post-header.h b/composer/e-composer-post-header.h
index 40dc5a8d58..c38bfe2d17 100644
--- a/composer/e-composer-post-header.h
+++ b/composer/e-composer-post-header.h
@@ -46,6 +46,8 @@
G_BEGIN_DECLS
+/* Avoid including files from the Mail module. */
+
typedef struct _EComposerPostHeader EComposerPostHeader;
typedef struct _EComposerPostHeaderClass EComposerPostHeaderClass;
typedef struct _EComposerPostHeaderPrivate EComposerPostHeaderPrivate;
@@ -60,7 +62,8 @@ struct _EComposerPostHeaderClass {
};
GType e_composer_post_header_get_type (void);
-EComposerHeader * e_composer_post_header_new (const gchar *label);
+EComposerHeader *
+ e_composer_post_header_new (const gchar *label);
EAccount * e_composer_post_header_get_account
(EComposerPostHeader *header);
void e_composer_post_header_set_account
diff --git a/composer/e-composer-private.c b/composer/e-composer-private.c
index 2a2cea6a4c..d4ec9ddc69 100644
--- a/composer/e-composer-private.c
+++ b/composer/e-composer-private.c
@@ -27,10 +27,12 @@ composer_setup_charset_menu (EMsgComposer *composer)
guint merge_id;
ui_manager = gtkhtml_editor_get_ui_manager (GTKHTML_EDITOR (composer));
- list = gtk_action_group_list_actions (composer->priv->charset_actions);
path = "/main-menu/edit-menu/pre-spell-check/charset-menu";
merge_id = gtk_ui_manager_new_merge_id (ui_manager);
+ list = gtk_action_group_list_actions (composer->priv->charset_actions);
+ list = g_list_sort (list, (GCompareFunc) e_action_compare_by_label);
+
while (list != NULL) {
GtkAction *action = list->data;
@@ -85,8 +87,8 @@ e_composer_private_init (EMsgComposer *composer)
GtkhtmlEditor *editor;
GtkUIManager *ui_manager;
- GtkWidget *widget;
GtkWidget *container;
+ GtkWidget *widget;
GtkWidget *send_widget;
GtkWidget *exp_box;
const gchar *path;
@@ -101,7 +103,7 @@ e_composer_private_init (EMsgComposer *composer)
widget = gtkhtml_editor_get_managed_widget (editor, "/main-menu");
gtk_widget_hide (widget);
widget = gtkhtml_editor_get_managed_widget (editor, "/main-toolbar");
- gtk_toolbar_set_style ((GtkToolbar *)widget, GTK_TOOLBAR_BOTH_HORIZ);
+ gtk_toolbar_set_style (GTK_TOOLBAR (widget), GTK_TOOLBAR_BOTH_HORIZ);
gtk_widget_hide (widget);
}
@@ -159,7 +161,6 @@ e_composer_private_init (EMsgComposer *composer)
gtk_container_remove((GtkContainer *)send_widget, gtk_bin_get_child ((GtkBin *)send_widget));
gtk_container_add((GtkContainer *)send_widget, tmp);
gtk_button_set_relief ((GtkButton *)send_widget, GTK_RELIEF_NORMAL);
-
path = "/main-toolbar/pre-main-toolbar/save-draft";
send_widget = gtk_ui_manager_get_widget (ui_manager, path);
tmp = gtk_hbox_new (FALSE, 0);
@@ -306,6 +307,11 @@ e_composer_private_dispose (EMsgComposer *composer)
composer->priv->header_table = NULL;
}
+ if (composer->priv->attachment_paned != NULL) {
+ g_object_unref (composer->priv->attachment_paned);
+ composer->priv->attachment_paned = NULL;
+ }
+
if (composer->priv->charset_actions != NULL) {
g_object_unref (composer->priv->charset_actions);
composer->priv->charset_actions = NULL;
diff --git a/composer/e-composer-private.h b/composer/e-composer-private.h
index 49d9ae6d74..82019b44ad 100644
--- a/composer/e-composer-private.h
+++ b/composer/e-composer-private.h
@@ -29,6 +29,7 @@
#include "e-composer-autosave.h"
#include "e-composer-header-table.h"
#include "e-util/e-binding.h"
+#include "e-util/e-util.h"
#include "e-util/gconf-bridge.h"
#include "widgets/misc/e-attachment-paned.h"
#include "widgets/misc/e-attachment-store.h"
@@ -104,7 +105,6 @@ struct _EMsgComposerPrivate {
gchar *mime_type, *mime_body, *charset;
- guint32 attachment_bar_visible : 1;
guint32 is_alternative : 1;
guint32 autosaved : 1;
guint32 mode_post : 1;
@@ -113,8 +113,6 @@ struct _EMsgComposerPrivate {
CamelMimeMessage *redirect;
- guint notify_id;
-
gboolean send_invoked;
};
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index 946bff28c1..98f2c31f86 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -23,17 +23,6 @@
*
*/
-/*
-
- TODO
-
- - Somehow users should be able to see if any file (s) are attached even when
- the attachment bar is not shown.
-
- Should use EventSources to keep track of global changes made to configuration
- values. Right now it ignores the problem olympically. Miguel.
-*/
-
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
@@ -61,48 +50,39 @@
#include "e-util/e-dialog-utils.h"
#include "misc/e-charset-picker.h"
#include "e-util/e-error.h"
+#include "e-util/e-mktemp.h"
#include "e-util/e-plugin-ui.h"
#include "e-util/e-util-private.h"
-#include "e-util/e-util.h"
-#include "e-util/e-mktemp.h"
-#include <mail/em-event.h>
+#include "e-util/e-account-utils.h"
+#include "e-util/e-signature-utils.h"
#include "e-signature-combo-box.h"
+#include "shell/e-shell.h"
+#include "em-format/em-format.h"
+#include "em-format/em-format-quote.h"
-#include <camel/camel-session.h>
#include <camel/camel-charset-map.h>
+#include <camel/camel-cipher-context.h>
+#include <camel/camel-folder.h>
+#include <camel/camel-gpg-context.h>
#include <camel/camel-iconv.h>
-#include <camel/camel-stream-filter.h>
#include <camel/camel-mime-filter-charset.h>
-#include <camel/camel-stream-mem.h>
-#include <camel/camel-stream-fs.h>
#include <camel/camel-mime-filter-tohtml.h>
-#include <camel/camel-multipart-signed.h>
#include <camel/camel-multipart-encrypted.h>
+#include <camel/camel-multipart-signed.h>
+#include <camel/camel-stream-filter.h>
+#include <camel/camel-stream-fs.h>
+#include <camel/camel-stream-mem.h>
#include <camel/camel-string-utils.h>
-#include <camel/camel-cipher-context.h>
#if defined (HAVE_NSS)
#include <camel/camel-smime-context.h>
#endif
-#include "mail/em-utils.h"
-#include "mail/em-composer-utils.h"
-#include "mail/mail-config.h"
-#include "mail/mail-crypto.h"
-#include "mail/mail-tools.h"
-#include "mail/mail-ops.h"
-#include "mail/mail-mt.h"
-#include "mail/mail-session.h"
-#include "mail/em-popup.h"
-#include "mail/em-menu.h"
-
#include "e-msg-composer.h"
#include "e-attachment.h"
#include "e-composer-autosave.h"
#include "e-composer-private.h"
#include "e-composer-header-table.h"
-#include "evolution-shell-component-utils.h"
-
#ifdef HAVE_XFREE
#include <X11/XF86keysym.h>
#endif
@@ -116,6 +96,7 @@
enum {
SEND,
SAVE_DRAFT,
+ PRINT,
LAST_SIGNAL
};
@@ -142,6 +123,104 @@ static void handle_multipart_alternative (EMsgComposer *composer, CamelMultipart
static void handle_multipart_encrypted (EMsgComposer *composer, CamelMimePart *multipart, gint depth);
static void handle_multipart_signed (EMsgComposer *composer, CamelMultipart *multipart, gint depth);
+/**
+ * emcu_part_to_html:
+ * @part:
+ *
+ * Converts a mime part's contents into html text. If @credits is given,
+ * then it will be used as an attribution string, and the
+ * content will be cited. Otherwise no citation or attribution
+ * will be performed.
+ *
+ * Return Value: The part in displayable html format.
+ **/
+static char *
+emcu_part_to_html (CamelMimePart *part, ssize_t *len, EMFormat *source)
+{
+ EMFormatQuote *emfq;
+ CamelStreamMem *mem;
+ GByteArray *buf;
+ char *text;
+
+ buf = g_byte_array_new ();
+ mem = (CamelStreamMem *) camel_stream_mem_new ();
+ camel_stream_mem_set_byte_array (mem, buf);
+
+ emfq = em_format_quote_new(NULL, (CamelStream *)mem, 0);
+ ((EMFormat *) emfq)->composer = TRUE;
+ if (source) {
+ /* copy over things we can, other things are internal, perhaps need different api than 'clone' */
+ if (source->default_charset)
+ em_format_set_default_charset((EMFormat *)emfq, source->default_charset);
+ if (source->charset)
+ em_format_set_default_charset((EMFormat *)emfq, source->charset);
+ }
+ em_format_part((EMFormat *) emfq, (CamelStream *)mem, part);
+ g_object_unref(emfq);
+
+ camel_stream_write((CamelStream *) mem, "", 1);
+ camel_object_unref(mem);
+
+ text = (char *)buf->data;
+ if (len)
+ *len = buf->len-1;
+ g_byte_array_free (buf, FALSE);
+
+ return text;
+}
+
+/* copy of em_utils_prompt_user from mailer */
+static gboolean
+emcu_prompt_user (GtkWindow *parent, const char *promptkey, const char *tag, const char *arg0, ...)
+{
+ GtkWidget *mbox, *check = NULL;
+ va_list ap;
+ int button;
+ GConfClient *gconf = gconf_client_get_default ();
+
+ if (promptkey
+ && !gconf_client_get_bool(gconf, promptkey, NULL)) {
+ g_object_unref (gconf);
+ return TRUE;
+ }
+
+ va_start(ap, arg0);
+ mbox = e_error_newv(parent, tag, arg0, ap);
+ va_end(ap);
+
+ if (promptkey) {
+ check = gtk_check_button_new_with_mnemonic (_("_Do not show this message again."));
+ gtk_container_set_border_width((GtkContainer *)check, 12);
+ gtk_box_pack_start ((GtkBox *)((GtkDialog *) mbox)->vbox, check, TRUE, TRUE, 0);
+ gtk_widget_show (check);
+ }
+
+ button = gtk_dialog_run ((GtkDialog *) mbox);
+ if (promptkey)
+ gconf_client_set_bool(gconf, promptkey, !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check)), NULL);
+
+ gtk_widget_destroy(mbox);
+ g_object_unref (gconf);
+
+ return button == GTK_RESPONSE_YES;
+}
+
+/* copy of mail_tool_remove_xevolution_headers */
+static struct _camel_header_raw *
+emcu_remove_xevolution_headers (CamelMimeMessage *message)
+{
+ struct _camel_header_raw *scan, *list = NULL;
+
+ for (scan = ((CamelMimePart *)message)->headers;scan;scan=scan->next)
+ if (!strncmp(scan->name, "X-Evolution", 11))
+ camel_header_raw_append(&list, scan->name, scan->value, scan->offset);
+
+ for (scan=list;scan;scan=scan->next)
+ camel_medium_remove_header((CamelMedium *)message, scan->name);
+
+ return list;
+}
+
static EDestination**
destination_list_to_vector_sized (GList *list, gint n)
{
@@ -476,6 +555,7 @@ build_message (EMsgComposer *composer,
CamelMultipart *body = NULL;
CamelContentType *type;
CamelMimeMessage *new;
+ CamelSession *session;
CamelStream *stream;
CamelMimePart *part;
CamelException ex;
@@ -495,6 +575,7 @@ build_message (EMsgComposer *composer,
account = e_composer_header_table_get_account (table);
view = e_msg_composer_get_attachment_view (composer);
store = e_attachment_view_get_store (view);
+ session = e_msg_composer_get_session (composer);
/* evil kludgy hack for Redirect */
if (p->redirect) {
@@ -746,8 +827,14 @@ build_message (EMsgComposer *composer,
if (pgp_sign) {
CamelMimePart *npart = camel_mime_part_new ();
- cipher = mail_crypto_get_pgp_cipher_context (account);
- camel_cipher_sign (cipher, pgp_userid, CAMEL_CIPHER_HASH_SHA1, part, npart, &ex);
+ cipher = camel_gpg_context_new (session);
+ if (account != NULL)
+ camel_gpg_context_set_always_trust (
+ CAMEL_GPG_CONTEXT (cipher),
+ account->pgp_always_trust);
+ camel_cipher_sign (
+ cipher, pgp_userid, CAMEL_CIPHER_HASH_SHA1,
+ part, npart, &ex);
camel_object_unref (cipher);
if (camel_exception_is_set (&ex)) {
@@ -766,8 +853,14 @@ build_message (EMsgComposer *composer,
if (account && account->pgp_encrypt_to_self && pgp_userid)
g_ptr_array_add (recipients, g_strdup (pgp_userid));
- cipher = mail_crypto_get_pgp_cipher_context (account);
- camel_cipher_encrypt (cipher, pgp_userid, recipients, part, npart, &ex);
+ cipher = camel_gpg_context_new (session);
+ if (account != NULL)
+ camel_gpg_context_set_always_trust (
+ CAMEL_GPG_CONTEXT (cipher),
+ account->pgp_always_trust);
+ camel_cipher_encrypt (
+ cipher, pgp_userid, recipients,
+ part, npart, &ex);
camel_object_unref (cipher);
if (account && account->pgp_encrypt_to_self && pgp_userid)
@@ -841,6 +934,7 @@ build_message (EMsgComposer *composer,
}
if (smime_encrypt) {
+
/* check to see if we should encrypt to self, NB removed after use */
if (account->smime_encrypt_to_self)
g_ptr_array_add (recipients, g_strdup (account->smime_encrypt_key));
@@ -920,103 +1014,6 @@ skip_content:
/* Signatures */
static gchar *
-get_file_content (EMsgComposer *composer,
- const gchar *filename,
- gboolean want_html,
- guint flags,
- gboolean warn)
-{
- CamelStreamFilter *filtered_stream;
- CamelStreamMem *memstream;
- CamelMimeFilter *html, *charenc;
- CamelStream *stream;
- GByteArray *buffer;
- gchar *charset;
- gchar *content;
- gint fd;
-
- fd = g_open (filename, O_RDONLY, 0);
- if (fd == -1) {
- if (warn)
- e_error_run ((GtkWindow *)composer, "mail-composer:no-sig-file",
- filename, g_strerror (errno), NULL);
- return g_strdup ("");
- }
-
- stream = camel_stream_fs_new_with_fd (fd);
-
- if (want_html) {
- filtered_stream = camel_stream_filter_new_with_stream (stream);
- camel_object_unref (stream);
-
- html = camel_mime_filter_tohtml_new (flags, 0);
- camel_stream_filter_add (filtered_stream, html);
- camel_object_unref (html);
-
- stream = (CamelStream *) filtered_stream;
- }
-
- memstream = (CamelStreamMem *) camel_stream_mem_new ();
- buffer = g_byte_array_new ();
- camel_stream_mem_set_byte_array (memstream, buffer);
-
- camel_stream_write_to_stream (stream, (CamelStream *) memstream);
- camel_object_unref (stream);
-
- /* The newer signature UI saves signatures in UTF-8, but we still need to check that
- the signature is valid UTF-8 because it is possible that the user imported a
- signature file that is in his/her locale charset. If it's not in UTF-8 and not in
- the charset the composer is in (or their default mail charset) then
- there's nothing we can do. */
- if (buffer->len && !g_utf8_validate ((const gchar *)buffer->data, buffer->len, NULL)) {
- stream = (CamelStream *) memstream;
- memstream = (CamelStreamMem *) camel_stream_mem_new ();
- camel_stream_mem_set_byte_array (memstream, g_byte_array_new ());
-
- filtered_stream = camel_stream_filter_new_with_stream (stream);
- camel_object_unref (stream);
-
- charset = composer && composer->priv->charset ? composer->priv->charset : NULL;
- charset = charset ? g_strdup (charset) : e_composer_get_default_charset ();
- if ((charenc = (CamelMimeFilter *) camel_mime_filter_charset_new_convert (charset, "UTF-8"))) {
- camel_stream_filter_add (filtered_stream, charenc);
- camel_object_unref (charenc);
- }
-
- g_free (charset);
-
- camel_stream_write_to_stream ((CamelStream *) filtered_stream, (CamelStream *) memstream);
- camel_object_unref (filtered_stream);
- g_byte_array_free (buffer, TRUE);
-
- buffer = memstream->buffer;
- }
-
- camel_object_unref (memstream);
-
- g_byte_array_append (buffer, (const guint8 *)"", 1);
- content = (char*)buffer->data;
- g_byte_array_free (buffer, FALSE);
-
- return content;
-}
-
-gchar *
-e_msg_composer_get_sig_file_content (const gchar *sigfile, gboolean in_html)
-{
- if (!sigfile || !*sigfile) {
- return NULL;
- }
-
- return get_file_content (NULL, sigfile, !in_html,
- CAMEL_MIME_FILTER_TOHTML_PRESERVE_8BIT |
- CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS |
- CAMEL_MIME_FILTER_TOHTML_CONVERT_ADDRESSES |
- CAMEL_MIME_FILTER_TOHTML_CONVERT_SPACES,
- FALSE);
-}
-
-static gchar *
encode_signature_name (const gchar *name)
{
const gchar *s;
@@ -1106,34 +1103,6 @@ decode_signature_name (const gchar *name)
return dname;
}
-static gboolean
-add_signature_delim (void)
-{
- gboolean res;
- GConfClient *client = gconf_client_get_default ();
-
- res = !gconf_client_get_bool (client, COMPOSER_GCONF_NO_SIGNATURE_DELIM_KEY, NULL);
-
- g_object_unref (client);
-
- return res;
-}
-
-static gboolean
-is_top_signature (void)
-{
- GConfClient *gconf;
- gboolean res = FALSE;
-
- gconf = gconf_client_get_default ();
-
- res = gconf_client_get_bool (gconf, COMPOSER_GCONF_TOP_SIGNATURE_KEY, NULL);
-
- g_object_unref (gconf);
-
- return res;
-}
-
#define CONVERT_SPACES CAMEL_MIME_FILTER_TOHTML_CONVERT_SPACES
#define NO_SIGNATURE_TEXT \
"<!--+GtkHTML:<DATA class=\"ClueFlow\" key=\"signature\" value=\"1\">-->" \
@@ -1145,7 +1114,7 @@ get_signature_html (EMsgComposer *composer)
EComposerHeaderTable *table;
gchar *text = NULL, *html = NULL;
ESignature *signature;
- gboolean format_html, add_delim;
+ gboolean format_html;
table = e_msg_composer_get_header_table (composer);
signature = e_composer_header_table_get_signature (table);
@@ -1153,19 +1122,18 @@ get_signature_html (EMsgComposer *composer)
if (!signature)
return NULL;
- add_delim = add_signature_delim ();
-
if (!signature->autogen) {
if (!signature->filename)
return NULL;
format_html = signature->html;
- if (signature->script) {
- text = mail_config_signature_run_script (signature->filename);
- } else {
- text = e_msg_composer_get_sig_file_content (signature->filename, format_html);
- }
+ if (signature->script)
+ text = e_run_signature_script (
+ signature->filename);
+ else
+ text = e_read_signature_file (
+ signature, TRUE, NULL);
} else {
EAccount *account;
EAccountIdentity *id;
@@ -1182,8 +1150,7 @@ get_signature_html (EMsgComposer *composer)
name = id->name ? camel_text_to_html (id->name, CONVERT_SPACES, 0) : NULL;
organization = id->organization ? camel_text_to_html (id->organization, CONVERT_SPACES, 0) : NULL;
- text = g_strdup_printf ("%s%s%s%s%s%s%s%s%s",
- add_delim ? "-- <BR>" : "",
+ text = g_strdup_printf ("-- <BR>%s%s%s%s%s%s%s%s",
name ? name : "",
(address && *address) ? " &lt;<A HREF=\"mailto:" : "",
address ? address : "",
@@ -1213,13 +1180,12 @@ get_signature_html (EMsgComposer *composer)
"<!--+GtkHTML:<DATA class=\"ClueFlow\" key=\"signature_name\" value=\"uid:%s\">-->"
"<TABLE WIDTH=\"100%%\" CELLSPACING=\"0\" CELLPADDING=\"0\"><TR><TD><BR>"
"%s%s%s%s"
- "%s</TD></TR></TABLE>",
+ "</TD></TR></TABLE>",
encoded_uid ? encoded_uid : "",
format_html ? "" : "<PRE>\n",
- format_html || !add_delim || (!strncmp ("-- \n", text, 4) || strstr (text, "\n-- \n")) ? "" : "-- \n",
+ format_html || (!strncmp ("-- \n", text, 4) || strstr (text, "\n-- \n")) ? "" : "-- \n",
text,
- format_html ? "" : "</PRE>\n",
- is_top_signature () ? "<BR>" : "");
+ format_html ? "" : "</PRE>\n");
g_free (text);
g_free (encoded_uid);
text = html;
@@ -1233,11 +1199,17 @@ set_editor_text (EMsgComposer *composer,
const gchar *text,
gboolean set_signature)
{
- gchar *body = NULL;
+ EShell *shell;
+ EShellSettings *shell_settings;
+ gboolean reply_signature_on_top;
+ gchar *body = NULL, *html = NULL;
g_return_if_fail (E_IS_MSG_COMPOSER (composer));
g_return_if_fail (text != NULL);
+ shell = e_shell_get_default ();
+ shell_settings = e_shell_get_shell_settings (shell);
+
/*
Keeping Signatures in the beginning of composer
@@ -1252,9 +1224,30 @@ set_editor_text (EMsgComposer *composer,
*/
- if (is_top_signature ()) {
- /* put marker to the top */
- body = g_strdup_printf ("<BR>" NO_SIGNATURE_TEXT "%s", text);
+ reply_signature_on_top = e_shell_settings_get_boolean (
+ shell_settings, "composer-top-signature");
+
+ if (set_signature && reply_signature_on_top) {
+ gchar *tmp = NULL;
+ tmp = get_signature_html (composer);
+ if (tmp) {
+ /* Minimizing the damage. Make it just a part of the body instead of a signature */
+ html = strstr (tmp, "-- \n");
+ if (html) {
+ /* That two consecutive - symbols followed by a space */
+ *(html+1) = ' ';
+ body = g_strdup_printf ("</br>%s</br>%s", tmp, text);
+ } else {
+ /* HTML Signature. Make it as part of body */
+ body = g_strdup_printf ("</br>%s</br>%s", tmp, text);
+ }
+ g_free (tmp);
+ } else {
+ /* No signature set */
+ body = g_strdup_printf ("<!--+GtkHTML:<DATA class=\"ClueFlow\" key=\"signature\" value=\"1\">-->"
+ "<!--+GtkHTML:<DATA class=\"ClueFlow\" key=\"signature_name\" value=\"uid:Noname\">-->"
+ "<TABLE WIDTH=\"100%%\" CELLSPACING=\"0\" CELLPADDING=\"0\"><TR><TD> </TD></TR></TABLE>%s", text);
+ }
} else {
/* no marker => to the bottom */
body = g_strdup_printf ("%s<BR>", text);
@@ -1291,14 +1284,6 @@ autosave_load_draft (const gchar *filename)
if (e_composer_autosave_snapshot (composer))
g_unlink (filename);
- g_signal_connect (
- composer, "send",
- G_CALLBACK (em_utils_composer_send_cb), NULL);
-
- g_signal_connect (
- composer, "save-draft",
- G_CALLBACK (em_utils_composer_save_draft_cb), NULL);
-
gtk_widget_show (GTK_WIDGET (composer));
}
@@ -1366,7 +1351,7 @@ msg_composer_account_changed_cb (EMsgComposer *composer)
gtk_toggle_action_set_active (action, active);
uid = account->id->sig_uid;
- signature = uid ? mail_config_get_signature_by_uid (uid) : NULL;
+ signature = uid ? e_get_signature_by_uid (uid) : NULL;
e_composer_header_table_set_signature (table, signature);
/* XXX This should be done more generically. The composer
@@ -1420,53 +1405,6 @@ msg_composer_account_list_changed_cb (EMsgComposer *composer)
g_object_unref (iterator);
}
-static void
-msg_composer_update_preferences (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- EMsgComposer *composer)
-{
- GtkhtmlEditor *editor;
- gboolean enable;
- GError *error = NULL;
-
- editor = GTKHTML_EDITOR (composer);
-
- if (entry) {
- if (strcmp(gconf_entry_get_key(entry), COMPOSER_GCONF_INLINE_SPELLING_KEY) != 0 &&
- strcmp(gconf_entry_get_key(entry), COMPOSER_GCONF_MAGIC_LINKS_KEY) != 0 &&
- strcmp(gconf_entry_get_key(entry), COMPOSER_GCONF_MAGIC_SMILEYS_KEY) != 0)
- return;
- }
-
- enable = gconf_client_get_bool (
- client, COMPOSER_GCONF_INLINE_SPELLING_KEY, &error);
- if (error == NULL)
- gtkhtml_editor_set_inline_spelling (editor, enable);
- else {
- g_warning ("%s", error->message);
- g_clear_error (&error);
- }
-
- enable = gconf_client_get_bool (
- client, COMPOSER_GCONF_MAGIC_LINKS_KEY, &error);
- if (error == NULL)
- gtkhtml_editor_set_magic_links (editor, enable);
- else {
- g_warning ("%s", error->message);
- g_clear_error (&error);
- }
-
- enable = gconf_client_get_bool (
- client, COMPOSER_GCONF_MAGIC_SMILEYS_KEY, &error);
- if (error == NULL)
- gtkhtml_editor_set_magic_smileys (editor, enable);
- else {
- g_warning ("%s", error->message);
- g_clear_error (&error);
- }
-}
-
struct _drop_data {
EMsgComposer *composer;
@@ -1477,10 +1415,6 @@ struct _drop_data {
guint32 action;
guint info;
guint time;
-
- unsigned int move:1;
- unsigned int moved:1;
- unsigned int aborted:1;
};
static void
@@ -1497,11 +1431,11 @@ msg_composer_constructor (GType type,
guint n_construct_properties,
GObjectConstructParam *construct_properties)
{
+ EShell *shell;
+ EShellSettings *shell_settings;
GObject *object;
EMsgComposer *composer;
GtkToggleAction *action;
- GList *spell_languages;
- GConfClient *client;
GArray *array;
gboolean active;
guint binding_id;
@@ -1511,9 +1445,11 @@ msg_composer_constructor (GType type,
type, n_construct_properties, construct_properties);
composer = E_MSG_COMPOSER (object);
- client = gconf_client_get_default ();
array = composer->priv->gconf_bridge_binding_ids;
+ shell = e_shell_get_default ();
+ shell_settings = e_shell_get_shell_settings (shell);
+
/* Restore Persistent State */
binding_id = gconf_bridge_bind_property (
@@ -1530,29 +1466,16 @@ msg_composer_constructor (GType type,
/* Honor User Preferences */
- active = gconf_client_get_bool (
- client, COMPOSER_GCONF_SEND_HTML_KEY, NULL);
+ active = e_shell_settings_get_boolean (
+ shell_settings, "composer-format-html");
gtkhtml_editor_set_html_mode (GTKHTML_EDITOR (composer), active);
action = GTK_TOGGLE_ACTION (ACTION (REQUEST_READ_RECEIPT));
- active = gconf_client_get_bool (
- client, COMPOSER_GCONF_REQUEST_RECEIPT_KEY, NULL);
+ active = e_shell_settings_get_boolean (
+ shell_settings, "composer-request-receipt");
gtk_toggle_action_set_active (action, active);
- spell_languages = e_load_spell_languages ();
- gtkhtml_editor_set_spell_languages (
- GTKHTML_EDITOR (composer), spell_languages);
- g_list_free (spell_languages);
-
- gconf_client_add_dir (
- client, COMPOSER_GCONF_PREFIX,
- GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
- composer->priv->notify_id = gconf_client_notify_add (
- client, COMPOSER_GCONF_PREFIX, (GConfClientNotifyFunc)
- msg_composer_update_preferences, composer, NULL, NULL);
- msg_composer_update_preferences (client, 0, NULL, composer);
-
- g_object_unref (client);
+ e_shell_watch_window (shell, GTK_WINDOW (object));
return object;
}
@@ -1599,15 +1522,6 @@ msg_composer_destroy (GtkObject *object)
composer->priv->address_dialog = NULL;
}
- if (composer->priv->notify_id) {
- GConfClient *client;
-
- client = gconf_client_get_default ();
- gconf_client_notify_remove (client, composer->priv->notify_id);
- composer->priv->notify_id = 0;
- g_object_unref (client);
- }
-
/* Chain up to parent's destroy() method. */
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
@@ -1815,7 +1729,7 @@ msg_composer_paste_clipboard (GtkhtmlEditor *editor)
clipboard = gtk_widget_get_clipboard (widget, GDK_SELECTION_CLIPBOARD);
/* Assume the clipboard has an image. The return
- * value will be NULL we we assumed wrong. */
+ * value will be NULL if we assumed wrong. */
pixbuf = gtk_clipboard_wait_for_image (clipboard);
if (!GDK_IS_PIXBUF (pixbuf))
goto chainup;
@@ -2126,7 +2040,7 @@ msg_composer_class_init (EMsgComposerClass *class)
signals[SEND] = g_signal_new (
"send",
- E_TYPE_MSG_COMPOSER,
+ G_OBJECT_CLASS_TYPE (class),
G_SIGNAL_RUN_LAST,
0, NULL, NULL,
g_cclosure_marshal_VOID__VOID,
@@ -2134,11 +2048,20 @@ msg_composer_class_init (EMsgComposerClass *class)
signals[SAVE_DRAFT] = g_signal_new (
"save-draft",
- E_TYPE_MSG_COMPOSER,
+ G_OBJECT_CLASS_TYPE (class),
G_SIGNAL_RUN_LAST,
0, NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
+
+ signals[PRINT] = g_signal_new (
+ "print",
+ G_OBJECT_CLASS_TYPE (class),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__ENUM,
+ G_TYPE_NONE, 1,
+ GTK_TYPE_PRINT_OPERATION_ACTION);
}
static void
@@ -2153,6 +2076,7 @@ msg_composer_init (EMsgComposer *composer)
GtkUIManager *ui_manager;
GtkhtmlEditor *editor;
GtkHTML *html;
+ const gchar *id;
gint n_targets;
composer->lite = composer_lite;
@@ -2190,9 +2114,9 @@ msg_composer_init (EMsgComposer *composer)
/* Configure Headers */
e_composer_header_table_set_account_list (
- table, mail_config_get_accounts ());
+ table, e_get_account_list ());
e_composer_header_table_set_signature_list (
- table, mail_config_get_signatures ());
+ table, e_get_signature_list ());
g_signal_connect_swapped (
table, "notify::account",
@@ -2242,8 +2166,9 @@ msg_composer_init (EMsgComposer *composer)
/* Initialization may have tripped the "changed" state. */
gtkhtml_editor_set_changed (editor, FALSE);
- e_plugin_ui_register_manager (
- "org.gnome.evolution.composer", ui_manager, composer);
+ id = "org.gnome.evolution.composer";
+ e_plugin_ui_register_manager (ui_manager, id, composer);
+ e_plugin_ui_enable_manager (ui_manager, id);
}
GType
@@ -2287,7 +2212,6 @@ e_msg_composer_new (void)
return g_object_new (E_TYPE_MSG_COMPOSER, NULL);
}
-
void
e_msg_composer_set_lite (void)
{
@@ -2487,7 +2411,7 @@ handle_multipart_signed (EMsgComposer *composer,
gchar *html;
gssize length;
- html = em_utils_part_to_html (mime_part, &length, NULL);
+ html = emcu_part_to_html (mime_part, &length, NULL);
e_msg_composer_set_pending_body (composer, html, length);
} else {
e_msg_composer_attach (composer, mime_part);
@@ -2503,6 +2427,7 @@ handle_multipart_encrypted (EMsgComposer *composer,
CamelCipherContext *cipher;
CamelDataWrapper *content;
CamelMimePart *mime_part;
+ CamelSession *session;
CamelException ex;
CamelCipherValidity *valid;
GtkToggleAction *action;
@@ -2512,7 +2437,8 @@ handle_multipart_encrypted (EMsgComposer *composer,
gtk_toggle_action_set_active (action, TRUE);
camel_exception_init (&ex);
- cipher = mail_crypto_get_pgp_cipher_context (NULL);
+ session = e_msg_composer_get_session (composer);
+ cipher = camel_gpg_context_new (session);
mime_part = camel_mime_part_new ();
valid = camel_cipher_decrypt (cipher, multipart, mime_part, &ex);
camel_object_unref (cipher);
@@ -2550,7 +2476,7 @@ handle_multipart_encrypted (EMsgComposer *composer,
gchar *html;
gssize length;
- html = em_utils_part_to_html (mime_part, &length, NULL);
+ html = emcu_part_to_html (mime_part, &length, NULL);
e_msg_composer_set_pending_body (composer, html, length);
} else {
e_msg_composer_attach (composer, mime_part);
@@ -2616,7 +2542,7 @@ handle_multipart_alternative (EMsgComposer *composer,
gchar *html;
gssize length;
- html = em_utils_part_to_html (text_part, &length, NULL);
+ html = emcu_part_to_html (text_part, &length, NULL);
e_msg_composer_set_pending_body (composer, html, length);
}
}
@@ -2666,7 +2592,7 @@ handle_multipart (EMsgComposer *composer,
/* Since the first part is not multipart/alternative,
* this must be the body. */
- html = em_utils_part_to_html (mime_part, &length, NULL);
+ html = emcu_part_to_html (mime_part, &length, NULL);
e_msg_composer_set_pending_body (composer, html, length);
} else if (camel_mime_part_get_content_id (mime_part) ||
camel_mime_part_get_content_location (mime_part)) {
@@ -2697,11 +2623,11 @@ set_signature_gui (EMsgComposer *composer)
data = gtkhtml_editor_get_paragraph_data (editor, "signature_name");
if (g_str_has_prefix (data, "uid:")) {
decoded = decode_signature_name (data + 4);
- signature = mail_config_get_signature_by_uid (decoded);
+ signature = e_get_signature_by_uid (decoded);
g_free (decoded);
} else if (g_str_has_prefix (data, "name:")) {
decoded = decode_signature_name (data + 5);
- signature = mail_config_get_signature_by_name (decoded);
+ signature = e_get_signature_by_name (decoded);
g_free (decoded);
}
@@ -2758,10 +2684,12 @@ e_msg_composer_new_with_message (CamelMimeMessage *message)
account_name = g_strdup (account_name);
g_strstrip (account_name);
- if ((account = mail_config_get_account_by_uid (account_name)) == NULL)
- /* 'old' setting */
- account = mail_config_get_account_by_name (account_name);
- if (account) {
+ account = e_get_account_by_uid (account_name);
+ if (account == NULL)
+ /* XXX Backwards compatibility */
+ account = e_get_account_by_name (account_name);
+
+ if (account != NULL) {
g_free (account_name);
account_name = g_strdup (account->name);
}
@@ -2926,7 +2854,7 @@ e_msg_composer_new_with_message (CamelMimeMessage *message)
}
/* Remove any other X-Evolution-* headers that may have been set */
- xev = mail_tool_remove_xevolution_headers (message);
+ xev = emcu_remove_xevolution_headers (message);
camel_header_raw_clear (&xev);
/* Check for receipt request */
@@ -2982,7 +2910,7 @@ e_msg_composer_new_with_message (CamelMimeMessage *message)
gchar *html;
gssize length;
- html = em_utils_part_to_html ((CamelMimePart *)message, &length, NULL);
+ html = emcu_part_to_html ((CamelMimePart *)message, &length, NULL);
e_msg_composer_set_pending_body (composer, html, length);
}
@@ -3055,6 +2983,35 @@ e_msg_composer_new_redirect (CamelMimeMessage *message,
}
/**
+ * e_msg_composer_get_session:
+ * @composer: an #EMsgComposer
+ *
+ * Returns the mail module's global #CamelSession instance. Calling
+ * this function will load the mail module if it isn't already loaded.
+ *
+ * Returns: the mail module's #CamelSession
+ **/
+CamelSession *
+e_msg_composer_get_session (EMsgComposer *composer)
+{
+ EShell *shell;
+ 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_settings = e_shell_get_shell_settings (shell);
+
+ session = e_shell_settings_get_pointer (shell_settings, "mail-session");
+ g_return_val_if_fail (CAMEL_IS_SESSION (session), NULL);
+
+ return session;
+}
+
+/**
* e_msg_composer_send:
* @composer: an #EMsgComposer
*
@@ -3090,6 +3047,22 @@ e_msg_composer_save_draft (EMsgComposer *composer)
e_composer_autosave_set_saved (composer, FALSE);
}
+/**
+ * e_msg_composer_print:
+ * @composer: an #EMsgComposer
+ * @action: the print action to start
+ *
+ * Print the message in @composer.
+ **/
+void
+e_msg_composer_print (EMsgComposer *composer,
+ GtkPrintOperationAction action)
+{
+ g_return_if_fail (E_IS_MSG_COMPOSER (composer));
+
+ g_signal_emit (composer, signals[PRINT], 0, action);
+}
+
static GList *
add_recipients (GList *list, const gchar *recips)
{
@@ -3576,7 +3549,7 @@ e_msg_composer_get_message (EMsgComposer *composer,
store = e_attachment_view_get_store (view);
if (e_attachment_store_get_num_loading (store) > 0) {
- if (!em_utils_prompt_user (GTK_WINDOW (composer), NULL,
+ if (!emcu_prompt_user (GTK_WINDOW (composer), NULL,
"mail-composer:ask-send-message-pending-download", NULL)) {
return NULL;
}
@@ -3753,7 +3726,6 @@ e_msg_composer_show_sig_file (EMsgComposer *composer)
GtkhtmlEditor *editor;
GtkHTML *html;
gchar *html_text;
- gboolean top_signature;
g_return_if_fail (E_IS_MSG_COMPOSER (composer));
@@ -3780,8 +3752,6 @@ e_msg_composer_show_sig_file (EMsgComposer *composer)
}
gtkhtml_editor_run_command (editor, "unblock-selection");
- top_signature = is_top_signature ();
-
html_text = get_signature_html (composer);
if (html_text) {
gtkhtml_editor_run_command (editor, "insert-paragraph");
@@ -3795,10 +3765,6 @@ e_msg_composer_show_sig_file (EMsgComposer *composer)
gtkhtml_editor_run_command (editor, "style-normal");
gtkhtml_editor_insert_html (editor, html_text);
g_free (html_text);
- } else if (top_signature) {
- /* insert paragraph after the signature ClueFlow things */
- gtkhtml_editor_run_command (editor, "cursor-forward");
- gtkhtml_editor_run_command (editor, "insert-paragraph");
}
gtkhtml_editor_undo_end (editor);
@@ -3940,17 +3906,8 @@ e_msg_composer_load_from_file (const gchar *filename)
camel_object_unref (stream);
composer = e_msg_composer_new_with_message (msg);
- if (composer != NULL) {
- g_signal_connect (
- composer, "send",
- G_CALLBACK (em_utils_composer_send_cb), NULL);
-
- g_signal_connect (
- composer, "save-draft",
- G_CALLBACK (em_utils_composer_save_draft_cb), NULL);
-
+ if (composer != NULL)
gtk_widget_show (GTK_WIDGET (composer));
- }
return composer;
}
diff --git a/composer/e-msg-composer.h b/composer/e-msg-composer.h
index b9985f7f44..1a8f4676e7 100644
--- a/composer/e-msg-composer.h
+++ b/composer/e-msg-composer.h
@@ -25,6 +25,7 @@
#include <camel/camel-internet-address.h>
#include <camel/camel-mime-message.h>
+#include <camel/camel-session.h>
#include <libedataserver/e-account.h>
#include <libebook/e-destination.h>
#include <gtkhtml-editor.h>
@@ -67,21 +68,21 @@ struct _EMsgComposerClass {
GtkhtmlEditorClass parent_class;
};
-struct _EAttachmentBar;
-
GType e_msg_composer_get_type (void);
EMsgComposer * e_msg_composer_new (void);
-EMsgComposer * e_msg_composer_lite_new (void);
-
+void e_msg_composer_set_lite (void);
+gboolean e_msg_composer_get_lite (void);
+EMsgComposer * e_msg_composer_lite_new (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,
const gchar *resent_from);
-void e_msg_composer_set_lite (void);
-gboolean e_msg_composer_get_lite (void);
+CamelSession * e_msg_composer_get_session (EMsgComposer *composer);
void e_msg_composer_send (EMsgComposer *composer);
void e_msg_composer_save_draft (EMsgComposer *composer);
+void e_msg_composer_print (EMsgComposer *composer,
+ GtkPrintOperationAction action);
void e_msg_composer_set_alternative (EMsgComposer *composer,
gboolean alt);
@@ -129,9 +130,6 @@ void e_msg_composer_set_enable_autosave
(EMsgComposer *composer,
gboolean enabled);
-gchar * e_msg_composer_get_sig_file_content
- (const gchar *sigfile,
- gboolean in_html);
void e_msg_composer_add_message_attachments
(EMsgComposer *composer,
CamelMimeMessage *message,