Re: [evolution-patches] [Fwd: [composer, mailer] #59490 Signature is prefixed with '> " in replies]
- From: Radek Doulík <rodo novell com>
- To: Not Zed <notzed ximian com>
- Cc: Patches <evolution-patches ximian com>
- Subject: Re: [evolution-patches] [Fwd: [composer, mailer] #59490 Signature is prefixed with '> " in replies]
- Date: Fri, 23 Jul 2004 18:34:24 +0200
On Tue, 2004-07-20 at 20:40 +0800, Not Zed wrote:
umm, that email contains an embedded 0, it should be put into the body therefore.
gtkhtml handles binary doesn't it? its probably a bug that any of the code is using strlen at all.
I cooked second patch to avoid using strlen there as well. OK to commit?
R.
Index: composer/e-msg-composer.c
===================================================================
RCS file: /cvs/gnome/evolution/composer/e-msg-composer.c,v
retrieving revision 1.475
diff -u -p -r1.475 e-msg-composer.c
--- composer/e-msg-composer.c 22 Jul 2004 16:36:15 -0000 1.475
+++ composer/e-msg-composer.c 23 Jul 2004 14:16:25 -0000
@@ -1119,7 +1119,7 @@ get_signature_html (EMsgComposer *compos
}
static void
-set_editor_text(EMsgComposer *composer, const char *text, int set_signature, int pad_signature)
+set_editor_text(EMsgComposer *composer, const char *text, size_t len, int set_signature, int pad_signature)
{
Bonobo_PersistStream persist;
BonoboStream *stream;
@@ -1135,7 +1135,10 @@ set_editor_text(EMsgComposer *composer,
CORBA_exception_init (&ev);
- stream = bonobo_stream_mem_create (text, strlen (text), TRUE, FALSE);
+ if (len == -1)
+ len = strlen (text);
+
+ stream = bonobo_stream_mem_create (text, len, TRUE, FALSE);
object = bonobo_object_corba_objref (BONOBO_OBJECT (stream));
Bonobo_PersistStream_load (persist, (Bonobo_Stream) object, "text/html", &ev);
if (ev._major != CORBA_NO_EXCEPTION) {
@@ -3378,7 +3381,7 @@ e_msg_composer_new_with_type (int type)
if (new) {
e_msg_composer_set_send_html (new, send_html);
set_editor_signature (new);
- set_editor_text (new, "", TRUE, TRUE);
+ set_editor_text (new, "", 0, TRUE, TRUE);
}
return new;
@@ -3416,24 +3419,27 @@ is_special_header (const char *hdr_name)
}
static void
-e_msg_composer_set_pending_body (EMsgComposer *composer, char *text)
+e_msg_composer_set_pending_body (EMsgComposer *composer, char *text, size_t len)
{
char *old;
old = g_object_get_data ((GObject *) composer, "body:text");
g_free (old);
g_object_set_data ((GObject *) composer, "body:text", text);
+ g_object_set_data ((GObject *) composer, "body:len", GSIZE_TO_POINTER (len));
}
static void
e_msg_composer_flush_pending_body (EMsgComposer *composer, gboolean apply)
{
char *body;
+ size_t len;
body = g_object_get_data ((GObject *) composer, "body:text");
+ len = GPOINTER_TO_SIZE (g_object_get_data ((GObject *) composer, "body:len"));
if (body) {
if (apply)
- set_editor_text (composer, body, FALSE, FALSE);
+ set_editor_text (composer, body, len, FALSE, FALSE);
g_object_set_data ((GObject *) composer, "body:text", NULL);
g_free (body);
@@ -3559,7 +3565,8 @@ handle_multipart_signed (EMsgComposer *c
handle_multipart (composer, multipart, depth);
}
} else if (camel_content_type_is (content_type, "text", "*")) {
- e_msg_composer_set_pending_body (composer, em_utils_part_to_html (mime_part));
+ size_t len;
+ e_msg_composer_set_pending_body (composer, em_utils_part_to_html (mime_part, &len), len);
} else {
e_msg_composer_attach (composer, mime_part);
}
@@ -3613,7 +3620,9 @@ handle_multipart_encrypted (EMsgComposer
handle_multipart (composer, multipart, depth);
}
} else if (camel_content_type_is (content_type, "text", "*")) {
- e_msg_composer_set_pending_body (composer, em_utils_part_to_html (mime_part));
+ size_t len;
+
+ e_msg_composer_set_pending_body (composer, em_utils_part_to_html (mime_part, &len), len);
} else {
e_msg_composer_attach (composer, mime_part);
}
@@ -3668,8 +3677,11 @@ handle_multipart_alternative (EMsgCompos
}
}
- if (text_part)
- e_msg_composer_set_pending_body(composer, em_utils_part_to_html(text_part));
+ if (text_part) {
+ size_t len;
+
+ e_msg_composer_set_pending_body(composer, em_utils_part_to_html(text_part, &len), len);
+ }
}
static void
@@ -3706,8 +3718,10 @@ handle_multipart (EMsgComposer *composer
handle_multipart (composer, mp, depth + 1);
}
} else if (depth == 0 && i == 0) {
+ size_t len;
+
/* Since the first part is not multipart/alternative, then this must be the body */
- e_msg_composer_set_pending_body(composer, em_utils_part_to_html(mime_part));
+ e_msg_composer_set_pending_body(composer, em_utils_part_to_html(mime_part, &len), len);
} else if (camel_mime_part_get_content_id (mime_part) ||
camel_mime_part_get_content_location (mime_part)) {
/* special in-line attachment */
@@ -3981,7 +3995,9 @@ e_msg_composer_new_with_message (CamelMi
handle_multipart (new, multipart, 0);
}
} else {
- e_msg_composer_set_pending_body(new, em_utils_part_to_html((CamelMimePart *)message));
+ size_t len;
+
+ e_msg_composer_set_pending_body(new, em_utils_part_to_html((CamelMimePart *)message, &len), len);
}
/* We wait until now to set the body text because we need to ensure that
@@ -4200,7 +4216,7 @@ handle_mailto (EMsgComposer *composer, c
char *htmlbody;
htmlbody = camel_text_to_html (body, CAMEL_MIME_FILTER_TOHTML_PRE, 0);
- set_editor_text (composer, htmlbody, FALSE, FALSE);
+ set_editor_text (composer, htmlbody, -1, FALSE, FALSE);
g_free (htmlbody);
}
}
@@ -4289,11 +4305,11 @@ e_msg_composer_set_headers (EMsgComposer
* Loads the given HTML text into the editor.
**/
void
-e_msg_composer_set_body_text (EMsgComposer *composer, const char *text)
+e_msg_composer_set_body_text (EMsgComposer *composer, const char *text, size_t len)
{
g_return_if_fail (E_IS_MSG_COMPOSER (composer));
- set_editor_text (composer, text, TRUE, text == "");
+ set_editor_text (composer, text, len, TRUE, text == "");
}
/**
@@ -4311,7 +4327,7 @@ e_msg_composer_set_body (EMsgComposer *c
{
g_return_if_fail (E_IS_MSG_COMPOSER (composer));
- set_editor_text (composer, _("<b>(The composer contains a non-text message body, which cannot be edited.)<b>"), FALSE, FALSE);
+ set_editor_text (composer, _("<b>(The composer contains a non-text message body, which cannot be edited.)<b>"), -1, FALSE, FALSE);
e_msg_composer_set_send_html (composer, FALSE);
disable_editor (composer);
Index: composer/e-msg-composer.h
===================================================================
RCS file: /cvs/gnome/evolution/composer/e-msg-composer.h,v
retrieving revision 1.90
diff -u -p -r1.90 e-msg-composer.h
--- composer/e-msg-composer.h 9 Apr 2004 17:31:24 -0000 1.90
+++ composer/e-msg-composer.h 23 Jul 2004 14:16:25 -0000
@@ -151,7 +151,8 @@ void e_msg_composer_
EDestination **bcc,
const char *subject);
void e_msg_composer_set_body_text (EMsgComposer *composer,
- const char *text);
+ const char *text,
+ size_t len);
void e_msg_composer_set_body (EMsgComposer *composer,
const char *body,
const char *mime_type);
Index: composer/evolution-composer.c
===================================================================
RCS file: /cvs/gnome/evolution/composer/evolution-composer.c,v
retrieving revision 1.40
diff -u -p -r1.40 evolution-composer.c
--- composer/evolution-composer.c 17 Jun 2004 07:33:24 -0000 1.40
+++ composer/evolution-composer.c 23 Jul 2004 14:16:25 -0000
@@ -161,10 +161,10 @@ impl_Composer_set_body (PortableServer_S
if (!g_ascii_strcasecmp (mime_type, "text/plain")) {
char *htmlbody = camel_text_to_html (body, CAMEL_MIME_FILTER_TOHTML_PRE, 0);
- e_msg_composer_set_body_text (composer->composer, htmlbody);
+ e_msg_composer_set_body_text (composer->composer, htmlbody, -1);
g_free (htmlbody);
} else if (!g_ascii_strcasecmp (mime_type, "text/html"))
- e_msg_composer_set_body_text (composer->composer, body);
+ e_msg_composer_set_body_text (composer->composer, body, -1);
else
e_msg_composer_set_body (composer->composer, body, mime_type);
}
Index: composer/listener.c
===================================================================
RCS file: /cvs/gnome/evolution/composer/listener.c,v
retrieving revision 1.34
diff -u -p -r1.34 listener.c
--- composer/listener.c 31 Mar 2004 10:08:03 -0000 1.34
+++ composer/listener.c 23 Jul 2004 14:16:25 -0000
@@ -32,7 +32,6 @@
#include "listener.h"
static BonoboObjectClass *listener_parent_class;
-static POA_GNOME_GtkHTML_Editor_Listener__vepv listener_vepv;
inline static EditorListener *
listener_from_servant (PortableServer_Servant servant)
Index: mail/em-composer-utils.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/em-composer-utils.c,v
retrieving revision 1.17
diff -u -p -r1.17 em-composer-utils.c
--- mail/em-composer-utils.c 15 Jun 2004 20:27:55 -0000 1.17
+++ mail/em-composer-utils.c 23 Jul 2004 14:16:27 -0000
@@ -881,15 +881,17 @@ forward_non_attached (GPtrArray *message
flags |= EM_FORMAT_QUOTE_CITE;
for (i = 0; i < messages->len; i++) {
+ size_t len;
+
message = messages->pdata[i];
subject = mail_tool_generate_forward_subject (message);
- text = em_utils_message_to_html (message, _("-------- Forwarded Message --------"), flags);
+ text = em_utils_message_to_html (message, _("-------- Forwarded Message --------"), flags, &len);
if (text) {
composer = create_new_composer (subject, fromuri);
- e_msg_composer_set_body_text (composer, text);
+ e_msg_composer_set_body_text (composer, text, len);
e_msg_composer_unset_changed (composer);
e_msg_composer_drop_editor_undo (composer);
@@ -1663,6 +1665,7 @@ composer_set_body (EMsgComposer *compose
char *text, *credits;
CamelMimePart *part;
GConfClient *gconf;
+ size_t len;
gconf = mail_config_get_gconf_client ();
@@ -1680,9 +1683,9 @@ composer_set_body (EMsgComposer *compose
default:
/* do what any sane user would want when replying... */
credits = attribution_format (ATTRIBUTION, message);
- text = em_utils_message_to_html(message, credits, EM_FORMAT_QUOTE_CITE);
+ text = em_utils_message_to_html(message, credits, EM_FORMAT_QUOTE_CITE, &len);
g_free (credits);
- e_msg_composer_set_body_text(composer, text);
+ e_msg_composer_set_body_text(composer, text, len);
g_free (text);
break;
}
Index: mail/em-utils.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/em-utils.c,v
retrieving revision 1.45
diff -u -p -r1.45 em-utils.c
--- mail/em-utils.c 23 Jul 2004 03:49:22 -0000 1.45
+++ mail/em-utils.c 23 Jul 2004 14:16:28 -0000
@@ -1365,7 +1365,7 @@ em_utils_get_proxy_uri(void)
* Return Value: The part in displayable html format.
**/
char *
-em_utils_part_to_html(CamelMimePart *part)
+em_utils_part_to_html(CamelMimePart *part, size_t *len)
{
EMFormatQuote *emfq;
CamelStreamMem *mem;
@@ -1385,6 +1385,8 @@ em_utils_part_to_html(CamelMimePart *par
camel_object_unref (mem);
text = buf->data;
+ if (len)
+ *len = buf->len;
g_byte_array_free (buf, FALSE);
return text;
@@ -1402,7 +1404,7 @@ em_utils_part_to_html(CamelMimePart *par
* Return value: The html version.
**/
char *
-em_utils_message_to_html(CamelMimeMessage *message, const char *credits, guint32 flags)
+em_utils_message_to_html(CamelMimeMessage *message, const char *credits, guint32 flags, size_t *len)
{
EMFormatQuote *emfq;
CamelStreamMem *mem;
@@ -1422,6 +1424,8 @@ em_utils_message_to_html(CamelMimeMessag
camel_object_unref (mem);
text = buf->data;
+ if (len)
+ *len = buf->len;
g_byte_array_free (buf, FALSE);
return text;
Index: mail/em-utils.h
===================================================================
RCS file: /cvs/gnome/evolution/mail/em-utils.h,v
retrieving revision 1.14
diff -u -p -r1.14 em-utils.h
--- mail/em-utils.h 19 May 2004 07:02:12 -0000 1.14
+++ mail/em-utils.h 23 Jul 2004 14:16:28 -0000
@@ -84,8 +84,8 @@ void em_utils_adjustment_page(struct _Gt
char *em_utils_get_proxy_uri(void);
/* FIXME: should this have an override charset? */
-char *em_utils_part_to_html(struct _CamelMimePart *part);
-char *em_utils_message_to_html(struct _CamelMimeMessage *msg, const char *credits, guint32 flags);
+char *em_utils_part_to_html(struct _CamelMimePart *part, size_t *len);
+char *em_utils_message_to_html(struct _CamelMimeMessage *msg, const char *credits, guint32 flags, size_t *len);
void em_utils_expunge_folder (struct _GtkWidget *parent, struct _CamelFolder *folder);
void em_utils_empty_trash (struct _GtkWidget *parent);
Index: composer/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/composer/ChangeLog,v
retrieving revision 1.653
diff -u -p -r1.653 ChangeLog
--- composer/ChangeLog 22 Jul 2004 16:36:15 -0000 1.653
+++ composer/ChangeLog 23 Jul 2004 15:48:53 -0000
@@ -1,3 +1,12 @@
+2004-07-23 Radek Doulik <rodo ximian com>
+
+ * listener.c: removed unused static variable listener_vepv
+
+ * added len parameter to set_editor_text,
+ e_msg_composer_set_body_text, e_msg_composer_set_pending_body. it
+ allows us to send whole buffer (even if it contains \0 in the
+ middle) to gtkhtml editor.
+
2004-07-22 Radek Doulik <rodo ximian com>
* e-msg-composer.c (set_editor_text): removed body content +
Index: mail/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/mail/ChangeLog,v
retrieving revision 1.3418
diff -u -p -r1.3418 ChangeLog
--- mail/ChangeLog 23 Jul 2004 03:49:22 -0000 1.3418
+++ mail/ChangeLog 23 Jul 2004 15:49:13 -0000
@@ -1,3 +1,9 @@
+2004-07-23 Radek Doulik <rodo ximian com>
+
+ * added len parameter to em_utils_part_to_html and
+ em_utils_message_to_html. it is used to return length of returned
+ buffer. we use that info later when setting composer body content.
+
2004-07-22 Not Zed <NotZed Ximian com>
* em-utils.c (em_utils_part_to_html, em_utils_message_to_html):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]