Change version number for dbus api after adding the GetUnreadMessages signal
[modest] / src / modest-tny-msg.h
1 /* Copyright (c) 2006, 2007, 2008 Nokia Corporation
2  * All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7  *
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.
16  *
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.
28  */
29
30 #ifndef __MODEST_TNY_MSG_H__
31 #define __MODEST_TNY_MSG_H__
32
33 /**
34  * ModestTnyMsgForwardType:
35  *
36  * How the original message will be forwarded to the recipient
37  */
38 typedef enum _ModestTnyMsgForwardType {
39         MODEST_TNY_MSG_FORWARD_TYPE_INLINE = 1,
40         MODEST_TNY_MSG_FORWARD_TYPE_ATTACHMENT
41 } ModestTnyMsgForwardType;
42
43 /**
44  * ModestTnyMsgReplyType:
45  *
46  * How the original message will be forwarded to the recipient
47  */
48 typedef enum _ModestTnyMsgReplyType {
49         MODEST_TNY_MSG_REPLY_TYPE_CITE = 1,
50         MODEST_TNY_MSG_REPLY_TYPE_QUOTE
51 } ModestTnyMsgReplyType;
52
53 /**
54  * ModestTnyMsgReplyMode:
55  *
56  * Who will be the recipients of the replied message
57  */
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;
63
64 /**
65  * modest_tny_msg_new:
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
75  * 
76  * create a new TnyMsg with the given parameters
77  * 
78  * Returns: a new TnyMsg (free with g_object_unref)
79  */      
80 TnyMsg* modest_tny_msg_new (const gchar* mailto, const gchar* mailfrom, const gchar *cc,
81                             const gchar *bcc, const gchar* subject, 
82                             const gchar *references, const gchar *in_reply_to,
83                             const gchar *body,
84                             GList *attachments, gint *attached, GError **err);
85
86 /**
87  * modest_tny_msg_new_html_plain:
88  * @mailto: recipient for the message
89  * @mailfrom: sender of this message
90  * @cc: Cc: address for the message
91  * @bcc: Bcc: address for the message
92  * @subject: subject for the message
93  * @html_body: body for the message in HTML
94  * @plain_body: body for the message in plain text
95  * @attachments: a list of attachments (mime parts)
96  * @images: a list of images (mime parts)
97  * @attached: a #gint pointer, returns the number of attachments really included.
98  * @error: a pointer for errors in message creation
99  * 
100  * create a new TnyMsg with the given parameters
101  * 
102  * Returns: a new TnyMsg (free with g_object_unref)
103  */      
104 TnyMsg* modest_tny_msg_new_html_plain (const gchar* mailto, const gchar* mailfrom, const gchar *cc,
105                                        const gchar *bcc, const gchar* subject,
106                                        const gchar *references, const gchar *in_reply_to,
107                                        const gchar *html_body, const gchar *plain_body,
108                                        GList *attachments, GList *images, gint *attached, GError **err);
109
110 /**
111  * modest_tny_msg_find_body_part:
112  * @self: a message
113  * @want_html: prefer HTML-part when there are multiple body parts?
114  * 
115  * search a message for the body part. if @want_html is true, try HTML mail
116  * first.
117  * 
118  * Returns: the TnyMsgMimePart for the found part, or NULL if no matching part is found
119  */      
120 TnyMimePart*  modest_tny_msg_find_body_part  (TnyMsg * self, gboolean want_html);
121
122 /**
123  * modest_tny_msg_find_calendar_part:
124  * @self: a message
125  * 
126  * search a message for the calendar part.
127  * 
128  * Returns: the TnyMimePart for the found part, or NULL if no matching part is found
129  */      
130 TnyMimePart* modest_tny_msg_find_calendar (TnyMsg *self);
131
132
133 /**
134  * modest_tny_msg_find_body:
135  * @self: some #TnyMsg
136  * @want_html: 
137  * @is_html: if the original body was html or plain text
138  * 
139  * gets the body of a message as text, if @want_html is true, try HTML mail
140  * first.
141  * 
142  * Returns: the body of the message as text, or NULL if it is not found
143  * the text should be freed with 
144  **/
145 gchar*        modest_tny_msg_get_body        (TnyMsg *self, gboolean want_html, gboolean *is_html);
146
147
148
149
150 /**
151  * modest_tny_msg_create_forward_msg:
152  * @msg: a valid #TnyMsg instance
153  * @from: the sender of the forwarded mail
154  * @signature: signature to attach to the reply
155  * @forward_type: the type of formatting used to create the forwarded message
156  * 
157  * Creates a forwarded message from an existing one
158  * 
159  * Returns: a new #TnyMsg, or NULL in case of error
160  **/
161 TnyMsg*       modest_tny_msg_create_forward_msg   (TnyMsg *msg, 
162                                                    const gchar *from,
163                                                    const gchar *signature,
164                                                    ModestTnyMsgForwardType forward_type);
165
166 /**
167  * modest_tny_msg_create_reply_calendar_msg:
168  * @msg: a valid #TnyMsg instance, or %NULL
169  * @header: a valid #TnyHeader instance, or %NULL
170  * @from: the sender of the forwarded mail
171  * @signature: signature to add to the reply message
172  * @headers: #TnyList of #TnyPair with the headers to add
173  * 
174  * Creates a new message to reply to a calendar event
175  * 
176  * Returns: Returns: a new #TnyMsg, or NULL in case of error
177  **/
178 TnyMsg*       modest_tny_msg_create_reply_calendar_msg     (TnyMsg *msg,
179                                                             TnyHeader *header,
180                                                             const gchar *from,
181                                                             const gchar *signature,
182                                                             TnyList *headers);
183
184 /**
185  * modest_tny_msg_create_reply_msg:
186  * @msg: a valid #TnyMsg instance, or %NULL
187  * @header: a valid #TnyHeader instance, or %NULL
188  * @from: the sender of the forwarded mail
189  * @signature: signature to add to the reply message
190  * @reply_type: the type of formatting used to create the reply message
191  * @reply_mode: the mode of reply: to the sender only, to a mail list or to all
192  * 
193  * Creates a new message to reply to an existing one
194  * 
195  * Returns: Returns: a new #TnyMsg, or NULL in case of error
196  **/
197 TnyMsg*       modest_tny_msg_create_reply_msg     (TnyMsg *msg,
198                                                    TnyHeader *header,
199                                                    const gchar *from,
200                                                    const gchar *signature,
201                                                    ModestTnyMsgReplyType reply_type,
202                                                    ModestTnyMsgReplyMode reply_mode);
203
204
205 /**
206  * modest_tny_msg_get_parent_unique_id
207  * @msg: a valid #TnyMsg instance, or %NULL
208  * 
209  * gets the unique ID of the 'parent' (the original msg replied to or forward)
210  * 
211  * Returns: Returns: a the parent uid, or NULL if there is none.
212  **/
213 const gchar*  modest_tny_msg_get_parent_uid (TnyMsg *msg);
214
215
216 /**
217  * modest_tny_msg_estimate_size:
218  * @plain_body: a string
219  * @html_body: a string
220  * @parts_number: a gint (number of additional parts)
221  * @parts_size: a guint64 (sum of size of the additional parts)
222  *
223  * Estimates the size of the resulting message obtained from the size of the body
224  * parts, and adding the estimation of size headers.
225  */
226 guint64
227 modest_tny_msg_estimate_size (const gchar *plain_body, const gchar *html_body,
228                               guint64 parts_count,
229                               guint64 parts_size);
230
231 /**
232  * modest_tny_msg_get_all_recipients_list:
233  * @header: a #TnyHeader
234  *
235  * Obtains a list of all the addresses available in @header.
236  *
237  * Returns: a newly allocated #GSList of strings. Caller should free strings and list.
238  */
239 GSList *
240 modest_tny_msg_header_get_all_recipients_list (TnyHeader *header);
241
242 /**
243  * modest_tny_msg_get_all_recipients_list:
244  * @msg: a #TnyMsg
245  *
246  * Obtains a list of all the addresses available in a message header.
247  *
248  * Returns: a newly allocated #GSList of strings. Caller should free strings and list.
249  */
250 GSList *
251 modest_tny_msg_get_all_recipients_list (TnyMsg *msg);
252
253 /**
254  * modest_tny_msg_get_references:
255  * @msg: a #TnyMsg
256  * @message_id: a pointer to a string
257  * @references: a pointer to a string
258  * @in_reply_to: a pointer to a string
259  *
260  * obtains the Message-ID, References and In-Reply-To fields of a
261  * message
262  */
263 void modest_tny_msg_get_references (TnyMsg *msg, gchar **message_id, gchar **references, gchar **in_reply_to);
264
265 /**
266  * modest_tny_msg_get_attachments_parent:
267  * @msg: a #TnyMsg
268  *
269  * the mime part of the message attachments should be below
270  *
271  * Returns: the mime part (ref owned by caller)
272  */
273 TnyMimePart *modest_tny_msg_get_attachments_parent (TnyMsg *msg);
274
275
276 #endif /* __MODEST_TNY_MSG_H__ */