~ubuntu-branches/ubuntu/quantal/evolution-data-server/quantal

« back to all changes in this revision

Viewing changes to camel/camel-imapx-settings.c

  • Committer: Package Import Robot
  • Author(s): Mathieu Trudel-Lapierre
  • Date: 2012-07-03 22:41:23 UTC
  • mfrom: (1.1.100)
  • Revision ID: package-import@ubuntu.com-20120703224123-90dydkyfyvff8s0s
Tags: 3.5.3.1-0ubuntu1
* New upstream release 3.5.3.1.
* debian/control:
  - Drop libgconf2-dev from Build-Depends.
  - Bump versions for glib, goa, and libsoup in Build-Depends.
  - Add a Build-Depends on libgcr-3-dev (>= 3.4)
  - Rename packages following upstream SONAME changes.
  - Add Depends on libgnome-keyring-dev to libedataserver1.2-dev.
* debian/rules:
  - Update mkshlibs arguments for libcamel-1.2-38 instead of -33; as it was
    renamed in control due to the soname change.
  - Strip out -Bsymbolic-functions from LDFLAGS.
* Renamed install files in debian/:
  - libcamel-1.2-33.install => libcamel-1.2-38.install
  - libebackend-1.2-2.install => libebackend-1.2-4.install
  - libebook-1.2-13.install => libebook-1.2-17.install
  - libecal-1.2-11.install => libecal-1.2-15.install
  - libedata-book-1.2-13.install => libedata-book-1.2-15.install
  - libedata-cal-1.2-15.install => libedata-cal-1.2-18.install
  - libedataserver-1.2-16.install => libedataserver-1.2-17.install
  - libedataserverui-3.0-1.install => libedataserverui-3.0-4.install
* debian/patches/google_tests_fpic.patch: build tests with -fPIC; otherwise
  build fails.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * camel-imapx-settings.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 "camel-imapx-settings.h"
 
20
 
 
21
#define MIN_CONCURRENT_CONNECTIONS 1
 
22
#define MAX_CONCURRENT_CONNECTIONS 7
 
23
 
 
24
#define CAMEL_IMAPX_SETTINGS_GET_PRIVATE(obj) \
 
25
        (G_TYPE_INSTANCE_GET_PRIVATE \
 
26
        ((obj), CAMEL_TYPE_IMAPX_SETTINGS, CamelIMAPXSettingsPrivate))
 
27
 
 
28
struct _CamelIMAPXSettingsPrivate {
 
29
        GMutex *property_lock;
 
30
        gchar *namespace;
 
31
        gchar *shell_command;
 
32
 
 
33
        guint batch_fetch_count;
 
34
        guint concurrent_connections;
 
35
 
 
36
        gboolean check_all;
 
37
        gboolean check_subscribed;
 
38
        gboolean filter_all;
 
39
        gboolean filter_junk;
 
40
        gboolean filter_junk_inbox;
 
41
        gboolean use_idle;
 
42
        gboolean use_mobile_mode;
 
43
        gboolean use_namespace;
 
44
        gboolean use_qresync;
 
45
        gboolean use_shell_command;
 
46
        gboolean use_subscriptions;
 
47
 
 
48
        CamelSortType fetch_order;
 
49
};
 
50
 
 
51
enum {
 
52
        PROP_0,
 
53
        PROP_AUTH_MECHANISM,
 
54
        PROP_BATCH_FETCH_COUNT,
 
55
        PROP_CHECK_ALL,
 
56
        PROP_CHECK_SUBSCRIBED,
 
57
        PROP_CONCURRENT_CONNECTIONS,
 
58
        PROP_FETCH_ORDER,
 
59
        PROP_FILTER_ALL,
 
60
        PROP_FILTER_JUNK,
 
61
        PROP_FILTER_JUNK_INBOX,
 
62
        PROP_HOST,
 
63
        PROP_MOBILE_MODE,
 
64
        PROP_NAMESPACE,
 
65
        PROP_PORT,
 
66
        PROP_SECURITY_METHOD,
 
67
        PROP_SHELL_COMMAND,
 
68
        PROP_USER,
 
69
        PROP_USE_IDLE,
 
70
        PROP_USE_NAMESPACE,
 
71
        PROP_USE_QRESYNC,
 
72
        PROP_USE_SHELL_COMMAND,
 
73
        PROP_USE_SUBSCRIPTIONS
 
74
};
 
75
 
 
76
G_DEFINE_TYPE_WITH_CODE (
 
77
        CamelIMAPXSettings,
 
78
        camel_imapx_settings,
 
79
        CAMEL_TYPE_OFFLINE_SETTINGS,
 
80
        G_IMPLEMENT_INTERFACE (
 
81
                CAMEL_TYPE_NETWORK_SETTINGS, NULL))
 
82
 
 
83
static void
 
84
imapx_settings_set_property (GObject *object,
 
85
                             guint property_id,
 
86
                             const GValue *value,
 
87
                             GParamSpec *pspec)
 
