[evolution-data-server] Replace CamelStreamSeekPolicy with GSeekType.



commit b028f72eef417ad3656c304d097f966794cb8ffd
Author: Matthew Barnes <mbarnes redhat com>
Date:   Sat Jan 22 16:17:19 2011 -0500

    Replace CamelStreamSeekPolicy with GSeekType.

 camel/camel-seekable-stream.c                      |   20 +++++------
 camel/camel-seekable-stream.h                      |   10 +-----
 camel/camel-seekable-substream.c                   |   14 ++++----
 camel/camel-stream-fs.c                            |   10 +++---
 camel/camel-stream-mem.c                           |   10 +++---
 camel/providers/imap/camel-imap-search.c           |    2 +-
 camel/providers/imapx/camel-imapx-server.c         |    2 +-
 camel/tests/lib/streams.c                          |   34 ++++++++++----------
 docs/reference/camel/camel-sections.txt            |    1 -
 .../camel/tmpl/camel-seekable-stream.sgml          |   11 +------
 10 files changed, 48 insertions(+), 66 deletions(-)
---
diff --git a/camel/camel-seekable-stream.c b/camel/camel-seekable-stream.c
index 66954cf..e599ef1 100644
--- a/camel/camel-seekable-stream.c
+++ b/camel/camel-seekable-stream.c
@@ -40,7 +40,7 @@ seekable_stream_reset (CamelStream *stream,
 
 	return camel_seekable_stream_seek (
 		seekable_stream, seekable_stream->bound_start,
-		CAMEL_STREAM_SET, error);
+		G_SEEK_SET, error);
 }
 
 static goffset
@@ -61,7 +61,7 @@ seekable_stream_set_bounds (CamelSeekableStream *stream,
 
 	if (start > stream->position)
 		return camel_seekable_stream_seek (
-			stream, start, CAMEL_STREAM_SET, error);
+			stream, start, G_SEEK_SET, error);
 
 	return 0;
 }
@@ -89,20 +89,18 @@ camel_seekable_stream_init (CamelSeekableStream *stream)
  * camel_seekable_stream_seek:
  * @stream: a #CamelStream object
  * @offset: offset value
- * @policy: what to do with the offset
+ * @type: what to do with the offset
  * @error: return location for a #GError, or %NULL
  *
  * Seek to the specified position in @stream.
  *
- * If @policy is #CAMEL_STREAM_SET, seeks to @offset.
+ * If @type is #G_SEEK_SET, seeks to @offset.
  *
- * If @policy is #CAMEL_STREAM_CUR, seeks to the current position plus
- * @offset.
+ * If @type is #G_SEEK_CUR, seeks to the current position plus @offset.
  *
- * If @policy is #CAMEL_STREAM_END, seeks to the end of the stream plus
- * @offset.
+ * If @type is #G_SEEK_END, seeks to the end of the stream plus @offset.
  *
- * Regardless of @policy, the stream's final position will be clamped
+ * Regardless of @type, the stream's final position will be clamped
  * to the range specified by its lower and upper bounds, and the
  * stream's eos state will be updated.
  *
