aboutsummaryrefslogtreecommitdiffstats
path: root/camel
diff options
context:
space:
mode:
authorbertrand <bertrand@helixcode.com>2000-01-25 09:09:56 +0800
committerBertrand Guiheneuf <bertrand@src.gnome.org>2000-01-25 09:09:56 +0800
commit50e5c22f0f5c4083ceee623b5bc02a6a7fc4f18c (patch)
tree591b540959a558b6c908e7bcc671c0906e42a2a6 /camel
parent7dded29a632d26b8ed2c279004dd5fe39014de27 (diff)
downloadgsoc2013-evolution-50e5c22f0f5c4083ceee623b5bc02a6a7fc4f18c.tar
gsoc2013-evolution-50e5c22f0f5c4083ceee623b5bc02a6a7fc4f18c.tar.gz
gsoc2013-evolution-50e5c22f0f5c4083ceee623b5bc02a6a7fc4f18c.tar.bz2
gsoc2013-evolution-50e5c22f0f5c4083ceee623b5bc02a6a7fc4f18c.tar.lz
gsoc2013-evolution-50e5c22f0f5c4083ceee623b5bc02a6a7fc4f18c.tar.xz
gsoc2013-evolution-50e5c22f0f5c4083ceee623b5bc02a6a7fc4f18c.tar.zst
gsoc2013-evolution-50e5c22f0f5c4083ceee623b5bc02a6a7fc4f18c.zip
parent class is now CamelSeekableStream idem idem idem idem (_seek):
2000-01-24 bertrand <bertrand@helixcode.com> * camel/camel-seekable-stream.c: * camel/camel-seekable-stream.h: * camel/camel-simple-data-wrapper-stream.h: parent class is now CamelSeekableStream * camel/camel-stream-buffered-fs.h: idem * camel/camel-stream-buffered-fs.c: idem * camel/camel-stream-mem.h: idem * camel/camel-stream-mem.c: idem (_seek): change declaration * camel/camel-stream-fs.c: parent class is now CamelSeekableStream (_seek): change declaration * camel/camel-stream-fs.h: parent class is now CamelSeekableStream Major compatible change in the stream hierarchy. Removed the seek method from the general streams so that we can use them as "DataSources". svn path=/trunk/; revision=1622
Diffstat (limited to 'camel')
-rw-r--r--camel/Makefile.am2
-rw-r--r--camel/camel-seekable-stream.c112
-rw-r--r--camel/camel-seekable-stream.h87
-rw-r--r--camel/camel-simple-data-wrapper-stream.c2
-rw-r--r--camel/camel-simple-data-wrapper-stream.h4
-rw-r--r--camel/camel-stream-buffered-fs.c4
-rw-r--r--camel/camel-stream-fs.c14
-rw-r--r--camel/camel-stream-fs.h7
-rw-r--r--camel/camel-stream-mem.c12
-rw-r--r--camel/camel-stream-mem.h7
-rw-r--r--camel/camel-stream.c24
-rw-r--r--camel/camel-stream.h8
12 files changed, 230 insertions, 53 deletions
diff --git a/camel/Makefile.am b/camel/Makefile.am
index 9e46826c64..2003a951e6 100644
--- a/camel/Makefile.am
+++ b/camel/Makefile.am
@@ -52,6 +52,7 @@ libcamel_la_SOURCES = \
camel-op-queue.c \
camel-provider.c \
camel-recipient.c \
+ camel-seekable-stream.c \
camel-service.c \
camel-session.c \
camel-store.c \
@@ -92,6 +93,7 @@ libcamelinclude_HEADERS = \
camel-op-queue.h \
camel-provider.h \
camel-recipient.h \
+ camel-seekable-stream.h \
camel-service.h \
camel-session.h \
camel-store.h \
diff --git a/camel/camel-seekable-stream.c b/camel/camel-seekable-stream.c
new file mode 100644
index 0000000000..00cca3e369
--- /dev/null
+++ b/camel/camel-seekable-stream.c
@@ -0,0 +1,112 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ *
+ * Author :
+ * Bertrand Guiheneuf <bertrand@helixcode.com>
+ *
+ * Copyright 1999, 2000 HelixCode (http://www.helixcode.com) .
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+ */
+
+
+
+#include <config.h>
+#include "camel-seekable-stream.h"
+#include "camel-log.h"
+
+static CamelStreamClass *parent_class=NULL;
+
+
+/* Returns the class for a CamelSeekableStream */
+#define CSS_CLASS(so) CAMEL_SEEKABLE_STREAM_CLASS (GTK_OBJECT(so)->klass)
+
+static gint _seek (CamelSeekableStream *stream, gint offset, CamelStreamSeekPolicy policy);
+
+
+static void
+camel_seekable_stream_class_init (CamelSeekableStreamClass *camel_seekable_stream_class)
+{
+ CamelStreamClass *camel_stream_class = CAMEL_STREAM_CLASS (camel_seekable_stream_class);
+ GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (camel_seekable_stream_class);
+
+ parent_class = gtk_type_class (camel_stream_get_type ());
+
+ camel_seekable_stream_class->seek = _seek;
+
+}
+
+GtkType
+camel_seekable_stream_get_type (void)
+{
+ static GtkType camel_seekable_stream_type = 0;
+
+ if (!camel_seekable_stream_type) {
+ GtkTypeInfo camel_seekable_stream_info =
+ {
+ "CamelSeekableStream",
+ sizeof (CamelSeekableStream),
+ sizeof (CamelSeekableStreamClass),
+ (GtkClassInitFunc) camel_seekable_stream_class_init,
+ (GtkObjectInitFunc) NULL,
+ /* reserved_1 */ NULL,
+ /* reserved_2 */ NULL,
+ (GtkClassInitFunc) NULL,
+ };
+
+ camel_seekable_stream_type = gtk_type_unique (camel_stream_get_type (), &camel_seekable_stream_info);
+ }
+
+ return camel_seekable_stream_type;
+}
+
+
+
+
+static gint
+_seek (CamelSeekableStream *stream, gint offset, CamelStreamSeekPolicy policy)
+{
+ return -1;
+}
+
+
+
+
+
+
+
+/**
+ * camel_stream_seek:
+ * @stream: a CamelStream object.
+ * @offset: offset value
+ * @policy: what to do with the offset
+ *
+ *
+ *
+ * Return value: new position, -1 if operation failed.
+ **/
+gint
+camel_stream_seek (CamelSeekableStream *stream, gint offset, CamelStreamSeekPolicy policy)
+{
+ return CSS_CLASS (stream)->seek (stream, offset, policy);
+}
+
+
+
+
+
+
diff --git a/camel/camel-seekable-stream.h b/camel/camel-seekable-stream.h
new file mode 100644
index 0000000000..7f00edc81a
--- /dev/null
+++ b/camel/camel-seekable-stream.h
@@ -0,0 +1,87 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* camel-stream-fs.h :stream based on unix filesystem */
+
+/*
+ *
+ * Author :
+ * Bertrand Guiheneuf <bertrand@helixcode.com>
+ *
+ * Copyright 1999, 2000 HelixCode (http://www.helixcode.com) .
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+ */
+
+
+#ifndef CAMEL_SEEKABLE_STREAM_H
+#define CAMEL_SEEKABLE_STREAM_H 1
+
+
+#ifdef __cplusplus
+extern "C" {
+#pragma }
+#endif /* __cplusplus }*/
+
+#include <gtk/gtk.h>
+#include <stdio.h>
+#include "camel-stream.h"
+
+#define CAMEL_SEEKABLE_STREAM_TYPE (camel_seekable_stream_get_type ())
+#define CAMEL_SEEKABLE_STREAM(obj) (GTK_CHECK_CAST((obj), CAMEL_SEEKABLE_STREAM_TYPE, CamelSeekableStream))
+#define CAMEL_SEEKABLE_STREAM_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_SEEKABLE_STREAM_TYPE, CamelSeekableStreamClass))
+#define CAMEL_IS_SEEKABLE_STREAM(o) (GTK_CHECK_TYPE((o), CAMEL_SEEKABLE_STREAM_TYPE))
+
+
+typedef enum
+{
+ CAMEL_STREAM_SET,
+ CAMEL_STREAM_CUR,
+ CAMEL_STREAM_END
+
+} CamelStreamSeekPolicy;
+
+
+typedef struct
+{
+ CamelStream parent_object;
+
+} CamelSeekableStream;
+
+
+
+typedef struct {
+ CamelStreamClass parent_class;
+
+ /* Virtual methods */
+ gint (*seek) (CamelSeekableStream *stream, gint offset, CamelStreamSeekPolicy policy);
+
+
+} CamelSeekableStreamClass;
+
+
+
+/* Standard Gtk function */
+GtkType camel_seekable_stream_get_type (void);
+
+
+/* public methods */
+gint camel_stream_seek (CamelSeekableStream *stream, gint offset, CamelStreamSeekPolicy policy);
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* CAMEL_SEEKABLE_STREAM_H */
diff --git a/camel/camel-simple-data-wrapper-stream.c b/camel/camel-simple-data-wrapper-stream.c
index 2b5704b31e..5103e1383c 100644
--- a/camel/camel-simple-data-wrapper-stream.c
+++ b/camel/camel-simple-data-wrapper-stream.c
@@ -144,7 +144,7 @@ close (CamelStream *stream)
}
static gint
-seek (CamelStream *stream,
+seek (CamelSeekableStream *stream,
gint offset,
CamelStreamSeekPolicy policy)
{
diff --git a/camel/camel-simple-data-wrapper-stream.h b/camel/camel-simple-data-wrapper-stream.h
index 094f15faf7..9c756a568d 100644
--- a/camel/camel-simple-data-wrapper-stream.h
+++ b/camel/camel-simple-data-wrapper-stream.h
@@ -31,6 +31,8 @@
#include <gtk/gtk.h>
#include "camel-simple-data-wrapper.h"
+#include "camel-seekable-stream.h"
+
#ifdef __cplusplus
extern "C" {
@@ -53,7 +55,7 @@ typedef struct _CamelSimpleDataWrapperStream CamelSimpleDataWrapperStream;
typedef struct _CamelSimpleDataWrapperStreamClass CamelSimpleDataWrapperStreamClass;
struct _CamelSimpleDataWrapperStream {
- CamelStream parent;
+ CamelSeekableStream parent;
CamelSimpleDataWrapper *wrapper;
gint current_position;
diff --git a/camel/camel-stream-buffered-fs.c b/camel/camel-stream-buffered-fs.c
index c42f47aa96..0aba2e2538 100644
--- a/camel/camel-stream-buffered-fs.c
+++ b/camel/camel-stream-buffered-fs.c
@@ -47,7 +47,7 @@ static void _flush (CamelStream *stream);
static gint _available (CamelStream *stream);
static gboolean _eos (CamelStream *stream);
static void _close (CamelStream *stream);
-static gint _seek (CamelStream *stream, gint offset, CamelStreamSeekPolicy policy);
+static gint _seek (CamelSeekableStream *stream, gint offset, CamelStreamSeekPolicy policy);
static void _finalize (GtkObject *object);
static void _destroy (GtkObject *object);
@@ -259,7 +259,7 @@ _close (CamelStream *stream)
static gint
-_seek (CamelStream *stream, gint offset, CamelStreamSeekPolicy policy)
+_seek (CamelSeekableStream *stream, gint offset, CamelStreamSeekPolicy policy)
{
return 0;
}
diff --git a/camel/camel-stream-fs.c b/camel/camel-stream-fs.c
index 905582aae2..acff58738f 100644
--- a/camel/camel-stream-fs.c
+++ b/camel/camel-stream-fs.c
@@ -34,7 +34,7 @@
#include <string.h>
#include "camel-log.h"
-static CamelStreamClass *parent_class=NULL;
+static CamelSeekableStreamClass *parent_class=NULL;
/* Returns the class for a CamelStreamFS */
@@ -46,7 +46,7 @@ static void _flush (CamelStream *stream);
static gint _available (CamelStream *stream);
static gboolean _eos (CamelStream *stream);
static void _close (CamelStream *stream);
-static gint _seek (CamelStream *stream, gint offset, CamelStreamSeekPolicy policy);
+static gint _seek (CamelSeekableStream *stream, gint offset, CamelStreamSeekPolicy policy);
static void _finalize (GtkObject *object);
static void _destroy (GtkObject *object);
@@ -60,6 +60,7 @@ static void _init_with_name_and_bounds (CamelStreamFs *stream_fs, const gchar *n
static void
camel_stream_fs_class_init (CamelStreamFsClass *camel_stream_fs_class)
{
+ CamelSeekableStreamClass *camel_seekable_stream_class = CAMEL_SEEKABLE_STREAM_CLASS (camel_stream_fs_class);
CamelStreamClass *camel_stream_class = CAMEL_STREAM_CLASS (camel_stream_fs_class);
GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (camel_stream_fs_class);
@@ -78,7 +79,8 @@ camel_stream_fs_class_init (CamelStreamFsClass *camel_stream_fs_class)
camel_stream_class->available = _available;
camel_stream_class->eos = _eos;
camel_stream_class->close = _close;
- camel_stream_class->seek = _seek;
+
+ camel_seekable_stream_class->seek = _seek;
gtk_object_class->finalize = _finalize;
gtk_object_class->destroy = _destroy;
@@ -112,7 +114,7 @@ camel_stream_fs_get_type (void)
(GtkClassInitFunc) NULL,
};
- camel_stream_fs_type = gtk_type_unique (camel_stream_get_type (), &camel_stream_fs_info);
+ camel_stream_fs_type = gtk_type_unique (camel_seekable_stream_get_type (), &camel_stream_fs_info);
}
return camel_stream_fs_type;
@@ -375,7 +377,7 @@ _write (CamelStream *stream, const gchar *buffer, gint n)
CAMEL_LOG_FULL_DEBUG ( "CamelStreamFs:: entering write. n=%d\n", n);
if (stream_fs->sup_bound != -1)
- nb_to_write = MIN (stream_fs->sup_bound - stream_fs->cur_pos, n);;
+ nb_to_write = MIN (stream_fs->sup_bound - stream_fs->cur_pos, n);
else
nb_to_write = n;
@@ -459,7 +461,7 @@ _close (CamelStream *stream)
static gint
-_seek (CamelStream *stream, gint offset, CamelStreamSeekPolicy policy)
+_seek (CamelSeekableStream *stream, gint offset, CamelStreamSeekPolicy policy)
{
int whence;
gint return_position;
diff --git a/camel/camel-stream-fs.h b/camel/camel-stream-fs.h
index 7b5e7011c0..4910abbd5f 100644
--- a/camel/camel-stream-fs.h
+++ b/camel/camel-stream-fs.h
@@ -36,7 +36,7 @@ extern "C" {
#include <gtk/gtk.h>
#include <stdio.h>
-#include "camel-stream.h"
+#include "camel-seekable-stream.h"
#define CAMEL_STREAM_FS_TYPE (camel_stream_fs_get_type ())
#define CAMEL_STREAM_FS(obj) (GTK_CHECK_CAST((obj), CAMEL_STREAM_FS_TYPE, CamelStreamFs))
@@ -53,7 +53,8 @@ typedef enum
typedef struct
{
- CamelStream parent_object;
+ CamelSeekableStream parent_object;
+
gchar *name; /* name of the underlying file */
gint fd; /* file descriptor on the underlying file */
guint32 cur_pos; /* current postion in the stream */
@@ -65,7 +66,7 @@ typedef struct
typedef struct {
- CamelStreamClass parent_class;
+ CamelSeekableStreamClass parent_class;
/* Virtual methods */
void (*init_with_fd) (CamelStreamFs *stream_fs, int fd);
diff --git a/camel/camel-stream-mem.c b/camel/camel-stream-mem.c
index df69fc0448..6dd1b804cf 100644
--- a/camel/camel-stream-mem.c
+++ b/camel/camel-stream-mem.c
@@ -36,7 +36,7 @@ static CamelStreamClass *parent_class=NULL;
/* Returns the class for a CamelStreamMEM */
-#define CS_CLASS(so) CAMEL_STREAM_MEM_CLASS (GTK_OBJECT(so)->klass)
+#define CSM_CLASS(so) CAMEL_STREAM_MEM_CLASS (GTK_OBJECT(so)->klass)
static gint _read (CamelStream *stream, gchar *buffer, gint n);
static gint _write (CamelStream *stream, const gchar *buffer, gint n);
@@ -44,13 +44,14 @@ static void _flush (CamelStream *stream);
static gint _available (CamelStream *stream);
static gboolean _eos (CamelStream *stream);
static void _close (CamelStream *stream);
-static gint _seek (CamelStream *stream, gint offset, CamelStreamSeekPolicy policy);
+static gint _seek (CamelSeekableStream *stream, gint offset, CamelStreamSeekPolicy policy);
static void _finalize (GtkObject *object);
static void
camel_stream_mem_class_init (CamelStreamMemClass *camel_stream_mem_class)
{
+ CamelSeekableStreamClass *camel_seekable_stream_class = CAMEL_SEEKABLE_STREAM_CLASS (camel_stream_mem_class);
CamelStreamClass *camel_stream_class = CAMEL_STREAM_CLASS (camel_stream_mem_class);
GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (camel_stream_mem_class);
@@ -65,7 +66,8 @@ camel_stream_mem_class_init (CamelStreamMemClass *camel_stream_mem_class)
camel_stream_class->available = _available;
camel_stream_class->eos = _eos;
camel_stream_class->close = _close;
- camel_stream_class->seek = _seek;
+
+ camel_seekable_stream_class->seek = _seek;
gtk_object_class->finalize = _finalize;
@@ -96,7 +98,7 @@ camel_stream_mem_get_type (void)
(GtkClassInitFunc) NULL,
};
- camel_stream_mem_type = gtk_type_unique (camel_stream_get_type (), &camel_stream_mem_info);
+ camel_stream_mem_type = gtk_type_unique (camel_seekable_stream_get_type (), &camel_stream_mem_info);
}
return camel_stream_mem_type;
@@ -258,7 +260,7 @@ _close (CamelStream *stream)
static gint
-_seek (CamelStream *stream, gint offset, CamelStreamSeekPolicy policy)
+_seek (CamelSeekableStream *stream, gint offset, CamelStreamSeekPolicy policy)
{
gint position;
CamelStreamMem *camel_stream_mem = CAMEL_STREAM_MEM (stream);
diff --git a/camel/camel-stream-mem.h b/camel/camel-stream-mem.h
index 0ebcfead24..fa8c0514eb 100644
--- a/camel/camel-stream-mem.h
+++ b/camel/camel-stream-mem.h
@@ -36,7 +36,7 @@ extern "C" {
#include <gtk/gtk.h>
#include <stdio.h>
-#include "camel-stream.h"
+#include "camel-seekable-stream.h"
#define CAMEL_STREAM_MEM_TYPE (camel_stream_mem_get_type ())
#define CAMEL_STREAM_MEM(obj) (GTK_CHECK_CAST((obj), CAMEL_STREAM_MEM_TYPE, CamelStreamMem))
@@ -53,17 +53,18 @@ typedef enum
typedef struct
{
- CamelStream parent_object;
+ CamelSeekableStream parent_object;
GByteArray *buffer;
gint position;
CamelStreamMemMode mode;
+
} CamelStreamMem;
typedef struct {
- CamelStreamClass parent_class;
+ CamelSeekableStreamClass parent_class;
/* Virtual methods */
diff --git a/camel/camel-stream.c b/camel/camel-stream.c
index 26c346e1e5..5128d0309c 100644
--- a/camel/camel-stream.c
+++ b/camel/camel-stream.c
@@ -45,12 +45,6 @@ default_camel_close (CamelStream *stream)
/* nothing */
}
-static gint
-default_camel_seek (CamelStream *stream, gint offset, CamelStreamSeekPolicy policy)
-{
- /* nothing */
- return -1;
-}
static void
camel_stream_class_init (CamelStreamClass *camel_stream_class)
@@ -65,7 +59,6 @@ camel_stream_class_init (CamelStreamClass *camel_stream_class)
camel_stream_class->available = NULL;
camel_stream_class->eos = NULL;
camel_stream_class->close = default_camel_close;
- camel_stream_class->seek = default_camel_seek;
/* virtual method overload */
}
@@ -181,23 +174,6 @@ camel_stream_close (CamelStream *stream)
}
-/**
- * camel_stream_seek:
- * @stream: a CamelStream object.
- * @offset: offset value
- * @policy: what to do with the offset
- *
- *
- *
- * Return value: new position, -1 if operation failed.
- **/
-gint
-camel_stream_seek (CamelStream *stream, gint offset, CamelStreamSeekPolicy policy)
-{
- return CS_CLASS (stream)->seek (stream, offset, policy);
-}
-
-
/***************** Utility functions ********************/
diff --git a/camel/camel-stream.h b/camel/camel-stream.h
index b866dd5974..73b4c31082 100644
--- a/camel/camel-stream.h
+++ b/camel/camel-stream.h
@@ -41,12 +41,6 @@ extern "C" {
#define CAMEL_STREAM_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_STREAM_TYPE, CamelStreamClass))
#define CAMEL_IS_STREAM(o) (GTK_CHECK_TYPE((o), CAMEL_STREAM_TYPE))
-typedef enum
-{
- CAMEL_STREAM_SET,
- CAMEL_STREAM_CUR,
- CAMEL_STREAM_END
-} CamelStreamSeekPolicy;
typedef struct
{
@@ -66,7 +60,6 @@ typedef struct {
gint (*available) (CamelStream *stream);
gboolean (*eos) (CamelStream *stream);
void (*close) (CamelStream *stream);
- gint (*seek) (CamelStream *stream, gint offset, CamelStreamSeekPolicy policy);
} CamelStreamClass;
@@ -82,7 +75,6 @@ void camel_stream_flush (CamelStream *stream);
gint camel_stream_available (CamelStream *stream);
gboolean camel_stream_eos (CamelStream *stream);
void camel_stream_close (CamelStream *stream);
-gint camel_stream_seek (CamelStream *stream, gint offset, CamelStreamSeekPolicy policy);
/* utility macros and funcs */
#define camel_stream_write_string(stream, string) camel_stream_write ((stream), (string), strlen (string))