-/* modest-tny-stream-gtkhtml.c */
+/* Copyright (c) 2006, Nokia Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Nokia Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
-/* insert (c)/licensing information) */
+/* modest-tny-stream-gtkhtml.c */
#include "modest-tny-stream-gtkhtml.h"
#include <gtkhtml/gtkhtml-stream.h>
typedef struct _ModestTnyStreamGtkhtmlPrivate ModestTnyStreamGtkhtmlPrivate;
struct _ModestTnyStreamGtkhtmlPrivate {
- GtkHTML *gtkhtml;
GtkHTMLStream *stream;
};
#define MODEST_TNY_STREAM_GTKHTML_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \
{
ModestTnyStreamGtkhtmlPrivate *priv;
priv = MODEST_TNY_STREAM_GTKHTML_GET_PRIVATE(obj);
-
- priv->gtkhtml = NULL;
+
priv->stream = NULL;
}
ModestTnyStreamGtkhtmlPrivate *priv;
priv = MODEST_TNY_STREAM_GTKHTML_GET_PRIVATE(obj);
- priv->gtkhtml = NULL;
priv->stream = NULL;
}
GObject*
-modest_tny_stream_gtkhtml_new (GtkHTML *gtkhtml)
+modest_tny_stream_gtkhtml_new (GtkHTMLStream *stream)
{
GObject *obj;
ModestTnyStreamGtkhtmlPrivate *priv;
-
- g_return_val_if_fail (gtkhtml, NULL);
obj = G_OBJECT(g_object_new(MODEST_TYPE_TNY_STREAM_GTKHTML, NULL));
priv = MODEST_TNY_STREAM_GTKHTML_GET_PRIVATE(obj);
- priv->gtkhtml = gtkhtml;
+ g_return_val_if_fail (stream, NULL);
+
+ priv->stream = stream;
+
return obj;
}
static ssize_t
gtkhtml_read (TnyStreamIface *self, char *buffer, size_t n)
{
- g_warning (__FUNCTION__);
return -1; /* we cannot read */
}
{
ModestTnyStreamGtkhtmlPrivate *priv;
- g_return_val_if_fail (self, 0);
-
priv = MODEST_TNY_STREAM_GTKHTML_GET_PRIVATE(self);
- if (!priv->stream)
- priv->stream = gtk_html_begin (GTK_HTML(priv->gtkhtml));
+
+ if (!priv->stream) {
+ g_warning ("cannot write to closed stream");
+ return 0;
+ }
+
+ if (n == 0 || !buffer)
+ return 0;
gtk_html_stream_write (priv->stream, buffer, n);
-
return n; /* hmmm */
}
static gint
gtkhtml_flush (TnyStreamIface *self)
{
- ModestTnyStreamGtkhtmlPrivate *priv;
- g_return_val_if_fail (self, 0);
- priv = MODEST_TNY_STREAM_GTKHTML_GET_PRIVATE(self);
-
- gtk_html_flush (GTK_HTML(priv->gtkhtml));
return 0;
}
static gboolean
gtkhtml_eos (TnyStreamIface *self)
{
- g_warning (__FUNCTION__);
return TRUE;
}
static gint
gtkhtml_reset (TnyStreamIface *self)
{
- ModestTnyStreamGtkhtmlPrivate *priv;
- g_return_val_if_fail (self, 0);
- priv = MODEST_TNY_STREAM_GTKHTML_GET_PRIVATE(self);
-
- if (priv->stream) {
- gtk_html_end (priv->gtkhtml, priv->stream, GTK_HTML_STREAM_OK);
- priv->stream = NULL;
- }
-
return 0;
}
static ssize_t
gtkhtml_write_to_stream (TnyStreamIface *self, TnyStreamIface *output)
{
- g_warning (__FUNCTION__);
return 0;
}