aboutsummaryrefslogtreecommitdiffstats
path: root/modules/settings/e-settings-deprecated.c
blob: b34e791b0df94746f4c0e9b902719b27e588e097 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
/*
 * e-settings-deprecated.c
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, see <http://www.gnu.org/licenses/>.
 *
 */

/* This class is different from the others in this module.  Its purpose
 * is to transfer values from deprecated GSettings keys to the preferred
 * keys on startup, and keep them synchronized at all times for backward
 * compatibility. */

#include "e-settings-deprecated.h"

#include <shell/e-shell.h>
#include <mail/e-mail-enums.h>
#include <em-format/e-mail-formatter-enums.h>

#define E_SETTINGS_DEPRECATED_GET_PRIVATE(obj) \
    (G_TYPE_INSTANCE_GET_PRIVATE \
    ((obj), E_TYPE_SETTINGS_DEPRECATED, ESettingsDeprecatedPrivate))

struct _ESettingsDeprecatedPrivate {
    GSettings *calendar_settings;
    gulong week_start_day_name_handler_id;
    gulong work_day_monday_handler_id;
    gulong work_day_tuesday_handler_id;
    gulong work_day_wednesday_handler_id;
    gulong work_day_thursday_handler_id;
    gulong work_day_friday_handler_id;
    gulong work_day_saturday_handler_id;
    gulong work_day_sunday_handler_id;

    GSettings *mail_settings;
    gulong browser_close_on_reply_policy_handler_id;
    gulong forward_style_name_handler_id;
    gulong reply_style_name_handler_id;
    gulong image_loading_policy_handler_id;
    gulong show_headers_handler_id;
};

/* Flag values used in the "working-days" key. */
enum {
    DEPRECATED_WORKING_DAYS_SUNDAY = 1 << 0,
    DEPRECATED_WORKING_DAYS_MONDAY = 1 << 1,
    DEPRECATED_WORKING_DAYS_TUESDAY = 1 << 2,
    DEPRECATED_WORKING_DAYS_WEDNESDAY = 1 << 3,
    DEPRECATED_WORKING_DAYS_THURSDAY = 1 << 4,
    DEPRECATED_WORKING_DAYS_FRIDAY = 1 << 5,
    DEPRECATED_WORKING_DAYS_SATURDAY = 1 << 6
};

G_DEFINE_DYNAMIC_TYPE (
    ESettingsDeprecated,
    e_settings_deprecated,
    E_TYPE_EXTENSION)

static void
settings_deprecated_header_start_element (GMarkupParseContext *context,
                                          const gchar *element_name,
                                          const gchar **attribute_names,
                                          const gchar **attribute_values,
                                          gpointer user_data,
                                          GError **error)
{
    GVariantBuilder *builder = user_data;
    const gchar *name = NULL;
    const gchar *enabled = NULL;

    /* The enabled flag is determined by the presence of an "enabled"
     * attribute, but the actual value of the "enabled" attribute, if
     * present, is just an empty string.  It's pretty convoluted. */
    g_markup_collect_attributes (
        element_name,
        attribute_names,
        attribute_values,
        error,
        G_MARKUP_COLLECT_STRING,
        "name", &name,
        G_MARKUP_COLLECT_STRING |
        G_MARKUP_COLLECT_OPTIONAL,
        "enabled", &enabled,
        G_MARKUP_COLLECT_INVALID);

    if (name != NULL)
        g_variant_builder_add (
            builder, "(sb)", name, (enabled != NULL));
}

static void
e_settings_deprecated_set_int_with_change_test (GSettings *settings,
                                                const gchar *key,
                                                gint value)
{
    if (g_settings_get_int (settings, key) != value)
        g_settings_set_int (settings, key, value);
}

static void
e_settings_deprecated_set_string_with_change_test (GSettings *settings,
                                                   const gchar *key,
                                                   const gchar *value)
{
    gchar *stored = g_settings_get_string (settings, key);

    if (g_strcmp0 (stored, value) != 0)
        g_settings_set_string (settings, key, value);

    g_free (stored);
}

