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 {
31 gchar *real_junk_path;
32 gchar *real_trash_path;
35 guint batch_fetch_count;
36 guint concurrent_connections;
39 gboolean check_subscribed;
42 gboolean filter_junk_inbox;
44 gboolean use_mobile_mode;
45 gboolean use_namespace;
47 gboolean use_real_junk_path;
48 gboolean use_real_trash_path;
49 gboolean use_shell_command;
50 gboolean use_subscriptions;
52 CamelSortType fetch_order;
58 PROP_BATCH_FETCH_COUNT,
60 PROP_CHECK_SUBSCRIBED,
61 PROP_CONCURRENT_CONNECTIONS,
65 PROP_FILTER_JUNK_INBOX,
78 PROP_USE_REAL_JUNK_PATH,
79 PROP_USE_REAL_TRASH_PATH,
80 PROP_USE_SHELL_COMMAND,
81 PROP_USE_SUBSCRIPTIONS
84 G_DEFINE_TYPE_WITH_CODE (
87 CAMEL_TYPE_OFFLINE_SETTINGS,
88 G_IMPLEMENT_INTERFACE (
89 CAMEL_TYPE_NETWORK_SETTINGS, NULL))
92 imapx_settings_set_property (GObject *object,
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));
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));
111 camel_imapx_settings_set_check_all (
112 CAMEL_IMAPX_SETTINGS (object),
113 g_value_get_boolean (value));
116 case PROP_CHECK_SUBSCRIBED:
117 camel_imapx_settings_set_check_subscribed (
118 CAMEL_IMAPX_SETTINGS (object),
119 g_value_get_boolean (value));
122 case PROP_CONCURRENT_CONNECTIONS:
123 camel_imapx_settings_set_concurrent_connections (
124 CAMEL_IMAPX_SETTINGS (object),
125 g_value_get_uint (value));
128 case PROP_FETCH_ORDER:
129 camel_imapx_settings_set_fetch_order (
130 CAMEL_IMAPX_SETTINGS (object),
131 g_value_get_enum (value));
134 case PROP_FILTER_ALL:
135 camel_imapx_settings_set_filter_all (
136 CAMEL_IMAPX_SETTINGS (object),
137 g_value_get_boolean (value));
140 case PROP_FILTER_JUNK:
141 camel_imapx_settings_set_filter_junk (
142 CAMEL_IMAPX_SETTINGS (object),
143 g_value_get_boolean (value));
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));
153 camel_network_settings_set_host (
154 CAMEL_NETWORK_SETTINGS (object),
155 g_value_get_string (value));
158 case PROP_MOBILE_MODE:
159 camel_imapx_settings_set_mobile_mode (
160 CAMEL_IMAPX_SETTINGS (object),
161 g_value_get_boolean (value));
165 camel_imapx_settings_set_namespace (
166 CAMEL_IMAPX_SETTINGS (object),
167 g_value_get_string (value));
171 camel_network_settings_set_port (
172 CAMEL_NETWORK_SETTINGS (object),
173 g_value_get_uint (value));
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));
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));
188 case PROP_SECURITY_METHOD:
189 camel_network_settings_set_security_method (
190 CAMEL_NETWORK_SETTINGS (object),
191 g_value_get_enum (value));
194 case PROP_SHELL_COMMAND:
195 camel_imapx_settings_set_shell_command (
196 CAMEL_IMAPX_SETTINGS (object),
197 g_value_get_string (value));
201 camel_network_settings_set_user (
202 CAMEL_NETWORK_SETTINGS (object),
203 g_value_get_string (value));
207 camel_imapx_settings_set_use_idle (
208 CAMEL_IMAPX_SETTINGS (object),
209 g_value_get_boolean (value));
212 case PROP_USE_NAMESPACE:
213 camel_imapx_settings_set_use_namespace (
214 CAMEL_IMAPX_SETTINGS (object),
215 g_value_get_boolean (value));
218 case PROP_USE_QRESYNC:
219 camel_imapx_settings_set_use_qresync (
220 CAMEL_IMAPX_SETTINGS (object),
221 g_value_get_boolean (value));
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));
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));
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));
242 case PROP_USE_SUBSCRIPTIONS:
243 camel_imapx_settings_set_use_subscriptions (
244 CAMEL_IMAPX_SETTINGS (object),
245 g_value_get_boolean (value));
249 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
253 imapx_settings_get_property (GObject *object,
258 switch (property_id) {
259 case PROP_AUTH_MECHANISM:
260 g_value_take_string (
262 camel_network_settings_dup_auth_mechanism (
263 CAMEL_NETWORK_SETTINGS (object)));
266 case PROP_BATCH_FETCH_COUNT:
269 camel_imapx_settings_get_batch_fetch_count (
270 CAMEL_IMAPX_SETTINGS (object)));
274 g_value_set_boolean (
276 camel_imapx_settings_get_check_all (
277 CAMEL_IMAPX_SETTINGS (object)));
280 case PROP_CHECK_SUBSCRIBED:
281 g_value_set_boolean (
283 camel_imapx_settings_get_check_subscribed (
284 CAMEL_IMAPX_SETTINGS (object)));
287 case PROP_CONCURRENT_CONNECTIONS:
290 camel_imapx_settings_get_concurrent_connections (
291 CAMEL_IMAPX_SETTINGS (object)));
294 case PROP_FETCH_ORDER:
297 camel_imapx_settings_get_fetch_order (
298 CAMEL_IMAPX_SETTINGS (object)));
301 case PROP_FILTER_ALL:
302 g_value_set_boolean (
304 camel_imapx_settings_get_filter_all (
305 CAMEL_IMAPX_SETTINGS (object)));
308 case PROP_FILTER_JUNK:
309 g_value_set_boolean (
311 camel_imapx_settings_get_filter_junk (
312 CAMEL_IMAPX_SETTINGS (object)));
315 case PROP_FILTER_JUNK_INBOX:
316 g_value_set_boolean (
318 camel_imapx_settings_get_filter_junk_inbox (
319 CAMEL_IMAPX_SETTINGS (object)));
323 g_value_take_string (
325 camel_network_settings_dup_host (
326 CAMEL_NETWORK_SETTINGS (object)));
329 case PROP_MOBILE_MODE:
330 g_value_set_boolean (
332 camel_imapx_settings_get_mobile_mode (
333 CAMEL_IMAPX_SETTINGS (object)));
337 g_value_take_string (
339 camel_imapx_settings_dup_namespace (
340 CAMEL_IMAPX_SETTINGS (object)));
346 camel_network_settings_get_port (
347 CAMEL_NETWORK_SETTINGS (object)));
350 case PROP_REAL_JUNK_PATH:
351 g_value_take_string (
353 camel_imapx_settings_dup_real_junk_path (
354 CAMEL_IMAPX_SETTINGS (object)));
357 case PROP_REAL_TRASH_PATH:
358 g_value_take_string (
360 camel_imapx_settings_dup_real_trash_path (
361 CAMEL_IMAPX_SETTINGS (object)));
364 case PROP_SECURITY_METHOD:
367 camel_network_settings_get_security_method (
368 CAMEL_NETWORK_SETTINGS (object)));
371 case PROP_SHELL_COMMAND:
372 g_value_take_string (
374 camel_imapx_settings_dup_shell_command (
375 CAMEL_IMAPX_SETTINGS (object)));
379 g_value_take_string (
381 camel_network_settings_dup_user (
382 CAMEL_NETWORK_SETTINGS (object)));
386 g_value_set_boolean (
388 camel_imapx_settings_get_use_idle (
389 CAMEL_IMAPX_SETTINGS (object)));
392 case PROP_USE_NAMESPACE:
393 g_value_set_boolean (
395 camel_imapx_settings_get_use_namespace (
396 CAMEL_IMAPX_SETTINGS (object)));
399 case PROP_USE_QRESYNC:
400 g_value_set_boolean (
402 camel_imapx_settings_get_use_qresync (
403 CAMEL_IMAPX_SETTINGS (object)));
406 case PROP_USE_REAL_JUNK_PATH:
407 g_value_set_boolean (
409 camel_imapx_settings_get_use_real_junk_path (
410 CAMEL_IMAPX_SETTINGS (object)));
413 case PROP_USE_REAL_TRASH_PATH:
414 g_value_set_boolean (
416 camel_imapx_settings_get_use_real_trash_path (
417 CAMEL_IMAPX_SETTINGS (object)));
420 case PROP_USE_SHELL_COMMAND:
421 g_value_set_boolean (
423 camel_imapx_settings_get_use_shell_command (
424 CAMEL_IMAPX_SETTINGS (object)));
427 case PROP_USE_SUBSCRIPTIONS:
428 g_value_set_boolean (
430 camel_imapx_settings_get_use_subscriptions (
431 CAMEL_IMAPX_SETTINGS (object)));
435 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
439 imapx_settings_finalize (GObject *object)
441 CamelIMAPXSettingsPrivate *priv;
443 priv = CAMEL_IMAPX_SETTINGS_GET_PRIVATE (object);
445 g_mutex_clear (&priv->property_lock);
447 g_free (priv->namespace);
448 g_free (priv->shell_command);
450 /* Chain up to parent's finalize() method. */
451 G_OBJECT_CLASS (camel_imapx_settings_parent_class)->finalize (object);
455 camel_imapx_settings_class_init (CamelIMAPXSettingsClass *class)
457 GObjectClass *object_class;
459 g_type_class_add_private (class, sizeof (CamelIMAPXSettingsPrivate));
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;
466 /* Inherited from CamelNetworkSettings. */
467 g_object_class_override_property (
472 g_object_class_install_property (
474 PROP_BATCH_FETCH_COUNT,
478 "Number of envelopes to fetch at once",
484 G_PARAM_STATIC_STRINGS));
486 g_object_class_install_property (
489 g_param_spec_boolean (
492 "Check all folders for new messages",
496 G_PARAM_STATIC_STRINGS));
498 g_object_class_install_property (
500 PROP_CHECK_SUBSCRIBED,
501 g_param_spec_boolean (
504 "Check only subscribed folders for new messages",
508 G_PARAM_STATIC_STRINGS));
510 g_object_class_install_property (
512 PROP_CONCURRENT_CONNECTIONS,
514 "concurrent-connections",
515 "Concurrent Connections",
516 "Number of concurrent IMAP connections to use",
517 MIN_CONCURRENT_CONNECTIONS,
518 MAX_CONCURRENT_CONNECTIONS,
522 G_PARAM_STATIC_STRINGS));
524 g_object_class_install_property (
530 "Order in which new messages should be fetched",
531 CAMEL_TYPE_SORT_TYPE,
532 CAMEL_SORT_ASCENDING,
535 G_PARAM_STATIC_STRINGS));
537 g_object_class_install_property (
540 g_param_spec_boolean (
543 "Whether to apply filters in all folders",
547 G_PARAM_STATIC_STRINGS));
549 g_object_class_install_property (
552 g_param_spec_boolean (
555 "Whether to filter junk from all folders",
559 G_PARAM_STATIC_STRINGS));
561 g_object_class_install_property (
563 PROP_FILTER_JUNK_INBOX,
564 g_param_spec_boolean (
567 "Whether to filter junk from Inbox only",
571 G_PARAM_STATIC_STRINGS));
573 g_object_class_install_property (
576 g_param_spec_boolean (
579 "Mobile mode which adjusts the IMAPX for Mobile clients",
583 G_PARAM_STATIC_STRINGS));
585 /* Inherited from CamelNetworkSettings. */
586 g_object_class_override_property (
591 g_object_class_install_property (
594 g_param_spec_string (
597 "Custom IMAP namespace",
601 G_PARAM_STATIC_STRINGS));
603 /* Inherited from CamelNetworkSettings. */
604 g_object_class_override_property (
609 g_object_class_install_property (
612 g_param_spec_string (
615 "Path for a non-virtual Junk folder",
619 G_PARAM_STATIC_STRINGS));
621 g_object_class_install_property (
623 PROP_REAL_TRASH_PATH,
624 g_param_spec_string (
627 "Path for a non-virtual Trash folder",
631 G_PARAM_STATIC_STRINGS));
633 /* Inherited from CamelNetworkSettings. */
634 g_object_class_override_property (
636 PROP_SECURITY_METHOD,
639 g_object_class_install_property (
642 g_param_spec_string (
645 "Shell command for connecting to the server",
646 "ssh -C -l %u %h exec /usr/sbin/imapd",
649 G_PARAM_STATIC_STRINGS));
651 /* Inherited from CamelNetworkSettings. */
652 g_object_class_override_property (
657 g_object_class_install_property (
660 g_param_spec_boolean (
663 "Whether to use the IDLE IMAP extension",
667 G_PARAM_STATIC_STRINGS));
669 g_object_class_install_property (
672 g_param_spec_boolean (
675 "Whether to use a custom IMAP namespace",
679 G_PARAM_STATIC_STRINGS));
681 g_object_class_install_property (
684 g_param_spec_boolean (
687 "Whether to use the QRESYNC IMAP extension",
691 G_PARAM_STATIC_STRINGS));
693 g_object_class_install_property (
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",
703 G_PARAM_STATIC_STRINGS));
705 g_object_class_install_property (
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",
715 G_PARAM_STATIC_STRINGS));
717 g_object_class_install_property (
719 PROP_USE_SHELL_COMMAND,
720 g_param_spec_boolean (
723 "Whether to use a custom shell "
724 "command to connect to the server",
728 G_PARAM_STATIC_STRINGS));
730 g_object_class_install_property (
732 PROP_USE_SUBSCRIPTIONS,
733 g_param_spec_boolean (
736 "Whether to honor folder subscriptions",
740 G_PARAM_STATIC_STRINGS));
744 camel_imapx_settings_init (CamelIMAPXSettings *settings)
746 settings->priv = CAMEL_IMAPX_SETTINGS_GET_PRIVATE (settings);
747 g_mutex_init (&settings->priv->property_lock);
751 * camel_imapx_settings_get_batch_fetch_count:
752 * @settings: a #CamelIMAPXSettings
754 * Returns the number of message envelopes to fetch at once.
756 * This is a tunable performance parameter and probably should not be
757 * exposed in a graphical user interface.
759 * Returns: number of message envelopes to fetch at once
764 camel_imapx_settings_get_batch_fetch_count (CamelIMAPXSettings *settings)
766 g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), 0);
768 return settings->priv->batch_fetch_count;
772 * camel_imapx_settings_set_batch_fetch_count:
773 * @settings: a #CamelIMAPXSettings
774 * @batch_fetch_count: number of message envelopes to fetch at once
776 * Sets the number of message envelopes to fetch at once.
778 * This is a tunable performance parameter and probably should not be
779 * exposed in a graphical user interface.
784 camel_imapx_settings_set_batch_fetch_count (CamelIMAPXSettings *settings,
785 guint batch_fetch_count)
787 g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
789 if (settings->priv->batch_fetch_count == batch_fetch_count)
792 settings->priv->batch_fetch_count = batch_fetch_count;
794 g_object_notify (G_OBJECT (settings), "batch-fetch-count");
798 * camel_imapx_settings_get_check_all:
799 * @settings: a #CamelIMAPXSettings
801 * Returns whether to check all folders for new messages.
803 * Returns: whether to check all folders for new messages
808 camel_imapx_settings_get_check_all (CamelIMAPXSettings *settings)
810 g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), FALSE);
812 return settings->priv->check_all;
816 * camel_imapx_settings_set_check_all:
817 * @settings: a #CamelIMAPXSettings
818 * @check_all: whether to check all folders for new messages
820 * Sets whether to check all folders for new messages.
825 camel_imapx_settings_set_check_all (CamelIMAPXSettings *settings,
828 g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
830 if (settings->priv->check_all == check_all)
833 settings->priv->check_all = check_all;
835 g_object_notify (G_OBJECT (settings), "check-all");
839 * camel_imapx_settings_get_check_subscribed:
840 * @settings: a #CamelIMAPXSettings
842 * Returns whether to check only subscribed folders for new messages.
843 * Note that #CamelIMAPXSettings:check-all, if %TRUE, overrides this setting.
845 * Returns: whether to check only subscribed folders for new messages
850 camel_imapx_settings_get_check_subscribed (CamelIMAPXSettings *settings)
852 g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), FALSE);
854 return settings->priv->check_subscribed;
858 * camel_imapx_settings_set_check_subscribed:
859 * @settings: a #CamelIMAPXSettings
860 * @check_subscribed: whether to check only subscribed folders for new messages
862 * Sets whether to check only subscribed folders for new messages. Note
863 * that #CamelIMAPXSettings:check-all, if %TRUE, overrides this setting.
868 camel_imapx_settings_set_check_subscribed (CamelIMAPXSettings *settings,
869 gboolean check_subscribed)
871 g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
873 if (settings->priv->check_subscribed == check_subscribed)
876 settings->priv->check_subscribed = check_subscribed;
878 g_object_notify (G_OBJECT (settings), "check-subscribed");
882 * camel_imapx_settings_get_concurrent_connections:
883 * @settings: a #CamelIMAPXSettings
885 * Returns the number of concurrent network connections to the IMAP server
886 * to use for faster command/response processing.
888 * Returns: the number of concurrent connections to use
893 camel_imapx_settings_get_concurrent_connections (CamelIMAPXSettings *settings)
895 g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), 1);
897 return settings->priv->concurrent_connections;
901 * camel_imapx_settings_set_concurrent_connections:
902 * @settings: a #CamelIMAPXSettings
903 * @concurrent_connections: the number of concurrent connections to use
905 * Sets the number of concurrent network connections to the IMAP server to
906 * use for faster command/response processing.
908 * The minimum number of connections is 1, the maximum is 7. The
909 * @concurrent_connections value will be clamped to these limits if
915 camel_imapx_settings_set_concurrent_connections (CamelIMAPXSettings *settings,
916 guint concurrent_connections)
918 g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
920 concurrent_connections = CLAMP (
921 concurrent_connections,
922 MIN_CONCURRENT_CONNECTIONS,
923 MAX_CONCURRENT_CONNECTIONS);
925 if (settings->priv->concurrent_connections == concurrent_connections)
928 settings->priv->concurrent_connections = concurrent_connections;
930 g_object_notify (G_OBJECT (settings), "concurrent-connections");
934 * camel_imapx_settings_get_fetch_order:
935 * @settings: a #CamelIMAPXSettings
937 * Returns the order in which new messages should be fetched.
939 * Returns: the order in which new messages should be fetched
944 camel_imapx_settings_get_fetch_order (CamelIMAPXSettings *settings)
946 g_return_val_if_fail (
947 CAMEL_IS_IMAPX_SETTINGS (settings),
948 CAMEL_SORT_ASCENDING);
950 return settings->priv->fetch_order;
954 * camel_imapx_settings_set_fetch_order:
955 * @settings: a #CamelIMAPXSettings
956 * @fetch_order: the order in which new messages should be fetched
958 * Sets the order in which new messages should be fetched.
963 camel_imapx_settings_set_fetch_order (CamelIMAPXSettings *settings,
964 CamelSortType fetch_order)
966 g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
968 if (settings->priv->fetch_order == fetch_order)
971 settings->priv->fetch_order = fetch_order;
973 g_object_notify (G_OBJECT (settings), "fetch-order");
977 * camel_imapx_settings_get_filter_all:
978 * @settings: a #CamelIMAPXSettings
980 * Returns whether apply filters in all folders.
982 * Returns: whether to apply filters in all folders
987 camel_imapx_settings_get_filter_all (CamelIMAPXSettings *settings)
989 g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), FALSE);
991 return settings->priv->filter_all;
995 * camel_imapx_settings_set_filter_all:
996 * @settings: a #CamelIMAPXSettings
997 * @filter_all: whether to apply filters in all folders
999 * Sets whether to apply filters in all folders.
1004 camel_imapx_settings_set_filter_all (CamelIMAPXSettings *settings,
1005 gboolean filter_all)
1007 g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
1009 if (settings->priv->filter_all == filter_all)
1012 settings->priv->filter_all = filter_all;
1014 g_object_notify (G_OBJECT (settings), "filter-all");
1018 * camel_imapx_settings_get_filter_junk:
1019 * @settings: a #CamelIMAPXSettings
1021 * Returns whether to automatically find and tag junk messages amongst new
1022 * messages in all folders.
1024 * Returns: whether to filter junk in all folders
1029 camel_imapx_settings_get_filter_junk (CamelIMAPXSettings *settings)
1031 g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), FALSE);
1033 return settings->priv->filter_junk;
1037 * camel_imapx_settings_set_filter_junk:
1038 * @settings: a #CamelIMAPXSettings
1039 * @filter_junk: whether to filter junk in all folders
1041 * Sets whether to automatically find and tag junk messages amongst new
1042 * messages in all folders.
1047 camel_imapx_settings_set_filter_junk (CamelIMAPXSettings *settings,
1048 gboolean filter_junk)
1050 g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
1052 if (settings->priv->filter_junk == filter_junk)
1055 settings->priv->filter_junk = filter_junk;
1057 g_object_notify (G_OBJECT (settings), "filter-junk");
1061 * camel_imapx_settings_get_filter_junk_inbox:
1062 * @settings: a #CamelIMAPXSettings
1064 * Returns whether to automatically find and tag junk messages amongst new
1065 * messages in the Inbox folder only.
1067 * Returns: whether to filter junk in Inbox only
1072 camel_imapx_settings_get_filter_junk_inbox (CamelIMAPXSettings *settings)
1074 g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), FALSE);
1076 return settings->priv->filter_junk_inbox;
1080 * camel_imapx_settings_set_filter_junk_inbox:
1081 * @settings: a #CamelIMAPXSettings
1082 * @filter_junk_inbox: whether to filter junk in Inbox only
1084 * Sets whether to automatically find and tag junk messages amongst new
1085 * messages in the Inbox folder only.
1090 camel_imapx_settings_set_filter_junk_inbox (CamelIMAPXSettings *settings,
1091 gboolean filter_junk_inbox)
1093 g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
1095 if (settings->priv->filter_junk_inbox == filter_junk_inbox)
1098 settings->priv->filter_junk_inbox = filter_junk_inbox;
1100 g_object_notify (G_OBJECT (settings), "filter-junk-inbox");
1104 * camel_imapx_settings_get_mobile_mode:
1105 * @settings: a #CamelIMAPXSettings
1107 * Returns whether the backend is operating in mobile mode.
1112 camel_imapx_settings_get_mobile_mode (CamelIMAPXSettings *settings)
1114 g_return_val_if_fail (
1115 CAMEL_IS_IMAPX_SETTINGS (settings),
1116 CAMEL_SORT_ASCENDING);
1118 return settings->priv->use_mobile_mode;
1122 * camel_imapx_settings_set_mobile_mode:
1123 * @settings: a #CamelIMAPXSettings
1124 * @mobile_mode: whether to operate in mobile mode.
1126 * Sets the mode of operation as mobile or not for the backend.
1131 camel_imapx_settings_set_mobile_mode (CamelIMAPXSettings *settings,
1132 gboolean mobile_mode)
1134 g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
1136 if (settings->priv->use_mobile_mode == mobile_mode)
1139 settings->priv->use_mobile_mode = mobile_mode;
1141 g_object_notify (G_OBJECT (settings), "mobile-mode");
1145 * camel_imapx_settings_get_namespace:
1146 * @settings: a #CamelIMAPXSettings
1148 * Returns the custom IMAP namespace in which to find folders.
1150 * Returns: the custom IMAP namespace, or %NULL
1155 camel_imapx_settings_get_namespace (CamelIMAPXSettings *settings)
1157 g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), NULL);
1159 return settings->priv->namespace;
1163 * camel_imapx_settings_dup_namespace:
1164 * @settings: a #CamelIMAPXSettings
1166 * Thread-safe variation of camel_imapx_settings_get_namespace().
1167 * Use this function when accessing @settings from multiple threads.
1169 * The returned string should be freed with g_free() when no longer needed.
1171 * Returns: a newly-allocated copy of #CamelIMAPXSettings:namespace
1176 camel_imapx_settings_dup_namespace (CamelIMAPXSettings *settings)
1178 const gchar *protected;
1181 g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), NULL);
1183 g_mutex_lock (&settings->priv->property_lock);
1185 protected = camel_imapx_settings_get_namespace (settings);
1186 duplicate = g_strdup (protected);
1188 g_mutex_unlock (&settings->priv->property_lock);
1194 * camel_imapx_settings_set_namespace:
1195 * @settings: a #CamelIMAPXSettings
1196 * @namespace_: an IMAP namespace, or %NULL
1198 * Sets the custom IMAP namespace in which to find folders. If @namespace_
1199 * is %NULL, the default namespace is used.
1204 camel_imapx_settings_set_namespace (CamelIMAPXSettings *settings,
1205 const gchar *namespace_)
1207 g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
1209 /* The default namespace is an empty string. */
1210 if (namespace_ == NULL)
1213 g_mutex_lock (&settings->priv->property_lock);
1215 if (g_strcmp0 (settings->priv->namespace, namespace_) == 0) {
1216 g_mutex_unlock (&settings->priv->property_lock);
1220 g_free (settings->priv->namespace);
1221 settings->priv->namespace = g_strdup (namespace_);
1223 g_mutex_unlock (&settings->priv->property_lock);
1225 g_object_notify (G_OBJECT (settings), "namespace");
1229 * camel_imapx_settings_get_real_junk_path:
1230 * @settings: a #CamelIMAPXSettings
1232 * Returns the path to a real, non-virtual Junk folder to be used instead
1233 * of Camel's standard virtual Junk folder.
1235 * Returns: path to a real junk folder
1240 camel_imapx_settings_get_real_junk_path (CamelIMAPXSettings *settings)
1242 g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), NULL);
1244 return settings->priv->real_junk_path;
1248 * camel_imapx_settings_dup_real_junk_path:
1249 * @settings: a #CamelIMAPXSettings
1251 * Thread-safe variation of camel_imapx_settings_get_real_junk_path().
1252 * Use this function when accessing @settings from multiple threads.
1254 * The returned string should be freed with g_free() when no longer needed.
1256 * Returns: a newly-allocated copy of #CamelIMAPXSettings:real-junk-path
1261 camel_imapx_settings_dup_real_junk_path (CamelIMAPXSettings *settings)
1263 const gchar *protected;
1266 g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), NULL);
1268 g_mutex_lock (&settings->priv->property_lock);
1270 protected = camel_imapx_settings_get_real_junk_path (settings);
1271 duplicate = g_strdup (protected);
1273 g_mutex_unlock (&settings->priv->property_lock);
1279 * camel_imapx_settings_set_real_junk_path:
1280 * @settings: a #CamelIMAPXSettings
1281 * @real_junk_path: path to a real Junk folder, or %NULL
1283 * Sets the path to a real, non-virtual Junk folder to be used instead of
1284 * Camel's standard virtual Junk folder.
1289 camel_imapx_settings_set_real_junk_path (CamelIMAPXSettings *settings,
1290 const gchar *real_junk_path)
1292 g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
1294 /* An empty string is equivalent to NULL. */
1295 if (real_junk_path != NULL && *real_junk_path == '\0')
1296 real_junk_path = NULL;
1298 g_mutex_lock (&settings->priv->property_lock);
1300 g_free (settings->priv->real_junk_path);
1301 settings->priv->real_junk_path = g_strdup (real_junk_path);
1303 g_mutex_unlock (&settings->priv->property_lock);
1305 g_object_notify (G_OBJECT (settings), "real-junk-path");
1309 * camel_imapx_settings_get_real_trash_path:
1310 * @settings: a #CamelIMAPXSettings
1312 * Returns the path to a real, non-virtual Trash folder to be used instead
1313 * of Camel's standard virtual Trash folder.
1315 * Returns: path to a real Trash folder
1320 camel_imapx_settings_get_real_trash_path (CamelIMAPXSettings *settings)
1322 g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), NULL);
1324 return settings->priv->real_trash_path;
1328 * camel_imapx_settings_dup_real_trash_path:
1329 * @settings: a #CamelIMAPXSettings
1331 * Thread-safe variation of camel_imapx_settings_get_real_trash_path().
1332 * Use this function when accessing @settings from multiple threads.
1334 * The returned string should be freed with g_free() when no longer needed.
1336 * Returns: a newly-allocated copy of #CamelIMAPXsettings:real-trash-path
1341 camel_imapx_settings_dup_real_trash_path (CamelIMAPXSettings *settings)
1343 const gchar *protected;
1346 g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), NULL);
1348 g_mutex_lock (&settings->priv->property_lock);
1350 protected = camel_imapx_settings_get_real_trash_path (settings);
1351 duplicate = g_strdup (protected);
1353 g_mutex_unlock (&settings->priv->property_lock);
1359 * camel_imapx_settings_set_real_trash_path:
1360 * @settings: a #CamelIMAPXSettings
1361 * @real_trash_path: path to a real Trash folder, or %NULL
1363 * Sets the path to a real, non-virtual Trash folder to be used instead of
1364 * Camel's standard virtual Trash folder.
1369 camel_imapx_settings_set_real_trash_path (CamelIMAPXSettings *settings,
1370 const gchar *real_trash_path)
1372 g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
1374 /* An empty string is equivalent to NULL. */
1375 if (real_trash_path != NULL && *real_trash_path == '\0')
1376 real_trash_path = NULL;
1378 g_mutex_lock (&settings->priv->property_lock);
1380 g_free (settings->priv->real_trash_path);
1381 settings->priv->real_trash_path = g_strdup (real_trash_path);
1383 g_mutex_unlock (&settings->priv->property_lock);
1385 g_object_notify (G_OBJECT (settings), "real-trash-path");
1389 * camel_imapx_settings_get_shell_command:
1390 * @settings: a #CamelIMAPXSettings
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.
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.
1401 * Returns: shell command for connecting to the server, or %NULL
1406 camel_imapx_settings_get_shell_command (CamelIMAPXSettings *settings)
1408 g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), NULL);
1410 return settings->priv->shell_command;
1414 * camel_imapx_settings_dup_shell_command:
1415 * @settings: a #CamelIMAPXSettings
1417 * Thread-safe variation of camel_imapx_settings_get_shell_command().
1418 * Use this function when accessing @settings from multiple threads.
1420 * The returned string should be freed with g_free() when no longer needed.
1422 * Returns: a newly-allocated copy of #CamelIMAPXSettings:shell-command
1427 camel_imapx_settings_dup_shell_command (CamelIMAPXSettings *settings)
1429 const gchar *protected;
1432 g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), NULL);
1434 g_mutex_lock (&settings->priv->property_lock);
1436 protected = camel_imapx_settings_get_shell_command (settings);
1437 duplicate = g_strdup (protected);
1439 g_mutex_unlock (&settings->priv->property_lock);
1445 * camel_imapx_settings_set_shell_command:
1446 * @settings: a #CamelIMAPXSettings
1447 * @shell_command: shell command for connecting to the server, or %NULL
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.
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.
1461 camel_imapx_settings_set_shell_command (CamelIMAPXSettings *settings,
1462 const gchar *shell_command)
1464 g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
1466 /* An empty string is equivalent to NULL. */
1467 if (shell_command != NULL && *shell_command == '\0')
1468 shell_command = NULL;
1470 g_mutex_lock (&settings->priv->property_lock);
1472 if (g_strcmp0 (settings->priv->shell_command, shell_command) == 0) {
1473 g_mutex_unlock (&settings->priv->property_lock);
1477 g_free (settings->priv->shell_command);
1478 settings->priv->shell_command = g_strdup (shell_command);
1480 g_mutex_unlock (&settings->priv->property_lock);
1482 g_object_notify (G_OBJECT (settings), "shell-command");
1486 * camel_imapx_settings_get_use_idle:
1487 * @settings: a #CamelIMAPXSettings
1489 * Returns whether to use the IMAP IDLE extension if the server supports
1490 * it. See RFC 2177 for more details.
1492 * Returns: whether to use the IDLE extension
1497 camel_imapx_settings_get_use_idle (CamelIMAPXSettings *settings)
1499 g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), FALSE);
1501 return settings->priv->use_idle;
1505 * camel_imapx_settings_set_use_idle:
1506 * @settings: a #CamelIMAPXSettings
1507 * @use_idle: whether to use the IDLE extension
1509 * Sets whether to use the IMAP IDLE extension if the server supports it.
1510 * See RFC 2177 for more details.
1515 camel_imapx_settings_set_use_idle (CamelIMAPXSettings *settings,
1518 g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
1520 if (settings->priv->use_idle == use_idle)
1523 settings->priv->use_idle = use_idle;
1525 g_object_notify (G_OBJECT (settings), "use-idle");
1529 * camel_imapx_settings_get_use_namespace:
1530 * @settings: a #CamelIMAPXSettings
1532 * Returns whether to use a custom IMAP namespace to find folders. The
1533 * namespace itself is given by the #CamelIMAPStore:namespace property.
1535 * Returns: whether to use a custom IMAP namespace
1540 camel_imapx_settings_get_use_namespace (CamelIMAPXSettings *settings)
1542 g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), FALSE);
1544 return settings->priv->use_namespace;
1548 * camel_imapx_settings_set_use_namespace:
1549 * @settings: a #CamelIMAPXSettings
1550 * @use_namespace: whether to use a custom IMAP namespace
1552 * Sets whether to use a custom IMAP namespace to find folders. The
1553 * namespace itself is given by the #CamelIMAPXSettings:namespace property.
1558 camel_imapx_settings_set_use_namespace (CamelIMAPXSettings *settings,
1559 gboolean use_namespace)
1561 g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
1563 if (settings->priv->use_namespace == use_namespace)
1566 settings->priv->use_namespace = use_namespace;
1568 g_object_notify (G_OBJECT (settings), "use-namespace");
1572 * camel_imapx_settings_get_use_qresync:
1573 * @settings: a #CamelIMAPXSettings
1575 * Returns whether to use the Quick Mailbox Resynchronization (QRESYNC)
1576 * IMAP extension if the server supports it. See RFC 5162 for more
1579 * Returns: whether to use the QRESYNC extension
1584 camel_imapx_settings_get_use_qresync (CamelIMAPXSettings *settings)
1586 g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), FALSE);
1588 return settings->priv->use_qresync;
1592 * camel_imapx_settings_set_use_qresync:
1593 * @settings: a #CamelIMAPXSettings
1594 * @use_qresync: whether to use the QRESYNC extension
1596 * Sets whether to use the Quick Mailbox Resynchronization (QRESYNC)
1597 * IMAP extension if the server supports it. See RFC 5162 for more
1603 camel_imapx_settings_set_use_qresync (CamelIMAPXSettings *settings,
1604 gboolean use_qresync)
1606 g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
1608 if (settings->priv->use_qresync == use_qresync)
1611 settings->priv->use_qresync = use_qresync;
1613 g_object_notify (G_OBJECT (settings), "use-qresync");
1617 * camel_imapx_settings_get_use_real_junk_path:
1618 * @settings: a #CamelIMAPXSettings
1620 * Returns whether to use a real, non-virtual Junk folder instead of Camel's
1621 * standard virtual Junk folder.
1623 * Returns: whether to use a real Junk folder
1628 camel_imapx_settings_get_use_real_junk_path (CamelIMAPXSettings *settings)
1630 g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), FALSE);
1632 return settings->priv->use_real_junk_path;
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
1640 * Sets whether to use a real, non-virtual Junk folder instead of Camel's
1641 * standard virtual Junk folder.
1646 camel_imapx_settings_set_use_real_junk_path (CamelIMAPXSettings *settings,
1647 gboolean use_real_junk_path)
1649 g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
1651 if (settings->priv->use_real_junk_path == use_real_junk_path)
1654 settings->priv->use_real_junk_path = use_real_junk_path;
1656 g_object_notify (G_OBJECT (settings), "use-real-junk-path");
1660 * camel_imapx_settings_get_use_real_trash_path:
1661 * @settings: a #CamelIMAPXSettings
1663 * Returns whether to use a real, non-virtual Trash folder instead of Camel's
1664 * standard virtual Trash folder.
1666 * Returns: whether to use a real Trash folder
1671 camel_imapx_settings_get_use_real_trash_path (CamelIMAPXSettings *settings)
1673 g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), FALSE);
1675 return settings->priv->use_real_trash_path;
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
1683 * Sets whether to use a real, non-virtual Trash folder instead of Camel's
1684 * standard virtual Trash folder.
1689 camel_imapx_settings_set_use_real_trash_path (CamelIMAPXSettings *settings,
1690 gboolean use_real_trash_path)
1692 g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
1694 if (settings->priv->use_real_trash_path == use_real_trash_path)
1697 settings->priv->use_real_trash_path = use_real_trash_path;
1699 g_object_notify (G_OBJECT (settings), "use-real-trash-path");
1703 * camel_imapx_settings_get_use_shell_command:
1704 * @settings: a #CamelIMAPXSettings
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.
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.
1716 * Returns: whether to use a custom shell command to connect to the server
1721 camel_imapx_settings_get_use_shell_command (CamelIMAPXSettings *settings)
1723 g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), FALSE);
1725 return settings->priv->use_shell_command;
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
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.
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.
1747 camel_imapx_settings_set_use_shell_command (CamelIMAPXSettings *settings,
1748 gboolean use_shell_command)
1750 g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
1752 if (settings->priv->use_shell_command == use_shell_command)
1755 settings->priv->use_shell_command = use_shell_command;
1757 g_object_notify (G_OBJECT (settings), "use-shell-command");
1761 * camel_imapx_settings_get_use_subscriptions:
1762 * @settings: a #CamelIMAPXSettings
1764 * Returns whether to list and operate only on subscribed folders, or to
1765 * list and operate on all available folders regardless of subscriptions.
1767 * Returns: whether to honor folder subscriptions
1772 camel_imapx_settings_get_use_subscriptions (CamelIMAPXSettings *settings)
1774 g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), FALSE);
1776 return settings->priv->use_subscriptions;
1780 * camel_imapx_settings_set_use_subscriptions:
1781 * @settings: a #CamelIMAPXSettings
1782 * @use_subscriptions: whether to honor folder subscriptions
1784 * Sets whether to list and operate only on subscribed folders, or to
1785 * list and operate on all available folders regardless of subscriptions.
1790 camel_imapx_settings_set_use_subscriptions (CamelIMAPXSettings *settings,
1791 gboolean use_subscriptions)
1793 g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
1795 if (settings->priv->use_subscriptions == use_subscriptions)
1798 settings->priv->use_subscriptions = use_subscriptions;
1800 g_object_notify (G_OBJECT (settings), "use-subscriptions");