1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
|
/*
* e-mail-part-itip.c
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with the program; if not, see <http://www.gnu.org/licenses/>
*
*/
#include "e-mail-part-itip.h"
#define E_MAIL_PART_ITIP_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE \
((obj), E_TYPE_MAIL_PART_ITIP, EMailPartItipPrivate))
struct _EMailPartItipPrivate {
gint placeholder;
};
G_DEFINE_DYNAMIC_TYPE (
EMailPartItip,
e_mail_part_itip,
E_TYPE_MAIL_PART)
static void
mail_part_itip_dispose (GObject *object)
{
EMailPartItip *part = E_MAIL_PART_ITIP (object);
g_cancellable_cancel (part->cancellable);
g_clear_object (&part->cancellable);
g_clear_object (&part->client_cache);
g_clear_object (&part->comp);
g_clear_object (&part->view);
/* Chain up to parent's dispose() method. */
G_OBJECT_CLASS (e_mail_part_itip_parent_class)->dispose (object);
}
static void
mail_part_itip_finalize (GObject *object)
{
EMailPartItip *part = E_MAIL_PART_ITIP (object);
g_free (part->vcalendar);
g_free (part->calendar_uid);
g_free (part->from_address);
g_free (part->from_name);
g_free (part->to_address);
g_free (part->to_name);
g_free (part->delegator_address);
g_free (part->delegator_name);
g_free (part->my_address);
g_free (part->uid);
if (part->top_level != NULL)
icalcomponent_free (part->top_level);
if (part->main_comp != NULL)
icalcomponent_free (part->main_comp);
g_hash_table_destroy (part->real_comps);
/* Chain up to parent's finalize() method. */
G_OBJECT_CLASS (e_mail_part_itip_parent_class)->finalize (object);
}
static void
mail_part_itip_bind_dom_element (EMailPart *part,
WebKitDOMElement *element)
{
GString *buffer;
WebKitDOMDocument *document;
ItipView *view;
EMailPartItip *pitip;
pitip = E_MAIL_PART_ITIP (part);
if (!WEBKIT_DOM_IS_HTML_IFRAME_ELEMENT (element)) {
WebKitDOMNodeList *nodes;
guint ii, length;
nodes = webkit_dom_element_get_elements_by_tag_name (
element, "iframe");
length = webkit_dom_node_list_get_length (nodes);
for (ii = 0; ii < length; ii++) {
element = WEBKIT_DOM_ELEMENT (
webkit_dom_node_list_item (nodes, ii));
break;
}
}
g_return_if_fail (WEBKIT_DOM_IS_HTML_IFRAME_ELEMENT (element));
buffer = g_string_new ("");
document = webkit_dom_html_iframe_element_get_content_document (
WEBKIT_DOM_HTML_IFRAME_ELEMENT (element));
view = itip_view_new (pitip, pitip->client_cache);
g_object_set_data_full (
G_OBJECT (element), "view", view,
(GDestroyNotify) g_object_unref);
itip_view_create_dom_bindings (
view, webkit_dom_document_get_document_element (document));
itip_view_init_view (view);
g_string_free (buffer, TRUE);
}
static void
e_mail_part_itip_class_init (EMailPartItipClass *class)
{
GObjectClass *object_class;
EMailPartClass *mail_part_class;
g_type_class_add_private (class, sizeof (EMailPartItipPrivate));
object_class = G_OBJECT_CLASS (class);
object_class->dispose = mail_part_itip_dispose;
object_class->finalize = mail_part_itip_finalize;
mail_part_class = E_MAIL_PART_CLASS (class);
mail_part_class->bind_dom_element = mail_part_itip_bind_dom_element;
}
static void
e_mail_part_itip_class_finalize (EMailPartItipClass *class)
{
}
static void
e_mail_part_itip_init (EMailPartItip *part)
{
part->priv = E_MAIL_PART_ITIP_GET_PRIVATE (part);
e_mail_part_set_mime_type (E_MAIL_PART (part), "text/calendar");
E_MAIL_PART (part)->force_collapse = TRUE;
}
void
e_mail_part_itip_type_register (GTypeModule *type_module)
{
/* XXX G_DEFINE_DYNAMIC_TYPE declares a static type registration
* function, so we have to wrap it with a public function in
* order to register types from a separate compilation unit. */
e_mail_part_itip_register_type (type_module);
}
EMailPartItip *
e_mail_part_itip_new (CamelMimePart *mime_part,
const gchar *id)
{
g_return_val_if_fail (id != NULL, NULL);
return g_object_new (
E_TYPE_MAIL_PART_ITIP,
"id", id, "mime-part", mime_part, NULL);
}
|