1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
|
/*
* Evolution calendar - Timezone selector dialog
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with the program; if not, see <http://www.gnu.org/licenses/>
*
*
* Authors:
* Damon Chaplin <damon@ximian.com>
*
* Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
*
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "e-send-options-utils.h"
#include <string.h>
void
e_send_options_utils_set_default_data (ESendOptionsDialog *sod, ESource *source, const gchar *type)
{
ESendOptionsGeneral *gopts = NULL;
ESendOptionsStatusTracking *sopts;
GConfClient *gconf = gconf_client_get_default ();
ESourceList *source_list;
const gchar *uid;
const gchar *value;
gopts = sod->data->gopts;
sopts = sod->data->sopts;
if (!strcmp (type, "calendar"))
source_list = e_source_list_new_for_gconf (gconf, "/apps/evolution/calendar/sources");
else
source_list = e_source_list_new_for_gconf (gconf, "/apps/evolution/tasks/sources");
uid = e_source_peek_uid (source);
source = e_source_list_peek_source_by_uid (source_list, uid);
/* priority */
value = e_source_get_property (source, "priority");
if (value) {
if (!strcmp (value, "high"))
gopts->priority = E_PRIORITY_HIGH;
else if (!strcmp (value, "standard"))
gopts->priority = E_PRIORITY_STANDARD;
else if (!strcmp (value, "low"))
gopts->priority = E_PRIORITY_LOW;
else
gopts->priority = E_PRIORITY_UNDEFINED;
}
/* Reply requested */
value = e_source_get_property (source, "reply-requested");
if (value) {
if (!strcmp (value, "none"))
gopts->reply_enabled = FALSE;
else if (!strcmp (value, "convinient")) {
gopts->reply_enabled = TRUE;
gopts->reply_convenient = TRUE;
} else {
gint i = atoi (value);
gopts->reply_within = i;
}
}
/* Delay delivery */
value = e_source_get_property (source, "delay-delivery");
if (value) {
if (!strcmp (value, "none"))
gopts->delay_enabled = FALSE;
else {
gopts->delay_enabled = TRUE;
gopts->delay_until = icaltime_as_timet (icaltime_from_string (value));
}
}
/* Expiration Date */
value = e_source_get_property (source, "expiration");
if (value) {
if (!strcmp (value, "none"))
gopts->expiration_enabled = FALSE;
else {
gint i = atoi (value);
if (i == 0)
gopts->expiration_enabled = FALSE;
else
gopts->expiration_enabled = TRUE;
gopts->expire_after = i;
}
}
/* status tracking */
value = e_source_get_property (source, "status-tracking");
if (value) {
if (!strcmp (value, "none"))
sopts->tracking_enabled = FALSE;
else {
sopts->tracking_enabled = TRUE;
if (!strcmp (value, "delivered"))
sopts->track_when = E_DELIVERED;
else if (!strcmp (value, "delivered-opened"))
sopts->track_when = E_DELIVERED_OPENED;
else
sopts->track_when = E_ALL;
}
}
/* Return Notifications */
value = e_source_get_property (source, "return-open");
if (value) {
if (!strcmp (value, "none"))
sopts->opened = E_RETURN_NOTIFY_NONE;
else
sopts->opened = E_RETURN_NOTIFY_MAIL;
}
value = e_source_get_property (source, "return-accept");
if (value) {
if (!strcmp (value, "none"))
sopts->accepted = E_RETURN_NOTIFY_NONE;
else
sopts->accepted = E_RETURN_NOTIFY_MAIL;
}
value = e_source_get_property (source, "return-decline");
if (value) {
if (!strcmp (value, "none"))
sopts->declined = E_RETURN_NOTIFY_NONE;
else
sopts->declined = E_RETURN_NOTIFY_MAIL;
}
value = e_source_get_property (source, "return-complete");
if (value) {
if (!strcmp (value, "none"))
sopts->completed = E_RETURN_NOTIFY_NONE;
else
sopts->completed = E_RETURN_NOTIFY_MAIL;
}
g_object_unref (gconf);
}
void
e_send_options_utils_fill_component (ESendOptionsDialog *sod,
ECalComponent *comp,
icaltimezone *zone)
{
gint i = 1;
icalproperty *prop;
icalcomponent *icalcomp;
ESendOptionsGeneral *gopts;
ESendOptionsStatusTracking *sopts;
gopts = sod->data->gopts;
sopts = sod->data->sopts;
e_cal_component_set_sequence (comp, &i);
icalcomp = e_cal_component_get_icalcomponent (comp);
if (e_send_options_get_need_general_options (sod)) {
prop = icalproperty_new_x ((const gchar *) g_strdup_printf ("%d", gopts->priority));
icalproperty_set_x_name (prop, "X-EVOLUTION-OPTIONS-PRIORITY");
icalcomponent_add_property (icalcomp, prop);
if (gopts->reply_enabled) {
if (gopts->reply_convenient)
prop = icalproperty_new_x ("convenient");
else
prop = icalproperty_new_x ((const gchar *) g_strdup_printf ( "%d", gopts->reply_within));
icalproperty_set_x_name (prop, "X-EVOLUTION-OPTIONS-REPLY");
icalcomponent_add_property (icalcomp, prop);
}
if (gopts->expiration_enabled && gopts->expire_after) {
prop = icalproperty_new_x ((const gchar *) g_strdup_printf ( "%d", gopts->expire_after));
icalproperty_set_x_name (prop, "X-EVOLUTION-OPTIONS-EXPIRE");
icalcomponent_add_property (icalcomp, prop);
}
if (gopts->delay_enabled) {
struct icaltimetype temp;
gchar *str;
temp = icaltime_from_timet_with_zone (gopts->delay_until, FALSE, zone);
str = icaltime_as_ical_string_r (temp);
prop = icalproperty_new_x (str);
g_free (str);
icalproperty_set_x_name (prop, "X-EVOLUTION-OPTIONS-DELAY");
icalcomponent_add_property (icalcomp, prop);
}
}
if (sopts->tracking_enabled)
prop = icalproperty_new_x ((const gchar *) g_strdup_printf ( "%d", sopts->track_when));
else
prop = icalproperty_new_x ("0");
icalproperty_set_x_name (prop, "X-EVOLUTION-OPTIONS-TRACKINFO");
icalcomponent_add_property (icalcomp, prop);
prop = icalproperty_new_x ((const gchar *) g_strdup_printf ("%d", sopts->opened));
icalproperty_set_x_name (prop, "X-EVOLUTION-OPTIONS-OPENED");
icalcomponent_add_property (icalcomp, prop);
prop = icalproperty_new_x ((const gchar *) g_strdup_printf ("%d", sopts->accepted));
icalproperty_set_x_name (prop, "X-EVOLUTION-OPTIONS-ACCEPTED");
icalcomponent_add_property (icalcomp, prop);
prop = icalproperty_new_x ((const gchar *) g_strdup_printf ("%d", sopts->declined));
icalproperty_set_x_name (prop, "X-EVOLUTION-OPTIONS-DECLINED");
icalcomponent_add_property (icalcomp, prop);
prop = icalproperty_new_x ((const gchar *) g_strdup_printf ("%d", sopts->completed));
icalproperty_set_x_name (prop, "X-EVOLUTION-OPTIONS-COMPLETED");
icalcomponent_add_property (icalcomp, prop);
}
|