diff options
author | Milan Crha <mcrha@redhat.com> | 2011-02-02 01:09:00 +0800 |
---|---|---|
committer | Milan Crha <mcrha@redhat.com> | 2011-02-02 01:09:00 +0800 |
commit | a10247b540f298d0ae6360b5d31f7f47a733adf8 (patch) | |
tree | 1be8b726e04b120e370dffbe862fb74f97b2cc46 | |
parent | a9fb511ced4cfaffb7109e58a9db66e6279e309c (diff) | |
download | gsoc2013-evolution-a10247b540f298d0ae6360b5d31f7f47a733adf8.tar.gz gsoc2013-evolution-a10247b540f298d0ae6360b5d31f7f47a733adf8.tar.zst gsoc2013-evolution-a10247b540f298d0ae6360b5d31f7f47a733adf8.zip |
Bug #635144 - Using external editor duplicates signature
-rw-r--r-- | calendar/gui/itip-utils.c | 4 | ||||
-rw-r--r-- | composer/e-msg-composer.c | 6 | ||||
-rw-r--r-- | composer/e-msg-composer.h | 2 | ||||
-rw-r--r-- | mail/em-composer-utils.c | 23 | ||||
-rw-r--r-- | mail/em-utils.c | 12 | ||||
-rw-r--r-- | mail/em-utils.h | 2 | ||||
-rw-r--r-- | plugins/external-editor/external-editor.c | 2 |
7 files changed, 22 insertions, 29 deletions
diff --git a/calendar/gui/itip-utils.c b/calendar/gui/itip-utils.c index 0981b1c164..6163d59fae 100644 --- a/calendar/gui/itip-utils.c +++ b/calendar/gui/itip-utils.c @@ -1460,7 +1460,7 @@ itip_send_comp (ECalComponentItipMethod method, body = camel_text_to_html ( description, CAMEL_MIME_FILTER_TOHTML_PRE, 0); - e_msg_composer_set_body_text (composer, body, -1); + e_msg_composer_set_body_text (composer, body, TRUE); g_free (body); attachment = camel_mime_part_new (); @@ -1650,7 +1650,7 @@ reply_to_calendar_comp (ECalComponentItipMethod method, g_string_append (body, html_description); g_free (html_description); - e_msg_composer_set_body_text (composer, body->str, -1); + e_msg_composer_set_body_text (composer, body->str, TRUE); g_string_free (body, TRUE); } diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c index 9f011a26e1..7439007ae4 100644 --- a/composer/e-msg-composer.c +++ b/composer/e-msg-composer.c @@ -4078,18 +4078,20 @@ e_msg_composer_new_from_url (EShell *shell, * e_msg_composer_set_body_text: * @composer: a composer object * @text: the HTML text to initialize the editor with + * @update_signature: whether update signature in the text after setting it; + * Might be usually called with TRUE. * * Loads the given HTML text into the editor. **/ void e_msg_composer_set_body_text (EMsgComposer *composer, const gchar *text, - gssize len) + gboolean update_signature) { g_return_if_fail (E_IS_MSG_COMPOSER (composer)); g_return_if_fail (text != NULL); - set_editor_text (composer, text, TRUE); + set_editor_text (composer, text, update_signature); } /** diff --git a/composer/e-msg-composer.h b/composer/e-msg-composer.h index 2fe912d7a8..296bb35a2f 100644 --- a/composer/e-msg-composer.h +++ b/composer/e-msg-composer.h @@ -110,7 +110,7 @@ void e_msg_composer_print (EMsgComposer *composer, void e_msg_composer_set_body_text (EMsgComposer *composer, const gchar *text, - gssize len); + gboolean update_signature); void e_msg_composer_set_body (EMsgComposer *composer, const gchar *body, const gchar *mime_type); diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c index 1b5b380f76..3f0c4b155a 100644 --- a/mail/em-composer-utils.c +++ b/mail/em-composer-utils.c @@ -1415,14 +1415,13 @@ forward_non_attached (EShell *shell, flags |= EM_FORMAT_QUOTE_CITE; for (i = 0; i < messages->len; i++) { - gssize len; guint32 validity_found = 0; message = messages->pdata[i]; subject = mail_tool_generate_forward_subject (message); forward = quoting_text (QUOTING_FORWARD); - text = em_utils_message_to_html (message, forward, flags, &len, NULL, NULL, &validity_found); + text = em_utils_message_to_html (message, forward, flags, NULL, NULL, &validity_found); if (text) { composer = create_new_composer (shell, subject, from_uri); @@ -1431,7 +1430,7 @@ forward_non_attached (EShell *shell, if (CAMEL_IS_MULTIPART (camel_medium_get_content ((CamelMedium *)message))) e_msg_composer_add_message_attachments (composer, message, FALSE); - e_msg_composer_set_body_text (composer, text, len); + e_msg_composer_set_body_text (composer, text, TRUE); if (uids && uids->pdata[i]) e_msg_composer_set_source_headers ( @@ -2460,8 +2459,7 @@ composer_set_body (EMsgComposer *composer, gchar *text, *credits, *original; CamelMimePart *part; GConfClient *client; - gssize len = 0; - gboolean start_bottom; + gboolean start_bottom, has_body_text = FALSE; guint32 validity_found = 0; const gchar *key; @@ -2482,8 +2480,9 @@ composer_set_body (EMsgComposer *composer, break; case E_MAIL_REPLY_STYLE_OUTLOOK: original = quoting_text (QUOTING_ORIGINAL); - text = em_utils_message_to_html (message, original, EM_FORMAT_QUOTE_HEADERS, &len, source, start_bottom ? "<BR>" : NULL, &validity_found); - e_msg_composer_set_body_text (composer, text, len); + text = em_utils_message_to_html (message, original, EM_FORMAT_QUOTE_HEADERS, source, start_bottom ? "<BR>" : NULL, &validity_found); + e_msg_composer_set_body_text (composer, text, TRUE); + has_body_text = text && *text; g_free (text); g_free (original); emu_update_composers_security (composer, validity_found); @@ -2493,15 +2492,16 @@ composer_set_body (EMsgComposer *composer, default: /* do what any sane user would want when replying... */ credits = attribution_format (message); - text = em_utils_message_to_html (message, credits, EM_FORMAT_QUOTE_CITE, &len, source, start_bottom ? "<BR>" : NULL, &validity_found); + text = em_utils_message_to_html (message, credits, EM_FORMAT_QUOTE_CITE, source, start_bottom ? "<BR>" : NULL, &validity_found); g_free (credits); - e_msg_composer_set_body_text (composer, text, len); + e_msg_composer_set_body_text (composer, text, TRUE); + has_body_text = text && *text; g_free (text); emu_update_composers_security (composer, validity_found); break; } - if (len > 0 && start_bottom) { + if (has_body_text && start_bottom) { GtkhtmlEditor *editor = GTKHTML_EDITOR (composer); /* If we are placing signature on top, then move cursor to the end, @@ -2531,11 +2531,10 @@ gchar * em_utils_construct_composer_text (CamelMimeMessage *message, EMFormat *source) { gchar *text, *credits; - gssize len = 0; gboolean start_bottom = 0; credits = attribution_format (message); - text = em_utils_message_to_html (message, credits, EM_FORMAT_QUOTE_CITE, &len, source, start_bottom ? "<BR>" : NULL, NULL); + text = em_utils_message_to_html (message, credits, EM_FORMAT_QUOTE_CITE, source, start_bottom ? "<BR>" : NULL, NULL); g_free (credits); return text; diff --git a/mail/em-utils.c b/mail/em-utils.c index 0753a75947..ad75c4829f 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -1266,7 +1266,6 @@ em_utils_get_proxy_uri (const gchar *pUri) * @message: * @credits: * @flags: EMFormatQuote flags - * @len: * @source: * @append: Text to append, can be NULL. * @validity_found: if not NULL, then here will be set what validities @@ -1276,13 +1275,12 @@ em_utils_get_proxy_uri (const gchar *pUri) * Convert a message to html, quoting if the @credits attribution * string is given. * - * Return value: The html version. + * Return value: The html version as a NULL terminated string. **/ gchar * em_utils_message_to_html (CamelMimeMessage *message, const gchar *credits, guint32 flags, - gssize *len, EMFormat *source, const gchar *append, guint32 *validity_found) @@ -1290,7 +1288,6 @@ em_utils_message_to_html (CamelMimeMessage *message, EMFormatQuote *emfq; CamelStream *mem; GByteArray *buf; - gchar *text; buf = g_byte_array_new (); mem = camel_stream_mem_new (); @@ -1324,12 +1321,7 @@ em_utils_message_to_html (CamelMimeMessage *message, camel_stream_write(mem, "", 1, NULL, NULL); g_object_unref (mem); - text = (gchar *)buf->data; - if (len) - *len = buf->len-1; - g_byte_array_free (buf, FALSE); - - return text; + return (gchar *) g_byte_array_free (buf, FALSE); } /* ********************************************************************** */ diff --git a/mail/em-utils.h b/mail/em-utils.h index 698ff3f0e6..2b45b37037 100644 --- a/mail/em-utils.h +++ b/mail/em-utils.h @@ -70,7 +70,7 @@ gboolean em_utils_folder_is_outbox (CamelFolder *folder, const gchar *uri); gchar *em_utils_get_proxy_uri (const gchar *uri); /* FIXME: should this have an override charset? */ -gchar *em_utils_message_to_html (CamelMimeMessage *msg, const gchar *credits, guint32 flags, gssize *len, struct _EMFormat *source, const gchar *append, guint32 *validity_found); +gchar *em_utils_message_to_html (CamelMimeMessage *msg, const gchar *credits, guint32 flags, struct _EMFormat *source, const gchar *append, guint32 *validity_found); void em_utils_expunge_folder (GtkWidget *parent, EMailSession *session, CamelFolder *folder); void em_utils_empty_trash (GtkWidget *parent, EMailSession *session); diff --git a/plugins/external-editor/external-editor.c b/plugins/external-editor/external-editor.c index be215706ba..b3f58410af 100644 --- a/plugins/external-editor/external-editor.c +++ b/plugins/external-editor/external-editor.c @@ -193,7 +193,7 @@ update_composer_text (GArray *array) composer = g_array_index (array, gpointer, 0); text = g_array_index (array, gpointer, 1); - e_msg_composer_set_body_text (composer, text, -1); + e_msg_composer_set_body_text (composer, text, FALSE); enable_composer (composer); |