88
{
 
89
        switch (property_id) {
 
90
                case PROP_AUTH_MECHANISM:
 
91
                        camel_network_settings_set_auth_mechanism (
 
92
                                CAMEL_NETWORK_SETTINGS (object),
 
93
                                g_value_get_string (value));
 
94
                        return;
 
95
 
 
96
                case PROP_BATCH_FETCH_COUNT:
 
97
                        camel_imapx_settings_set_batch_fetch_count (
 
98
                                CAMEL_IMAPX_SETTINGS (object),
 
99
                                g_value_get_uint (value));
 
100
                        return;
 
101
 
 
102
                case PROP_CHECK_ALL:
 
103
                        camel_imapx_settings_set_check_all (
 
104
                                CAMEL_IMAPX_SETTINGS (object),
 
105
                                g_value_get_boolean (value));
 
106
                        return;
 
107
 
 
108
                case PROP_CHECK_SUBSCRIBED:
 
109
                        camel_imapx_settings_set_check_subscribed (
 
110
                                CAMEL_IMAPX_SETTINGS (object),
 
111
                                g_value_get_boolean (value));
 
112
                        return;
 
113
 
 
114
                case PROP_CONCURRENT_CONNECTIONS:
 
115
                        camel_imapx_settings_set_concurrent_connections (
 
116
                                CAMEL_IMAPX_SETTINGS (object),
 
117
                                g_value_get_uint (value));
 
118
                        return;
 
119
 
 
120
                case PROP_FETCH_ORDER:
 
121
                        camel_imapx_settings_set_fetch_order (
 
122
                                CAMEL_IMAPX_SETTINGS (object),
 
123
                                g_value_get_enum (value));
 
124
                        return;
 
125
 
 
126
                case PROP_FILTER_ALL:
 
127
                        camel_imapx_settings_set_filter_all (
 
128
                                CAMEL_IMAPX_SETTINGS (object),
 
129
                                g_value_get_boolean (value));
 
130
                        return;
 
131
 
 
132
                case PROP_FILTER_JUNK:
 
133
                        camel_imapx_settings_set_filter_junk (
 
134
                                CAMEL_IMAPX_SETTINGS (object),
 
135
                                g_value_get_boolean (value));
 
136
                        return;
 
137
 
 
138
                case PROP_FILTER_JUNK_INBOX:
 
139
                        camel_imapx_settings_set_filter_junk_inbox (
 
140
                                CAMEL_IMAPX_SETTINGS (object),
 
141
                                g_value_get_boolean (value));
 
142
                        return;
 
143
 
 
144
                case PROP_HOST:
 
145
                        camel_network_settings_set_host (
 
146
                                CAMEL_NETWORK_SETTINGS (object),
 
147
                                g_value_get_string (value));
 
148
                        return;
 
149
 
 
150
                case PROP_MOBILE_MODE:
 
151
                        camel_imapx_settings_set_mobile_mode (
 
152
                                CAMEL_IMAPX_SETTINGS (object),
 
153
                                g_value_get_boolean (value));
 
154
                        return;
 
155
 
 
156
                case PROP_NAMESPACE:
 
157
                        camel_imapx_settings_set_namespace (
 
158
                                CAMEL_IMAPX_SETTINGS (object),
 
159
                                g_value_get_string (value));
 
160
                        return;
 
161
 
 
162
                case PROP_PORT:
 
163
                        camel_network_settings_set_port (
 
164
                                CAMEL_NETWORK_SETTINGS (object),
 
165
                                g_value_get_uint (value));
 
166
                        return;
 
167
 
 
168
                case PROP_SECURITY_METHOD:
 
169
                        camel_network_settings_set_security_method (
 
170
                                CAMEL_NETWORK_SETTINGS (object),
 
171
                                g_value_get_enum (value));
 
172
                        return;
 
173
 
 
174
                case PROP_SHELL_COMMAND:
 
175
                        camel_imapx_settings_set_shell_command (
 
176
                                CAMEL_IMAPX_SETTINGS (object),
 
177
                                g_value_get_string (value));
 
178
                        return;
 
179
 
 
180
                case PROP_USER:
 
181
                        camel_network_settings_set_user (
 
182
                                CAMEL_NETWORK_SETTINGS (object),
 
183
                                g_value_get_string (value));
 
184
                        return;
 
185
 
 
186
                case PROP_USE_IDLE:
 
187
                        camel_imapx_settings_set_use_idle (
 
188
                                CAMEL_IMAPX_SETTINGS (object),
 
189
                                g_value_get_boolean (value));
 
190
                        return;
 
191
 
 
192
                case PROP_USE_NAMESPACE:
 
193
                        camel_imapx_settings_set_use_namespace (
 
194
                                CAMEL_IMAPX_SETTINGS (object),
 
195
                                g_value_get_boolean (value));
 
196
                        return;
 
197
 
 
198
                case PROP_USE_QRESYNC:
 
199
                        camel_imapx_settings_set_use_qresync (
 
200
                                CAMEL_IMAPX_SETTINGS (object),
 
201
                                g_value_get_boolean (value));
 
202
                        return;
 
203
 
 
204
                case PROP_USE_SHELL_COMMAND:
 
205
                        camel_imapx_settings_set_use_shell_command (
 
206
                                CAMEL_IMAPX_SETTINGS (object),
 
207
                                g_value_get_boolean (value));
 
208
                        return;
 
209
 
 
210
                case PROP_USE_SUBSCRIPTIONS:
 
211
                        camel_imapx_settings_set_use_subscriptions (
 
212
                                CAMEL_IMAPX_SETTINGS (object),
 
213
                                g_value_get_boolean (value));
 
214
                        return;
 
215
        }
 
216
 
 
217
        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
 
218
}
 
219
 
 
220
static void
 
221
imapx_settings_get_property (GObject *object,
 
222
                             guint property_id,
 
223
                             GValue *value,
 
224
                             GParamSpec *pspec)
 
225
{
 
226
        switch (property_id) {
 
227
                case PROP_AUTH_MECHANISM:
 
228
                        g_value_take_string (
 
229
                                value,
 
230
                                camel_network_settings_dup_auth_mechanism (
 
231
                                CAMEL_NETWORK_SETTINGS (object)));
 
232
                        return;
 
233
 
 
234
                case PROP_BATCH_FETCH_COUNT:
 
235
                        g_value_set_uint (
 
236
                                value,
 
237
                                camel_imapx_settings_get_batch_fetch_count (
 
238
                                CAMEL_IMAPX_SETTINGS (object)));
 
239
                        return;
 
240
 
 
241
                case PROP_CHECK_ALL:
 
242
                        g_value_set_boolean (
 
243
                                value,
 
244
                                camel_imapx_settings_get_check_all (
 
245
                                CAMEL_IMAPX_SETTINGS (object)));
 
246
                        return;
 
247
 
 
248
                case PROP_CHECK_SUBSCRIBED:
 
249
                        g_value_set_boolean (
 
250
                                value,
 
251
                                camel_imapx_settings_get_check_subscribed (
 
252
                                CAMEL_IMAPX_SETTINGS (object)));
 
253
                        return;
 
254
 
 
255
                case PROP_CONCURRENT_CONNECTIONS:
 
256
                        g_value_set_uint (
 
257
                                value,
 
258
                                camel_imapx_settings_get_concurrent_connections (
 
259
                                CAMEL_IMAPX_SETTINGS (object)));
 
260
                        return;
 
261
 
 
262
                case PROP_FETCH_ORDER:
 
263
                        g_value_set_enum (
 
264
                                value,
 
265
                                camel_imapx_settings_get_fetch_order (
 
266
                                CAMEL_IMAPX_SETTINGS (object)));
 
267
                        return;
 
268
 
 
269
                case PROP_FILTER_ALL:
 
270
                        g_value_set_boolean (
 
271
                                value,
 
272
                                camel_imapx_settings_get_filter_all (
 
273
                                CAMEL_IMAPX_SETTINGS (object)));
 
274
                        return;
 
275
 
 
276
                case PROP_FILTER_JUNK:
 
277
                        g_value_set_boolean (
 
278
                                value,
 
279
                                camel_imapx_settings_get_filter_junk (
 
280
                                CAMEL_IMAPX_SETTINGS (object)));
 
281
                        return;
 
282
 
 
283
                case PROP_FILTER_JUNK_INBOX:
 
284
                        g_value_set_boolean (
 
285
                                value,
 
286
                                camel_imapx_settings_get_filter_junk_inbox (
 
287
                                CAMEL_IMAPX_SETTINGS (object)));
 
288
                        return;
 
289
 
 
290
                case PROP_HOST:
 
291
                        g_value_take_string (
 
292
                                value,
 
293
                                camel_network_settings_dup_host (
 
294
                                CAMEL_NETWORK_SETTINGS (object)));
 
295
                        return;
 
296
 
 
297
                case PROP_MOBILE_MODE:
 
298
                        g_value_set_boolean (
 
299
                                value,
 
300
                                camel_imapx_settings_get_mobile_mode (
 
301
                                CAMEL_IMAPX_SETTINGS (object)));
 
302
                        return;
 
303
 
 
304
                case PROP_NAMESPACE:
 
305
                        g_value_take_string (
 
306
                                value,
 
307
                                camel_imapx_settings_dup_namespace (
 
308
                                CAMEL_IMAPX_SETTINGS (object)));
 
309
                        return;
 
310
 
 
311
                case PROP_PORT:
 
312
                        g_value_set_uint (
 
313
                                value,
 
314
                                camel_network_settings_get_port (
 
315
                                CAMEL_NETWORK_SETTINGS (object)));
 
316
                        return;
 
317
 
 
318
                case PROP_SECURITY_METHOD:
 
319
                        g_value_set_enum (
 
320
                                value,
 
321
                                camel_network_settings_get_security_method (
 
322
                                CAMEL_NETWORK_SETTINGS (object)));
 
323
                        return;
 
324
 
 
325
                case PROP_SHELL_COMMAND:
 
326
                        g_value_take_string (
 
327
                                value,
 
328
                                camel_imapx_settings_dup_shell_command (
 
329
                                CAMEL_IMAPX_SETTINGS (object)));
 
330
                        return;
 
331
 
 
332
                case PROP_USER:
 
333
                        g_value_take_string (
 
334
                                value,
 
335
                                camel_network_settings_dup_user (
 
336
                                CAMEL_NETWORK_SETTINGS (object)));
 
337
                        return;
 
338
 
 
339
                case PROP_USE_IDLE:
 
340
                        g_value_set_boolean (
 
341
                                value,
 
342
                                camel_imapx_settings_get_use_idle (
 
343
                                CAMEL_IMAPX_SETTINGS (object)));
 
344
                        return;
 
345
 
 
346
                case PROP_USE_NAMESPACE:
 
347
                        g_value_set_boolean (
 
348
                                value,
 
349
                                camel_imapx_settings_get_use_namespace (
 
350
                                CAMEL_IMAPX_SETTINGS (object)));
 
351
                        return;
 
352
 
 
353
                case PROP_USE_QRESYNC:
 
354
                        g_value_set_boolean (
 
355
                                value,
 
356
                                camel_imapx_settings_get_use_qresync (
 
357
                                CAMEL_IMAPX_SETTINGS (object)));
 
358
                        return;
 
359
 
 
360
                case PROP_USE_SHELL_COMMAND:
 
361
                        g_value_set_boolean (
 
362
                                value,
 
363
                                camel_imapx_settings_get_use_shell_command (
 
364
                                CAMEL_IMAPX_SETTINGS (object)));
 
365
                        return;
 
366
 
 
367
                case PROP_USE_SUBSCRIPTIONS:
 
368
                        g_value_set_boolean (
 
369
                                value,
 
370
                                camel_imapx_settings_get_use_subscriptions (
 
371
                                CAMEL_IMAPX_SETTINGS (object)));
 
372
                        return;
 
373
        }
 
374
 
 
375
        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
 
376
}
 
