aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Loper <mloper@src.gnome.org>2000-02-09 08:48:28 +0800
committerMatthew Loper <mloper@src.gnome.org>2000-02-09 08:48:28 +0800
commit66dc424c9c809c775e1491299bb2a8c97715865f (patch)
treed15e62877fc1cacc537f61b82f40a45fb7b01fb3
parentc9f1db9bd04c54e488d2c3670c9baed990aa205f (diff)
downloadgsoc2013-evolution-66dc424c9c809c775e1491299bb2a8c97715865f.tar.gz
gsoc2013-evolution-66dc424c9c809c775e1491299bb2a8c97715865f.tar.zst
gsoc2013-evolution-66dc424c9c809c775e1491299bb2a8c97715865f.zip
+ * tests/test-formatter.c (convert_to_html_and_print): Use the
+ buffer length of the stream to create strings which are then + printed, rather than printing the stream (which might not have a + trailing \0) directly. + + * camel/camel-formatter.c (str_tolower): New function; makes a + string lowercase. svn path=/trunk/; revision=1698
-rw-r--r--ChangeLog8
-rw-r--r--camel/camel-formatter.c48
-rw-r--r--tests/test-formatter.c23
3 files changed, 66 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index 2745cd92fe..69ac056f74 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2000-02-08 Matt Loper <matt.loper@splashtech.com>
+ * tests/test-formatter.c (convert_to_html_and_print): Use the
+ buffer length of the stream to create strings which are then
+ printed, rather than printing the stream (which might not have a
+ trailing \0) directly.
+
+ * camel/camel-formatter.c (str_tolower): New function; makes a
+ string lowercase.
+
* tests/test-formatter.c (convert_to_html_and_print): Fixed call
to 'camel_formatter_mime_message_to_html' to contain correct
params.
diff --git a/camel/camel-formatter.c b/camel/camel-formatter.c
index 4a1b873141..91a47af01e 100644
--- a/camel/camel-formatter.c
+++ b/camel/camel-formatter.c
@@ -76,6 +76,7 @@ static gchar* text_to_html (const guchar *input,
/* compares strings case-insensitively */
static gint strcase_equal (gconstpointer v, gconstpointer v2);
+static void str_tolower (gchar* str);
/* writes the header info for a mime message into a stream */
static void write_header_info_to_stream (CamelMimeMessage* mime_message,
@@ -125,6 +126,8 @@ camel_formatter_mime_message_to_html (CamelFormatter* formatter,
CamelStream* body_stream)
{
CamelFormatterPrivate* fmt = formatter->priv;
+
+ g_print ("camel_formatter_mime_message_to_html: entered\n");
/* initialize members of our formatter */
fmt->current_root = mime_message;
@@ -164,6 +167,9 @@ lookup_unique_id (CamelMimeMessage* root, CamelDataWrapper* child)
static GHashTable* mime_function_table;
+/* This tries to create a tag, given a mimetype and the child of a
+ * mime message. It can return NULL if it can't match the mimetype to
+ * a bonobo object. */
static gchar*
get_bonobo_tag_for_object (CamelFormatter* formatter,
CamelDataWrapper* wrapper,
@@ -211,6 +217,9 @@ call_handler_function (CamelFormatter* formatter,
/*
* Try to find a handler function in our own lookup table
*/
+ str_tolower (mimetype_whole);
+ str_tolower (mimetype_main);
+
if (mimetype_whole)
handler_function = g_hash_table_lookup (
mime_function_table, mimetype_whole);
@@ -250,7 +259,7 @@ call_handler_function (CamelFormatter* formatter,
else {
handle_unknown_type (formatter, wrapper);
debug ("no function or bonobo object found for mimetype \"%s\"\n",
- mimetype_whole || mimetype_main);
+ mimetype_whole?mimetype_whole:mimetype_main);
}
}
@@ -260,12 +269,9 @@ call_handler_function (CamelFormatter* formatter,
*----------------------------------------------------------------------*/
/* This routine was originally written by Daniel Velliard, (C) 1998
- World Wide Web Consortium.
-
- It will (for example) turn the input 'ab <c>' into 'ab &lt;c&gt;'
-
- It has also been altered to turn '\n' into <br>.
-*/
+ * World Wide Web Consortium.
+ * - It will (for example) turn the input 'ab <c>' into 'ab &lt;c&gt;'
+ * - It has also been altered to turn '\n' into <br>. */
static gchar *
text_to_html (const guchar *input,
guint len,
@@ -453,11 +459,24 @@ write_header_info_to_stream (CamelMimeMessage* mime_message,
write_recipients_to_stream ("BCC:", recipients, stream);
}
+/* case-insensitive string comparison */
static gint
strcase_equal (gconstpointer v, gconstpointer v2)
{
return g_strcasecmp ((const gchar*) v, (const gchar*)v2) == 0;
}
+
+static void
+str_tolower (gchar* str)
+{
+ int i;
+ int len = strlen (str);
+
+ for (i = 0; i < len; i++) {
+ str[i] = tolower (str[i]);
+ }
+}
+
#define MIME_TYPE_WHOLE(a) (gmime_content_field_get_mime_type ( \
camel_mime_part_get_content_type (CAMEL_MIME_PART (a))))
@@ -481,6 +500,9 @@ handle_text_plain (CamelFormatter *formatter, CamelDataWrapper *wrapper)
g_assert (CAMEL_IS_SIMPLE_DATA_WRAPPER (wrapper));
simple_data_wrapper = CAMEL_SIMPLE_DATA_WRAPPER (wrapper);
+ camel_stream_write_string (formatter->priv->stream,
+ "\n<!-- text/plain below -->\n");
+
/* If there's any text, write it to the stream */
if (simple_data_wrapper->byte_array->len != 0) {
@@ -525,7 +547,9 @@ handle_text_html (CamelFormatter *formatter, CamelDataWrapper *wrapper)
text = text_to_html (simple_data_wrapper->byte_array->data,
simple_data_wrapper->byte_array->len,
&returned_strlen);
-
+
+ camel_stream_write_string (formatter->priv->stream,
+ "\n<!-- text/html below -->\n");
camel_stream_write_string (formatter->priv->stream, text);
g_free (text);
}
@@ -560,6 +584,8 @@ handle_vcard (CamelFormatter *formatter, CamelDataWrapper *wrapper)
gchar* vcard;
debug ("handle_vcard: entered\n");
+ camel_stream_write_string (formatter->priv->stream,
+ "\n<!-- image below -->\n");
// camel_stream_write_string (formatter->priv->stream, vcard);
// g_free (vcard);
@@ -576,7 +602,10 @@ handle_mime_message (CamelFormatter *formatter,
CamelDataWrapper* message_contents =
camel_medium_get_content_object (CAMEL_MEDIUM (mime_message));
- debug ("handle_mime_message: entered\n");
+ debug ("handle_mime_message: entered\n");
+ camel_stream_write_string (formatter->priv->stream,
+ "\n<!-- mime message below -->\n");
+
camel_stream_write_string (formatter->priv->stream,
"<table width=95% border=1><tr><td>\n\n");
@@ -822,6 +851,7 @@ camel_formatter_init (gpointer object, gpointer klass)
{
CamelFormatter* cmf = CAMEL_FORMATTER (object);
cmf->priv = g_new (CamelFormatterPrivate, 1);
+ cmf->priv->attachments = NULL;
}
diff --git a/tests/test-formatter.c b/tests/test-formatter.c
index b3e0ca76a6..536d3e9bbf 100644
--- a/tests/test-formatter.c
+++ b/tests/test-formatter.c
@@ -14,16 +14,29 @@ static void
convert_to_html_and_print (CamelMimeMessage *msg)
{
CamelFormatter* cmf = camel_formatter_new();
+ gchar* header_str;
+ gchar* body_str;
+
CamelStream* header_stream =
camel_stream_mem_new (CAMEL_STREAM_FS_WRITE);
CamelStream* body_stream =
camel_stream_mem_new (CAMEL_STREAM_FS_WRITE);
camel_formatter_mime_message_to_html (
cmf, msg, header_stream, body_stream);
+
+ header_str = g_strndup (
+ CAMEL_STREAM_MEM (header_stream)->buffer->data,
+ CAMEL_STREAM_MEM (header_stream)->buffer->len);
+ body_str = g_strndup (
+ CAMEL_STREAM_MEM (body_stream)->buffer->data,
+ CAMEL_STREAM_MEM (body_stream)->buffer->len);
g_print ("Header follows\n----------------------\n%s\n",
- (CAMEL_STREAM_MEM(header_stream))->buffer->data);
+ header_str);
g_print ("Body follows\n----------------------\n%s\n",
- (CAMEL_STREAM_MEM(body_stream))->buffer->data);
+ body_str);
+
+ g_free (header_str);
+ g_free (body_str);
}
static void
@@ -63,12 +76,14 @@ main (int argc, char**argv)
printf ("You must create the file mail.test before running this test");
exit(2);
}
-
- camel_data_wrapper_construct_from_stream ( CAMEL_DATA_WRAPPER (message), input_stream);
+
+ camel_data_wrapper_construct_from_stream (
+ CAMEL_DATA_WRAPPER (message), input_stream);
camel_debug_level = CAMEL_LOG_LEVEL_FULL_DEBUG;
convert_to_html_and_print (message);
+
camel_stream_close (input_stream);
gtk_object_unref (GTK_OBJECT (input_stream));
>3-3/+3 * SIZEify.sf2004-03-182-0/+5 * Add SIZE data.perky2004-03-182-0/+2 * Join SIZEify movement here; add a SIZE line.matusita2004-03-181-0/+1 * Add SIZE.motoyuki2004-03-181-0/+1 * Add size data.trevor2004-03-181-0/+1 * SIZEify.kuriyama2004-03-186-0/+7 * Move .include line position.kuriyama2004-03-181-2/+2 * SIZEify.trevor2004-03-181-0/+2 * BROKEN on amd64 and ia64: Coredump during buildkris2004-03-173-3/+21 * Whoa there, boy, that's a mighty big commit y'all have there...ade2004-03-1433-36/+34 * Since asami's directory on MASTER_SITE_LOCAL is gone, stow histrevor2004-03-131-1/+1 * Sync FORBIDDEN tags with the FreeBSD VuXML database, please refer to theeik2004-03-121-0/+2 * Update I18N patch.okazaki2004-03-112-4/+6 * Update I18N patch.okazaki2004-03-112-3/+6 * Remove unused entry for cdb-0.75.tar.gz. List size.trevor2004-03-111-1/+1 * Updatet to 0.3.5.nork2004-03-102-9/+3 * Fix up some conflicts issues: there was an edge case where samba-devellinimon2004-03-101-1/+1 * Update to KDE 3.2.1 / QT 3.3.1lofi2004-03-108-46/+186 * Change WATANABE-san's e-mail addresssanpei2004-03-082-3/+4 * - Update to version 4.0.8krion2004-03-082-3/+3 * Fix $LATEST_NAME conflict.kuriyama2004-03-081-0/+1 * BROKEN on ia64: Configure failskris2004-03-072-2/+14 * Fix build on 5-currentmaho2004-03-071-8/+2 * BROKEN on sparc64: Does not compile (needs -fPIC)kris2004-03-071-0/+4 * Unbreak by fixing bug introduced in rev 1.45, which attempted tonectar2004-03-061-1/+2 * Add ja-mailman , japanized mailman which is a mailing list managernork2004-03-053-0/+29 * Update to 20040305.nork2004-03-052-2/+5 * Enable menubar fontset support. Uses the patches alrady used inlinimon2004-03-044-4/+50 * Fix build with a SelF-eXtracting archive in CD-ROM.nork2004-03-043-12/+18 * Remove japanese/vfxdvi{118,240,300,360,400,600}.nork2004-03-0418-2225/+0 * Unbreak build by fixing varargs problem on gcc3.3.linimon2004-03-045-48/+92 * Utilize PORTDOCS and DOCSDIR.nork2004-03-0452-140/+159 * Update to 1.7 alpha.nork2004-03-033-4/+11 * Update to 0.3.1.nobutaka2004-03-023-3/+17 * Update to 5100.nobutaka2004-03-023-9/+8 * Fix build with ruby 1.8.knu2004-03-021-0/+19 * Change MAINTAINERship to submitter.nork2004-03-012-2/+2 * o Add new vfontcap.freetype and vfontcap.vflib file (obtained fromnork2004-03-018-278/+338 * o Update to 1.5.6.nork2004-03-014-22/+11 * - Hand over maintainership to submitterpav2004-02-292-2/+2 * - Fix rmdir linepav2004-02-292-2/+2 * Add stardict2-dict-ja, a english -> japanese, japanese -> englishpav2004-02-299-0/+85 * - Update to 22.40y1.1.21pav2004-02-298-28/+226 * - Update to version 0.3.4krion2004-02-293-6/+11 * - Update checksum. Affected archive contains TeX font files, so I don'tpav2004-02-292-12/+11 * - Assign maintainership to submitterkrion2004-02-278-8/+8 * BROKEN on !i386: Does not compilekris2004-02-251-1/+7 * BROKEN on !i386 and !sparc64: Does not compilekris2004-02-241-1/+7 * Create DOCSDIR before install the document.nobutaka2004-02-231-1/+2 * BROKEN on !i386: Does not compilekris2004-02-231-1/+7 * BROKEN on !i386: Does not buildkris2004-02-232-2/+14 * BROKEN: Checksum mismatchkris2004-02-232-0/+4 * Add WITH_DBSKKD knob.nobutaka2004-02-221-0/+4 * 1. Change the install location of elisp files.nobutaka2004-02-223-2/+13 * BROKEN: Checksum mismatchkris2004-02-221-0/+2 * BROKEN on 4.x: does not compilekris2004-02-221-0/+4 * BROKEN: Checksum mismatchkris2004-02-221-0/+2 * BROKEN: Checksum mismatchkris2004-02-221-0/+2 * Don't use perl to generate files that we already have (timestamps b0rk3dnectar2004-02-221-4/+20 * Update to 4.0.7: bugfix in handling roman-kana conversion in fence-mode.linimon2004-02-212-3/+3 * Update to 2.06.4: see CHANGES.jis and ChangeLog for details. Also:linimon2004-02-212-3/+8 * Remove BROKEN tag; this port now installs correctly.kris2004-02-182-8/+0 * Update to 20040209 version.kuriyama2004-02-182-3/+5 * BROKEN on 5.x: configure failskris2004-02-181-1/+7 * Mark as deprecated: either fails to fetch, and has done so for some time;linimon2004-02-171-0/+2 * BROKEN: Inconsistent dependencies (linux_base 7.x and 8.x)kris2004-02-171-0/+2 * Typo fix.max2004-02-173-6/+6 * BROKEN: Checksum mismatchkris2004-02-171-0/+2 * Fix the bug of a make rule in the install-links target that installsokazaki2004-02-161-2/+2 * RcNG'ize the startup script (and bump the port revision).max2004-02-1612-102/+168 * Update to version 4.0.6: revise handling of Dakuten and Han-dakuten inlinimon2004-02-132-2/+3 * Add pre-install message about a possibly desireable compile optionlinimon2004-02-132-0/+16 * - Use LATEST_LINKkrion2004-02-131-0/+2 * Update to 3.7p1max2004-02-1312-42/+69 * Upgrade to 2.04.max2004-02-135-9/+9 * Utilize USE_ICONV.okazaki2004-02-111-14/+20 * Sync with editors/emacs21:sumikawa2004-02-114-2/+184 * Update to release 0.21. See ChangeLog for details (linimon2004-02-114-8/+27 * SIZEify.matusita2004-02-112-0/+3 * Update to JNetHack-3.4.3-0.1.knu2004-02-098-62/+45 * BROKEN on 5.x: does not installkris2004-02-092-0/+8 * BROKEN on 5.x: Does not compilekris2004-02-091-0/+4 * Update to 0.2.8.nobutaka2004-02-085-33/+15 * Update to 0.17.nobutaka2004-02-083-4/+5 * Use PLIST_FILES (bento-tested, marcus-reviewed).trevor2004-02-0624-13/+13 * Use PLIST_FILES.trevor2004-02-0612-6/+6 * BROKEN on 5.x: Does not compilekris2004-02-051-1/+7 * Add NO_{PACKAGE,CDROM} because Motoya Co.,Ltd does not permitnork2004-02-051-1/+3 * Update to KDE 3.2.0lofi2004-02-0510-18/+26 * Bump PORTREVISION on all ports that depend on gettext to aid with upgrading.marcus2004-02-0471-23/+71 * Add USE_GETTEXT and bump PORTREVISION.marcus2004-02-049-20/+20 * - Update MASTER_SITESkrion2004-02-011-1/+2 * - Mark NOT_FOR_ARCHS for AMD64krion2004-02-011-1/+3 * - Mark BROKEN: Japanese patch not yet releasedkrion2004-02-011-0/+2 * patch fromtrevor2004-02-011-3/+1 * Fixed the bug password cannot be changed from a client.sumikawa2004-01-302-1/+27 * The linux-atk port was repo-copied into the accessibility category.trevor2004-01-301-1/+1 * Upgrade JLP to 0.2.1.sumikawa2004-01-303-2/+4 * SIZEify.trevor2004-01-2936-0/+57 * Add size data.trevor2004-01-281-0/+12 * Add size data.trevor2004-01-281-0/+1 * PR:maho2004-01-262-7/+38 * Now gettext 0.12.1 is gettext-old.trevor2004-01-249-11/+11 * - Update to 1.17krion2004-01-232-4/+4 * Use LS macro.trevor2004-01-231-1/+1 * - fix PKGORIGINeik2004-01-232-0/+4 * Update to 1.6.nork2004-01-233-2/+6 * Use the SORT macro from bsd.port.mk.trevor2004-01-225-7/+10 * - Change maintainer's emailkrion2004-01-2211-11/+11 * Reverse the MANLANG arguments to workaround a bug in make(1). This ismarcus2004-01-203-3/+3 * Update to 0.19arved2004-01-192-2/+2 * Unbreak for 501000maho2004-01-191-1/+1 * Update to 0.3.3.nork2004-01-182-7/+6 * Fix build. [1]nobutaka2004-01-184-29/+33 * - Fix buildkrion2004-01-161-2/+2 * Add a ebview-gtk2 0.3.1, which is a gtk2 based toolnork2004-01-168-109/+36 * - update to 2.1.3clement2004-01-164-4/+4 * o Remove unnecessary URL. [1]nork2004-01-161-2/+2 * Add RESTRICTED.nork2004-01-161-0/+2 * Add a motoya-ttfonts, Free Japanese TrueType fonts named 'MOTOYAnork2004-01-169-0/+124 * - fix *squirrelmail ports.clement2004-01-131-1/+1 * Update to 2004-01-11 snapshot of w3m 0.4.2.nobutaka2004-01-122-1/+5 * update to 0.32yoichi2004-01-122-2/+2 * I forgot to remove this obsolete patch with the upgrade to 0.9.nectar2004-01-111-12/+0 * Update to 0.2.4.nobutaka2004-01-112-2/+2 * Make this port compile clean when specifying another ${PREFIX}.petef2004-01-102-2/+14 * Update 0.8 -> 0.9nectar2004-01-084-8/+16 * New port: japanese/multiskkservedwin2004-01-086-0/+96 * Update to 4.0.5: adds keybindings; minor bugfixes.linimon2004-01-072-2/+2 * Unbreak by making this port a non-slave port and going back to 1.0.1.knu2004-01-068-17/+1029 * - Update to 200401pav2004-01-032-5/+3 * Update to 200401 version.yoichi2004-01-032-4/+4 * Update to 0.2.2.nobutaka2004-01-016-11/+33 * New port: japanese/wikickeredwin2003-12-2910-0/+360 * New Port: japanese/xlockmore - Xlockmore which supports the Japanese language.edwin2003-12-292-0/+18 * Fix build on -current. (Note: the maintainer/submitter claimed that itlinimon2003-12-291-6/+10 * Resurrect previous commit, pre-build to post-patch.nork2003-12-272-2/+2 * o Add CONFLICTS. [1]nork2003-12-272-2/+6 * Per bento logs, mark broken on recent versions of 5.x due to installlinimon2003-12-231-1/+5 * Mark as broken on 5.x due to gcc3.3 multiline string handling.linimon2003-12-221-0/+12 * - Support USE_LIBTOOL properlykrion2003-12-225-11/+30 * - Use canonical form (ports@FreeBSD.org) in MAINTAINER linesergei2003-12-216-6/+6 * Update ports: japanese/yc.eledwin2003-12-202-2/+2 * Minor update to 1.16, mainly fixes fetch.linimon2003-12-202-4/+4 * Chase mastersite and renaming of distfile.linimon2003-12-202-6/+3 * Mark as broken on 5.x due to gcc3.3's stricter handling of multilinelinimon2003-12-201-1/+7 * Update to latest patch. Adds Canna 3.7 Wide character API adaptation.linimon2003-12-204-4/+4 * Remove the OpenSSL distinfo entry.marcus2003-12-181-1/+0 * Update to 1.6b-langjajp-tm0.1(chase mozilla 1.6beta).nork2003-12-182-3/+3 * o Update to 20031208.kuriyama2003-12-164-10/+26 * - Update to 0.1.5krion2003-12-152-2/+2 * * Fix pkg-message generation on read-only filesystem.kuriyama2003-12-131-0/+1 * s/rpm2cpio/rpm2cpio.pl/ after the recent update of archivers/rpm2cpio (thenetchild2003-12-121-2/+2 * Update to 0.2.0.nobutaka2003-12-117-41/+27 * fix lockup problem on large-numbered anchor.sf2003-12-102-0/+15 * Update to 0.1.7.nobutaka2003-12-083-3/+4