1 /*
2  * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
3  * Copyright (C) 2019 Red Hat, Inc. (www.redhat.com)
4  *
5  * This library is free software: you can redistribute it and/or modify it
6  * under the terms of the GNU Lesser General Public License as published by
7  * the Free Software Foundation.
8  *
9  * This library is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
12  * for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this library. If not, see <http://www.gnu.org/licenses/>.
16  *
17  */
18 
19 #include "evolution-data-server-config.h"
20 
21 /**
22  * SECTION:e-cal-component-attendee
23  * @short_description: An ECalComponentAttendee structure
24  * @include: libecal/libecal.h
25  *
26  * Contains functions to work with the #ECalComponentAttendee structure.
27  **/
28 
29 #include "e-cal-component-parameter-bag.h"
30 
31 #include "e-cal-component-attendee.h"
32 
33 G_DEFINE_BOXED_TYPE (ECalComponentAttendee, e_cal_component_attendee, e_cal_component_attendee_copy, e_cal_component_attendee_free)
34 
35 struct _ECalComponentAttendee {
36 	gchar *value;
37 
38 	gchar *member;
39 	ICalParameterCutype cutype;
40 	ICalParameterRole role;
41 	ICalParameterPartstat partstat;
42 	gboolean rsvp;
43 
44 	gchar *delegatedfrom;
45 	gchar *delegatedto;
46 	gchar *sentby;
47 	gchar *cn;
48 	gchar *language;
49 
50 	ECalComponentParameterBag *parameter_bag;
51 };
52 
53 /**
54  * e_cal_component_attendee_new:
55  *
56  * Creates a new empty #ECalComponentAttendee structure. Free it
57  * with e_cal_component_attendee_free(), when no longer needed.
58  *
59  * Returns: (transfer full): a newly allocated #ECalComponentAttendee
60  *
61  * Since: 3.34
62  **/
63 ECalComponentAttendee *
e_cal_component_attendee_new(void)64 e_cal_component_attendee_new (void)
65 {
66 	ECalComponentAttendee *attendee;
67 
68 	attendee = g_slice_new0 (ECalComponentAttendee);
69 	attendee->cutype = I_CAL_CUTYPE_NONE;
70 	attendee->role = I_CAL_ROLE_REQPARTICIPANT;
71 	attendee->partstat = I_CAL_PARTSTAT_NEEDSACTION;
72 	attendee->parameter_bag = e_cal_component_parameter_bag_new ();
73 
74 	return attendee;
75 }
76 
77 /**
78  * e_cal_component_attendee_new_full:
79  * @value: (nullable): usually a "mailto:email" of the attendee
80  * @member: (nullable): member parameter
81  * @cutype: type of the attendee, an #ICalParameterCutype
82  * @role: role of the attendee, an #ICalParameterRole
83  * @partstat: current status of the attendee, an #ICalParameterPartstat
84  * @rsvp: whether requires RSVP
85  * @delegatedfrom: (nullable): delegated from
86  * @delegatedto: (nullable): delegated to
87  * @sentby: (nullable): sent by
88  * @cn: (nullable): common name
89  * @language: (nullable): language
90  *
91  * Creates a new #ECalComponentAttendee structure, with all members filled
92  * with given values from the parameters. The %NULL and empty strings are
93  * treated as unset the value. Free the structure
94  * with e_cal_component_attendee_free(), when no longer needed.
95  *
96  * Returns: (transfer full): a newly allocated #ECalComponentAttendee
97  *
98  * Since: 3.34
99  **/
100 ECalComponentAttendee *
e_cal_component_attendee_new_full(const gchar * value,const gchar * member,ICalParameterCutype cutype,ICalParameterRole role,ICalParameterPartstat partstat,gboolean rsvp,const gchar * delegatedfrom,const gchar * delegatedto,const gchar * sentby,const gchar * cn,const gchar * language)101 e_cal_component_attendee_new_full (const gchar *value,
102 				   const gchar *member,
103 				   ICalParameterCutype cutype,
104 				   ICalParameterRole role,
105 				   ICalParameterPartstat partstat,
106 				   gboolean rsvp,
107 				   const gchar *delegatedfrom,
108 				   const gchar *delegatedto,
109 				   const gchar *sentby,
110 				   const gchar *cn,
111 				   const gchar *language)
112 {
113 	ECalComponentAttendee *attendee;
114 
115 	attendee = e_cal_component_attendee_new ();
116 	attendee->value = value && *value ? g_strdup (value) : NULL;
117 	attendee->member = member && *member ? g_strdup (member) : NULL;
118 	attendee->cutype = cutype;
119 	attendee->role = role;
120 	attendee->partstat = partstat;
121 	attendee->rsvp = rsvp;
122 	attendee->delegatedfrom = delegatedfrom && *delegatedfrom ? g_strdup (delegatedfrom) : NULL;
123 	attendee->delegatedto = delegatedto && *delegatedto ? g_strdup (delegatedto) : NULL;
124 	attendee->sentby = sentby && *sentby ? g_strdup (sentby) : NULL;
125 	attendee->cn = cn && *cn ? g_strdup (cn) : NULL;
126 	attendee->language = language && *language ? g_strdup (language) : NULL;
127 
128 	return attendee;
129 }
130 
131 /**
132  * e_cal_component_attendee_new_from_property:
133  * @property: an #ICalProperty of kind %I_CAL_ATTENDEE_PROPERTY
134  *
135  * Creates a new #ECalComponentAttendee, filled with values from @property,
136  * which should be of kind %I_CAL_ATTENDEE_PROPERTY. The function returns
137  * %NULL when it is not of the expected kind. Free the structure
138  * with e_cal_component_attendee_free(), when no longer needed.
139  *
140  * Returns: (transfer full) (nullable): a newly allocated #ECalComponentAttendee
141  *
142  * Since: 3.34
143  **/
144 ECalComponentAttendee *
e_cal_component_attendee_new_from_property(const ICalProperty * property)145 e_cal_component_attendee_new_from_property (const ICalProperty *property)
146 {
147 	ECalComponentAttendee *attendee;
148 
149 	g_return_val_if_fail (I_CAL_IS_PROPERTY ((ICalProperty *) property), NULL);
150 
151 	if (i_cal_property_isa ((ICalProperty *) property) != I_CAL_ATTENDEE_PROPERTY)
152 		return NULL;
153 
154 	attendee = e_cal_component_attendee_new ();
155 
156 	e_cal_component_attendee_set_from_property (attendee, property);
157 
158 	return attendee;
159 }
160 
161 /**
162  * e_cal_component_attendee_copy:
163  * @attendee: (not nullable): an #ECalComponentAttendee
164  *
165  * Returns a newly allocated copy of @attendee, which should be freed with
166  * e_cal_component_attendee_free(), when no longer needed.
167  *
168  * Returns: (transfer full): a newly allocated copy of @attendee
169  *
170  * Since: 3.34
171  **/
172 ECalComponentAttendee *
e_cal_component_attendee_copy(const ECalComponentAttendee * attendee)173 e_cal_component_attendee_copy (const ECalComponentAttendee *attendee)
174 {
175 	ECalComponentAttendee *copy;
176 
177 	g_return_val_if_fail (attendee != NULL, NULL);
178 
179 	copy = e_cal_component_attendee_new_full (attendee->value,
180 		attendee->member,
181 		attendee->cutype,
182 		attendee->role,
183 		attendee->partstat,
184 		attendee->rsvp,
185 		attendee->delegatedfrom,
186 		attendee->delegatedto,
187 		attendee->sentby,
188 		attendee->cn,
189 		attendee->language);
190 
191 	e_cal_component_parameter_bag_assign (copy->parameter_bag, attendee->parameter_bag);
192 
193 	return copy;
194 }
195 
196 /**
197  * e_cal_component_attendee_free: (skip)
198  * @attendee: (type ECalComponentAttendee) (nullable): an #ECalComponentAttendee to free
199  *
200  * Free @attendee, previously created by e_cal_component_attendee_new(),
201  * e_cal_component_attendee_new_full(), e_cal_component_attendee_new_from_property()
202  * or e_cal_component_attendee_copy(). The function does nothing, if @attendee
203  * is %NULL.
204  *
205  * Since: 3.34
206  **/
207 void
e_cal_component_attendee_free(gpointer attendee)208 e_cal_component_attendee_free (gpointer attendee)
209 {
210 	ECalComponentAttendee *att = attendee;
211 
212 	if (att) {
213 		e_cal_component_parameter_bag_free (att->parameter_bag);
214 		g_free (att->value);
215 		g_free (att->member);
216 		g_free (att->delegatedfrom);
217 		g_free (att->delegatedto);
218 		g_free (att->sentby);
219 		g_free (att->cn);
220 		g_free (att->language);
221 		g_slice_free (ECalComponentAttendee, att);
222 	}
223 }
224 
225 static gboolean
e_cal_component_attendee_filter_params_cb(ICalParameter * param,gpointer user_data)226 e_cal_component_attendee_filter_params_cb (ICalParameter *param,
227 					   gpointer user_data)
228 {
229 	ICalParameterKind kind;
230 
231 	kind = i_cal_parameter_isa (param);
232 
233 	return kind != I_CAL_MEMBER_PARAMETER &&
234 	       kind != I_CAL_CUTYPE_PARAMETER &&
235 	       kind != I_CAL_ROLE_PARAMETER &&
236 	       kind != I_CAL_PARTSTAT_PARAMETER &&
237 	       kind != I_CAL_RSVP_PARAMETER &&
238 	       kind != I_CAL_DELEGATEDFROM_PARAMETER &&
239 	       kind != I_CAL_DELEGATEDTO_PARAMETER &&
240 	       kind != I_CAL_SENTBY_PARAMETER &&
241 	       kind != I_CAL_CN_PARAMETER &&
242 	       kind != I_CAL_LANGUAGE_PARAMETER;
243 }
244 
245 /**
246  * e_cal_component_attendee_set_from_property:
247  * @attendee: an #ECalComponentAttendee
248  * @property: an #ICalProperty
249  *
250  * Fill the @attendee structure with the information from
251  * the @property, which should be of %I_CAL_ATTENDEE_PROPERTY kind.
252  *
253  * Since: 3.34
254  **/
255 void
e_cal_component_attendee_set_from_property(ECalComponentAttendee * attendee,const ICalProperty * property)256 e_cal_component_attendee_set_from_property (ECalComponentAttendee *attendee,
257 					    const ICalProperty *property)
258 {
259 	ICalProperty *prop = (ICalProperty *) property;
260 	ICalParameter *param;
261 
262 	g_return_if_fail (attendee != NULL);
263 	g_return_if_fail (I_CAL_IS_PROPERTY ((ICalProperty *) property));
264 	g_return_if_fail (i_cal_property_isa (prop) == I_CAL_ATTENDEE_PROPERTY);
265 
266 	e_cal_component_attendee_set_value (attendee, i_cal_property_get_attendee (prop));
267 
268 	param = i_cal_property_get_first_parameter (prop, I_CAL_MEMBER_PARAMETER);
269 	e_cal_component_attendee_set_member (attendee, param ? i_cal_parameter_get_member (param) : NULL);
270 	g_clear_object (&param);
271 
272 	param = i_cal_property_get_first_parameter (prop, I_CAL_CUTYPE_PARAMETER);
273 	e_cal_component_attendee_set_cutype (attendee, param ? i_cal_parameter_get_cutype (param) : I_CAL_CUTYPE_NONE);
274 	g_clear_object (&param);
275 
276 	param = i_cal_property_get_first_parameter (prop, I_CAL_ROLE_PARAMETER);
277 	e_cal_component_attendee_set_role (attendee, param ? i_cal_parameter_get_role (param) : I_CAL_ROLE_REQPARTICIPANT);
278 	g_clear_object (&param);
279 
280 	param = i_cal_property_get_first_parameter (prop, I_CAL_PARTSTAT_PARAMETER);
281 	e_cal_component_attendee_set_partstat (attendee, param ? i_cal_parameter_get_partstat (param) : I_CAL_PARTSTAT_NEEDSACTION);
282 	g_clear_object (&param);
283 
284 	param = i_cal_property_get_first_parameter (prop, I_CAL_RSVP_PARAMETER);
285 	e_cal_component_attendee_set_rsvp (attendee, param && i_cal_parameter_get_rsvp (param) == I_CAL_RSVP_TRUE);
286 	g_clear_object (&param);
287 
288 	param = i_cal_property_get_first_parameter (prop, I_CAL_DELEGATEDFROM_PARAMETER);
289 	e_cal_component_attendee_set_delegatedfrom (attendee, param ? i_cal_parameter_get_delegatedfrom (param) : NULL);
290 	g_clear_object (&param);
291 
292 	param = i_cal_property_get_first_parameter (prop, I_CAL_DELEGATEDTO_PARAMETER);
293 	e_cal_component_attendee_set_delegatedto (attendee, param ? i_cal_parameter_get_delegatedto (param) : NULL);
294 	g_clear_object (&param);
295 
296 	param = i_cal_property_get_first_parameter (prop, I_CAL_SENTBY_PARAMETER);
297 	e_cal_component_attendee_set_sentby (attendee, param ? i_cal_parameter_get_sentby (param) : NULL);
298 	g_clear_object (&param);
299 
300 	param = i_cal_property_get_first_parameter (prop, I_CAL_CN_PARAMETER);
301 	e_cal_component_attendee_set_cn (attendee, param ? i_cal_parameter_get_cn (param) : NULL);
302 	g_clear_object (&param);
303 
304 	param = i_cal_property_get_first_parameter (prop, I_CAL_LANGUAGE_PARAMETER);
305 	e_cal_component_attendee_set_language (attendee, param ? i_cal_parameter_get_language (param) : NULL);
306 	g_clear_object (&param);
307 
308 	e_cal_component_parameter_bag_set_from_property (attendee->parameter_bag, prop, e_cal_component_attendee_filter_params_cb, NULL);
309 }
310 
311 /**
312  * e_cal_component_attendee_get_as_property:
313  * @attendee: an #ECalComponentAttendee
314  *
315  * Converts information stored in @attendee into an #ICalProperty
316  * of %I_CAL_ATTENDEE_PROPERTY kind. The caller is responsible to free
317  * the returned object with g_object_unref(), when no longer needed.
318  *
319  * Returns: (transfer full): a newly created #ICalProperty, containing
320  *    information from the @attendee.
321  *
322  * Since: 3.34
323  **/
324 ICalProperty *
e_cal_component_attendee_get_as_property(const ECalComponentAttendee * attendee)325 e_cal_component_attendee_get_as_property (const ECalComponentAttendee *attendee)
326 {
327 	ICalProperty *prop;
328 
329 	g_return_val_if_fail (attendee != NULL, NULL);
330 
331 	prop = i_cal_property_new (I_CAL_ATTENDEE_PROPERTY);
332 	g_return_val_if_fail (prop != NULL, NULL);
333 
334 	e_cal_component_attendee_fill_property (attendee, prop);
335 
336 	return prop;
337 }
338 
339 /**
340  * e_cal_component_attendee_fill_property:
341  * @attendee: an #ECalComponentAttendee
342  * @property: (inout) (not nullable): an #ICalProperty
343  *
344  * Fill @property with information from @attendee. The @property
345  * should be of kind %I_CAL_ATTENDEE_PROPERTY.
346  *
347  * Since: 3.34
348  **/
349 void
e_cal_component_attendee_fill_property(const ECalComponentAttendee * attendee,ICalProperty * property)350 e_cal_component_attendee_fill_property (const ECalComponentAttendee *attendee,
351 					ICalProperty *property)
352 {
353 	ICalParameter *param;
354 
355 	g_return_if_fail (attendee != NULL);
356 	g_return_if_fail (I_CAL_IS_PROPERTY (property));
357 	g_return_if_fail (i_cal_property_isa (property) == I_CAL_ATTENDEE_PROPERTY);
358 
359 	i_cal_property_set_attendee (property, attendee->value ? attendee->value : "mailto:");
360 
361 	#define fill_param(_param, _val, _filled) \
362 		param = i_cal_property_get_first_parameter (property, _param); \
363 		if (_filled) { \
364 			if (!param) { \
365 				param = i_cal_parameter_new (_param); \
366 				i_cal_property_add_parameter (property, param); \
367 			} \
368 			i_cal_parameter_set_ ## _val (param, attendee-> _val); \
369 			g_clear_object (&param); \
370 		} else if (param) { \
371 			i_cal_property_remove_parameter_by_kind (property, _param); \
372 			g_clear_object (&param); \
373 		}
374 
375 	fill_param (I_CAL_MEMBER_PARAMETER, member, attendee->member && *attendee->member);
376 	fill_param (I_CAL_CUTYPE_PARAMETER, cutype, attendee->cutype != I_CAL_CUTYPE_NONE);
377 	fill_param (I_CAL_ROLE_PARAMETER, role, attendee->role != I_CAL_ROLE_NONE);
378 	fill_param (I_CAL_PARTSTAT_PARAMETER, partstat, attendee->partstat != I_CAL_PARTSTAT_NONE);
379 
380 	param = i_cal_property_get_first_parameter (property, I_CAL_RSVP_PARAMETER);
381 	if (param) {
382 		i_cal_parameter_set_rsvp (param, attendee->rsvp ? I_CAL_RSVP_TRUE : I_CAL_RSVP_FALSE);
383 		g_clear_object (&param);
384 	} else {
385 		param = i_cal_parameter_new (I_CAL_RSVP_PARAMETER);
386 		i_cal_parameter_set_rsvp (param, attendee->rsvp ? I_CAL_RSVP_TRUE : I_CAL_RSVP_FALSE);
387 		i_cal_property_take_parameter (property, param);
388 	}
389 
390 	fill_param (I_CAL_DELEGATEDFROM_PARAMETER, delegatedfrom, attendee->delegatedfrom && *attendee->delegatedfrom);
391 	fill_param (I_CAL_DELEGATEDTO_PARAMETER, delegatedto, attendee->delegatedto && *attendee->delegatedto);
392 	fill_param (I_CAL_SENTBY_PARAMETER, sentby, attendee->sentby && *attendee->sentby);
393 	fill_param (I_CAL_CN_PARAMETER, cn, attendee->cn && *attendee->cn);
394 	fill_param (I_CAL_LANGUAGE_PARAMETER, language, attendee->language && *attendee->language);
395 
396 	#undef fill_param
397 
398 	e_cal_component_parameter_bag_fill_property (attendee->parameter_bag, property);
399 }
400 
401 /**
402  * e_cal_component_attendee_get_value:
403  * @attendee: an #ECalComponentAttendee
404  *
405  * Returns: (nullable): the @attendee URI, usually of "mailto:email" form
406  *
407  * Since: 3.34
408  **/
409 const gchar *
e_cal_component_attendee_get_value(const ECalComponentAttendee * attendee)410 e_cal_component_attendee_get_value (const ECalComponentAttendee *attendee)
411 {
412 	g_return_val_if_fail (attendee != NULL, NULL);
413 
414 	return attendee->value;
415 }
416 
417 /**
418  * e_cal_component_attendee_set_value:
419  * @attendee: an #ECalComponentAttendee
420  * @value: (nullable): the value to set
421  *
422  * Set the @attendee URI, usually of "mailto:email" form. The %NULL
423  * and empty strings are treated as unset the value.
424  *
425  * Since: 3.34
426  **/
427 void
e_cal_component_attendee_set_value(ECalComponentAttendee * attendee,const gchar * value)428 e_cal_component_attendee_set_value (ECalComponentAttendee *attendee,
429 				    const gchar *value)
430 {
431 	g_return_if_fail (attendee != NULL);
432 
433 	if (value && !*value)
434 		value = NULL;
435 
436 	if (g_strcmp0 (attendee->value, value) != 0) {
437 		g_free (attendee->value);
438 		attendee->value = g_strdup (value);
439 	}
440 }
441 
442 /**
443  * e_cal_component_attendee_get_member:
444  * @attendee: an #ECalComponentAttendee
445  *
446  * Returns: (nullable): the @attendee member property
447  *
448  * Since: 3.34
449  **/
450 const gchar *
e_cal_component_attendee_get_member(const ECalComponentAttendee * attendee)451 e_cal_component_attendee_get_member (const ECalComponentAttendee *attendee)
452 {
453 	g_return_val_if_fail (attendee != NULL, NULL);
454 
455 	return attendee->member;
456 }
457 
458 /**
459  * e_cal_component_attendee_set_member:
460  * @attendee: an #ECalComponentAttendee
461  * @member: (nullable): the value to set
462  *
463  * Set the @attendee member parameter. The %NULL
464  * and empty strings are treated as unset the value.
465  *
466  * Since: 3.34
467  **/
468 void
e_cal_component_attendee_set_member(ECalComponentAttendee * attendee,const gchar * member)469 e_cal_component_attendee_set_member (ECalComponentAttendee *attendee,
470 				     const gchar *member)
471 {
472 	g_return_if_fail (attendee != NULL);
473 
474 	if (member && !*member)
475 		member = NULL;
476 
477 	if (g_strcmp0 (attendee->member, member) != 0) {
478 		g_free (attendee->member);
479 		attendee->member = g_strdup (member);
480 	}
481 }
482 
483 /**
484  * e_cal_component_attendee_get_cutype:
485  * @attendee: an #ECalComponentAttendee
486  *
487  * Returns: the @attendee type, as an #ICalParameterCutype
488  *
489  * Since: 3.34
490  **/
491 ICalParameterCutype
e_cal_component_attendee_get_cutype(const ECalComponentAttendee * attendee)492 e_cal_component_attendee_get_cutype (const ECalComponentAttendee *attendee)
493 {
494 	g_return_val_if_fail (attendee != NULL, I_CAL_CUTYPE_NONE);
495 
496 	return attendee->cutype;
497 }
498 
499 /**
500  * e_cal_component_attendee_set_cutype:
501  * @attendee: an #ECalComponentAttendee
502  * @cutype: the value to set, as an #ICalParameterCutype
503  *
504  * Set the @attendee type, as an #ICalParameterCutype.
505  *
506  * Since: 3.34
507  **/
508 void
e_cal_component_attendee_set_cutype(ECalComponentAttendee * attendee,ICalParameterCutype cutype)509 e_cal_component_attendee_set_cutype (ECalComponentAttendee *attendee,
510 				     ICalParameterCutype cutype)
511 {
512 	g_return_if_fail (attendee != NULL);
513 
514 	if (attendee->cutype != cutype) {
515 		attendee->cutype = cutype;
516 	}
517 }
518 
519 /**
520  * e_cal_component_attendee_get_role:
521  * @attendee: an #ECalComponentAttendee
522  *
523  * Returns: the @attendee role, as an #ICalParameterRole
524  *
525  * Since: 3.34
526  **/
527 ICalParameterRole
e_cal_component_attendee_get_role(const ECalComponentAttendee * attendee)528 e_cal_component_attendee_get_role (const ECalComponentAttendee *attendee)
529 {
530 	g_return_val_if_fail (attendee != NULL, I_CAL_ROLE_NONE);
531 
532 	return attendee->role;
533 }
534 
535 /**
536  * e_cal_component_attendee_set_role:
537  * @attendee: an #ECalComponentAttendee
538  * @role: the value to set, as an #ICalParameterRole
539  *
540  * Set the @attendee role, as an #ICalParameterRole.
541  *
542  * Since: 3.34
543  **/
544 void
e_cal_component_attendee_set_role(ECalComponentAttendee * attendee,ICalParameterRole role)545 e_cal_component_attendee_set_role (ECalComponentAttendee *attendee,
546 				   ICalParameterRole role)
547 {
548 	g_return_if_fail (attendee != NULL);
549 
550 	if (attendee->role != role) {
551 		attendee->role = role;
552 	}
553 }
554 
555 /**
556  * e_cal_component_attendee_get_partstat:
557  * @attendee: an #ECalComponentAttendee
558  *
559  * Returns: the @attendee status, as an #ICalParameterPartstat
560  *
561  * Since: 3.34
562  **/
563 ICalParameterPartstat
e_cal_component_attendee_get_partstat(const ECalComponentAttendee * attendee)564 e_cal_component_attendee_get_partstat (const ECalComponentAttendee *attendee)
565 {
566 	g_return_val_if_fail (attendee != NULL, I_CAL_PARTSTAT_NONE);
567 
568 	return attendee->partstat;
569 }
570 
571 /**
572  * e_cal_component_attendee_set_partstat:
573  * @attendee: an #ECalComponentAttendee
574  * @partstat: the value to set, as an #ICalParameterPartstat
575  *
576  * Set the @attendee status, as an #ICalParameterPartstat.
577  *
578  * Since: 3.34
579  **/
580 void
e_cal_component_attendee_set_partstat(ECalComponentAttendee * attendee,ICalParameterPartstat partstat)581 e_cal_component_attendee_set_partstat (ECalComponentAttendee *attendee,
582 				       ICalParameterPartstat partstat)
583 {
584 	g_return_if_fail (attendee != NULL);
585 
586 	if (attendee->partstat != partstat) {
587 		attendee->partstat = partstat;
588 	}
589 }
590 
591 /**
592  * e_cal_component_attendee_get_rsvp:
593  * @attendee: an #ECalComponentAttendee
594  *
595  * Returns: whether the @attendee requires RSVP
596  *
597  * Since: 3.34
598  **/
599 gboolean
e_cal_component_attendee_get_rsvp(const ECalComponentAttendee * attendee)600 e_cal_component_attendee_get_rsvp (const ECalComponentAttendee *attendee)
601 {
602 	g_return_val_if_fail (attendee != NULL, FALSE);
603 
604 	return attendee->rsvp;
605 }
606 
607 /**
608  * e_cal_component_attendee_set_rsvp:
609  * @attendee: an #ECalComponentAttendee
610  * @rsvp: the value to set
611  *
612  * Set the @attendee RSVP.
613  *
614  * Since: 3.34
615  **/
616 void
e_cal_component_attendee_set_rsvp(ECalComponentAttendee * attendee,gboolean rsvp)617 e_cal_component_attendee_set_rsvp (ECalComponentAttendee *attendee,
618 				   gboolean rsvp)
619 {
620 	g_return_if_fail (attendee != NULL);
621 
622 	if ((attendee->rsvp ? 1 : 0) != (rsvp ? 1 : 0)) {
623 		attendee->rsvp = rsvp;
624 	}
625 }
626 
627 /**
628  * e_cal_component_attendee_get_delegatedfrom:
629  * @attendee: an #ECalComponentAttendee
630  *
631  * Returns: (nullable): the @attendee delegatedfrom parameter
632  *
633  * Since: 3.34
634  **/
635 const gchar *
e_cal_component_attendee_get_delegatedfrom(const ECalComponentAttendee * attendee)636 e_cal_component_attendee_get_delegatedfrom (const ECalComponentAttendee *attendee)
637 {
638 	g_return_val_if_fail (attendee != NULL, NULL);
639 
640 	return attendee->delegatedfrom;
641 }
642 
643 /**
644  * e_cal_component_attendee_set_delegatedfrom:
645  * @attendee: an #ECalComponentAttendee
646  * @delegatedfrom: (nullable): the value to set
647  *
648  * Set the @attendee delegatedfrom parameter. The %NULL
649  * and empty strings are treated as unset the value.
650  *
651  * Since: 3.34
652  **/
653 void
e_cal_component_attendee_set_delegatedfrom(ECalComponentAttendee * attendee,const gchar * delegatedfrom)654 e_cal_component_attendee_set_delegatedfrom (ECalComponentAttendee *attendee,
655 					    const gchar *delegatedfrom)
656 {
657 	g_return_if_fail (attendee != NULL);
658 
659 	if (delegatedfrom && !*delegatedfrom)
660 		delegatedfrom = NULL;
661 
662 	if (g_strcmp0 (attendee->delegatedfrom, delegatedfrom) != 0) {
663 		g_free (attendee->delegatedfrom);
664 		attendee->delegatedfrom = g_strdup (delegatedfrom);
665 	}
666 }
667 
668 /**
669  * e_cal_component_attendee_get_delegatedto:
670  * @attendee: an #ECalComponentAttendee
671  *
672  * Returns: (nullable): the @attendee delegatedto parameter
673  *
674  * Since: 3.34
675  **/
676 const gchar *
e_cal_component_attendee_get_delegatedto(const ECalComponentAttendee * attendee)677 e_cal_component_attendee_get_delegatedto (const ECalComponentAttendee *attendee)
678 {
679 	g_return_val_if_fail (attendee != NULL, NULL);
680 
681 	return attendee->delegatedto;
682 }
683 
684 /**
685  * e_cal_component_attendee_set_delegatedto:
686  * @attendee: an #ECalComponentAttendee
687  * @delegatedto: (nullable): the value to set
688  *
689  * Set the @attendee delegatedto parameter. The %NULL
690  * and empty strings are treated as unset the value.
691  *
692  * Since: 3.34
693  **/
694 void
e_cal_component_attendee_set_delegatedto(ECalComponentAttendee * attendee,const gchar * delegatedto)695 e_cal_component_attendee_set_delegatedto (ECalComponentAttendee *attendee,
696 					  const gchar *delegatedto)
697 {
698 	g_return_if_fail (attendee != NULL);
699 
700 	if (delegatedto && !*delegatedto)
701 		delegatedto = NULL;
702 
703 	if (g_strcmp0 (attendee->delegatedto, delegatedto) != 0) {
704 		g_free (attendee->delegatedto);
705 		attendee->delegatedto = g_strdup (delegatedto);
706 	}
707 }
708 
709 /**
710  * e_cal_component_attendee_get_sentby:
711  * @attendee: an #ECalComponentAttendee
712  *
713  * Returns: (nullable): the @attendee sentby parameter
714  *
715  * Since: 3.34
716  **/
717 const gchar *
e_cal_component_attendee_get_sentby(const ECalComponentAttendee * attendee)718 e_cal_component_attendee_get_sentby (const ECalComponentAttendee *attendee)
719 {
720 	g_return_val_if_fail (attendee != NULL, NULL);
721 
722 	return attendee->sentby;
723 }
724 
725 /**
726  * e_cal_component_attendee_set_sentby:
727  * @attendee: an #ECalComponentAttendee
728  * @sentby: (nullable): the value to set
729  *
730  * Set the @attendee sentby parameter. The %NULL
731  * and empty strings are treated as unset the value.
732  *
733  * Since: 3.34
734  **/
735 void
e_cal_component_attendee_set_sentby(ECalComponentAttendee * attendee,const gchar * sentby)736 e_cal_component_attendee_set_sentby (ECalComponentAttendee *attendee,
737 				     const gchar *sentby)
738 {
739 	g_return_if_fail (attendee != NULL);
740 
741 	if (sentby && !*sentby)
742 		sentby = NULL;
743 
744 	if (g_strcmp0 (attendee->sentby, sentby) != 0) {
745 		g_free (attendee->sentby);
746 		attendee->sentby = g_strdup (sentby);
747 	}
748 }
749 
750 /**
751  * e_cal_component_attendee_get_cn:
752  * @attendee: an #ECalComponentAttendee
753  *
754  * Returns: (nullable): the @attendee common name (cn) parameter
755  *
756  * Since: 3.34
757  **/
758 const gchar *
e_cal_component_attendee_get_cn(const ECalComponentAttendee * attendee)759 e_cal_component_attendee_get_cn (const ECalComponentAttendee *attendee)
760 {
761 	g_return_val_if_fail (attendee != NULL, NULL);
762 
763 	return attendee->cn;
764 }
765 
766 /**
767  * e_cal_component_attendee_set_cn:
768  * @attendee: an #ECalComponentAttendee
769  * @cn: (nullable): the value to set
770  *
771  * Set the @attendee common name (cn) parameter. The %NULL
772  * and empty strings are treated as unset the value.
773  *
774  * Since: 3.34
775  **/
776 void
e_cal_component_attendee_set_cn(ECalComponentAttendee * attendee,const gchar * cn)777 e_cal_component_attendee_set_cn (ECalComponentAttendee *attendee,
778 				 const gchar *cn)
779 {
780 	g_return_if_fail (attendee != NULL);
781 
782 	if (cn && !*cn)
783 		cn = NULL;
784 
785 	if (g_strcmp0 (attendee->cn, cn) != 0) {
786 		g_free (attendee->cn);
787 		attendee->cn = g_strdup (cn);
788 	}
789 }
790 
791 /**
792  * e_cal_component_attendee_get_language:
793  * @attendee: an #ECalComponentAttendee
794  *
795  * Returns: (nullable): the @attendee language parameter
796  *
797  * Since: 3.34
798  **/
799 const gchar *
e_cal_component_attendee_get_language(const ECalComponentAttendee * attendee)800 e_cal_component_attendee_get_language (const ECalComponentAttendee *attendee)
801 {
802 	g_return_val_if_fail (attendee != NULL, NULL);
803 
804 	return attendee->language;
805 }
806 
807 /**
808  * e_cal_component_attendee_set_language:
809  * @attendee: an #ECalComponentAttendee
810  * @language: (nullable): the value to set
811  *
812  * Set the @attendee language parameter. The %NULL
813  * and empty strings are treated as unset the value.
814  *
815  * Since: 3.34
816  **/
817 void
e_cal_component_attendee_set_language(ECalComponentAttendee * attendee,const gchar * language)818 e_cal_component_attendee_set_language (ECalComponentAttendee *attendee,
819 				       const gchar *language)
820 {
821 	g_return_if_fail (attendee != NULL);
822 
823 	if (language && !*language)
824 		language = NULL;
825 
826 	if (g_strcmp0 (attendee->language, language) != 0) {
827 		g_free (attendee->language);
828 		attendee->language = g_strdup (language);
829 	}
830 }
831 
832 /**
833  * e_cal_component_attendee_get_parameter_bag:
834  * @attendee: an #ECalComponentAttendee
835  *
836  * Returns: (transfer none): an #ECalComponentParameterBag with additional
837  *    parameters stored with the attendee property, other than those accessible
838  *    with the other functions of the @attendee.
839  *
840  * Since: 3.34
841  **/
842 ECalComponentParameterBag *
e_cal_component_attendee_get_parameter_bag(const ECalComponentAttendee * attendee)843 e_cal_component_attendee_get_parameter_bag (const ECalComponentAttendee *attendee)
844 {
845 	g_return_val_if_fail (attendee != NULL, NULL);
846 
847 	return attendee->parameter_bag;
848 }
849