377
 
 
378
static void
 
379
imapx_settings_finalize (GObject *object)
 
380
{
 
381
        CamelIMAPXSettingsPrivate *priv;
 
382
 
 
383
        priv = CAMEL_IMAPX_SETTINGS_GET_PRIVATE (object);
 
384
 
 
385
        g_mutex_free (priv->property_lock);
 
386
 
 
387
        g_free (priv->namespace);
 
388
        g_free (priv->shell_command);
 
389
 
 
390
        /* Chain up to parent's finalize() method. */
 
391
        G_OBJECT_CLASS (camel_imapx_settings_parent_class)->finalize (object);
 
392
}
 
393
 
 
394
static void
 
395
camel_imapx_settings_class_init (CamelIMAPXSettingsClass *class)
 
396
{
 
397
        GObjectClass *object_class;
 
398
 
 
399
        g_type_class_add_private (class, sizeof (CamelIMAPXSettingsPrivate));
 
400
 
 
401
        object_class = G_OBJECT_CLASS (class);
 
402
        object_class->set_property = imapx_settings_set_property;
 
403
        object_class->get_property = imapx_settings_get_property;
 
404
        object_class->finalize = imapx_settings_finalize;
 
405
 
 
406
        /* Inherited from CamelNetworkSettings. */
 
407
        g_object_class_override_property (
 
408
                object_class,
 
409
                PROP_AUTH_MECHANISM,
 
410
                "auth-mechanism");
 
411
 
 
412
        g_object_class_install_property (
 
413
                object_class,
 
414
                PROP_BATCH_FETCH_COUNT,
 
415
                g_param_spec_uint (
 
416
                        "batch-fetch-count",
 
417
                        "Batch Fetch Count",
 
418
                        "Number of envelopes to fetch at once",
 
419
                        0,
 
420
                        G_MAXUINT,
 
421
                        500,
 
422
                        G_PARAM_READWRITE |
 
423
                        G_PARAM_CONSTRUCT |
 
424
                        G_PARAM_STATIC_STRINGS));
 
425
 
 
426
        g_object_class_install_property (
 
427
                object_class,
 
428
                PROP_CHECK_ALL,
 
429
                g_param_spec_boolean (
 
430
                        "check-all",
 
431
                        "Check All",
 
432
                        "Check all folders for new messages",
 
433
                        FALSE,
 
434
                        G_PARAM_READWRITE |
 
435
                        G_PARAM_CONSTRUCT |
 
436
                        G_PARAM_STATIC_STRINGS));
 
437
 
 
438
        g_object_class_install_property (
 
439
                object_class,
 
440
                PROP_CHECK_SUBSCRIBED,
 
441
                g_param_spec_boolean (
 
442
                        "check-subscribed",
 
443
                        "Check Subscribed",
 
444
                        "Check only subscribed folders for new messages",
 
445
                        FALSE,
 
446
                        G_PARAM_READWRITE |
 
447
                        G_PARAM_CONSTRUCT |
 
448
                        G_PARAM_STATIC_STRINGS));
 
449
 
 
450
        g_object_class_install_property (
 
451
                object_class,
 
452
                PROP_CONCURRENT_CONNECTIONS,
 
453
                g_param_spec_uint (
 
454
                        "concurrent-connections",
 
455
                        "Concurrent Connections",
 
456
                        "Number of concurrent IMAP connections to use",
 
457
                        MIN_CONCURRENT_CONNECTIONS,
 
458
                        MAX_CONCURRENT_CONNECTIONS,
 
459
                        5,
 
460
                        G_PARAM_READWRITE |
 
461
                        G_PARAM_CONSTRUCT |
 
462
                        G_PARAM_STATIC_STRINGS));
 
463
 
 
464
        g_object_class_install_property (
 
465
                object_class,
 
466
                PROP_FETCH_ORDER,
 
467
                g_param_spec_enum (
 
468
                        "fetch-order",
 
469
                        "Fetch Order",
 
470
                        "Order in which new messages should be fetched",
 
471
                        CAMEL_TYPE_SORT_TYPE,
 
472
                        CAMEL_SORT_ASCENDING,
 
473
                        G_PARAM_READWRITE |
 
474
                        G_PARAM_CONSTRUCT |
 
475
                        G_PARAM_STATIC_STRINGS));
 
476
 
 
477
        g_object_class_install_property (
 
478
                object_class,
 
479
                PROP_FILTER_ALL,
 
480
                g_param_spec_boolean (
 
481
                        "filter-all",
 
482
                        "Filter All",
 
483
                        "Whether to apply filters in all folders",
 
484
                        FALSE,
 
485
                        G_PARAM_READWRITE |
 
486
                        G_PARAM_CONSTRUCT |
 
487
                        G_PARAM_STATIC_STRINGS));
 
488
 
 
489
        g_object_class_install_property (
 
490
                object_class,
 
491
                PROP_FILTER_JUNK,
 
492
                g_param_spec_boolean (
 
493
                        "filter-junk",
 
494
                        "Filter Junk",
 
495
                        "Whether to filter junk from all folders",
 
496
                        FALSE,
 
497
                        G_PARAM_READWRITE |
 
498
                        G_PARAM_CONSTRUCT |
 
499
                        G_PARAM_STATIC_STRINGS));
 
500
 
 
501
        g_object_class_install_property (
 
502
                object_class,
 
503
                PROP_FILTER_JUNK_INBOX,
 
504
                g_param_spec_boolean (
 
505
                        "filter-junk-inbox",
 
506
                        "Filter Junk Inbox",
 
507
                        "Whether to filter junk from Inbox only",
 
508
                        FALSE,
 
509
                        G_PARAM_READWRITE |
 
510
                        G_PARAM_CONSTRUCT |
 
511
                        G_PARAM_STATIC_STRINGS));
 
512
 
 
513
        g_object_class_install_property (
 
514
                object_class,
 
515
                PROP_MOBILE_MODE,
 
516
                g_param_spec_boolean (
 
517
                        "mobile-mode",
 
518
                        "Mobile Mode",
 
519
                        "Mobile mode which adjusts the IMAPX for Mobile clients",
 
520
                        FALSE,
 
521
                        G_PARAM_READWRITE |
 
522
                        G_PARAM_CONSTRUCT |
 
523
                        G_PARAM_STATIC_STRINGS));
 
524
 
 
525
        /* Inherited from CamelNetworkSettings. */
 
526
        g_object_class_override_property (
 
527
                object_class,
 
528
                PROP_HOST,
 
529
                "host");
 
530
 
 
531
        g_object_class_install_property (
 
532
                object_class,
 
533
                PROP_NAMESPACE,
 
534
                g_param_spec_string (
 
535
                        "namespace",
 
536
                        "Namespace",
 
537
                        "Custom IMAP namespace",
 
538
                        NULL,
 
539
                        G_PARAM_READWRITE |
 
540
                        G_PARAM_CONSTRUCT |
 
541
                        G_PARAM_STATIC_STRINGS));
 
542
 
 
543
        /* Inherited from CamelNetworkSettings. */
 
544
        g_object_class_override_property (
 
545
                object_class,
 
546
                PROP_PORT,
 
547
                "port");
 
548
 
 
549
        /* Inherited from CamelNetworkSettings. */
 
550
        g_object_class_override_property (
 
551
                object_class,
 
552
                PROP_SECURITY_METHOD,
 
553
                "security-method");
 
554
 
 
555
        g_object_class_install_property (
 
556
                object_class,
 
557
                PROP_SHELL_COMMAND,
 
558
                g_param_spec_string (
 
559
                        "shell-command",
 
560
                        "Shell Command",
 
561
                        "Shell command for connecting to the server",
 
562
                        "ssh -C -l %u %h exec /usr/sbin/imapd",
 
563
                        G_PARAM_READWRITE |
 
564
                        G_PARAM_CONSTRUCT |
 
565
                        G_PARAM_STATIC_STRINGS));
 
566
 
 
567
        /* Inherited from CamelNetworkSettings. */
 
568
        g_object_class_override_property (
 
569
                object_class,
 
570
                PROP_USER,
 
571
                "user");
 
572
 
 
573
        g_object_class_install_property (
 
574
                object_class,
 
575
                PROP_USE_IDLE,
 
576
                g_param_spec_boolean (
 
577
                        "use-idle",
 
578
                        "Use IDLE",
 
579
                        "Whether to use the IDLE IMAP extension",
 
580
                        TRUE,
 
581
                        G_PARAM_READWRITE |
 
582
                        G_PARAM_CONSTRUCT |
 
583
                        G_PARAM_STATIC_STRINGS));
 
584
 
 
585
        g_object_class_install_property (
 
586
                object_class,
 
587
                PROP_USE_NAMESPACE,
 
588
                g_param_spec_boolean (
 
589
                        "use-namespace",
 
590
                        "Use Namespace",
 
591
                        "Whether to use a custom IMAP namespace",
 
592
                        FALSE,
 
593
                        G_PARAM_READWRITE |
 
594
                        G_PARAM_CONSTRUCT |
 
595
                        G_PARAM_STATIC_STRINGS));
 
596
 
 
597
        g_object_class_install_property (
 
598
                object_class,
 
599
                PROP_USE_QRESYNC,
 
600
                g_param_spec_boolean (
 
601
                        "use-qresync",
 
602
                        "Use QRESYNC",
 
603
                        "Whether to use the QRESYNC IMAP extension",
 
604
                        TRUE,
 
605
                        G_PARAM_READWRITE |
 
606
                        G_PARAM_CONSTRUCT |
 
607
                        G_PARAM_STATIC_STRINGS));
 
608
 
 
609
        g_object_class_install_property (
 
610
                object_class,
 
611
                PROP_USE_SHELL_COMMAND,
 
612
                g_param_spec_boolean (
 
613
                        "use-shell-command",
 
614
                        "Use Shell Command",
 
615
                        "Whether to use a custom shell "
 
616
                        "command to connect to the server",
 
617
                        FALSE,
 
618
                        G_PARAM_READWRITE |
 
619
                        G_PARAM_CONSTRUCT |
 
620
                        G_PARAM_STATIC_STRINGS));
 
621
 
 
622
        g_object_class_install_property (
 
623
                object_class,
 
624
                PROP_USE_SUBSCRIPTIONS,
 
625
                g_param_spec_boolean (
 
626
                        "use-subscriptions",
 
627
                        "Use Subscriptions",
 
628
                        "Whether to honor folder subscriptions",
 
629
                        TRUE,
 
630
                        G_PARAM_READWRITE |
 
631
                        G_PARAM_CONSTRUCT |
 
632
                        G_PARAM_STATIC_STRINGS));
 
633
}
 
