evolution-3.6.4/modules/mail-config/e-mail-config-local-accounts.c

No issues found

Incomplete coverage

Tool Failure ID Location Function Message Data
clang-analyzer no-output-found e-mail-config-local-accounts.c Message(text='Unable to locate XML output from invoke-clang-analyzer') None
clang-analyzer no-output-found e-mail-config-local-accounts.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-local-accounts.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 <config.h>
 20 #include <glib/gi18n-lib.h>
 21 
 22 #include <camel/camel.h>
 23 #include <libebackend/libebackend.h>
 24 
 25 #include <mail/e-mail-config-service-page.h>
 26 
 27 /* Standard GObject macros */
 28 #define E_TYPE_MAIL_CONFIG_LOCAL_BACKEND \
 29 	(e_mail_config_local_backend_get_type ())
 30 #define E_MAIL_CONFIG_LOCAL_BACKEND(obj) \
 31 	(G_TYPE_CHECK_INSTANCE_CAST \
 32 	((obj), E_TYPE_MAIL_CONFIG_LOCAL_BACKEND, EMailConfigLocalBackend))
 33 #define E_MAIL_CONFIG_LOCAL_BACKEND_CLASS(cls) \
 34 	(G_TYPE_CHECK_CLASS_CAST \
 35 	((cls), E_TYPE_MAIL_CONFIG_LOCAL_BACKEND, EMailConfigLocalBackendClass))
 36 #define E_IS_MAIL_CONFIG_LOCAL_BACKEND(obj) \
 37 	(G_TYPE_CHECK_INSTANCE_TYPE \
 38 	((obj), E_TYPE_MAIL_CONFIG_LOCAL_BACKEND))
 39 #define E_IS_MAIL_CONFIG_LOCAL_BACKEND_CLASS(cls) \
 40 	(G_TYPE_CHECK_CLASS_TYPE \
 41 	((cls), E_TYPE_MAIL_CONFIG_LOCAL_BACKEND))
 42 #define E_MAIL_CONFIG_LOCAL_BACKEND_GET_CLASS(obj) \
 43 	(G_TYPE_INSTANCE_GET_CLASS \
 44 	((obj), E_TYPE_MAIL_CONFIG_LOCAL_BACKEND, EMailConfigLocalBackendClass))
 45 
 46 typedef struct _EMailConfigLocalBackend EMailConfigLocalBackend;
 47 typedef struct _EMailConfigLocalBackendClass EMailConfigLocalBackendClass;
 48 
 49 typedef EMailConfigLocalBackend EMailConfigMhBackend;
 50 typedef EMailConfigLocalBackendClass EMailConfigMhBackendClass;
 51 
 52 typedef EMailConfigLocalBackend EMailConfigMboxBackend;
 53 typedef EMailConfigLocalBackendClass EMailConfigMboxBackendClass;
 54 
 55 typedef EMailConfigLocalBackend EMailConfigMaildirBackend;
 56 typedef EMailConfigLocalBackendClass EMailConfigMaildirBackendClass;
 57 
 58 typedef EMailConfigLocalBackend EMailConfigSpoolDirBackend;
 59 typedef EMailConfigLocalBackendClass EMailConfigSpoolDirBackendClass;
 60 
 61 typedef EMailConfigLocalBackend EMailConfigSpoolFileBackend;
 62 typedef EMailConfigLocalBackendClass EMailConfigSpoolFileBackendClass;
 63 
 64 /* XXX For lack of a better place for this... */
 65 typedef EMailConfigServiceBackend EMailConfigNoneBackend;
 66 typedef EMailConfigServiceBackendClass EMailConfigNoneBackendClass;
 67 
 68 struct _EMailConfigLocalBackend {
 69 	EMailConfigServiceBackend parent;
 70 };
 71 
 72 struct _EMailConfigLocalBackendClass {
 73 	EMailConfigServiceBackendClass parent_class;
 74 
 75 	const gchar *file_chooser_label;
 76 	const gchar *file_chooser_title;
 77 	GtkFileChooserAction file_chooser_action;
 78 };
 79 
 80 /* Forward Declarations */
 81 void		e_mail_config_local_accounts_register_types
 82 						(GTypeModule *type_module);
 83 GType		e_mail_config_local_backend_get_type
 84 						(void) G_GNUC_CONST;
 85 GType		e_mail_config_mh_backend_get_type
 86 						(void) G_GNUC_CONST;
 87 GType		e_mail_config_mbox_backend_get_type
 88 						(void) G_GNUC_CONST;
 89 GType		e_mail_config_maildir_backend_get_type
 90 						(void) G_GNUC_CONST;
 91 GType		e_mail_config_spool_dir_backend_get_type
 92 						(void) G_GNUC_CONST;
 93 GType		e_mail_config_spool_file_backend_get_type
 94 						(void) G_GNUC_CONST;
 95 GType		e_mail_config_none_backend_get_type
 96 						(void) G_GNUC_CONST;
 97 
 98 G_DEFINE_DYNAMIC_TYPE_EXTENDED (
 99 	EMailConfigLocalBackend,
100 	e_mail_config_local_backend,
101 	E_TYPE_MAIL_CONFIG_SERVICE_BACKEND,
102 	G_TYPE_FLAG_ABSTRACT,
103 	/* no custom code */)
104 
105 G_DEFINE_DYNAMIC_TYPE (
106 	EMailConfigMhBackend,
107 	e_mail_config_mh_backend,
108 	E_TYPE_MAIL_CONFIG_LOCAL_BACKEND)
109 
110 G_DEFINE_DYNAMIC_TYPE (
111 	EMailConfigMboxBackend,
112 	e_mail_config_mbox_backend,
113 	E_TYPE_MAIL_CONFIG_LOCAL_BACKEND)
114 
115 G_DEFINE_DYNAMIC_TYPE (
116 	EMailConfigMaildirBackend,
117 	e_mail_config_maildir_backend,
118 	E_TYPE_MAIL_CONFIG_LOCAL_BACKEND)
119 
120 G_DEFINE_DYNAMIC_TYPE (
121 	EMailConfigSpoolDirBackend,
122 	e_mail_config_spool_dir_backend,
123 	E_TYPE_MAIL_CONFIG_LOCAL_BACKEND)
124 
125 G_DEFINE_DYNAMIC_TYPE (
126 	EMailConfigSpoolFileBackend,
127 	e_mail_config_spool_file_backend,
128 	E_TYPE_MAIL_CONFIG_LOCAL_BACKEND)
129 
130 /* XXX For lack of a better place for this... */
131 G_DEFINE_DYNAMIC_TYPE (
132 	EMailConfigNoneBackend,
133 	e_mail_config_none_backend,
134 	E_TYPE_MAIL_CONFIG_SERVICE_BACKEND)
135 
136 static void
137 mail_config_local_backend_file_set_cb (GtkFileChooserButton *file_chooser_button,
138                                        CamelLocalSettings *local_settings)
139 {
140 	GtkFileChooser *file_chooser;
141 	gchar *path;
142 
143 	file_chooser = GTK_FILE_CHOOSER (file_chooser_button);
144 
145 	path = gtk_file_chooser_get_filename (file_chooser);
146 	camel_local_settings_set_path (local_settings, path);
147 	g_free (path);
148 }
149 
150 static void
151 mail_config_local_backend_insert_widgets (EMailConfigServiceBackend *backend,
152                                           GtkBox *parent)
153 {
154 	CamelSettings *settings;
155 	EMailConfigLocalBackendClass *class;
156 	GtkLabel *label;
157 	GtkWidget *widget;
158 	GtkWidget *container;
159 	const gchar *path;
160 
161 	class = E_MAIL_CONFIG_LOCAL_BACKEND_GET_CLASS (backend);
162 	settings = e_mail_config_service_backend_get_settings (backend);
163 
164 	widget = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
165 	gtk_box_pack_start (parent, widget, FALSE, FALSE, 0);
166 	gtk_widget_show (widget);
167 
168 	container = widget;
169 
170 	widget = gtk_label_new_with_mnemonic (class->file_chooser_label);
171 	gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
172 	gtk_widget_show (widget);
173 
174 	label = GTK_LABEL (widget);
175 
176 	widget = gtk_file_chooser_button_new (
177 		class->file_chooser_title,
178 		class->file_chooser_action);
179 	gtk_label_set_mnemonic_widget (label, widget);
180 	gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
181 	gtk_widget_show (widget);
182 
183 	g_signal_connect (
184 		widget, "file-set",
185 		G_CALLBACK (mail_config_local_backend_file_set_cb),
186 		CAMEL_LOCAL_SETTINGS (settings));
187 
188 	path = camel_local_settings_get_path (CAMEL_LOCAL_SETTINGS (settings));
189 	if (path != NULL)
190 		gtk_file_chooser_set_filename (
191 			GTK_FILE_CHOOSER (widget), path);
192 }
193 
194 static gboolean
195 mail_config_local_backend_check_complete (EMailConfigServiceBackend *backend)
196 {
197 	CamelSettings *settings;
198 	CamelLocalSettings *local_settings;
199 	const gchar *path;
200 
201 	settings = e_mail_config_service_backend_get_settings (backend);
202 
203 	local_settings = CAMEL_LOCAL_SETTINGS (settings);
204 	path = camel_local_settings_get_path (local_settings);
205 
206 	return (path != NULL && *path != '\0');
207 }
208 
209 static void
210 mail_config_local_backend_commit_changes (EMailConfigServiceBackend *backend)
211 {
212 	/* CamelLocalSettings "path" property is already up-to-date,
213 	 * and it's bound to the appropriate ESourceExtension property,
214 	 * so nothing to do here. */
215 }
216 
217 static void
218 e_mail_config_local_backend_class_init (EMailConfigLocalBackendClass *class)
219 {
220 	EMailConfigServiceBackendClass *backend_class;
221 
222 	backend_class = E_MAIL_CONFIG_SERVICE_BACKEND_CLASS (class);
223 	backend_class->insert_widgets = mail_config_local_backend_insert_widgets;
224 	backend_class->check_complete = mail_config_local_backend_check_complete;
225 	backend_class->commit_changes = mail_config_local_backend_commit_changes;
226 }
227 
228 static void
229 e_mail_config_local_backend_class_finalize (EMailConfigLocalBackendClass *class)
230 {
231 }
232 
233 static void
234 e_mail_config_local_backend_init (EMailConfigLocalBackend *backend)
235 {
236 }
237 
238 static void
239 e_mail_config_mh_backend_class_init (EMailConfigLocalBackendClass *class)
240 {
241 	EMailConfigServiceBackendClass *backend_class;
242 
243 	backend_class = E_MAIL_CONFIG_SERVICE_BACKEND_CLASS (class);
244 	backend_class->backend_name = "mh";
245 
246 	class->file_chooser_label = _("Mail _Directory:");
247 	class->file_chooser_title = _("Choose a MH mail directory");
248 	class->file_chooser_action = GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER;
249 }
250 
251 static void
252 e_mail_config_mh_backend_class_finalize (EMailConfigLocalBackendClass *class)
253 {
254 }
255 
256 static void
257 e_mail_config_mh_backend_init (EMailConfigLocalBackend *backend)
258 {
259 }
260 
261 static void
262 e_mail_config_mbox_backend_class_init (EMailConfigLocalBackendClass *class)
263 {
264 	EMailConfigServiceBackendClass *backend_class;
265 
266 	backend_class = E_MAIL_CONFIG_SERVICE_BACKEND_CLASS (class);
267 	backend_class->backend_name = "mbox";
268 
269 	class->file_chooser_label = _("Local Delivery _File:");
270 	class->file_chooser_title = _("Choose a local delivery file");
271 	class->file_chooser_action = GTK_FILE_CHOOSER_ACTION_OPEN;
272 }
273 
274 static void
275 e_mail_config_mbox_backend_class_finalize (EMailConfigLocalBackendClass *class)
276 {
277 }
278 
279 static void
280 e_mail_config_mbox_backend_init (EMailConfigLocalBackend *backend)
281 {
282 }
283 
284 static void
285 e_mail_config_maildir_backend_class_init (EMailConfigLocalBackendClass *class)
286 {
287 	EMailConfigServiceBackendClass *backend_class;
288 
289 	backend_class = E_MAIL_CONFIG_SERVICE_BACKEND_CLASS (class);
290 	backend_class->backend_name = "maildir";
291 
292 	class->file_chooser_label = _("Mail _Directory:");
293 	class->file_chooser_title = _("Choose a Maildir mail directory");
294 	class->file_chooser_action = GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER;
295 }
296 
297 static void
298 e_mail_config_maildir_backend_class_finalize (EMailConfigLocalBackendClass *class)
299 {
300 }
301 
302 static void
303 e_mail_config_maildir_backend_init (EMailConfigLocalBackend *backend)
304 {
305 }
306 
307 static void
308 e_mail_config_spool_dir_backend_class_init (EMailConfigLocalBackendClass *class)
309 {
310 	EMailConfigServiceBackendClass *backend_class;
311 
312 	backend_class = E_MAIL_CONFIG_SERVICE_BACKEND_CLASS (class);
313 	backend_class->backend_name = "spool";
314 
315 	class->file_chooser_label = _("Spool _File:");
316 	class->file_chooser_title = _("Choose a mbox spool file");
317 	class->file_chooser_action = GTK_FILE_CHOOSER_ACTION_OPEN;
318 }
319 
320 static void
321 e_mail_config_spool_dir_backend_class_finalize (EMailConfigLocalBackendClass *class)
322 {
323 }
324 
325 static void
326 e_mail_config_spool_dir_backend_init (EMailConfigLocalBackend *backend)
327 {
328 }
329 
330 static void
331 e_mail_config_spool_file_backend_class_init (EMailConfigLocalBackendClass *class)
332 {
333 	EMailConfigServiceBackendClass *backend_class;
334 
335 	backend_class = E_MAIL_CONFIG_SERVICE_BACKEND_CLASS (class);
336 	backend_class->backend_name = "spooldir";
337 
338 	class->file_chooser_label = _("Spool _Directory:");
339 	class->file_chooser_title = _("Choose a mbox spool directory");
340 	class->file_chooser_action = GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER;
341 }
342 
343 static void
344 e_mail_config_spool_file_backend_class_finalize (EMailConfigLocalBackendClass *class)
345 {
346 }
347 
348 static void
349 e_mail_config_spool_file_backend_init (EMailConfigLocalBackend *backend)
350 {
351 }
352 
353 static void
354 e_mail_config_none_backend_class_init (EMailConfigServiceBackendClass *class)
355 {
356 	class->backend_name = "none";
357 }
358 
359 static void
360 e_mail_config_none_backend_class_finalize (EMailConfigServiceBackendClass *class)
361 {
362 }
363 
364 static void
365 e_mail_config_none_backend_init (EMailConfigServiceBackend *backend)
366 {
367 }
368 
369 void
370 e_mail_config_local_accounts_register_types (GTypeModule *type_module)
371 {
372 	/* Abstract base type */
373 	e_mail_config_local_backend_register_type (type_module);
374 
375 	/* Concrete sub-types */
376 	e_mail_config_mh_backend_register_type (type_module);
377 	e_mail_config_mbox_backend_register_type (type_module);
378 	e_mail_config_maildir_backend_register_type (type_module);
379 	e_mail_config_spool_dir_backend_register_type (type_module);
380 	e_mail_config_spool_file_backend_register_type (type_module);
381 
382 	/* XXX For lack of a better place for this... */
383 	e_mail_config_none_backend_register_type (type_module);
384 }