Initialize the gmime for upstream
[platform/upstream/gmime.git] / gmime / gmime-message.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_MESSAGE_H__
23 #define __GMIME_MESSAGE_H__
24
25 #include <stdarg.h>
26 #include <time.h>
27
28 #include <gmime/internet-address.h>
29 #include <gmime/gmime-encodings.h>
30 #include <gmime/gmime-object.h>
31 #include <gmime/gmime-header.h>
32 #include <gmime/gmime-stream.h>
33
34 G_BEGIN_DECLS
35
36 #define GMIME_TYPE_MESSAGE            (g_mime_message_get_type ())
37 #define GMIME_MESSAGE(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMIME_TYPE_MESSAGE, GMimeMessage))
38 #define GMIME_MESSAGE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GMIME_TYPE_MESSAGE, GMimeMessageClass))
39 #define GMIME_IS_MESSAGE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GMIME_TYPE_MESSAGE))
40 #define GMIME_IS_MESSAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GMIME_TYPE_MESSAGE))
41 #define GMIME_MESSAGE_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GMIME_TYPE_MESSAGE, GMimeMessageClass))
42
43 typedef struct _GMimeMessage GMimeMessage;
44 typedef struct _GMimeMessageClass GMimeMessageClass;
45
46
47 /**
48  * GMimeRecipientType:
49  * @GMIME_RECIPIENT_TYPE_TO: Represents the recipients in the To: header.
50  * @GMIME_RECIPIENT_TYPE_CC: Represents the recipients in the Cc: header.
51  * @GMIME_RECIPIENT_TYPE_BCC: Represents the recipients in the Bcc: header.
52  *
53  * A message recipient type.
54  **/
55 typedef enum _GMimeRecipientType {
56         GMIME_RECIPIENT_TYPE_TO,
57         GMIME_RECIPIENT_TYPE_CC,
58         GMIME_RECIPIENT_TYPE_BCC
59 } GMimeRecipientType;
60
61
62 /**
63  * GMimeMessage:
64  * @parent_object: parent #GMimeObject
65  * @mime_part: toplevel MIME part
66  * @recipients: hash table of recipients using recipient header name as the hash key
67  * @message_id: Message-Id string
68  * @reply_to: Reply-To string
69  * @subject: Subject string
70  * @from: From string
71  * @date: Date value
72  * @tz_offset: timezone offset
73  *
74  * A MIME Message object.
75  **/
76 struct _GMimeMessage {
77         GMimeObject parent_object;
78         
79         InternetAddressList **recipients;
80         GMimeObject *mime_part;
81         char *message_id;
82         char *reply_to;
83         char *subject;
84         char *from;
85         
86         time_t date;
87         int tz_offset;
88 };
89
90 struct _GMimeMessageClass {
91         GMimeObjectClass parent_class;
92         
93 };
94
95
96 GType g_mime_message_get_type (void);
97
98 GMimeMessage *g_mime_message_new (gboolean pretty_headers);
99
100 void g_mime_message_set_sender (GMimeMessage *message, const char *sender);
101 const char *g_mime_message_get_sender (GMimeMessage *message);
102
103 void g_mime_message_set_reply_to (GMimeMessage *message, const char *reply_to);
104 const char *g_mime_message_get_reply_to (GMimeMessage *message);
105
106 void g_mime_message_add_recipient (GMimeMessage *message, GMimeRecipientType type, const char *name, const char *addr);
107 InternetAddressList *g_mime_message_get_recipients (GMimeMessage *message, GMimeRecipientType type);
108 InternetAddressList *g_mime_message_get_all_recipients (GMimeMessage *message);
109
110 void g_mime_message_set_subject (GMimeMessage *message, const char *subject);
111 const char *g_mime_message_get_subject (GMimeMessage *message);
112
113 void g_mime_message_set_date (GMimeMessage *message, time_t date, int tz_offset);
114 void g_mime_message_get_date (GMimeMessage *message, time_t *date, int *tz_offset);
115 void g_mime_message_set_date_as_string (GMimeMessage *message, const char *str);
116 char *g_mime_message_get_date_as_string (GMimeMessage *message);
117
118 void g_mime_message_set_message_id (GMimeMessage *message, const char *message_id);
119 const char *g_mime_message_get_message_id (GMimeMessage *message);
120
121 GMimeObject *g_mime_message_get_mime_part (GMimeMessage *message);
122 void g_mime_message_set_mime_part (GMimeMessage *message, GMimeObject *mime_part);
123
124 /* convenience functions */
125
126 void g_mime_message_foreach (GMimeMessage *message, GMimeObjectForeachFunc callback,
127                              gpointer user_data);
128
129 GMimeObject *g_mime_message_get_body (GMimeMessage *message);
130
131 G_END_DECLS
132
133 #endif /* __GMIME_MESSAGE_H__ */