2
* camel-imapx-settings.c
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.
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.
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/>
19
#include "camel-imapx-settings.h"
21
#define MIN_CONCURRENT_CONNECTIONS 1
22
#define MAX_CONCURRENT_CONNECTIONS 7
24
#define CAMEL_IMAPX_SETTINGS_GET_PRIVATE(obj) \
25
(G_TYPE_INSTANCE_GET_PRIVATE \
26
((obj), CAMEL_TYPE_IMAPX_SETTINGS, CamelIMAPXSettingsPrivate))
28
struct _CamelIMAPXSettingsPrivate {
29
GMutex *property_lock;
33
guint batch_fetch_count;
34
guint concurrent_connections;
37
gboolean check_subscribed;
40
gboolean filter_junk_inbox;
42
gboolean use_mobile_mode;
43
gboolean use_namespace;
45
gboolean use_shell_command;
46
gboolean use_subscriptions;
48
CamelSortType fetch_order;
54
PROP_BATCH_FETCH_COUNT,
56
PROP_CHECK_SUBSCRIBED,
57
PROP_CONCURRENT_CONNECTIONS,
61
PROP_FILTER_JUNK_INBOX,
72
PROP_USE_SHELL_COMMAND,
73
PROP_USE_SUBSCRIPTIONS
76
G_DEFINE_TYPE_WITH_CODE (
79
CAMEL_TYPE_OFFLINE_SETTINGS,
80
G_IMPLEMENT_INTERFACE (
81
CAMEL_TYPE_NETWORK_SETTINGS, NULL))
84
imapx_settings_set_property (GObject *object,
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));
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));
103
camel_imapx_settings_set_check_all (
104
CAMEL_IMAPX_SETTINGS (object),
105
g_value_get_boolean (value));
108
case PROP_CHECK_SUBSCRIBED:
109
camel_imapx_settings_set_check_subscribed (
110
CAMEL_IMAPX_SETTINGS (object),
111
g_value_get_boolean (value));
114
case PROP_CONCURRENT_CONNECTIONS:
115
camel_imapx_settings_set_concurrent_connections (
116
CAMEL_IMAPX_SETTINGS (object),
117
g_value_get_uint (value));
120
case PROP_FETCH_ORDER:
121
camel_imapx_settings_set_fetch_order (
122
CAMEL_IMAPX_SETTINGS (object),
123
g_value_get_enum (value));
126
case PROP_FILTER_ALL:
127
camel_imapx_settings_set_filter_all (
128
CAMEL_IMAPX_SETTINGS (object),
129
g_value_get_boolean (value));
132
case PROP_FILTER_JUNK:
133
camel_imapx_settings_set_filter_junk (
134
CAMEL_IMAPX_SETTINGS (object),
135
g_value_get_boolean (value));
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));
145
camel_network_settings_set_host (
146
CAMEL_NETWORK_SETTINGS (object),
147
g_value_get_string (value));
150
case PROP_MOBILE_MODE:
151
camel_imapx_settings_set_mobile_mode (
152
CAMEL_IMAPX_SETTINGS (object),
153
g_value_get_boolean (value));
157
camel_imapx_settings_set_namespace (
158
CAMEL_IMAPX_SETTINGS (object),
159
g_value_get_string (value));
163
camel_network_settings_set_port (
164
CAMEL_NETWORK_SETTINGS (object),
165
g_value_get_uint (value));
168
case PROP_SECURITY_METHOD:
169
camel_network_settings_set_security_method (
170
CAMEL_NETWORK_SETTINGS (object),
171
g_value_get_enum (value));
174
case PROP_SHELL_COMMAND:
175
camel_imapx_settings_set_shell_command (
176
CAMEL_IMAPX_SETTINGS (object),
177
g_value_get_string (value));
181
camel_network_settings_set_user (
182
CAMEL_NETWORK_SETTINGS (object),
183
g_value_get_string (value));
187
camel_imapx_settings_set_use_idle (
188
CAMEL_IMAPX_SETTINGS (object),
189
g_value_get_boolean (value));
192
case PROP_USE_NAMESPACE:
193
camel_imapx_settings_set_use_namespace (
194
CAMEL_IMAPX_SETTINGS (object),
195
g_value_get_boolean (value));
198
case PROP_USE_QRESYNC:
199
camel_imapx_settings_set_use_qresync (
200
CAMEL_IMAPX_SETTINGS (object),
201
g_value_get_boolean (value));
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));
210
case PROP_USE_SUBSCRIPTIONS:
211
camel_imapx_settings_set_use_subscriptions (
212
CAMEL_IMAPX_SETTINGS (object),
213
g_value_get_boolean (value));
217
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
221
imapx_settings_get_property (GObject *object,
226
switch (property_id) {
227
case PROP_AUTH_MECHANISM:
228
g_value_take_string (
230
camel_network_settings_dup_auth_mechanism (
231
CAMEL_NETWORK_SETTINGS (object)));
234
case PROP_BATCH_FETCH_COUNT:
237
camel_imapx_settings_get_batch_fetch_count (
238
CAMEL_IMAPX_SETTINGS (object)));
242
g_value_set_boolean (
244
camel_imapx_settings_get_check_all (
245
CAMEL_IMAPX_SETTINGS (object)));
248
case PROP_CHECK_SUBSCRIBED:
249
g_value_set_boolean (
251
camel_imapx_settings_get_check_subscribed (
252
CAMEL_IMAPX_SETTINGS (object)));
255
case PROP_CONCURRENT_CONNECTIONS:
258
camel_imapx_settings_get_concurrent_connections (
259
CAMEL_IMAPX_SETTINGS (object)));
262
case PROP_FETCH_ORDER:
265
camel_imapx_settings_get_fetch_order (
266
CAMEL_IMAPX_SETTINGS (object)));
269
case PROP_FILTER_ALL:
270
g_value_set_boolean (
272
camel_imapx_settings_get_filter_all (
273
CAMEL_IMAPX_SETTINGS (object)));
276
case PROP_FILTER_JUNK:
277
g_value_set_boolean (
279
camel_imapx_settings_get_filter_junk (
280
CAMEL_IMAPX_SETTINGS (object)));
283
case PROP_FILTER_JUNK_INBOX:
284
g_value_set_boolean (
286
camel_imapx_settings_get_filter_junk_inbox (
287
CAMEL_IMAPX_SETTINGS (object)));
291
g_value_take_string (
293
camel_network_settings_dup_host (
294
CAMEL_NETWORK_SETTINGS (object)));
297
case PROP_MOBILE_MODE:
298
g_value_set_boolean (
300
camel_imapx_settings_get_mobile_mode (
301
CAMEL_IMAPX_SETTINGS (object)));
305
g_value_take_string (
307
camel_imapx_settings_dup_namespace (
308
CAMEL_IMAPX_SETTINGS (object)));
314
camel_network_settings_get_port (
315
CAMEL_NETWORK_SETTINGS (object)));
318
case PROP_SECURITY_METHOD:
321
camel_network_settings_get_security_method (
322
CAMEL_NETWORK_SETTINGS (object)));
325
case PROP_SHELL_COMMAND:
326
g_value_take_string (
328
camel_imapx_settings_dup_shell_command (
329
CAMEL_IMAPX_SETTINGS (object)));
333
g_value_take_string (
335
camel_network_settings_dup_user (
336
CAMEL_NETWORK_SETTINGS (object)));
340
g_value_set_boolean (
342
camel_imapx_settings_get_use_idle (
343
CAMEL_IMAPX_SETTINGS (object)));
346
case PROP_USE_NAMESPACE:
347
g_value_set_boolean (
349
camel_imapx_settings_get_use_namespace (
350
CAMEL_IMAPX_SETTINGS (object)));
353
case PROP_USE_QRESYNC:
354
g_value_set_boolean (
356
camel_imapx_settings_get_use_qresync (
357
CAMEL_IMAPX_SETTINGS (object)));
360
case PROP_USE_SHELL_COMMAND:
361
g_value_set_boolean (
363
camel_imapx_settings_get_use_shell_command (
364
CAMEL_IMAPX_SETTINGS (object)));
367
case PROP_USE_SUBSCRIPTIONS:
368
g_value_set_boolean (
370
camel_imapx_settings_get_use_subscriptions (
371
CAMEL_IMAPX_SETTINGS (object)));
375
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
379
imapx_settings_finalize (GObject *object)
381
CamelIMAPXSettingsPrivate *priv;
383
priv = CAMEL_IMAPX_SETTINGS_GET_PRIVATE (object);
385
g_mutex_free (priv->property_lock);
387
g_free (priv->namespace);
388
g_free (priv->shell_command);
390
/* Chain up to parent's finalize() method. */
391
G_OBJECT_CLASS (camel_imapx_settings_parent_class)->finalize (object);
395
camel_imapx_settings_class_init (CamelIMAPXSettingsClass *class)
397
GObjectClass *object_class;
399
g_type_class_add_private (class, sizeof (CamelIMAPXSettingsPrivate));
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;
406
/* Inherited from CamelNetworkSettings. */
407
g_object_class_override_property (
412
g_object_class_install_property (
414
PROP_BATCH_FETCH_COUNT,
418
"Number of envelopes to fetch at once",
424
G_PARAM_STATIC_STRINGS));
426
g_object_class_install_property (
429
g_param_spec_boolean (
432
"Check all folders for new messages",
436
G_PARAM_STATIC_STRINGS));
438
g_object_class_install_property (
440
PROP_CHECK_SUBSCRIBED,
441
g_param_spec_boolean (
444
"Check only subscribed folders for new messages",
448
G_PARAM_STATIC_STRINGS));
450
g_object_class_install_property (
452
PROP_CONCURRENT_CONNECTIONS,
454
"concurrent-connections",
455
"Concurrent Connections",
456
"Number of concurrent IMAP connections to use",
457
MIN_CONCURRENT_CONNECTIONS,
458
MAX_CONCURRENT_CONNECTIONS,
462
G_PARAM_STATIC_STRINGS));
464
g_object_class_install_property (
470
"Order in which new messages should be fetched",
471
CAMEL_TYPE_SORT_TYPE,
472
CAMEL_SORT_ASCENDING,
475
G_PARAM_STATIC_STRINGS));
477
g_object_class_install_property (
480
g_param_spec_boolean (
483
"Whether to apply filters in all folders",
487
G_PARAM_STATIC_STRINGS));
489
g_object_class_install_property (
492
g_param_spec_boolean (
495
"Whether to filter junk from all folders",
499
G_PARAM_STATIC_STRINGS));
501
g_object_class_install_property (
503
PROP_FILTER_JUNK_INBOX,
504
g_param_spec_boolean (
507
"Whether to filter junk from Inbox only",
511
G_PARAM_STATIC_STRINGS));
513
g_object_class_install_property (
516
g_param_spec_boolean (
519
"Mobile mode which adjusts the IMAPX for Mobile clients",
523
G_PARAM_STATIC_STRINGS));
525
/* Inherited from CamelNetworkSettings. */
526
g_object_class_override_property (
531
g_object_class_install_property (
534
g_param_spec_string (
537
"Custom IMAP namespace",
541
G_PARAM_STATIC_STRINGS));
543
/* Inherited from CamelNetworkSettings. */
544
g_object_class_override_property (
549
/* Inherited from CamelNetworkSettings. */
550
g_object_class_override_property (
552
PROP_SECURITY_METHOD,
555
g_object_class_install_property (
558
g_param_spec_string (
561
"Shell command for connecting to the server",
562
"ssh -C -l %u %h exec /usr/sbin/imapd",
565
G_PARAM_STATIC_STRINGS));
567
/* Inherited from CamelNetworkSettings. */
568
g_object_class_override_property (
573
g_object_class_install_property (
576
g_param_spec_boolean (
579
"Whether to use the IDLE IMAP extension",
583
G_PARAM_STATIC_STRINGS));
585
g_object_class_install_property (
588
g_param_spec_boolean (
591
"Whether to use a custom IMAP namespace",
595
G_PARAM_STATIC_STRINGS));
597
g_object_class_install_property (
600
g_param_spec_boolean (
603
"Whether to use the QRESYNC IMAP extension",
607
G_PARAM_STATIC_STRINGS));
609
g_object_class_install_property (
611
PROP_USE_SHELL_COMMAND,
612
g_param_spec_boolean (
615
"Whether to use a custom shell "
616
"command to connect to the server",
620
G_PARAM_STATIC_STRINGS));
622
g_object_class_install_property (
624
PROP_USE_SUBSCRIPTIONS,
625
g_param_spec_boolean (
628
"Whether to honor folder subscriptions",
632
G_PARAM_STATIC_STRINGS));
636
camel_imapx_settings_init (CamelIMAPXSettings *settings)
638
settings->priv = CAMEL_IMAPX_SETTINGS_GET_PRIVATE (settings);
639
settings->priv->property_lock = g_mutex_new ();
643
* camel_imapx_settings_get_batch_fetch_count:
644
* @settings: a #CamelIMAPXSettings
646
* Returns the number of message envelopes to fetch at once.
648
* This is a tunable performance parameter and probably should not be
649
* exposed in a graphical user interface.
651
* Returns: number of message envelopes to fetch at once
656
camel_imapx_settings_get_batch_fetch_count (CamelIMAPXSettings *settings)
658
g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), 0);
660
return settings->priv->batch_fetch_count;
664
* camel_imapx_settings_set_batch_fetch_count:
665
* @settings: a #CamelIMAPXSettings
666
* @batch_fetch_count: number of message envelopes to fetch at once
668
* Sets the number of message envelopes to fetch at once.
670
* This is a tunable performance parameter and probably should not be
671
* exposed in a graphical user interface.
676
camel_imapx_settings_set_batch_fetch_count (CamelIMAPXSettings *settings,
677
guint batch_fetch_count)
679
g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
681
if (settings->priv->batch_fetch_count == batch_fetch_count)
684
settings->priv->batch_fetch_count = batch_fetch_count;
686
g_object_notify (G_OBJECT (settings), "batch-fetch-count");
690
* camel_imapx_settings_get_check_all:
691
* @settings: a #CamelIMAPXSettings
693
* Returns whether to check all folders for new messages.
695
* Returns: whether to check all folders for new messages
700
camel_imapx_settings_get_check_all (CamelIMAPXSettings *settings)
702
g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), FALSE);
704
return settings->priv->check_all;
708
* camel_imapx_settings_set_check_all:
709
* @settings: a #CamelIMAPXSettings
710
* @check_all: whether to check all folders for new messages
712
* Sets whether to check all folders for new messages.
717
camel_imapx_settings_set_check_all (CamelIMAPXSettings *settings,
720
g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
722
if ((settings->priv->check_all ? 1 : 0) == (check_all ? 1 : 0))
725
settings->priv->check_all = check_all;
727
g_object_notify (G_OBJECT (settings), "check-all");
731
* camel_imapx_settings_get_check_subscribed:
732
* @settings: a #CamelIMAPXSettings
734
* Returns whether to check only subscribed folders for new messages.
735
* Note that #CamelIMAPXSettings:check-all, if %TRUE, overrides this setting.
737
* Returns: whether to check only subscribed folders for new messages
742
camel_imapx_settings_get_check_subscribed (CamelIMAPXSettings *settings)
744
g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), FALSE);
746
return settings->priv->check_subscribed;
750
* camel_imapx_settings_set_check_subscribed:
751
* @settings: a #CamelIMAPXSettings
752
* @check_subscribed: whether to check only subscribed folders for new messages
754
* Sets whether to check only subscribed folders for new messages. Note
755
* that #CamelIMAPXSettings:check-all, if %TRUE, overrides this setting.
760
camel_imapx_settings_set_check_subscribed (CamelIMAPXSettings *settings,
761
gboolean check_subscribed)
763
g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
765
if ((settings->priv->check_subscribed ? 1 : 0) == (check_subscribed ? 1 : 0))
768
settings->priv->check_subscribed = check_subscribed;
770
g_object_notify (G_OBJECT (settings), "check-subscribed");
774
* camel_imapx_settings_get_concurrent_connections:
775
* @settings: a #CamelIMAPXSettings
777
* Returns the number of concurrent network connections to the IMAP server
778
* to use for faster command/response processing.
780
* Returns: the number of concurrent connections to use
785
camel_imapx_settings_get_concurrent_connections (CamelIMAPXSettings *settings)
787
g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), 1);
789
return settings->priv->concurrent_connections;
793
* camel_imapx_settings_set_concurrent_connections:
794
* @settings: a #CamelIMAPXSettings
795
* @concurrent_connections: the number of concurrent connections to use
797
* Sets the number of concurrent network connections to the IMAP server to
798
* use for faster command/response processing.
800
* The minimum number of connections is 1, the maximum is 7. The
801
* @concurrent_connections value will be clamped to these limits if
807
camel_imapx_settings_set_concurrent_connections (CamelIMAPXSettings *settings,
808
guint concurrent_connections)
810
g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
812
concurrent_connections = CLAMP (
813
concurrent_connections,
814
MIN_CONCURRENT_CONNECTIONS,
815
MAX_CONCURRENT_CONNECTIONS);
817
if (settings->priv->concurrent_connections == concurrent_connections)
820
settings->priv->concurrent_connections = concurrent_connections;
822
g_object_notify (G_OBJECT (settings), "concurrent-connections");
826
* camel_imapx_settings_get_fetch_order:
827
* @settings: a #CamelIMAPXSettings
829
* Returns the order in which new messages should be fetched.
831
* Returns: the order in which new messages should be fetched
836
camel_imapx_settings_get_fetch_order (CamelIMAPXSettings *settings)
838
g_return_val_if_fail (
839
CAMEL_IS_IMAPX_SETTINGS (settings),
840
CAMEL_SORT_ASCENDING);
842
return settings->priv->fetch_order;
846
* camel_imapx_settings_set_fetch_order:
847
* @settings: a #CamelIMAPXSettings
848
* @fetch_order: the order in which new messages should be fetched
850
* Sets the order in which new messages should be fetched.
855
camel_imapx_settings_set_fetch_order (CamelIMAPXSettings *settings,
856
CamelSortType fetch_order)
858
g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
860
if (settings->priv->fetch_order == fetch_order)
863
settings->priv->fetch_order = fetch_order;
865
g_object_notify (G_OBJECT (settings), "fetch-order");
869
* camel_imapx_settings_get_filter_all:
870
* @settings: a #CamelIMAPXSettings
872
* Returns whether apply filters in all folders.
874
* Returns: whether to apply filters in all folders
879
camel_imapx_settings_get_filter_all (CamelIMAPXSettings *settings)
881
g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), FALSE);
883
return settings->priv->filter_all;
887
* camel_imapx_settings_set_filter_all:
888
* @settings: a #CamelIMAPXSettings
889
* @filter_all: whether to apply filters in all folders
891
* Sets whether to apply filters in all folders.
896
camel_imapx_settings_set_filter_all (CamelIMAPXSettings *settings,
899
g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
901
if ((settings->priv->filter_all ? 1 : 0) == (filter_all ? 1 : 0))
904
settings->priv->filter_all = filter_all;
906
g_object_notify (G_OBJECT (settings), "filter-all");
910
* camel_imapx_settings_get_filter_junk:
911
* @settings: a #CamelIMAPXSettings
913
* Returns whether to automatically find and tag junk messages amongst new
914
* messages in all folders.
916
* Returns: whether to filter junk in all folders
921
camel_imapx_settings_get_filter_junk (CamelIMAPXSettings *settings)
923
g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), FALSE);
925
return settings->priv->filter_junk;
929
* camel_imapx_settings_set_filter_junk:
930
* @settings: a #CamelIMAPXSettings
931
* @filter_junk: whether to filter junk in all folders
933
* Sets whether to automatically find and tag junk messages amongst new
934
* messages in all folders.
939
camel_imapx_settings_set_filter_junk (CamelIMAPXSettings *settings,
940
gboolean filter_junk)
942
g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
944
if ((settings->priv->filter_junk ? 1 : 0) == (filter_junk ? 1 : 0))
947
settings->priv->filter_junk = filter_junk;
949
g_object_notify (G_OBJECT (settings), "filter-junk");
953
* camel_imapx_settings_get_filter_junk_inbox:
954
* @settings: a #CamelIMAPXSettings
956
* Returns whether to automatically find and tag junk messages amongst new
957
* messages in the Inbox folder only.
959
* Returns: whether to filter junk in Inbox only
964
camel_imapx_settings_get_filter_junk_inbox (CamelIMAPXSettings *settings)
966
g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), FALSE);
968
return settings->priv->filter_junk_inbox;
972
* camel_imapx_settings_set_filter_junk_inbox:
973
* @settings: a #CamelIMAPXSettings
974
* @filter_junk_inbox: whether to filter junk in Inbox only
976
* Sets whether to automatically find and tag junk messages amongst new
977
* messages in the Inbox folder only.
982
camel_imapx_settings_set_filter_junk_inbox (CamelIMAPXSettings *settings,
983
gboolean filter_junk_inbox)
985
g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
987
if ((settings->priv->filter_junk_inbox ? 1 : 0) == (filter_junk_inbox ? 1 : 0))
990
settings->priv->filter_junk_inbox = filter_junk_inbox;
992
g_object_notify (G_OBJECT (settings), "filter-junk-inbox");
996
* camel_imapx_settings_get_mobile_mode:
997
* @settings: a #CamelIMAPXSettings
999
* Returns whether the backend is operating in mobile mode.
1004
camel_imapx_settings_get_mobile_mode (CamelIMAPXSettings *settings)
1006
g_return_val_if_fail (
1007
CAMEL_IS_IMAPX_SETTINGS (settings),
1008
CAMEL_SORT_ASCENDING);
1010
return settings->priv->use_mobile_mode;
1014
* camel_imapx_settings_set_mobile_mode:
1015
* @settings: a #CamelIMAPXSettings
1016
* @mobile_mode: whether to operate in mobile mode.
1018
* Sets the mode of operation as mobile or not for the backend.
1023
camel_imapx_settings_set_mobile_mode (CamelIMAPXSettings *settings,
1024
gboolean mobile_mode)
1026
g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
1028
if ((settings->priv->use_mobile_mode ? 1 : 0) == (mobile_mode ? 1 : 0))
1031
settings->priv->use_mobile_mode = mobile_mode;
1033
g_object_notify (G_OBJECT (settings), "mobile-mode");
1037
* camel_imapx_settings_get_namespace:
1038
* @settings: a #CamelIMAPXSettings
1040
* Returns the custom IMAP namespace in which to find folders.
1042
* Returns: the custom IMAP namespace, or %NULL
1047
camel_imapx_settings_get_namespace (CamelIMAPXSettings *settings)
1049
g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), NULL);
1051
return settings->priv->namespace;
1055
* camel_imapx_settings_dup_namespace:
1056
* @settings: a #CamelIMAPXSettings
1058
* Thread-safe variation of camel_imapx_settings_get_namespace().
1059
* Use this function when accessing @settings from multiple threads.
1061
* The returned string should be freed with g_free() when no longer needed.
1063
* Returns: a newly-allocated copy of #CamelIMAPXSettings:namespace
1068
camel_imapx_settings_dup_namespace (CamelIMAPXSettings *settings)
1070
const gchar *protected;
1073
g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), NULL);
1075
g_mutex_lock (settings->priv->property_lock);
1077
protected = camel_imapx_settings_get_namespace (settings);
1078
duplicate = g_strdup (protected);
1080
g_mutex_unlock (settings->priv->property_lock);
1086
* camel_imapx_settings_set_namespace:
1087
* @settings: a #CamelIMAPXSettings
1088
* @namespace_: an IMAP namespace, or %NULL
1090
* Sets the custom IMAP namespace in which to find folders. If @namespace_
1091
* is %NULL, the default namespace is used.
1096
camel_imapx_settings_set_namespace (CamelIMAPXSettings *settings,
1097
const gchar *namespace_)
1099
g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
1101
/* The default namespace is an empty string. */
1102
if (namespace_ == NULL)
1105
g_mutex_lock (settings->priv->property_lock);
1107
if (g_strcmp0 (settings->priv->namespace, namespace_) == 0) {
1108
g_mutex_unlock (settings->priv->property_lock);
1112
g_free (settings->priv->namespace);
1113
settings->priv->namespace = g_strdup (namespace_);
1115
g_mutex_unlock (settings->priv->property_lock);
1117
g_object_notify (G_OBJECT (settings), "namespace");
1121
* camel_imapx_settings_get_shell_command:
1122
* @settings: a #CamelIMAPXSettings
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.
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.
1133
* Returns: shell command for connecting to the server, or %NULL
1138
camel_imapx_settings_get_shell_command (CamelIMAPXSettings *settings)
1140
g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), NULL);
1142
return settings->priv->shell_command;
1146
* camel_imapx_settings_dup_shell_command:
1147
* @settings: a #CamelIMAPXSettings
1149
* Thread-safe variation of camel_imapx_settings_get_shell_command().
1150
* Use this function when accessing @settings from multiple threads.
1152
* The returned string should be freed with g_free() when no longer needed.
1154
* Returns: a newly-allocated copy of #CamelIMAPXSettings:shell-command
1159
camel_imapx_settings_dup_shell_command (CamelIMAPXSettings *settings)
1161
const gchar *protected;
1164
g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), NULL);
1166
g_mutex_lock (settings->priv->property_lock);
1168
protected = camel_imapx_settings_get_shell_command (settings);
1169
duplicate = g_strdup (protected);
1171
g_mutex_unlock (settings->priv->property_lock);
1177
* camel_imapx_settings_set_shell_command:
1178
* @settings: a #CamelIMAPXSettings
1179
* @shell_command: shell command for connecting to the server, or %NULL
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.
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.
1193
camel_imapx_settings_set_shell_command (CamelIMAPXSettings *settings,
1194
const gchar *shell_command)
1196
g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
1198
/* An empty string is equivalent to NULL. */
1199
if (shell_command != NULL && *shell_command == '\0')
1200
shell_command = NULL;
1202
g_mutex_lock (settings->priv->property_lock);
1204
if (g_strcmp0 (settings->priv->shell_command, shell_command) == 0) {
1205
g_mutex_unlock (settings->priv->property_lock);
1209
g_free (settings->priv->shell_command);
1210
settings->priv->shell_command = g_strdup (shell_command);
1212
g_mutex_unlock (settings->priv->property_lock);
1214
g_object_notify (G_OBJECT (settings), "shell-command");
1218
* camel_imapx_settings_get_use_idle:
1219
* @settings: a #CamelIMAPXSettings
1221
* Returns whether to use the IMAP IDLE extension if the server supports
1222
* it. See RFC 2177 for more details.
1224
* Returns: whether to use the IDLE extension
1229
camel_imapx_settings_get_use_idle (CamelIMAPXSettings *settings)
1231
g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), FALSE);
1233
return settings->priv->use_idle;
1237
* camel_imapx_settings_set_use_idle:
1238
* @settings: a #CamelIMAPXSettings
1239
* @use_idle: whether to use the IDLE extension
1241
* Sets whether to use the IMAP IDLE extension if the server supports it.
1242
* See RFC 2177 for more details.
1247
camel_imapx_settings_set_use_idle (CamelIMAPXSettings *settings,
1250
g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
1252
if ((settings->priv->use_idle ? 1 : 0) == (use_idle ? 1 : 0))
1255
settings->priv->use_idle = use_idle;
1257
g_object_notify (G_OBJECT (settings), "use-idle");
1261
* camel_imapx_settings_get_use_namespace:
1262
* @settings: a #CamelIMAPXSettings
1264
* Returns whether to use a custom IMAP namespace to find folders. The
1265
* namespace itself is given by the #CamelIMAPStore:namespace property.
1267
* Returns: whether to use a custom IMAP namespace
1272
camel_imapx_settings_get_use_namespace (CamelIMAPXSettings *settings)
1274
g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), FALSE);
1276
return settings->priv->use_namespace;
1280
* camel_imapx_settings_set_use_namespace:
1281
* @settings: a #CamelIMAPXSettings
1282
* @use_namespace: whether to use a custom IMAP namespace
1284
* Sets whether to use a custom IMAP namespace to find folders. The
1285
* namespace itself is given by the #CamelIMAPXSettings:namespace property.
1290
camel_imapx_settings_set_use_namespace (CamelIMAPXSettings *settings,
1291
gboolean use_namespace)
1293
g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
1295
if ((settings->priv->use_namespace ? 1 : 0) == (use_namespace ? 1 : 0))
1298
settings->priv->use_namespace = use_namespace;
1300
g_object_notify (G_OBJECT (settings), "use-namespace");
1304
* camel_imapx_settings_get_use_qresync:
1305
* @settings: a #CamelIMAPXSettings
1307
* Returns whether to use the Quick Mailbox Resynchronization (QRESYNC)
1308
* IMAP extension if the server supports it. See RFC 5162 for more
1311
* Returns: whether to use the QRESYNC extension
1316
camel_imapx_settings_get_use_qresync (CamelIMAPXSettings *settings)
1318
g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), FALSE);
1320
return settings->priv->use_qresync;
1324
* camel_imapx_settings_set_use_qresync:
1325
* @settings: a #CamelIMAPXSettings
1326
* @use_qresync: whether to use the QRESYNC extension
1328
* Sets whether to use the Quick Mailbox Resynchronization (QRESYNC)
1329
* IMAP extension if the server supports it. See RFC 5162 for more
1335
camel_imapx_settings_set_use_qresync (CamelIMAPXSettings *settings,
1336
gboolean use_qresync)
1338
g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
1340
if ((settings->priv->use_qresync ? 1 : 0) == (use_qresync ? 1 : 0))
1343
settings->priv->use_qresync = use_qresync;
1345
g_object_notify (G_OBJECT (settings), "use-qresync");
1349
* camel_imapx_settings_get_use_shell_command:
1350
* @settings: a #CamelIMAPXSettings
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.
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.
1362
* Returns: whether to use a custom shell command to connect to the server
1367
camel_imapx_settings_get_use_shell_command (CamelIMAPXSettings *settings)
1369
g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), FALSE);
1371
return settings->priv->use_shell_command;
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
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.
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.
1393
camel_imapx_settings_set_use_shell_command (CamelIMAPXSettings *settings,
1394
gboolean use_shell_command)
1396
g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
1398
if ((settings->priv->use_shell_command ? 1 : 0) == (use_shell_command ? 1 : 0))
1401
settings->priv->use_shell_command = use_shell_command;
1403
g_object_notify (G_OBJECT (settings), "use-shell-command");
1407
* camel_imapx_settings_get_use_subscriptions:
1408
* @settings: a #CamelIMAPXSettings
1410
* Returns whether to list and operate only on subscribed folders, or to
1411
* list and operate on all available folders regardless of subscriptions.
1413
* Returns: whether to honor folder subscriptions
1418
camel_imapx_settings_get_use_subscriptions (CamelIMAPXSettings *settings)
1420
g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), FALSE);
1422
return settings->priv->use_subscriptions;
1426
* camel_imapx_settings_set_use_subscriptions:
1427
* @settings: a #CamelIMAPXSettings
1428
* @use_subscriptions: whether to honor folder subscriptions
1430
* Sets whether to list and operate only on subscribed folders, or to
1431
* list and operate on all available folders regardless of subscriptions.
1436
camel_imapx_settings_set_use_subscriptions (CamelIMAPXSettings *settings,
1437
gboolean use_subscriptions)
1439
g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
1441
if ((settings->priv->use_subscriptions ? 1 : 0) == (use_subscriptions ? 1 : 0))
1444
settings->priv->use_subscriptions = use_subscriptions;
1446
g_object_notify (G_OBJECT (settings), "use-subscriptions");