Added the function that quotes emails
[modest] / src / widgets / modest-msg-view.c
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 #include <config.h>
31
32 #include <widgets/modest-msg-view.h>
33 #include <widgets/modest-isearch-view.h>
34 #include <modest-marshal.h>
35
36 enum {
37         ATTACHMENT_CLICKED_SIGNAL,
38         RECPT_ACTIVATED_SIGNAL,
39         LINK_CONTEXTUAL_SIGNAL,
40         FETCH_IMAGE_SIGNAL,
41         SHOW_DETAILS_SIGNAL,
42         LIMIT_ERROR_SIGNAL,
43         LAST_SIGNAL
44 };
45 static guint signals[LAST_SIGNAL] = {0};
46
47 void
48 modest_msg_view_set_msg_with_other_body (ModestMsgView *self, TnyMsg *msg, TnyMimePart *part)
49 {
50         return MODEST_MSG_VIEW_GET_IFACE (self)->set_msg_with_other_body_func (self, msg, part);
51 }
52
53 GtkAdjustment*
54 modest_msg_view_get_vadjustment (ModestMsgView *self)
55 {
56         return MODEST_MSG_VIEW_GET_IFACE (self)->get_vadjustment_func (self);
57 }
58
59 GtkAdjustment*
60 modest_msg_view_get_hadjustment (ModestMsgView *self)
61 {
62         return MODEST_MSG_VIEW_GET_IFACE (self)->get_hadjustment_func (self);
63 }
64
65 void
66 modest_msg_view_set_vadjustment (ModestMsgView *self, GtkAdjustment *vadj)
67 {
68         MODEST_MSG_VIEW_GET_IFACE (self)->set_vadjustment_func (self, vadj);
69 }
70
71 void
72 modest_msg_view_set_hadjustment (ModestMsgView *self, GtkAdjustment *hadj)
73 {
74         MODEST_MSG_VIEW_GET_IFACE (self)->set_hadjustment_func (self, hadj);
75 }
76
77 void
78 modest_msg_view_set_shadow_type (ModestMsgView *self, GtkShadowType type)
79 {
80         MODEST_MSG_VIEW_GET_IFACE (self)->set_shadow_type_func (self, type);
81 }
82
83 GtkShadowType
84 modest_msg_view_get_shadow_type (ModestMsgView *self)
85 {
86         return MODEST_MSG_VIEW_GET_IFACE (self)->get_shadow_type_func (self);
87 }
88
89 TnyHeaderFlags
90 modest_msg_view_get_priority (ModestMsgView *self)
91 {
92         return MODEST_MSG_VIEW_GET_IFACE (self)->get_priority_func (self);
93 }
94
95 void
96 modest_msg_view_set_priority (ModestMsgView *self, TnyHeaderFlags flags)
97 {
98         MODEST_MSG_VIEW_GET_IFACE (self)->set_priority_func (self, flags);
99 }
100
101 void
102 modest_msg_view_set_view_images (ModestMsgView *self, gboolean view_images)
103 {
104         MODEST_MSG_VIEW_GET_IFACE (self)->set_view_images_func (self, view_images);
105 }
106
107 TnyList*
108 modest_msg_view_get_selected_attachments (ModestMsgView *self)
109 {
110         return MODEST_MSG_VIEW_GET_IFACE (self)->get_selected_attachments_func (self);
111 }
112
113 TnyList*
114 modest_msg_view_get_attachments (ModestMsgView *self)
115 {
116         return MODEST_MSG_VIEW_GET_IFACE (self)->get_attachments_func (self);
117 }
118
119 void
120 modest_msg_view_grab_focus (ModestMsgView *self)
121 {
122         MODEST_MSG_VIEW_GET_IFACE (self)->grab_focus_func (self);
123 }
124
125 void
126 modest_msg_view_remove_attachment (ModestMsgView *self, TnyMimePart *attachment)
127 {
128         MODEST_MSG_VIEW_GET_IFACE (self)->remove_attachment_func (self, attachment);
129 }
130
131 void
132 modest_msg_view_set_branding (ModestMsgView *self, const gchar *brand_name, const GdkPixbuf *brand_icon)
133 {
134         MODEST_MSG_VIEW_GET_IFACE (self)->set_branding_func (self, brand_name, brand_icon);
135 }
136
137 void
138 modest_msg_view_request_fetch_images (ModestMsgView *self)
139 {
140         MODEST_MSG_VIEW_GET_IFACE (self)->request_fetch_images_func (self);
141 }
142
143 gboolean
144 modest_msg_view_has_blocked_external_images (ModestMsgView *self)
145 {
146         return MODEST_MSG_VIEW_GET_IFACE (self)->has_blocked_external_images_func (self);
147 }
148
149 static void
150 modest_msg_view_base_init (gpointer g_class)
151 {
152         static gboolean initialized = FALSE;
153
154         if (!initialized) {
155                 
156                 signals[ATTACHMENT_CLICKED_SIGNAL] =
157                         g_signal_new ("attachment_clicked",
158                                       MODEST_TYPE_MSG_VIEW,
159                                       G_SIGNAL_RUN_FIRST,
160                                       G_STRUCT_OFFSET(ModestMsgViewIface, attachment_clicked),
161                                       NULL, NULL,
162                                       g_cclosure_marshal_VOID__OBJECT,
163                                       G_TYPE_NONE, 1, G_TYPE_OBJECT);
164                 
165                 signals[RECPT_ACTIVATED_SIGNAL] =
166                         g_signal_new ("recpt_activated",
167                                       MODEST_TYPE_MSG_VIEW,
168                                       G_SIGNAL_RUN_FIRST,
169                                       G_STRUCT_OFFSET(ModestMsgViewIface, recpt_activated),
170                                       NULL, NULL,
171                                       g_cclosure_marshal_VOID__STRING,
172                                       G_TYPE_NONE, 1, G_TYPE_STRING);
173                 
174                 signals[LINK_CONTEXTUAL_SIGNAL] =
175                         g_signal_new ("link_contextual",
176                                       MODEST_TYPE_MSG_VIEW,
177                                       G_SIGNAL_RUN_FIRST,
178                                       G_STRUCT_OFFSET(ModestMsgViewIface, link_contextual),
179                                       NULL, NULL,
180                                       g_cclosure_marshal_VOID__STRING,
181                                       G_TYPE_NONE, 1, G_TYPE_STRING);
182                 
183                 signals[FETCH_IMAGE_SIGNAL] =
184                         g_signal_new ("fetch_image",
185                                       MODEST_TYPE_MSG_VIEW,
186                                       G_SIGNAL_ACTION | G_SIGNAL_RUN_LAST,
187                                       G_STRUCT_OFFSET(ModestMsgViewIface, fetch_image),
188                                       NULL, NULL,
189                                       modest_marshal_BOOLEAN__STRING_OBJECT,
190                                       G_TYPE_BOOLEAN, 2, G_TYPE_STRING, G_TYPE_OBJECT);
191                 
192                 signals[SHOW_DETAILS_SIGNAL] =
193                         g_signal_new ("show_details",
194                                       MODEST_TYPE_MSG_VIEW,
195                                       G_SIGNAL_RUN_FIRST,
196                                       G_STRUCT_OFFSET(ModestMsgViewIface, show_details),
197                                       NULL, NULL,
198                                       g_cclosure_marshal_VOID__VOID,
199                                       G_TYPE_NONE, 0);
200                 
201                 signals[LIMIT_ERROR_SIGNAL] =
202                         g_signal_new ("limit_error",
203                                       MODEST_TYPE_MSG_VIEW,
204                                       G_SIGNAL_RUN_FIRST,
205                                       G_STRUCT_OFFSET(ModestMsgViewIface, limit_error),
206                                       NULL, NULL,
207                                       g_cclosure_marshal_VOID__VOID,
208                                       G_TYPE_NONE, 0);
209                 
210                 initialized = TRUE;
211         }
212 }
213
214 GType
215 modest_msg_view_get_type (void)
216 {
217         static GType my_type = 0;
218         if (!my_type) {
219                 static const GTypeInfo my_info = {
220                         sizeof(ModestMsgViewIface),
221                         modest_msg_view_base_init,   /* base init */
222                         NULL,           /* base finalize */
223                         NULL,           /* class_init */
224                         NULL,           /* class finalize */
225                         NULL,           /* class data */
226                         0,
227                         0,              /* n_preallocs */
228                         NULL,           /* instance_init */
229                         NULL
230                 };
231
232                 my_type = g_type_register_static (G_TYPE_INTERFACE,
233                                                   "ModestMsgView",
234                                                   &my_info, 0);
235
236                 g_type_interface_add_prerequisite (my_type,
237                                                    MODEST_TYPE_ZOOMABLE);
238                 g_type_interface_add_prerequisite (my_type,
239                                                    MODEST_TYPE_ISEARCH_VIEW);
240                 g_type_interface_add_prerequisite (my_type,
241                                                    TNY_TYPE_MIME_PART_VIEW);
242                 g_type_interface_add_prerequisite (my_type,
243                                                    TNY_TYPE_HEADER_VIEW);
244                 g_type_interface_add_prerequisite (my_type,
245                                                    MODEST_TYPE_MIME_PART_VIEW);
246
247         }
248         return my_type;
249 }