aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJP Rosevear <jpr@ximian.com>2001-12-09 07:18:37 +0800
committerJP Rosevear <jpr@src.gnome.org>2001-12-09 07:18:37 +0800
commitd1ddbc231d6e816af4e582b79da400fda8e8bd01 (patch)
tree3b96dd341632540f62015d4fd327c83b2246b77d
parent9cb9cf06c9063ddf76a87b07cb6e94c2008dd605 (diff)
downloadgsoc2013-evolution-d1ddbc231d6e816af4e582b79da400fda8e8bd01.tar.gz
gsoc2013-evolution-d1ddbc231d6e816af4e582b79da400fda8e8bd01.tar.zst
gsoc2013-evolution-d1ddbc231d6e816af4e582b79da400fda8e8bd01.zip
if we have an alarm that can be represented on the pilot, set the
2001-12-08 JP Rosevear <jpr@ximian.com> * conduits/calendar/calendar-conduit.c (local_record_from_comp): if we have an alarm that can be represented on the pilot, set the appointment fields appropriately, if the duration has values for minutes and/or hours and/or days, use the lowest common denominator (comp_from_remote_record): if the appointment on the pilot has an alarm, find the first alarm an item currently had that is relative to the start and with a negative duration and update it (or create a new one if no valid ones exist) * cal-util/cal-component.c (cal_component_get_alarm_uids): build list in the order they appear in the component so we get consisting order for the gui and for the pilot svn path=/trunk/; revision=14943
-rw-r--r--calendar/ChangeLog16
-rw-r--r--calendar/cal-util/cal-component.c38
-rw-r--r--calendar/conduits/calendar/calendar-conduit.c97
3 files changed, 137 insertions, 14 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 42806972dc..e67de963cf 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,19 @@
+2001-12-08 JP Rosevear <jpr@ximian.com>
+
+ * conduits/calendar/calendar-conduit.c (local_record_from_comp):
+ if we have an alarm that can be represented on the pilot, set the
+ appointment fields appropriately, if the duration has values for
+ minutes and/or hours and/or days, use the lowest common
+ denominator
+ (comp_from_remote_record): if the appointment on the pilot has an
+ alarm, find the first alarm an item currently had that is relative
+ to the start and with a negative duration and update it (or create
+ a new one if no valid ones exist)
+
+ * cal-util/cal-component.c (cal_component_get_alarm_uids): build
+ list in the order they appear in the component so we get
+ consisting order for the gui and for the pilot
+
2001-12-08 Rodrigo Moya <rodrigo@ximian.com>
* gui/calendar-config.c (calendar_config_get_default_uri):
diff --git a/calendar/cal-util/cal-component.c b/calendar/cal-util/cal-component.c
index 5fc5addf19..eeb51c79f6 100644
--- a/calendar/cal-util/cal-component.c
+++ b/calendar/cal-util/cal-component.c
@@ -4462,19 +4462,6 @@ make_alarm (icalcomponent *subcomp)
return alarm;
}
-/* Used from g_hash_table_foreach(); adds an alarm UID to a list */
-static void
-add_alarm_uid (gpointer key, gpointer value, gpointer data)
-{
- const char *auid;
- GList **l;
-
- auid = key;
- l = data;
-
- *l = g_list_prepend (*l, g_strdup (auid));
-}
-
/**
* cal_component_get_alarm_uids:
* @comp: A calendar component.
@@ -4489,6 +4476,7 @@ GList *
cal_component_get_alarm_uids (CalComponent *comp)
{
CalComponentPrivate *priv;
+ icalcompiter iter;
GList *l;
g_return_val_if_fail (comp != NULL, NULL);
@@ -4498,7 +4486,29 @@ cal_component_get_alarm_uids (CalComponent *comp)
g_return_val_if_fail (priv->icalcomp != NULL, NULL);
l = NULL;
- g_hash_table_foreach (priv->alarm_uid_hash, add_alarm_uid, &l);
+ for (iter = icalcomponent_begin_component (priv->icalcomp, ICAL_VALARM_COMPONENT);
+ icalcompiter_deref (&iter) != NULL;
+ icalcompiter_next (&iter)) {
+ icalcomponent *subcomp;
+ icalproperty *prop;
+
+ 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;
+
+ xname = icalproperty_get_x_name (prop);
+ g_assert (xname != NULL);
+
+ if (strcmp (xname, EVOLUTION_ALARM_UID_PROPERTY) == 0) {
+ const char *auid;
+
+ auid = alarm_uid_from_prop (prop);
+ l = g_list_append (l, g_strdup (auid));
+ }
+ }
+ }
return l;
}
diff --git a/calendar/conduits/calendar/calendar-conduit.c b/calendar/conduits/calendar/calendar-conduit.c
index 71d6cf73b6..1546141254 100644
--- a/calendar/conduits/calendar/calendar-conduit.c
+++ b/calendar/conduits/calendar/calendar-conduit.c
@@ -66,6 +66,8 @@ void conduit_destroy_gpilot_conduit (GnomePilotConduit*);
#define WARN(e...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, e)
#define INFO(e...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, e)
+#define PILOT_MAX_ADVANCE 99
+
/* Debug routines */
static char *
print_local (ECalLocalRecord *local)
@@ -720,6 +722,54 @@ local_record_from_comp (ECalLocalRecord *local, CalComponent *comp, ECalConduitC
*local->appt->exception = icaltimetype_to_tm (dt->value);
}
cal_component_free_exdate_list (edl);
+
+ /* Alarm */
+ local->appt->alarm = 0;
+ if (cal_component_has_alarms (comp)) {
+ GList *uids, *l;
+ CalComponentAlarm *alarm;
+ CalAlarmTrigger trigger;
+
+ uids = cal_component_get_alarm_uids (comp);
+ for (l = uids; l != NULL; l = l->next) {
+ alarm = cal_component_get_alarm (comp, l->data);
+ cal_component_alarm_get_trigger (alarm, &trigger);
+
+ if ((trigger.type == CAL_ALARM_TRIGGER_RELATIVE_START
+ && trigger.u.rel_duration.is_neg)) {
+ local->appt->advanceUnits = advMinutes;
+ local->appt->advance =
+ trigger.u.rel_duration.minutes
+ + trigger.u.rel_duration.hours * 60
+ + trigger.u.rel_duration.days * 60 * 24
+ + trigger.u.rel_duration.weeks * 7 * 60 * 24;
+
+ if (local->appt->advance > PILOT_MAX_ADVANCE) {
+ local->appt->advanceUnits = advHours;
+ local->appt->advance =
+ trigger.u.rel_duration.minutes / 60
+ + trigger.u.rel_duration.hours
+ + trigger.u.rel_duration.days * 24
+ + trigger.u.rel_duration.weeks * 7 * 24;
+ }
+ if (local->appt->advance > PILOT_MAX_ADVANCE) {
+ local->appt->advanceUnits = advDays;
+ local->appt->advance =
+ trigger.u.rel_duration.minutes / (60 * 24)
+ + trigger.u.rel_duration.hours / 24
+ + trigger.u.rel_duration.days
+ + trigger.u.rel_duration.weeks * 7;
+ }
+ if (local->appt->advance > PILOT_MAX_ADVANCE)
+ local->appt->advance = PILOT_MAX_ADVANCE;
+
+ local->appt->alarm = 1;
+ break;
+ }
+ cal_component_alarm_free (alarm);
+ }
+ cal_obj_uid_list_free (uids);
+ }
cal_component_get_classification (comp, &classif);
@@ -907,6 +957,53 @@ comp_from_remote_record (GnomePilotConduitSyncAbs *conduit,
}
cal_component_set_exdate_list (comp, edl);
cal_component_free_exdate_list (edl);
+
+ /* Alarm */
+ if (appt.alarm) {
+ CalComponentAlarm *alarm = NULL;
+ CalAlarmTrigger trigger;
+ gboolean found = FALSE;
+
+ if (cal_component_has_alarms (comp)) {
+ GList *uids, *l;
+
+ uids = cal_component_get_alarm_uids (comp);
+ for (l = uids; l != NULL; l = l->next) {
+ alarm = cal_component_get_alarm (comp, l->data);
+ cal_component_alarm_get_trigger (alarm, &trigger);
+ if ((trigger.type == CAL_ALARM_TRIGGER_RELATIVE_START
+ && trigger.u.rel_duration.is_neg)) {
+ found = TRUE;
+ break;
+ }
+ cal_component_alarm_free (alarm);
+ }
+ cal_obj_uid_list_free (uids);
+ }
+ if (!found)
+ alarm = cal_component_alarm_new ();
+
+ memset (&trigger, 0, sizeof (CalAlarmTrigger));
+ trigger.type = CAL_ALARM_TRIGGER_RELATIVE_START;
+ trigger.u.rel_duration.is_neg = 1;
+ switch (appt.advanceUnits) {
+ case advMinutes:
+ trigger.u.rel_duration.minutes = appt.advance;
+ break;
+ case advHours:
+ trigger.u.rel_duration.hours = appt.advance;
+ break;
+ case advDays:
+ trigger.u.rel_duration.days = appt.advance;
+ break;
+ }
+ cal_component_alarm_set_trigger (alarm, trigger);
+ cal_component_alarm_set_action (alarm, CAL_ALARM_DISPLAY);
+
+ if (!found)
+ cal_component_add_alarm (comp, alarm);
+ cal_component_alarm_free (alarm);
+ }
cal_component_set_transparency (comp, CAL_COMPONENT_TRANSP_NONE);