evolution-3.6.4/mail/e-mail-config-page.c

No issues found

Incomplete coverage

Tool Failure ID Location Function Message Data
clang-analyzer no-output-found e-mail-config-page.c Message(text='Unable to locate XML output from invoke-clang-analyzer') None
clang-analyzer no-output-found e-mail-config-page.c Message(text='Unable to locate XML output from invoke-clang-analyzer') None
Failure running clang-analyzer ('no-output-found')
Message
Unable to locate XML output from invoke-clang-analyzer
Failure running clang-analyzer ('no-output-found')
Message
Unable to locate XML output from invoke-clang-analyzer
  1 /*
  2  * e-mail-config-page.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 "e-mail-config-page.h"
 20 
 21 #include <config.h>
 22 #include <glib/gi18n-lib.h>
 23 
 24 #include <libedataserver/libedataserver.h>
 25 
 26 #include <e-util/e-marshal.h>
 27 
 28 enum {
 29 	CHANGED,
 30 	SETUP_DEFAULTS,
 31 	CHECK_COMPLETE,
 32 	COMMIT_CHANGES,
 33 	LAST_SIGNAL
 34 };
 35 
 36 static gulong signals[LAST_SIGNAL];
 37 
 38 G_DEFINE_INTERFACE (
 39 	EMailConfigPage,
 40 	e_mail_config_page,
 41 	GTK_TYPE_WIDGET)
 42 
 43 static gboolean
 44 mail_config_page_check_complete (EMailConfigPage *page)
 45 {
 46 	return TRUE;
 47 }
 48 
 49 static gboolean
 50 mail_config_page_submit_sync (EMailConfigPage *page,
 51                               GCancellable *cancellable,
 52                               GError **error)
 53 {
 54 	EAsyncClosure *closure;
 55 	GAsyncResult *result;
 56 	gboolean success;
 57 
 58 	closure = e_async_closure_new ();
 59 
 60 	e_mail_config_page_submit (
 61 		page, cancellable, e_async_closure_callback, closure);
 62 
 63 	result = e_async_closure_wait (closure);
 64 
 65 	success = e_mail_config_page_submit_finish (page, result, error);
 66 
 67 	e_async_closure_free (closure);
 68 
 69 	return success;
 70 }
 71 
 72 static void
 73 mail_config_page_submit (EMailConfigPage *page,
 74                          GCancellable *cancellable,
 75                          GAsyncReadyCallback callback,
 76                          gpointer user_data)
 77 {
 78 	GSimpleAsyncResult *simple;
 79 
 80 	simple = g_simple_async_result_new (
 81 		G_OBJECT (page), callback,
 82 		user_data, mail_config_page_submit);
 83 
 84 	g_simple_async_result_set_check_cancellable (simple, cancellable);
 85 
 86 	g_simple_async_result_complete_in_idle (simple);
 87 
 88 	g_object_unref (simple);
 89 }
 90 
 91 static gboolean
 92 mail_config_page_submit_finish (EMailConfigPage *page,
 93                                 GAsyncResult *result,
 94                                 GError **error)
 95 {
 96 	GSimpleAsyncResult *simple;
 97 
 98 	g_return_val_if_fail (
 99 		g_simple_async_result_is_valid (
100 		result, G_OBJECT (page), mail_config_page_submit), FALSE);
101 
102 	simple = G_SIMPLE_ASYNC_RESULT (result);
103 
104 	/* Assume success unless a GError is set. */
105 	return !g_simple_async_result_propagate_error (simple, error);
106 }
107 
108 static gboolean
109 mail_config_page_check_complete_accumulator (GSignalInvocationHint *ihint,
110                                              GValue *return_accu,
111                                              const GValue *handler_return,
112                                              gpointer unused)
113 {
114 	gboolean v_boolean;
115 
116 	/* Abort emission if a handler returns FALSE. */
117 	v_boolean = g_value_get_boolean (handler_return);
118 	g_value_set_boolean (return_accu, v_boolean);
119 
120 	return v_boolean;
121 }
122 
123 static void
124 e_mail_config_page_default_init (EMailConfigPageInterface *interface)
125 {
126 	interface->title = _("Untitled");
127 	interface->page_type = GTK_ASSISTANT_PAGE_CONTENT;
128 
129 	interface->check_complete = mail_config_page_check_complete;
130 	interface->submit_sync = mail_config_page_submit_sync;
131 	interface->submit = mail_config_page_submit;
132 	interface->submit_finish = mail_config_page_submit_finish;
133 
134 	signals[CHANGED] = g_signal_new (
135 		"changed",
136 		G_TYPE_FROM_INTERFACE (interface),
137 		G_SIGNAL_RUN_LAST,
138 		G_STRUCT_OFFSET (EMailConfigPageInterface, changed),
139 		NULL, NULL,
140 		g_cclosure_marshal_VOID__VOID,
141 		G_TYPE_NONE, 0);
142 
143 	signals[SETUP_DEFAULTS] = g_signal_new (
144 		"setup-defaults",
145 		G_TYPE_FROM_INTERFACE (interface),
146 		G_SIGNAL_RUN_LAST,
147 		G_STRUCT_OFFSET (EMailConfigPageInterface, setup_defaults),
148 		NULL, NULL,
149 		g_cclosure_marshal_VOID__VOID,
150 		G_TYPE_NONE, 0);
151 
152 	signals[CHECK_COMPLETE] = g_signal_new (
153 		"check-complete",
154 		G_TYPE_FROM_INTERFACE (interface),
155 		G_SIGNAL_RUN_LAST,
156 		G_STRUCT_OFFSET (EMailConfigPageInterface, check_complete),
157 		mail_config_page_check_complete_accumulator, NULL,
158 		e_marshal_BOOLEAN__VOID,
159 		G_TYPE_BOOLEAN, 0);
160 
161 	signals[COMMIT_CHANGES] = g_signal_new (
162 		"commit-changes",
163 		G_TYPE_FROM_INTERFACE (interface),
164 		G_SIGNAL_RUN_LAST,
165 		G_STRUCT_OFFSET (EMailConfigPageInterface, commit_changes),
166 		NULL, NULL,
167 		g_cclosure_marshal_VOID__POINTER,
168 		G_TYPE_NONE, 1,
169 		G_TYPE_POINTER);
170 }
171 
172 gint
173 e_mail_config_page_compare (GtkWidget *page_a,
174                             GtkWidget *page_b)
175 {
176 	EMailConfigPageInterface *interface_a = NULL;
177 	EMailConfigPageInterface *interface_b = NULL;
178 
179 	if (E_IS_MAIL_CONFIG_PAGE (page_a))
180 		interface_a = E_MAIL_CONFIG_PAGE_GET_INTERFACE (page_a);
181 
182 	if (E_IS_MAIL_CONFIG_PAGE (page_b))
183 		interface_b = E_MAIL_CONFIG_PAGE_GET_INTERFACE (page_b);
184 
185 	if (interface_a == interface_b)
186 		return 0;
187 
188 	if (interface_a != NULL && interface_b == NULL)
189 		return -1;
190 
191 	if (interface_a == NULL && interface_b != NULL)
192 		return 1;
193 
194 	if (interface_a->sort_order < interface_b->sort_order)
195 		return -1;
196 
197 	if (interface_a->sort_order > interface_b->sort_order)
198 		return 1;
199 
200 	return 0;
201 }
202 
203 void
204 e_mail_config_page_changed (EMailConfigPage *page)
205 {
206 	g_return_if_fail (E_IS_MAIL_CONFIG_PAGE (page));
207 
208 	g_signal_emit (page, signals[CHANGED], 0);
209 }
210 
211 void
212 e_mail_config_page_setup_defaults (EMailConfigPage *page)
213 {
214 	g_return_if_fail (E_IS_MAIL_CONFIG_PAGE (page));
215 
216 	g_signal_emit (page, signals[SETUP_DEFAULTS], 0);
217 }
218 
219 gboolean
220 e_mail_config_page_check_complete (EMailConfigPage *page)
221 {
222 	gboolean complete;
223 
224 	g_return_val_if_fail (E_IS_MAIL_CONFIG_PAGE (page), FALSE);
225 
226 	g_signal_emit (page, signals[CHECK_COMPLETE], 0, &complete);
227 
228 	return complete;
229 }
230 
231 void
232 e_mail_config_page_commit_changes (EMailConfigPage *page,
233                                    GQueue *source_queue)
234 {
235 	g_return_if_fail (E_IS_MAIL_CONFIG_PAGE (page));
236 	g_return_if_fail (source_queue != NULL);
237 
238 	g_signal_emit (page, signals[COMMIT_CHANGES], 0, source_queue);
239 }
240 
241 gboolean
242 e_mail_config_page_submit_sync (EMailConfigPage *page,
243                                 GCancellable *cancellable,
244                                 GError **error)
245 {
246 	EMailConfigPageInterface *interface;
247 
248 	g_return_val_if_fail (E_IS_MAIL_CONFIG_PAGE (page), FALSE);
249 
250 	interface = E_MAIL_CONFIG_PAGE_GET_INTERFACE (page);
251 	g_return_val_if_fail (interface->submit_sync != NULL, FALSE);
252 
253 	return interface->submit_sync (page, cancellable, error);
254 }
255 
256 void
257 e_mail_config_page_submit (EMailConfigPage *page,
258                            GCancellable *cancellable,
259                            GAsyncReadyCallback callback,
260                            gpointer user_data)
261 {
262 	EMailConfigPageInterface *interface;
263 
264 	g_return_if_fail (E_IS_MAIL_CONFIG_PAGE (page));
265 
266 	interface = E_MAIL_CONFIG_PAGE_GET_INTERFACE (page);
267 	g_return_if_fail (interface->submit != NULL);
268 
269 	return interface->submit (page, cancellable, callback, user_data);
270 }
271 
272 gboolean
273 e_mail_config_page_submit_finish (EMailConfigPage *page,
274                                   GAsyncResult *result,
275                                   GError **error)
276 {
277 	EMailConfigPageInterface *interface;
278 
279 	g_return_val_if_fail (E_IS_MAIL_CONFIG_PAGE (page), FALSE);
280 	g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
281 
282 	interface = E_MAIL_CONFIG_PAGE_GET_INTERFACE (page);
283 	g_return_val_if_fail (interface->submit_finish != NULL, FALSE);
284 
285 	return interface->submit_finish (page, result, error);
286 }