aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--camel/camel-formatter.c56
-rw-r--r--camel/camel-formatter.h5
3 files changed, 33 insertions, 36 deletions
diff --git a/ChangeLog b/ChangeLog
index 4d10a1afe5..ac26198c90 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2000-01-21 Matt Loper <matt@helixcode.com>
+
+ * camel/camel-formatter.c (camel_formatter_make_html): added a
+ CamelMimeMessage as a param to this function, and removed it as a
+ member of the object.
+
2000-01-21 Federico Mena Quintero <federico@helixcode.com>
* configure.in (AC_OUTPUT): Added libversit/Makefile and
@@ -5,7 +11,7 @@
* Makefile.am (SUBDIRS): Added libversit and calendar.
-2000-01-20 Matt Loper <matt.loper@splashtech.com>
+2000-01-20 Matt Loper <matt@helixcode.com>
* camel/camel-formatter.c, camel/camel-formatter.h: New
files. You'll be able to use a CamelFormatter to get
diff --git a/camel/camel-formatter.c b/camel/camel-formatter.c
index a7d72e0b04..f1347c7b0f 100644
--- a/camel/camel-formatter.c
+++ b/camel/camel-formatter.c
@@ -20,7 +20,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
*
- *
*----------------------------------------------------------------------*/
#include <config.h>
@@ -30,7 +29,7 @@ static GtkObjectClass *parent_class=NULL;
static void _finalize (GtkObject *object);
struct _CamelFormatterPrivate {
- CamelMimeMessage *msg;
+ /* nothing here yet */
};
static void
@@ -53,58 +52,51 @@ write_recipients_to_stream (const gchar *recipient_type,
gchar *s;
g_assert (recipient_type && stream_out);
- s = g_strdup_printf ("<b>%s: <br>\n", recipient_type);
+ /* Write "To:", "CC:", or "BCC:" to the stream */
+ s = g_strdup_printf ("<b>%s:</b> ", recipient_type);
camel_stream_write_string (stream_out, s);
g_free (s);
+ /* Write out each recipient of 'recipient_type' to the stream */
while (recipients) {
camel_stream_write_string (stream_out, recipients->data);
recipients = recipients->next;
if (recipients)
camel_stream_write_string (stream_out, "; ");
}
- camel_stream_write_string (stream_out, "</b><br>\n");
+ camel_stream_write_string (stream_out, "<br><br>\n");
}
-void
-set_mime_message (CamelFormatter* cfm, CamelMimeMessage* msg)
+CamelFormatter*
+camel_formatter_new ()
{
- g_assert(cfm && msg);
- cfm->priv->msg = msg;
+ return (gtk_type_new (CAMEL_FORMATTER_TYPE));
}
-
/**
- * camel_formatter_to_html: write data content in a byte stream
- * @data_wrapper: the camel formatter object
- * @stream_out byte stream where data will be written
- *
- * This method must be overriden by subclasses
- * Data must be written in the bytes stream
- * in a architecture independant fashion.
- * If data is a standard data (for example an jpg image)
- * it must be serialized in the strea exactly as it
- * would be saved on disk. A simple dump of the stream in
- * a file should be sufficient for the data to be
- * re-read by a foreign application.
- *
+ * camel_formatter_make_html:
+ * @formatter: the camel formatter object
+ * @stream_out: byte stream where data will be written
+ *
+ * Writes a CamelMimeMessage out, as html, into a stream passed in as
+ * a parameter.
**/
void
-camel_formatter_make_html (CamelFormatter *mhs,
+camel_formatter_make_html (CamelFormatter* formatter,
+ CamelMimeMessage* mime_message,
CamelStream* stream_out)
{
gchar *s = NULL;
GList *recipients = NULL;
- CamelMimeMessage *mime_message;
- g_assert (mhs && stream_out);
- g_assert (mhs->priv->msg);
+ g_assert (formatter && mime_message && stream_out);
- mime_message = mhs->priv->msg;
-
camel_stream_write_string (stream_out, "Content type: text/html\n");
-
+
+ /* A few fields will probably be available from the mime_message;
+ for each one that's available, write it to the output stream
+ with a helper function, 'write_field_to_stream'. */
if ((s = (gchar*)camel_mime_message_get_subject (mime_message))) {
write_field_to_stream ("Subject: ", s, stream_out);
}
@@ -155,7 +147,7 @@ static void
camel_formatter_init (gpointer object, gpointer klass)
{
CamelFormatter* cmf = CAMEL_FORMATTER (object);
- cmf->priv->msg = NULL;
+ cmf->priv = g_new (CamelFormatterPrivate, 1);
}
@@ -189,9 +181,9 @@ camel_formatter_get_type (void)
static void
_finalize (GtkObject *object)
{
- CamelFormatter *mhs = CAMEL_FORMATTER (object);
+ CamelFormatter *formatter = CAMEL_FORMATTER (object);
- g_free (mhs->priv);
+ g_free (formatter->priv);
GTK_OBJECT_CLASS (parent_class)->finalize (object);
}
diff --git a/camel/camel-formatter.h b/camel/camel-formatter.h
index d2ed5bd12c..16942fc5ce 100644
--- a/camel/camel-formatter.h
+++ b/camel/camel-formatter.h
@@ -50,13 +50,12 @@ typedef struct {
GtkType camel_formatter_get_type (void);
/* Public functions */
-CamelFormatter* camel_formatter_new (CamelMimeMessage* msg);
-
-void set_mime_message (CamelFormatter* cfm, CamelMimeMessage* msg);
+CamelFormatter* camel_formatter_new ();
/* The main job of CamelFormatter is to take a mime message, and
produce html from it. */
void camel_formatter_make_html (CamelFormatter* cmf,
+ CamelMimeMessage *msg,
CamelStream* stream_out);
#endif // CAMEL_FORMATTER_H