diff options
author | Radek Doulik <rodo@src.gnome.org> | 2001-06-29 00:21:14 +0800 |
---|---|---|
committer | Radek Doulik <rodo@src.gnome.org> | 2001-06-29 00:21:14 +0800 |
commit | 3460368f5986462c91b18f1a7c9ffac67031f9cd (patch) | |
tree | 1c7f8d75c6474d8672addc5a3e60272eb9cec6eb | |
parent | 2a0952de00e5d4c2327ceb11ba00e5ea1ce9b97d (diff) | |
download | gsoc2013-evolution-3460368f5986462c91b18f1a7c9ffac67031f9cd.tar gsoc2013-evolution-3460368f5986462c91b18f1a7c9ffac67031f9cd.tar.gz gsoc2013-evolution-3460368f5986462c91b18f1a7c9ffac67031f9cd.tar.bz2 gsoc2013-evolution-3460368f5986462c91b18f1a7c9ffac67031f9cd.tar.lz gsoc2013-evolution-3460368f5986462c91b18f1a7c9ffac67031f9cd.tar.xz gsoc2013-evolution-3460368f5986462c91b18f1a7c9ffac67031f9cd.tar.zst gsoc2013-evolution-3460368f5986462c91b18f1a7c9ffac67031f9cd.zip |
simplified(refactored) signature handling + better support for html
signatures
svn path=/trunk/; revision=10563
-rw-r--r-- | composer/e-msg-composer.c | 83 | ||||
-rw-r--r-- | composer/e-msg-composer.h | 9 | ||||
-rw-r--r-- | composer/evolution-composer.c | 14 |
3 files changed, 37 insertions, 69 deletions
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c index c077e8b673..c14b784703 100644 --- a/composer/e-msg-composer.c +++ b/composer/e-msg-composer.c @@ -638,7 +638,7 @@ read_file_content (gint fd) } static char * -get_file_content (char *file_name, gboolean convert, guint flags) +get_file_content (const gchar *file_name, gboolean convert, guint flags) { gint fd; char *raw; @@ -682,20 +682,11 @@ get_file_content (char *file_name, gboolean convert, guint flags) static char * get_sig_file_content (const char *sigfile, gboolean in_html) { - gchar *file_name; - gchar *htmlsig = NULL; - if (!sigfile || !*sigfile) { return NULL; } - file_name = in_html ? g_strconcat (sigfile, ".html", NULL) : (gchar *) sigfile; - - htmlsig = get_file_content (file_name, !in_html, 0); - - if (in_html) g_free (file_name); - - return htmlsig; + return get_file_content (sigfile, !in_html, 0); } static void @@ -728,19 +719,37 @@ prepare_engine (EMsgComposer *composer) CORBA_exception_free (&ev); } +static const gchar * +get_sig_file (EMsgComposer *composer) +{ + + return NULL; +} + static gchar * get_signature_html (EMsgComposer *composer) { - gboolean format_html = composer->send_html; - gchar *text, *html = NULL; + gboolean format_html = FALSE; + gchar *text, *html = NULL, *sig_file = NULL; - text = get_sig_file_content (composer->sig_file, format_html); - /* if we tried HTML sig and it's not available, try also non HTML signature */ - if (format_html && !text) { - format_html = FALSE; - text = get_sig_file_content (composer->sig_file, format_html); + if (E_MSG_COMPOSER_HDRS (composer->hdrs)->account->id) { + MailConfigIdentity *id; + + id = E_MSG_COMPOSER_HDRS (composer->hdrs)->account->id; + if (composer->send_html) { + if (id->has_html_signature) { + sig_file = id->html_signature; + format_html = TRUE; + } else + sig_file = id->signature; + } else + sig_file = id->signature; } + if (!sig_file) + return NULL; + + text = get_sig_file_content (sig_file, format_html); if (text) { html = g_strdup_printf ("<!--+GtkHTML:<DATA class=\"ClueFlow\" key=\"signature\" value=\"1\">-->" "<TABLE WIDTH=\"100%%\" CELLSPACING=\"0\" CELLPADDING=\"0\"><TR><TD>" @@ -1160,7 +1169,7 @@ menu_edit_delete_all_cb (BonoboUIComponent *uic, void *data, const char *path) GNOME_GtkHTML_Editor_Engine_runCommand (composer->editor_engine, "delete", &ev); GNOME_GtkHTML_Editor_Engine_setParagraphData (composer->editor_engine, "signature", "0", &ev); GNOME_GtkHTML_Editor_Engine_setParagraphData (composer->editor_engine, "orig", "0", &ev); - e_msg_composer_set_sig_file (composer, composer->sig_file); + e_msg_composer_show_sig_file (composer); GNOME_GtkHTML_Editor_Engine_runCommand (composer->editor_engine, "style-normal", &ev); GNOME_GtkHTML_Editor_Engine_thaw (composer->editor_engine, &ev); GNOME_GtkHTML_Editor_Engine_undo_end (composer->editor_engine, &ev); @@ -1558,7 +1567,7 @@ from_changed_cb (EMsgComposerHdrs *hdrs, composer = E_MSG_COMPOSER (data); - e_msg_composer_set_sig_file (composer, hdrs->account->id->signature); + e_msg_composer_show_sig_file (composer); } @@ -2053,14 +2062,13 @@ e_msg_composer_new (void) * Return value: A pointer to the newly created widget **/ EMsgComposer * -e_msg_composer_new_with_sig_file (const char *sig_file, gboolean send_html) +e_msg_composer_new_with_sig_file () { EMsgComposer *new; new = create_composer (); if (new) { - new->sig_file = g_strdup (sig_file); - e_msg_composer_set_send_html (new, send_html); + e_msg_composer_set_send_html (new, mail_config_get_send_html ()); set_editor_text (new, ""); } @@ -2679,7 +2687,7 @@ delete_old_signature (EMsgComposer *composer) * Set a signature **/ void -e_msg_composer_set_sig_file (EMsgComposer *composer, const char *sig_file) +e_msg_composer_show_sig_file (EMsgComposer *composer) { CORBA_Environment ev; gchar *html; @@ -2696,12 +2704,6 @@ e_msg_composer_set_sig_file (EMsgComposer *composer, const char *sig_file) GNOME_GtkHTML_Editor_Engine_undo_begin (composer->editor_engine, "Set signature", "Reset signature", &ev); delete_old_signature (composer); - - if (composer->sig_file != sig_file && (!sig_file || !composer->sig_file || strcmp (composer->sig_file, sig_file))) { - g_free (composer->sig_file); - composer->sig_file = g_strdup (sig_file); - } - html = get_signature_html (composer); if (html) { if (!GNOME_GtkHTML_Editor_Engine_isParagraphEmpty (composer->editor_engine, &ev)) @@ -2720,24 +2722,6 @@ e_msg_composer_set_sig_file (EMsgComposer *composer, const char *sig_file) } /** - * e_msg_composer_get_sig_file: - * @composer: A message composer widget - * - * Get the signature file - * - * Return value: The signature file. - **/ -const char * -e_msg_composer_get_sig_file (EMsgComposer *composer) -{ - g_return_val_if_fail (composer != NULL, NULL); - g_return_val_if_fail (E_IS_MSG_COMPOSER (composer), NULL); - - return composer->sig_file; -} - - -/** * e_msg_composer_set_send_html: * @composer: A message composer widget * @send_html: Whether the composer should have the "Send HTML" flag set @@ -2771,8 +2755,7 @@ e_msg_composer_set_send_html (EMsgComposer *composer, composer->send_html, NULL); set_config (composer, "FormatHTML", composer->send_html); - if (composer->sig_file) - e_msg_composer_set_sig_file (composer, composer->sig_file); + e_msg_composer_show_sig_file (composer); GNOME_GtkHTML_Editor_Engine_runCommand (composer->editor_engine, "unblock-redraw", &ev); CORBA_exception_free (&ev); } diff --git a/composer/e-msg-composer.h b/composer/e-msg-composer.h index 7f0db7e16b..61cdff256b 100644 --- a/composer/e-msg-composer.h +++ b/composer/e-msg-composer.h @@ -73,8 +73,6 @@ struct _EMsgComposer { Bonobo_PropertyBag property_bag; - char *sig_file; - gboolean attachment_bar_visible : 1; gboolean send_html : 1; gboolean pgp_sign : 1; @@ -102,8 +100,7 @@ struct _EMsgComposerClass { GtkType e_msg_composer_get_type (void); void e_msg_composer_construct (EMsgComposer *composer); EMsgComposer *e_msg_composer_new (void); -EMsgComposer *e_msg_composer_new_with_sig_file (const char *sig_file, - gboolean send_html); +EMsgComposer *e_msg_composer_new_with_sig_file (void); EMsgComposer *e_msg_composer_new_with_message (CamelMimeMessage *msg); EMsgComposer *e_msg_composer_new_from_url (const char *url); void e_msg_composer_show_attachments (EMsgComposer *composer, @@ -122,9 +119,7 @@ void e_msg_composer_add_header (EMsgComposer *compose void e_msg_composer_attach (EMsgComposer *composer, CamelMimePart *attachment); CamelMimeMessage *e_msg_composer_get_message (EMsgComposer *composer); -void e_msg_composer_set_sig_file (EMsgComposer *composer, - const char *sig_file); -const char *e_msg_composer_get_sig_file (EMsgComposer *composer); +void e_msg_composer_show_sig_file (EMsgComposer *composer); gboolean e_msg_composer_get_send_html (EMsgComposer *composer); void e_msg_composer_set_send_html (EMsgComposer *composer, gboolean send_html); diff --git a/composer/evolution-composer.c b/composer/evolution-composer.c index ef9456c1aa..6dfddf1202 100644 --- a/composer/evolution-composer.c +++ b/composer/evolution-composer.c @@ -257,19 +257,9 @@ static void init (EvolutionComposer *composer) { const MailConfigAccount *account; - gboolean send_html; - gchar *sig_file = NULL; - account = mail_config_get_default_account (); - send_html = mail_config_get_send_html (); - - if (account->id) - sig_file = account->id->signature; - - if (sig_file) - composer->composer = e_msg_composer_new_with_sig_file (sig_file, send_html); - else - composer->composer = e_msg_composer_new (); + account = mail_config_get_default_account (); + composer->composer = e_msg_composer_new_with_sig_file (); gtk_signal_connect (GTK_OBJECT (composer->composer), "send", GTK_SIGNAL_FUNC (send_cb), NULL); |