634
 
 
635
static void
 
636
camel_imapx_settings_init (CamelIMAPXSettings *settings)
 
637
{
 
638
        settings->priv = CAMEL_IMAPX_SETTINGS_GET_PRIVATE (settings);
 
639
        settings->priv->property_lock = g_mutex_new ();
 
640
}
 
641
 
 
642
/**
 
643
 * camel_imapx_settings_get_batch_fetch_count:
 
644
 * @settings: a #CamelIMAPXSettings
 
645
 *
 
646
 * Returns the number of message envelopes to fetch at once.
 
647
 *
 
648
 * This is a tunable performance parameter and probably should not be
 
649
 * exposed in a graphical user interface.
 
650
 *
 
651
 * Returns: number of message envelopes to fetch at once
 
652
 *
 
653
 * Since: 3.2
 
654
 **/
 
655
guint
 
656
camel_imapx_settings_get_batch_fetch_count (CamelIMAPXSettings *settings)
 
657
{
 
658
        g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), 0);
 
659
 
 
660
        return settings->priv->batch_fetch_count;
 
661
}
 
662
 
 
663
/**
 
664
 * camel_imapx_settings_set_batch_fetch_count:
 
665
 * @settings: a #CamelIMAPXSettings
 
666
 * @batch_fetch_count: number of message envelopes to fetch at once
 
667
 *
 
668
 * Sets the number of message envelopes to fetch at once.
 
669
 *
 
670
 * This is a tunable performance parameter and probably should not be
 
671
 * exposed in a graphical user interface.
 
672
 *
 
673
 * Since: 3.2
 
674
 **/
 
675
void
 
676
camel_imapx_settings_set_batch_fetch_count (CamelIMAPXSettings *settings,
 
677
                                            guint batch_fetch_count)
 
678
{
 
679
        g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
 
680
 
 
681
        if (settings->priv->batch_fetch_count == batch_fetch_count)
 
682
                return;
 
683
 
 
684
        settings->priv->batch_fetch_count = batch_fetch_count;
 
685
 
 
686
        g_object_notify (G_OBJECT (settings), "batch-fetch-count");
 
687
}
 
688
 
 
689
/**
 
690
 * camel_imapx_settings_get_check_all:
 
691
 * @settings: a #CamelIMAPXSettings
 
692
 *
 
693
 * Returns whether to check all folders for new messages.
 
694
 *
 
695
 * Returns: whether to check all folders for new messages
 
696
 *
 
697
 * Since: 3.2
 
698
 **/
 
699
gboolean
 
700
camel_imapx_settings_get_check_all (CamelIMAPXSettings *settings)
 
