No issues found
Tool | Failure ID | Location | Function | Message | Data |
---|---|---|---|---|---|
clang-analyzer | no-output-found | e-mail-part-list.c | Message(text='Unable to locate XML output from invoke-clang-analyzer') | None | |
clang-analyzer | no-output-found | e-mail-part-list.c | Message(text='Unable to locate XML output from invoke-clang-analyzer') | None |
1 /*
2 * e-mail-part-list.c
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) version 3.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with the program; if not, see <http://www.gnu.org/licenses/>
16 *
17 */
18
19 #include <camel/camel.h>
20
21 #include "e-mail-part-list.h"
22
23 G_DEFINE_TYPE (EMailPartList, e_mail_part_list, G_TYPE_OBJECT)
24
25 static CamelObjectBag *registry = NULL;
26 G_LOCK_DEFINE_STATIC (registry);
27
28 static void
29 unref_mail_part (gpointer user_data)
30 {
31 if (user_data)
32 e_mail_part_unref (user_data);
33 }
34
35 static void
36 e_mail_part_list_finalize (GObject *object)
37 {
38 EMailPartList *part_list = E_MAIL_PART_LIST (object);
39
40 g_clear_object (&part_list->folder);
41 g_clear_object (&part_list->message);
42
43 if (part_list->list) {
44 g_slist_free_full (part_list->list, unref_mail_part);
45 part_list->list = NULL;
46 }
47
48 if (part_list->message_uid) {
49 g_free (part_list->message_uid);
50 part_list->message_uid = NULL;
51 }
52
53 G_OBJECT_CLASS (e_mail_part_list_parent_class)->finalize (object);
54 }
55
56 static void
57 e_mail_part_list_class_init (EMailPartListClass *class)
58 {
59 GObjectClass *object_class;
60
61 object_class = G_OBJECT_CLASS (class);
62 object_class->finalize = e_mail_part_list_finalize;
63 }
64
65 static void
66 e_mail_part_list_init (EMailPartList *part_list)
67 {
68
69 }
70
71 EMailPartList *
72 e_mail_part_list_new ()
73 {
74 return g_object_new (E_TYPE_MAIL_PART_LIST, NULL);
75 }
76
77 EMailPart *
78 e_mail_part_list_find_part (EMailPartList *part_list,
79 const gchar *id)
80 {
81 GSList *iter;
82 gboolean by_cid;
83
84 g_return_val_if_fail (E_IS_MAIL_PART_LIST (part_list), NULL);
85 g_return_val_if_fail (id && *id, NULL);
86
87 by_cid = (g_str_has_prefix (id, "cid:") || g_str_has_prefix (id, "CID:"));
88
89 for (iter = part_list->list; iter; iter = iter->next) {
90
91 EMailPart *part = iter->data;
92 if (!part)
93 continue;
94
95 if ((by_cid && (g_strcmp0 (part->cid, id) == 0)) ||
96 (!by_cid && (g_strcmp0 (part->id, id) == 0)))
97 return part;
98 }
99
100 return NULL;
101 }
102
103 /**
104 * e_mail_part_list_get_iter:
105 * @part_list: a #GSList of #EMailPart
106 * @id: id of #EMailPart to lookup
107 *
108 * Returns iter of an #EMailPart within the @part_list.
109 *
110 * Return Value: a #GSList sublist. The list is owned by #EMailPartList and
111 * must not be freed or altered.
112 */
113 GSList *
114 e_mail_part_list_get_iter (GSList *list,
115 const gchar *id)
116 {
117 GSList *iter;
118
119 g_return_val_if_fail (list != NULL, NULL);
120 g_return_val_if_fail (id && *id, NULL);
121
122 for (iter = list; iter; iter = iter->next) {
123
124 EMailPart *part = iter->data;
125 if (!part)
126 continue;
127
128 if (g_strcmp0 (part->id, id) == 0)
129 return iter;
130 }
131
132 return NULL;
133 }
134
135 /**
136 * e_mail_part_list_get_registry:
137 *
138 * Returns a #CamelObjectBag where parsed #EMailPartLists can be stored.
139 */
140 CamelObjectBag *
141 e_mail_part_list_get_registry (void)
142 {
143 G_LOCK (registry);
144 if (registry == NULL) {
145 registry = camel_object_bag_new (
146 g_str_hash, g_str_equal,
147 (CamelCopyFunc) g_strdup, g_free);
148 }
149 G_UNLOCK (registry);
150
151 return registry;
152 }