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 settings->priv->batch_fetch_count = batch_fetch_count;
683 g_object_notify (G_OBJECT (settings), "batch-fetch-count");
687 * camel_imapx_settings_get_check_all:
688 * @settings: a #CamelIMAPXSettings
690 * Returns whether to check all folders for new messages.
692 * Returns: whether to check all folders for new messages
697 camel_imapx_settings_get_check_all (CamelIMAPXSettings *settings)
699 g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), FALSE);
701 return settings->priv->check_all;
705 * camel_imapx_settings_set_check_all:
706 * @settings: a #CamelIMAPXSettings
707 * @check_all: whether to check all folders for new messages
709 * Sets whether to check all folders for new messages.
714 camel_imapx_settings_set_check_all (CamelIMAPXSettings *settings,
717 g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
719 settings->priv->check_all = check_all;
721 g_object_notify (G_OBJECT (settings), "check-all");
725 * camel_imapx_settings_get_check_subscribed:
726 * @settings: a #CamelIMAPXSettings
728 * Returns whether to check only subscribed folders for new messages.
729 * Note that #CamelIMAPXSettings:check-all, if %TRUE, overrides this setting.
731 * Returns: whether to check only subscribed folders for new messages
736 camel_imapx_settings_get_check_subscribed (CamelIMAPXSettings *settings)
738 g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), FALSE);
740 return settings->priv->check_subscribed;
744 * camel_imapx_settings_set_check_subscribed:
745 * @settings: a #CamelIMAPXSettings
746 * @check_subscribed: whether to check only subscribed folders for new messages
748 * Sets whether to check only subscribed folders for new messages. Note
749 * that #CamelIMAPXSettings:check-all, if %TRUE, overrides this setting.
754 camel_imapx_settings_set_check_subscribed (CamelIMAPXSettings *settings,
755 gboolean check_subscribed)
757 g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
759 settings->priv->check_subscribed = check_subscribed;
761 g_object_notify (G_OBJECT (settings), "check-subscribed");
765 * camel_imapx_settings_get_concurrent_connections:
766 * @settings: a #CamelIMAPXSettings
768 * Returns the number of concurrent network connections to the IMAP server
769 * to use for faster command/response processing.
771 * Returns: the number of concurrent connections to use
776 camel_imapx_settings_get_concurrent_connections (CamelIMAPXSettings *settings)
778 g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), 1);
780 return settings->priv->concurrent_connections;
784 * camel_imapx_settings_set_concurrent_connections:
785 * @settings: a #CamelIMAPXSettings
786 * @concurrent_connections: the number of concurrent connections to use
788 * Sets the number of concurrent network connections to the IMAP server to
789 * use for faster command/response processing.
791 * The minimum number of connections is 1, the maximum is 7. The
792 * @concurrent_connections value will be clamped to these limits if
798 camel_imapx_settings_set_concurrent_connections (CamelIMAPXSettings *settings,
799 guint concurrent_connections)
801 g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
803 concurrent_connections = CLAMP (
804 concurrent_connections,
805 MIN_CONCURRENT_CONNECTIONS,
806 MAX_CONCURRENT_CONNECTIONS);
808 settings->priv->concurrent_connections = concurrent_connections;
810 g_object_notify (G_OBJECT (settings), "concurrent-connections");
814 * camel_imapx_settings_get_fetch_order:
815 * @settings: a #CamelIMAPXSettings
817 * Returns the order in which new messages should be fetched.
819 * Returns: the order in which new messages should be fetched
824 camel_imapx_settings_get_fetch_order (CamelIMAPXSettings *settings)
826 g_return_val_if_fail (
827 CAMEL_IS_IMAPX_SETTINGS (settings),
828 CAMEL_SORT_ASCENDING);
830 return settings->priv->fetch_order;
834 * camel_imapx_settings_set_fetch_order:
835 * @settings: a #CamelIMAPXSettings
836 * @fetch_order: the order in which new messages should be fetched
838 * Sets the order in which new messages should be fetched.
843 camel_imapx_settings_set_fetch_order (CamelIMAPXSettings *settings,
844 CamelSortType fetch_order)
846 g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
848 settings->priv->fetch_order = fetch_order;
850 g_object_notify (G_OBJECT (settings), "fetch-order");
854 * camel_imapx_settings_get_filter_all:
855 * @settings: a #CamelIMAPXSettings
857 * Returns whether apply filters in all folders.
859 * Returns: whether to apply filters in all folders
864 camel_imapx_settings_get_filter_all (CamelIMAPXSettings *settings)
866 g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), FALSE);
868 return settings->priv->filter_all;
872 * camel_imapx_settings_set_filter_all:
873 * @settings: a #CamelIMAPXSettings
874 * @filter_all: whether to apply filters in all folders
876 * Sets whether to apply filters in all folders.
881 camel_imapx_settings_set_filter_all (CamelIMAPXSettings *settings,
884 g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
886 settings->priv->filter_all = filter_all;
888 g_object_notify (G_OBJECT (settings), "filter-all");
892 * camel_imapx_settings_get_filter_junk:
893 * @settings: a #CamelIMAPXSettings
895 * Returns whether to automatically find and tag junk messages amongst new
896 * messages in all folders.
898 * Returns: whether to filter junk in all folders
903 camel_imapx_settings_get_filter_junk (CamelIMAPXSettings *settings)
905 g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), FALSE);
907 return settings->priv->filter_junk;
911 * camel_imapx_settings_set_filter_junk:
912 * @settings: a #CamelIMAPXSettings
913 * @filter_junk: whether to filter junk in all folders
915 * Sets whether to automatically find and tag junk messages amongst new
916 * messages in all folders.
921 camel_imapx_settings_set_filter_junk (CamelIMAPXSettings *settings,
922 gboolean filter_junk)
924 g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
926 settings->priv->filter_junk = filter_junk;
928 g_object_notify (G_OBJECT (settings), "filter-junk");
932 * camel_imapx_settings_get_filter_junk_inbox:
933 * @settings: a #CamelIMAPXSettings
935 * Returns whether to automatically find and tag junk messages amongst new
936 * messages in the Inbox folder only.
938 * Returns: whether to filter junk in Inbox only
943 camel_imapx_settings_get_filter_junk_inbox (CamelIMAPXSettings *settings)
945 g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), FALSE);
947 return settings->priv->filter_junk_inbox;
951 * camel_imapx_settings_set_filter_junk_inbox:
952 * @settings: a #CamelIMAPXSettings
953 * @filter_junk_inbox: whether to filter junk in Inbox only
955 * Sets whether to automatically find and tag junk messages amongst new
956 * messages in the Inbox folder only.
961 camel_imapx_settings_set_filter_junk_inbox (CamelIMAPXSettings *settings,
962 gboolean filter_junk_inbox)
964 g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
966 settings->priv->filter_junk_inbox = filter_junk_inbox;
968 g_object_notify (G_OBJECT (settings), "filter-junk-inbox");
972 * camel_imapx_settings_get_mobile_mode:
973 * @settings: a #CamelIMAPXSettings
975 * Returns whether the backend is operating in mobile mode.
980 camel_imapx_settings_get_mobile_mode (CamelIMAPXSettings *settings)
982 g_return_val_if_fail (
983 CAMEL_IS_IMAPX_SETTINGS (settings),
984 CAMEL_SORT_ASCENDING);
986 return settings->priv->use_mobile_mode;
990 * camel_imapx_settings_set_mobile_mode:
991 * @settings: a #CamelIMAPXSettings
992 * @mobile_mode: whether to operate in mobile mode.
994 * Sets the mode of operation as mobile or not for the backend.
999 camel_imapx_settings_set_mobile_mode (CamelIMAPXSettings *settings,
1000 gboolean mobile_mode)
1002 g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
1004 settings->priv->use_mobile_mode = mobile_mode;
1006 g_object_notify (G_OBJECT (settings), "mobile-mode");
1010 * camel_imapx_settings_get_namespace:
1011 * @settings: a #CamelIMAPXSettings
1013 * Returns the custom IMAP namespace in which to find folders.
1015 * Returns: the custom IMAP namespace, or %NULL
1020 camel_imapx_settings_get_namespace (CamelIMAPXSettings *settings)
1022 g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), NULL);
1024 return settings->priv->namespace;
1028 * camel_imapx_settings_dup_namespace:
1029 * @settings: a #CamelIMAPXSettings
1031 * Thread-safe variation of camel_imapx_settings_get_namespace().
1032 * Use this function when accessing @settings from a worker thread.
1034 * The returned string should be freed with g_free() when no longer needed.
1036 * Returns: a newly-allocated copy of #CamelIMAPXSettings:namespace
1041 camel_imapx_settings_dup_namespace (CamelIMAPXSettings *settings)
1043 const gchar *protected;
1046 g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), NULL);
1048 g_mutex_lock (settings->priv->property_lock);
1050 protected = camel_imapx_settings_get_namespace (settings);
1051 duplicate = g_strdup (protected);
1053 g_mutex_unlock (settings->priv->property_lock);
1059 * camel_imapx_settings_set_namespace:
1060 * @settings: a #CamelIMAPXSettings
1061 * @namespace: an IMAP namespace, or %NULL
1063 * Sets the custom IMAP namespace in which to find folders. If @namespace
1064 * is %NULL, the default namespace is used.
1069 camel_imapx_settings_set_namespace (CamelIMAPXSettings *settings,
1070 const gchar *namespace)
1072 g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
1074 /* The default namespace is an empty string. */
1075 if (namespace == NULL)
1078 g_mutex_lock (settings->priv->property_lock);
1080 g_free (settings->priv->namespace);
1081 settings->priv->namespace = g_strdup (namespace);
1083 g_mutex_unlock (settings->priv->property_lock);
1085 g_object_notify (G_OBJECT (settings), "namespace");
1089 * camel_imapx_settings_get_shell_command:
1090 * @settings: a #CamelIMAPXSettings
1092 * Returns an optional shell command used to establish an input/output
1093 * stream with an IMAP server. Normally the input/output stream is
1094 * established through a network socket.
1096 * This option is useful only to a select few advanced users who likely
1097 * administer their own IMAP server. Most users will not understand what
1098 * this option menas or how to use it. Probably not worth exposing in a
1099 * graphical interface.
1101 * Returns: shell command for connecting to the server, or %NULL
1106 camel_imapx_settings_get_shell_command (CamelIMAPXSettings *settings)
1108 g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), NULL);
1110 return settings->priv->shell_command;
1114 * camel_imapx_settings_dup_shell_command:
1115 * @settings: a #CamelIMAPXSettings
1117 * Thread-safe variation of camel_imapx_settings_get_shell_command().
1118 * Use this function when accessing @settings from a worker thread.
1120 * The returned string should be freed with g_free() when no longer needed.
1122 * Returns: a newly-allocated copy of #CamelIMAPXSettings:shell-command
1127 camel_imapx_settings_dup_shell_command (CamelIMAPXSettings *settings)
1129 const gchar *protected;
1132 g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), NULL);
1134 g_mutex_lock (settings->priv->property_lock);
1136 protected = camel_imapx_settings_get_shell_command (settings);
1137 duplicate = g_strdup (protected);
1139 g_mutex_unlock (settings->priv->property_lock);
1145 * camel_imapx_settings_set_shell_command:
1146 * @settings: a #CamelIMAPXSettings
1147 * @shell_command: shell command for connecting to the server, or %NULL
1149 * Sets an optional shell command used to establish an input/output stream
1150 * with an IMAP server. Normally the input/output stream is established
1151 * through a network socket.
1153 * This option is useful only to a select few advanced users who likely
1154 * administer their own IMAP server. Most users will not understand what
1155 * this option means or how to use it. Probably not worth exposing in a
1156 * graphical interface.
1161 camel_imapx_settings_set_shell_command (CamelIMAPXSettings *settings,
1162 const gchar *shell_command)
1164 g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
1166 /* An empty string is equivalent to NULL. */
1167 if (shell_command != NULL && *shell_command == '\0')
1168 shell_command = NULL;
1170 g_mutex_lock (settings->priv->property_lock);
1172 g_free (settings->priv->shell_command);
1173 settings->priv->shell_command = g_strdup (shell_command);
1175 g_mutex_unlock (settings->priv->property_lock);
1177 g_object_notify (G_OBJECT (settings), "shell-command");
1181 * camel_imapx_settings_get_use_idle:
1182 * @settings: a #CamelIMAPXSettings
1184 * Returns whether to use the IMAP IDLE extension if the server supports
1185 * it. See RFC 2177 for more details.
1187 * Returns: whether to use the IDLE extension
1192 camel_imapx_settings_get_use_idle (CamelIMAPXSettings *settings)
1194 g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), FALSE);
1196 return settings->priv->use_idle;
1200 * camel_imapx_settings_set_use_idle:
1201 * @settings: a #CamelIMAPXSettings
1202 * @use_idle: whether to use the IDLE extension
1204 * Sets whether to use the IMAP IDLE extension if the server supports it.
1205 * See RFC 2177 for more details.
1210 camel_imapx_settings_set_use_idle (CamelIMAPXSettings *settings,
1213 g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
1215 settings->priv->use_idle = use_idle;
1217 g_object_notify (G_OBJECT (settings), "use-idle");
1221 * camel_imapx_settings_get_use_namespace:
1222 * @settings: a #CamelIMAPXSettings
1224 * Returns whether to use a custom IMAP namespace to find folders. The
1225 * namespace itself is given by the #CamelIMAPStore:namespace property.
1227 * Returns: whether to use a custom IMAP namespace
1232 camel_imapx_settings_get_use_namespace (CamelIMAPXSettings *settings)
1234 g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), FALSE);
1236 return settings->priv->use_namespace;
1240 * camel_imapx_settings_set_use_namespace:
1241 * @settings: a #CamelIMAPXSettings
1242 * @use_namespace: whether to use a custom IMAP namespace
1244 * Sets whether to use a custom IMAP namespace to find folders. The
1245 * namespace itself is given by the #CamelIMAPXSettings:namespace property.
1250 camel_imapx_settings_set_use_namespace (CamelIMAPXSettings *settings,
1251 gboolean use_namespace)
1253 g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
1255 settings->priv->use_namespace = use_namespace;
1257 g_object_notify (G_OBJECT (settings), "use-namespace");
1261 * camel_imapx_settings_get_use_qresync:
1262 * @settings: a #CamelIMAPXSettings
1264 * Returns whether to use the Quick Mailbox Resynchronization (QRESYNC)
1265 * IMAP extension if the server supports it. See RFC 5162 for more
1268 * Returns: whether to use the QRESYNC extension
1273 camel_imapx_settings_get_use_qresync (CamelIMAPXSettings *settings)
1275 g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), FALSE);
1277 return settings->priv->use_qresync;
1281 * camel_imapx_settings_set_use_qresync:
1282 * @settings: a #CamelIMAPXSettings
1283 * @use_qresync: whether to use the QRESYNC extension
1285 * Sets whether to use the Quick Mailbox Resynchronization (QRESYNC)
1286 * IMAP extension if the server supports it. See RFC 5162 for more
1292 camel_imapx_settings_set_use_qresync (CamelIMAPXSettings *settings,
1293 gboolean use_qresync)
1295 g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
1297 settings->priv->use_qresync = use_qresync;
1299 g_object_notify (G_OBJECT (settings), "use-qresync");
1303 * camel_imapx_settings_get_use_shell_command:
1304 * @settings: a #CamelIMAPXSettings
1306 * Returns whether to use a custom shell command to establish an input/output
1307 * stream with an IMAP server, instead of the more common method of opening a
1308 * network socket. The shell command itself is given by the
1309 * #CamelIMAPXSettings:shell-command property.
1311 * This option is useful only to a select few advanced users who likely
1312 * administer their own IMAP server. Most users will not understand what
1313 * this option means or how to use it. Probably not worth exposing in a
1314 * graphical interface.
1316 * Returns: whether to use a custom shell command to connect to the server
1321 camel_imapx_settings_get_use_shell_command (CamelIMAPXSettings *settings)
1323 g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), FALSE);
1325 return settings->priv->use_shell_command;
1329 * camel_imapx_settings_set_use_shell_command:
1330 * @settings: a #CamelIMAPXSettings
1331 * @use_shell_command: whether to use a custom shell command to connect
1334 * Sets whether to use a custom shell command to establish an input/output
1335 * stream with an IMAP server, instead of the more common method of opening
1336 * a network socket. The shell command itself is given by the
1337 * #CamelIMAPXSettings:shell-command property.
1339 * This option is useful only to a select few advanced users who likely
1340 * administer their own IMAP server. Most users will not understand what
1341 * this option means or how to use it. Probably not worth exposing in a
1342 * graphical interface.
1347 camel_imapx_settings_set_use_shell_command (CamelIMAPXSettings *settings,
1348 gboolean use_shell_command)
1350 g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
1352 settings->priv->use_shell_command = use_shell_command;
1354 g_object_notify (G_OBJECT (settings), "use-shell-command");
1358 * camel_imapx_settings_get_use_subscriptions:
1359 * @settings: a #CamelIMAPXSettings
1361 * Returns whether to list and operate only on subscribed folders, or to
1362 * list and operate on all available folders regardless of subscriptions.
1364 * Returns: whether to honor folder subscriptions
1369 camel_imapx_settings_get_use_subscriptions (CamelIMAPXSettings *settings)
1371 g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), FALSE);
1373 return settings->priv->use_subscriptions;
1377 * camel_imapx_settings_set_use_subscriptions:
1378 * @settings: a #CamelIMAPXSettings
1379 * @use_subscriptions: whether to honor folder subscriptions
1381 * Sets whether to list and operate only on subscribed folders, or to
1382 * list and operate on all available folders regardless of subscriptions.
1387 camel_imapx_settings_set_use_subscriptions (CamelIMAPXSettings *settings,
1388 gboolean use_subscriptions)
1390 g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
1392 settings->priv->use_subscriptions = use_subscriptions;
1394 g_object_notify (G_OBJECT (settings), "use-subscriptions");