1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ 2 /* GMime 3 * Copyright (C) 2000-2020 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 #include <gmime/gmime-autocrypt.h> 34 #include <gmime/gmime-crypto-context.h> 35 36 G_BEGIN_DECLS 37 38 #define GMIME_TYPE_MESSAGE (g_mime_message_get_type ()) 39 #define GMIME_MESSAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMIME_TYPE_MESSAGE, GMimeMessage)) 40 #define GMIME_MESSAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GMIME_TYPE_MESSAGE, GMimeMessageClass)) 41 #define GMIME_IS_MESSAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GMIME_TYPE_MESSAGE)) 42 #define GMIME_IS_MESSAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GMIME_TYPE_MESSAGE)) 43 #define GMIME_MESSAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GMIME_TYPE_MESSAGE, GMimeMessageClass)) 44 45 typedef struct _GMimeMessage GMimeMessage; 46 typedef struct _GMimeMessageClass GMimeMessageClass; 47 48 49 /** 50 * GMimeAddressType: 51 * @GMIME_ADDRESS_TYPE_SENDER: Represents the addresses in the Sender header. 52 * @GMIME_ADDRESS_TYPE_FROM: Represents the addresses in the From header. 53 * @GMIME_ADDRESS_TYPE_REPLY_TO: Represents the addresses in the Reply-To header. 54 * @GMIME_ADDRESS_TYPE_TO: Represents the recipients in the To header. 55 * @GMIME_ADDRESS_TYPE_CC: Represents the recipients in the Cc header. 56 * @GMIME_ADDRESS_TYPE_BCC: Represents the recipients in the Bcc header. 57 * 58 * An address type. 59 **/ 60 typedef enum _GMimeAddressType { 61 GMIME_ADDRESS_TYPE_SENDER, 62 GMIME_ADDRESS_TYPE_FROM, 63 GMIME_ADDRESS_TYPE_REPLY_TO, 64 GMIME_ADDRESS_TYPE_TO, 65 GMIME_ADDRESS_TYPE_CC, 66 GMIME_ADDRESS_TYPE_BCC, 67 } GMimeAddressType; 68 69 70 /** 71 * GMimeMessage: 72 * @parent_object: parent #GMimeObject 73 * @addrlists: a table of address lists 74 * @mime_part: toplevel MIME part 75 * @message_id: Message-Id string 76 * @date: Date value 77 * @subject: Subject string 78 * 79 * A MIME Message object. 80 **/ 81 struct _GMimeMessage { 82 GMimeObject parent_object; 83 84 InternetAddressList **addrlists; 85 GMimeObject *mime_part; 86 char *message_id; 87 GDateTime *date; 88 char *subject; 89 90 /* <private> */ 91 char *marker; 92 }; 93 94 struct _GMimeMessageClass { 95 GMimeObjectClass parent_class; 96 97 }; 98 99 100 GType g_mime_message_get_type (void); 101 102 GMimeMessage *g_mime_message_new (gboolean pretty_headers); 103 104 InternetAddressList *g_mime_message_get_from (GMimeMessage *message); 105 InternetAddressList *g_mime_message_get_sender (GMimeMessage *message); 106 InternetAddressList *g_mime_message_get_reply_to (GMimeMessage *message); 107 InternetAddressList *g_mime_message_get_to (GMimeMessage *message); 108 InternetAddressList *g_mime_message_get_cc (GMimeMessage *message); 109 InternetAddressList *g_mime_message_get_bcc (GMimeMessage *message); 110 111 void g_mime_message_add_mailbox (GMimeMessage *message, GMimeAddressType type, const char *name, const char *addr); 112 InternetAddressList *g_mime_message_get_addresses (GMimeMessage *message, GMimeAddressType type); 113 InternetAddressList *g_mime_message_get_all_recipients (GMimeMessage *message); 114 115 void g_mime_message_set_subject (GMimeMessage *message, const char *subject, const char *charset); 116 const char *g_mime_message_get_subject (GMimeMessage *message); 117 118 void g_mime_message_set_date (GMimeMessage *message, GDateTime *date); 119 GDateTime *g_mime_message_get_date (GMimeMessage *message); 120 121 void g_mime_message_set_message_id (GMimeMessage *message, const char *message_id); 122 const char *g_mime_message_get_message_id (GMimeMessage *message); 123 124 GMimeObject *g_mime_message_get_mime_part (GMimeMessage *message); 125 void g_mime_message_set_mime_part (GMimeMessage *message, GMimeObject *mime_part); 126 127 GMimeAutocryptHeader *g_mime_message_get_autocrypt_header (GMimeMessage *message, GDateTime *now); 128 GMimeAutocryptHeaderList *g_mime_message_get_autocrypt_gossip_headers (GMimeMessage *message, GDateTime *now, GMimeDecryptFlags flags, const char *session_key, GError **err); 129 GMimeAutocryptHeaderList *g_mime_message_get_autocrypt_gossip_headers_from_inner_part (GMimeMessage *message, GDateTime *now, GMimeObject *inner_part); 130 131 /* convenience functions */ 132 133 void g_mime_message_foreach (GMimeMessage *message, GMimeObjectForeachFunc callback, 134 gpointer user_data); 135 136 GMimeObject *g_mime_message_get_body (GMimeMessage *message); 137 138 G_END_DECLS 139 140 #endif /* __GMIME_MESSAGE_H__ */ 141