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/>
20 * SECTION: e-source-offline
21 * @include: libedataserver/e-source-offline.h
22 * @short_description: #ESource extension for offline settings
24 * The #ESourceOffline extension tracks whether data from a remote
25 * server should be cached locally for viewing while offline.
27 * Access the extension as follows:
30 * #include <libedataserver/e-source-offline.h>
32 * ESourceOffline *extension;
34 * extension = e_source_get_extension (source, E_SOURCE_EXTENSION_OFFLINE);
38 #include "e-source-offline.h"
40 #define E_SOURCE_OFFLINE_GET_PRIVATE(obj) \
41 (G_TYPE_INSTANCE_GET_PRIVATE \
42 ((obj), E_TYPE_SOURCE_OFFLINE, ESourceOfflinePrivate))
44 struct _ESourceOfflinePrivate {
45 gboolean stay_synchronized;
50 PROP_STAY_SYNCHRONIZED
56 E_TYPE_SOURCE_EXTENSION)
59 source_offline_set_property (GObject *object,
64 switch (property_id) {
65 case PROP_STAY_SYNCHRONIZED:
66 e_source_offline_set_stay_synchronized (
67 E_SOURCE_OFFLINE (object),
68 g_value_get_boolean (value));
72 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
76 source_offline_get_property (GObject *object,
81 switch (property_id) {
82 case PROP_STAY_SYNCHRONIZED:
85 e_source_offline_get_stay_synchronized (
86 E_SOURCE_OFFLINE (object)));
90 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
94 e_source_offline_class_init (ESourceOfflineClass *class)
96 GObjectClass *object_class;
97 ESourceExtensionClass *extension_class;
99 g_type_class_add_private (class, sizeof (ESourceOfflinePrivate));
101 object_class = G_OBJECT_CLASS (class);
102 object_class->set_property = source_offline_set_property;
103 object_class->get_property = source_offline_get_property;
105 extension_class = E_SOURCE_EXTENSION_CLASS (class);
106 extension_class->name = E_SOURCE_EXTENSION_OFFLINE;
108 g_object_class_install_property (
110 PROP_STAY_SYNCHRONIZED,
111 g_param_spec_boolean (
114 "Keep remote content synchronized locally",
118 G_PARAM_STATIC_STRINGS |
119 E_SOURCE_PARAM_SETTING));
123 e_source_offline_init (ESourceOffline *extension)
125 extension->priv = E_SOURCE_OFFLINE_GET_PRIVATE (extension);
129 * e_source_offline_get_stay_synchronized:
130 * @extension: an #ESourceOffline
132 * Returns whether data from a remote server should be cached locally
133 * for viewing while offline. Backends are responsible for implementing
136 * Returns: whether data should be cached for offline
141 e_source_offline_get_stay_synchronized (ESourceOffline *extension)
143 g_return_val_if_fail (E_IS_SOURCE_OFFLINE (extension), FALSE);
145 return extension->priv->stay_synchronized;
149 * e_source_offline_set_stay_synchronized:
150 * @extension: an #ESourceOffline
151 * @stay_synchronized: whether data should be cached for offline
153 * Sets whether data from a remote server should be cached locally for
154 * viewing while offline. Backends are responsible for implementing
160 e_source_offline_set_stay_synchronized (ESourceOffline *extension,
161 gboolean stay_synchronized)
163 g_return_if_fail (E_IS_SOURCE_OFFLINE (extension));
165 extension->priv->stay_synchronized = stay_synchronized;
167 g_object_notify (G_OBJECT (extension), "stay-synchronized");