701
{
 
702
        g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), FALSE);
 
703
 
 
704
        return settings->priv->check_all;
 
705
}
 
706
 
 
707
/**
 
708
 * camel_imapx_settings_set_check_all:
 
709
 * @settings: a #CamelIMAPXSettings
 
710
 * @check_all: whether to check all folders for new messages
 
711
 *
 
712
 * Sets whether to check all folders for new messages.
 
713
 *
 
714
 * Since: 3.2
 
715
 **/
 
716
void
 
717
camel_imapx_settings_set_check_all (CamelIMAPXSettings *settings,
 
718
                                    gboolean check_all)
 
719
{
 
720
        g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
 
721
 
 
722
        if ((settings->priv->check_all ? 1 : 0) == (check_all ? 1 : 0))
 
723
                return;
 
724
 
 
725
        settings->priv->check_all = check_all;
 
726
 
 
727
        g_object_notify (G_OBJECT (settings), "check-all");
 
728
}
 
729
 
 
730
/**
 
731
 * camel_imapx_settings_get_check_subscribed:
 
732
 * @settings: a #CamelIMAPXSettings
 
733
 *
 
734
 * Returns whether to check only subscribed folders for new messages.
 
735
 * Note that #CamelIMAPXSettings:check-all, if %TRUE, overrides this setting.
 
736
 *
 
737
 * Returns: whether to check only subscribed folders for new messages
 
738
 *
 
739
 * Since: 3.2
 
740
 **/
 
741
gboolean
 
742
camel_imapx_settings_get_check_subscribed (CamelIMAPXSettings *settings)
 
743
{
 
744
        g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), FALSE);
 
745
 
 
746
        return settings->priv->check_subscribed;
 
747
}
 
748
 
 
749
/**
 
750
 * camel_imapx_settings_set_check_subscribed:
 
751
 * @settings: a #CamelIMAPXSettings
 
752
 * @check_subscribed: whether to check only subscribed folders for new messages
 
753
 *
 
754
 * Sets whether to check only subscribed folders for new messages.  Note
 
755
 * that #CamelIMAPXSettings:check-all, if %TRUE, overrides this setting.
 
756
 *
 
757
 * Since: 3.2
 
758
 **/
 
759
void
 
760
camel_imapx_settings_set_check_subscribed (CamelIMAPXSettings *settings,
 
761
                                           gboolean check_subscribed)
 
762
{
 
763
        g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
 
764
 
 
765
        if ((settings->priv->check_subscribed ? 1 : 0) == (check_subscribed ? 1 : 0))
 
766
                return;
 
767
 
 
768
        settings->priv->check_subscribed = check_subscribed;
 
769
 
 
770
        g_object_notify (G_OBJECT (settings), "check-subscribed");
 
771
}
 
772
 
 
773
/**
 
774
 * camel_imapx_settings_get_concurrent_connections:
 
775
 * @settings: a #CamelIMAPXSettings
 
776
 * 
 
777
 * Returns the number of concurrent network connections to the IMAP server
 
778
 * to use for faster command/response processing.
 
779
 *
 
780
 * Returns: the number of concurrent connections to use
 
781
 *
 
782
 * Since: 3.2
 
783
 **/
 
784
guint
 
785
camel_imapx_settings_get_concurrent_connections (CamelIMAPXSettings *settings)
 
786
{
 
787
        g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), 1);
 
788
 
 
789
        return settings->priv->concurrent_connections;
 
790
}
 
791
 
 
792
/**
 
793
 * camel_imapx_settings_set_concurrent_connections:
 
794
 * @settings: a #CamelIMAPXSettings
 
795
 * @concurrent_connections: the number of concurrent connections to use
 
796
 *
 
797
 * Sets the number of concurrent network connections to the IMAP server to
 
798
 * use for faster command/response processing.
 
799
 *
 
800
 * The minimum number of connections is 1, the maximum is 7.  The
 
801
 * @concurrent_connections value will be clamped to these limits if
 
802
 * necessary.
 
803
 *
 
804
 * Since: 3.2
 
805
 **/
 
806
void
 
807
camel_imapx_settings_set_concurrent_connections (CamelIMAPXSettings *settings,
 
808
                                                 guint concurrent_connections)
 
809
{
 
810
        g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
 
811
 
 
812
        concurrent_connections = CLAMP (
 
813
                concurrent_connections,
 
814
                MIN_CONCURRENT_CONNECTIONS,
 
815
                MAX_CONCURRENT_CONNECTIONS);
 
816
 
 
817
        if (settings->priv->concurrent_connections == concurrent_connections)
 
818
                return;
 
819
 
 
820
        settings->priv->concurrent_connections = concurrent_connections;
 
821
 
 
822
        g_object_notify (G_OBJECT (settings), "concurrent-connections");
 
823
}
 
824
 
 
825
/**
 
826
 * camel_imapx_settings_get_fetch_order:
 
827
 * @settings: a #CamelIMAPXSettings
 
828
 *
 
829
 * Returns the order in which new messages should be fetched.
 
830
 *
 
831
 * Returns: the order in which new messages should be fetched
 
832
 *
 
833
 * Since: 3.2
 
834
 **/
 
835
CamelSortType
 
836
camel_imapx_settings_get_fetch_order (CamelIMAPXSettings *settings)
 
837
{
 
838
        g_return_val_if_fail (
 
839
                CAMEL_IS_IMAPX_SETTINGS (settings),
 
840
                CAMEL_SORT_ASCENDING);
 
841
 
 
842
        return settings->priv->fetch_order;
 
843
}
 
844
 
 
845
/**
 
846
 * camel_imapx_settings_set_fetch_order:
 
847
 * @settings: a #CamelIMAPXSettings
 
848
 * @fetch_order: the order in which new messages should be fetched
 
849
 *
 
850
 * Sets the order in which new messages should be fetched.
 
851
 *
 
852
 * Since: 3.2
 
853
 **/
 
854
void
 
855
camel_imapx_settings_set_fetch_order (CamelIMAPXSettings *settings,
 
856
                                      CamelSortType fetch_order)
 
857
{
 
858
        g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
 
859
 
 
860
        if (settings->priv->fetch_order == fetch_order)
 
861
                return;
 
862
 
 
863
        settings->priv->fetch_order = fetch_order;
 
864
 
 
865
        g_object_notify (G_OBJECT (settings), "fetch-order");
 
866
}
 
867
 
 
868
/**
 
869
 * camel_imapx_settings_get_filter_all:
 
870
 * @settings: a #CamelIMAPXSettings
 
871
 *
 
872
 * Returns whether apply filters in all folders.
 
873
 *
 
874
 * Returns: whether to apply filters in all folders
 
875
 *
 
876
 * Since: 3.4
 
877
 **/
 
878
gboolean
 
879
camel_imapx_settings_get_filter_all (CamelIMAPXSettings *settings)
 
880
{
 
881
        g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), FALSE);
 
882
 
 
883
        return settings->priv->filter_all;
 
884
}
 
885
 
 
886
/**
 
887
 * camel_imapx_settings_set_filter_all:
 
888
 * @settings: a #CamelIMAPXSettings
 
889
 * @filter_all: whether to apply filters in all folders
 
890
 *
 
891
 * Sets whether to apply filters in all folders.
 
892
 *
 
893
 * Since: 3.4
 
894
 **/
 
895
void
 
896
camel_imapx_settings_set_filter_all (CamelIMAPXSettings *settings,
 
897
                                     gboolean filter_all)
 
