aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
authorJP Rosevear <jpr@ximian.com>2001-01-19 22:57:09 +0800
committerJP Rosevear <jpr@src.gnome.org>2001-01-19 22:57:09 +0800
commit3532a74349645ca733bafe1417822ba2bfb9bd26 (patch)
treee53d13bb4fe4f66d8d514f3ab8b3da2ae151889d /calendar
parent0b808ca4dce7445007567a9b8dedc2246ca134f5 (diff)
downloadgsoc2013-evolution-3532a74349645ca733bafe1417822ba2bfb9bd26.tar
gsoc2013-evolution-3532a74349645ca733bafe1417822ba2bfb9bd26.tar.gz
gsoc2013-evolution-3532a74349645ca733bafe1417822ba2bfb9bd26.tar.bz2
gsoc2013-evolution-3532a74349645ca733bafe1417822ba2bfb9bd26.tar.lz
gsoc2013-evolution-3532a74349645ca733bafe1417822ba2bfb9bd26.tar.xz
gsoc2013-evolution-3532a74349645ca733bafe1417822ba2bfb9bd26.tar.zst
gsoc2013-evolution-3532a74349645ca733bafe1417822ba2bfb9bd26.zip
create a new cal component alarm (cal_component_add_alarm): add alarm to
2001-01-19 JP Rosevear <jpr@ximian.com> * cal-util/cal-component.c (cal_component_alarm_new): create a new cal component alarm (cal_component_add_alarm): add alarm to the cal component (cal_component_remove_alarm): remove alarm from the cal component (remove_alarm): remove alarm from hash * cal-util/cal-component.h: new protos * conduits/calendar/calendar-conduit.c (comp_from_remote_record): add alarm information, still needs to be hacked to replace an already existing alarm. questions abound about the heuristic for doing this. 2001-01-17 JP Rosevear <jpr@ximian.com> * README: Update package requirements svn path=/trunk/; revision=7647
Diffstat (limited to 'calendar')
-rw-r--r--calendar/ChangeLog19
-rw-r--r--calendar/cal-util/cal-component.c176
-rw-r--r--calendar/cal-util/cal-component.h10
-rw-r--r--calendar/conduits/calendar/calendar-conduit.c27
4 files changed, 191 insertions, 41 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index caab58dc82..059dc4cd02 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,22 @@
+2001-01-19 JP Rosevear <jpr@ximian.com>
+
+ * cal-util/cal-component.c (cal_component_alarm_new): create a new
+ cal component alarm
+ (cal_component_add_alarm): add alarm to the cal component
+ (cal_component_remove_alarm): remove alarm from the cal component
+ (remove_alarm): remove alarm from hash
+
+ * cal-util/cal-component.h: new protos
+
+ * conduits/calendar/calendar-conduit.c (comp_from_remote_record):
+ add alarm information, still needs to be hacked to replace an already
+ existing alarm. questions abound about the heuristic for doing this.
+
+2001-01-17 JP Rosevear <jpr@ximian.com>
+
+ * gui/event-editor.c (dialog_to_comp_object): Properly set categories
+ to NULL if there are none
+
2001-01-18 Federico Mena Quintero <federico@ximian.com>
* gui/tasks-migrate.[ch]: New files with a simple sequence to
diff --git a/calendar/cal-util/cal-component.c b/calendar/cal-util/cal-component.c
index daf50600c8..7b61aab7f5 100644
--- a/calendar/cal-util/cal-component.c
+++ b/calendar/cal-util/cal-component.c
@@ -688,6 +688,17 @@ add_alarm (CalComponent *comp, icalcomponent *alarm, const char *auid)
return auid;
}
+static void
+remove_alarm (CalComponent *comp, const char *auid)
+{
+ CalComponentPrivate *priv;
+
+ priv = comp->priv;
+
+ g_hash_table_remove (priv->alarm_uid_hash, auid);
+}
+
+
/* Scans an alarm subcomponent, adds an UID extension property to it (so that we
* can reference alarms by unique IDs), and adds its mapping to the component. */
static void
@@ -3442,6 +3453,66 @@ cal_component_has_alarms (CalComponent *comp)
return g_hash_table_size (priv->alarm_uid_hash) != 0;
}
+void
+cal_component_add_alarm (CalComponent *comp, CalComponentAlarm *alarm)
+{
+ CalComponentPrivate *priv;
+
+ g_return_if_fail (comp != NULL);
+ g_return_if_fail (IS_CAL_COMPONENT (comp));
+ g_return_if_fail (alarm != NULL);
+
+ priv = comp->priv;
+
+ alarm->parent = comp;
+ add_alarm (comp, alarm->icalcomp, icalproperty_get_x (alarm->uid));
+ icalcomponent_add_component (priv->icalcomp, alarm->icalcomp);
+}
+
+void
+cal_component_remove_alarm (CalComponent *comp, const char *auid)
+{
+ CalComponentPrivate *priv;
+ icalcompiter iter;
+
+ g_return_if_fail (comp != NULL);
+ g_return_if_fail (IS_CAL_COMPONENT (comp));
+ g_return_if_fail (auid != NULL);
+
+ priv = comp->priv;
+
+ for (iter = icalcomponent_begin_component (priv->icalcomp, ICAL_VALARM_COMPONENT);
+ icalcompiter_deref (&iter) != NULL;
+ icalcompiter_next (&iter)) {
+ icalproperty *prop;
+ icalcomponent *subcomp;
+
+ subcomp = icalcompiter_deref (&iter);
+ for (prop = icalcomponent_get_first_property (subcomp, ICAL_X_PROPERTY);
+ prop;
+ prop = icalcomponent_get_next_property (subcomp, ICAL_X_PROPERTY)) {
+ const char *xname;
+ const char *alarm_uid;
+
+ xname = icalproperty_get_x_name (prop);
+ g_assert (xname != NULL);
+
+ if (strcmp (xname, EVOLUTION_ALARM_UID_PROPERTY) == 0) {
+ alarm_uid = alarm_uid_from_prop (prop);
+ if (strcmp (alarm_uid, auid) == 0) {
+ remove_alarm (comp, auid);
+ icalcomponent_remove_component (priv->icalcomp, subcomp);
+ icalcomponent_free (subcomp);
+ break;
+ }
+
+ return;
+ }
+ }
+ }
+}
+
+
/* Scans an icalproperty from a calendar component and adds its mapping to our
* own alarm structure.
*/
@@ -3574,30 +3645,6 @@ cal_component_get_alarm (CalComponent *comp, const char *auid)
}
/**
- * cal_component_alarm_free:
- * @alarm: A calendar alarm.
- *
- * Frees an alarm structure.
- **/
-void
-cal_component_alarm_free (CalComponentAlarm *alarm)
-{
- g_return_if_fail (alarm != NULL);
-
- g_assert (alarm->icalcomp != NULL);
-
- if (icalcomponent_get_parent (alarm->icalcomp) != NULL)
- icalcomponent_free (alarm->icalcomp);
-
- alarm->icalcomp = NULL;
-
- alarm->parent = NULL;
- alarm->action = NULL;
-
- g_free (alarm);
-}
-
-/**
* cal_component_alarms_free:
* @alarms: Component alarms structure.
*
@@ -3626,6 +3673,30 @@ cal_component_alarms_free (CalComponentAlarms *alarms)
}
/**
+ * cal_component_alarm_new:
+ *
+ *
+ *
+ * Return value: a new alarm component
+ **/
+CalComponentAlarm *
+cal_component_alarm_new (void)
+{
+ CalComponentAlarm *alarm = g_new0 (CalComponentAlarm, 1);
+ char *new_auid ;
+
+ alarm->icalcomp = icalcomponent_new (ICAL_VALARM_COMPONENT);
+
+ new_auid = cal_component_gen_uid ();
+ alarm->uid = icalproperty_new_x (new_auid);
+ icalproperty_set_x_name (alarm->uid, EVOLUTION_ALARM_UID_PROPERTY);
+ icalcomponent_add_property (alarm->icalcomp, alarm->uid);
+ g_free (new_auid);
+
+ return alarm;
+}
+
+/**
* cal_component_alarm_get_uid:
* @alarm: An alarm subcomponent.
*
@@ -3844,12 +3915,14 @@ cal_component_alarm_set_trigger (CalComponentAlarm *alarm, CalAlarmTrigger trigg
switch (trigger.type) {
case CAL_ALARM_TRIGGER_RELATIVE_START:
t.duration = trigger.u.rel_duration;
+ t.time.is_date = -1;
value_type = ICAL_DURATION_VALUE;
related = ICAL_RELATED_START;
break;
case CAL_ALARM_TRIGGER_RELATIVE_END:
t.duration = trigger.u.rel_duration;
+ t.time.is_date = -1;
value_type = ICAL_DURATION_VALUE;
related = ICAL_RELATED_END;
break;
@@ -3891,6 +3964,46 @@ cal_component_alarm_set_trigger (CalComponentAlarm *alarm, CalAlarmTrigger trigg
}
}
+/**
+ * cal_component_alarm_free:
+ * @alarm: A calendar alarm.
+ *
+ * Frees an alarm structure.
+ **/
+void
+cal_component_alarm_free (CalComponentAlarm *alarm)
+{
+ g_return_if_fail (alarm != NULL);
+
+ g_assert (alarm->icalcomp != NULL);
+
+ if (icalcomponent_get_parent (alarm->icalcomp) != NULL)
+ icalcomponent_free (alarm->icalcomp);
+
+ alarm->icalcomp = NULL;
+
+ alarm->parent = NULL;
+ alarm->action = NULL;
+
+ g_free (alarm);
+}
+
+
+/* Returns TRUE if both strings match, i.e. they are both NULL or the
+ strings are equal. */
+static gboolean
+cal_component_strings_match (const gchar *string1,
+ const gchar *string2)
+{
+ if (string1 == NULL || string2 == NULL)
+ return (string1 == string2) ? TRUE : FALSE;
+
+ if (!strcmp (string1, string2))
+ return TRUE;
+
+ return FALSE;
+}
+
/**
* cal_component_event_dates_match:
@@ -3947,19 +4060,4 @@ cal_component_event_dates_match (CalComponent *comp1,
}
-/* Returns TRUE if both strings match, i.e. they are both NULL or the
- strings are equal. */
-static gboolean
-cal_component_strings_match (const gchar *string1,
- const gchar *string2)
-{
- if (string1 == NULL || string2 == NULL)
- return (string1 == string2) ? TRUE : FALSE;
-
- if (!strcmp (string1, string2))
- return TRUE;
-
- return FALSE;
-}
-
diff --git a/calendar/cal-util/cal-component.h b/calendar/cal-util/cal-component.h
index b7d8b602e9..97b518dfe2 100644
--- a/calendar/cal-util/cal-component.h
+++ b/calendar/cal-util/cal-component.h
@@ -327,13 +327,17 @@ typedef struct {
} CalAlarmTrigger;
gboolean cal_component_has_alarms (CalComponent *comp);
+void cal_component_add_alarm (CalComponent *comp, CalComponentAlarm *alarm);
+void cal_component_remove_alarm (CalComponent *comp, const char *auid);
+
GList *cal_component_get_alarm_uids (CalComponent *comp);
CalComponentAlarm *cal_component_get_alarm (CalComponent *comp, const char *auid);
-void cal_component_alarm_free (CalComponentAlarm *alarm);
-
void cal_component_alarms_free (CalComponentAlarms *alarms);
+/* CalComponentAlarms */
+CalComponentAlarm *cal_component_alarm_new (void);
+
const char *cal_component_alarm_get_uid (CalComponentAlarm *alarm);
void cal_component_alarm_get_action (CalComponentAlarm *alarm, CalAlarmAction *action);
@@ -342,6 +346,8 @@ void cal_component_alarm_set_action (CalComponentAlarm *alarm, CalAlarmAction ac
void cal_component_alarm_get_trigger (CalComponentAlarm *alarm, CalAlarmTrigger *trigger);
void cal_component_alarm_set_trigger (CalComponentAlarm *alarm, CalAlarmTrigger trigger);
+void cal_component_alarm_free (CalComponentAlarm *alarm);
+
diff --git a/calendar/conduits/calendar/calendar-conduit.c b/calendar/conduits/calendar/calendar-conduit.c
index 868d7bddd7..9b820ef1d3 100644
--- a/calendar/conduits/calendar/calendar-conduit.c
+++ b/calendar/conduits/calendar/calendar-conduit.c
@@ -655,6 +655,33 @@ comp_from_remote_record (GnomePilotConduitSyncAbs *conduit,
} else {
cal_component_set_rrule_list (comp, NULL);
}
+
+ /* Alarm information */
+ if (appt.alarm) {
+ CalComponentAlarm *alarm;
+ CalAlarmTrigger trig;
+
+ alarm = cal_component_alarm_new ();
+ cal_component_add_alarm (comp, alarm);
+
+ memset (&trig, 0, sizeof (trig));
+ trig.type = CAL_ALARM_TRIGGER_RELATIVE_START;
+ trig.u.rel_duration.is_neg = 1;
+ switch (appt.advanceUnits) {
+ case advMinutes:
+ trig.u.rel_duration.minutes = appt.advance;
+ break;
+ case advHours:
+ trig.u.rel_duration.hours = appt.advance;
+ break;
+ case advDays:
+ trig.u.rel_duration.days = appt.advance;
+ break;
+ }
+ cal_component_alarm_set_trigger (alarm, trig);
+
+ cal_component_alarm_set_action (alarm, CAL_ALARM_AUDIO);
+ }
cal_component_set_transparency (comp, CAL_COMPONENT_TRANSP_NONE);