No issues found
Tool | Failure ID | Location | Function | Message | Data |
---|---|---|---|---|---|
clang-analyzer | no-output-found | e-mail-config-summary-page.c | Message(text='Unable to locate XML output from invoke-clang-analyzer') | None | |
clang-analyzer | no-output-found | e-mail-config-summary-page.c | Message(text='Unable to locate XML output from invoke-clang-analyzer') | None |
1 /*
2 * e-mail-config-summary-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-summary-page.h"
20
21 #include <config.h>
22 #include <glib/gi18n-lib.h>
23
24 #include <camel/camel.h>
25 #include <libebackend/libebackend.h>
26
27 #define E_MAIL_CONFIG_SUMMARY_PAGE_GET_PRIVATE(obj) \
28 (G_TYPE_INSTANCE_GET_PRIVATE \
29 ((obj), E_TYPE_MAIL_CONFIG_SUMMARY_PAGE, EMailConfigSummaryPagePrivate))
30
31 struct _EMailConfigSummaryPagePrivate {
32 ESource *account_source;
33 ESource *identity_source;
34 ESource *transport_source;
35 EMailConfigServiceBackend *account_backend;
36 EMailConfigServiceBackend *transport_backend;
37
38 gulong account_source_changed_id;
39 gulong identity_source_changed_id;
40 gulong transport_source_changed_id;
41
42 /* Widgets (not referenced) */
43 GtkLabel *name_label;
44 GtkLabel *address_label;
45 GtkLabel *recv_backend_label;
46 GtkLabel *recv_host_label;
47 GtkLabel *recv_user_label;
48 GtkLabel *recv_security_label;
49 GtkLabel *send_backend_label;
50 GtkLabel *send_host_label;
51 GtkLabel *send_user_label;
52 GtkLabel *send_security_label;
53 GtkEntry *account_name_entry;
54 };
55
56 enum {
57 PROP_0,
58 PROP_ACCOUNT_BACKEND,
59 PROP_ACCOUNT_SOURCE,
60 PROP_IDENTITY_SOURCE,
61 PROP_TRANSPORT_BACKEND,
62 PROP_TRANSPORT_SOURCE
63 };
64
65 enum {
66 REFRESH,
67 LAST_SIGNAL
68 };
69
70 static gulong signals[LAST_SIGNAL];
71
72 /* Forward Declarations */
73 static void e_mail_config_summary_page_interface_init
74 (EMailConfigPageInterface *interface);
75
76 G_DEFINE_TYPE_WITH_CODE (
77 EMailConfigSummaryPage,
78 e_mail_config_summary_page,
79 GTK_TYPE_BOX,
80 G_IMPLEMENT_INTERFACE (
81 E_TYPE_EXTENSIBLE, NULL)
82 G_IMPLEMENT_INTERFACE (
83 E_TYPE_MAIL_CONFIG_PAGE,
84 e_mail_config_summary_page_interface_init))
85
86 /* Helper for mail_config_summary_page_refresh() */
87 static void
88 mail_config_summary_page_refresh_auth_labels (ESource *source,
89 GtkLabel *host_label,
90 GtkLabel *user_label)
91 {
92 ESourceAuthentication *extension;
93 const gchar *extension_name;
94 const gchar *value;
95
96 extension_name = E_SOURCE_EXTENSION_AUTHENTICATION;
97 if (!e_source_has_extension (source, extension_name))
98 return;
99
100 extension = e_source_get_extension (source, extension_name);
101
102 value = e_source_authentication_get_host (extension);
103 gtk_label_set_text (host_label, value);
104
105 value = e_source_authentication_get_user (extension);
106 gtk_label_set_text (user_label, value);
107 }
108
109 /* Helper for mail_config_summary_page_refresh() */
110 static void
111 mail_config_summary_page_refresh_security_label (ESource *source,
112 GtkLabel *security_label)
113 {
114 GEnumClass *enum_class;
115 GEnumValue *enum_value;
116 ESourceSecurity *extension;
117 const gchar *extension_name;
118 const gchar *value;
119
120 extension_name = E_SOURCE_EXTENSION_SECURITY;
121 if (!e_source_has_extension (source, extension_name))
122 return;
123
124 extension = e_source_get_extension (source, extension_name);
125
126 /* XXX This is a pain in the butt, but we want to avoid hard-coding
127 * string values from the CamelNetworkSecurityMethod enum class
128 * in case they change in the future. */
129 enum_class = g_type_class_ref (CAMEL_TYPE_NETWORK_SECURITY_METHOD);
130 value = e_source_security_get_method (extension);
131 if (value != NULL)
132 enum_value = g_enum_get_value_by_nick (enum_class, value);
133 else
134 enum_value = NULL;
135 if (enum_value == NULL) {
136 gtk_label_set_text (security_label, value);
137 } else switch ((CamelNetworkSecurityMethod) enum_value->value) {
138 case CAMEL_NETWORK_SECURITY_METHOD_NONE:
139 gtk_label_set_text (security_label, _("None"));
140 break;
141 case CAMEL_NETWORK_SECURITY_METHOD_SSL_ON_ALTERNATE_PORT:
142 gtk_label_set_text (security_label, _("SSL"));
143 break;
144 case CAMEL_NETWORK_SECURITY_METHOD_STARTTLS_ON_STANDARD_PORT:
145 gtk_label_set_text (security_label, _("TLS"));
146 break;
147 }
148 g_type_class_unref (enum_class);
149 }
150
151 static void
152 mail_config_summary_page_source_changed (ESource *source,
153 EMailConfigSummaryPage *page)
154 {
155 e_mail_config_summary_page_refresh (page);
156 }
157
158 static void
159 mail_config_summary_page_set_property (GObject *object,
160 guint property_id,
161 const GValue *value,
162 GParamSpec *pspec)
163 {
164 switch (property_id) {
165 case PROP_ACCOUNT_BACKEND:
166 e_mail_config_summary_page_set_account_backend (
167 E_MAIL_CONFIG_SUMMARY_PAGE (object),
168 g_value_get_object (value));
169 return;
170
171 case PROP_IDENTITY_SOURCE:
172 e_mail_config_summary_page_set_identity_source (
173 E_MAIL_CONFIG_SUMMARY_PAGE (object),
174 g_value_get_object (value));
175 return;
176
177 case PROP_TRANSPORT_BACKEND:
178 e_mail_config_summary_page_set_transport_backend (
179 E_MAIL_CONFIG_SUMMARY_PAGE (object),
180 g_value_get_object (value));
181 return;
182 }
183
184 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
185 }
186
187 static void
188 mail_config_summary_page_get_property (GObject *object,
189 guint property_id,
190 GValue *value,
191 GParamSpec *pspec)
192 {
193 switch (property_id) {
194 case PROP_ACCOUNT_BACKEND:
195 g_value_set_object (
196 value,
197 e_mail_config_summary_page_get_account_backend (
198 E_MAIL_CONFIG_SUMMARY_PAGE (object)));
199 return;
200
201 case PROP_ACCOUNT_SOURCE:
202 g_value_set_object (
203 value,
204 e_mail_config_summary_page_get_account_source (
205 E_MAIL_CONFIG_SUMMARY_PAGE (object)));
206 return;
207
208 case PROP_IDENTITY_SOURCE:
209 g_value_set_object (
210 value,
211 e_mail_config_summary_page_get_identity_source (
212 E_MAIL_CONFIG_SUMMARY_PAGE (object)));
213 return;
214
215 case PROP_TRANSPORT_BACKEND:
216 g_value_set_object (
217 value,
218 e_mail_config_summary_page_get_transport_backend (
219 E_MAIL_CONFIG_SUMMARY_PAGE (object)));
220 return;
221
222 case PROP_TRANSPORT_SOURCE:
223 g_value_set_object (
224 value,
225 e_mail_config_summary_page_get_transport_source (
226 E_MAIL_CONFIG_SUMMARY_PAGE (object)));
227 return;
228 }
229
230 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
231 }
232
233 static void
234 mail_config_summary_page_dispose (GObject *object)
235 {
236 EMailConfigSummaryPagePrivate *priv;
237
238 priv = E_MAIL_CONFIG_SUMMARY_PAGE_GET_PRIVATE (object);
239
240 if (priv->account_source != NULL) {
241 g_signal_handler_disconnect (
242 priv->account_source,
243 priv->account_source_changed_id);
244 g_object_unref (priv->account_source);
245 priv->account_source = NULL;
246 priv->account_source_changed_id = 0;
247 }
248
249 if (priv->identity_source != NULL) {
250 g_signal_handler_disconnect (
251 priv->identity_source,
252 priv->identity_source_changed_id);
253 g_object_unref (priv->identity_source);
254 priv->identity_source = NULL;
255 }
256
257 if (priv->transport_source != NULL) {
258 g_signal_handler_disconnect (
259 priv->transport_source,
260 priv->transport_source_changed_id);
261 g_object_unref (priv->transport_source);
262 priv->transport_source = NULL;
263 priv->transport_source_changed_id = 0;
264 }
265
266 if (priv->account_backend != NULL) {
267 g_object_unref (priv->account_backend);
268 priv->account_backend = NULL;
269 }
270
271 if (priv->transport_backend != NULL) {
272 g_object_unref (priv->transport_backend);
273 priv->transport_backend = NULL;
274 }
275
276 /* Chain up to parent's dispose() method. */
277 G_OBJECT_CLASS (e_mail_config_summary_page_parent_class)->
278 dispose (object);
279 }
280
281 static void
282 mail_config_summary_page_constructed (GObject *object)
283 {
284 EMailConfigSummaryPage *page;
285 GtkLabel *label;
286 GtkWidget *widget;
287 GtkWidget *container;
288 GtkSizeGroup *size_group;
289 const gchar *text;
290 gchar *markup;
291
292 page = E_MAIL_CONFIG_SUMMARY_PAGE (object);
293
294 /* Chain up to parent's constructed() method. */
295 G_OBJECT_CLASS (e_mail_config_summary_page_parent_class)->
296 constructed (object);
297
298 gtk_orientable_set_orientation (
299 GTK_ORIENTABLE (page), GTK_ORIENTATION_VERTICAL);
300
301 /* This page is dense with information,
302 * so put extra space between sections. */
303 gtk_box_set_spacing (GTK_BOX (page), 24);
304
305 size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
306
307 text = _("This is a summary of the settings which will be used "
308 "to access your mail.");
309 widget = gtk_label_new (text);
310 gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
311 gtk_box_pack_start (GTK_BOX (page), widget, FALSE, FALSE, 0);
312 gtk_widget_show (widget);
313
314 /*** Account Information ***/
315
316 widget = gtk_grid_new ();
317 gtk_grid_set_row_spacing (GTK_GRID (widget), 6);
318 gtk_grid_set_column_spacing (GTK_GRID (widget), 6);
319 gtk_box_pack_start (GTK_BOX (page), widget, FALSE, FALSE, 0);
320 gtk_widget_show (widget);
321
322 container = widget;
323
324 text = _("Account Information");
325 markup = g_markup_printf_escaped ("<b>%s</b>", text);
326 widget = gtk_label_new (markup);
327 gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
328 gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
329 gtk_grid_attach (GTK_GRID (container), widget, 0, 0, 2, 1);
330 gtk_widget_show (widget);
331 g_free (markup);
332
333 text = _("Type the name by which you would like to refer to "
334 "this account.\nFor example, \"Work\" or \"Personal\".");
335 widget = gtk_label_new (text);
336 gtk_widget_set_margin_left (widget, 12);
337 gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
338 gtk_grid_attach (GTK_GRID (container), widget, 0, 1, 2, 1);
339 gtk_widget_show (widget);
340
341 text = _("_Name:");
342 widget = gtk_label_new_with_mnemonic (text);
343 gtk_widget_set_margin_left (widget, 12);
344 gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
345 gtk_grid_attach (GTK_GRID (container), widget, 0, 2, 1, 1);
346 gtk_widget_show (widget);
347
348 label = GTK_LABEL (widget);
349
350 widget = gtk_entry_new ();
351 gtk_widget_set_hexpand (widget, TRUE);
352 gtk_label_set_mnemonic_widget (label, widget);
353 gtk_grid_attach (GTK_GRID (container), widget, 1, 2, 1, 1);
354 page->priv->account_name_entry = GTK_ENTRY (widget);
355 gtk_widget_show (widget);
356
357 /* This entry affects the "check-complete" result. */
358 g_signal_connect_swapped (
359 widget, "changed",
360 G_CALLBACK (e_mail_config_page_changed), page);
361
362 /*** Details ***/
363
364 widget = gtk_grid_new ();
365 gtk_grid_set_row_spacing (GTK_GRID (widget), 6);
366 gtk_grid_set_column_spacing (GTK_GRID (widget), 12);
367 gtk_box_pack_start (GTK_BOX (page), widget, FALSE, FALSE, 0);
368 gtk_widget_show (widget);
369
370 container = widget;
371
372 text = _("Personal Details");
373 markup = g_markup_printf_escaped ("<b>%s</b>", text);
374 widget = gtk_label_new (markup);
375 gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
376 gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
377 gtk_grid_attach (GTK_GRID (container), widget, 0, 0, 3, 1);
378 gtk_widget_show (widget);
379 g_free (markup);
380
381 text = _("Full Name:");
382 widget = gtk_label_new (text);
383 gtk_widget_set_margin_left (widget, 12);
384 gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
385 gtk_grid_attach (GTK_GRID (container), widget, 0, 1, 1, 1);
386 gtk_widget_show (widget);
387
388 widget = gtk_label_new (NULL);
389 gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
390 gtk_label_set_ellipsize (GTK_LABEL (widget), PANGO_ELLIPSIZE_END);
391 gtk_grid_attach (GTK_GRID (container), widget, 1, 1, 2, 1);
392 page->priv->name_label = GTK_LABEL (widget);
393 gtk_widget_show (widget);
394
395 text = _("Email Address:");
396 widget = gtk_label_new (text);
397 gtk_widget_set_margin_left (widget, 12);
398 gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
399 gtk_grid_attach (GTK_GRID (container), widget, 0, 2, 1, 1);
400 gtk_widget_show (widget);
401
402 widget = gtk_label_new (NULL);
403 gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
404 gtk_label_set_ellipsize (GTK_LABEL (widget), PANGO_ELLIPSIZE_END);
405 gtk_grid_attach (GTK_GRID (container), widget, 1, 2, 2, 1);
406 page->priv->address_label = GTK_LABEL (widget);
407 gtk_widget_show (widget);
408
409 text = _("Receiving");
410 markup = g_markup_printf_escaped ("<b>%s</b>", text);
411 widget = gtk_label_new (markup);
412 gtk_widget_set_hexpand (widget, TRUE);
413 gtk_widget_set_margin_top (widget, 6);
414 gtk_size_group_add_widget (size_group, widget);
415 gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
416 gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
417 gtk_grid_attach (GTK_GRID (container), widget, 1, 3, 1, 1);
418 gtk_widget_show (widget);
419 g_free (markup);
420
421 text = _("Sending");
422 markup = g_markup_printf_escaped ("<b>%s</b>", text);
423 widget = gtk_label_new (markup);
424 gtk_widget_set_hexpand (widget, TRUE);
425 gtk_widget_set_margin_top (widget, 6);
426 gtk_size_group_add_widget (size_group, widget);
427 gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
428 gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
429 gtk_grid_attach (GTK_GRID (container), widget, 2, 3, 1, 1);
430 gtk_widget_show (widget);
431 g_free (markup);
432
433 text = _("Server Type:");
434 widget = gtk_label_new (text);
435 gtk_widget_set_margin_left (widget, 12);
436 gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
437 gtk_grid_attach (GTK_GRID (container), widget, 0, 4, 1, 1);
438 gtk_widget_show (widget);
439
440 widget = gtk_label_new (NULL);
441 gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
442 gtk_label_set_ellipsize (GTK_LABEL (widget), PANGO_ELLIPSIZE_END);
443 gtk_grid_attach (GTK_GRID (container), widget, 1, 4, 1, 1);
444 page->priv->recv_backend_label = GTK_LABEL (widget);
445 gtk_widget_show (widget);
446
447 widget = gtk_label_new (NULL);
448 gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
449 gtk_label_set_ellipsize (GTK_LABEL (widget), PANGO_ELLIPSIZE_END);
450 gtk_grid_attach (GTK_GRID (container), widget, 2, 4, 1, 1);
451 page->priv->send_backend_label = GTK_LABEL (widget);
452 gtk_widget_show (widget);
453
454 text = _("Server:");
455 widget = gtk_label_new (text);
456 gtk_widget_set_margin_left (widget, 12);
457 gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
458 gtk_grid_attach (GTK_GRID (container), widget, 0, 5, 1, 1);
459 gtk_widget_show (widget);
460
461 widget = gtk_label_new (NULL);
462 gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
463 gtk_label_set_ellipsize (GTK_LABEL (widget), PANGO_ELLIPSIZE_END);
464 gtk_grid_attach (GTK_GRID (container), widget, 1, 5, 1, 1);
465 page->priv->recv_host_label = GTK_LABEL (widget);
466 gtk_widget_show (widget);
467
468 widget = gtk_label_new (NULL);
469 gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
470 gtk_label_set_ellipsize (GTK_LABEL (widget), PANGO_ELLIPSIZE_END);
471 gtk_grid_attach (GTK_GRID (container), widget, 2, 5, 1, 1);
472 page->priv->send_host_label = GTK_LABEL (widget);
473 gtk_widget_show (widget);
474
475 text = _("Username:");
476 widget = gtk_label_new (text);
477 gtk_widget_set_margin_left (widget, 12);
478 gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
479 gtk_grid_attach (GTK_GRID (container), widget, 0, 6, 1, 1);
480 gtk_widget_show (widget);
481
482 widget = gtk_label_new (NULL);
483 gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
484 gtk_label_set_ellipsize (GTK_LABEL (widget), PANGO_ELLIPSIZE_END);
485 gtk_grid_attach (GTK_GRID (container), widget, 1, 6, 1, 1);
486 page->priv->recv_user_label = GTK_LABEL (widget);
487 gtk_widget_show (widget);
488
489 widget = gtk_label_new (NULL);
490 gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
491 gtk_label_set_ellipsize (GTK_LABEL (widget), PANGO_ELLIPSIZE_END);
492 gtk_grid_attach (GTK_GRID (container), widget, 2, 6, 1, 1);
493 page->priv->send_user_label = GTK_LABEL (widget);
494 gtk_widget_show (widget);
495
496 text = _("Security:");
497 widget = gtk_label_new (text);
498 gtk_widget_set_margin_left (widget, 12);
499 gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
500 gtk_grid_attach (GTK_GRID (container), widget, 0, 7, 1, 1);
501 gtk_widget_show (widget);
502
503 widget = gtk_label_new (NULL);
504 gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
505 gtk_label_set_ellipsize (GTK_LABEL (widget), PANGO_ELLIPSIZE_END);
506 gtk_grid_attach (GTK_GRID (container), widget, 1, 7, 1, 1);
507 page->priv->recv_security_label = GTK_LABEL (widget);
508 gtk_widget_show (widget);
509
510 widget = gtk_label_new (NULL);
511 gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
512 gtk_label_set_ellipsize (GTK_LABEL (widget), PANGO_ELLIPSIZE_END);
513 gtk_grid_attach (GTK_GRID (container), widget, 2, 7, 1, 1);
514 page->priv->send_security_label = GTK_LABEL (widget);
515 gtk_widget_show (widget);
516
517 g_object_unref (size_group);
518
519 e_extensible_load_extensions (E_EXTENSIBLE (page));
520 }
521
522 static void
523 mail_config_summary_page_refresh (EMailConfigSummaryPage *page)
524 {
525 EMailConfigSummaryPagePrivate *priv;
526 ESource *source;
527 gboolean account_is_transport = FALSE;
528
529 priv = E_MAIL_CONFIG_SUMMARY_PAGE_GET_PRIVATE (page);
530
531 /* Clear all labels. */
532 gtk_label_set_text (priv->name_label, "");
533 gtk_label_set_text (priv->address_label, "");
534 gtk_label_set_text (priv->recv_backend_label, "");
535 gtk_label_set_text (priv->recv_host_label, "");
536 gtk_label_set_text (priv->recv_user_label, "");
537 gtk_label_set_text (priv->recv_security_label, "");
538 gtk_label_set_text (priv->send_backend_label, "");
539 gtk_label_set_text (priv->send_host_label, "");
540 gtk_label_set_text (priv->send_user_label, "");
541 gtk_label_set_text (priv->send_security_label, "");
542
543 source = e_mail_config_summary_page_get_identity_source (page);
544
545 if (source != NULL) {
546 ESourceMailIdentity *extension;
547 const gchar *extension_name;
548 const gchar *value;
549
550 value = e_source_get_display_name (source);
551 gtk_entry_set_text (priv->account_name_entry, value);
552
553 extension_name = E_SOURCE_EXTENSION_MAIL_IDENTITY;
554 extension = e_source_get_extension (source, extension_name);
555
556 value = e_source_mail_identity_get_name (extension);
557 gtk_label_set_text (priv->name_label, value);
558
559 value = e_source_mail_identity_get_address (extension);
560 gtk_label_set_text (priv->address_label, value);
561 }
562
563 source = e_mail_config_summary_page_get_account_source (page);
564
565 if (source != NULL) {
566 ESourceBackend *extension;
567 const gchar *extension_name;
568 const gchar *value;
569
570 extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
571 extension = e_source_get_extension (source, extension_name);
572
573 value = e_source_backend_get_backend_name (extension);
574 gtk_label_set_text (priv->recv_backend_label, value);
575
576 mail_config_summary_page_refresh_auth_labels (
577 source,
578 priv->recv_host_label,
579 priv->recv_user_label);
580
581 mail_config_summary_page_refresh_security_label (
582 source,
583 priv->recv_security_label);
584
585 extension_name = E_SOURCE_EXTENSION_MAIL_TRANSPORT;
586 if (e_source_has_extension (source, extension_name))
587 account_is_transport = TRUE;
588 }
589
590 if (account_is_transport)
591 source = e_mail_config_summary_page_get_account_source (page);
592 else
593 source = e_mail_config_summary_page_get_transport_source (page);
594
595 if (source != NULL) {
596 ESourceBackend *extension;
597 const gchar *extension_name;
598 const gchar *value;
599
600 extension_name = E_SOURCE_EXTENSION_MAIL_TRANSPORT;
601 extension = e_source_get_extension (source, extension_name);
602
603 value = e_source_backend_get_backend_name (extension);
604 gtk_label_set_text (priv->send_backend_label, value);
605
606 mail_config_summary_page_refresh_auth_labels (
607 source,
608 priv->send_host_label,
609 priv->send_user_label);
610
611 mail_config_summary_page_refresh_security_label (
612 source,
613 priv->send_security_label);
614 }
615 }
616
617 static gboolean
618 mail_config_summary_page_check_complete (EMailConfigPage *page)
619 {
620 EMailConfigSummaryPagePrivate *priv;
621 gchar *stripped_text;
622 const gchar *text;
623 gboolean complete;
624
625 priv = E_MAIL_CONFIG_SUMMARY_PAGE_GET_PRIVATE (page);
626
627 /* Strip the account name of leading and trailing
628 * whitespace as e_source_set_display_name() does. */
629 text = gtk_entry_get_text (priv->account_name_entry);
630 stripped_text = g_strstrip (g_strdup ((text != NULL) ? text : ""));
631 complete = (*stripped_text != '\0');
632 g_free (stripped_text);
633
634 return complete;
635 }
636
637 static void
638 mail_config_summary_page_commit_changes (EMailConfigPage *page,
639 GQueue *source_queue)
640 {
641 EMailConfigSummaryPagePrivate *priv;
642 EMailConfigServiceBackend *backend;
643 ESource *account_source;
644 ESource *identity_source;
645 ESource *transport_source;
646 ESource *collection_source;
647 ESourceExtension *extension;
648 const gchar *extension_name;
649 const gchar *parent_uid;
650 const gchar *text;
651
652 priv = E_MAIL_CONFIG_SUMMARY_PAGE_GET_PRIVATE (page);
653
654 backend = e_mail_config_summary_page_get_account_backend (
655 E_MAIL_CONFIG_SUMMARY_PAGE (page));
656 account_source =
657 e_mail_config_service_backend_get_source (backend);
658 collection_source =
659 e_mail_config_service_backend_get_collection (backend);
660
661 /* The transport backend is NULL when the Sending Page is hidden. */
662 backend = e_mail_config_summary_page_get_transport_backend (
663 E_MAIL_CONFIG_SUMMARY_PAGE (page));
664 transport_source = (backend != NULL) ?
665 e_mail_config_service_backend_get_source (backend) : NULL;
666
667 identity_source = e_mail_config_summary_page_get_identity_source (
668 E_MAIL_CONFIG_SUMMARY_PAGE (page));
669
670 /* This should propagate to the other sources through bindings. */
671 text = gtk_entry_get_text (priv->account_name_entry);
672 e_source_set_display_name (identity_source, text);
673
674 /* Setup parent/child relationships and cross-references. */
675
676 if (collection_source != NULL) {
677 parent_uid = e_source_get_uid (collection_source);
678 e_source_set_parent (account_source, parent_uid);
679 e_source_set_parent (identity_source, parent_uid);
680 if (transport_source != NULL)
681 e_source_set_parent (transport_source, parent_uid);
682 } else {
683 parent_uid = e_source_get_uid (account_source);
684 e_source_set_parent (identity_source, parent_uid);
685 if (transport_source != NULL)
686 e_source_set_parent (transport_source, parent_uid);
687 }
688
689 extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
690 extension = e_source_get_extension (account_source, extension_name);
691 e_source_mail_account_set_identity_uid (
692 E_SOURCE_MAIL_ACCOUNT (extension),
693 e_source_get_uid (identity_source));
694
695 extension_name = E_SOURCE_EXTENSION_MAIL_SUBMISSION;
696 extension = e_source_get_extension (identity_source, extension_name);
697 if (transport_source != NULL)
698 e_source_mail_submission_set_transport_uid (
699 E_SOURCE_MAIL_SUBMISSION (extension),
700 e_source_get_uid (transport_source));
701 }
702
703 static void
704 e_mail_config_summary_page_class_init (EMailConfigSummaryPageClass *class)
705 {
706 GObjectClass *object_class;
707
708 g_type_class_add_private (
709 class, sizeof (EMailConfigSummaryPagePrivate));
710
711 object_class = G_OBJECT_CLASS (class);
712 object_class->set_property = mail_config_summary_page_set_property;
713 object_class->get_property = mail_config_summary_page_get_property;
714 object_class->dispose = mail_config_summary_page_dispose;
715 object_class->constructed = mail_config_summary_page_constructed;
716
717 class->refresh = mail_config_summary_page_refresh;
718
719 g_object_class_install_property (
720 object_class,
721 PROP_ACCOUNT_BACKEND,
722 g_param_spec_object (
723 "account-backend",
724 "Account Backend",
725 "Active mail account service backend",
726 E_TYPE_MAIL_CONFIG_SERVICE_BACKEND,
727 G_PARAM_READWRITE |
728 G_PARAM_STATIC_STRINGS));
729
730 g_object_class_install_property (
731 object_class,
732 PROP_ACCOUNT_SOURCE,
733 g_param_spec_object (
734 "account-source",
735 "Account Source",
736 "Mail account source being edited",
737 E_TYPE_SOURCE,
738 G_PARAM_READABLE |
739 G_PARAM_STATIC_STRINGS));
740
741 g_object_class_install_property (
742 object_class,
743 PROP_IDENTITY_SOURCE,
744 g_param_spec_object (
745 "identity-source",
746 "Identity Source",
747 "Mail identity source being edited",
748 E_TYPE_SOURCE,
749 G_PARAM_READWRITE |
750 G_PARAM_STATIC_STRINGS));
751
752 g_object_class_install_property (
753 object_class,
754 PROP_TRANSPORT_BACKEND,
755 g_param_spec_object (
756 "transport-backend",
757 "Transport Backend",
758 "Active mail transport service backend",
759 E_TYPE_MAIL_CONFIG_SERVICE_BACKEND,
760 G_PARAM_READWRITE |
761 G_PARAM_STATIC_STRINGS));
762
763 g_object_class_install_property (
764 object_class,
765 PROP_TRANSPORT_SOURCE,
766 g_param_spec_object (
767 "transport-source",
768 "Transport Source",
769 "Mail transport source being edited",
770 E_TYPE_SOURCE,
771 G_PARAM_READABLE |
772 G_PARAM_STATIC_STRINGS));
773
774 signals[REFRESH] = g_signal_new (
775 "refresh",
776 G_TYPE_FROM_CLASS (class),
777 G_SIGNAL_RUN_LAST,
778 G_STRUCT_OFFSET (EMailConfigSummaryPageClass, refresh),
779 NULL, NULL,
780 g_cclosure_marshal_VOID__VOID,
781 G_TYPE_NONE, 0);
782 }
783
784 static void
785 e_mail_config_summary_page_interface_init (EMailConfigPageInterface *interface)
786 {
787 interface->title = _("Account Summary");
788 interface->sort_order = E_MAIL_CONFIG_SUMMARY_PAGE_SORT_ORDER;
789 interface->check_complete = mail_config_summary_page_check_complete;
790 interface->commit_changes = mail_config_summary_page_commit_changes;
791 }
792
793 static void
794 e_mail_config_summary_page_init (EMailConfigSummaryPage *page)
795 {
796 page->priv = E_MAIL_CONFIG_SUMMARY_PAGE_GET_PRIVATE (page);
797 }
798
799 EMailConfigPage *
800 e_mail_config_summary_page_new (void)
801 {
802 return g_object_new (E_TYPE_MAIL_CONFIG_SUMMARY_PAGE, NULL);
803 }
804
805 void
806 e_mail_config_summary_page_refresh (EMailConfigSummaryPage *page)
807 {
808 g_return_if_fail (E_IS_MAIL_CONFIG_SUMMARY_PAGE (page));
809
810 g_signal_emit (page, signals[REFRESH], 0);
811 }
812
813 EMailConfigServiceBackend *
814 e_mail_config_summary_page_get_account_backend (EMailConfigSummaryPage *page)
815 {
816 g_return_val_if_fail (E_IS_MAIL_CONFIG_SUMMARY_PAGE (page), NULL);
817
818 return page->priv->account_backend;
819 }
820
821 void
822 e_mail_config_summary_page_set_account_backend (EMailConfigSummaryPage *page,
823 EMailConfigServiceBackend *backend)
824 {
825 g_return_if_fail (E_IS_MAIL_CONFIG_SUMMARY_PAGE (page));
826
827 if (backend != NULL) {
828 g_return_if_fail (E_IS_MAIL_CONFIG_SERVICE_BACKEND (backend));
829 g_object_ref (backend);
830 }
831
832 if (page->priv->account_backend != NULL)
833 g_object_unref (page->priv->account_backend);
834
835 page->priv->account_backend = backend;
836
837 if (page->priv->account_source != NULL) {
838 g_signal_handler_disconnect (
839 page->priv->account_source,
840 page->priv->account_source_changed_id);
841 g_object_unref (page->priv->account_source);
842 page->priv->account_source = NULL;
843 page->priv->account_source_changed_id = 0;
844 }
845
846 if (backend != NULL) {
847 ESource *source;
848 gulong handler_id;
849
850 source = e_mail_config_service_backend_get_source (backend);
851
852 handler_id = g_signal_connect (
853 source, "changed",
854 G_CALLBACK (mail_config_summary_page_source_changed),
855 page);
856
857 page->priv->account_source = g_object_ref (source);
858 page->priv->account_source_changed_id = handler_id;
859 }
860
861 g_object_freeze_notify (G_OBJECT (page));
862 g_object_notify (G_OBJECT (page), "account-backend");
863 g_object_notify (G_OBJECT (page), "account-source");
864 g_object_thaw_notify (G_OBJECT (page));
865
866 e_mail_config_summary_page_refresh (page);
867 }
868
869 ESource *
870 e_mail_config_summary_page_get_account_source (EMailConfigSummaryPage *page)
871 {
872 g_return_val_if_fail (E_IS_MAIL_CONFIG_SUMMARY_PAGE (page), NULL);
873
874 return page->priv->account_source;
875 }
876
877 ESource *
878 e_mail_config_summary_page_get_identity_source (EMailConfigSummaryPage *page)
879 {
880 g_return_val_if_fail (E_IS_MAIL_CONFIG_SUMMARY_PAGE (page), NULL);
881
882 return page->priv->identity_source;
883 }
884
885 void
886 e_mail_config_summary_page_set_identity_source (EMailConfigSummaryPage *page,
887 ESource *identity_source)
888 {
889 g_return_if_fail (E_IS_MAIL_CONFIG_SUMMARY_PAGE (page));
890
891 if (page->priv->identity_source == identity_source)
892 return;
893
894 if (identity_source != NULL) {
895 g_return_if_fail (E_IS_SOURCE (identity_source));
896 g_object_ref (identity_source);
897 }
898
899 if (page->priv->identity_source != NULL) {
900 g_signal_handler_disconnect (
901 page->priv->identity_source,
902 page->priv->identity_source_changed_id);
903 g_object_unref (page->priv->identity_source);
904 }
905
906 page->priv->identity_source = identity_source;
907 page->priv->identity_source_changed_id = 0;
908
909 if (identity_source != NULL) {
910 gulong handler_id;
911
912 handler_id = g_signal_connect (
913 identity_source, "changed",
914 G_CALLBACK (mail_config_summary_page_source_changed),
915 page);
916
917 page->priv->identity_source_changed_id = handler_id;
918 }
919
920 g_object_notify (G_OBJECT (page), "identity-source");
921
922 e_mail_config_summary_page_refresh (page);
923 }
924
925 EMailConfigServiceBackend *
926 e_mail_config_summary_page_get_transport_backend (EMailConfigSummaryPage *page)
927 {
928 g_return_val_if_fail (E_IS_MAIL_CONFIG_SUMMARY_PAGE (page), NULL);
929
930 return page->priv->transport_backend;
931 }
932
933 void
934 e_mail_config_summary_page_set_transport_backend (EMailConfigSummaryPage *page,
935 EMailConfigServiceBackend *backend)
936 {
937 g_return_if_fail (E_IS_MAIL_CONFIG_SUMMARY_PAGE (page));
938
939 if (backend != NULL) {
940 g_return_if_fail (E_IS_MAIL_CONFIG_SERVICE_BACKEND (backend));
941 g_object_ref (backend);
942 }
943
944 if (page->priv->transport_backend != NULL)
945 g_object_unref (page->priv->transport_backend);
946
947 page->priv->transport_backend = backend;
948
949 if (page->priv->transport_source != NULL) {
950 g_signal_handler_disconnect (
951 page->priv->transport_source,
952 page->priv->transport_source_changed_id);
953 g_object_unref (page->priv->transport_source);
954 page->priv->transport_source = NULL;
955 page->priv->transport_source_changed_id = 0;
956 }
957
958 if (backend != NULL) {
959 ESource *source;
960 gulong handler_id;
961
962 source = e_mail_config_service_backend_get_source (backend);
963
964 handler_id = g_signal_connect (
965 source, "changed",
966 G_CALLBACK (mail_config_summary_page_source_changed),
967 page);
968
969 page->priv->transport_source = g_object_ref (source);
970 page->priv->transport_source_changed_id = handler_id;
971 }
972
973 g_object_freeze_notify (G_OBJECT (page));
974 g_object_notify (G_OBJECT (page), "transport-backend");
975 g_object_notify (G_OBJECT (page), "transport-source");
976 g_object_thaw_notify (G_OBJECT (page));
977
978 e_mail_config_summary_page_refresh (page);
979 }
980
981 ESource *
982 e_mail_config_summary_page_get_transport_source (EMailConfigSummaryPage *page)
983 {
984 g_return_val_if_fail (E_IS_MAIL_CONFIG_SUMMARY_PAGE (page), NULL);
985
986 return page->priv->transport_source;
987 }