898
{
 
899
        g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
 
900
 
 
901
        if ((settings->priv->filter_all ? 1 : 0) == (filter_all ? 1 : 0))
 
902
                return;
 
903
 
 
904
        settings->priv->filter_all = filter_all;
 
905
 
 
906
        g_object_notify (G_OBJECT (settings), "filter-all");
 
907
}
 
908
 
 
909
/**
 
910
 * camel_imapx_settings_get_filter_junk:
 
911
 * @settings: a #CamelIMAPXSettings
 
912
 *
 
913
 * Returns whether to automatically find and tag junk messages amongst new
 
914
 * messages in all folders.
 
915
 *
 
916
 * Returns: whether to filter junk in all folders
 
917
 *
 
918
 * Since: 3.2
 
919
 **/
 
920
gboolean
 
921
camel_imapx_settings_get_filter_junk (CamelIMAPXSettings *settings)
 
922
{
 
923
        g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), FALSE);
 
924
 
 
925
        return settings->priv->filter_junk;
 
926
}
 
927
 
 
928
/**
 
929
 * camel_imapx_settings_set_filter_junk:
 
930
 * @settings: a #CamelIMAPXSettings
 
931
 * @filter_junk: whether to filter junk in all folders
 
932
 *
 
933
 * Sets whether to automatically find and tag junk messages amongst new
 
934
 * messages in all folders.
 
935
 *
 
936
 * Since: 3.2
 
937
 **/
 
938
void
 
939
camel_imapx_settings_set_filter_junk (CamelIMAPXSettings *settings,
 
940
                                      gboolean filter_junk)
 
941
{
 
942
        g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
 
943
 
 
944
        if ((settings->priv->filter_junk ? 1 : 0) == (filter_junk ? 1 : 0))
 
945
                return;
 
946
 
 
947
        settings->priv->filter_junk = filter_junk;
 
948
 
 
949
        g_object_notify (G_OBJECT (settings), "filter-junk");
 
950
}
 
951
 
 
952
/**
 
953
 * camel_imapx_settings_get_filter_junk_inbox:
 
954
 * @settings: a #CamelIMAPXSettings
 
955
 *
 
956
 * Returns whether to automatically find and tag junk messages amongst new
 
957
 * messages in the Inbox folder only.
 
958
 *
 
959
 * Returns: whether to filter junk in Inbox only
 
960
 *
 
961
 * Since: 3.2
 
962
 **/
 
963
gboolean
 
964
camel_imapx_settings_get_filter_junk_inbox (CamelIMAPXSettings *settings)
 
965
{
 
966
        g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), FALSE);
 
967
 
 
968
        return settings->priv->filter_junk_inbox;
 
969
}
 
970
 
 
971
/**
 
972
 * camel_imapx_settings_set_filter_junk_inbox:
 
973
 * @settings: a #CamelIMAPXSettings
 
974
 * @filter_junk_inbox: whether to filter junk in Inbox only
 
975
 *
 
976
 * Sets whether to automatically find and tag junk messages amongst new
 
977
 * messages in the Inbox folder only.
 
978
 *
 
979
 * Since: 3.2
 
980
 **/
 
981
void
 
982
camel_imapx_settings_set_filter_junk_inbox (CamelIMAPXSettings *settings,
 
983
                                            gboolean filter_junk_inbox)
 
984
{
 
985
        g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
 
986
 
 
987
        if ((settings->priv->filter_junk_inbox ? 1 : 0) == (filter_junk_inbox ? 1 : 0))
 
988
                return;
 
989
 
 
990
        settings->priv->filter_junk_inbox = filter_junk_inbox;
 
991
 
 
992
        g_object_notify (G_OBJECT (settings), "filter-junk-inbox");
 
993
}
 
994
 
 
995
/**
 
996
 * camel_imapx_settings_get_mobile_mode:
 
997
 * @settings: a #CamelIMAPXSettings
 
998
 *
 
999
 * Returns whether the backend is operating in mobile mode.
 
1000
 *
 
1001
 * Since: 3.2
 
1002
 **/
 
1003
gboolean
 
1004
camel_imapx_settings_get_mobile_mode (CamelIMAPXSettings *settings)
 
1005
{
 
1006
        g_return_val_if_fail (
 
1007
                CAMEL_IS_IMAPX_SETTINGS (settings),
 
1008
                CAMEL_SORT_ASCENDING);
 
1009
 
 
1010
        return settings->priv->use_mobile_mode;
 
1011
}
 
1012
 
 
1013
/**
 
1014
 * camel_imapx_settings_set_mobile_mode:
 
1015
 * @settings: a #CamelIMAPXSettings
 
1016
 * @mobile_mode: whether to operate in mobile mode.
 
1017
 *
 
1018
 * Sets the mode of operation as mobile or not for the backend.
 
1019
 *
 
1020
 * Since: 3.2
 
1021
 **/
 
1022
void
 
1023
camel_imapx_settings_set_mobile_mode (CamelIMAPXSettings *settings,
 
1024
                                      gboolean mobile_mode)
 
1025
{
 
1026
        g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
 
1027
 
 
1028
        if ((settings->priv->use_mobile_mode ? 1 : 0) == (mobile_mode ? 1 : 0))
 
1029
                return;
 
1030
 
 
1031
        settings->priv->use_mobile_mode = mobile_mode;
 
1032
 
 
1033
        g_object_notify (G_OBJECT (settings), "mobile-mode");
 
1034
}
 
1035
 
 
1036
/**
 
1037
 * camel_imapx_settings_get_namespace:
 
1038
 * @settings: a #CamelIMAPXSettings
 
1039
 *
 
1040
 * Returns the custom IMAP namespace in which to find folders.
 
1041
 *
 
1042
 * Returns: the custom IMAP namespace, or %NULL
 
1043
 *
 
1044
 * Since: 3.2
 
1045
 **/
 
1046
const gchar *
 
1047
camel_imapx_settings_get_namespace (CamelIMAPXSettings *settings)
 
1048
{
 
1049
        g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), NULL);
 
1050
 
 
1051
        return settings->priv->namespace;
 
1052
}
 
1053
 
 
1054
/**
 
1055
 * camel_imapx_settings_dup_namespace:
 
1056
 * @settings: a #CamelIMAPXSettings
 
1057
 *
 
1058
 * Thread-safe variation of camel_imapx_settings_get_namespace().
 
1059
 * Use this function when accessing @settings from multiple threads.
 
1060
 *
 
1061
 * The returned string should be freed with g_free() when no longer needed.
 
1062
 *
 
1063
 * Returns: a newly-allocated copy of #CamelIMAPXSettings:namespace
 
1064
 *
 
1065
 * Since: 3.4
 
1066
 **/
 
1067
gchar *
 
1068
camel_imapx_settings_dup_namespace (CamelIMAPXSettings *settings)
 
1069
{
 
1070
        const gchar *protected;
 
1071
        gchar *duplicate;
 
1072
 
 
1073
        g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), NULL);
 
1074
 
 
1075
        g_mutex_lock (settings->priv->property_lock);
 
1076
 
 
1077
        protected = camel_imapx_settings_get_namespace (settings);
 
1078
        duplicate = g_strdup (protected);
 
1079
 
 
1080
        g_mutex_unlock (settings->priv->property_lock);
 
1081
 
 
1082
        return duplicate;
 
1083
}
 
1084
 
 
1085
/**
 
1086
 * camel_imapx_settings_set_namespace:
 
1087
 * @settings: a #CamelIMAPXSettings
 
1088
 * @namespace_: an IMAP namespace, or %NULL
 
1089
 *
 
1090
 * Sets the custom IMAP namespace in which to find folders.  If @namespace_
 
1091
 * is %NULL, the default namespace is used.
 
1092
 *
 
1093
 * Since: 3.2
 
1094
 **/
 
