Extending test-client-custom-summary to try e_book_client_get_contacts_uids()
[platform/upstream/evolution-data-server.git] / camel / camel-stream.h
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; fill-column: 160 -*- */
2 /* camel-stream.h : class for an abstract stream */
3
4 /*
5  * Author:
6  *  Bertrand Guiheneuf <bertrand@helixcode.com>
7  *
8  * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of version 2 of the GNU Lesser General Public
12  * License as published by the Free Software Foundation.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
22  * USA
23  */
24
25 #if !defined (__CAMEL_H_INSIDE__) && !defined (CAMEL_COMPILATION)
26 #error "Only <camel/camel.h> can be included directly."
27 #endif
28
29 #ifndef CAMEL_STREAM_H
30 #define CAMEL_STREAM_H
31
32 #include <stdarg.h>
33 #include <unistd.h>
34 #include <camel/camel-object.h>
35
36 /* Standard GObject macros */
37 #define CAMEL_TYPE_STREAM \
38         (camel_stream_get_type ())
39 #define CAMEL_STREAM(obj) \
40         (G_TYPE_CHECK_INSTANCE_CAST \
41         ((obj), CAMEL_TYPE_STREAM, CamelStream))
42 #define CAMEL_STREAM_CLASS(cls) \
43         (G_TYPE_CHECK_CLASS_CAST \
44         ((cls), CAMEL_TYPE_STREAM, CamelStreamClass))
45 #define CAMEL_IS_STREAM(obj) \
46         (G_TYPE_CHECK_INSTANCE_TYPE \
47         ((obj), CAMEL_TYPE_STREAM))
48 #define CAMEL_IS_STREAM_CLASS(cls) \
49         (G_TYPE_CHECK_CLASS_TYPE \
50         ((cls), CAMEL_TYPE_STREAM))
51 #define CAMEL_STREAM_GET_CLASS(obj) \
52         (G_TYPE_INSTANCE_GET_CLASS \
53         ((obj), CAMEL_TYPE_STREAM, CamelStreamClass))
54
55 G_BEGIN_DECLS
56
57 typedef struct _CamelStream CamelStream;
58 typedef struct _CamelStreamClass CamelStreamClass;
59
60 struct _CamelStream {
61         CamelObject parent;
62
63         gboolean eos;
64 };
65
66 struct _CamelStreamClass {
67         CamelObjectClass parent_class;
68
69         gssize          (*read)                 (CamelStream *stream,
70                                                  gchar *buffer,
71                                                  gsize n,
72                                                  GCancellable *cancellable,
73                                                  GError **error);
74         gssize          (*write)                (CamelStream *stream,
75                                                  const gchar *buffer,
76                                                  gsize n,
77                                                  GCancellable *cancellable,
78                                                  GError **error);
79         gint            (*close)                (CamelStream *stream,
80                                                  GCancellable *cancellable,
81                                                  GError **error);
82         gint            (*flush)                (CamelStream *stream,
83                                                  GCancellable *cancellable,
84                                                  GError **error);
85         gboolean        (*eos)                  (CamelStream *stream);
86 };
87
88 GType           camel_stream_get_type           (void);
89 gssize          camel_stream_read               (CamelStream *stream,
90                                                  gchar *buffer,
91                                                  gsize n,
92                                                  GCancellable *cancellable,
93                                                  GError **error);
94 gssize          camel_stream_write              (CamelStream *stream,
95                                                  const gchar *buffer,
96                                                  gsize n,
97                                                  GCancellable *cancellable,
98                                                  GError **error);
99 gint            camel_stream_flush              (CamelStream *stream,
100                                                  GCancellable *cancellable,
101                                                  GError **error);
102 gint            camel_stream_close              (CamelStream *stream,
103                                                  GCancellable *cancellable,
104                                                  GError **error);
105 gboolean        camel_stream_eos                (CamelStream *stream);
106
107 /* utility macros and funcs */
108 gssize          camel_stream_write_string       (CamelStream *stream,
109                                                  const gchar *string,
110                                                  GCancellable *cancellable,
111                                                  GError **error);
112
113 /* Write a whole stream to another stream, until eof or error on
114  * either stream.  */
115 gssize          camel_stream_write_to_stream    (CamelStream *stream,
116                                                  CamelStream *output_stream,
117                                                  GCancellable *cancellable,
118                                                  GError **error);
119
120 G_END_DECLS
121
122 #endif /* CAMEL_STREAM_H */