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