[Xfce4-commits] r29459 - in xfcalendar/trunk: . src
Juha Kautto
juha at xfce.org
Sat Feb 7 13:53:21 CET 2009
Author: juha
Date: 2009-02-07 12:53:21 +0000 (Sat, 07 Feb 2009)
New Revision: 29459
Modified:
xfcalendar/trunk/configure.in.in
xfcalendar/trunk/src/day-view.c
xfcalendar/trunk/src/ical-code.c
xfcalendar/trunk/src/ical-code.h
Log:
Fixed two bugs:
1) day view did not show recurring events
2) TODO completed time used wrong timezone (start date timezone)
Modified: xfcalendar/trunk/configure.in.in
===================================================================
--- xfcalendar/trunk/configure.in.in 2009-02-07 07:43:49 UTC (rev 29458)
+++ xfcalendar/trunk/configure.in.in 2009-02-07 12:53:21 UTC (rev 29459)
@@ -9,7 +9,7 @@
dnl
dnl Version information
-m4_define([orage_version], [4.5.99.1.0-svn])
+m4_define([orage_version], [4.5.99.1.1-svn])
m4_define([gtk_minimum_version], [2.6.0])
m4_define([xfce_minimum_version], [4.4.0])
Modified: xfcalendar/trunk/src/day-view.c
===================================================================
--- xfcalendar/trunk/src/day-view.c 2009-02-07 07:43:49 UTC (rev 29458)
+++ xfcalendar/trunk/src/day-view.c 2009-02-07 12:53:21 UTC (rev 29459)
@@ -564,6 +564,11 @@
{
xfical_appt *appt;
int days = 1;
+ GList *date_list, *tmp; /* recurring event times */
+ struct time_data {
+ char starttimecur[17];
+ char endtimecur[17];
+ } *time_datap;
days = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(dw->day_spin));
/* xfical_appt_get_next_on_day uses extra days so to show 7 days we need
@@ -573,7 +578,24 @@
appt;
appt = xfical_appt_get_next_on_day(a_day, FALSE, days-1
, ical_type , file_type)) {
- add_row(dw, appt, a_day, days);
+ if (appt->freq) { /* complex, need to process all events */
+ date_list = NULL;
+ xfical_process_each_app(appt, a_day, days, &date_list);
+ for (tmp = g_list_first(date_list);
+ tmp != NULL;
+ tmp = g_list_next(tmp)) {
+ time_datap = (struct time_data *)tmp->data;
+ /* Only use date since time is the same always */
+ strncpy(appt->starttimecur, time_datap->starttimecur, 8);
+ strncpy(appt->endtimecur, time_datap->endtimecur, 8);
+ add_row(dw, appt, a_day, days);
+ g_free(time_datap);
+ }
+ g_list_free(date_list);
+ }
+ else { /* simple case, only one event */
+ add_row(dw, appt, a_day, days);
+ }
xfical_appt_free(appt);
}
}
Modified: xfcalendar/trunk/src/ical-code.c
===================================================================
--- xfcalendar/trunk/src/ical-code.c 2009-02-07 07:43:49 UTC (rev 29458)
+++ xfcalendar/trunk/src/ical-code.c 2009-02-07 12:53:21 UTC (rev 29459)
@@ -1478,8 +1478,8 @@
return(ialarm);
}
-/* Add VALARM. We know we need one when we come here.
- * We also assume all alarms start and stop same time = have same trigger
+/* Add VALARM.
+ * FIXME: We assume all alarms start and stop same time = have same trigger
*/
static void appt_add_alarm_internal(xfical_appt *appt, icalcomponent *ievent)
{
@@ -1492,6 +1492,9 @@
#ifdef ORAGE_DEBUG
orage_message(-200, P_N);
#endif
+ if (appt->alarmtime == 0) { /* no alarm */
+ return;
+ }
duration = appt->alarmtime;
trg.time = icaltime_null_time();
if (appt->alarm_before)
@@ -1530,7 +1533,7 @@
}
}
-static void appt_add_recur_internal(xfical_appt *appt, icalcomponent *ievent)
+static void appt_add_recur_internal(xfical_appt *appt, icalcomponent *icmp)
{
#undef P_N
#define P_N "appt_add_recur_internal: "
@@ -1545,6 +1548,9 @@
#ifdef ORAGE_DEBUG
orage_message(-200, P_N);
#endif
+ if (appt->freq == XFICAL_FREQ_NONE) {
+ return;
+ }
recur_p = g_stpcpy(recur_str, "FREQ=");
switch(appt->freq) {
case XFICAL_FREQ_DAILY:
@@ -1624,23 +1630,162 @@
, byday_a[g_par.ical_weekstartday]);
}
rrule = icalrecurrencetype_from_string(recur_str);
- icalcomponent_add_property(ievent, icalproperty_new_rrule(rrule));
+ icalcomponent_add_property(icmp, icalproperty_new_rrule(rrule));
}
+static void appt_add_starttime_internal(xfical_appt *appt, icalcomponent *icmp)
+{
+#undef P_N
+#define P_N "appt_add_starttime_internal: "
+ struct icaltimetype wtime;
+
+#ifdef ORAGE_DEBUG
+ orage_message(-200, P_N);
+#endif
+ if (appt->allDay) { /* cut the string after Date: yyyymmdd */
+ appt->starttime[8] = '\0';
+ appt->endtime[8] = '\0';
+ }
+
+ if ORAGE_STR_EXISTS(appt->starttime) {
+ wtime=icaltime_from_string(appt->starttime);
+ if (appt->allDay) { /* date */
+ icalcomponent_add_property(icmp
+ , icalproperty_new_dtstart(wtime));
+ }
+ else if ORAGE_STR_EXISTS(appt->start_tz_loc) {
+ if (strcmp(appt->start_tz_loc, "UTC") == 0) {
+ wtime=icaltime_convert_to_zone(wtime, utc_icaltimezone);
+ icalcomponent_add_property(icmp
+ , icalproperty_new_dtstart(wtime));
+ }
+ else if (strcmp(appt->start_tz_loc, "floating") == 0) {
+ icalcomponent_add_property(icmp
+ , icalproperty_new_dtstart(wtime));
+ }
+ else {
+ /* FIXME: add this vtimezone to vcalendar if it is not there */
+ icalcomponent_add_property(icmp
+ , icalproperty_vanew_dtstart(wtime
+ , icalparameter_new_tzid(appt->start_tz_loc)
+ , 0));
+ }
+ }
+ else { /* floating time */
+ icalcomponent_add_property(icmp
+ , icalproperty_new_dtstart(wtime));
+ }
+ }
+}
+
+static void appt_add_endtime_internal(xfical_appt *appt, icalcomponent *icmp)
+{
+#undef P_N
+#define P_N "appt_add_endtime_internal: "
+ struct icaltimetype wtime;
+ gboolean end_time_done;
+ struct icaldurationtype duration;
+
+#ifdef ORAGE_DEBUG
+ orage_message(-200, P_N);
+#endif
+ if (!appt->use_due_time && (appt->type == XFICAL_TYPE_TODO)) {
+ ; /* done with due time */
+ }
+ else if (appt->use_duration) {
+ /* both event and todo can have duration */
+ duration = icaldurationtype_from_int(appt->duration);
+ icalcomponent_add_property(icmp
+ , icalproperty_new_duration(duration));
+ }
+ else if ORAGE_STR_EXISTS(appt->endtime) {
+ end_time_done = FALSE;
+ wtime = icaltime_from_string(appt->endtime);
+ if (appt->allDay) {
+ /* need to add 1 day. For example:
+ * DTSTART=20070221 & DTEND=20070223
+ * means only 21 and 22 February */
+ duration = icaldurationtype_from_int(60*60*24);
+ wtime = icaltime_add(wtime, duration);
+ }
+ else if ORAGE_STR_EXISTS(appt->end_tz_loc) {
+ /* Null == floating => no special action needed */
+ if (strcmp(appt->end_tz_loc, "UTC") == 0)
+ wtime = icaltime_convert_to_zone(wtime, utc_icaltimezone);
+ else if (strcmp(appt->end_tz_loc, "floating") != 0) {
+ /* FIXME: add this vtimezone to vcalendar if it is not there */
+ if (appt->type == XFICAL_TYPE_EVENT)
+ icalcomponent_add_property(icmp
+ , icalproperty_vanew_dtend(wtime
+ , icalparameter_new_tzid(appt->end_tz_loc)
+ , 0));
+ else if (appt->type == XFICAL_TYPE_TODO)
+ icalcomponent_add_property(icmp
+ , icalproperty_vanew_due(wtime
+ , icalparameter_new_tzid(appt->end_tz_loc)
+ , 0));
+ end_time_done = TRUE;
+ }
+ }
+ if (!end_time_done) {
+ if (appt->type == XFICAL_TYPE_EVENT)
+ icalcomponent_add_property(icmp
+ , icalproperty_new_dtend(wtime));
+ else if (appt->type == XFICAL_TYPE_TODO)
+ icalcomponent_add_property(icmp
+ , icalproperty_new_due(wtime));
+ }
+ }
+}
+
+static void appt_add_completedtime_internal(xfical_appt *appt
+ , icalcomponent *icmp)
+{
+#undef P_N
+#define P_N "appt_add_completedtime_internal: "
+ struct icaltimetype wtime;
+ icaltimezone *l_icaltimezone = NULL;
+
+#ifdef ORAGE_DEBUG
+ orage_message(-200, P_N);
+#endif
+ if (appt->type != XFICAL_TYPE_TODO) {
+ return; /* only VTODO can have completed time */
+ }
+ if (appt->completed) {
+ wtime = icaltime_from_string(appt->completedtime);
+ if ORAGE_STR_EXISTS(appt->completed_tz_loc) {
+ /* Null == floating => no special action needed */
+ if (strcmp(appt->completed_tz_loc, "floating") == 0) {
+ wtime = icaltime_convert_to_zone(wtime
+ , local_icaltimezone);
+ }
+ else if (strcmp(appt->completed_tz_loc, "UTC") != 0) {
+ /* FIXME: add this vtimezone to vcalendar if it is not there */
+ l_icaltimezone = icaltimezone_get_builtin_timezone(
+ appt->completed_tz_loc);
+ wtime = icaltime_convert_to_zone(wtime, l_icaltimezone);
+ }
+ }
+ else
+ wtime = icaltime_convert_to_zone(wtime, local_icaltimezone);
+ wtime = icaltime_convert_to_zone(wtime, utc_icaltimezone);
+ icalcomponent_add_property(icmp
+ , icalproperty_new_completed(wtime));
+ }
+}
+
static char *appt_add_internal(xfical_appt *appt, gboolean add, char *uid
, struct icaltimetype cre_time)
{
#undef P_N
#define P_N "appt_add_internal: "
icalcomponent *icmp;
- struct icaltimetype dtstamp, create_time, wtime;
- gboolean end_time_done;
+ struct icaltimetype dtstamp, create_time;
gchar *int_uid, *ext_uid;
gchar **tmp_cat;
- struct icaldurationtype duration;
int i;
icalcomponent_kind ikind = ICAL_VEVENT_COMPONENT;
- icaltimezone *l_icaltimezone = NULL;
#ifdef ORAGE_DEBUG
orage_message(-200, P_N);
@@ -1699,92 +1844,14 @@
}
g_strfreev(tmp_cat);
}
- if (appt->allDay) { /* cut the string after Date: yyyymmdd */
- appt->starttime[8] = '\0';
- appt->endtime[8] = '\0';
- }
+ appt_add_starttime_internal(appt, icmp);
- if ORAGE_STR_EXISTS(appt->starttime) {
- wtime=icaltime_from_string(appt->starttime);
- if (appt->allDay) { /* date */
- icalcomponent_add_property(icmp
- , icalproperty_new_dtstart(wtime));
- }
- else if ORAGE_STR_EXISTS(appt->start_tz_loc) {
- if (strcmp(appt->start_tz_loc, "UTC") == 0) {
- wtime=icaltime_convert_to_zone(wtime, utc_icaltimezone);
- icalcomponent_add_property(icmp
- , icalproperty_new_dtstart(wtime));
- }
- else if (strcmp(appt->start_tz_loc, "floating") == 0) {
- icalcomponent_add_property(icmp
- , icalproperty_new_dtstart(wtime));
- }
- else {
- /* FIXME: add this vtimezone to vcalendar if it is not there */
- icalcomponent_add_property(icmp
- , icalproperty_vanew_dtstart(wtime
- , icalparameter_new_tzid(appt->start_tz_loc)
- , 0));
- }
- }
- else { /* floating time */
- icalcomponent_add_property(icmp
- , icalproperty_new_dtstart(wtime));
- }
- }
-
if (appt->type != XFICAL_TYPE_JOURNAL) {
/* journal has no duration nor enddate or due
* journal also has no priority or transparent setting
* journal also has not alarms or repeat settings */
- if (!appt->use_due_time && (appt->type == XFICAL_TYPE_TODO)) {
- ; /* done with due time */
- }
- else if (appt->use_duration) {
- /* both event and todo can have duration */
- duration = icaldurationtype_from_int(appt->duration);
- icalcomponent_add_property(icmp
- , icalproperty_new_duration(duration));
- }
- else if ORAGE_STR_EXISTS(appt->endtime) {
- end_time_done = FALSE;
- wtime = icaltime_from_string(appt->endtime);
- if (appt->allDay) {
- /* need to add 1 day. For example:
- * DTSTART=20070221 & DTEND=20070223
- * means only 21 and 22 February */
- duration = icaldurationtype_from_int(60*60*24);
- wtime = icaltime_add(wtime, duration);
- }
- else if ORAGE_STR_EXISTS(appt->end_tz_loc) {
- /* Null == floating => no special action needed */
- if (strcmp(appt->end_tz_loc, "UTC") == 0)
- wtime = icaltime_convert_to_zone(wtime, utc_icaltimezone);
- else if (strcmp(appt->end_tz_loc, "floating") != 0) {
- /* FIXME: add this vtimezone to vcalendar if it is not there */
- if (appt->type == XFICAL_TYPE_EVENT)
- icalcomponent_add_property(icmp
- , icalproperty_vanew_dtend(wtime
- , icalparameter_new_tzid(appt->end_tz_loc)
- , 0));
- else if (appt->type == XFICAL_TYPE_TODO)
- icalcomponent_add_property(icmp
- , icalproperty_vanew_due(wtime
- , icalparameter_new_tzid(appt->end_tz_loc)
- , 0));
- end_time_done = TRUE;
- }
- }
- if (!end_time_done) {
- if (appt->type == XFICAL_TYPE_EVENT)
- icalcomponent_add_property(icmp
- , icalproperty_new_dtend(wtime));
- else if (appt->type == XFICAL_TYPE_TODO)
- icalcomponent_add_property(icmp
- , icalproperty_new_due(wtime));
- }
- }
+ appt_add_endtime_internal(appt, icmp);
+ appt_add_completedtime_internal(appt, icmp);
if (appt->priority != 0)
icalcomponent_add_property(icmp
@@ -1797,38 +1864,11 @@
icalcomponent_add_property(icmp
, icalproperty_new_transp(ICAL_TRANSP_OPAQUE));
}
- else if (appt->type == XFICAL_TYPE_TODO) {
- if (appt->completed) {
- wtime = icaltime_from_string(appt->completedtime);
- if ORAGE_STR_EXISTS(appt->completed_tz_loc) {
- /* Null == floating => no special action needed */
- if (strcmp(appt->completed_tz_loc, "floating") == 0) {
- wtime = icaltime_convert_to_zone(wtime
- , local_icaltimezone);
- }
- else if (strcmp(appt->completed_tz_loc, "UTC") != 0) {
- /* FIXME: add this vtimezone to vcalendar if it is not there */
- l_icaltimezone = icaltimezone_get_builtin_timezone(
- appt->start_tz_loc);
- wtime = icaltime_convert_to_zone(wtime, l_icaltimezone);
- }
- }
- else
- wtime = icaltime_convert_to_zone(wtime, local_icaltimezone);
- wtime = icaltime_convert_to_zone(wtime, utc_icaltimezone);
- icalcomponent_add_property(icmp
- , icalproperty_new_completed(wtime));
- }
- }
- if (appt->freq != XFICAL_FREQ_NONE) {
- /* NOTE: according to standard VJOURNAL _has_ recurrency,
- * but I can't understand how it could be usefull,
- * so Orage takes it away */
- appt_add_recur_internal(appt, icmp);
- }
- if (appt->alarmtime != 0) {
- appt_add_alarm_internal(appt, icmp);
- }
+ /* NOTE: according to standard VJOURNAL _has_ recurrency,
+ * but I can't understand how it could be usefull,
+ * so Orage takes it away */
+ appt_add_recur_internal(appt, icmp);
+ appt_add_alarm_internal(appt, icmp);
}
if (ext_uid[0] == 'O') {
@@ -2601,7 +2641,7 @@
* Caller is responsible for filling and allocating and freeing it.
* returns: TRUE is successfull, FALSE if failed
*/
-gboolean xfical_appt_mod(char *ical_uid, xfical_appt *app)
+gboolean xfical_appt_mod(char *ical_uid, xfical_appt *appt)
{
#undef P_N
#define P_N "xfical_appt_mod: "
@@ -2656,7 +2696,7 @@
return(FALSE);
}
- appt_add_internal(app, FALSE, ical_uid, create_time);
+ appt_add_internal(appt, FALSE, ical_uid, create_time);
return(TRUE);
}
@@ -2756,7 +2796,7 @@
xfical_period per;
struct icaltimetype alarm_time, next_time;
gboolean trg_active = FALSE;
- alarm_struct *new_alarm;;
+ alarm_struct *new_alarm;
#ifdef ORAGE_DEBUG
orage_message(-200, P_N);
@@ -3074,7 +3114,7 @@
/* Read next EVENT/TODO/JOURNAL component on the specified date from
* ical datafile.
* a_day: start date of ical component which is to be read
- * first: get first appointment is TRUE, if not get next.
+ * first: get first appointment if TRUE, if not get next.
* days: how many more days to check forward. 0 = only one day
* type: EVENT/TODO/JOURNAL to be read
* returns: NULL if failed and xfical_appt pointer to xfical_appt struct
@@ -3092,7 +3132,7 @@
, nsdate, nedate; /* repeating event occurrency start and end */
xfical_period per; /* event start and end times with duration */
icalcomponent *c=NULL;
- icalproperty *p = NULL;
+ icalproperty *p=NULL;
static icalcompiter ci;
gboolean date_found=FALSE;
gboolean recurrent_date_found=FALSE;
@@ -3312,7 +3352,7 @@
return(marked);
}
- /* Mark days with appointments into calendar
+ /* Mark days from appointment c into calendar
* year: Year to be searched
* month: Month to be searched
*/
@@ -3414,7 +3454,69 @@
xfical_mark_calendar_internal(gtkcal, f_ical[i].ical, year, month+1);
}
}
+/* FIXME: seems like this does not understand timezones, but returns
+ * always raw time */
+void process_one_app(icalcomponent *comp, struct icaltime_span *span
+ , void *data)
+{
+#undef P_N
+#define P_N "process_one_app: "
+ time_t start, end;
+ struct tm start_tm, end_tm;
+ char start_s[40], end_s[40];
+ struct time_data {
+ char starttimecur[17];
+ char endtimecur[17];
+ } *time_datap;
+ GList **list;
+#ifdef ORAGE_DEBUG
+ orage_message(-100, P_N);
+#endif
+ list = (GList **)data;
+ start = span->start;
+ end = span->end;
+ gmtime_r(&start, &start_tm);
+ gmtime_r(&end, &end_tm);
+ time_datap = g_new0(struct time_data, 1);
+ strcpy(time_datap->starttimecur, orage_tm_time_to_icaltime(&start_tm));
+ strcpy(time_datap->endtimecur, orage_tm_time_to_icaltime(&end_tm));
+ *list = g_list_prepend(*list, time_datap);
+/*
+ * g_print("callme: Start:%s End:%s \n"
+ * , time_datap->starttimecur, time_datap->endtimecur);
+ */
+}
+
+void xfical_process_each_app(xfical_appt *appt, char *a_day, int days
+ , GList **data)
+{
+#undef P_N
+#define P_N "xfical_process_each_app: "
+ icalcomponent_kind ikind = ICAL_VEVENT_COMPONENT;
+ icalcomponent *icmp;
+ struct icaltimetype asdate, aedate;
+
+#ifdef ORAGE_DEBUG
+ orage_message(-100, P_N);
+#endif
+ icmp = icalcomponent_vanew(ikind
+ , icalproperty_new_uid("RECUR_TEST")
+ , NULL);
+ appt_add_starttime_internal(appt, icmp);
+ appt_add_endtime_internal(appt, icmp);
+ appt_add_recur_internal(appt, icmp);
+
+ asdate = icaltime_from_string(a_day);
+ aedate = asdate;
+ if (days)
+ icaltime_adjust(&aedate, days, 0, 0, 0);
+
+ icalcomponent_foreach_recurrence(icmp, asdate, aedate, process_one_app
+ , (void *)data);
+ icalcomponent_free(icmp);
+}
+
#ifdef HAVE_ARCHIVE
static void xfical_icalcomponent_archive_normal(icalcomponent *e)
{
Modified: xfcalendar/trunk/src/ical-code.h
===================================================================
--- xfcalendar/trunk/src/ical-code.h 2009-02-07 07:43:49 UTC (rev 29458)
+++ xfcalendar/trunk/src/ical-code.h 2009-02-07 12:53:21 UTC (rev 29459)
@@ -117,7 +117,8 @@
gint recur_count;
gchar recur_until[17];
gboolean recur_byday[7]; /* 0=Mo, 1=Tu, 2=We, 3=Th, 4=Fr, 5=Sa, 6=Su */
- gint recur_byday_cnt[7]; /* monthly/early: 1=first -1=last 2=second... */ gint interval; /* 1=every day/week..., 2=every second day/week,... */
+ gint recur_byday_cnt[7]; /* monthly/early: 1=first -1=last 2=second... */
+ gint interval; /* 1=every day/week..., 2=every second day/week,... */
} xfical_appt;
gboolean xfical_set_local_timezone(gboolean testing);
@@ -127,22 +128,22 @@
void xfical_file_close_force(void);
xfical_appt *xfical_appt_alloc();
-char *xfical_appt_add(xfical_appt *app);
+char *xfical_appt_add(xfical_appt *appt);
xfical_appt *xfical_appt_get(char *ical_id);
void xfical_appt_free(xfical_appt *appt);
-gboolean xfical_appt_mod(char *ical_id, xfical_appt *app);
+gboolean xfical_appt_mod(char *ical_id, xfical_appt *appt);
gboolean xfical_appt_del(char *ical_id);
xfical_appt *xfical_appt_get_next_on_day(char *a_day, gboolean first, gint days
, xfical_type type, gchar *file_type);
xfical_appt *xfical_appt_get_next_with_string(char *str, gboolean first
, gchar *file_type);
+void xfical_process_each_app(xfical_appt *appt, char *a_day, int days
+ , GList **data);
void xfical_mark_calendar(GtkCalendar *gtkcal);
void xfical_alarm_build_list(gboolean first_list_today);
-gboolean xfical_alarm_passed(char *alarm_stime);
-gboolean xfical_duration(char *alarm_stime, int *days, int *hours, int *mins);
int xfical_compare_times(xfical_appt *appt);
#ifdef HAVE_ARCHIVE
gboolean xfical_archive_open(void);
More information about the Xfce4-commits
mailing list