From 4ae033dd397990b79a6d1ff40554e286306e7e66 Mon Sep 17 00:00:00 2001 From: Federico Mena Quintero Date: Tue, 4 Jul 2000 00:58:22 +0000 Subject: Use CalComponentText instead of CalComponentPropSummary. Removed the 2000-07-03 Federico Mena Quintero * cal-util/cal-component.c (cal_component_get_summary): Use CalComponentText instead of CalComponentPropSummary. Removed the latter typedef. (cal_component_set_summary): Likewise. (scan_property): Handle the CLASSIFICATION property. (cal_component_get_classification): Ditto. (cal_component_set_classification): Ditto. svn path=/trunk/; revision=3880 --- calendar/ChangeLog | 8 +++ calendar/cal-util/cal-component.c | 110 +++++++++++++++++++++++++++++++++++++- calendar/cal-util/cal-component.h | 21 ++++---- 3 files changed, 128 insertions(+), 11 deletions(-) diff --git a/calendar/ChangeLog b/calendar/ChangeLog index 199b355241..243e579602 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,5 +1,13 @@ 2000-07-03 Federico Mena Quintero + * cal-util/cal-component.c (cal_component_get_summary): Use + CalComponentText instead of CalComponentPropSummary. Removed the + latter typedef. + (cal_component_set_summary): Likewise. + (scan_property): Handle the CLASSIFICATION property. + (cal_component_get_classification): Ditto. + (cal_component_set_classification): Ditto. + * cal-util/cal-component.c (cal_component_free_text_list): Renamed from cal_component_free_description_list(). We can share this function since both comments and descriptions have the same form. diff --git a/calendar/cal-util/cal-component.c b/calendar/cal-util/cal-component.c index 9c497c0429..a16aefd0ca 100644 --- a/calendar/cal-util/cal-component.c +++ b/calendar/cal-util/cal-component.c @@ -20,6 +20,7 @@ */ #include +#include #include #include "cal-component.h" #include "timeutil.h" @@ -40,6 +41,8 @@ typedef struct { }; GSList *categories_list; + icalproperty *classification; + struct text { icalproperty *prop; icalparameter *altrep_param; @@ -172,6 +175,9 @@ free_icalcomponent (CalComponent *comp) priv->categories_list = free_slist (priv->categories_list); + priv->classification = NULL; + priv->comment_list = NULL; + priv->description_list = free_slist (priv->description_list); priv->dtstart.prop = NULL; @@ -385,6 +391,10 @@ scan_property (CalComponent *comp, icalproperty *prop) scan_categories (comp, prop); break; + case ICAL_CLASS_PROPERTY: + priv->classification = prop; + break; + case ICAL_COMMENT_PROPERTY: scan_text (comp, &priv->comment_list, prop); break; @@ -815,6 +825,102 @@ cal_component_free_categories_list (GSList *categ_list) g_slist_free (categ_list); } +/** + * cal_component_get_classification: + * @comp: A calendar component object. + * @classif: Return value for the classification. + * + * Queries the classification of a calendar component object. If the + * classification property is not set on this component, this function returns + * #CAL_COMPONENT_CLASS_NONE. + **/ +void +cal_component_get_classification (CalComponent *comp, CalComponentClassification *classif) +{ + CalComponentPrivate *priv; + const char *class; + + g_return_if_fail (comp != NULL); + g_return_if_fail (IS_CAL_COMPONENT (comp)); + g_return_if_fail (classif != NULL); + + priv = comp->priv; + g_return_if_fail (priv->icalcomp != NULL); + + if (!priv->classification) { + *classif = CAL_COMPONENT_CLASS_NONE; + return; + } + + class = icalproperty_get_class (priv->classification); + + if (strcasecmp (class, "PUBLIC") == 0) + *classif = CAL_COMPONENT_CLASS_PUBLIC; + else if (strcasecmp (class, "PRIVATE") == 0) + *classif = CAL_COMPONENT_CLASS_PRIVATE; + else if (strcasecmp (class, "CONFIDENTIAL") == 0) + *classif = CAL_COMPONENT_CLASS_CONFIDENTIAL; + else + *classif = CAL_COMPONENT_CLASS_UNKNOWN; +} + +/** + * cal_component_set_classification: + * @comp: A calendar component object. + * @classif: Classification to use. + * + * Sets the classification property of a calendar component object. To unset + * the property, specify CAL_COMPONENT_CLASS_NONE for @classif. + **/ +void +cal_component_set_classification (CalComponent *comp, CalComponentClassification classif) +{ + CalComponentPrivate *priv; + char *str; + + g_return_if_fail (comp != NULL); + g_return_if_fail (IS_CAL_COMPONENT (comp)); + g_return_if_fail (classif != CAL_COMPONENT_CLASS_UNKNOWN); + + priv = comp->priv; + g_return_if_fail (priv->icalcomp != NULL); + + if (classif == CAL_COMPONENT_CLASS_NONE) { + if (priv->classification) { + icalcomponent_remove_property (priv->icalcomp, priv->classification); + icalproperty_free (priv->classification); + priv->classification = NULL; + } + + return; + } + + switch (classif) { + case CAL_COMPONENT_CLASS_PUBLIC: + str = "PUBLIC"; + break; + + case CAL_COMPONENT_CLASS_PRIVATE: + str = "PRIVATE"; + break; + + case CAL_COMPONENT_CLASS_CONFIDENTIAL: + str = "CONFIDENTIAL"; + break; + + default: + g_assert_not_reached (); + str = NULL; + } + + if (priv->classification) + icalproperty_set_class (priv->classification, str); + else { + priv->classification = icalproperty_new_class (str); + icalcomponent_add_property (priv->icalcomp, priv->classification); + } +} + /** * cal_component_free_text_list: * @text_list: List of #CalComponentText structures. @@ -1261,7 +1367,7 @@ cal_component_set_due (CalComponent *comp, CalComponentDateTime *dt) * Queries the summary of a calendar component object. **/ void -cal_component_get_summary (CalComponent *comp, CalComponentPropSummary *summary) +cal_component_get_summary (CalComponent *comp, CalComponentText *summary) { CalComponentPrivate *priv; @@ -1291,7 +1397,7 @@ cal_component_get_summary (CalComponent *comp, CalComponentPropSummary *summary) * Sets the summary of a calendar component object. **/ void -cal_component_set_summary (CalComponent *comp, const CalComponentPropSummary *summary) +cal_component_set_summary (CalComponent *comp, CalComponentText *summary) { CalComponentPrivate *priv; diff --git a/calendar/cal-util/cal-component.h b/calendar/cal-util/cal-component.h index d2d2c2c96f..dbb0096830 100644 --- a/calendar/cal-util/cal-component.h +++ b/calendar/cal-util/cal-component.h @@ -53,13 +53,13 @@ typedef enum { /* Structures to return properties and their parameters */ -typedef struct { - /* Summary string */ - const char *value; - - /* Alternate representation URI */ - const char *altrep; -} CalComponentPropSummary; +typedef enum { + CAL_COMPONENT_CLASS_NONE, + CAL_COMPONENT_CLASS_PUBLIC, + CAL_COMPONENT_CLASS_PRIVATE, + CAL_COMPONENT_CLASS_CONFIDENTIAL, + CAL_COMPONENT_CLASS_UNKNOWN +} CalComponentClassification; typedef struct { /* Description string */ @@ -111,6 +111,9 @@ void cal_component_get_categories_list (CalComponent *comp, GSList **categ_list) void cal_component_set_categories_list (CalComponent *comp, GSList *categ_list); void cal_component_free_categories_list (GSList *categ_list); +void cal_component_get_classification (CalComponent *comp, CalComponentClassification *classif); +void cal_component_set_classification (CalComponent *comp, CalComponentClassification classif); + void cal_component_free_text_list (GSList *text_list); void cal_component_get_comment_list (CalComponent *comp, GSList **text_list); @@ -130,8 +133,8 @@ void cal_component_set_dtend (CalComponent *comp, CalComponentDateTime *dt); void cal_component_get_due (CalComponent *comp, CalComponentDateTime *dt); void cal_component_set_due (CalComponent *comp, CalComponentDateTime *dt); -void cal_component_get_summary (CalComponent *comp, CalComponentPropSummary *summary); -void cal_component_set_summary (CalComponent *comp, const CalComponentPropSummary *summary); +void cal_component_get_summary (CalComponent *comp, CalComponentText *summary); +void cal_component_set_summary (CalComponent *comp, CalComponentText *summary); -- cgit v1.2.3