Extending test-client-custom-summary to try e_book_client_get_contacts_uids()
[platform/upstream/evolution-data-server.git] / camel / camel-store-settings.c
1 /*
2  * camel-store-settings.c
3  *
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.
8  *
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.
13  *
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/>
16  *
17  */
18
19 #include "camel-store-settings.h"
20
21 #define CAMEL_STORE_SETTINGS_GET_PRIVATE(obj) \
22         (G_TYPE_INSTANCE_GET_PRIVATE \
23         ((obj), CAMEL_TYPE_STORE_SETTINGS, CamelStoreSettingsPrivate))
24
25 struct _CamelStoreSettingsPrivate {
26         gboolean filter_inbox;
27 };
28
29 enum {
30         PROP_0,
31         PROP_FILTER_INBOX
32 };
33
34 G_DEFINE_TYPE (
35         CamelStoreSettings,
36         camel_store_settings,
37         CAMEL_TYPE_SETTINGS)
38
39 static void
40 store_settings_set_property (GObject *object,
41                              guint property_id,
42                              const GValue *value,
43                              GParamSpec *pspec)
44 {
45         switch (property_id) {
46                 case PROP_FILTER_INBOX:
47                         camel_store_settings_set_filter_inbox (
48                                 CAMEL_STORE_SETTINGS (object),
49                                 g_value_get_boolean (value));
50                         return;
51         }
52
53         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
54 }
55
56 static void
57 store_settings_get_property (GObject *object,
58                              guint property_id,
59                              GValue *value,
60                              GParamSpec *pspec)
61 {
62         switch (property_id) {
63                 case PROP_FILTER_INBOX:
64                         g_value_set_boolean (
65                                 value,
66                                 camel_store_settings_get_filter_inbox (
67                                 CAMEL_STORE_SETTINGS (object)));
68                         return;
69         }
70
71         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
72 }
73
74 static void
75 camel_store_settings_class_init (CamelStoreSettingsClass *class)
76 {
77         GObjectClass *object_class;
78
79         g_type_class_add_private (class, sizeof (CamelStoreSettingsPrivate));
80
81         object_class = G_OBJECT_CLASS (class);
82         object_class->set_property = store_settings_set_property;
83         object_class->get_property = store_settings_get_property;
84
85         g_object_class_install_property (
86                 object_class,
87                 PROP_FILTER_INBOX,
88                 g_param_spec_boolean (
89                         "filter-inbox",
90                         "Filter Inbox",
91                         "Whether to filter new messages in Inbox",
92                         FALSE,
93                         G_PARAM_READWRITE |
94                         G_PARAM_CONSTRUCT |
95                         G_PARAM_STATIC_STRINGS));
96 }
97
98 static void
99 camel_store_settings_init (CamelStoreSettings *settings)
100 {
101         settings->priv = CAMEL_STORE_SETTINGS_GET_PRIVATE (settings);
102 }
103
104 /**
105  * camel_store_settings_get_filter_inbox:
106  * @settings: a #CamelStoreSettings
107  *
108  * Returns whether to automatically apply filters to newly arrived messages
109  * in the store's Inbox folder (assuming it has an Inbox folder).
110  *
111  * Returns: whether to filter new messages in Inbox
112  *
113  * Since: 3.2
114  **/
115 gboolean
116 camel_store_settings_get_filter_inbox (CamelStoreSettings *settings)
117 {
118         g_return_val_if_fail (CAMEL_IS_STORE_SETTINGS (settings), FALSE);
119
120         return settings->priv->filter_inbox;
121 }
122
123 /**
124  * camel_store_settings_set_filter_inbox:
125  * @settings: a #CamelStoreSettings
126  * @filter_inbox: whether to filter new messages in Inbox
127  *
128  * Sets whether to automatically apply filters to newly arrived messages
129  * in the store's Inbox folder (assuming it has an Inbox folder).
130  *
131  * Since: 3.2
132  **/
133 void
134 camel_store_settings_set_filter_inbox (CamelStoreSettings *settings,
135                                        gboolean filter_inbox)
136 {
137         g_return_if_fail (CAMEL_IS_STORE_SETTINGS (settings));
138
139         if (settings->priv->filter_inbox == filter_inbox)
140                 return;
141
142         settings->priv->filter_inbox = filter_inbox;
143
144         g_object_notify (G_OBJECT (settings), "filter-inbox");
145 }