aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/cal-util
diff options
context:
space:
mode:
Diffstat (limited to 'calendar/cal-util')
-rw-r--r--calendar/cal-util/cal-component.c172
-rw-r--r--calendar/cal-util/cal-component.h31
2 files changed, 203 insertions, 0 deletions
diff --git a/calendar/cal-util/cal-component.c b/calendar/cal-util/cal-component.c
index 1c5bddd4fc..1fdfc5da8c 100644
--- a/calendar/cal-util/cal-component.c
+++ b/calendar/cal-util/cal-component.c
@@ -72,6 +72,8 @@ struct _CalComponentPrivate {
GSList *exrule_list; /* list of icalproperty objects */
icalproperty *last_modified;
+ icalproperty *percent;
+ icalproperty *priority;
struct period {
icalproperty *prop;
@@ -243,6 +245,8 @@ free_icalcomponent (CalComponent *comp)
priv->exrule_list = NULL;
priv->last_modified = NULL;
+ priv->percent = NULL;
+ priv->priority = NULL;
priv->rdate_list = free_slist (priv->rdate_list);
@@ -517,6 +521,14 @@ scan_property (CalComponent *comp, icalproperty *prop)
priv->last_modified = prop;
break;
+ case ICAL_PERCENTCOMPLETE_PROPERTY:
+ priv->percent = prop;
+ break;
+
+ case ICAL_PRIORITY_PROPERTY:
+ priv->priority = prop;
+ break;
+
case ICAL_RDATE_PROPERTY:
scan_period (comp, &priv->rdate_list, prop);
break;
@@ -2143,6 +2155,136 @@ cal_component_set_last_modified (CalComponent *comp, struct icaltimetype *t)
}
/**
+ * cal_component_get_percent:
+ * @comp: A calendar component object.
+ * @percent: Return value for the percent-complete property. This should be
+ * freed using the cal_component_free_percent() function.
+ *
+ * Queries the percent-complete property of a calendar component object.
+ **/
+void
+cal_component_get_percent (CalComponent *comp, int **percent)
+{
+ CalComponentPrivate *priv;
+
+ g_return_if_fail (comp != NULL);
+ g_return_if_fail (IS_CAL_COMPONENT (comp));
+ g_return_if_fail (percent != NULL);
+
+ priv = comp->priv;
+ g_return_if_fail (priv->icalcomp != NULL);
+
+ if (priv->percent) {
+ *percent = g_new (int, 1);
+ **percent = icalproperty_get_percentcomplete (priv->percent);
+ } else
+ *percent = NULL;
+}
+
+/**
+ * cal_component_set_percent:
+ * @comp: A calendar component object.
+ * @percent: Value for the percent-complete property.
+ *
+ * Sets the percent-complete property of a calendar component object.
+ **/
+void
+cal_component_set_percent (CalComponent *comp, int *percent)
+{
+ CalComponentPrivate *priv;
+
+ g_return_if_fail (comp != NULL);
+ g_return_if_fail (IS_CAL_COMPONENT (comp));
+
+ priv = comp->priv;
+ g_return_if_fail (priv->icalcomp != NULL);
+
+ if (!percent) {
+ if (priv->percent) {
+ icalcomponent_remove_property (priv->icalcomp, priv->percent);
+ icalproperty_free (priv->percent);
+ priv->percent = NULL;
+ }
+
+ return;
+ }
+
+ g_return_if_fail (*percent >= 0 && *percent <= 100);
+
+ if (priv->percent)
+ icalproperty_set_percentcomplete (priv->percent, *percent);
+ else {
+ priv->percent = icalproperty_new_percentcomplete (*percent);
+ icalcomponent_add_property (priv->icalcomp, priv->percent);
+ }
+}
+
+/**
+ * cal_component_get_priority:
+ * @comp: A calendar component object.
+ * @priority: Return value for the priority property. This should be freed using
+ * the cal_component_free_priority() function.
+ *
+ * Queries the priority property of a calendar component object.
+ **/
+void
+cal_component_get_priority (CalComponent *comp, int **priority)
+{
+ CalComponentPrivate *priv;
+
+ g_return_if_fail (comp != NULL);
+ g_return_if_fail (IS_CAL_COMPONENT (comp));
+ g_return_if_fail (priority != NULL);
+
+ priv = comp->priv;
+ g_return_if_fail (priv->icalcomp != NULL);
+
+ if (priv->priority) {
+ *priority = g_new (int, 1);
+ **priority = icalproperty_get_priority (priv->priority);
+ } else
+ *priority = NULL;
+}
+
+/**
+ * cal_component_set_priority:
+ * @comp: A calendar component object.
+ * @priority: Value for the priority property.
+ *
+ * Sets the priority property of a calendar component object.
+ **/
+void
+cal_component_set_priority (CalComponent *comp, int *priority)
+{
+ CalComponentPrivate *priv;
+
+ g_return_if_fail (comp != NULL);
+ g_return_if_fail (IS_CAL_COMPONENT (comp));
+
+ priv = comp->priv;
+ g_return_if_fail (priv->icalcomp != NULL);
+
+ if (!priority) {
+ if (priv->priority) {
+ icalcomponent_remove_property (priv->icalcomp, priv->priority);
+ icalproperty_free (priv->priority);
+ priv->priority = NULL;
+ }
+
+ return;
+ }
+
+ g_return_if_fail (*priority >= 0 && *priority <= 9);
+
+ if (priv->priority)
+ icalproperty_set_priority (priv->priority, *priority);
+ else {
+ priv->priority = icalproperty_new_priority (*priority);
+ icalcomponent_add_property (priv->icalcomp, priv->priority);
+ }
+}
+
+/**
* cal_component_get_rdate_list:
* @comp: A calendar component object.
* @period_list: Return value for the list of recurrence dates, as a list of
@@ -2622,6 +2764,36 @@ cal_component_free_icaltimetype (struct icaltimetype *t)
}
/**
+ * cal_component_free_percent:
+ * @percent: Percent value.
+ *
+ * Frees a percent value as returned by the cal_component_get_percent()
+ * function.
+ **/
+void
+cal_component_free_percent (int *percent)
+{
+ g_return_if_fail (percent != NULL);
+
+ g_free (percent);
+}
+
+/**
+ * cal_component_free_priority:
+ * @priority: Priority value.
+ *
+ * Frees a priority value as returned by the cal_component_get_priority()
+ * function.
+ **/
+void
+cal_component_free_priority (int *priority)
+{
+ g_return_if_fail (priority != NULL);
+
+ g_free (priority);
+}
+
+/**
* cal_component_free_period_list:
* @period_list: List of #CalComponentPeriod structures.
*
diff --git a/calendar/cal-util/cal-component.h b/calendar/cal-util/cal-component.h
index 1fc1d455d4..faecd6621f 100644
--- a/calendar/cal-util/cal-component.h
+++ b/calendar/cal-util/cal-component.h
@@ -51,6 +51,29 @@ typedef enum {
CAL_COMPONENT_TIMEZONE
} CalComponentVType;
+/* Field identifiers for a calendar component */
+typedef enum {
+ CAL_COMPONENT_FIELD_CATEGORIES,
+ CAL_COMPONENT_FIELD_CLASSIFICATION,
+ CAL_COMPONENT_FIELD_COMPLETED,
+ CAL_COMPONENT_FIELD_CREATED,
+ CAL_COMPONENT_FIELD_DTEND,
+ CAL_COMPONENT_FIELD_DTSTART,
+ CAL_COMPONENT_FIELD_DUE,
+ CAL_COMPONENT_FIELD_PERCENT,
+ CAL_COMPONENT_FIELD_PRIORITY,
+ CAL_COMPONENT_FIELD_SUMMARY,
+ CAL_COMPONENT_FIELD_TRANSPARENCY,
+ CAL_COMPONENT_FIELD_URL,
+ CAL_COMPONENT_FIELD_HAS_ALARMS, /* not a real field */
+ CAL_COMPONENT_FIELD_ICON, /* not a real field */
+ CAL_COMPONENT_FIELD_COMPLETE, /* not a real field */
+ CAL_COMPONENT_FIELD_RECURRING, /* not a real field */
+ CAL_COMPONENT_FIELD_OVERDUE, /* not a real field */
+ CAL_COMPONENT_FIELD_COLOR, /* not a real field */
+ CAL_COMPONETN_FIELD_NUM_FIELDS
+} CalComponentField;
+
/* Structures to return properties and their parameters */
typedef enum {
@@ -181,6 +204,12 @@ void cal_component_set_exrule_list (CalComponent *comp, GSList *recur_list);
void cal_component_get_last_modified (CalComponent *comp, struct icaltimetype **t);
void cal_component_set_last_modified (CalComponent *comp, struct icaltimetype *t);
+void cal_component_get_percent (CalComponent *comp, int **percent);
+void cal_component_set_percent (CalComponent *comp, int *percent);
+
+void cal_component_get_priority (CalComponent *comp, int **priority);
+void cal_component_set_priority (CalComponent *comp, int *priority);
+
void cal_component_get_rdate_list (CalComponent *comp, GSList **period_list);
void cal_component_set_rdate_list (CalComponent *comp, GSList *period_list);
@@ -205,6 +234,8 @@ void cal_component_free_categories_list (GSList *categ_list);
void cal_component_free_datetime (CalComponentDateTime *dt);
void cal_component_free_exdate_list (GSList *exdate_list);
void cal_component_free_icaltimetype (struct icaltimetype *t);
+void cal_component_free_percent (int *percent);
+void cal_component_free_priority (int *priority);
void cal_component_free_period_list (GSList *period_list);
void cal_component_free_recur_list (GSList *recur_list);
void cal_component_free_sequence (int *sequence);