1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 * Authors: Jeffrey Stedfast <fejj@ximian.com>
5 * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27 #include "camel-mime-filter-save.h"
28 #include "camel-stream-mem.h"
30 #define CAMEL_MIME_FILTER_SAVE_GET_PRIVATE(obj) \
31 (G_TYPE_INSTANCE_GET_PRIVATE \
32 ((obj), CAMEL_TYPE_MIME_FILTER_SAVE, CamelMimeFilterSavePrivate))
34 struct _CamelMimeFilterSavePrivate {
38 G_DEFINE_TYPE (CamelMimeFilterSave, camel_mime_filter_save, CAMEL_TYPE_MIME_FILTER)
41 mime_filter_save_filter (CamelMimeFilter *mime_filter,
49 CamelMimeFilterSavePrivate *priv;
51 priv = CAMEL_MIME_FILTER_SAVE_GET_PRIVATE (mime_filter);
53 if (priv->stream != NULL)
54 camel_stream_write (priv->stream, in, len, NULL, NULL);
58 *outprespace = mime_filter->outpre;
62 mime_filter_save_complete (CamelMimeFilter *mime_filter,
71 mime_filter_save_filter (
72 mime_filter, in, len, prespace,
73 out, outlen, outprespace);
77 mime_filter_save_reset (CamelMimeFilter *mime_filter)
83 camel_mime_filter_save_class_init (CamelMimeFilterSaveClass *class)
85 CamelMimeFilterClass *mime_filter_class;
87 g_type_class_add_private (class, sizeof (CamelMimeFilterSavePrivate));
89 mime_filter_class = CAMEL_MIME_FILTER_CLASS (class);
90 mime_filter_class->filter = mime_filter_save_filter;
91 mime_filter_class->complete = mime_filter_save_complete;
92 mime_filter_class->reset = mime_filter_save_reset;
96 camel_mime_filter_save_init (CamelMimeFilterSave *filter)
98 filter->priv = CAMEL_MIME_FILTER_SAVE_GET_PRIVATE (filter);
102 * camel_mime_filter_save_new:
103 * @stream: a #CamelStream object
105 * Create a new #CamelMimeFilterSave filter object that will save a
106 * copy of all filtered data to @stream.
108 * Returns: a new #CamelMimeFilterSave object
111 camel_mime_filter_save_new (CamelStream *stream)
113 CamelMimeFilter *filter;
114 CamelMimeFilterSavePrivate *priv;
117 g_return_val_if_fail (CAMEL_IS_STREAM (stream), NULL);
119 filter = g_object_new (CAMEL_TYPE_MIME_FILTER_SAVE, NULL);
120 priv = CAMEL_MIME_FILTER_SAVE_GET_PRIVATE (filter);
123 priv->stream = g_object_ref (stream);
125 priv->stream = camel_stream_mem_new ();