static void
e_settings_deprecated_set_strv_with_change_test (GSettings *settings,
                                                 const gchar *key,
                                                 const gchar * const *value)
{
    gchar **stored = g_settings_get_strv (settings, key);
    gboolean changed;
    gint ii;

    changed = !stored || !value;
    for (ii = 0; !changed && stored[ii] && value[ii]; ii++) {
        changed = g_strcmp0 (stored[ii], value[ii]) != 0;
    }

    changed = changed || stored[ii] != NULL || value[ii] != NULL;

    if (changed)
        g_settings_set_strv (settings, key, value);

    g_strfreev (stored);
}

static void
settings_deprecated_header_parse_xml (const gchar *xml,
                                      GVariantBuilder *builder)
{
    static GMarkupParser parser = {
        settings_deprecated_header_start_element, };

    GMarkupParseContext *context;

    context = g_markup_parse_context_new (&parser, 0, builder, NULL);
    g_markup_parse_context_parse (context, xml, -1, NULL);
    g_markup_parse_context_end_parse (context, NULL);
    g_markup_parse_context_free (context);
}

static GVariant *
settings_deprecated_header_strv_to_variant (gchar **strv)
{
    GVariantBuilder builder;
    guint ii, length;

    length = g_strv_length (strv);

    /* Disregard an empty list. */
    if (length == 0)
        return NULL;

    g_variant_builder_init (&builder, G_VARIANT_TYPE ("a(sb)"));

    for (ii = 0; ii < length; ii++)
        settings_deprecated_header_parse_xml (strv[ii], &builder);

    return g_variant_builder_end (&builder);
}

static void
settings_deprecated_week_start_day_name_cb (GSettings *settings,
                                            const gchar *key)
{
    GDateWeekday weekday;
    gint tm_wday;

    weekday = g_settings_get_enum (settings, "week-start-day-name");
    tm_wday = e_weekday_to_tm_wday (weekday);
    e_settings_deprecated_set_int_with_change_test (settings, "week-start-day", tm_wday);
}

static void
settings_deprecated_work_day_monday_cb (GSettings *settings,
                                        const gchar *key)
{
    gint flags;

    flags = g_settings_get_int (settings, "working-days");
    if (g_settings_get_boolean (settings, "work-day-monday"))
        flags |= DEPRECATED_WORKING_DAYS_MONDAY;
    else
        flags &= ~DEPRECATED_WORKING_DAYS_MONDAY;
    e_settings_deprecated_set_int_with_change_test (settings, "working-days", flags);
}

static void
settings_deprecated_work_day_tuesday_cb (GSettings *settings,
                                         const gchar *key)
{
    gint flags;

    flags = g_settings_get_int (settings, "working-days");
    if (g_settings_get_boolean (settings, "work-day-tuesday"))
        flags |= DEPRECATED_WORKING_DAYS_TUESDAY;
    else
        flags &= ~DEPRECATED_WORKING_DAYS_TUESDAY;
    e_settings_deprecated_set_int_with_change_test (settings, "working-days", flags);
}

static void
settings_deprecated_work_day_wednesday_cb (GSettings *settings,
                                           const gchar *key)
{
    gint flags;

    flags = g_settings_get_int (settings, "working-days");
    if (g_settings_get_boolean (settings, "work-day-wednesday"))
        flags |= DEPRECATED_WORKING_DAYS_WEDNESDAY;
    else
        flags &= ~DEPRECATED_WORKING_DAYS_WEDNESDAY;
    e_settings_deprecated_set_int_with_change_test (settings, "working-days", flags);
}

static void
settings_deprecated_work_day_thursday_cb (GSettings *settings,
                                          const gchar *key)
{
    gint flags;

    flags = g_settings_get_int (settings, "working-days");
    if (g_settings_get_boolean (settings, "work-day-thursday"))
        flags |= DEPRECATED_WORKING_DAYS_THURSDAY;
    else
        flags &= ~DEPRECATED_WORKING_DAYS_THURSDAY;
    e_settings_deprecated_set_int_with_change_test (settings, "working-days", flags);
}

