1 /* Copyright (c) 2006, 2007, 2008 Nokia Corporation
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * * Neither the name of the Nokia Corporation nor the names of its
14 * contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
18 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
20 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
21 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #ifndef __MODEST_TNY_MSG_H__
31 #define __MODEST_TNY_MSG_H__
34 * ModestTnyMsgForwardType:
36 * How the original message will be forwarded to the recipient
38 typedef enum _ModestTnyMsgForwardType {
39 MODEST_TNY_MSG_FORWARD_TYPE_INLINE = 1,
40 MODEST_TNY_MSG_FORWARD_TYPE_ATTACHMENT
41 } ModestTnyMsgForwardType;
44 * ModestTnyMsgReplyType:
46 * How the original message will be forwarded to the recipient
48 typedef enum _ModestTnyMsgReplyType {
49 MODEST_TNY_MSG_REPLY_TYPE_CITE = 1,
50 MODEST_TNY_MSG_REPLY_TYPE_QUOTE
51 } ModestTnyMsgReplyType;
54 * ModestTnyMsgReplyMode:
56 * Who will be the recipients of the replied message
58 typedef enum _ModestTnyMsgReplyMode {
59 MODEST_TNY_MSG_REPLY_MODE_SENDER,
60 MODEST_TNY_MSG_REPLY_MODE_LIST,
61 MODEST_TNY_MSG_REPLY_MODE_ALL
62 } ModestTnyMsgReplyMode;
66 * @mailto: recipient for the message
67 * @mailfrom: sender of this message
68 * @cc: Cc: address for the message
69 * @bcc: Bcc: address for the message
70 * @subject: subject for the messdage
71 * @body: body for the message
72 * @attachments: a list of attachments (local URIs)
73 * @attached: a #gint pointer, returns the number of attachments really included.
74 * @error: a pointer for errors in message creation
76 * create a new TnyMsg with the given parameters
78 * Returns: a new TnyMsg (free with g_object_unref)
80 TnyMsg* modest_tny_msg_new (const gchar* mailto, const gchar* mailfrom, const gchar *cc,
81 const gchar *bcc, const gchar* subject, const gchar *body,
82 GList *attachments, gint *attached, GError **err);
85 * modest_tny_msg_new_html_plain:
86 * @mailto: recipient for the message
87 * @mailfrom: sender of this message
88 * @cc: Cc: address for the message
89 * @bcc: Bcc: address for the message
90 * @subject: subject for the message
91 * @html_body: body for the message in HTML
92 * @plain_body: body for the message in plain text
93 * @attachments: a list of attachments (mime parts)
94 * @images: a list of images (mime parts)
95 * @attached: a #gint pointer, returns the number of attachments really included.
96 * @error: a pointer for errors in message creation
98 * create a new TnyMsg with the given parameters
100 * Returns: a new TnyMsg (free with g_object_unref)
102 TnyMsg* modest_tny_msg_new_html_plain (const gchar* mailto, const gchar* mailfrom, const gchar *cc,
103 const gchar *bcc, const gchar* subject,
104 const gchar *html_body, const gchar *plain_body,
105 GList *attachments, GList *images, gint *attached, GError **err);
108 * modest_tny_msg_find_body_part:
110 * @want_html: prefer HTML-part when there are multiple body parts?
112 * search a message for the body part. if @want_html is true, try HTML mail
115 * Returns: the TnyMsgMimePart for the found part, or NULL if no matching part is found
117 TnyMimePart* modest_tny_msg_find_body_part (TnyMsg * self, gboolean want_html);
121 * modest_tny_msg_find_body:
122 * @self: some #TnyMsg
124 * @is_html: if the original body was html or plain text
126 * gets the body of a message as text, if @want_html is true, try HTML mail
129 * Returns: the body of the message as text, or NULL if it is not found
130 * the text should be freed with
132 gchar* modest_tny_msg_get_body (TnyMsg *self, gboolean want_html, gboolean *is_html);
138 * modest_tny_msg_create_forward_msg:
139 * @msg: a valid #TnyMsg instance
140 * @from: the sender of the forwarded mail
141 * @signature: signature to attach to the reply
142 * @forward_type: the type of formatting used to create the forwarded message
144 * Creates a forwarded message from an existing one
146 * Returns: a new #TnyMsg, or NULL in case of error
148 TnyMsg* modest_tny_msg_create_forward_msg (TnyMsg *msg,
150 const gchar *signature,
151 ModestTnyMsgForwardType forward_type);
154 * modest_tny_msg_create_reply_msg:
155 * @msg: a valid #TnyMsg instance, or %NULL
156 * @header: a valid #TnyHeader instance, or %NULL
157 * @from: the sender of the forwarded mail
158 * @signature: signature to add to the reply message
159 * @reply_type: the type of formatting used to create the reply message
160 * @reply_mode: the mode of reply: to the sender only, to a mail list or to all
162 * Creates a new message to reply to an existing one
164 * Returns: Returns: a new #TnyMsg, or NULL in case of error
166 TnyMsg* modest_tny_msg_create_reply_msg (TnyMsg *msg,
169 const gchar *signature,
170 ModestTnyMsgReplyType reply_type,
171 ModestTnyMsgReplyMode reply_mode);
175 * modest_tny_msg_get_parent_unique_id
176 * @msg: a valid #TnyMsg instance, or %NULL
178 * gets the unique ID of the 'parent' (the original msg replied to or forward)
180 * Returns: Returns: a the parent uid, or NULL if there is none.
182 const gchar* modest_tny_msg_get_parent_uid (TnyMsg *msg);
186 * modest_tny_msg_estimate_size:
187 * @plain_body: a string
188 * @html_body: a string
189 * @parts_number: a gint (number of additional parts)
190 * @parts_size: a guint64 (sum of size of the additional parts)
192 * Estimates the size of the resulting message obtained from the size of the body
193 * parts, and adding the estimation of size headers.
196 modest_tny_msg_estimate_size (const gchar *plain_body, const gchar *html_body,
201 * modest_tny_msg_get_all_recipients_list:
204 * Obtains a list of all the addresses available in a message header.
206 * Returns: a newly allocated #GSList of strings. Caller should free strings and list.
209 modest_tny_msg_get_all_recipients_list (TnyMsg *msg);
212 #endif /* __MODEST_TNY_MSG_H__ */