1 /*
2  * e-mail-config-remote-accounts.c
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
11  * for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program; if not, see <http://www.gnu.org/licenses/>.
15  *
16  */
17 
18 #include "evolution-config.h"
19 
20 #include <glib/gi18n-lib.h>
21 
22 #include <camel/camel.h>
23 #include <libebackend/libebackend.h>
24 
25 #include <mail/e-mail-config-auth-check.h>
26 #include <mail/e-mail-config-service-page.h>
27 
28 /* Standard GObject macros */
29 #define E_TYPE_MAIL_CONFIG_REMOTE_BACKEND \
30 	(e_mail_config_remote_backend_get_type ())
31 #define E_MAIL_CONFIG_REMOTE_BACKEND(obj) \
32 	(G_TYPE_CHECK_INSTANCE_CAST \
33 	((obj), E_TYPE_MAIL_CONFIG_REMOTE_BACKEND, EMailConfigRemoteBackend))
34 #define E_MAIL_CONFIG_REMOTE_BACKEND_CLASS(cls) \
35 	(G_TYPE_CHECK_CLASS_CAST \
36 	((cls), E_TYPE_MAIL_CONFIG_REMOTE_BACKEND, EMailConfigRemoteBackendClass))
37 #define E_IS_MAIL_CONFIG_REMOTE_BACKEND(obj) \
38 	(G_TYPE_CHECK_INSTANCE_TYPE \
39 	((obj), E_TYPE_MAIL_CONFIG_REMOTE_BACKEND))
40 #define E_IS_MAIL_CONFIG_REMOTE_BACKEND_CLASS(cls) \
41 	(G_TYPE_CHECK_CLASS_TYPE \
42 	((cls), E_TYPE_MAIL_CONFIG_REMOTE_BACKEND))
43 #define E_MAIL_CONFIG_REMOTE_BACKEND_GET_CLASS(obj) \
44 	(G_TYPE_INSTANCE_GET_CLASS \
45 	((obj), E_TYPE_MAIL_CONFIG_REMOTE_BACKEND, EMailConfigRemoteBackendClass))
46 
47 typedef struct _EMailConfigRemoteBackend EMailConfigRemoteBackend;
48 typedef struct _EMailConfigRemoteBackendClass EMailConfigRemoteBackendClass;
49 
50 typedef EMailConfigRemoteBackend EMailConfigPopBackend;
51 typedef EMailConfigRemoteBackendClass EMailConfigPopBackendClass;
52 
53 typedef EMailConfigRemoteBackend EMailConfigNntpBackend;
54 typedef EMailConfigRemoteBackendClass EMailConfigNntpBackendClass;
55 
56 typedef EMailConfigRemoteBackend EMailConfigImapxBackend;
57 typedef EMailConfigRemoteBackendClass EMailConfigImapxBackendClass;
58 
59 struct _EMailConfigRemoteBackend {
60 	EMailConfigServiceBackend parent;
61 
62 	GtkWidget *host_entry;		/* not referenced */
63 	GtkWidget *port_entry;		/* not referenced */
64 	GtkWidget *port_error_image;	/* not referenced */
65 	GtkWidget *user_entry;		/* not referenced */
66 	GtkWidget *forget_password_btn;	/* not referenced */
67 	GtkWidget *security_combo_box;	/* not referenced */
68 	GtkWidget *auth_check;		/* not referenced */
69 
70 	GCancellable *cancellable;
71 };
72 
73 struct _EMailConfigRemoteBackendClass {
74 	EMailConfigServiceBackendClass parent_class;
75 };
76 
77 /* Forward Declarations */
78 void		e_mail_config_remote_accounts_register_types
79 						(GTypeModule *type_module);
80 GType		e_mail_config_remote_backend_get_type
81 						(void) G_GNUC_CONST;
82 GType		e_mail_config_pop_backend_get_type
83 						(void) G_GNUC_CONST;
84 GType		e_mail_config_nntp_backend_get_type
85 						(void) G_GNUC_CONST;
86 GType		e_mail_config_imapx_backend_get_type
87 						(void) G_GNUC_CONST;
88 
89 G_DEFINE_DYNAMIC_TYPE_EXTENDED (
90 	EMailConfigRemoteBackend,
91 	e_mail_config_remote_backend,
92 	E_TYPE_MAIL_CONFIG_SERVICE_BACKEND,
93 	G_TYPE_FLAG_ABSTRACT,
94 	/* no custom code */)
95 
G_DEFINE_DYNAMIC_TYPE(EMailConfigPopBackend,e_mail_config_pop_backend,E_TYPE_MAIL_CONFIG_REMOTE_BACKEND)96 G_DEFINE_DYNAMIC_TYPE (
97 	EMailConfigPopBackend,
98 	e_mail_config_pop_backend,
99 	E_TYPE_MAIL_CONFIG_REMOTE_BACKEND)
100 
101 G_DEFINE_DYNAMIC_TYPE (
102 	EMailConfigNntpBackend,
103 	e_mail_config_nntp_backend,
104 	E_TYPE_MAIL_CONFIG_REMOTE_BACKEND)
105 
106 G_DEFINE_DYNAMIC_TYPE (
107 	EMailConfigImapxBackend,
108 	e_mail_config_imapx_backend,
109 	E_TYPE_MAIL_CONFIG_REMOTE_BACKEND)
110 
111 static void
112 source_lookup_password_done (GObject *source,
113 			     GAsyncResult *result,
114 			     gpointer user_data)
115 {
116 	gchar *password = NULL;
117 
118 	g_return_if_fail (E_IS_SOURCE (source));
119 	g_return_if_fail (result != NULL);
120 
121 	if (e_source_lookup_password_finish (E_SOURCE (source), result, &password, NULL)) {
122 		if (password && *password && E_IS_MAIL_CONFIG_REMOTE_BACKEND (user_data)) {
123 			EMailConfigRemoteBackend *remote_backend = user_data;
124 
125 			gtk_widget_show (remote_backend->forget_password_btn);
126 		}
127 
128 		e_util_safe_free_string (password);
129 	}
130 }
131 
132 static void
source_delete_password_done(GObject * source,GAsyncResult * result,gpointer user_data)133 source_delete_password_done (GObject *source,
134 			     GAsyncResult *result,
135 			     gpointer user_data)
136 {
137 	GError *error = NULL;
138 
139 	g_return_if_fail (E_IS_SOURCE (source));
140 	g_return_if_fail (result != NULL);
141 
142 	if (e_source_delete_password_finish (E_SOURCE (source), result, &error)) {
143 		if (E_IS_MAIL_CONFIG_REMOTE_BACKEND (user_data)) {
144 			EMailConfigRemoteBackend *remote_backend = user_data;
145 
146 			gtk_widget_set_sensitive (remote_backend->forget_password_btn, FALSE);
147 		}
148 	} else if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
149 		g_warning ("%s: Failed to forget password: %s", G_STRFUNC, error ? error->message : "Unknown error");
150 	}
151 
152 	g_clear_error (&error);
153 }
154 
155 static void
remote_backend_forget_password_cb(GtkWidget * button,EMailConfigRemoteBackend * remote_backend)156 remote_backend_forget_password_cb (GtkWidget *button,
157 				   EMailConfigRemoteBackend *remote_backend)
158 {
159 	ESource *source;
160 
161 	g_return_if_fail (E_IS_MAIL_CONFIG_REMOTE_BACKEND (remote_backend));
162 
163 	source = e_mail_config_service_backend_get_source (E_MAIL_CONFIG_SERVICE_BACKEND (remote_backend));
164 
165 	e_source_delete_password (source, remote_backend->cancellable, source_delete_password_done, remote_backend);
166 }
167 
168 static void
mail_config_remote_backend_insert_widgets(EMailConfigServiceBackend * backend,GtkBox * parent)169 mail_config_remote_backend_insert_widgets (EMailConfigServiceBackend *backend,
170                                            GtkBox *parent)
171 {
172 	EMailConfigRemoteBackend *remote_backend;
173 	CamelProvider *provider;
174 	CamelSettings *settings;
175 	ESource *source, *existing_source;
176 	ESourceBackend *extension;
177 	EMailConfigServicePage *page;
178 	EMailConfigServicePageClass *class;
179 	GtkLabel *label;
180 	GtkWidget *widget;
181 	GtkWidget *container;
182 	const gchar *backend_name;
183 	const gchar *extension_name;
184 	const gchar *text;
185 	gchar *markup;
186 
187 	remote_backend = E_MAIL_CONFIG_REMOTE_BACKEND (backend);
188 
189 	page = e_mail_config_service_backend_get_page (backend);
190 	source = e_mail_config_service_backend_get_source (backend);
191 	settings = e_mail_config_service_backend_get_settings (backend);
192 	existing_source = e_source_registry_ref_source (e_mail_config_service_page_get_registry (page), e_source_get_uid (source));
193 
194 	class = E_MAIL_CONFIG_SERVICE_PAGE_GET_CLASS (page);
195 	extension_name = class->extension_name;
196 	extension = e_source_get_extension (source, extension_name);
197 	backend_name = e_source_backend_get_backend_name (extension);
198 
199 	text = _("Configuration");
200 	markup = g_markup_printf_escaped ("<b>%s</b>", text);
201 	widget = gtk_label_new (markup);
202 	gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
203 	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
204 	gtk_box_pack_start (GTK_BOX (parent), widget, FALSE, FALSE, 0);
205 	gtk_widget_show (widget);
206 	g_free (markup);
207 
208 	widget = gtk_grid_new ();
209 	gtk_widget_set_margin_left (widget, 12);
210 	gtk_grid_set_row_spacing (GTK_GRID (widget), 6);
211 	gtk_grid_set_column_spacing (GTK_GRID (widget), 6);
212 	gtk_box_pack_start (GTK_BOX (parent), widget, FALSE, FALSE, 0);
213 	gtk_widget_show (widget);
214 
215 	container = widget;
216 
217 	widget = gtk_label_new_with_mnemonic (_("_Server:"));
218 	gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
219 	gtk_grid_attach (GTK_GRID (container), widget, 0, 0, 1, 1);
220 	gtk_widget_show (widget);
221 
222 	label = GTK_LABEL (widget);
223 
224 	widget = gtk_entry_new ();
225 	gtk_widget_set_hexpand (widget, TRUE);
226 	gtk_label_set_mnemonic_widget (label, widget);
227 	gtk_grid_attach (GTK_GRID (container), widget, 1, 0, 1, 1);
228 	remote_backend->host_entry = widget;  /* do not reference */
229 	gtk_widget_show (widget);
230 
231 	widget = gtk_label_new_with_mnemonic (_("_Port:"));
232 	gtk_grid_attach (GTK_GRID (container), widget, 2, 0, 1, 1);
233 	gtk_widget_show (widget);
234 
235 	label = GTK_LABEL (widget);
236 
237 	widget = e_port_entry_new ();
238 	gtk_label_set_mnemonic_widget (label, widget);
239 	gtk_grid_attach (GTK_GRID (container), widget, 3, 0, 1, 1);
240 	remote_backend->port_entry = widget;  /* do not reference */
241 	gtk_widget_show (widget);
242 
243 	widget = gtk_image_new_from_icon_name ("dialog-warning", GTK_ICON_SIZE_BUTTON);
244 	g_object_set (G_OBJECT (widget),
245 		"visible", FALSE,
246 		"has-tooltip", TRUE,
247 		"tooltip-text", _("Port number is not valid"),
248 		NULL);
249 	gtk_grid_attach (GTK_GRID (container), widget, 4, 0, 1, 1);
250 	remote_backend->port_error_image = widget;  /* do not reference */
251 
252 	widget = gtk_label_new_with_mnemonic (_("User_name:"));
253 	gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
254 	gtk_grid_attach (GTK_GRID (container), widget, 0, 1, 1, 1);
255 	gtk_widget_show (widget);
256 
257 	label = GTK_LABEL (widget);
258 
259 	widget = gtk_entry_new ();
260 	gtk_widget_set_hexpand (widget, TRUE);
261 	gtk_label_set_mnemonic_widget (label, widget);
262 	gtk_grid_attach (GTK_GRID (container), widget, 1, 1, 4, 1);
263 	remote_backend->user_entry = widget;  /* do not reference */
264 	gtk_widget_show (widget);
265 
266 	widget = gtk_button_new_with_mnemonic (_("_Forget password"));
267 	gtk_widget_set_halign (widget, GTK_ALIGN_START);
268 	gtk_widget_set_hexpand (widget, FALSE);
269 	gtk_grid_attach (GTK_GRID (container), widget, 1, 2, 4, 1);
270 	remote_backend->forget_password_btn = widget; /* do not reference */
271 	gtk_widget_hide (widget);
272 
273 	text = _("Security");
274 	markup = g_markup_printf_escaped ("<b>%s</b>", text);
275 	widget = gtk_label_new (markup);
276 	gtk_widget_set_margin_top (widget, 6);
277 	gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
278 	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
279 	gtk_box_pack_start (GTK_BOX (parent), widget, FALSE, FALSE, 0);
280 	gtk_widget_show (widget);
281 	g_free (markup);
282 
283 	widget = gtk_grid_new ();
284 	gtk_widget_set_margin_left (widget, 12);
285 	gtk_grid_set_row_spacing (GTK_GRID (widget), 6);
286 	gtk_grid_set_column_spacing (GTK_GRID (widget), 6);
287 	gtk_box_pack_start (GTK_BOX (parent), widget, FALSE, FALSE, 0);
288 	gtk_widget_show (widget);
289 
290 	container = widget;
291 
292 	widget = gtk_label_new_with_mnemonic (_("Encryption _method:"));
293 	gtk_grid_attach (GTK_GRID (container), widget, 0, 0, 1, 1);
294 	gtk_widget_show (widget);
295 
296 	label = GTK_LABEL (widget);
297 
298 	/* The IDs correspond to the CamelNetworkSecurityMethod enum. */
299 	widget = gtk_combo_box_text_new ();
300 	gtk_combo_box_text_append (
301 		GTK_COMBO_BOX_TEXT (widget),
302 		"none",
303 		_("No encryption"));
304 	gtk_combo_box_text_append (
305 		GTK_COMBO_BOX_TEXT (widget),
306 		"starttls-on-standard-port",
307 		_("STARTTLS after connecting"));
308 	gtk_combo_box_text_append (
309 		GTK_COMBO_BOX_TEXT (widget),
310 		"ssl-on-alternate-port",
311 		_("TLS on a dedicated port"));
312 	gtk_label_set_mnemonic_widget (label, widget);
313 	gtk_widget_set_halign (widget, GTK_ALIGN_START);
314 	gtk_grid_attach (GTK_GRID (container), widget, 1, 0, 1, 1);
315 	remote_backend->security_combo_box = widget;  /* do not reference */
316 	gtk_widget_show (widget);
317 
318 	provider = camel_provider_get (backend_name, NULL);
319 	if (provider != NULL && provider->port_entries != NULL)
320 		e_port_entry_set_camel_entries (
321 			E_PORT_ENTRY (remote_backend->port_entry),
322 			provider->port_entries);
323 
324 	text = _("Authentication");
325 	markup = g_markup_printf_escaped ("<b>%s</b>", text);
326 	widget = gtk_label_new (markup);
327 	gtk_widget_set_margin_top (widget, 6);
328 	gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
329 	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
330 	gtk_box_pack_start (GTK_BOX (parent), widget, FALSE, FALSE, 0);
331 	gtk_widget_show (widget);
332 	g_free (markup);
333 
334 	widget = e_mail_config_auth_check_new (backend);
335 	gtk_widget_set_margin_left (widget, 12);
336 	gtk_box_pack_start (GTK_BOX (parent), widget, FALSE, FALSE, 0);
337 	remote_backend->auth_check = widget;  /* do not reference */
338 	gtk_widget_show (widget);
339 
340 	g_signal_connect (remote_backend->forget_password_btn, "clicked",
341 		G_CALLBACK (remote_backend_forget_password_cb), remote_backend);
342 
343 	e_binding_bind_object_text_property (
344 		settings, "host",
345 		remote_backend->host_entry, "text",
346 		G_BINDING_BIDIRECTIONAL |
347 		G_BINDING_SYNC_CREATE);
348 
349 	e_binding_bind_property_full (
350 		settings, "security-method",
351 		remote_backend->security_combo_box, "active-id",
352 		G_BINDING_BIDIRECTIONAL |
353 		G_BINDING_SYNC_CREATE,
354 		e_binding_transform_enum_value_to_nick,
355 		e_binding_transform_enum_nick_to_value,
356 		NULL, (GDestroyNotify) NULL);
357 
358 	e_binding_bind_property (
359 		settings, "port",
360 		remote_backend->port_entry, "port",
361 		G_BINDING_BIDIRECTIONAL |
362 		G_BINDING_SYNC_CREATE);
363 
364 	e_binding_bind_property (
365 		settings, "security-method",
366 		remote_backend->port_entry, "security-method",
367 		G_BINDING_SYNC_CREATE);
368 
369 	e_binding_bind_object_text_property (
370 		settings, "user",
371 		remote_backend->user_entry, "text",
372 		G_BINDING_BIDIRECTIONAL |
373 		G_BINDING_SYNC_CREATE);
374 
375 	/* Don't use G_BINDING_SYNC_CREATE here since the widget
376 	 * chooses its initial mechanism more intelligently than
377 	 * a simple property binding would. */
378 	e_binding_bind_property (
379 		settings, "auth-mechanism",
380 		remote_backend->auth_check, "active-mechanism",
381 		G_BINDING_BIDIRECTIONAL);
382 
383 	if (!existing_source) {
384 		/* Default to TLS for new accounts */
385 		g_object_set (G_OBJECT (settings),
386 			"security-method", CAMEL_NETWORK_SECURITY_METHOD_SSL_ON_ALTERNATE_PORT,
387 			NULL);
388 	}
389 
390 	g_clear_object (&existing_source);
391 
392 	e_source_lookup_password (source, remote_backend->cancellable, source_lookup_password_done, remote_backend);
393 }
394 
395 static gboolean
mail_config_remote_backend_check_complete(EMailConfigServiceBackend * backend)396 mail_config_remote_backend_check_complete (EMailConfigServiceBackend *backend)
397 {
398 	EMailConfigRemoteBackend *remote_backend;
399 	CamelSettings *settings;
400 	CamelNetworkSettings *network_settings;
401 	CamelProvider *provider;
402 	EPortEntry *port_entry;
403 	const gchar *host;
404 	const gchar *user;
405 	gboolean correct, complete = TRUE;
406 
407 	remote_backend = E_MAIL_CONFIG_REMOTE_BACKEND (backend);
408 
409 	settings = e_mail_config_service_backend_get_settings (backend);
410 	provider = e_mail_config_service_backend_get_provider (backend);
411 
412 	g_return_val_if_fail (provider != NULL, FALSE);
413 
414 	network_settings = CAMEL_NETWORK_SETTINGS (settings);
415 	host = camel_network_settings_get_host (network_settings);
416 	user = camel_network_settings_get_user (network_settings);
417 
418 	correct = TRUE;
419 
420 	if (CAMEL_PROVIDER_NEEDS (provider, CAMEL_URL_PART_HOST) &&
421 	    (host == NULL || *host == '\0'))
422 		correct = FALSE;
423 
424 	complete = complete && correct;
425 	e_util_set_entry_issue_hint (remote_backend->host_entry, correct ? NULL : _("Server address cannot be empty"));
426 
427 	correct = TRUE;
428 
429 	port_entry = E_PORT_ENTRY (remote_backend->port_entry);
430 	if (CAMEL_PROVIDER_NEEDS (provider, CAMEL_URL_PART_PORT) &&
431 	    !e_port_entry_is_valid (port_entry))
432 		correct = FALSE;
433 
434 	complete = complete && correct;
435 	gtk_widget_set_visible (remote_backend->port_error_image, !correct);
436 
437 	correct = TRUE;
438 
439 	if (CAMEL_PROVIDER_NEEDS (provider, CAMEL_URL_PART_USER) &&
440 	    (user == NULL || *user == '\0'))
441 		correct = FALSE;
442 
443 	complete = complete && correct;
444 	e_util_set_entry_issue_hint (remote_backend->user_entry, correct ? NULL : _("User name cannot be empty"));
445 
446 	return complete;
447 }
448 
449 static void
mail_config_remote_backend_commit_changes(EMailConfigServiceBackend * backend)450 mail_config_remote_backend_commit_changes (EMailConfigServiceBackend *backend)
451 {
452 	/* All CamelNetworkSettings properties are already up-to-date,
453 	 * and these properties are bound to ESourceExtension properties,
454 	 * so nothing to do here. */
455 }
456 
457 static void
mail_config_remote_backend_dispose(GObject * object)458 mail_config_remote_backend_dispose (GObject *object)
459 {
460 	EMailConfigRemoteBackend *remote_backend = E_MAIL_CONFIG_REMOTE_BACKEND (object);
461 
462 	if (remote_backend->cancellable) {
463 		g_cancellable_cancel (remote_backend->cancellable);
464 		g_clear_object (&remote_backend->cancellable);
465 	}
466 
467 	/* Chain up to parent's method. */
468 	G_OBJECT_CLASS (e_mail_config_remote_backend_parent_class)->dispose (object);
469 }
470 
471 static void
e_mail_config_remote_backend_class_init(EMailConfigRemoteBackendClass * class)472 e_mail_config_remote_backend_class_init (EMailConfigRemoteBackendClass *class)
473 {
474 	EMailConfigServiceBackendClass *backend_class;
475 	GObjectClass *object_class;
476 
477 	backend_class = E_MAIL_CONFIG_SERVICE_BACKEND_CLASS (class);
478 	backend_class->insert_widgets = mail_config_remote_backend_insert_widgets;
479 	backend_class->check_complete = mail_config_remote_backend_check_complete;
480 	backend_class->commit_changes = mail_config_remote_backend_commit_changes;
481 
482 	object_class = G_OBJECT_CLASS (class);
483 	object_class->dispose = mail_config_remote_backend_dispose;
484 }
485 
486 static void
e_mail_config_remote_backend_class_finalize(EMailConfigRemoteBackendClass * class)487 e_mail_config_remote_backend_class_finalize (EMailConfigRemoteBackendClass *class)
488 {
489 }
490 
491 static void
e_mail_config_remote_backend_init(EMailConfigRemoteBackend * backend)492 e_mail_config_remote_backend_init (EMailConfigRemoteBackend *backend)
493 {
494 	backend->cancellable = g_cancellable_new ();
495 }
496 
497 static gboolean
mail_config_pop_backend_auto_configure(EMailConfigServiceBackend * backend,EConfigLookup * config_lookup,gint * out_priority,gboolean * out_is_complete)498 mail_config_pop_backend_auto_configure (EMailConfigServiceBackend *backend,
499 					EConfigLookup *config_lookup,
500 					gint *out_priority,
501 					gboolean *out_is_complete)
502 {
503 	return e_mail_config_service_backend_auto_configure_for_kind (backend, config_lookup,
504 		E_CONFIG_LOOKUP_RESULT_MAIL_RECEIVE, NULL, NULL, out_priority, out_is_complete);
505 }
506 
507 static void
e_mail_config_pop_backend_class_init(EMailConfigRemoteBackendClass * class)508 e_mail_config_pop_backend_class_init (EMailConfigRemoteBackendClass *class)
509 {
510 	EMailConfigServiceBackendClass *backend_class;
511 
512 	backend_class = E_MAIL_CONFIG_SERVICE_BACKEND_CLASS (class);
513 	backend_class->backend_name = "pop";
514 	backend_class->auto_configure = mail_config_pop_backend_auto_configure;
515 }
516 
517 static void
e_mail_config_pop_backend_class_finalize(EMailConfigRemoteBackendClass * class)518 e_mail_config_pop_backend_class_finalize (EMailConfigRemoteBackendClass *class)
519 {
520 }
521 
522 static void
e_mail_config_pop_backend_init(EMailConfigRemoteBackend * backend)523 e_mail_config_pop_backend_init (EMailConfigRemoteBackend *backend)
524 {
525 }
526 
527 static void
e_mail_config_nntp_backend_class_init(EMailConfigRemoteBackendClass * class)528 e_mail_config_nntp_backend_class_init (EMailConfigRemoteBackendClass *class)
529 {
530 	EMailConfigServiceBackendClass *backend_class;
531 
532 	backend_class = E_MAIL_CONFIG_SERVICE_BACKEND_CLASS (class);
533 	backend_class->backend_name = "nntp";
534 }
535 
536 static void
e_mail_config_nntp_backend_class_finalize(EMailConfigRemoteBackendClass * class)537 e_mail_config_nntp_backend_class_finalize (EMailConfigRemoteBackendClass *class)
538 {
539 }
540 
541 static void
e_mail_config_nntp_backend_init(EMailConfigRemoteBackend * backend)542 e_mail_config_nntp_backend_init (EMailConfigRemoteBackend *backend)
543 {
544 }
545 
546 static gboolean
mail_config_imapx_backend_auto_configure(EMailConfigServiceBackend * backend,EConfigLookup * config_lookup,gint * out_priority,gboolean * out_is_complete)547 mail_config_imapx_backend_auto_configure (EMailConfigServiceBackend *backend,
548 					  EConfigLookup *config_lookup,
549 					  gint *out_priority,
550 					  gboolean *out_is_complete)
551 {
552 	return e_mail_config_service_backend_auto_configure_for_kind (backend, config_lookup,
553 		E_CONFIG_LOOKUP_RESULT_MAIL_RECEIVE, NULL, NULL, out_priority, out_is_complete);
554 }
555 
556 static void
e_mail_config_imapx_backend_class_init(EMailConfigRemoteBackendClass * class)557 e_mail_config_imapx_backend_class_init (EMailConfigRemoteBackendClass *class)
558 {
559 	EMailConfigServiceBackendClass *backend_class;
560 
561 	backend_class = E_MAIL_CONFIG_SERVICE_BACKEND_CLASS (class);
562 	backend_class->backend_name = "imapx";
563 	backend_class->auto_configure = mail_config_imapx_backend_auto_configure;
564 }
565 
566 static void
e_mail_config_imapx_backend_class_finalize(EMailConfigRemoteBackendClass * class)567 e_mail_config_imapx_backend_class_finalize (EMailConfigRemoteBackendClass *class)
568 {
569 }
570 
571 static void
e_mail_config_imapx_backend_init(EMailConfigRemoteBackend * backend)572 e_mail_config_imapx_backend_init (EMailConfigRemoteBackend *backend)
573 {
574 }
575 
576 void
e_mail_config_remote_accounts_register_types(GTypeModule * type_module)577 e_mail_config_remote_accounts_register_types (GTypeModule *type_module)
578 {
579 	/* Abstract base type */
580 	e_mail_config_remote_backend_register_type (type_module);
581 
582 	/* Concrete sub-types */
583 	e_mail_config_pop_backend_register_type (type_module);
584 	e_mail_config_nntp_backend_register_type (type_module);
585 	e_mail_config_imapx_backend_register_type (type_module);
586 }
587 
588