static void
settings_deprecated_work_day_friday_cb (GSettings *settings,
                                        const gchar *key)
{
    gint flags;

    flags = g_settings_get_int (settings, "working-days");
    if (g_settings_get_boolean (settings, "work-day-friday"))
        flags |= DEPRECATED_WORKING_DAYS_FRIDAY;
    else
        flags &= ~DEPRECATED_WORKING_DAYS_FRIDAY;
    e_settings_deprecated_set_int_with_change_test (settings, "working-days", flags);
}

static void
settings_deprecated_work_day_saturday_cb (GSettings *settings,
                                          const gchar *key)
{
    gint flags;

    flags = g_settings_get_int (settings, "working-days");
    if (g_settings_get_boolean (settings, "work-day-saturday"))
        flags |= DEPRECATED_WORKING_DAYS_SATURDAY;
    else
        flags &= ~DEPRECATED_WORKING_DAYS_SATURDAY;
    e_settings_deprecated_set_int_with_change_test (settings, "working-days", flags);
}

static void
settings_deprecated_work_day_sunday_cb (GSettings *settings,
                                        const gchar *key)
{
    gint flags;

    flags = g_settings_get_int (settings, "working-days");
    if (g_settings_get_boolean (settings, "work-day-sunday"))
        flags |= DEPRECATED_WORKING_DAYS_SUNDAY;
    else
        flags &= ~DEPRECATED_WORKING_DAYS_SUNDAY;
    e_settings_deprecated_set_int_with_change_test (settings, "working-days", flags);
}

static void
settings_deprecated_browser_close_on_reply_policy_cb (GSettings *settings,
                                                      const gchar *key)
{
    const gchar *deprecated_key = "prompt-on-reply-close-browser";

    switch (g_settings_get_enum (settings, key)) {
        case E_AUTOMATIC_ACTION_POLICY_ALWAYS:
            e_settings_deprecated_set_string_with_change_test (
                settings, deprecated_key, "always");
            break;
        case E_AUTOMATIC_ACTION_POLICY_NEVER:
            e_settings_deprecated_set_string_with_change_test (
                settings, deprecated_key, "never");
            break;
        default:
            e_settings_deprecated_set_string_with_change_test (
                settings, deprecated_key, "ask");
            break;
    }
}

static void
settings_deprecated_forward_style_name_cb (GSettings *settings,
                                           const gchar *key)
{
    EMailForwardStyle style;

    style = g_settings_get_enum (settings, "forward-style-name");
    e_settings_deprecated_set_int_with_change_test (settings, "forward-style", style);
}

static void
settings_deprecated_reply_style_name_cb (GSettings *settings,
                                         const gchar *key)
{
    EMailReplyStyle style;

    style = g_settings_get_enum (settings, "reply-style-name");
    e_settings_deprecated_set_int_with_change_test (settings, "reply-style", style);
}

static void
settings_deprecated_image_loading_policy_cb (GSettings *settings,
                                             const gchar *key)
{
    EMailImageLoadingPolicy policy;

    policy = g_settings_get_enum (settings, "image-loading-policy");
    e_settings_deprecated_set_int_with_change_test (settings, "load-http-images", policy);
}

static void
settings_deprecated_show_headers_cb (GSettings *settings,
                                     const gchar *key)
{
    GVariant *variant;
    gsize ii, n_children;
    gchar **strv = NULL;

    variant = g_settings_get_value (settings, key);
    n_children = g_variant_n_children (variant);

    strv = g_new0 (gchar *, n_children + 1);

    for (ii = 0; ii < n_children; ii++) {
        const gchar *name = NULL;
        gboolean enabled = FALSE;

        g_variant_get_child (
            variant, ii, "(&sb)", &name, &enabled);

        strv[ii] = g_strdup_printf (
            "<?xml version=\"1.0\"?>\n"
            "<header name=\"%s\"%s/>\n",
            name, enabled ? " enabled=\"\"" : "");
    }

    e_settings_deprecated_set_strv_with_change_test (
        settings, "headers",
        (const gchar * const *) strv);

    g_strfreev (strv);

    g_variant_unref (variant);
}

