1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 * Copyright (C) 2000-2012 Jeffrey Stedfast
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.
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.
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
22 #ifndef __GMIME_OBJECT_H__
23 #define __GMIME_OBJECT_H__
26 #include <glib-object.h>
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>
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))
43 typedef struct _GMimeObject GMimeObject;
44 typedef struct _GMimeObjectClass GMimeObjectClass;
48 * @parent_object: parent #GObject
49 * @disposition: a #GMimeContentDisposition
50 * @content_type: a #GMimeContentType
51 * @content_id: a Content-Id
52 * @headers: a #GMimeHeaderList
54 * Base class for all MIME parts.
57 GObject parent_object;
59 GMimeContentDisposition *disposition;
60 GMimeContentType *content_type;
61 GMimeHeaderList *headers;
66 struct _GMimeObjectClass {
67 GObjectClass parent_class;
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);
75 void (* set_content_type) (GMimeObject *object, GMimeContentType *content_type);
77 char * (* get_headers) (GMimeObject *object);
79 ssize_t (* write_to_stream) (GMimeObject *object, GMimeStream *stream);
81 void (* encode) (GMimeObject *object, GMimeEncodingConstraint constraint);
86 * GMimeObjectForeachFunc:
87 * @parent: parent #GMimeObject
88 * @part: a #GMimeObject
89 * @user_data: User-supplied callback data.
91 * The function signature for a callback to g_mime_message_foreach()
92 * and g_mime_multipart_foreach().
94 typedef void (* GMimeObjectForeachFunc) (GMimeObject *parent, GMimeObject *part, gpointer user_data);
97 GType g_mime_object_get_type (void);
99 void g_mime_object_register_type (const char *type, const char *subtype, GType object_type);
101 GMimeObject *g_mime_object_new (GMimeContentType *content_type);
102 GMimeObject *g_mime_object_new_type (const char *type, const char *subtype);
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);
109 void g_mime_object_set_content_disposition (GMimeObject *object, GMimeContentDisposition *disposition);
110 GMimeContentDisposition *g_mime_object_get_content_disposition (GMimeObject *object);
112 void g_mime_object_set_disposition (GMimeObject *object, const char *disposition);
113 const char *g_mime_object_get_disposition (GMimeObject *object);
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);
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);
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);
127 GMimeHeaderList *g_mime_object_get_header_list (GMimeObject *object);
129 char *g_mime_object_get_headers (GMimeObject *object);
131 ssize_t g_mime_object_write_to_stream (GMimeObject *object, GMimeStream *stream);
132 char *g_mime_object_to_string (GMimeObject *object);
134 void g_mime_object_encode (GMimeObject *object, GMimeEncodingConstraint constraint);
137 G_GNUC_INTERNAL void g_mime_object_type_registry_init (void);
138 G_GNUC_INTERNAL void g_mime_object_type_registry_shutdown (void);
142 #endif /* __GMIME_OBJECT_H__ */