* we were assuming that the source of a 'new folder' thing always
[modest] / src / modest-tny-msg.h
1 /* Copyright (c) 2006, 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  * 
74  * create a new TnyMsg with the given parameters
75  * 
76  * Returns: a new TnyMsg (free with g_object_unref)
77  */      
78 TnyMsg* modest_tny_msg_new (const gchar* mailto, const gchar* mailfrom, const gchar *cc,
79                             const gchar *bcc, const gchar* subject, const gchar *body,
80                             GList *attachments);
81
82 /**
83  * modest_tny_msg_new_html_plain:
84  * @mailto: recipient for the message
85  * @mailfrom: sender of this message
86  * @cc: Cc: address for the message
87  * @bcc: Bcc: address for the message
88  * @subject: subject for the message
89  * @html_body: body for the message in HTML
90  * @plain_body: body for the message in plain text
91  * @attachments: a list of attachments (mime parts)
92  * @attachments: a list of images (mime parts)
93  * 
94  * create a new TnyMsg with the given parameters
95  * 
96  * Returns: a new TnyMsg (free with g_object_unref)
97  */      
98 TnyMsg* modest_tny_msg_new_html_plain (const gchar* mailto, const gchar* mailfrom, const gchar *cc,
99                                        const gchar *bcc, const gchar* subject, 
100                                        const gchar *html_body, const gchar *plain_body,
101                                        GList *attachments, GList *images);
102
103 /**
104  * modest_tny_msg_find_body_part:
105  * @self: a message
106  * @want_html: prefer HTML-part when there are multiple body parts?
107  * 
108  * search a message for the body part. if @want_html is true, try HTML mail
109  * first.
110  * 
111  * Returns: the TnyMsgMimePart for the found part, or NULL if no matching part is found
112  */      
113 TnyMimePart*  modest_tny_msg_find_body_part  (TnyMsg * self, gboolean want_html);
114
115
116 /**
117  * modest_tny_msg_find_body:
118  * @self: some #TnyMsg
119  * @want_html: 
120  * @is_html: if the original body was html or plain text
121  * 
122  * gets the body of a message as text, if @want_html is true, try HTML mail
123  * first.
124  * 
125  * Returns: the body of the message as text, or NULL if it is not found
126  * the text should be freed with 
127  **/
128 gchar*        modest_tny_msg_get_body        (TnyMsg *self, gboolean want_html, gboolean *is_html);
129
130
131
132 /**
133  * modest_tny_msg_get_header:
134  * @self: some #TnyMsg 
135  * @header: the header to get
136  * 
137  * gets the mail header for a #TnyMsg as a newly allocated string,
138  * or NULL if it cannot be found
139  * 
140  * Returns: the header
141  **/
142 gchar*       modest_tny_msg_get_header (TnyMsg *msg, const gchar *header);
143
144
145 /**
146  * modest_tny_msg_create_forward_msg:
147  * @msg: a valid #TnyMsg instance
148  * @from: the sender of the forwarded mail
149  * @signature: signature to attach to the reply
150  * @forward_type: the type of formatting used to create the forwarded message
151  * 
152  * Creates a forwarded message from an existing one
153  * 
154  * Returns: a new #TnyMsg, or NULL in case of error
155  **/
156 TnyMsg*       modest_tny_msg_create_forward_msg   (TnyMsg *msg, 
157                                                    const gchar *from,
158                                                    const gchar *signature,
159                                                    ModestTnyMsgForwardType forward_type);
160
161 /**
162  * modest_tny_msg_create_reply_msg:
163  * @msg: a valid #TnyMsg instance, or %NULL
164  * @header: a valid #TnyHeader instance, or %NULL
165  * @from: the sender of the forwarded mail
166  * @signature: signature to add to the reply message
167  * @reply_type: the type of formatting used to create the reply message
168  * @reply_mode: the mode of reply: to the sender only, to a mail list or to all
169  * 
170  * Creates a new message to reply to an existing one
171  * 
172  * Returns: Returns: a new #TnyMsg, or NULL in case of error
173  **/
174 TnyMsg*       modest_tny_msg_create_reply_msg     (TnyMsg *msg,
175                                                    TnyHeader *header,
176                                                    const gchar *from,
177                                                    const gchar *signature,
178                                                    ModestTnyMsgReplyType reply_type,
179                                                    ModestTnyMsgReplyMode reply_mode);
180
181
182 /**
183  * modest_tny_msg_get_parent_unique_id
184  * @msg: a valid #TnyMsg instance, or %NULL
185  * 
186  * gets the unique ID of the 'parent' (the original msg replied to or forward)
187  * 
188  * Returns: Returns: a the parent uid, or NULL if there is none.
189  **/
190 const gchar*  modest_tny_msg_get_parent_uid (TnyMsg *msg);
191
192
193
194
195 #endif /* __MODEST_TNY_MSG_H__ */