static void
settings_deprecated_dispose (GObject *object)
{
    ESettingsDeprecatedPrivate *priv;

    priv = E_SETTINGS_DEPRECATED_GET_PRIVATE (object);

    if (priv->week_start_day_name_handler_id > 0) {
        g_signal_handler_disconnect (
            priv->calendar_settings,
            priv->week_start_day_name_handler_id);
        priv->week_start_day_name_handler_id = 0;
    }

    if (priv->work_day_monday_handler_id > 0) {
        g_signal_handler_disconnect (
            priv->calendar_settings,
            priv->work_day_monday_handler_id);
        priv->work_day_monday_handler_id = 0;
    }

    if (priv->work_day_tuesday_handler_id > 0) {
        g_signal_handler_disconnect (
            priv->calendar_settings,
            priv->work_day_tuesday_handler_id);
        priv->work_day_tuesday_handler_id = 0;
    }

    if (priv->work_day_wednesday_handler_id > 0) {
        g_signal_handler_disconnect (
            priv->calendar_settings,
            priv->work_day_wednesday_handler_id);
        priv->work_day_wednesday_handler_id = 0;
    }

    if (priv->work_day_thursday_handler_id > 0) {
        g_signal_handler_disconnect (
            priv->calendar_settings,
            priv->work_day_thursday_handler_id);
        priv->work_day_thursday_handler_id = 0;
    }

    if (priv->work_day_friday_handler_id > 0) {
        g_signal_handler_disconnect (
            priv->calendar_settings,
            priv->work_day_friday_handler_id);
        priv->work_day_friday_handler_id = 0;
    }

    if (priv->work_day_saturday_handler_id > 0) {
        g_signal_handler_disconnect (
            priv->calendar_settings,
            priv->work_day_saturday_handler_id);
        priv->work_day_saturday_handler_id = 0;
    }

    if (priv->work_day_sunday_handler_id > 0) {
        g_signal_handler_disconnect (
            priv->calendar_settings,
            priv->work_day_sunday_handler_id);
        priv->work_day_sunday_handler_id = 0;
    }

    if (priv->browser_close_on_reply_policy_handler_id > 0) {
        g_signal_handler_disconnect (
            priv->mail_settings,
            priv->browser_close_on_reply_policy_handler_id);
        priv->browser_close_on_reply_policy_handler_id = 0;
    }

    if (priv->forward_style_name_handler_id > 0) {
        g_signal_handler_disconnect (
            priv->mail_settings,
            priv->forward_style_name_handler_id);
        priv->forward_style_name_handler_id = 0;
    }

    if (priv->reply_style_name_handler_id > 0) {
        g_signal_handler_disconnect (
            priv->mail_settings,
            priv->reply_style_name_handler_id);
        priv->reply_style_name_handler_id = 0;
    }

    if (priv->image_loading_policy_handler_id > 0) {
        g_signal_handler_disconnect (
            priv->mail_settings,
            priv->image_loading_policy_handler_id);
        priv->image_loading_policy_handler_id = 0;
    }

    if (priv->show_headers_handler_id > 0) {
        g_signal_handler_disconnect (
            priv->mail_settings,
            priv->show_headers_handler_id);
        priv->show_headers_handler_id = 0;
    }

    g_clear_object (&priv->calendar_settings);
    g_clear_object (&priv->mail_settings);

    /* Chain up to parent's dispose() method. */
    G_OBJECT_CLASS (e_settings_deprecated_parent_class)->dispose (object);
}

