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
This commit is contained in:
Federico Mena Quintero
2000-07-04 00:58:22 +00:00
committed by Federico Mena Quintero
parent 7ad9e59992
commit 4ae033dd39
3 changed files with 128 additions and 11 deletions
+8
View File
@@ -1,5 +1,13 @@
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.
* 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.
+108 -2
View File
@@ -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;
@@ -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;
+12 -9
View File
@@ -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);