aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/cal-util
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@helixcode.com>2000-07-04 08:58:22 +0800
committerFederico Mena Quintero <federico@src.gnome.org>2000-07-04 08:58:22 +0800
commit4ae033dd397990b79a6d1ff40554e286306e7e66 (patch)
treee5204f4b9dd951b9841b6656c393f0d01c0e0b0f /calendar/cal-util
parent7ad9e599926815d42e88dc2a9a9037fc860d143c (diff)
downloadgsoc2013-evolution-4ae033dd397990b79a6d1ff40554e286306e7e66.tar
gsoc2013-evolution-4ae033dd397990b79a6d1ff40554e286306e7e66.tar.gz
gsoc2013-evolution-4ae033dd397990b79a6d1ff40554e286306e7e66.tar.bz2
gsoc2013-evolution-4ae033dd397990b79a6d1ff40554e286306e7e66.tar.lz
gsoc2013-evolution-4ae033dd397990b79a6d1ff40554e286306e7e66.tar.xz
gsoc2013-evolution-4ae033dd397990b79a6d1ff40554e286306e7e66.tar.zst
gsoc2013-evolution-4ae033dd397990b79a6d1ff40554e286306e7e66.zip
Use CalComponentText instead of CalComponentPropSummary. Removed the
2000-07-03 Federico Mena Quintero <federico@helixcode.com> * 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
Diffstat (limited to 'calendar/cal-util')
-rw-r--r--calendar/cal-util/cal-component.c110
-rw-r--r--calendar/cal-util/cal-component.h21
2 files changed, 120 insertions, 11 deletions
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 <config.h>
+#include <string.h>
#include <unistd.h>
#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;
@@ -816,6 +826,102 @@ cal_component_free_categories_list (GSList *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);