static void
settings_deprecated_constructed (GObject *object)
{
    ESettingsDeprecatedPrivate *priv;
    GVariant *variant;
    gulong handler_id;
    gchar *string_value;
    gchar **strv_value;
    gint int_value;

    priv = E_SETTINGS_DEPRECATED_GET_PRIVATE (object);

    /* Chain up to parent's constructed() method. */
    G_OBJECT_CLASS (e_settings_deprecated_parent_class)->
        constructed (object);

    /* Migrate values from deprecated to preferred keys. */

    int_value = g_settings_get_int (
        priv->calendar_settings, "week-start-day");
    g_settings_set_enum (
        priv->calendar_settings, "week-start-day-name",
        e_weekday_from_tm_wday (int_value));

    int_value = g_settings_get_int (
        priv->calendar_settings, "working-days");
    g_settings_set_boolean (
        priv->calendar_settings, "work-day-monday",
        (int_value & DEPRECATED_WORKING_DAYS_MONDAY) != 0);
    g_settings_set_boolean (
        priv->calendar_settings, "work-day-tuesday",
        (int_value & DEPRECATED_WORKING_DAYS_TUESDAY) != 0);
    g_settings_set_boolean (
        priv->calendar_settings, "work-day-wednesday",
        (int_value & DEPRECATED_WORKING_DAYS_WEDNESDAY) != 0);
    g_settings_set_boolean (
        priv->calendar_settings, "work-day-thursday",
        (int_value & DEPRECATED_WORKING_DAYS_THURSDAY) != 0);
    g_settings_set_boolean (
        priv->calendar_settings, "work-day-friday",
        (int_value & DEPRECATED_WORKING_DAYS_FRIDAY) != 0);
    g_settings_set_boolean (
        priv->calendar_settings, "work-day-saturday",
        (int_value & DEPRECATED_WORKING_DAYS_SATURDAY) != 0);
    g_settings_set_boolean (
        priv->calendar_settings, "work-day-sunday",
        (int_value & DEPRECATED_WORKING_DAYS_SUNDAY) != 0);

    string_value = g_settings_get_string (
        priv->mail_settings, "prompt-on-reply-close-browser");
    if (g_strcmp0 (string_value, "always") == 0) {
        g_settings_set_enum (
            priv->mail_settings,
            "browser-close-on-reply-policy",
            E_AUTOMATIC_ACTION_POLICY_ALWAYS);
    } else if (g_strcmp0 (string_value, "never") == 0) {
        g_settings_set_enum (
            priv->mail_settings,
            "browser-close-on-reply-policy",
            E_AUTOMATIC_ACTION_POLICY_NEVER);
    } else {
        g_settings_set_enum (
            priv->mail_settings,
            "browser-close-on-reply-policy",
            E_AUTOMATIC_ACTION_POLICY_ASK);
    }
    g_free (string_value);

    int_value = g_settings_get_int (
        priv->mail_settings, "forward-style");
    g_settings_set_enum (
        priv->mail_settings, "forward-style-name", int_value);

    strv_value = g_settings_get_strv (priv->mail_settings, "headers");
    variant = settings_deprecated_header_strv_to_variant (strv_value);
    if (variant != NULL)
        g_settings_set_value (
            priv->mail_settings, "show-headers", variant);
    else
        g_settings_reset (priv->mail_settings, "show-headers");
    g_strfreev (strv_value);

    int_value = g_settings_get_int (
        priv->mail_settings, "reply-style");
    g_settings_set_enum (
        priv->mail_settings, "reply-style-name", int_value);

    int_value = g_settings_get_int (
        priv->mail_settings, "load-http-images");
    g_settings_set_enum (
        priv->mail_settings, "image-loading-policy", int_value);

    /* Write changes back to the deprecated keys. */

    handler_id = g_signal_connect (
        priv->calendar_settings, "changed::week-start-day-name",
        G_CALLBACK (settings_deprecated_week_start_day_name_cb), NULL);
    priv->week_start_day_name_handler_id = handler_id;

    handler_id = g_signal_connect (
        priv->calendar_settings, "changed::work-day-monday",
        G_CALLBACK (settings_deprecated_work_day_monday_cb), NULL);
    priv->work_day_monday_handler_id = handler_id;

    handler_id = g_signal_connect (
        priv->calendar_settings, "changed::work-day-tuesday",
        G_CALLBACK (settings_deprecated_work_day_tuesday_cb), NULL);
    priv->work_day_tuesday_handler_id = handler_id;

    handler_id = g_signal_connect (
        priv->calendar_settings, "changed::work-day-wednesday",
        G_CALLBACK (settings_deprecated_work_day_wednesday_cb), NULL);
    priv->work_day_wednesday_handler_id = handler_id;

    handler_id = g_signal_connect (
        priv->calendar_settings, "changed::work-day-thursday",
        G_CALLBACK (settings_deprecated_work_day_thursday_cb), NULL);
    priv->work_day_thursday_handler_id = handler_id;

    handler_id = g_signal_connect (
        priv->calendar_settings, "changed::work-day-friday",
        G_CALLBACK (settings_deprecated_work_day_friday_cb), NULL);
    priv->work_day_friday_handler_id = handler_id;

    handler_id = g_signal_connect (
        priv->calendar_settings, "changed::work-day-saturday",
        G_CALLBACK (settings_deprecated_work_day_saturday_cb), NULL);
    priv->work_day_saturday_handler_id = handler_id;

    handler_id = g_signal_connect (
        priv->calendar_settings, "changed::work-day-sunday",
        G_CALLBACK (settings_deprecated_work_day_sunday_cb), NULL);
    priv->work_day_sunday_handler_id = handler_id;

    handler_id = g_signal_connect (
        priv->mail_settings, "changed::browser-close-on-reply-policy",
        G_CALLBACK (settings_deprecated_browser_close_on_reply_policy_cb), NULL);
    priv->browser_close_on_reply_policy_handler_id = handler_id;

    handler_id = g_signal_connect (
        priv->mail_settings, "changed::forward-style-name",
        G_CALLBACK (settings_deprecated_forward_style_name_cb), NULL);
    priv->forward_style_name_handler_id = handler_id;

    handler_id = g_signal_connect (
        priv->mail_settings, "changed::reply-style-name",
        G_CALLBACK (settings_deprecated_reply_style_name_cb), NULL);
    priv->reply_style_name_handler_id = handler_id;

    handler_id = g_signal_connect (
        priv->mail_settings, "changed::image-loading-policy",
        G_CALLBACK (settings_deprecated_image_loading_policy_cb), NULL);
    priv->image_loading_policy_handler_id = handler_id;

    handler_id = g_signal_connect (
        priv->mail_settings, "changed::show-headers",
        G_CALLBACK (settings_deprecated_show_headers_cb), NULL);
    priv->show_headers_handler_id = handler_id;
}

