X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fmodest-tny-stream-gtkhtml.c;h=6303a0f8fe89de131af38c6ec6411155de47a916;hp=3f67145e8d6cd7c1c08184fedcce5d988098d3a8;hb=64d81bebf80d459f9800395a17b4ce8fa3099e2d;hpb=c3319565e84fd1e46aa6b04f2e544cb02c6e61e0 diff --git a/src/modest-tny-stream-gtkhtml.c b/src/modest-tny-stream-gtkhtml.c index 3f67145..6303a0f 100644 --- a/src/modest-tny-stream-gtkhtml.c +++ b/src/modest-tny-stream-gtkhtml.c @@ -1,6 +1,34 @@ -/* 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 @@ -22,7 +50,6 @@ enum { typedef struct _ModestTnyStreamGtkhtmlPrivate ModestTnyStreamGtkhtmlPrivate; struct _ModestTnyStreamGtkhtmlPrivate { - GtkHTML *gtkhtml; GtkHTMLStream *stream; }; #define MODEST_TNY_STREAM_GTKHTML_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \ @@ -85,8 +112,7 @@ modest_tny_stream_gtkhtml_init (ModestTnyStreamGtkhtml *obj) { ModestTnyStreamGtkhtmlPrivate *priv; priv = MODEST_TNY_STREAM_GTKHTML_GET_PRIVATE(obj); - - priv->gtkhtml = NULL; + priv->stream = NULL; } @@ -96,22 +122,22 @@ modest_tny_stream_gtkhtml_finalize (GObject *obj) 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; } @@ -122,7 +148,6 @@ modest_tny_stream_gtkhtml_new (GtkHTML *gtkhtml) static ssize_t gtkhtml_read (TnyStreamIface *self, char *buffer, size_t n) { - g_warning (__FUNCTION__); return -1; /* we cannot read */ } @@ -132,14 +157,17 @@ gtkhtml_write (TnyStreamIface *self, const char *buffer, size_t n) { 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 */ } @@ -147,11 +175,6 @@ gtkhtml_write (TnyStreamIface *self, const char *buffer, size_t n) 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; } @@ -173,7 +196,6 @@ gtkhtml_close (TnyStreamIface *self) static gboolean gtkhtml_eos (TnyStreamIface *self) { - g_warning (__FUNCTION__); return TRUE; } @@ -182,15 +204,6 @@ gtkhtml_eos (TnyStreamIface *self) 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; } @@ -198,7 +211,6 @@ gtkhtml_reset (TnyStreamIface *self) static ssize_t gtkhtml_write_to_stream (TnyStreamIface *self, TnyStreamIface *output) { - g_warning (__FUNCTION__); return 0; }