Fix FSF address (Tobias Mueller, #470445)
[platform/upstream/evolution-data-server.git] / servers / groupwise / e-gw-sendoptions.c
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /* 
3  * Authors : 
4  *  JP Rosevear <jpr@ximian.com>
5  *  Rodrigo Moya <rodrigo@ximian.com>
6  *
7  * Copyright 2003, Novell, Inc.
8  *
9  * This program is free software; you can redistribute it and/or 
10  * modify it under the terms of version 2 of the GNU Lesser General Public 
11  * License as published by the Free Software Foundation.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
21  * USA
22  */
23
24 #ifdef HAVE_CONFIG_H
25 #include <config.h>
26 #endif
27 #include <string.h>
28 #include "e-gw-connection.h"
29 #include "e-gw-sendoptions.h"
30 #include "e-gw-message.h"
31
32 struct _EGwSendOptionsPrivate {
33         EGwSendOptionsGeneral *gopts;
34         EGwSendOptionsStatusTracking *mopts;
35         EGwSendOptionsStatusTracking *copts;
36         EGwSendOptionsStatusTracking *topts;
37 };
38
39 static GObjectClass *parent_class = NULL;
40
41 static gboolean e_gw_sendoptions_store_settings (SoupSoapParameter *param, EGwSendOptions *opts);
42 static void e_gw_sendoptions_init (GObject *object);
43 static void e_gw_sendoptions_class_init (GObjectClass *klass);
44 static void e_gw_sendoptions_dispose (GObject *object);
45 static void e_gw_sendoptions_finalize (GObject *object);
46
47 EGwSendOptionsGeneral*
48 e_gw_sendoptions_get_general_options (EGwSendOptions *opts) 
49 {
50         g_return_val_if_fail (opts != NULL || E_IS_GW_SENDOPTIONS (opts), NULL);
51
52         return opts->priv->gopts;
53 }
54
55 EGwSendOptionsStatusTracking*
56 e_gw_sendoptions_get_status_tracking_options (EGwSendOptions *opts, char *type)
57 {
58         g_return_val_if_fail (opts != NULL || E_IS_GW_SENDOPTIONS (opts), NULL);
59         g_return_val_if_fail (type != NULL, NULL);
60
61         if (!g_ascii_strcasecmp (type, "mail"))
62                 return opts->priv->mopts;
63         else if (!g_ascii_strcasecmp (type, "calendar"))
64                 return opts->priv->copts;
65         else if (!g_ascii_strcasecmp (type, "task"))
66                 return opts->priv->topts;
67         else
68                 return NULL;
69 }
70
71 static void
72 e_gw_sendoptions_dispose (GObject *object)
73 {
74         EGwSendOptions *opts = (EGwSendOptions *) object;
75
76         g_return_if_fail (E_IS_GW_SENDOPTIONS (opts));
77
78         if (parent_class->dispose)
79                 (* parent_class->dispose) (object);
80 }
81
82 static void
83 e_gw_sendoptions_finalize (GObject *object) 
84 {
85         EGwSendOptions *opts = (EGwSendOptions *) object;
86         EGwSendOptionsPrivate *priv;
87
88         g_return_if_fail (E_IS_GW_SENDOPTIONS (opts));
89
90         priv = opts->priv;
91         
92         if (priv->gopts) {
93                 g_free (priv->gopts);
94                 priv->gopts = NULL;
95         }
96
97         if (priv->mopts) {
98                 g_free (priv->mopts);
99                 priv->mopts = NULL;
100         }
101
102         if (priv->copts) {
103                 g_free (priv->copts);
104                 priv->copts = NULL;
105         }
106
107         if (priv->topts) {
108                 g_free (priv->topts);
109                 priv->topts = NULL;
110         }
111
112         if (priv) {
113                 g_free (priv);
114                 opts->priv = NULL;
115         }
116
117         if (parent_class->finalize)
118                 (* parent_class->finalize) (object);
119 }
120
121 static void
122 e_gw_sendoptions_class_init (GObjectClass *klass)
123 {
124         GObjectClass *object_class = G_OBJECT_CLASS (klass);
125
126         parent_class = g_type_class_peek_parent (klass);
127
128         object_class->dispose = e_gw_sendoptions_dispose;
129         object_class->finalize = e_gw_sendoptions_finalize;
130 }
131
132 static void
133 e_gw_sendoptions_init (GObject *object)
134 {               
135         EGwSendOptions *opts;
136         EGwSendOptionsPrivate *priv;
137
138         opts = E_GW_SENDOPTIONS (object);
139
140         /* allocate internal structure */
141         priv = g_new0 (EGwSendOptionsPrivate, 1);
142         priv->gopts = g_new0 (EGwSendOptionsGeneral, 1);
143         priv->mopts = g_new0 (EGwSendOptionsStatusTracking, 1);
144         priv->copts = g_new0 (EGwSendOptionsStatusTracking, 1);
145         priv->topts = g_new0 (EGwSendOptionsStatusTracking, 1);
146         opts->priv = priv;
147 }
148
149 GType
150 e_gw_sendoptions_get_type (void)
151 {
152         static GType type = 0;
153
154         if (!type) {
155                 static GTypeInfo info = {
156                         sizeof (EGwSendOptionsClass),
157                         NULL,
158                         NULL,
159                         (GClassInitFunc) e_gw_sendoptions_class_init,
160                         NULL, NULL,
161                         sizeof (EGwSendOptions),
162                         0,
163                         (GInstanceInitFunc) e_gw_sendoptions_init,
164                         NULL
165                 };
166                 type = g_type_register_static (G_TYPE_OBJECT, "EGwSendOptions", &info, 0);
167         }
168
169         return type;
170 }
171
172 static void
173 parse_status_tracking_options (SoupSoapParameter *group_param, guint i, EGwSendOptionsStatusTracking *sopts)
174 {
175         SoupSoapParameter *subparam, *field_param, *val_param;
176
177         for (subparam = soup_soap_parameter_get_first_child_by_name(group_param, "setting") ;
178                              subparam != NULL ;
179                              subparam = soup_soap_parameter_get_next_child_by_name (subparam, "setting")) {
180
181                 char *field = NULL, *val = NULL;
182                 field_param = soup_soap_parameter_get_first_child_by_name (subparam, "field");
183                 val_param = soup_soap_parameter_get_first_child_by_name (subparam, "value");
184                 
185                 if (field_param) {
186                         field = soup_soap_parameter_get_string_value (field_param);
187                         if (!field)
188                                 continue;
189                 } else
190                         continue;
191
192                 if (!g_ascii_strcasecmp (field + i, "StatusInfo")) {
193                         if (val_param)
194                                 val = soup_soap_parameter_get_string_value (val_param);
195
196                         if (val) {
197                                 sopts->tracking_enabled = TRUE;
198                                 if (!strcmp (val, "Delivered"))
199                                         sopts->track_when = E_GW_DELIVERED;
200                                 if (!strcmp (val, "DeliveredAndOpened"))
201                                         sopts->track_when = E_GW_DELIVERED_OPENED;
202                                 if (!strcmp (val, "Full"))
203                                         sopts->track_when = E_GW_ALL;
204                                 if (!strcmp (val, "None"))
205                                         sopts->tracking_enabled = FALSE;
206                         } else
207                                 sopts->tracking_enabled = FALSE;
208
209                 } else  if (!g_ascii_strcasecmp (field + i, "AutoDelete")) {
210                         if (val_param)
211                                 val = soup_soap_parameter_get_string_value (val_param);
212
213                         if (val) {
214                                 if (!strcmp (val, "1"))
215                                         sopts->autodelete = TRUE;
216                                 else
217                                         sopts->autodelete = FALSE;
218                         } else
219                                 sopts->autodelete = FALSE;
220
221                 } else if (!g_ascii_strcasecmp (field + i, "ReturnOpen")) {
222                         if (val_param)
223                                 val_param = soup_soap_parameter_get_first_child_by_name (val_param, "mail");
224                         if (val_param)
225                                 val = soup_soap_parameter_get_string_value (val_param);
226
227                         if (val && !strcmp (val, "1")) {
228                                 sopts->opened = E_GW_RETURN_NOTIFY_MAIL;
229                         } else
230                                 sopts->opened = E_GW_RETURN_NOTIFY_NONE;
231                         
232
233                 } else if (!g_ascii_strcasecmp (field + i, "ReturnDelete")) {
234                         if (val_param)
235                                 val_param = soup_soap_parameter_get_first_child_by_name (val_param, "mail");
236                         
237                         if (val_param)
238                                 val = soup_soap_parameter_get_string_value (val_param);
239
240                         if (val && !strcmp (val, "1")) {
241                                 sopts->declined = E_GW_RETURN_NOTIFY_MAIL;
242                         } else
243                                 sopts->declined = E_GW_RETURN_NOTIFY_NONE;
244
245                 } else if (!g_ascii_strcasecmp (field + i, "ReturnAccept")) {
246                         if (val_param)
247                                 val_param = soup_soap_parameter_get_first_child_by_name (val_param, "mail");
248                         
249                         if (val_param)
250                                 val = soup_soap_parameter_get_string_value (val_param);
251
252                         if (val && !strcmp (val, "1")) {
253                                 sopts->accepted = E_GW_RETURN_NOTIFY_MAIL;
254                         } else
255                                 sopts->accepted = E_GW_RETURN_NOTIFY_NONE;
256
257
258                 } else if (!g_ascii_strcasecmp (field + i, "ReturnCompleted")) {
259                         if (val_param)
260                                 val_param = soup_soap_parameter_get_first_child_by_name (val_param, "mail");
261                         
262                         if (val_param)
263                                 val = soup_soap_parameter_get_string_value (val_param);
264
265                         if (val && !strcmp (val, "1")) {
266                                 sopts->completed = E_GW_RETURN_NOTIFY_MAIL;
267                         } else
268                                 sopts->completed = E_GW_RETURN_NOTIFY_NONE;
269
270                 }                       
271                 g_free (field);
272                 g_free (val);           
273         }       
274 }
275
276 /* These are not actually general Options. These can be configured seperatly for
277    each component. Since win32 shows them as general options, we too do the same 
278    way. So the Options are take from the mail setttings */
279         
280 static void 
281 parse_general_options (SoupSoapParameter *group_param, EGwSendOptionsGeneral *gopts) 
282 {
283         SoupSoapParameter *subparam, *field_param, *val_param;
284
285         for (subparam = soup_soap_parameter_get_first_child_by_name(group_param, "setting") ;
286                              subparam != NULL ;
287                              subparam = soup_soap_parameter_get_next_child_by_name (subparam, "setting")) {
288                 char *field = NULL, *val = NULL;
289                 field_param = soup_soap_parameter_get_first_child_by_name (subparam, "field");
290                 val_param = soup_soap_parameter_get_first_child_by_name (subparam, "value");
291                 
292                 if (field_param) {
293                         field = soup_soap_parameter_get_string_value (field_param);
294                         if (!field)
295                                 continue;
296                 } else
297                         continue;
298
299                 if (!g_ascii_strcasecmp (field, "mailPriority")) {
300                         if (val_param)
301                                 val = soup_soap_parameter_get_string_value (val_param);
302
303                         if (val) {
304                                 if (!g_ascii_strcasecmp (val, "High"))
305                                         gopts->priority = E_GW_PRIORITY_HIGH;
306                                 else if (!g_ascii_strcasecmp (val, "Standard")) {
307                                         gopts->priority = E_GW_PRIORITY_STANDARD;
308                                 } else if (!g_ascii_strcasecmp (val, "Low"))
309                                         gopts->priority = E_GW_PRIORITY_LOW;
310                                 else
311                                         gopts->priority = E_GW_PRIORITY_UNDEFINED;
312                                         
313                         } else
314                                 gopts->priority = E_GW_PRIORITY_UNDEFINED;
315                 } else if (!g_ascii_strcasecmp (field, "mailReplyRequested")) {
316                        if (val_param)
317                                 val = soup_soap_parameter_get_string_value (val_param);
318
319                         if (val) {
320                                 if (!g_ascii_strcasecmp (val, "None"))
321                                         gopts->reply_enabled = FALSE;
322                                 else if (!g_ascii_strcasecmp (val, "WhenConvenient")) {
323                                         gopts->reply_enabled = TRUE;
324                                         gopts->reply_convenient = TRUE;
325                                 } else {
326                                         char *temp;
327                                         int i = 0;
328                                         
329                                         val_param = soup_soap_parameter_get_first_child_by_name (val_param, "WithinNDays");
330                                         temp = soup_soap_parameter_get_string_value (val_param); 
331                                 
332                                         if (temp)       
333                                                 i = atoi (temp);                                                        
334
335                                         gopts->reply_within = i;
336                                         gopts->reply_enabled = TRUE;            
337                                         g_free (temp);
338                                 }
339                         }
340                 } else if (!g_ascii_strcasecmp (field, "mailExpireDays")) {
341                         if (val_param)
342                                 val = soup_soap_parameter_get_string_value (val_param);
343
344                         if (val) {
345                                 int i = atoi (val);
346                                 if (i != 0)
347                                         gopts->expiration_enabled = TRUE;
348                                 else 
349                                         gopts->expiration_enabled = FALSE;
350
351                                 gopts->expire_after = i;
352                         } else
353                                 gopts->expiration_enabled = FALSE;
354                 }
355                 g_free (field);
356                 g_free (val);
357         }
358 }
359
360 /* These settings are common to all components */
361
362 static void
363 parse_advanced_settings (SoupSoapParameter *group_param, EGwSendOptionsGeneral *gopts) 
364 {
365         SoupSoapParameter *subparam, *field_param, *val_param;
366
367         for (subparam = soup_soap_parameter_get_first_child_by_name(group_param, "setting") ;
368                              subparam != NULL ;
369                              subparam = soup_soap_parameter_get_next_child_by_name (subparam, "setting")) {
370                 char *field = NULL, *val = NULL;
371                 field_param = soup_soap_parameter_get_first_child_by_name (subparam, "field");
372                 val_param = soup_soap_parameter_get_first_child_by_name (subparam, "value");
373                 
374                 if (field_param) {
375                         field = soup_soap_parameter_get_string_value (field_param);
376                         if (!field)
377                                 continue;
378                 } else
379                         continue;
380
381                 if (!g_ascii_strcasecmp (field, "delayDelivery")) {
382                         if (val_param)
383                                 val = soup_soap_parameter_get_string_value (val_param);
384                         if (val) {
385                                 gint i = atoi (val);
386                                 if (i > 0 ) {
387                                         gopts->delay_enabled = TRUE;
388                                         gopts->delay_until = i;
389                                 } else 
390                                         gopts->delay_enabled = FALSE;
391                         } else
392                                 gopts->delay_enabled = FALSE;
393                 }
394         }
395 }
396
397 /* TODO have to handle the locked settings */
398 static gboolean
399 e_gw_sendoptions_store_settings (SoupSoapParameter *param, EGwSendOptions *opts)
400 {
401         SoupSoapParameter *group_param;
402         EGwSendOptionsPrivate *priv;
403
404         priv = opts->priv;
405         
406         for (group_param = soup_soap_parameter_get_first_child_by_name(param, "group") ;
407                              group_param != NULL ;
408                              group_param = soup_soap_parameter_get_next_child_by_name (group_param, "group")) {
409                 char *temp = NULL;
410
411                 temp = soup_soap_parameter_get_property (group_param, "type");
412                 
413                 if (!temp) 
414                         continue;
415
416                 if (!g_ascii_strcasecmp (temp, "MailMessageSettings")) {
417                         parse_status_tracking_options (group_param, 4, priv->mopts);
418                         parse_general_options (group_param, priv->gopts);
419                 }       
420                 
421                 if (!g_ascii_strcasecmp (temp, "AppointmentMessageSettings")) { 
422                         parse_status_tracking_options (group_param, 11, priv->copts);
423                 }
424                 if (!g_ascii_strcasecmp (temp, "TaskMessageSettings")) 
425                         parse_status_tracking_options (group_param, 4, priv->topts);
426
427                 if (!g_ascii_strcasecmp (temp, "AdvancedSettings")) 
428                         parse_advanced_settings (group_param, priv->gopts);
429
430                 g_free (temp);
431         }
432         
433         return TRUE;
434 }
435
436 static void
437 e_gw_sendoptions_write_settings (SoupSoapMessage *msg, char *field_name, char *value, char *value_name, gboolean value_direct)
438 {
439         soup_soap_message_start_element (msg, "setting", NULL, NULL);
440         
441         soup_soap_message_start_element (msg, "field", NULL, NULL);
442         soup_soap_message_write_string (msg, field_name);
443         soup_soap_message_end_element (msg);
444
445         soup_soap_message_start_element (msg, "value", NULL, NULL);
446         
447         if (!value_direct)
448                 e_gw_message_write_string_parameter (msg, value_name, NULL, value);
449         else
450                 soup_soap_message_write_string (msg, value);
451
452         soup_soap_message_end_element (msg);
453         
454         soup_soap_message_end_element (msg);    
455 }       
456
457 static void
458 set_status_tracking_changes (SoupSoapMessage *msg, EGwSendOptionsStatusTracking *n_sopts, EGwSendOptionsStatusTracking *o_sopts, char *comp)
459 {
460         char *value, *comp_name = NULL;
461
462         if (n_sopts->tracking_enabled != o_sopts->tracking_enabled || n_sopts->track_when != o_sopts->track_when) {
463                 if (n_sopts->tracking_enabled) {
464                         if (n_sopts->track_when == E_GW_DELIVERED)
465                                 value = g_strdup ("Delivered");
466                         else if (n_sopts->track_when == E_GW_DELIVERED_OPENED)
467                                 value = g_strdup ("DeliveredAndOpened");
468                         else
469                                 value = g_strdup ("Full");
470                 } else
471                         value = g_strdup ("None");
472                 comp_name = g_strconcat (comp, "StatusInfo", NULL);
473                 e_gw_sendoptions_write_settings (msg, comp_name, value, NULL, TRUE);
474                 g_free (comp_name), comp_name = NULL;
475                 g_free (value), value = NULL;
476         }
477                 
478         if (!strcmp (comp, "mail")) {
479                 if (n_sopts->autodelete != o_sopts->autodelete) {
480                         if (n_sopts->autodelete)
481                                 value = g_strdup ("1");
482                         else
483                                 value = g_strdup ("0");
484                         comp_name = g_strconcat (comp, "AutoDelete", NULL);
485                         e_gw_sendoptions_write_settings (msg, comp_name, value, NULL, TRUE);
486                         g_free (comp_name), comp_name = NULL;
487                         g_free (value), value = NULL;
488                 }
489         }
490
491         if (n_sopts->opened != o_sopts->opened) {
492                 comp_name = g_strconcat (comp, "ReturnOpen", NULL);
493                 if (n_sopts->opened == E_GW_RETURN_NOTIFY_MAIL) {
494                         value = g_strdup ("1");
495                         e_gw_sendoptions_write_settings (msg, comp_name, value, "mail", FALSE);
496                 } else {
497                         value = g_strdup ("None");
498                         e_gw_sendoptions_write_settings (msg, comp_name, value, NULL, TRUE);
499                 }
500
501                 g_free (comp_name), comp_name = NULL;
502                 g_free (value), value = NULL;
503         }
504         
505         if (n_sopts->declined != o_sopts->declined) {
506                 comp_name = g_strconcat (comp, "ReturnDelete", NULL);
507                 if (n_sopts->declined == E_GW_RETURN_NOTIFY_MAIL) {
508                         value = g_strdup ("1");
509                         e_gw_sendoptions_write_settings (msg, comp_name, value, "mail", FALSE);
510                 } else {
511                         value = g_strdup ("None");
512                         e_gw_sendoptions_write_settings (msg, comp_name, value, NULL, TRUE);
513                 }
514
515                 g_free (comp_name), comp_name = NULL;
516                 g_free (value), value = NULL;
517         }
518         
519         if (!strcmp (comp, "appointment") || !strcmp (comp, "task")) {
520                 if (n_sopts->accepted != o_sopts->accepted) {
521                         comp_name = g_strconcat (comp, "ReturnAccept", NULL);
522                         if (n_sopts->accepted == E_GW_RETURN_NOTIFY_MAIL) {
523                                 value = g_strdup ("1");
524                                 e_gw_sendoptions_write_settings (msg, comp_name, value, "mail", FALSE);
525                         } else {
526                                 value = g_strdup ("None");
527                                 e_gw_sendoptions_write_settings (msg, comp_name, value, NULL, TRUE);
528                         }
529         
530                         g_free (comp_name), comp_name = NULL;
531                         g_free (value), value = NULL;
532                 }
533         }
534         
535         if (!strcmp (comp, "task")) {
536                 if (n_sopts->completed != o_sopts->completed) {
537                         comp_name = g_strconcat (comp, "ReturnCompleted", NULL);
538                         if (n_sopts->completed == E_GW_RETURN_NOTIFY_MAIL) {
539                                 value = g_strdup ("1");
540                                 e_gw_sendoptions_write_settings (msg, comp_name, value, "mail", FALSE);
541                         } else {
542                                 value = g_strdup ("None");
543                                 e_gw_sendoptions_write_settings (msg, comp_name, value, NULL, TRUE);
544                         }
545         
546                         g_free (comp_name), comp_name = NULL;
547                         g_free (value), value = NULL;
548                 }
549         }
550
551 }
552
553 static void
554 set_general_options_changes (SoupSoapMessage *msg, EGwSendOptionsGeneral *n_gopts, EGwSendOptionsGeneral *o_gopts)
555 {
556         char *value;
557
558         if (n_gopts->priority != o_gopts->priority) {
559                 if (n_gopts->priority == E_GW_PRIORITY_HIGH)
560                         value = g_strdup ("High");
561                 else if (n_gopts->priority == E_GW_PRIORITY_STANDARD)
562                         value = g_strdup ("Standard");
563                 else if (n_gopts->priority == E_GW_PRIORITY_LOW)
564                         value = g_strdup ("Low");
565                 else 
566                         value = NULL;
567                 e_gw_sendoptions_write_settings (msg, "mailPriority", value, NULL, TRUE);
568                 e_gw_sendoptions_write_settings (msg, "appointmentPriority", value, NULL, TRUE);
569                 e_gw_sendoptions_write_settings (msg, "taskPriority", value, NULL, TRUE);
570                 g_free (value), value = NULL;
571         }
572
573         if (n_gopts->reply_enabled != o_gopts->reply_enabled || n_gopts->reply_convenient != o_gopts->reply_convenient ||
574                         n_gopts->reply_within != o_gopts->reply_within) {
575                 
576                 if (n_gopts->reply_enabled) {
577                         if (n_gopts->reply_convenient)
578                                 value = g_strdup ("WhenConvenient");
579                         else 
580                                 value = g_strdup_printf ("%d", n_gopts->reply_within);  
581                 } else 
582                         value = g_strdup ("None");
583                 
584                 if (n_gopts->reply_enabled && !n_gopts->reply_convenient)
585                         e_gw_sendoptions_write_settings (msg, "mailReplyRequested", value, "WithinNDays" , FALSE);
586                 else
587                         e_gw_sendoptions_write_settings (msg, "mailReplyRequested", value, NULL, TRUE);
588
589                 g_free (value), value = NULL;
590         }
591
592         if (n_gopts->expiration_enabled != o_gopts->expiration_enabled || n_gopts->expire_after != o_gopts->expire_after) {
593                 if (n_gopts->expiration_enabled) {
594                         value = g_strdup_printf ("%d", n_gopts->expire_after);
595                 } else
596                         value = g_strdup ("0");
597                 
598                 e_gw_sendoptions_write_settings (msg, "mailExpireDays", value, NULL, TRUE);
599                 g_free (value), value = NULL;
600         }
601
602         if (n_gopts->delay_enabled != o_gopts->delay_enabled || n_gopts->delay_until != o_gopts->delay_until) {
603                 if (n_gopts->delay_enabled) {
604                         value = g_strdup_printf ("%d", n_gopts->delay_until);
605                 } else
606                         value = g_strdup ("-1");
607                 
608                 e_gw_sendoptions_write_settings (msg, "delayDelivery", value, NULL, TRUE);
609                 g_free (value), value = NULL;
610         }
611 }
612
613 /* n_opts has the new options, o_opts has the old options settings */
614 gboolean 
615 e_gw_sendoptions_form_message_to_modify (SoupSoapMessage *msg, EGwSendOptions *n_opts, EGwSendOptions *o_opts)
616 {
617         g_return_val_if_fail (n_opts != NULL || o_opts != NULL, FALSE);
618         g_return_val_if_fail (E_IS_GW_SENDOPTIONS (n_opts) || E_IS_GW_SENDOPTIONS (o_opts), FALSE);
619
620         soup_soap_message_start_element (msg, "settings", NULL, NULL);
621
622         set_general_options_changes (msg, n_opts->priv->gopts, o_opts->priv->gopts);
623         set_status_tracking_changes (msg, n_opts->priv->mopts, o_opts->priv->mopts, "mail");
624         set_status_tracking_changes (msg, n_opts->priv->copts, o_opts->priv->copts, "appointment");
625         set_status_tracking_changes (msg, n_opts->priv->topts, o_opts->priv->topts, "task");
626         
627         soup_soap_message_end_element (msg);
628
629         return TRUE;
630 }
631
632 EGwSendOptions *
633 e_gw_sendoptions_new (void)
634 {
635         EGwSendOptions *opts;
636
637         opts = g_object_new (E_TYPE_GW_SENDOPTIONS, NULL);
638
639         return opts;
640 }
641
642 EGwSendOptions *
643 e_gw_sendoptions_new_from_soap_parameter (SoupSoapParameter *param) 
644 {
645         EGwSendOptions *opts;
646         
647         g_return_val_if_fail (param != NULL, NULL);
648
649         opts = g_object_new (E_TYPE_GW_SENDOPTIONS, NULL);
650
651         if (!e_gw_sendoptions_store_settings (param, opts)){
652                 g_object_unref (opts);
653                 return NULL;
654         }
655         
656         return opts;
657 }
658
659