static void
e_settings_deprecated_class_init (ESettingsDeprecatedClass *class)
{
    GObjectClass *object_class;
    EExtensionClass *extension_class;

    g_type_class_add_private (class, sizeof (ESettingsDeprecatedPrivate));

    object_class = G_OBJECT_CLASS (class);
    object_class->dispose = settings_deprecated_dispose;
    object_class->constructed = settings_deprecated_constructed;

    extension_class = E_EXTENSION_CLASS (class);
    extension_class->extensible_type = E_TYPE_SHELL;
}

static void
e_settings_deprecated_class_finalize (ESettingsDeprecatedClass *class)
{
}

static void
e_settings_deprecated_init (ESettingsDeprecated *extension)
{
    GSettings *settings;

    extension->priv = E_SETTINGS_DEPRECATED_GET_PRIVATE (extension);

    settings = g_settings_new ("org.gnome.evolution.calendar");
    extension->priv->calendar_settings = settings;

    settings = g_settings_new ("org.gnome.evolution.mail");
    extension->priv->mail_settings = settings;
}

void
e_settings_deprecated_type_register (GTypeModule *type_module)
{
    /* XXX G_DEFINE_DYNAMIC_TYPE declares a static type registration
     *     function, so we have to wrap it with a public function in
     *     order to register types from a separate compilation unit. */
    e_settings_deprecated_register_type (type_module);
}