1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
6 * Bertrand Guiheneuf <bertrand@helixcode.com>
8 * Copyright 1999, 2000 HelixCode (http://www.helixcode.com) .
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation; either version 2 of the
13 * License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
29 #include "camel-seekable-stream.h"
30 #include "camel-log.h"
32 static CamelStreamClass *parent_class=NULL;
35 /* Returns the class for a CamelSeekableStream */
36 #define CSS_CLASS(so) CAMEL_SEEKABLE_STREAM_CLASS (GTK_OBJECT(so)->klass)
38 static gint _seek (CamelSeekableStream *stream, gint offset, CamelStreamSeekPolicy policy);
42 camel_seekable_stream_class_init (CamelSeekableStreamClass *camel_seekable_stream_class)
44 CamelStreamClass *camel_stream_class = CAMEL_STREAM_CLASS (camel_seekable_stream_class);
45 GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (camel_seekable_stream_class);
47 parent_class = gtk_type_class (camel_stream_get_type ());
49 camel_seekable_stream_class->seek = _seek;
54 camel_seekable_stream_get_type (void)
56 static GtkType camel_seekable_stream_type = 0;
58 if (!camel_seekable_stream_type) {
59 GtkTypeInfo camel_seekable_stream_info =
61 "CamelSeekableStream",
62 sizeof (CamelSeekableStream),
63 sizeof (CamelSeekableStreamClass),
64 (GtkClassInitFunc) camel_seekable_stream_class_init,
65 (GtkObjectInitFunc) NULL,
66 /* reserved_1 */ NULL,
67 /* reserved_2 */ NULL,
68 (GtkClassInitFunc) NULL,
71 camel_seekable_stream_type = gtk_type_unique (camel_stream_get_type (), &camel_seekable_stream_info);
74 return camel_seekable_stream_type;
81 _seek (CamelSeekableStream *stream,
83 CamelStreamSeekPolicy policy)
92 * @stream: a CamelStream object.
93 * @offset: offset value
94 * @policy: what to do with the offset
98 * Return value: new position, -1 if operation failed.
101 camel_seekable_stream_seek (CamelSeekableStream *stream,
103 CamelStreamSeekPolicy policy)
105 return CSS_CLASS (stream)->seek (stream, offset, policy);
112 * camel_seekable_stream_get_current_position: get the position of a stream
113 * @stream: seekable stream object
115 * Get the current position of a seekable stream.
117 * Return value: the position.
120 camel_seekable_stream_get_current_position (CamelSeekableStream *stream)
122 return stream->cur_pos;