2 * camel-offline-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-offline-settings.h"
21 #include <camel/camel-store-settings.h>
23 #define CAMEL_OFFLINE_SETTINGS_GET_PRIVATE(obj) \
24 (G_TYPE_INSTANCE_GET_PRIVATE \
25 ((obj), CAMEL_TYPE_OFFLINE_SETTINGS, CamelOfflineSettingsPrivate))
27 struct _CamelOfflineSettingsPrivate {
28 gboolean stay_synchronized;
33 PROP_STAY_SYNCHRONIZED
38 camel_offline_settings,
39 CAMEL_TYPE_STORE_SETTINGS)
42 offline_settings_set_property (GObject *object,
47 switch (property_id) {
48 case PROP_STAY_SYNCHRONIZED:
49 camel_offline_settings_set_stay_synchronized (
50 CAMEL_OFFLINE_SETTINGS (object),
51 g_value_get_boolean (value));
55 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
59 offline_settings_get_property (GObject *object,
64 switch (property_id) {
65 case PROP_STAY_SYNCHRONIZED:
68 camel_offline_settings_get_stay_synchronized (
69 CAMEL_OFFLINE_SETTINGS (object)));
73 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
77 camel_offline_settings_class_init (CamelOfflineSettingsClass *class)
79 GObjectClass *object_class;
81 g_type_class_add_private (class, sizeof (CamelOfflineSettingsPrivate));
83 object_class = G_OBJECT_CLASS (class);
84 object_class->set_property = offline_settings_set_property;
85 object_class->get_property = offline_settings_get_property;
87 g_object_class_install_property (
89 PROP_STAY_SYNCHRONIZED,
90 g_param_spec_boolean (
93 "Stay synchronized with the remote server",
97 G_PARAM_STATIC_STRINGS));
101 camel_offline_settings_init (CamelOfflineSettings *settings)
103 settings->priv = CAMEL_OFFLINE_SETTINGS_GET_PRIVATE (settings);
107 * camel_offline_settings_get_stay_synchronized:
108 * @settings: a #CamelOfflineSettings
110 * Returns whether to synchronize the local cache with the remote server
111 * before switching to offline mode, so the store's content can still be
112 * read while offline.
114 * Returns: whether to stay synchronized with the remote server
119 camel_offline_settings_get_stay_synchronized (CamelOfflineSettings *settings)
121 g_return_val_if_fail (CAMEL_IS_OFFLINE_SETTINGS (settings), FALSE);
123 return settings->priv->stay_synchronized;
127 * camel_offline_settings_set_stay_synchronized:
128 * @settings: a #CamelOfflineSettings
129 * @stay_synchronized: whether to stay synchronized with the remote server
131 * Sets whether to synchronize the local cache with the remote server before
132 * switching to offline mode, so the store's content can still be read while
138 camel_offline_settings_set_stay_synchronized (CamelOfflineSettings *settings,
139 gboolean stay_synchronized)
141 g_return_if_fail (CAMEL_IS_OFFLINE_SETTINGS (settings));
143 if (settings->priv->stay_synchronized == stay_synchronized)
146 settings->priv->stay_synchronized = stay_synchronized;
148 g_object_notify (G_OBJECT (settings), "stay-synchronized");