goa: Add missing linker flag (for real).
[platform/upstream/evolution-data-server.git] / libedataserver / e-source-mdn.c
1 /*
2  * e-source-mdn.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 /**
20  * SECTION: e-source-mdn
21  * @include: libedataserver/libedataserver.h
22  * @short_description: #ESource extension for MDN settings
23  *
24  * The #ESourceMDN extension tracks Message Disposition Notification
25  * settings for a mail account.  See RFC 2298 for more information about
26  * Message Disposition Notification.
27  *
28  * Access the extension as follows:
29  *
30  * |[
31  *   #include <libedataserver/libedataserver.h>
32  *
33  *   ESourceMDN *extension;
34  *
35  *   extension = e_source_get_extension (source, E_SOURCE_EXTENSION_MDN);
36  * ]|
37  **/
38
39 #include "e-source-mdn.h"
40
41 #include <libedataserver/e-source-enumtypes.h>
42
43 #define E_SOURCE_MDN_GET_PRIVATE(obj) \
44         (G_TYPE_INSTANCE_GET_PRIVATE \
45         ((obj), E_TYPE_SOURCE_MDN, ESourceMDNPrivate))
46
47 struct _ESourceMDNPrivate {
48         EMdnResponsePolicy response_policy;
49 };
50
51 enum {
52         PROP_0,
53         PROP_RESPONSE_POLICY
54 };
55
56 G_DEFINE_TYPE (
57         ESourceMDN,
58         e_source_mdn,
59         E_TYPE_SOURCE_EXTENSION)
60
61 static void
62 source_mdn_set_property (GObject *object,
63                          guint property_id,
64                          const GValue *value,
65                          GParamSpec *pspec)
66 {
67         switch (property_id) {
68                 case PROP_RESPONSE_POLICY:
69                         e_source_mdn_set_response_policy (
70                                 E_SOURCE_MDN (object),
71                                 g_value_get_enum (value));
72                         return;
73         }
74
75         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
76 }
77
78 static void
79 source_mdn_get_property (GObject *object,
80                          guint property_id,
81                          GValue *value,
82                          GParamSpec *pspec)
83 {
84         switch (property_id) {
85                 case PROP_RESPONSE_POLICY:
86                         g_value_set_enum (
87                                 value,
88                                 e_source_mdn_get_response_policy (
89                                 E_SOURCE_MDN (object)));
90                         return;
91         }
92
93         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
94 }
95
96 static void
97 e_source_mdn_class_init (ESourceMDNClass *class)
98 {
99         GObjectClass *object_class;
100         ESourceExtensionClass *extension_class;
101
102         g_type_class_add_private (class, sizeof (ESourceMDNPrivate));
103
104         object_class = G_OBJECT_CLASS (class);
105         object_class->set_property = source_mdn_set_property;
106         object_class->get_property = source_mdn_get_property;
107
108         extension_class = E_SOURCE_EXTENSION_CLASS (class);
109         extension_class->name = E_SOURCE_EXTENSION_MDN;
110
111         g_object_class_install_property (
112                 object_class,
113                 PROP_RESPONSE_POLICY,
114                 g_param_spec_enum (
115                         "response-policy",
116                         "Response Policy",
117                         "Policy for responding to MDN requests",
118                         E_TYPE_MDN_RESPONSE_POLICY,
119                         E_MDN_RESPONSE_POLICY_ASK,
120                         G_PARAM_READWRITE |
121                         G_PARAM_CONSTRUCT |
122                         G_PARAM_STATIC_STRINGS |
123                         E_SOURCE_PARAM_SETTING));
124 }
125
126 static void
127 e_source_mdn_init (ESourceMDN *extension)
128 {
129         extension->priv = E_SOURCE_MDN_GET_PRIVATE (extension);
130 }
131
132 /**
133  * e_source_mdn_get_response_policy:
134  * @extension: an #ESourceMDN
135  *
136  * Returns the policy for this mail account on responding to Message
137  * Disposition Notification requests when receiving mail messages.
138  *
139  * Returns: the #EMdnResponsePolicy for this account
140  *
141  * Since: 3.6
142  **/
143 EMdnResponsePolicy
144 e_source_mdn_get_response_policy (ESourceMDN *extension)
145 {
146         g_return_val_if_fail (
147                 E_IS_SOURCE_MDN (extension),
148                 E_MDN_RESPONSE_POLICY_NEVER);
149
150         return extension->priv->response_policy;
151 }
152
153 /**
154  * e_source_mdn_set_response_policy:
155  * @extension: an #ESourceMDN
156  * @response_policy: the #EMdnResponsePolicy
157  *
158  * Sets the policy for this mail account on responding to Message
159  * Disposition Notification requests when receiving mail messages.
160  *
161  * Since: 3.6
162  **/
163 void
164 e_source_mdn_set_response_policy (ESourceMDN *extension,
165                                   EMdnResponsePolicy response_policy)
166 {
167         g_return_if_fail (E_IS_SOURCE_MDN (extension));
168
169         if (extension->priv->response_policy == response_policy)
170                 return;
171
172         extension->priv->response_policy = response_policy;
173
174         g_object_notify (G_OBJECT (extension), "response-policy");
175 }