1095
void
 
1096
camel_imapx_settings_set_namespace (CamelIMAPXSettings *settings,
 
1097
                                    const gchar *namespace_)
 
1098
{
 
1099
        g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
 
1100
 
 
1101
        /* The default namespace is an empty string. */
 
1102
        if (namespace_ == NULL)
 
1103
                namespace_ = "";
 
1104
 
 
1105
        g_mutex_lock (settings->priv->property_lock);
 
1106
 
 
1107
        if (g_strcmp0 (settings->priv->namespace, namespace_) == 0) {
 
1108
                g_mutex_unlock (settings->priv->property_lock);
 
1109
                return;
 
1110
        }
 
1111
 
 
1112
        g_free (settings->priv->namespace);
 
1113
        settings->priv->namespace = g_strdup (namespace_);
 
1114
 
 
1115
        g_mutex_unlock (settings->priv->property_lock);
 
1116
 
 
1117
        g_object_notify (G_OBJECT (settings), "namespace");
 
1118
}
 
1119
 
 
1120
/**
 
1121
 * camel_imapx_settings_get_shell_command:
 
1122
 * @settings: a #CamelIMAPXSettings
 
1123
 *
 
1124
 * Returns an optional shell command used to establish an input/output
 
1125
 * stream with an IMAP server.  Normally the input/output stream is
 
1126
 * established through a network socket.
 
1127
 *
 
1128
 * This option is useful only to a select few advanced users who likely
 
1129
 * administer their own IMAP server.  Most users will not understand what
 
1130
 * this option menas or how to use it.  Probably not worth exposing in a
 
1131
 * graphical interface.
 
1132
 *
 
1133
 * Returns: shell command for connecting to the server, or %NULL
 
1134
 *
 
1135
 * Since: 3.2
 
1136
 **/
 
1137
const gchar *
 
1138
camel_imapx_settings_get_shell_command (CamelIMAPXSettings *settings)
 
1139
{
 
1140
        g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), NULL);
 
1141
 
 
1142
        return settings->priv->shell_command;
 
1143
}
 
1144
 
 
1145
/**
 
1146
 * camel_imapx_settings_dup_shell_command:
 
1147
 * @settings: a #CamelIMAPXSettings
 
1148
 *
 
1149
 * Thread-safe variation of camel_imapx_settings_get_shell_command().
 
1150
 * Use this function when accessing @settings from multiple threads.
 
1151
 *
 
1152
 * The returned string should be freed with g_free() when no longer needed.
 
1153
 *
 
1154
 * Returns: a newly-allocated copy of #CamelIMAPXSettings:shell-command
 
1155
 *
 
1156
 * Since: 3.4
 
1157
 **/
 
1158
gchar *
 
1159
camel_imapx_settings_dup_shell_command (CamelIMAPXSettings *settings)
 
1160
{
 
1161
        const gchar *protected;
 
1162
        gchar *duplicate;
 
1163
 
 
1164
        g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), NULL);
 
1165
 
 
1166
        g_mutex_lock (settings->priv->property_lock);
 
1167
 
 
1168
        protected = camel_imapx_settings_get_shell_command (settings);
 
1169
        duplicate = g_strdup (protected);
 
1170
 
 
1171
        g_mutex_unlock (settings->priv->property_lock);
 
1172
 
 
1173
        return duplicate;
 
1174
}
 
1175
 
 
1176
/**
 
1177
 * camel_imapx_settings_set_shell_command:
 
1178
 * @settings: a #CamelIMAPXSettings
 
1179
 * @shell_command: shell command for connecting to the server, or %NULL
 
1180
 *
 
1181
 * Sets an optional shell command used to establish an input/output stream
 
1182
 * with an IMAP server.  Normally the input/output stream is established
 
1183
 * through a network socket.
 
1184
 *
 
1185
 * This option is useful only to a select few advanced users who likely
 
1186
 * administer their own IMAP server.  Most users will not understand what
 
1187
 * this option means or how to use it.  Probably not worth exposing in a
 
1188
 * graphical interface.
 
1189
 *
 
1190
 * Since: 3.2
 
1191
 **/
 
1192
void
 
1193
camel_imapx_settings_set_shell_command (CamelIMAPXSettings *settings,
 
1194
                                        const gchar *shell_command)
 
1195
{
 
1196
        g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
 
1197
 
 
1198
        /* An empty string is equivalent to NULL. */
 
1199
        if (shell_command != NULL && *shell_command == '\0')
 
1200
                shell_command = NULL;
 
1201
 
 
1202
        g_mutex_lock (settings->priv->property_lock);
 
1203
 
 
1204
        if (g_strcmp0 (settings->priv->shell_command, shell_command) == 0) {
 
1205
                g_mutex_unlock (settings->priv->property_lock);
 
1206
                return;
 
1207
        }
 
1208
 
 
1209
        g_free (settings->priv->shell_command);
 
1210
        settings->priv->shell_command = g_strdup (shell_command);
 
1211
 
 
1212
        g_mutex_unlock (settings->priv->property_lock);
 
1213
 
 
1214
        g_object_notify (G_OBJECT (settings), "shell-command");
 
1215
}
 
1216
 
 
1217
/**
 
1218
 * camel_imapx_settings_get_use_idle:
 
1219
 * @settings: a #CamelIMAPXSettings
 
1220
 *
 
1221
 * Returns whether to use the IMAP IDLE extension if the server supports
 
1222
 * it.  See RFC 2177 for more details.
 
1223
 *
 
1224
 * Returns: whether to use the IDLE extension
 
1225
 *
 
1226
 * Since: 3.2
 
1227
 **/
 
1228
gboolean
 
1229
camel_imapx_settings_get_use_idle (CamelIMAPXSettings *settings)
 
1230
{
 
1231
        g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), FALSE);
 
1232
 
 
1233
        return settings->priv->use_idle;
 
1234
}
 
1235
 
 
1236
/**
 
1237
 * camel_imapx_settings_set_use_idle:
 
1238
 * @settings: a #CamelIMAPXSettings
 
1239
 * @use_idle: whether to use the IDLE extension
 
1240
 *
 
1241
 * Sets whether to use the IMAP IDLE extension if the server supports it.
 
1242
 * See RFC 2177 for more details.
 
1243
 *
 
1244
 * Since: 3.2
 
1245
 **/
 
1246
void
 
1247
camel_imapx_settings_set_use_idle (CamelIMAPXSettings *settings,
 
1248
                                   gboolean use_idle)
 
1249
{
 
1250
        g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
 
1251
 
 
1252
        if ((settings->priv->use_idle ? 1 : 0) == (use_idle ? 1 : 0))
 
1253
                return;
 
1254
 
 
1255
        settings->priv->use_idle = use_idle;
 
1256
 
 
1257
        g_object_notify (G_OBJECT (settings), "use-idle");
 
1258
}
 
1259
 
 
1260
/**
 
1261
 * camel_imapx_settings_get_use_namespace:
 
1262
 * @settings: a #CamelIMAPXSettings
 
1263
 *
 
1264
 * Returns whether to use a custom IMAP namespace to find folders.  The
 
1265
 * namespace itself is given by the #CamelIMAPStore:namespace property.
 
1266
 *
 
1267
 * Returns: whether to use a custom IMAP namespace
 
1268
 *
 
1269
 * Since: 3.2
 
1270
 **/
 
1271
gboolean
 
1272
camel_imapx_settings_get_use_namespace (CamelIMAPXSettings *settings)
 
