aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Loper <mloper@src.gnome.org>2000-02-09 16:36:29 +0800
committerMatthew Loper <mloper@src.gnome.org>2000-02-09 16:36:29 +0800
commita56ab5213877f040f31db0696a1a60bd066772ed (patch)
tree47c5f75549e2ec794bbd6c437a9032fccea0d65b
parentca082de77aec8542e913e1ce374dd849f51a4a27 (diff)
downloadgsoc2013-evolution-a56ab5213877f040f31db0696a1a60bd066772ed.tar
gsoc2013-evolution-a56ab5213877f040f31db0696a1a60bd066772ed.tar.gz
gsoc2013-evolution-a56ab5213877f040f31db0696a1a60bd066772ed.tar.bz2
gsoc2013-evolution-a56ab5213877f040f31db0696a1a60bd066772ed.tar.lz
gsoc2013-evolution-a56ab5213877f040f31db0696a1a60bd066772ed.tar.xz
gsoc2013-evolution-a56ab5213877f040f31db0696a1a60bd066772ed.tar.zst
gsoc2013-evolution-a56ab5213877f040f31db0696a1a60bd066772ed.zip
New file; shows a message in tree format, where multipart's have multiple
* tests/ui-tests/message-browser.c: New file; shows a message in tree format, where multipart's have multiple leaves. * camel/camel-formatter.c: Changed references from 'multipart/alternate' to 'multipart/alternative'. svn path=/trunk/; revision=1700
-rw-r--r--ChangeLog6
-rw-r--r--camel/camel-formatter.c46
-rw-r--r--tests/ui-tests/Makefile.am10
-rw-r--r--tests/ui-tests/message-browser.c155
4 files changed, 194 insertions, 23 deletions
diff --git a/ChangeLog b/ChangeLog
index 69ac056f74..4a2e0d1c18 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2000-02-08 Matt Loper <matt.loper@splashtech.com>
+ * tests/ui-tests/message-browser.c: New file; shows a message in
+ tree format, where multipart's have multiple leaves.
+
+ * camel/camel-formatter.c: Changed references from
+ 'multipart/alternate' to 'multipart/alternative'.
+
* 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
diff --git a/camel/camel-formatter.c b/camel/camel-formatter.c
index 91a47af01e..49776243ff 100644
--- a/camel/camel-formatter.c
+++ b/camel/camel-formatter.c
@@ -49,24 +49,24 @@
* 'call_handler_function()' to continue the process recursively.
*/
-static void handle_text_plain (CamelFormatter *formatter,
- CamelDataWrapper *wrapper);
-static void handle_text_html (CamelFormatter *formatter,
- CamelDataWrapper *wrapper);
-static void handle_image (CamelFormatter *formatter,
- CamelDataWrapper *wrapper);
-static void handle_vcard (CamelFormatter *formatter,
- CamelDataWrapper *wrapper);
-static void handle_mime_message (CamelFormatter *formatter,
- CamelDataWrapper *wrapper);
-static void handle_multipart_mixed (CamelFormatter *formatter,
- CamelDataWrapper *wrapper);
-static void handle_multipart_related (CamelFormatter *formatter,
- CamelDataWrapper *wrapper);
-static void handle_multipart_alternate(CamelFormatter *formatter,
- CamelDataWrapper *wrapper);
-static void handle_unknown_type (CamelFormatter *formatter,
- CamelDataWrapper *wrapper);
+static void handle_text_plain (CamelFormatter *formatter,
+ CamelDataWrapper *wrapper);
+static void handle_text_html (CamelFormatter *formatter,
+ CamelDataWrapper *wrapper);
+static void handle_image (CamelFormatter *formatter,
+ CamelDataWrapper *wrapper);
+static void handle_vcard (CamelFormatter *formatter,
+ CamelDataWrapper *wrapper);
+static void handle_mime_message (CamelFormatter *formatter,
+ CamelDataWrapper *wrapper);
+static void handle_multipart_mixed (CamelFormatter *formatter,
+ CamelDataWrapper *wrapper);
+static void handle_multipart_related (CamelFormatter *formatter,
+ CamelDataWrapper *wrapper);
+static void handle_multipart_alternative(CamelFormatter *formatter,
+ CamelDataWrapper *wrapper);
+static void handle_unknown_type (CamelFormatter *formatter,
+ CamelDataWrapper *wrapper);
/* encodes some characters into their 'escaped' version;
* so '<' turns into '&lt;', and '"' turns into '&quot;' */
@@ -743,7 +743,7 @@ handle_multipart_related (CamelFormatter *formatter,
}
/*
- The current policy for multipart/alternate is this:
+ The current policy for multipart/alternative is this:
if (we find a text/html body part)
we print it
@@ -753,13 +753,13 @@ handle_multipart_related (CamelFormatter *formatter,
we print nothing
*/
static void
-handle_multipart_alternate (CamelFormatter *formatter,
+handle_multipart_alternative (CamelFormatter *formatter,
CamelDataWrapper *wrapper)
{
CamelMultipart* multipart = CAMEL_MULTIPART (wrapper);
CamelMimePart* mime_part;
- debug ("handle_multipart_alternate: entered\n");
+ debug ("handle_multipart_alternative: entered\n");
mime_part = find_preferred_displayable_body_part_in_multipart_alternative(
multipart);
@@ -773,7 +773,7 @@ handle_multipart_alternate (CamelFormatter *formatter,
MIME_TYPE_MAIN (mime_part));
}
- debug ("handle_multipart_alternate: exiting\n");
+ debug ("handle_multipart_alternative: exiting\n");
}
static void
@@ -834,7 +834,7 @@ camel_formatter_class_init (CamelFormatterClass *camel_formatter_class)
/* hook up mime types to functions that handle them */
ADD_HANDLER ("text/plain", handle_text_plain);
ADD_HANDLER ("text/html", handle_text_html);
- ADD_HANDLER ("multipart/alternate", handle_multipart_alternate);
+ ADD_HANDLER ("multipart/alternative", handle_multipart_alternative);
ADD_HANDLER ("multipart/related", handle_multipart_related);
ADD_HANDLER ("multipart/mixed", handle_multipart_mixed);
ADD_HANDLER ("message/rfc822", handle_mime_message);
diff --git a/tests/ui-tests/Makefile.am b/tests/ui-tests/Makefile.am
index 7c26399bbb..34c05f3115 100644
--- a/tests/ui-tests/Makefile.am
+++ b/tests/ui-tests/Makefile.am
@@ -14,3 +14,13 @@ LDADD = \
$(INTLLIBS) \
$(EXTRA_GNOME_LIBS) \
$(PTHREAD_LIB)
+
+message_browser_LDADD = \
+ $(top_builddir)/camel/libcamel.la \
+ $(INTLLIBS) \
+ $(EXTRA_GNOME_LIBS) \
+ $(PTHREAD_LIB) \
+ $(EXTRA_GNOME_LIBS_THREADS)
+
+noinst_PROGRAMS = \
+ message-browser
diff --git a/tests/ui-tests/message-browser.c b/tests/ui-tests/message-browser.c
new file mode 100644
index 0000000000..b0e20288df
--- /dev/null
+++ b/tests/ui-tests/message-browser.c
@@ -0,0 +1,155 @@
+/*--------------------------------*-C-*---------------------------------*
+ *
+ * Copyright 2000, Matt Loper <matt@helixcode.com>.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
+ *
+ *----------------------------------------------------------------------*/
+
+#include <gnome.h>
+#include <camel/camel.h>
+#include <camel/camel-mime-message.h>
+#include <camel/camel-stream.h>
+#include <camel/camel-stream-fs.h>
+#include <camel/gmime-utils.h>
+
+static void
+handle_tree_item (CamelDataWrapper* object, GtkWidget* tree_ctrl)
+{
+ GtkWidget* tree_item;
+ gchar* label = gmime_content_field_get_mime_type (object->mime_type);
+
+ tree_item = gtk_tree_item_new_with_label (label);
+ gtk_tree_append (GTK_TREE (tree_ctrl), tree_item);
+
+ if (CAMEL_IS_MULTIPART (object))
+ {
+ CamelMultipart* multipart = CAMEL_MULTIPART (object);
+ GtkWidget* subtree;
+ int max_multiparts = camel_multipart_get_number (multipart);
+ int i;
+
+ g_print ("found a multipart w/ %d parts\n", max_multiparts);
+
+ if (max_multiparts > 0) {
+ subtree = gtk_tree_new();
+ gtk_tree_item_set_subtree (GTK_TREE_ITEM(tree_item),
+ GTK_WIDGET (subtree));
+ }
+
+ for (i = 0; i < max_multiparts; i++) {
+ CamelMimeBodyPart* body_part =
+ camel_multipart_get_part (multipart, i);
+
+ g_print ("handling part %d\n", i);
+ handle_tree_item (CAMEL_DATA_WRAPPER (body_part),
+ tree_item);
+ }
+ }
+}
+
+
+GtkWidget*
+get_message_tree_ctrl (CamelMimeMessage* message)
+{
+ GtkWidget* tree_ctrl = gtk_tree_new ();
+ CamelDataWrapper* message_contents =
+ camel_medium_get_content_object (CAMEL_MEDIUM (message));
+ int i;
+/*
+ * Set up the scroll window
+ */
+ GtkWidget* scroll_wnd = gtk_scrolled_window_new (NULL,NULL);
+ gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW(scroll_wnd),
+ tree_ctrl);
+ gtk_widget_set_usize (scroll_wnd, 150, 200);
+
+ handle_tree_item (message_contents, tree_ctrl);
+
+#if 0
+ for (i = 0; i < 10; i++)
+ {
+ GtkWidget* tree_item =
+ gtk_tree_item_new_with_label ("hello");
+ GtkWidget* subtree = gtk_tree_new();
+ gtk_tree_append (GTK_TREE (tree_ctrl), tree_item);
+ gtk_tree_item_set_subtree (tree_item, subtree);
+ }
+#endif
+
+ return scroll_wnd;
+}
+
+static CamelMimeMessage*
+filename_to_camel_msg (gchar* filename)
+{
+ CamelMimeMessage* message;
+ CamelStream* input_stream;
+
+ camel_init();
+
+ message = camel_mime_message_new_with_session (
+ (CamelSession *)NULL);
+ input_stream = camel_stream_fs_new_with_name (
+ filename, CAMEL_STREAM_FS_READ);
+ camel_data_wrapper_construct_from_stream (
+ CAMEL_DATA_WRAPPER (message), input_stream);
+
+ camel_stream_close (input_stream);
+
+ return message;
+}
+
+
+static void
+print_usage_and_quit()
+{
+ g_print ("Usage: message-browser [FILENAME]\n\n");
+ g_print ("\tWhere FILENAME is the name of a message\n");
+ exit (0);
+}
+
+
+int
+main (int argc, char *argv[])
+{
+ GtkWidget* app;
+ CamelMimeMessage* message;
+
+ if (argc != 2)
+ print_usage_and_quit();
+
+ gnome_init ("MessageBrowser", "1.0", argc, argv);
+
+ app = gnome_app_new ("Message Browser Test", NULL);
+
+ message = filename_to_camel_msg (argv[1]);
+
+#if 0
+ if (!message) {
+ g_print ("Couldn't open message \"%s\", bailing...\n",
+ argv[1]);
+ exit (0);
+ }
+#endif
+ gnome_app_set_contents (GNOME_APP (app),
+ get_message_tree_ctrl (message));
+
+ gtk_widget_show_all (app);
+ gtk_signal_connect (GTK_OBJECT (app), "destroy",
+ GTK_SIGNAL_FUNC(gtk_main_quit),
+ &app);
+ gtk_main();
+}