@@ -111,7 +109,7 @@ camel_seekable_stream_init (CamelSeekableStream *stream)
 goffset
 camel_seekable_stream_seek (CamelSeekableStream *stream,
                             goffset offset,
-                            CamelStreamSeekPolicy policy,
+                            GSeekType type,
                             GError **error)
 {
 	CamelSeekableStreamClass *class;
@@ -122,7 +120,7 @@ camel_seekable_stream_seek (CamelSeekableStream *stream,
 	class = CAMEL_SEEKABLE_STREAM_GET_CLASS (stream);
 	g_return_val_if_fail (class->seek != NULL, -1);
 
-	new_offset = class->seek (stream, offset, policy, error);
+	new_offset = class->seek (stream, offset, type, error);
 	CAMEL_CHECK_GERROR (stream, seek, new_offset >= 0, error);
 
 	return new_offset;
diff --git a/camel/camel-seekable-stream.h b/camel/camel-seekable-stream.h
index ad1cc5c..b1613cd 100644
--- a/camel/camel-seekable-stream.h
+++ b/camel/camel-seekable-stream.h
@@ -57,12 +57,6 @@ G_BEGIN_DECLS
 typedef struct _CamelSeekableStream CamelSeekableStream;
 typedef struct _CamelSeekableStreamClass CamelSeekableStreamClass;
 
-typedef enum {
-	CAMEL_STREAM_SET = SEEK_SET,
-	CAMEL_STREAM_CUR = SEEK_CUR,
-	CAMEL_STREAM_END = SEEK_END
-} CamelStreamSeekPolicy;
-
 #define CAMEL_STREAM_UNBOUND (~0)
 
 struct _CamelSeekableStream {
@@ -78,7 +72,7 @@ struct _CamelSeekableStreamClass {
 
 	goffset		(*seek)			(CamelSeekableStream *stream,
 						 goffset offset,
-						 CamelStreamSeekPolicy policy,
+						 GSeekType type,
 						 GError **error);
 	goffset		(*tell)			(CamelSeekableStream *stream);
 	gint		(*set_bounds)		(CamelSeekableStream *stream,
@@ -90,7 +84,7 @@ struct _CamelSeekableStreamClass {
 GType		camel_seekable_stream_get_type	(void);
 goffset		camel_seekable_stream_seek	(CamelSeekableStream *stream,
 						 goffset offset,
-						 CamelStreamSeekPolicy policy,
+						 GSeekType type,
 						 GError **error);
 goffset		camel_seekable_stream_tell	(CamelSeekableStream *stream);
 gint		camel_seekable_stream_set_bounds (CamelSeekableStream *stream,
diff --git a/camel/camel-seekable-substream.c b/camel/camel-seekable-substream.c
index f75dee0..251a5db 100644
--- a/camel/camel-seekable-substream.c
+++ b/camel/camel-seekable-substream.c
@@ -40,7 +40,7 @@ seekable_substream_parent_reset (CamelSeekableSubstream *seekable_substream,
 
 	return camel_seekable_stream_seek (
 		parent, seekable_stream->position,
-		CAMEL_STREAM_SET, NULL) == seekable_stream->position;
+		G_SEEK_SET, NULL) == seekable_stream->position;
 }
 
 static void
@@ -191,7 +191,7 @@ seekable_substream_eos (CamelStream *stream)
 static goffset
 seekable_substream_seek (CamelSeekableStream *seekable_stream,
                          goffset offset,
-                         CamelStreamSeekPolicy policy,
+                         GSeekType type,
                          GError **error)
 {
 	CamelStream *stream;
@@ -203,20 +203,20 @@ seekable_substream_seek (CamelSeekableStream *seekable_stream,
 
 	stream->eos = FALSE;
 
-	switch (policy) {
-	case CAMEL_STREAM_SET:
+	switch (type) {
+	case G_SEEK_SET:
 		real_offset = offset;
 		break;
 
-	case CAMEL_STREAM_CUR:
+	case G_SEEK_CUR:
 		real_offset = seekable_stream->position + offset;
 		break;
 
-	case CAMEL_STREAM_END:
+	case G_SEEK_END:
 		if (seekable_stream->bound_end == CAMEL_STREAM_UNBOUND) {
 			real_offset = camel_seekable_stream_seek (
 				seekable_substream->parent_stream,
-				offset, CAMEL_STREAM_END, error);
+				offset, G_SEEK_END, error);
 			if (real_offset != -1) {
 				if (real_offset<seekable_stream->bound_start)
 					real_offset = seekable_stream->bound_start;
diff --git a/camel/camel-stream-fs.c b/camel/camel-stream-fs.c
index aa3383b..d302ac7 100644
--- a/camel/camel-stream-fs.c
+++ b/camel/camel-stream-fs.c
@@ -166,7 +166,7 @@ stream_fs_close (CamelStream *stream,
 static goffset
 stream_fs_seek (CamelSeekableStream *stream,
                 goffset offset,
-                CamelStreamSeekPolicy policy,
+                GSeekType type,
                 GError **error)
 {
 	CamelStreamFsPrivate *priv;
@@ -174,14 +174,14 @@ stream_fs_seek (CamelSeekableStream *stream,
 
 	priv = CAMEL_STREAM_FS_GET_PRIVATE (stream);
 
-	switch (policy) {
-	case CAMEL_STREAM_SET:
+	switch (type) {
+	case G_SEEK_SET:
 		real = offset;
 		break;
-	case CAMEL_STREAM_CUR:
+	case G_SEEK_CUR:
 		real = stream->position + offset;
 		break;
-	case CAMEL_STREAM_END:
+	case G_SEEK_END:
 		if (stream->bound_end == CAMEL_STREAM_UNBOUND) {
 			real = lseek (priv->fd, offset, SEEK_END);
 			if (real != -1) {
diff --git a/camel/camel-stream-mem.c b/camel/camel-stream-mem.c
index 4ac97dd..89c078a 100644
--- a/camel/camel-stream-mem.c
+++ b/camel/camel-stream-mem.c
@@ -153,7 +153,7 @@ stream_mem_eos (CamelStream *stream)
 static goffset
 stream_mem_seek (CamelSeekableStream *stream,
                  goffset offset,
-                 CamelStreamSeekPolicy policy,
+                 GSeekType type,
                  GError **error)
 {
 	CamelStreamMemPrivate *priv;
@@ -161,14 +161,14 @@ stream_mem_seek (CamelSeekableStream *stream,
 
 	priv = CAMEL_STREAM_MEM_GET_PRIVATE (stream);
 
-	switch  (policy) {
-	case CAMEL_STREAM_SET:
+	switch (type) {
+	case G_SEEK_SET:
 		position = offset;
 		break;
-	case CAMEL_STREAM_CUR:
+	case G_SEEK_CUR:
 		position = stream->position + offset;
 		break;
-	case CAMEL_STREAM_END:
+	case G_SEEK_END:
 		position = (priv->buffer)->len + offset;
 		break;
 	default:
diff --git a/camel/providers/imap/camel-imap-search.c b/camel/providers/imap/camel-imap-search.c
index 6c5d252..baa5d66 100644
--- a/camel/providers/imap/camel-imap-search.c
+++ b/camel/providers/imap/camel-imap-search.c
@@ -245,7 +245,7 @@ save_match (CamelImapSearch *is, struct _match_record *mr)
 
 	if (camel_stream_write (stream, (gchar *)&header, sizeof (header), NULL, NULL) != sizeof (header)
 	    || camel_stream_write (stream, mr->matches->data, mr->matches->len*sizeof (guint32), NULL, NULL) != mr->matches->len*sizeof (guint32)
-	    || camel_seekable_stream_seek ((CamelSeekableStream *)stream, 0, CAMEL_STREAM_SET, NULL) == -1
+	    || camel_seekable_stream_seek ((CamelSeekableStream *)stream, 0, G_SEEK_SET, NULL) == -1
 	    || camel_stream_write (stream, (gchar *)&mark, sizeof (mark), NULL, NULL) != sizeof (mark)) {
 		d(printf(" saving failed, removing cache entry\n"));
 		camel_data_cache_remove(is->cache, "search/body-contains", mr->hash, NULL);
diff --git a/camel/providers/imapx/camel-imapx-server.c b/camel/providers/imapx/camel-imapx-server.c
index dda55ee..9225c0c 100644
--- a/camel/providers/imapx/camel-imapx-server.c
+++ b/camel/providers/imapx/camel-imapx-server.c
@@ -1400,7 +1400,7 @@ imapx_untagged (CamelIMAPXServer *imap,
 			if (job && job->error == NULL) {
 				if (job->u.get_message.use_multi_fetch) {
 					job->u.get_message.body_offset = finfo->offset;
-					camel_seekable_stream_seek ((CamelSeekableStream *)job->u.get_message.stream, finfo->offset, CAMEL_STREAM_SET, NULL);
+					camel_seekable_stream_seek ((CamelSeekableStream *)job->u.get_message.stream, finfo->offset, G_SEEK_SET, NULL);
 				}
 
 				job->u.get_message.body_len = camel_stream_write_to_stream (finfo->body, job->u.get_message.stream, job->cancellable, &job->error);
diff --git a/camel/tests/lib/streams.c b/camel/tests/lib/streams.c
index 61d9377..f884650 100644
--- a/camel/tests/lib/streams.c
+++ b/camel/tests/lib/streams.c
@@ -24,7 +24,7 @@ test_stream_seekable_writepart (CamelSeekableStream *s)
 	push ("seekable stream test, writing ");
 
 	check (camel_seekable_stream_tell (s) == 0);
-	check (camel_seekable_stream_seek (s, 0, CAMEL_STREAM_SET, NULL) == 0);
+	check (camel_seekable_stream_seek (s, 0, G_SEEK_SET, NULL) == 0);
 	check (camel_seekable_stream_tell (s) == 0);
 
 	check (camel_stream_write (CAMEL_STREAM (s), "", 0, NULL, NULL) == 0);
@@ -41,10 +41,10 @@ test_stream_seekable_writepart (CamelSeekableStream *s)
 	}
 	end = 10240*sizeof (teststring)+1;
 
-	check_msg (camel_seekable_stream_seek (s, 0, CAMEL_STREAM_END, NULL) == end, "seek =%d end = %d",
-		  camel_seekable_stream_seek (s, 0, CAMEL_STREAM_END, NULL), end);
+	check_msg (camel_seekable_stream_seek (s, 0, G_SEEK_END, NULL) == end, "seek =%d end = %d",
+		  camel_seekable_stream_seek (s, 0, G_SEEK_END, NULL), end);
 
-	check (camel_seekable_stream_seek (s, 0, CAMEL_STREAM_END, NULL) == end);
+	check (camel_seekable_stream_seek (s, 0, G_SEEK_END, NULL) == end);
 	check (camel_seekable_stream_tell (s) == end);
 	/* need to read 0 first to set eos */
 	check (camel_stream_read (
@@ -64,7 +64,7 @@ test_stream_seekable_readpart (CamelSeekableStream *s)
 
 	end = 10240*sizeof (teststring)+1;
 
-	check (camel_seekable_stream_seek (s, 0, CAMEL_STREAM_SET, NULL) == 0);
+	check (camel_seekable_stream_seek (s, 0, G_SEEK_SET, NULL) == 0);
 	check (camel_seekable_stream_tell (s) == 0);
 	check (!camel_stream_eos (CAMEL_STREAM (s)));
 
@@ -76,13 +76,13 @@ test_stream_seekable_readpart (CamelSeekableStream *s)
 		/* exercise all seek methods */
 		switch (i % 3) {
 		case 0:
-			check (camel_seekable_stream_seek (s, new, CAMEL_STREAM_SET, NULL) == new);
+			check (camel_seekable_stream_seek (s, new, G_SEEK_SET, NULL) == new);
 			break;
 		case 1:
-			check (camel_seekable_stream_seek (s, new-off, CAMEL_STREAM_CUR, NULL) == new);
+			check (camel_seekable_stream_seek (s, new-off, G_SEEK_CUR, NULL) == new);
 			break;
 		case 2:
-			check (camel_seekable_stream_seek (s, new-end, CAMEL_STREAM_END, NULL) == new);
+			check (camel_seekable_stream_seek (s, new-end, G_SEEK_END, NULL) == new);
 			break;
 		}
 		check (camel_seekable_stream_tell (s) == new);
@@ -102,7 +102,7 @@ test_stream_seekable_readpart (CamelSeekableStream *s)
 	}
 
 	/* verify end-of-file behaviour */
-	check (camel_seekable_stream_seek (s, -1, CAMEL_STREAM_END, NULL) == end-1);
+	check (camel_seekable_stream_seek (s, -1, G_SEEK_END, NULL) == end-1);
 	check (camel_seekable_stream_tell (s) == end-1);
 
 	check (camel_stream_read (
@@ -111,7 +111,7 @@ test_stream_seekable_readpart (CamelSeekableStream *s)
 
 	check (camel_stream_read (
 		CAMEL_STREAM (s), testbuf, 10240, NULL, NULL) == 0);
-	check (camel_seekable_stream_seek (s, 0, CAMEL_STREAM_CUR, NULL) == end);
+	check (camel_seekable_stream_seek (s, 0, G_SEEK_CUR, NULL) == end);
 	check (camel_seekable_stream_tell (s) == end);
 	check (camel_stream_eos (CAMEL_STREAM (s)));
 
@@ -133,11 +133,11 @@ test_seekable_substream_writepart (CamelStream *s, gint type)
 	push ("writing substream, type %d", type);
 
 	if (type == 1) {
-		check (camel_seekable_stream_seek (sp, ss->bound_start, CAMEL_STREAM_SET, NULL) == ss->bound_start);
+		check (camel_seekable_stream_seek (sp, ss->bound_start, G_SEEK_SET, NULL) == ss->bound_start);
 		s = (CamelStream *)sp;
 	} else {
 		check (camel_seekable_stream_tell (ss) == ss->bound_start);
-		check (camel_seekable_stream_seek (ss, 0, CAMEL_STREAM_SET, NULL) == ss->bound_start);
+		check (camel_seekable_stream_seek (ss, 0, G_SEEK_SET, NULL) == ss->bound_start);
 	}
 
 	check (camel_seekable_stream_tell (CAMEL_SEEKABLE_STREAM (s)) == ss->bound_start);
@@ -189,10 +189,10 @@ test_seekable_substream_readpart (CamelStream *s)
 
 	push ("reading substream");
 
-	check (camel_seekable_stream_seek (ss, 0, CAMEL_STREAM_SET, NULL) == ss->bound_start);
+	check (camel_seekable_stream_seek (ss, 0, G_SEEK_SET, NULL) == ss->bound_start);
 	check (camel_seekable_stream_tell (ss) == ss->bound_start);
 
-	check (camel_seekable_stream_seek (sp, ss->bound_start, CAMEL_STREAM_SET, NULL) == ss->bound_start);
+	check (camel_seekable_stream_seek (sp, ss->bound_start, G_SEEK_SET, NULL) == ss->bound_start);
 	check (camel_seekable_stream_tell (sp) == ss->bound_start);
 
 	/* check writes, cross check with parent stream */
@@ -205,7 +205,7 @@ test_seekable_substream_readpart (CamelStream *s)
 			check (camel_seekable_stream_tell (ss) == ss->bound_start + (i+1)*sizeof (teststring));
 
 			/* yeah great, the substreams affect the seek ... */
-			check (camel_seekable_stream_seek (sp, ss->bound_start + (i)*sizeof (teststring), CAMEL_STREAM_SET, NULL) == ss->bound_start + i*sizeof (teststring));
+			check (camel_seekable_stream_seek (sp, ss->bound_start + (i)*sizeof (teststring), G_SEEK_SET, NULL) == ss->bound_start + i*sizeof (teststring));
 			check (camel_stream_read (
 				CAMEL_STREAM (sp), testbuf,
 				sizeof (teststring), NULL, NULL)
@@ -217,7 +217,7 @@ test_seekable_substream_readpart (CamelStream *s)
 		check (camel_stream_read (s, testbuf, len, NULL, NULL) == len);
 		check (memcmp (testbuf, teststring, len) == 0);
 
-		check (camel_seekable_stream_seek (sp, ss->bound_end - len, CAMEL_STREAM_SET, NULL) == ss->bound_end - len);
+		check (camel_seekable_stream_seek (sp, ss->bound_end - len, G_SEEK_SET, NULL) == ss->bound_end - len);
 		check (camel_stream_read (
 			CAMEL_STREAM (sp), testbuf, len, NULL, NULL) == len);
 		check (memcmp (testbuf, teststring, len) == 0);
@@ -238,7 +238,7 @@ test_seekable_substream_readpart (CamelStream *s)
 			check (memcmp (testbuf, teststring, sizeof (teststring)) == 0);
 			check (camel_seekable_stream_tell (ss) == ss->bound_start + (i+1)*sizeof (teststring));
 
-			check (camel_seekable_stream_seek (sp, ss->bound_start + (i)*sizeof (teststring), CAMEL_STREAM_SET, NULL) == ss->bound_start + i*sizeof (teststring));
+			check (camel_seekable_stream_seek (sp, ss->bound_start + (i)*sizeof (teststring), G_SEEK_SET, NULL) == ss->bound_start + i*sizeof (teststring));
 			check (camel_stream_read (
 				CAMEL_STREAM (sp), testbuf,
 				sizeof (teststring), NULL, NULL)
diff --git a/docs/reference/camel/camel-sections.txt b/docs/reference/camel/camel-sections.txt
index 74ec52a..77f6d74 100644
--- a/docs/reference/camel/camel-sections.txt
+++ b/docs/reference/camel/camel-sections.txt
@@ -1872,7 +1872,6 @@ camel_sexp_to_sql_sexp
 <FILE>camel-seekable-stream</FILE>
 <TITLE>CamelSeekableStream</TITLE>
 CamelSeekableStream
-CamelStreamSeekPolicy
 CAMEL_STREAM_UNBOUND
 camel_seekable_stream_seek
 camel_seekable_stream_tell
diff --git a/docs/reference/camel/tmpl/camel-seekable-stream.sgml b/docs/reference/camel/tmpl/camel-seekable-stream.sgml
index ae831b7..eb3d8c0 100644
--- a/docs/reference/camel/tmpl/camel-seekable-stream.sgml
+++ b/docs/reference/camel/tmpl/camel-seekable-stream.sgml
@@ -26,15 +26,6 @@ CamelSeekableStream
 </para>
 
 
-<!-- ##### ENUM CamelStreamSeekPolicy ##### -->
-<para>
-
-</para>
-
- CAMEL_STREAM_SET: 
- CAMEL_STREAM_CUR: 
- CAMEL_STREAM_END: 
-
 <!-- ##### MACRO CAMEL_STREAM_UNBOUND ##### -->
 <para>
 
@@ -49,7 +40,7 @@ CamelSeekableStream
 
 @stream: 
 @offset: 
- policy: 
+ type: 
 @error: 
 @Returns: 
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]