1273
{
 
1274
        g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), FALSE);
 
1275
 
 
1276
        return settings->priv->use_namespace;
 
1277
}
 
1278
 
 
1279
/**
 
1280
 * camel_imapx_settings_set_use_namespace:
 
1281
 * @settings: a #CamelIMAPXSettings
 
1282
 * @use_namespace: whether to use a custom IMAP namespace
 
1283
 *
 
1284
 * Sets whether to use a custom IMAP namespace to find folders.  The
 
1285
 * namespace itself is given by the #CamelIMAPXSettings:namespace property.
 
1286
 *
 
1287
 * Since: 3.2
 
1288
 **/
 
1289
void
 
1290
camel_imapx_settings_set_use_namespace (CamelIMAPXSettings *settings,
 
1291
                                        gboolean use_namespace)
 
1292
{
 
1293
        g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
 
1294
 
 
1295
        if ((settings->priv->use_namespace ? 1 : 0) == (use_namespace ? 1 : 0))
 
1296
                return;
 
1297
 
 
1298
        settings->priv->use_namespace = use_namespace;
 
1299
 
 
1300
        g_object_notify (G_OBJECT (settings), "use-namespace");
 
1301
}
 
1302
 
 
1303
/**
 
1304
 * camel_imapx_settings_get_use_qresync:
 
1305
 * @settings: a #CamelIMAPXSettings
 
1306
 *
 
1307
 * Returns whether to use the Quick Mailbox Resynchronization (QRESYNC)
 
1308
 * IMAP extension if the server supports it.  See RFC 5162 for more
 
1309
 * details.
 
1310
 *
 
1311
 * Returns: whether to use the QRESYNC extension
 
1312
 *
 
1313
 * Since: 3.2
 
1314
 **/
 
1315
gboolean
 
1316
camel_imapx_settings_get_use_qresync (CamelIMAPXSettings *settings)
 
1317
{
 
1318
        g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), FALSE);
 
1319
 
 
1320
        return settings->priv->use_qresync;
 
1321
}
 
1322
 
 
1323
/**
 
1324
 * camel_imapx_settings_set_use_qresync:
 
1325
 * @settings: a #CamelIMAPXSettings
 
1326
 * @use_qresync: whether to use the QRESYNC extension
 
1327
 *
 
1328
 * Sets whether to use the Quick Mailbox Resynchronization (QRESYNC)
 
1329
 * IMAP extension if the server supports it.  See RFC 5162 for more
 
1330
 * details.
 
1331
 *
 
1332
 * Since: 3.2
 
1333
 **/
 
1334
void
 
1335
camel_imapx_settings_set_use_qresync (CamelIMAPXSettings *settings,
 
1336
                                      gboolean use_qresync)
 
1337
{
 
1338
        g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
 
1339
 
 
1340
        if ((settings->priv->use_qresync ? 1 : 0) == (use_qresync ? 1 : 0))
 
1341
                return;
 
1342
 
 
1343
        settings->priv->use_qresync = use_qresync;
 
1344
 
 
1345
        g_object_notify (G_OBJECT (settings), "use-qresync");
 
1346
}
 
1347
 
 
1348
/**
 
1349
 * camel_imapx_settings_get_use_shell_command:
 
1350
 * @settings: a #CamelIMAPXSettings
 
1351
 *
 
1352
 * Returns whether to use a custom shell command to establish an input/output
 
1353
 * stream with an IMAP server, instead of the more common method of opening a
 
1354
 * network socket.  The shell command itself is given by the
 
1355
 * #CamelIMAPXSettings:shell-command property.
 
1356
 *
 
1357
 * This option is useful only to a select few advanced users who likely
 
1358
 * administer their own IMAP server.  Most users will not understand what
 
1359
 * this option means or how to use it.  Probably not worth exposing in a
 
1360
 * graphical interface.
 
1361
 *
 
1362
 * Returns: whether to use a custom shell command to connect to the server
 
1363
 *
 
1364
 * Since: 3.2
 
1365
 **/
 
1366
gboolean
 
1367
camel_imapx_settings_get_use_shell_command (CamelIMAPXSettings *settings)
 
1368
{
 
1369
        g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), FALSE);
 
1370
 
 
1371
        return settings->priv->use_shell_command;
 
1372
}
 
1373
 
 
1374
/**
 
1375
 * camel_imapx_settings_set_use_shell_command:
 
1376
 * @settings: a #CamelIMAPXSettings
 
1377
 * @use_shell_command: whether to use a custom shell command to connect
 
1378
 *                     to the server
 
1379
 *
 
1380
 * Sets whether to use a custom shell command to establish an input/output
 
1381
 * stream with an IMAP server, instead of the more common method of opening
 
1382
 * a network socket.  The shell command itself is given by the
 
1383
 * #CamelIMAPXSettings:shell-command property.
 
1384
 *
 
1385
 * This option is useful only to a select few advanced users who likely
 
1386
 * administer their own IMAP server.  Most users will not understand what
 
1387
 * this option means or how to use it.  Probably not worth exposing in a
 
1388
 * graphical interface.
 
1389
 *
 
1390
 * Since: 3.2
 
1391
 **/
 
1392
void
 
1393
camel_imapx_settings_set_use_shell_command (CamelIMAPXSettings *settings,
 
1394
                                            gboolean use_shell_command)
 
1395
{
 
1396
        g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
 
1397
 
 
1398
        if ((settings->priv->use_shell_command ? 1 : 0) == (use_shell_command ? 1 : 0))
 
1399
                return;
 
1400
 
 
1401
        settings->priv->use_shell_command = use_shell_command;
 
1402
 
 
1403
        g_object_notify (G_OBJECT (settings), "use-shell-command");
 
1404
}
 
1405
 
 
1406
/**
 
1407
 * camel_imapx_settings_get_use_subscriptions:
 
1408
 * @settings: a #CamelIMAPXSettings
 
1409
 *
 
1410
 * Returns whether to list and operate only on subscribed folders, or to
 
1411
 * list and operate on all available folders regardless of subscriptions.
 
1412
 *
 
1413
 * Returns: whether to honor folder subscriptions
 
1414
 *
 
1415
 * Since: 3.2
 
1416
 **/
 
1417
gboolean
 
1418
camel_imapx_settings_get_use_subscriptions (CamelIMAPXSettings *settings)
 
1419
{
 
1420
        g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), FALSE);
 
1421
 
 
1422
        return settings->priv->use_subscriptions;
 
1423
}
 
1424
 
 
1425
/**
 
1426
 * camel_imapx_settings_set_use_subscriptions:
 
1427
 * @settings: a #CamelIMAPXSettings
 
1428
 * @use_subscriptions: whether to honor folder subscriptions
 
1429
 *
 
1430
 * Sets whether to list and operate only on subscribed folders, or to
 
1431
 * list and operate on all available folders regardless of subscriptions.
 
1432
 *
 
1433
 * Since: 3.2
 
1434
 **/
 
1435
void
 
1436
camel_imapx_settings_set_use_subscriptions (CamelIMAPXSettings *settings,
 
1437
                                            gboolean use_subscriptions)
 
1438
{
 
1439
        g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
 
1440
 
 
1441
        if ((settings->priv->use_subscriptions ? 1 : 0) == (use_subscriptions ? 1 : 0))
 
1442
                return;
 
1443
 
 
1444
        settings->priv->use_subscriptions = use_subscriptions;
 
1445
 
 
1446
        g_object_notify (G_OBJECT (settings), "use-subscriptions");
 
1447
}
 
1448