Initialize the gmime for upstream
[platform/upstream/gmime.git] / gmime / gmime-object.h
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*  GMime
3  *  Copyright (C) 2000-2012 Jeffrey Stedfast
4  *
5  *  This library is free software; you can redistribute it and/or
6  *  modify it under the terms of the GNU Lesser General Public License
7  *  as published by the Free Software Foundation; either version 2.1
8  *  of the License, or (at your option) any later version.
9  *
10  *  This library is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  *  Lesser General Public License for more details.
14  *
15  *  You should have received a copy of the GNU Lesser General Public
16  *  License along with this library; if not, write to the Free
17  *  Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
18  *  02110-1301, USA.
19  */
20
21
22 #ifndef __GMIME_OBJECT_H__
23 #define __GMIME_OBJECT_H__
24
25 #include <glib.h>
26 #include <glib-object.h>
27
28 #include <gmime/gmime-content-type.h>
29 #include <gmime/gmime-disposition.h>
30 #include <gmime/gmime-encodings.h>
31 #include <gmime/gmime-stream.h>
32 #include <gmime/gmime-header.h>
33
34 G_BEGIN_DECLS
35
36 #define GMIME_TYPE_OBJECT            (g_mime_object_get_type ())
37 #define GMIME_OBJECT(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMIME_TYPE_OBJECT, GMimeObject))
38 #define GMIME_OBJECT_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GMIME_TYPE_OBJECT, GMimeObjectClass))
39 #define GMIME_IS_OBJECT(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GMIME_TYPE_OBJECT))
40 #define GMIME_IS_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GMIME_TYPE_OBJECT))
41 #define GMIME_OBJECT_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GMIME_TYPE_OBJECT, GMimeObjectClass))
42
43 typedef struct _GMimeObject GMimeObject;
44 typedef struct _GMimeObjectClass GMimeObjectClass;
45
46 /**
47  * GMimeObject:
48  * @parent_object: parent #GObject
49  * @disposition: a #GMimeContentDisposition
50  * @content_type: a #GMimeContentType
51  * @content_id: a Content-Id
52  * @headers: a #GMimeHeaderList
53  *
54  * Base class for all MIME parts.
55  **/
56 struct _GMimeObject {
57         GObject parent_object;
58         
59         GMimeContentDisposition *disposition;
60         GMimeContentType *content_type;
61         GMimeHeaderList *headers;
62         
63         char *content_id;
64 };
65
66 struct _GMimeObjectClass {
67         GObjectClass parent_class;
68         
69         void         (* prepend_header) (GMimeObject *object, const char *header, const char *value);
70         void         (* append_header)  (GMimeObject *object, const char *header, const char *value);
71         void         (* set_header)     (GMimeObject *object, const char *header, const char *value);
72         const char * (* get_header)     (GMimeObject *object, const char *header);
73         gboolean     (* remove_header)  (GMimeObject *object, const char *header);
74         
75         void         (* set_content_type) (GMimeObject *object, GMimeContentType *content_type);
76         
77         char *       (* get_headers)   (GMimeObject *object);
78         
79         ssize_t      (* write_to_stream) (GMimeObject *object, GMimeStream *stream);
80         
81         void         (* encode) (GMimeObject *object, GMimeEncodingConstraint constraint);
82 };
83
84
85 /**
86  * GMimeObjectForeachFunc:
87  * @parent: parent #GMimeObject
88  * @part: a #GMimeObject
89  * @user_data: User-supplied callback data.
90  *
91  * The function signature for a callback to g_mime_message_foreach()
92  * and g_mime_multipart_foreach().
93  **/
94 typedef void (* GMimeObjectForeachFunc) (GMimeObject *parent, GMimeObject *part, gpointer user_data);
95
96
97 GType g_mime_object_get_type (void);
98
99 void g_mime_object_register_type (const char *type, const char *subtype, GType object_type);
100
101 GMimeObject *g_mime_object_new (GMimeContentType *content_type);
102 GMimeObject *g_mime_object_new_type (const char *type, const char *subtype);
103
104 void g_mime_object_set_content_type (GMimeObject *object, GMimeContentType *content_type);
105 GMimeContentType *g_mime_object_get_content_type (GMimeObject *object);
106 void g_mime_object_set_content_type_parameter (GMimeObject *object, const char *name, const char *value);
107 const char *g_mime_object_get_content_type_parameter (GMimeObject *object, const char *name);
108
109 void g_mime_object_set_content_disposition (GMimeObject *object, GMimeContentDisposition *disposition);
110 GMimeContentDisposition *g_mime_object_get_content_disposition (GMimeObject *object);
111
112 void g_mime_object_set_disposition (GMimeObject *object, const char *disposition);
113 const char *g_mime_object_get_disposition (GMimeObject *object);
114
115 void g_mime_object_set_content_disposition_parameter (GMimeObject *object, const char *attribute, const char *value);
116 const char *g_mime_object_get_content_disposition_parameter (GMimeObject *object, const char *attribute);
117
118 void g_mime_object_set_content_id (GMimeObject *object, const char *content_id);
119 const char *g_mime_object_get_content_id (GMimeObject *object);
120
121 void g_mime_object_prepend_header (GMimeObject *object, const char *header, const char *value);
122 void g_mime_object_append_header (GMimeObject *object, const char *header, const char *value);
123 void g_mime_object_set_header (GMimeObject *object, const char *header, const char *value);
124 const char *g_mime_object_get_header (GMimeObject *object, const char *header);
125 gboolean g_mime_object_remove_header (GMimeObject *object, const char *header);
126
127 GMimeHeaderList *g_mime_object_get_header_list (GMimeObject *object);
128
129 char *g_mime_object_get_headers (GMimeObject *object);
130
131 ssize_t g_mime_object_write_to_stream (GMimeObject *object, GMimeStream *stream);
132 char *g_mime_object_to_string (GMimeObject *object);
133
134 void g_mime_object_encode (GMimeObject *object, GMimeEncodingConstraint constraint);
135
136 /* Internal API */
137 G_GNUC_INTERNAL void g_mime_object_type_registry_init (void);
138 G_GNUC_INTERNAL void g_mime_object_type_registry_shutdown (void);
139
140 G_END_DECLS
141
142 #endif /* __GMIME_OBJECT_H__ */