diff options
author | JP Rosevear <jpr@helixcode.com> | 2000-10-12 13:07:47 +0800 |
---|---|---|
committer | JP Rosevear <jpr@src.gnome.org> | 2000-10-12 13:07:47 +0800 |
commit | 4f67f61e80997e10e1b66bff12f0b9ac6a2bfa5a (patch) | |
tree | fdb9f926c3cce4c16ed0424fd65dc7aa5af07354 /calendar | |
parent | 2adab13971baa11b24d52c2ce2991ba39b08ad37 (diff) | |
download | gsoc2013-evolution-4f67f61e80997e10e1b66bff12f0b9ac6a2bfa5a.tar.gz gsoc2013-evolution-4f67f61e80997e10e1b66bff12f0b9ac6a2bfa5a.tar.zst gsoc2013-evolution-4f67f61e80997e10e1b66bff12f0b9ac6a2bfa5a.zip |
Store recurrence stuff on the desktop properly (get_ical_day): Utility
2000-10-12 JP Rosevear <jpr@helixcode.com>
* conduits/calendar/calendar-conduit.c (comp_from_remote_record):
Store recurrence stuff on the desktop properly
(get_ical_day): Utility function
svn path=/trunk/; revision=5878
Diffstat (limited to 'calendar')
-rw-r--r-- | calendar/ChangeLog | 6 | ||||
-rw-r--r-- | calendar/conduits/calendar/calendar-conduit.c | 91 |
2 files changed, 97 insertions, 0 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog index 020e228ca8..a91d7d2819 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,9 @@ +2000-10-12 JP Rosevear <jpr@helixcode.com> + + * conduits/calendar/calendar-conduit.c (comp_from_remote_record): + Store recurrence stuff on the desktop properly + (get_ical_day): Utility function + 2000-10-12 Iain Holmes <iain@helixcode.com> * gui/component-factory.c: Disable the executive summary. diff --git a/calendar/conduits/calendar/calendar-conduit.c b/calendar/conduits/calendar/calendar-conduit.c index aad146d03f..757dd66958 100644 --- a/calendar/conduits/calendar/calendar-conduit.c +++ b/calendar/conduits/calendar/calendar-conduit.c @@ -323,6 +323,28 @@ status_to_string (gint status) return "Unknown"; } +static icalrecurrencetype_weekday +get_ical_day (int day) +{ + switch (day) { + case 0: + return ICAL_MONDAY_WEEKDAY; + case 1: + return ICAL_TUESDAY_WEEKDAY; + case 2: + return ICAL_WEDNESDAY_WEEKDAY; + case 3: + return ICAL_THURSDAY_WEEKDAY; + case 4: + return ICAL_FRIDAY_WEEKDAY; + case 5: + return ICAL_SATURDAY_WEEKDAY; + case 6: + return ICAL_SUNDAY_WEEKDAY; + } + + return ICAL_NO_WEEKDAY; +} static void compute_pid (ECalConduitContext *ctxt, ECalLocalRecord *local, const char *uid) @@ -483,6 +505,8 @@ comp_from_remote_record (GnomePilotConduitSyncAbs *conduit, CalComponent *comp; struct Appointment appt; struct icaltimetype now = icaltime_from_timet (time (NULL), FALSE, FALSE), it; + struct icalrecurrencetype recur; + int pos, i; CalComponentText summary = {NULL, NULL}; CalComponentText description = {NULL, NULL}; CalComponentDateTime dt = {NULL, NULL}; @@ -532,6 +556,73 @@ comp_from_remote_record (GnomePilotConduitSyncAbs *conduit, dt.value = ⁢ cal_component_set_dtend (comp, &dt); } + + /* Recurrence information */ + icalrecurrencetype_clear (&recur); + + switch (appt.repeatType) { + case repeatNone: + recur.freq = ICAL_NO_RECURRENCE; + /* nothing */ + break; + + case repeatDaily: + recur.freq = ICAL_DAILY_RECURRENCE; + recur.interval = appt.repeatFrequency; + break; + + case repeatWeekly: + recur.freq = ICAL_WEEKLY_RECURRENCE; + recur.interval = appt.repeatFrequency; + + pos = 0; + for (i = 0; i < 7; i++) { + if (appt.repeatDays[i]) + recur.by_day[pos++] = get_ical_day (i); + } + + break; + + case repeatMonthlyByDay: + recur.freq = ICAL_MONTHLY_RECURRENCE; + recur.interval = appt.repeatFrequency; + recur.by_month_day[0] = appt.begin.tm_mday; + break; + + case repeatMonthlyByDate: + recur.freq = ICAL_MONTHLY_RECURRENCE; + recur.interval = appt.repeatFrequency; + /* Not handled! */ + break; + + case repeatYearly: + recur.freq = ICAL_YEARLY_RECURRENCE; + recur.interval = appt.repeatFrequency; + break; + + default: + g_assert_not_reached (); + } + + if (recur.freq != ICAL_NO_RECURRENCE) { + GSList *list = NULL; + + /* recurrence start of week */ + recur.week_start = get_ical_day (appt.repeatWeekstart); + + if (appt.repeatEnd.tm_sec || appt.repeatEnd.tm_min || appt.repeatEnd.tm_hour + || appt.repeatEnd.tm_mday || appt.repeatEnd.tm_mon || appt.repeatEnd.tm_year) { + time_t t = mktime (&appt.repeatEnd); + t = time_add_day (t, 1); + recur.until = icaltime_from_timet (t, FALSE, FALSE); + } + + list = g_slist_append (list, &recur); + cal_component_set_rrule_list (comp, list); + g_slist_free (list); + } else { + cal_component_set_rrule_list (comp, NULL); + } cal_component_set_transparency (comp, CAL_COMPONENT_TRANSP_NONE); |