aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--calendar/ChangeLog10
-rw-r--r--calendar/Makefile.am23
-rw-r--r--calendar/alarm.h2
-rw-r--r--calendar/cal-client/Makefile.am15
-rw-r--r--calendar/cal-util/Makefile.am21
-rw-r--r--calendar/cal-util/cal-util.c (renamed from calendar/cal-client/cal-util.c)0
-rw-r--r--calendar/cal-util/cal-util.h (renamed from calendar/cal-client/cal-util.h)0
-rw-r--r--calendar/cal-util/icalendar.c (renamed from calendar/icalendar.c)2
-rw-r--r--calendar/cal-util/icalendar.h (renamed from calendar/icalendar.h)0
-rw-r--r--calendar/cal-util/timeutil.c (renamed from calendar/timeutil.c)0
-rw-r--r--calendar/cal-util/timeutil.h (renamed from calendar/timeutil.h)0
-rw-r--r--calendar/calendar.c2
-rw-r--r--calendar/calendar.h2
-rw-r--r--calendar/calobj.c1608
-rw-r--r--calendar/calobj.h263
-rw-r--r--calendar/corba-cal-factory.c4
-rw-r--r--calendar/corba-cal.c4
-rw-r--r--calendar/eventedit.c2
-rw-r--r--calendar/gncal-day-panel.c2
-rw-r--r--calendar/gncal-day-view.c2
-rw-r--r--calendar/gncal-week-view.c2
-rw-r--r--calendar/gnome-cal.c2
-rw-r--r--calendar/goto.c2
-rw-r--r--calendar/gui/Makefile.am23
-rw-r--r--calendar/gui/alarm-notify/alarm.h2
-rw-r--r--calendar/gui/alarm.h2
-rw-r--r--calendar/gui/calendar.c2
-rw-r--r--calendar/gui/calendar.h2
-rw-r--r--calendar/gui/corba-cal-factory.c4
-rw-r--r--calendar/gui/corba-cal.c4
-rw-r--r--calendar/gui/eventedit.c2
-rw-r--r--calendar/gui/gncal-day-panel.c2
-rw-r--r--calendar/gui/gncal-day-view.c2
-rw-r--r--calendar/gui/gncal-week-view.c2
-rw-r--r--calendar/gui/gnome-cal.c2
-rw-r--r--calendar/gui/goto.c2
-rw-r--r--calendar/gui/main.c2
-rw-r--r--calendar/gui/mark.c2
-rw-r--r--calendar/gui/month-view.c2
-rw-r--r--calendar/gui/year-view.c2
-rw-r--r--calendar/main.c2
-rw-r--r--calendar/mark.c2
-rw-r--r--calendar/month-view.c2
-rw-r--r--calendar/pcs/Makefile.am52
-rw-r--r--calendar/pcs/icalendar.c657
-rw-r--r--calendar/pcs/icalendar.h13
-rw-r--r--calendar/year-view.c2
47 files changed, 806 insertions, 1951 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index b3a7f6dc73..a6a390842f 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,13 @@
+2000-03-03 Seth Alves <alves@hungry.com>
+
+ * cal-util/Makefile.am: new file -- things shared between
+ the client and server go in this directory
+
+ * calobj.c calobj.h icalendar.c icalendar.h
+ timeutil.c timeutil.h cal-util.c cal-util.h where moved
+ backend stuff went into pcs. shared stuff went into
+ cal-util.
+
2000-03-02 Federico Mena Quintero <federico@helixcode.com>
At this point the calendar client and personal calendar server
diff --git a/calendar/Makefile.am b/calendar/Makefile.am
index d9001476a4..40e1357a62 100644
--- a/calendar/Makefile.am
+++ b/calendar/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = doc idl pcs cal-client
+SUBDIRS = doc idl cal-util pcs cal-client
idldir = $(datadir)/idl
idl_DATA = \
@@ -27,7 +27,8 @@ INCLUDES = \
$(BONOBO_VFS_GNOME_CFLAGS) \
$(GNOME_CONDUIT_INCLUDEDIR) \
$(PISOCK_INCLUDEDIR) \
- -I../libical/src/libical \
+ -I$(top_srcdir) \
+ -I$(top_srcdir)/libical/src/libical \
-DGNOMELOCALEDIR=\""$(datadir)/locale"\"
GNOMECAL_CORBA_GENERATED = \
@@ -51,11 +52,7 @@ gnomecal_SOURCES = \
GnomeCal.h \
alarm.c \
alarm.h \
- calendar.c \
- calendar.h \
calendar-conduit.h \
- calobj.c \
- calobj.h \
eventedit.c \
eventedit.h \
corba-cal.c \
@@ -78,8 +75,6 @@ gnomecal_SOURCES = \
gnome-cal.c \
gnome-cal.h \
goto.c \
- icalendar.c \
- icalendar.h \
layout.c \
layout.h \
main.c \
@@ -93,14 +88,21 @@ gnomecal_SOURCES = \
prop.c \
quick-view.c \
quick-view.h \
- timeutil.c \
- timeutil.h \
todo-conduit.h \
view-utils.h \
view-utils.c \
year-view.c \
year-view.h
+# calendar.c \
+# calendar.h \
+# calobj.c \
+# calobj.h \
+# icalendar.c \
+# icalendar.h \
+# timeutil.c \
+# timeutil.h \
+
calendar_pilot_sync_SOURCES = \
GnomeCal-common.c \
GnomeCal-stubs.c \
@@ -116,6 +118,7 @@ calendar_pilot_sync_SOURCES = \
LINK_FLAGS = \
$(BONOBO_VFS_GNOME_LIBS) \
$(INTLLIBS) \
+ cal-util/libcalutil.la \
../libversit/libversit.la \
$(ICAL_LINK_FLAGS)
diff --git a/calendar/alarm.h b/calendar/alarm.h
index 2dc77e623b..6bb5c1afa5 100644
--- a/calendar/alarm.h
+++ b/calendar/alarm.h
@@ -2,7 +2,7 @@
#define ALARM_H
#include <time.h>
-#include "calobj.h"
+#include "pcs/calobj.h"
typedef void (*AlarmFunction)(time_t time, CalendarAlarm *which, void *closuse);
diff --git a/calendar/cal-client/Makefile.am b/calendar/cal-client/Makefile.am
index 71e914c5fb..00b66147b7 100644
--- a/calendar/cal-client/Makefile.am
+++ b/calendar/cal-client/Makefile.am
@@ -19,6 +19,7 @@ $(CORBA_GENERATED): $(idls)
INCLUDES = \
-DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
-DG_LOG_DOMAIN=\"cal-client\" \
+ -I$(top_srcdir)/calendar/cal-util \
-I$(srcdir) -I$(top_srcdir) \
-I. \
-I.. \
@@ -34,12 +35,11 @@ libcal_client_la_SOURCES = \
$(CORBA_GENERATED) \
cal-client.c \
cal-listener.c \
- cal-listener.h \
- cal-util.c
+ cal-listener.h
libcal_clientinclude_HEADERS = \
- cal-client.h \
- cal-util.h
+ cal-client.h
+
#
# client-test program
@@ -54,7 +54,8 @@ client_test_INCLUDES = \
$(INCLUDES) \
-DG_LOG_DOMAIN=\"client-test\"
-client_test_LDADD = \
- $(BONOBO_VFS_GNOME_LIBS) \
- $(top_builddir)/libversit/libversit.la \
+client_test_LDADD = \
+ $(BONOBO_VFS_GNOME_LIBS) \
+ $(top_builddir)/libversit/libversit.la \
+ $(top_srcdir)/calendar/cal-util/libcalutil.la \
libcal-client.la
diff --git a/calendar/cal-util/Makefile.am b/calendar/cal-util/Makefile.am
new file mode 100644
index 0000000000..c22c0f1948
--- /dev/null
+++ b/calendar/cal-util/Makefile.am
@@ -0,0 +1,21 @@
+
+
+#INCLUDES = \
+# -DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
+# -DG_LOG_DOMAIN=\"cal-client\" \
+# -I$(srcdir) -I$(top_srcdir) \
+# -I. \
+# -I.. \
+# -I$(top_builddir) \
+# -I$(includedir) \
+# $(GNOME_INCLUDEDIR)
+
+
+lib_LTLIBRARIES = libcalutil.la
+
+libcalutil_la_SOURCES = \
+ cal-util.c \
+ cal-util.h \
+ timeutil.c \
+ timeutil.h
+
diff --git a/calendar/cal-client/cal-util.c b/calendar/cal-util/cal-util.c
index f3054af958..f3054af958 100644
--- a/calendar/cal-client/cal-util.c
+++ b/calendar/cal-util/cal-util.c
diff --git a/calendar/cal-client/cal-util.h b/calendar/cal-util/cal-util.h
index 5087eee4d3..5087eee4d3 100644
--- a/calendar/cal-client/cal-util.h
+++ b/calendar/cal-util/cal-util.h
diff --git a/calendar/icalendar.c b/calendar/cal-util/icalendar.c
index af4f2ca83b..0a0f39c636 100644
--- a/calendar/icalendar.c
+++ b/calendar/cal-util/icalendar.c
@@ -144,7 +144,7 @@ ical_object_create_from_icalcomponent (icalcomponent* comp)
copy_str (&ical->class, icalproperty_get_class (prop));
break;
case ICAL_COMMENT_PROPERTY:
- tmpStr = icalproperty_get_comment (prop);
+ /*tmpStr = icalproperty_get_comment (prop);*/
tmpStr = g_strconcat (icalproperty_get_comment (prop),
ical->comment,
NULL);
diff --git a/calendar/icalendar.h b/calendar/cal-util/icalendar.h
index 09bfa06fad..09bfa06fad 100644
--- a/calendar/icalendar.h
+++ b/calendar/cal-util/icalendar.h
diff --git a/calendar/timeutil.c b/calendar/cal-util/timeutil.c
index 7ddc0e04d4..7ddc0e04d4 100644
--- a/calendar/timeutil.c
+++ b/calendar/cal-util/timeutil.c
diff --git a/calendar/timeutil.h b/calendar/cal-util/timeutil.h
index 407213d7f8..407213d7f8 100644
--- a/calendar/timeutil.h
+++ b/calendar/cal-util/timeutil.h
diff --git a/calendar/calendar.c b/calendar/calendar.c
index 172ef3390e..776f38452d 100644
--- a/calendar/calendar.c
+++ b/calendar/calendar.c
@@ -20,7 +20,7 @@
#include "calendar.h"
#include "alarm.h"
#include "timeutil.h"
-#include "../libversit/vcc.h"
+#include "libversit/vcc.h"
#include "icalendar.h"
#ifdef HAVE_TZNAME
diff --git a/calendar/calendar.h b/calendar/calendar.h
index 23fa65c094..83a5f67c84 100644
--- a/calendar/calendar.h
+++ b/calendar/calendar.h
@@ -1,7 +1,7 @@
#ifndef CALENDAR_H
#define CALENDAR_H
-#include "calobj.h"
+#include "pcs/calobj.h"
BEGIN_GNOME_DECLS
diff --git a/calendar/calobj.c b/calendar/calobj.c
deleted file mode 100644
index ce0d330303..0000000000
--- a/calendar/calobj.c
+++ /dev/null
@@ -1,1608 +0,0 @@
-/*
- * Calendar objects implementations.
- * Copyright (C) 1998 the Free Software Foundation
- *
- * Authors:
- * Miguel de Icaza (miguel@gnu.org)
- * Federico Mena (quartic@gimp.org)
- */
-#include <config.h>
-#include <string.h>
-#include <glib.h>
-#include <ctype.h>
-#include <unistd.h>
-#include "calobj.h"
-#include "timeutil.h"
-#include "../libversit/vcc.h"
-
-extern CalendarAlarm alarm_defaults[4];
-
-static char *
-ical_gen_uid (void)
-{
- static char *hostname;
- time_t t = time (NULL);
- static int serial;
-
- if (!hostname){
- char buffer [128];
-
- if ((gethostname (buffer, sizeof (buffer)-1) == 0) &&
- (buffer [0] != 0))
- hostname = g_strdup (buffer);
- else
- hostname = g_strdup ("localhost");
- }
-
- return g_strdup_printf (
- "%s-%d-%d-%d-%d@%s",
- isodate_from_time_t (t),
- getpid (),
- getgid (),
- getppid (),
- serial++,
- hostname);
-}
-
-iCalObject *
-ical_object_new (void)
-{
- iCalObject *ico;
-
- ico = g_new0 (iCalObject, 1);
-
- ico->seq = -1;
- ico->dtstamp = time (NULL);
- ico->uid = ical_gen_uid ();
-
- ico->pilot_id = 0;
- ico->pilot_status = ICAL_PILOT_SYNC_MOD;
-
- return ico;
-}
-
-static void
-default_alarm (iCalObject *ical, CalendarAlarm *alarm, char *def_mail, enum AlarmType type)
-{
- alarm->type = type;
- alarm->enabled = alarm_defaults[type].enabled;
- alarm->count = alarm_defaults[type].count;
- alarm->units = alarm_defaults[type].units;
- if (alarm_defaults[type].data)
- alarm->data = g_strdup (alarm_defaults[type].data);
- else
- alarm->data = g_strdup ("");
-}
-
-iCalObject *
-ical_new (char *comment, char *organizer, char *summary)
-{
- iCalObject *ico;
-
- ico = ical_object_new ();
-
- ico->comment = g_strdup (comment);
- ico->organizer = g_new0 (iCalPerson, 1);
- ico->organizer->addr = g_strdup (organizer);
- ico->summary = g_strdup (summary);
- ico->class = g_strdup ("PUBLIC");
- ico->status = g_strdup ("NEEDS ACTION");
-
- default_alarm (ico, &ico->dalarm, organizer, ALARM_DISPLAY);
- default_alarm (ico, &ico->palarm, organizer, ALARM_PROGRAM);
- default_alarm (ico, &ico->malarm, organizer, ALARM_MAIL);
- default_alarm (ico, &ico->aalarm, organizer, ALARM_AUDIO);
-
- return ico;
-}
-
-static void
-my_free (gpointer data, gpointer user_dat_ignored)
-{
- g_free (data);
-}
-
-static void
-list_free (GList *list)
-{
- g_list_foreach (list, my_free, 0);
- g_list_free (list);
-}
-
-#define free_if_defined(x) if (x){ g_free (x); x = 0; }
-#define lfree_if_defined(x) if (x){ list_free (x); x = 0; }
-void
-ical_object_destroy (iCalObject *ico)
-{
- /* Regular strings */
- free_if_defined (ico->comment);
- free_if_defined (ico->organizer);
- free_if_defined (ico->summary);
- free_if_defined (ico->uid);
- free_if_defined (ico->status);
- free_if_defined (ico->class);
- free_if_defined (ico->url);
- free_if_defined (ico->recur);
-
- /* Lists */
- lfree_if_defined (ico->exdate);
- lfree_if_defined (ico->categories);
- lfree_if_defined (ico->resources);
- lfree_if_defined (ico->related);
- lfree_if_defined (ico->attach);
-
- /* Alarms */
- g_free (ico->dalarm.data);
- g_free (ico->palarm.data);
- g_free (ico->malarm.data);
- g_free (ico->aalarm.data);
-
- g_free (ico);
-}
-
-static GList *
-set_list (char *str)
-{
- GList *list = 0;
- char *s;
-
- for (s = strtok (str, ";"); s; s = strtok (NULL, ";"))
- list = g_list_prepend (list, g_strdup (s));
-
- return list;
-}
-
-static GList *
-set_date_list (char *str)
-{
- GList *list = 0;
- char *s;
-
- for (s = strtok (str, ";,"); s; s = strtok (NULL, ";,")){
- time_t *t = g_new (time_t, 1);
-
- while (*s && isspace (*s))
- s++;
- *t = time_from_isodate (s);
- list = g_list_prepend (list, t);
- }
- return list;
-}
-
-void
-ical_object_add_exdate (iCalObject *o, time_t t)
-{
- time_t *pt = g_new (time_t, 1);
-
- *pt = t;
- o->exdate = g_list_prepend (o->exdate, pt);
-}
-
-static void
-ignore_space(char **str)
-{
- while (**str && isspace (**str))
- (*str)++;
-}
-
-static void
-skip_numbers (char **str)
-{
- while (**str){
- ignore_space (str);
- if (!isdigit (**str))
- return;
- while (**str && isdigit (**str))
- (*str)++;
- }
-}
-
-static void
-weekdaylist (iCalObject *o, char **str)
-{
- int i;
- struct {
- char first_letter, second_letter;
- int index;
- } days [] = {
- { 'S', 'U', 0 },
- { 'M', 'O', 1 },
- { 'T', 'U', 2 },
- { 'W', 'E', 3 },
- { 'T', 'H', 4 },
- { 'F', 'R', 5 },
- { 'S', 'A', 6 }
- };
-
- ignore_space (str);
- do {
- for (i = 0; i < 7; i++){
- if (**str == days [i].first_letter && *(*str+1) == days [i].second_letter){
- o->recur->weekday |= 1 << i;
- *str += 2;
- if (**str == ' ')
- (*str)++;
- }
- }
- } while (isalpha (**str));
-
- if (o->recur->weekday == 0){
- struct tm tm = *localtime (&o->dtstart);
-
- o->recur->weekday = 1 << tm.tm_wday;
- }
-}
-
-static void
-weekdaynum (iCalObject *o, char **str)
-{
- int i;
- struct {
- char first_letter, second_letter;
- int index;
- } days [] = {
- { 'S', 'U', 0 },
- { 'M', 'O', 1 },
- { 'T', 'U', 2 },
- { 'W', 'E', 3 },
- { 'T', 'H', 4 },
- { 'F', 'R', 5 },
- { 'S', 'A', 6 }
- };
-
- ignore_space (str);
- do {
- for (i = 0; i < 7; i++){
- if (**str == days [i].first_letter && *(*str+1) == days [i].second_letter){
- o->recur->weekday = i;
- *str += 2;
- if (**str == ' ')
- (*str)++;
- }
- }
- } while (isalpha (**str));
-}
-
-static void
-ocurrencelist (iCalObject *o, char **str)
-{
- char *p;
-
- ignore_space (str);
- p = *str;
- if (!isdigit (*p))
- return;
-
- if (!(*p >= '1' && *p <= '5'))
- return;
-
- if (!(*(p+1) == '+' || *(p+1) == '-'))
- return;
-
- o->recur->u.month_pos = (*p-'0') * (*(p+1) == '+' ? 1 : -1);
- *str += 2;
-}
-
-#if 0
-
-static void
-daynumber (iCalObject *o, char **str)
-{
- int val = 0;
- char *p = *str;
-
- ignore_space (str);
- if (strcmp (p, "LD")){
- o->recur->u.month_day = DAY_LASTDAY;
- *str += 2;
- return;
- }
-
- if (!(isdigit (*p)))
- return;
-
- while (**str && isdigit (**str)){
- val = val * 10 + (**str - '0');
- (*str)++;
- }
-
- if (**str == '+')
- (*str)++;
-
- if (**str == '-')
- val *= -1;
- o->recur->u.month_day = val;
-}
-
-#endif
-
-static void
-daynumberlist (iCalObject *o, char **str)
-{
- int first = 0;
- int val = 0;
-
- ignore_space (str);
-
- while (**str){
- if (!isdigit (**str))
- return;
- while (**str && isdigit (**str)){
- val = 10 * val + (**str - '0');
- (*str)++;
- }
- if (!first){
- /*
- * Some broken applications set this to zero
- */
- if (val == 0){
- struct tm day = *localtime (&o->dtstart);
-
- val = day.tm_mday;
- }
- o->recur->u.month_day = val;
- first = 1;
- val = 0;
- }
- }
-}
-
-static void
-load_recur_weekly (iCalObject *o, char **str)
-{
- weekdaylist (o, str);
-}
-
-static void
-load_recur_monthly_pos (iCalObject *o, char **str)
-{
- ocurrencelist (o, str);
- weekdaynum (o, str);
-}
-
-static void
-load_recur_monthly_day (iCalObject *o, char **str)
-{
- daynumberlist (o, str);
-}
-
-static void
-load_recur_yearly_month (iCalObject *o, char **str)
-{
- /* Skip as we do not support multiple months and we do expect
- * the dtstart to agree with the value on this field
- */
- skip_numbers (str);
-}
-
-static void
-load_recur_yearly_day (iCalObject *o, char **str)
-{
- /* Skip as we do not support multiple days and we do expect
- * the dtstart to agree with the value on this field
- *
- * FIXME: we should support every-n-years
- */
- skip_numbers (str);
-}
-
-static void
-duration (iCalObject *o, char **str)
-{
- unsigned int duration = 0;
-
- ignore_space (str);
- if (**str != '#')
- return;
- (*str)++;
- while (**str && isdigit (**str)){
- duration = duration * 10 + (**str - '0');
- (*str)++;
- }
- o->recur->duration = duration;
-}
-
-static void
-enddate (iCalObject *o, char **str)
-{
- ignore_space (str);
- if (isdigit (**str)){
- o->recur->_enddate = time_from_isodate (*str);
- *str += 16;
- }
-}
-
-static int
-load_recurrence (iCalObject *o, char *str)
-{
- enum RecurType type;
- int interval = 0;
-
- type = -1;
- switch (*str++){
- case 'D':
- type = RECUR_DAILY;
- break;
-
- case 'W':
- type = RECUR_WEEKLY;
- break;
-
- case 'M':
- if (*str == 'P')
- type = RECUR_MONTHLY_BY_POS;
- else if (*str == 'D')
- type = RECUR_MONTHLY_BY_DAY;
- str++;
- break;
-
- case 'Y':
- if (*str == 'M')
- type = RECUR_YEARLY_BY_MONTH;
- else if (*str == 'D')
- type = RECUR_YEARLY_BY_DAY;
- str++;
- break;
- }
- if (type == -1)
- return 0;
-
- o->recur = g_new0 (Recurrence, 1);
- o->recur->type = type;
- ignore_space (&str);
-
- /* Get the interval */
- for (;*str && isdigit (*str);str++)
- interval = interval * 10 + (*str-'0');
-
- if (interval == 0)
- interval = 1;
-
- o->recur->interval = interval;
-
- /* this is the default per the spec */
- o->recur->duration = 2;
-
- ignore_space (&str);
-
- switch (type){
- case RECUR_DAILY:
- break;
- case RECUR_WEEKLY:
- load_recur_weekly (o, &str);
- break;
- case RECUR_MONTHLY_BY_POS:
- load_recur_monthly_pos (o, &str);
- break;
- case RECUR_MONTHLY_BY_DAY:
- load_recur_monthly_day (o, &str);
- break;
- case RECUR_YEARLY_BY_MONTH:
- load_recur_yearly_month (o, &str);
- break;
- case RECUR_YEARLY_BY_DAY:
- load_recur_yearly_day (o, &str);
- break;
- default:
- g_warning ("Unimplemented recurrence type %d", (int) type);
- break;
- }
- duration (o, &str);
- enddate (o, &str);
-
- /* Compute the enddate */
- if (o->recur->_enddate == 0){
- if (o->recur->duration != 0){
- ical_object_compute_end (o);
- } else
- o->recur->enddate = 0;
- } else {
- o->recur->enddate = o->recur->_enddate;
- }
- return 1;
-}
-
-#define is_a_prop_of(obj,prop) isAPropertyOf (obj,prop)
-#define str_val(obj) the_str = fakeCString (vObjectUStringZValue (obj))
-#define has(obj,prop) (vo = isAPropertyOf (obj, prop))
-
-/*
- * FIXME: This is loosing precission. Enhanec the thresholds
- */
-#define HOURS(n) (n*(60*60))
-
-static void
-setup_alarm_at (iCalObject *ico, CalendarAlarm *alarm, char *iso_time, VObject *vo)
-{
- time_t alarm_time = time_from_isodate (iso_time);
- time_t base = ico->dtstart;
- int d = difftime (base, alarm_time);
- VObject *a;
- char *the_str;
-
- alarm->enabled = 1;
- if (d > HOURS (2)){
- if (d > HOURS (48)){
- alarm->count = d / HOURS (24);
- alarm->units = ALARM_DAYS;
- } else {
- alarm->count = d / (60*60);
- alarm->units = ALARM_HOURS;
- }
- } else {
- alarm->count = d / 60;
- alarm->units = ALARM_MINUTES;
- }
-
- if ((a = is_a_prop_of (vo, VCSnoozeTimeProp))){
- alarm->snooze_secs = isodiff_to_secs (str_val (a));
- free (the_str);
- }
-
- if ((a = is_a_prop_of (vo, VCRepeatCountProp))){
- alarm->snooze_repeat = atoi (str_val (a));
- free (the_str);
- }
-}
-
-/*
- * Duplicates an iCalObject. Implementation is a grand hack
- */
-iCalObject *
-ical_object_duplicate (iCalObject *o)
-{
- VObject *vo;
- iCalObject *new;
-
- /* FIXME!!!!! The UID needs to change!!! */
-
- vo = ical_object_to_vobject (o);
- switch (o->type){
- case ICAL_EVENT:
- new = ical_object_create_from_vobject (vo, VCEventProp);
- break;
- case ICAL_TODO:
- new = ical_object_create_from_vobject (vo, VCTodoProp);
- break;
- default:
- new = NULL;
- }
-
- cleanVObject (vo);
- return new;
-}
-
-/* FIXME: we need to load the recurrence properties */
-iCalObject *
-ical_object_create_from_vobject (VObject *o, const char *object_name)
-{
- time_t now = time (NULL);
- iCalObject *ical;
- VObject *vo, *a;
- VObjectIterator i;
- char *the_str;
-
- ical = g_new0 (iCalObject, 1);
-
- if (strcmp (object_name, VCEventProp) == 0)
- ical->type = ICAL_EVENT;
- else if (strcmp (object_name, VCTodoProp) == 0)
- ical->type = ICAL_TODO;
- else {
- g_free (ical);
- return 0;
- }
-
- /* uid */
- if (has (o, VCUniqueStringProp)){
- ical->uid = g_strdup (str_val (vo));
- free (the_str);
- } else {
- ical->uid = ical_gen_uid ();
- }
-
- /* seq */
- if (has (o, VCSequenceProp)){
- ical->seq = atoi (str_val (vo));
- free (the_str);
- } else
- ical->seq = 0;
-
- /* dtstart */
- if (has (o, VCDTstartProp)){
- ical->dtstart = time_from_isodate (str_val (vo));
- free (the_str);
- } else
- ical->dtstart = 0;
-
- /* dtend */
- ical->dtend = 0; /* default value */
- if (ical->type == ICAL_EVENT){
- if (has (o, VCDTendProp)){
- ical->dtend = time_from_isodate (str_val (vo));
- free (the_str);
- }
- } else if (ical->type == ICAL_TODO){
- if (has (o, VCDueProp)){
- ical->dtend = time_from_isodate (str_val (vo));
- free (the_str);
- }
- }
-
- /* dcreated */
- if (has (o, VCDCreatedProp)){
- ical->created = time_from_isodate (str_val (vo));
- free (the_str);
- }
-
- /* completed */
- if (has (o, VCCompletedProp)){
- ical->completed = time_from_isodate (str_val (vo));
- free (the_str);
- }
-
- /* last_mod */
- if (has (o, VCLastModifiedProp)){
- ical->last_mod = time_from_isodate (str_val (vo));
- free (the_str);
- } else
- ical->last_mod = now;
-
- /* exdate */
- if (has (o, VCExpDateProp)){
- ical->exdate = set_date_list (str_val (vo));
- free (the_str);
- }
-
- /* description/comment */
- if (has (o, VCDescriptionProp)){
- ical->comment = g_strdup (str_val (vo));
- free (the_str);
- }
-
- /* summary */
- if (has (o, VCSummaryProp)){
- ical->summary = g_strdup (str_val (vo));
- free (the_str);
- } else
- ical->summary = g_strdup ("");
-
- /* status */
- if (has (o, VCStatusProp)){
- ical->status = g_strdup (str_val (vo));
- free (the_str);
- } else
- ical->status = g_strdup ("NEEDS ACTION");
-
- if (has (o, VCClassProp)){
- ical->class = g_strdup (str_val (vo));
- free (the_str);
- } else
- ical->class = g_strdup ("PUBLIC");
-
- /* categories */
- if (has (o, VCCategoriesProp)){
- ical->categories = set_list (str_val (vo));
- free (the_str);
- }
-
- /* resources */
- if (has (o, VCResourcesProp)){
- ical->resources = set_list (str_val (vo));
- free (the_str);
- }
-
- /* priority */
- if (has (o, VCPriorityProp)){
- ical->priority = atoi (str_val (vo));
- free (the_str);
- }
-
- /* tranparency */
- if (has (o, VCTranspProp)){
- ical->transp = atoi (str_val (vo)) ? ICAL_TRANSPARENT : ICAL_OPAQUE;
- free (the_str);
- }
-
- /* Organizer */
- if (has (o, VCOrgNameProp)){
- ical->organizer = g_new0 (iCalPerson, 1);
- ical->organizer->addr = g_strdup (str_val (vo));
- free (the_str);
- }
-
- /* related */
- if (has (o, VCRelatedToProp)){
- char *str;
- char *s;
- iCalRelation *rel;
- str = str_val (vo);
- for (s = strtok (str, ";"); s; s = strtok (NULL, ";")) {
- rel = g_new0 (iCalRelation, 1);
- rel->uid = g_strdup (s);
- rel->reltype = g_strdup ("PARENT");
- ical->related = g_list_prepend (ical->related, rel);
- }
- free (the_str);
- }
-
- /* attach */
- initPropIterator (&i, o);
- while (moreIteration (&i)){
- vo = nextVObject (&i);
- if (strcmp (vObjectName (vo), VCAttachProp) == 0){
- ical->attach = g_list_prepend (ical->attach, g_strdup (str_val (vo)));
- free (the_str);
- }
- }
-
- /* url */
- if (has (o, VCURLProp)){
- ical->url = g_strdup (str_val (vo));
- free (the_str);
- }
-
- /* dalarm */
- ical->dalarm.type = ALARM_DISPLAY;
- ical->dalarm.enabled = 0;
- if (has (o, VCDAlarmProp)){
- if ((a = is_a_prop_of (vo, VCRunTimeProp))){
- setup_alarm_at (ical, &ical->dalarm, str_val (a), vo);
- free (the_str);
- }
- }
-
- /* aalarm */
- ical->aalarm.type = ALARM_AUDIO;
- ical->aalarm.enabled = 0;
- if (has (o, VCAAlarmProp)){
- if ((a = is_a_prop_of (vo, VCRunTimeProp))){
- setup_alarm_at (ical, &ical->aalarm, str_val (a), vo);
- free (the_str);
- }
- }
-
- /* palarm */
- ical->palarm.type = ALARM_PROGRAM;
- ical->palarm.enabled = 0;
- if (has (o, VCPAlarmProp)){
- ical->palarm.type = ALARM_PROGRAM;
- if ((a = is_a_prop_of (vo, VCRunTimeProp))){
- setup_alarm_at (ical, &ical->palarm, str_val (a), vo);
- free (the_str);
-
- if ((a = is_a_prop_of (vo, VCProcedureNameProp))){
- ical->palarm.data = g_strdup (str_val (a));
- free (the_str);
- } else
- ical->palarm.data = g_strdup ("");
- }
- }
-
- /* malarm */
- ical->malarm.type = ALARM_MAIL;
- ical->malarm.enabled = 0;
- if (has (o, VCMAlarmProp)){
- ical->malarm.type = ALARM_MAIL;
- if ((a = is_a_prop_of (vo, VCRunTimeProp))){
- setup_alarm_at (ical, &ical->malarm, str_val (a), vo);
- free (the_str);
-
- if ((a = is_a_prop_of (vo, VCEmailAddressProp))){
- ical->malarm.data = g_strdup (str_val (a));
- free (the_str);
- } else
- ical->malarm.data = g_strdup ("");
- }
- }
-
- /* rrule */
- if (has (o, VCRRuleProp)){
- if (!load_recurrence (ical, str_val (vo))) {
- ical_object_destroy (ical);
- return NULL;
- }
- free (the_str);
- }
-
- /*
- * Pilot
- */
- if (has (o, XPilotIdProp)){
- ical->pilot_id = atoi (str_val (vo));
- free (the_str);
- } else
- ical->pilot_id = 0;
-
- if (has (o, XPilotStatusProp)){
- ical->pilot_status = atoi (str_val (vo));
- free (the_str);
- } else
- ical->pilot_status = ICAL_PILOT_SYNC_MOD;
-
- return ical;
-}
-
-static char *
-to_str (int num)
-{
- static char buf [40];
-
- sprintf (buf, "%d", num);
- return buf;
-}
-
-/*
- * stores a GList in the property.
- */
-static void
-store_list (VObject *o, char *prop, GList *values)
-{
- GList *l;
- int len;
- char *result, *p;
-
- for (len = 0, l = values; l; l = l->next)
- len += strlen (l->data) + 1;
-
- result = g_malloc (len);
-
- for (p = result, l = values; l; l = l->next) {
- int len = strlen (l->data);
-
- strcpy (p, l->data);
-
- if (l->next) {
- p [len] = ';';
- p += len+1;
- } else
- p += len;
- }
-
- *p = 0;
-
- addPropValue (o, prop, result);
- g_free (result);
-}
-
-static void
-store_rel_list (VObject *o, char *prop, GList *values)
-{
- GList *l;
- int len;
- char *result, *p;
-
- for (len = 0, l = values; l; l = l->next)
- len += strlen (((iCalRelation*)(l->data))->uid) + 1;
-
- result = g_malloc (len);
-
- for (p = result, l = values; l; l = l->next) {
- int len = strlen (((iCalRelation*)(l->data))->uid);
-
- strcpy (p, ((iCalRelation*)(l->data))->uid);
-
- if (l->next) {
- p [len] = ';';
- p += len+1;
- } else
- p += len;
- }
-
- *p = 0;
-
- addPropValue (o, prop, result);
- g_free (result);
-}
-
-static void
-store_date_list (VObject *o, char *prop, GList *values)
-{
- GList *l;
- int size, len;
- char *s, *p;
-
- size = g_list_length (values);
- s = p = g_malloc ((size * 17 + 1) * sizeof (char));
-
- for (l = values; l; l = l->next){
- strcpy (s, isodate_from_time_t (*(time_t *)l->data));
- len = strlen (s);
- s [len] = ',';
- s += len + 1;
- }
- s--;
- *s = 0;
- addPropValue (o, prop, p);
- g_free (p);
-}
-
-static char *recur_type_name [] = { "D", "W", "MP", "MD", "YM", "YD" };
-static char *recur_day_list [] = { "SU", "MO", "TU","WE", "TH", "FR", "SA" };
-static char *alarm_names [] = { VCMAlarmProp, VCPAlarmProp, VCDAlarmProp, VCAAlarmProp };
-
-static VObject *
-save_alarm (VObject *o, CalendarAlarm *alarm, iCalObject *ical)
-{
- VObject *alarm_object;
- struct tm tm;
- time_t alarm_time;
-
- if (!alarm->enabled)
- return NULL;
- tm = *localtime (&ical->dtstart);
- switch (alarm->units){
- case ALARM_MINUTES:
- tm.tm_min -= alarm->count;
- break;
-
- case ALARM_HOURS:
- tm.tm_hour -= alarm->count;
- break;
-
- case ALARM_DAYS:
- tm.tm_mday -= alarm->count;
- break;
- }
-
- alarm_time = mktime (&tm);
- alarm_object = addProp (o, alarm_names [alarm->type]);
- addPropValue (alarm_object, VCRunTimeProp, isodate_from_time_t (alarm_time));
-
- if (alarm->snooze_secs)
- addPropValue (alarm_object, VCSnoozeTimeProp, isodiff_from_secs (alarm->snooze_secs));
- else
- addPropValue (alarm_object, VCSnoozeTimeProp, "");
-
- if (alarm->snooze_repeat){
- char buf [20];
-
- sprintf (buf, "%d", alarm->snooze_repeat);
- addPropValue (alarm_object, VCRepeatCountProp, buf);
- } else
- addPropValue (alarm_object, VCRepeatCountProp, "");
- return alarm_object;
-}
-
-VObject *
-ical_object_to_vobject (iCalObject *ical)
-{
- VObject *o, *alarm, *s;
- GList *l;
-
- if (ical->type == ICAL_EVENT)
- o = newVObject (VCEventProp);
- else
- o = newVObject (VCTodoProp);
-
- /* uid */
- if (ical->uid)
- addPropValue (o, VCUniqueStringProp, ical->uid);
-
- /* seq */
- addPropValue (o, VCSequenceProp, to_str (ical->seq));
-
- /* dtstart */
- addPropValue (o, VCDTstartProp, isodate_from_time_t (ical->dtstart));
-
- /* dtend */
- if (ical->type == ICAL_EVENT){
- addPropValue (o, VCDTendProp, isodate_from_time_t (ical->dtend));
- } else if (ical->type == ICAL_TODO){
- addPropValue (o, VCDueProp, isodate_from_time_t (ical->dtend));
- }
-
- /* dcreated */
- addPropValue (o, VCDCreatedProp, isodate_from_time_t (ical->created));
-
- /* completed */
- if (ical->completed)
- addPropValue (o, VCDTendProp, isodate_from_time_t (ical->completed));
-
- /* last_mod */
- addPropValue (o, VCLastModifiedProp, isodate_from_time_t (ical->last_mod));
-
- /* exdate */
- if (ical->exdate)
- store_date_list (o, VCExpDateProp, ical->exdate);
-
- /* description/comment */
- if (ical->comment && strlen (ical->comment)){
- s = addPropValue (o, VCDescriptionProp, ical->comment);
- if (strchr (ical->comment, '\n'))
- addProp (s, VCQuotedPrintableProp);
- }
-
- /* summary */
- if (strlen (ical->summary)){
- s = addPropValue (o, VCSummaryProp, ical->summary);
- if (strchr (ical->summary, '\n'))
- addProp (s, VCQuotedPrintableProp);
- } else {
- addPropValue (o, VCSummaryProp, _("Appointment"));
- }
-
- /* status */
- addPropValue (o, VCStatusProp, ical->status);
-
- /* class */
- addPropValue (o, VCClassProp, ical->class);
-
- /* categories */
- if (ical->categories)
- store_list (o, VCCategoriesProp, ical->categories);
-
- /* resources */
- if (ical->resources)
- store_list (o, VCCategoriesProp, ical->resources);
-
- /* priority */
- addPropValue (o, VCPriorityProp, to_str (ical->priority));
-
- /* transparency */
- addPropValue (o, VCTranspProp, to_str (ical->transp));
-
- /* Owner/organizer */
- if (ical->organizer && ical->organizer->addr)
- addPropValue (o, VCOrgNameProp, ical->organizer->addr);
-
- /* related */
- if (ical->related)
- store_rel_list (o, VCRelatedToProp, ical->related);
-
- /* attach */
- for (l = ical->attach; l; l = l->next)
- addPropValue (o, VCAttachProp, l->data);
-
- /* url */
- if (ical->url)
- addPropValue (o, VCURLProp, ical->url);
-
- if (ical->recur){
- char result [256];
- char buffer [80];
- int i;
-
- sprintf (result, "%s%d ", recur_type_name [ical->recur->type], ical->recur->interval);
- switch (ical->recur->type){
- case RECUR_DAILY:
- break;
-
- case RECUR_WEEKLY:
- for (i = 0; i < 7; i++){
- if (ical->recur->weekday & (1 << i)){
- sprintf (buffer, "%s ", recur_day_list [i]);
- strcat (result, buffer);
- }
- }
- break;
-
- case RECUR_MONTHLY_BY_POS: {
- int nega = ical->recur->u.month_pos < 0;
-
- sprintf (buffer, "%d%s ", nega ? -ical->recur->u.month_pos : ical->recur->u.month_pos,
- nega ? "-" : "+");
- strcat (result, buffer);
- /* the gui is set up for a single day, not a set here in this case */
- sprintf (buffer, "%s ", recur_day_list [ical->recur->weekday]);
- strcat (result, buffer);
- }
- break;
-
- case RECUR_MONTHLY_BY_DAY:
- sprintf (buffer, "%d ", ical->recur->u.month_pos);
- strcat (result, buffer);
- break;
-
- case RECUR_YEARLY_BY_MONTH:
- break;
-
- case RECUR_YEARLY_BY_DAY:
- break;
- }
- if (ical->recur->_enddate == 0)
- sprintf (buffer, "#%d ",ical->recur->duration);
- else
- sprintf (buffer, "%s ", isodate_from_time_t (ical->recur->_enddate));
- strcat (result, buffer);
- addPropValue (o, VCRRuleProp, result);
- }
-
- save_alarm (o, &ical->aalarm, ical);
- save_alarm (o, &ical->dalarm, ical);
-
- if ((alarm = save_alarm (o, &ical->palarm, ical)))
- addPropValue (alarm, VCProcedureNameProp, ical->palarm.data);
- if ((alarm = save_alarm (o, &ical->malarm, ical)))
- addPropValue (alarm, VCEmailAddressProp, ical->malarm.data);
-
- /* Pilot */
- {
- char buffer [20];
-
- sprintf (buffer, "%d", ical->pilot_id);
- addPropValue (o, XPilotIdProp, buffer);
- sprintf (buffer, "%d", ical->pilot_status);
- addPropValue (o, XPilotStatusProp, buffer);
- }
-
- return o;
-}
-
-void
-ical_foreach (GList *events, calendarfn fn, void *closure)
-{
- for (; events; events = events->next){
- iCalObject *ical = events->data;
-
- (*fn) (ical, ical->dtstart, ical->dtend, closure);
- }
-}
-
-static int
-is_date_in_list (GList *list, struct tm *date)
-{
- struct tm tm;
-
- for (; list; list = list->next){
- time_t *timep = list->data;
-
- tm = *localtime (timep);
- if (date->tm_mday == tm.tm_mday &&
- date->tm_mon == tm.tm_mon &&
- date->tm_year == tm.tm_year){
- return 1;
- }
- }
- return 0;
-}
-
-static int
-generate (iCalObject *ico, time_t reference, calendarfn cb, void *closure)
-{
- struct tm dt_start, dt_end, ref;
- time_t s_t, e_t;
-
- dt_start = *localtime (&ico->dtstart);
- dt_end = *localtime (&ico->dtend);
- ref = *localtime (&reference);
-
- dt_start.tm_mday = ref.tm_mday;
- dt_start.tm_mon = ref.tm_mon;
- dt_start.tm_year = ref.tm_year;
-
- dt_end.tm_mday = ref.tm_mday;
- dt_end.tm_mon = ref.tm_mon;
- dt_end.tm_year = ref.tm_year;
-
-
- if (ref.tm_isdst > dt_start.tm_isdst){
- dt_start.tm_hour--;
- dt_end.tm_hour--;
- } else if (ref.tm_isdst < dt_start.tm_isdst){
- dt_start.tm_hour++;
- dt_end.tm_hour++;
- }
-
- s_t = mktime (&dt_start);
-
- if (ico->exdate && is_date_in_list (ico->exdate, &dt_start))
- return 1;
-
- e_t = mktime (&dt_end);
-
- if ((s_t == -1) || (e_t == -1)) {
- g_warning ("Produced invalid dates!\n");
- return 0;
- }
-
- return (*cb) (ico, s_t, e_t, closure);
-}
-
-int
-ical_object_get_first_weekday (int weekday_mask)
-{
- int i;
-
- for (i = 0; i < 7; i++)
- if (weekday_mask & (1 << i))
- return i;
-
- return -1;
-}
-
-#define time_in_range(t, a, b) ((t >= a) && (b ? (t < b) : 1))
-#define recur_in_range(t, r) (r->enddate ? (t < r->enddate) : 1)
-
-/*
- * Generate every possible event. Invokes the callback routine for
- * every occurrence of the event in the [START, END] time interval.
- *
- * If END is zero, the event is generated forever.
- * The callback routine is expected to return 0 when no further event
- * generation is requested.
- */
-void
-ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendarfn cb, void *closure)
-{
- time_t current;
- int first_week_day;
-
- /* If there is no recurrence, just check ranges */
-
- if (!ico->recur) {
- if ((end && (ico->dtstart < end) && (ico->dtend > start))
- || ((end == 0) && (ico->dtend > start))) {
- time_t ev_s, ev_e;
-
- /* Clip range */
-
- ev_s = MAX (ico->dtstart, start);
- ev_e = MIN (ico->dtend, end);
-
- (* cb) (ico, ev_s, ev_e, closure);
- }
- return;
- }
-
- /* The event has a recurrence rule -- check that we will generate at least one instance */
-
- if (end != 0) {
- if (ico->dtstart > end)
- return;
-
- if (!IS_INFINITE (ico->recur) && (ico->recur->enddate < start))
- return;
- }
-
- /* Generate the instances */
-
- current = ico->dtstart;
-
- switch (ico->recur->type) {
- case RECUR_DAILY:
- do {
- if (time_in_range (current, start, end) && recur_in_range (current, ico->recur))
- if (!generate (ico, current, cb, closure))
- return;
-
- /* Advance */
-
- current = time_add_day (current, ico->recur->interval);
-
- if (current == -1) {
- g_warning ("RECUR_DAILY: time_add_day() returned invalid time");
- return;
- }
- } while ((current < end) || (end == 0));
-
- break;
-
- case RECUR_WEEKLY:
- do {
- struct tm tm;
-
- tm = *localtime (&current);
-
- if (time_in_range (current, start, end) && recur_in_range (current, ico->recur)) {
- /* Weekdays to recur on are specified as a bitmask */
- if (ico->recur->weekday & (1 << tm.tm_wday)) {
- if (!generate (ico, current, cb, closure))
- return;
- }
- }
-
- /* Advance by day for scanning the week or by interval at week end */
-
- if (tm.tm_wday == 6)
- current = time_add_day (current, (ico->recur->interval - 1) * 7 + 1);
- else
- current = time_add_day (current, 1);
-
- if (current == -1) {
- g_warning ("RECUR_WEEKLY: time_add_day() returned invalid time\n");
- return;
- }
- } while (current < end || (end == 0));
-
- break;
-
- case RECUR_MONTHLY_BY_POS:
- /* FIXME: We only deal with positives now */
- if (ico->recur->u.month_pos < 0) {
- g_warning ("RECUR_MONTHLY_BY_POS does not support negative positions yet");
- return;
- }
-
- if (ico->recur->u.month_pos == 0)
- return;
-
- first_week_day = /* ical_object_get_first_weekday (ico->recur->weekday); */
- ico->recur->weekday; /* the i/f only lets you choose a single day of the week! */
-
- /* This should not happen, but take it into account */
- if (first_week_day == -1) {
- g_warning ("ical_object_get_first_weekday() returned -1");
- return;
- }
-
- do {
- struct tm tm;
- time_t t;
- int week_day_start;
-
- tm = *localtime (&current);
- tm.tm_mday = 1;
- t = mktime (&tm);
- tm = *localtime (&t);
- week_day_start = tm.tm_wday;
-
- tm.tm_mday = (7 * (ico->recur->u.month_pos - ((week_day_start <= first_week_day ) ? 1 : 0))
- - (week_day_start - first_week_day) + 1);
- if( tm.tm_mday > 31 )
- {
- tm.tm_mday = 1;
- tm.tm_mon += ico->recur->interval;
- current = mktime (&tm);
- continue;
- }
-
- switch( tm.tm_mon )
- {
- case 3:
- case 5:
- case 8:
- case 10:
- if( tm.tm_mday > 30 )
- {
- tm.tm_mday = 1;
- tm.tm_mon += ico->recur->interval;
- current = mktime (&tm);
- continue;
- }
- break;
- case 1:
- if( ((tm.tm_year+1900)%4) == 0
- && ((tm.tm_year+1900)%400) != 100
- && ((tm.tm_year+1900)%400) != 200
- && ((tm.tm_year+1900)%400) != 300 )
- {
-
- if( tm.tm_mday > 29 )
- {
- tm.tm_mday = 1;
- tm.tm_mon += ico->recur->interval;
- current = mktime (&tm);
- continue;
- }
- }
- else
- {
- if( tm.tm_mday > 28 )
- {
- tm.tm_mday = 1;
- tm.tm_mon += ico->recur->interval;
- current = mktime (&tm);
- continue;
- }
- }
- break;
- }
-
- t = mktime (&tm);
-
- if (time_in_range (t, start, end) && recur_in_range (current, ico->recur))
- if (!generate (ico, t, cb, closure))
- return;
-
- /* Advance by the appropriate number of months */
-
- current = mktime (&tm);
-
- tm.tm_mday = 1;
- tm.tm_mon += ico->recur->interval;
- current = mktime (&tm);
-
- if (current == -1) {
- g_warning ("RECUR_MONTHLY_BY_DAY: mktime error\n");
- return;
- }
- } while ((current < end) || (end == 0));
-
- break;
-
- case RECUR_MONTHLY_BY_DAY:
- do {
- struct tm tm;
- time_t t;
- int p;
-
- tm = *localtime (&current);
-
- p = tm.tm_mday;
- tm.tm_mday = ico->recur->u.month_day;
- t = mktime (&tm);
- if (time_in_range (t, start, end) && recur_in_range (current, ico->recur))
- if (!generate (ico, t, cb, closure))
- return;
-
- /* Advance by the appropriate number of months */
-
- tm.tm_mday = p;
- tm.tm_mon += ico->recur->interval;
- current = mktime (&tm);
-
- if (current == -1) {
- g_warning ("RECUR_MONTHLY_BY_DAY: mktime error\n");
- return;
- }
- } while (current < end || (end == 0));
-
- break;
-
- case RECUR_YEARLY_BY_MONTH:
- case RECUR_YEARLY_BY_DAY:
- do {
- if (time_in_range (current, start, end) && recur_in_range (current, ico->recur))
- if (!generate (ico, current, cb, closure))
- return;
-
- /* Advance */
-
- current = time_add_year (current, ico->recur->interval);
- } while (current < end || (end == 0));
-
- break;
-
- default:
- g_assert_not_reached ();
- }
-}
-
-static int
-duration_callback (iCalObject *ico, time_t start, time_t end, void *closure)
-{
- int *count = closure;
- struct tm tm;
-
- tm = *localtime (&start);
-
- (*count)++;
- if (ico->recur->duration == *count) {
- ico->recur->enddate = time_day_end (end);
- return 0;
- }
- return 1;
-}
-
-/* Computes ico->recur->enddate from ico->recur->duration */
-void
-ical_object_compute_end (iCalObject *ico)
-{
- int count = 0;
-
- g_return_if_fail (ico->recur != NULL);
-
- ico->recur->_enddate = 0;
- ico->recur->enddate = 0;
- ical_object_generate_events (ico, ico->dtstart, 0, duration_callback, &count);
-}
-
-int
-alarm_compute_offset (CalendarAlarm *a)
-{
- if (!a->enabled)
- return -1;
- switch (a->units){
- case ALARM_MINUTES:
- a->offset = a->count * 60;
- break;
- case ALARM_HOURS:
- a->offset = a->count * 3600;
- break;
- case ALARM_DAYS:
- a->offset = a->count * 24 * 3600;
- }
- return a->offset;
-}
-
-iCalObject *
-ical_object_new_from_string (const char *vcal_string)
-{
- iCalObject *ical = NULL;
- VObject *cal, *event;
- VObjectIterator i;
- const char *object_name;
-
- cal = Parse_MIME (vcal_string, strlen (vcal_string));
-
- initPropIterator (&i, cal);
-
- while (moreIteration (&i)){
- event = nextVObject (&i);
-
- object_name = vObjectName (event);
-
- if (strcmp (object_name, VCEventProp) == 0){
- ical = ical_object_create_from_vobject (event, object_name);
- break;
- }
- }
-
- cleanVObject (cal);
- cleanStrTbl ();
-
- return ical;
-}
-
-/**
- * ical_object_find_in_string:
- * @uid: Unique identifier of the sought object.
- * @vcalobj: String representation of a complete calendar object.
- * @ico: The resulting #iCalObject is stored here.
- *
- * Parses a complete vCalendar object string and tries to find the calendar
- * object that matches the specified @uid. If found, it stores the resulting
- * #iCalObject in the @ico parameter.
- *
- * Return value: A result code depending on whether the parse and search were
- * successful.
- **/
-CalObjFindStatus
-ical_object_find_in_string (const char *uid, const char *vcalobj, iCalObject **ico)
-{
- VObject *vcal;
- VObjectIterator i;
- CalObjFindStatus status;
-
- g_return_val_if_fail (uid != NULL, CAL_OBJ_FIND_SYNTAX_ERROR);
- g_return_val_if_fail (vcalobj != NULL, CAL_OBJ_FIND_SYNTAX_ERROR);
- g_return_val_if_fail (ico != NULL, CAL_OBJ_FIND_SYNTAX_ERROR);
-
- *ico = NULL;
- status = CAL_OBJ_FIND_NOT_FOUND;
-
- vcal = Parse_MIME (vcalobj, strlen (vcalobj));
-
- if (!vcal)
- return CAL_OBJ_FIND_SYNTAX_ERROR;
-
- initPropIterator (&i, vcal);
-
- while (moreIteration (&i)) {
- VObject *vobj;
- VObject *uid_prop;
- char *the_str;
-
- vobj = nextVObject (&i);
-
- uid_prop = isAPropertyOf (vobj, VCUniqueStringProp);
- if (!uid_prop)
- continue;
-
- /* str_val() sets the_str to the string representation of the
- * property.
- */
- str_val (uid_prop);
-
- if (strcmp (the_str, uid) == 0) {
- const char *object_name;
-
- object_name = vObjectName (vobj);
- *ico = ical_object_create_from_vobject (vobj, object_name);
-
- if (*ico)
- status = CAL_OBJ_FIND_SUCCESS;
- }
-
- free (the_str);
-
- if (status == CAL_OBJ_FIND_SUCCESS)
- break;
- }
-
- cleanVObject (vcal);
- cleanStrTbl ();
-
- return status;
-}
diff --git a/calendar/calobj.h b/calendar/calobj.h
deleted file mode 100644
index 38d9598298..0000000000
--- a/calendar/calobj.h
+++ /dev/null
@@ -1,263 +0,0 @@
-/*
- * Internal representation of a Calendar object. This is modeled after the
- * iCalendar/vCalendar specificiation
- *
- * Authors: Miguel de Icaza (miguel@gnu.org)
- * Federico Mena (quartic@gimp.org).
- */
-#ifndef CALOBJ_H
-#define CALOBJ_H
-
-#include <libgnome/libgnome.h>
-#include "../libversit/vcc.h"
-
-BEGIN_GNOME_DECLS
-
-enum AlarmType {
- ALARM_MAIL,
- ALARM_PROGRAM,
- ALARM_DISPLAY,
- ALARM_AUDIO
-};
-
-enum AlarmUnit {
- ALARM_MINUTES,
- ALARM_HOURS,
- ALARM_DAYS
-};
-
-typedef struct {
- enum AlarmType type;
- int enabled;
- int count;
- enum AlarmUnit units;
- char *data; /* not used for iCalendar alarms */
-
- /* the following pointers are used for iCalendar alarms */
-
- char *attach; /* AUDIO, EMAIL, PROC */
- char *desc; /* DISPLAY, EMAIL, PROC */
- char *summary; /* EMAIL */
- char *attendee; /* EMAIL */
-
- /* Does not get saved, internally used */
- time_t offset;
- time_t trigger;
-
- int snooze_secs;
- int snooze_repeat;
-
- /* Widgets */
- void *w_count; /* A GtkEntry */
- void *w_enabled; /* A GtkChecButton */
- void *w_timesel; /* A GtkMenu */
- void *w_entry; /* A GnomeEntryFile/GtkEntry for PROGRAM/MAIL */
- void *w_label;
-} CalendarAlarm;
-
-/* Calendar object type */
-typedef enum {
- ICAL_EVENT,
- ICAL_TODO,
- ICAL_JOURNAL,
- ICAL_FBREQUEST,
- ICAL_FBREPLY,
- ICAL_BUSYTIME,
- ICAL_TIMEZONE
-} iCalType;
-
-/* For keys that might contain binary or text/binary */
-typedef struct {
- char *data;
- int len;
-} iCalValue;
-
-typedef enum {
- ICAL_PILOT_SYNC_NONE = 0,
- ICAL_PILOT_SYNC_MOD = 1,
- ICAL_PILOT_SYNC_DEL = 3
-} iCalPilotState;
-
-typedef struct {
- int valid; /* true if the Geography was specified */
- double latitude;
- double longitude;
-} iCalGeo;
-
-typedef enum {
- ICAL_OPAQUE,
- ICAL_TRANSPARENT
-} iCalTransp;
-
-typedef struct {
- char *uid;
- char *reltype;
-} iCalRelation;
-
-typedef char NotYet;
-
-enum RecurType {
- RECUR_DAILY,
- RECUR_WEEKLY,
- RECUR_MONTHLY_BY_POS,
- RECUR_MONTHLY_BY_DAY,
- RECUR_YEARLY_BY_MONTH,
- RECUR_YEARLY_BY_DAY,
-};
-
-#define DAY_LASTDAY 10000
-
-typedef struct {
- enum RecurType type;
-
- int interval;
-
- /* Used for recur computation */
- time_t enddate; /* If the value is zero, it is an infinite event
- * otherwise, it is either the _enddate value (if
- * this is what got specified) or it is our computed
- * ending date (computed from the duration item).
- */
-
- int weekday;
-
- union {
- int month_pos;
- int month_day;
- } u;
-
- int duration;
- time_t _enddate; /* As found on the vCalendar file */
- int __count;
-} Recurrence;
-
-/*
- NOTE: iCalPerson is used for various property values which specify
- people (e.g. ATTENDEE, ORGANIZER, etc. Not all fields are valid
- under RFC 2445 for all property values, but iCalPerson can store
- them anyway. Enforcing the RFC is a job for the parser.
-*/
-
-typedef struct {
- char *addr;
- char *name;
- char *role;
- char *partstat;
- gboolean rsvp;
- char *cutype; /* calendar user type */
- GList *member; /* group memberships */
- GList *deleg_to;
- GList *deleg_from;
- char *sent_by;
- char *directory;
- GList *altrep; /* list of char* URI's */
-} iCalPerson;
-
-#define IS_INFINITE(r) (r->duration == 0)
-
-/* Flags to indicate what has changed in an object */
-typedef enum {
- CHANGE_NEW = 1 << 0, /* new object */
- CHANGE_SUMMARY = 1 << 1, /* summary */
- CHANGE_DATES = 1 << 2, /* dtstart / dtend */
- CHANGE_ALL = CHANGE_SUMMARY | CHANGE_DATES
-} CalObjectChange;
-
-/*
- * This describes an iCalendar object, note that we never store durations, instead we
- * always compute the end time computed from the start + duration.
- */
-typedef struct {
- iCalType type;
-
- GList *attach; /* type: one or more URIs or binary data */
- GList *attendee; /* type: CAL-ADDRESS (list of iCalPerson) */
- GList *categories; /* type: one or more TEXT */
- char *class;
-
- char *comment; /* we collapse one or more TEXTs into one */
- time_t completed;
- time_t created;
- GList *contact; /* type: one or more TEXT */
- char *desc;
- time_t dtstamp;
- time_t dtstart;
- time_t dtend; /* also duedate for todo's */
- gboolean date_only; /* set if the start/end times were
- specified using dates, not times (internal use, not stored to disk) */
- GList *exdate; /* type: one or more time_t's */
- GList *exrule; /* type: one or more RECUR */
- iCalGeo geo;
- time_t last_mod;
- char *location;
- iCalPerson *organizer;
- int percent;
- int priority;
- char *rstatus; /* request status for freebusy */
- GList *related; /* type: one or more TEXT */
- GList *resources; /* type: one or more TEXT */
- GList *rdate; /* type: one or more recurrence date */
- GList *rrule; /* type: one or more recurrence rules */
- int seq;
- char *status;
- char *summary;
- iCalTransp transp;
- char *uid;
- char *url;
- time_t recurid;
-
- CalendarAlarm dalarm;
- CalendarAlarm aalarm;
- CalendarAlarm palarm;
- CalendarAlarm malarm;
-
- GList *alarms;
-
- Recurrence *recur;
-
- int new;
- void *user_data; /* Generic data pointer */
-
- /* Pilot */
- iCalPilotState pilot_status; /* Status information */
- guint32 pilot_id; /* Pilot ID */
-} iCalObject;
-
-/* The callback for the recurrence generator */
-typedef int (*calendarfn) (iCalObject *, time_t, time_t, void *);
-
-iCalObject *ical_new (char *comment, char *organizer, char *summary);
-iCalObject *ical_object_new (void);
-iCalObject *ical_object_new_from_string (const char *vcalendar_string);
-void ical_object_destroy (iCalObject *ico);
-iCalObject *ical_object_create_from_vobject (VObject *obj, const char *object_name);
-VObject *ical_object_to_vobject (iCalObject *ical);
-iCalObject *ical_object_duplicate (iCalObject *o);
-void ical_foreach (GList *events, calendarfn fn, void *closure);
-void ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendarfn cb, void *closure);
-void ical_object_add_exdate (iCalObject *o, time_t t);
-
-/* Computes the enddate field of the recurrence based on the duration */
-void ical_object_compute_end (iCalObject *ico);
-
-typedef enum {
- CAL_OBJ_FIND_SUCCESS,
- CAL_OBJ_FIND_SYNTAX_ERROR,
- CAL_OBJ_FIND_NOT_FOUND
-} CalObjFindStatus;
-
-CalObjFindStatus ical_object_find_in_string (const char *uid, const char *vcalobj, iCalObject **ico);
-
-
-/* Returns the first toggled day in a weekday mask -- we do this because we do not support multiple
- * days on a monthly-by-pos recurrence. If no days are toggled, it returns -1.
- */
-int ical_object_get_first_weekday (int weekday_mask);
-
-/* Returns the number of seconds configured to trigger the alarm in advance to an event */
-int alarm_compute_offset (CalendarAlarm *a);
-
-END_GNOME_DECLS
-
-#endif
-
diff --git a/calendar/corba-cal-factory.c b/calendar/corba-cal-factory.c
index a86af3c238..a0630fda73 100644
--- a/calendar/corba-cal-factory.c
+++ b/calendar/corba-cal-factory.c
@@ -12,8 +12,8 @@
#include "gnome-cal.h"
#include "main.h"
#include "alarm.h"
-#include "timeutil.h"
-#include "../libversit/vcc.h"
+#include "cal-util/timeutil.h"
+#include "libversit/vcc.h"
#include <libgnorba/gnorba.h>
#include <bonobo.h>
#include "GnomeCal.h"
diff --git a/calendar/corba-cal.c b/calendar/corba-cal.c
index 6d848ddb87..759b989893 100644
--- a/calendar/corba-cal.c
+++ b/calendar/corba-cal.c
@@ -12,8 +12,8 @@
#include "calendar.h"
#include "gnome-cal.h"
#include "alarm.h"
-#include "timeutil.h"
-#include "../libversit/vcc.h"
+#include "cal-util/timeutil.h"
+#include "libversit/vcc.h"
#include <libgnorba/gnome-factory.h>
#include "GnomeCal.h"
#include "corba-cal-factory.h"
diff --git a/calendar/eventedit.c b/calendar/eventedit.c
index a3ec95da07..e65db4e3da 100644
--- a/calendar/eventedit.c
+++ b/calendar/eventedit.c
@@ -11,7 +11,7 @@
#include "calendar.h"
#include "eventedit.h"
#include "main.h"
-#include "timeutil.h"
+#include "cal-util/timeutil.h"
static void event_editor_class_init (EventEditorClass *class);
diff --git a/calendar/gncal-day-panel.c b/calendar/gncal-day-panel.c
index f407a497d3..8d21b6fabc 100644
--- a/calendar/gncal-day-panel.c
+++ b/calendar/gncal-day-panel.c
@@ -10,7 +10,7 @@
#include <gtk/gtkhseparator.h>
#include "gncal-day-panel.h"
#include "main.h"
-#include "timeutil.h"
+#include "cal-util/timeutil.h"
guint
diff --git a/calendar/gncal-day-view.c b/calendar/gncal-day-view.c
index 22a0859069..955aac0ef9 100644
--- a/calendar/gncal-day-view.c
+++ b/calendar/gncal-day-view.c
@@ -8,7 +8,7 @@
#include <gnome.h>
#include "gncal-day-view.h"
-#include "timeutil.h"
+#include "cal-util/timeutil.h"
#include "view-utils.h"
#include "main.h"
#include "eventedit.h"
diff --git a/calendar/gncal-week-view.c b/calendar/gncal-week-view.c
index 888c656ff4..553977e076 100644
--- a/calendar/gncal-week-view.c
+++ b/calendar/gncal-week-view.c
@@ -12,7 +12,7 @@
#include <gtk/gtk.h>
#include "gncal-week-view.h"
#include "main.h"
-#include "timeutil.h"
+#include "cal-util/timeutil.h"
static void gncal_week_view_init (GncalWeekView *wview);
diff --git a/calendar/gnome-cal.c b/calendar/gnome-cal.c
index 0e3c475fdf..8682099900 100644
--- a/calendar/gnome-cal.c
+++ b/calendar/gnome-cal.c
@@ -17,7 +17,7 @@
#include "gncal-week-view.h"
#include "month-view.h"
#include "year-view.h"
-#include "timeutil.h"
+#include "cal-util/timeutil.h"
#include "main.h"
#include "corba-cal.h"
diff --git a/calendar/goto.c b/calendar/goto.c
index 41609da678..ef756a5463 100644
--- a/calendar/goto.c
+++ b/calendar/goto.c
@@ -11,7 +11,7 @@
#include "gnome-month-item.h"
#include "main.h"
#include "mark.h"
-#include "timeutil.h"
+#include "cal-util/timeutil.h"
static GtkWidget *goto_win; /* The goto dialog window */
diff --git a/calendar/gui/Makefile.am b/calendar/gui/Makefile.am
index d9001476a4..40e1357a62 100644
--- a/calendar/gui/Makefile.am
+++ b/calendar/gui/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = doc idl pcs cal-client
+SUBDIRS = doc idl cal-util pcs cal-client
idldir = $(datadir)/idl
idl_DATA = \
@@ -27,7 +27,8 @@ INCLUDES = \
$(BONOBO_VFS_GNOME_CFLAGS) \
$(GNOME_CONDUIT_INCLUDEDIR) \
$(PISOCK_INCLUDEDIR) \
- -I../libical/src/libical \
+ -I$(top_srcdir) \
+ -I$(top_srcdir)/libical/src/libical \
-DGNOMELOCALEDIR=\""$(datadir)/locale"\"
GNOMECAL_CORBA_GENERATED = \
@@ -51,11 +52,7 @@ gnomecal_SOURCES = \
GnomeCal.h \
alarm.c \
alarm.h \
- calendar.c \
- calendar.h \
calendar-conduit.h \
- calobj.c \
- calobj.h \
eventedit.c \
eventedit.h \
corba-cal.c \
@@ -78,8 +75,6 @@ gnomecal_SOURCES = \
gnome-cal.c \
gnome-cal.h \
goto.c \
- icalendar.c \
- icalendar.h \
layout.c \
layout.h \
main.c \
@@ -93,14 +88,21 @@ gnomecal_SOURCES = \
prop.c \
quick-view.c \
quick-view.h \
- timeutil.c \
- timeutil.h \
todo-conduit.h \
view-utils.h \
view-utils.c \
year-view.c \
year-view.h
+# calendar.c \
+# calendar.h \
+# calobj.c \
+# calobj.h \
+# icalendar.c \
+# icalendar.h \
+# timeutil.c \
+# timeutil.h \
+
calendar_pilot_sync_SOURCES = \
GnomeCal-common.c \
GnomeCal-stubs.c \
@@ -116,6 +118,7 @@ calendar_pilot_sync_SOURCES = \
LINK_FLAGS = \
$(BONOBO_VFS_GNOME_LIBS) \
$(INTLLIBS) \
+ cal-util/libcalutil.la \
../libversit/libversit.la \
$(ICAL_LINK_FLAGS)
diff --git a/calendar/gui/alarm-notify/alarm.h b/calendar/gui/alarm-notify/alarm.h
index 2dc77e623b..6bb5c1afa5 100644
--- a/calendar/gui/alarm-notify/alarm.h
+++ b/calendar/gui/alarm-notify/alarm.h
@@ -2,7 +2,7 @@
#define ALARM_H
#include <time.h>
-#include "calobj.h"
+#include "pcs/calobj.h"
typedef void (*AlarmFunction)(time_t time, CalendarAlarm *which, void *closuse);
diff --git a/calendar/gui/alarm.h b/calendar/gui/alarm.h
index 2dc77e623b..6bb5c1afa5 100644
--- a/calendar/gui/alarm.h
+++ b/calendar/gui/alarm.h
@@ -2,7 +2,7 @@
#define ALARM_H
#include <time.h>
-#include "calobj.h"
+#include "pcs/calobj.h"
typedef void (*AlarmFunction)(time_t time, CalendarAlarm *which, void *closuse);
diff --git a/calendar/gui/calendar.c b/calendar/gui/calendar.c
index 172ef3390e..776f38452d 100644
--- a/calendar/gui/calendar.c
+++ b/calendar/gui/calendar.c
@@ -20,7 +20,7 @@
#include "calendar.h"
#include "alarm.h"
#include "timeutil.h"
-#include "../libversit/vcc.h"
+#include "libversit/vcc.h"
#include "icalendar.h"
#ifdef HAVE_TZNAME
diff --git a/calendar/gui/calendar.h b/calendar/gui/calendar.h
index 23fa65c094..83a5f67c84 100644
--- a/calendar/gui/calendar.h
+++ b/calendar/gui/calendar.h
@@ -1,7 +1,7 @@
#ifndef CALENDAR_H
#define CALENDAR_H
-#include "calobj.h"
+#include "pcs/calobj.h"
BEGIN_GNOME_DECLS
diff --git a/calendar/gui/corba-cal-factory.c b/calendar/gui/corba-cal-factory.c
index a86af3c238..a0630fda73 100644
--- a/calendar/gui/corba-cal-factory.c
+++ b/calendar/gui/corba-cal-factory.c
@@ -12,8 +12,8 @@
#include "gnome-cal.h"
#include "main.h"
#include "alarm.h"
-#include "timeutil.h"
-#include "../libversit/vcc.h"
+#include "cal-util/timeutil.h"
+#include "libversit/vcc.h"
#include <libgnorba/gnorba.h>
#include <bonobo.h>
#include "GnomeCal.h"
diff --git a/calendar/gui/corba-cal.c b/calendar/gui/corba-cal.c
index 6d848ddb87..759b989893 100644
--- a/calendar/gui/corba-cal.c
+++ b/calendar/gui/corba-cal.c
@@ -12,8 +12,8 @@
#include "calendar.h"
#include "gnome-cal.h"
#include "alarm.h"
-#include "timeutil.h"
-#include "../libversit/vcc.h"
+#include "cal-util/timeutil.h"
+#include "libversit/vcc.h"
#include <libgnorba/gnome-factory.h>
#include "GnomeCal.h"
#include "corba-cal-factory.h"
diff --git a/calendar/gui/eventedit.c b/calendar/gui/eventedit.c
index a3ec95da07..e65db4e3da 100644
--- a/calendar/gui/eventedit.c
+++ b/calendar/gui/eventedit.c
@@ -11,7 +11,7 @@
#include "calendar.h"
#include "eventedit.h"
#include "main.h"
-#include "timeutil.h"
+#include "cal-util/timeutil.h"
static void event_editor_class_init (EventEditorClass *class);
diff --git a/calendar/gui/gncal-day-panel.c b/calendar/gui/gncal-day-panel.c
index f407a497d3..8d21b6fabc 100644
--- a/calendar/gui/gncal-day-panel.c
+++ b/calendar/gui/gncal-day-panel.c
@@ -10,7 +10,7 @@
#include <gtk/gtkhseparator.h>
#include "gncal-day-panel.h"
#include "main.h"
-#include "timeutil.h"
+#include "cal-util/timeutil.h"
guint
diff --git a/calendar/gui/gncal-day-view.c b/calendar/gui/gncal-day-view.c
index 22a0859069..955aac0ef9 100644
--- a/calendar/gui/gncal-day-view.c
+++ b/calendar/gui/gncal-day-view.c
@@ -8,7 +8,7 @@
#include <gnome.h>
#include "gncal-day-view.h"
-#include "timeutil.h"
+#include "cal-util/timeutil.h"
#include "view-utils.h"
#include "main.h"
#include "eventedit.h"
diff --git a/calendar/gui/gncal-week-view.c b/calendar/gui/gncal-week-view.c
index 888c656ff4..553977e076 100644
--- a/calendar/gui/gncal-week-view.c
+++ b/calendar/gui/gncal-week-view.c
@@ -12,7 +12,7 @@
#include <gtk/gtk.h>
#include "gncal-week-view.h"
#include "main.h"
-#include "timeutil.h"
+#include "cal-util/timeutil.h"
static void gncal_week_view_init (GncalWeekView *wview);
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
index 0e3c475fdf..8682099900 100644
--- a/calendar/gui/gnome-cal.c
+++ b/calendar/gui/gnome-cal.c
@@ -17,7 +17,7 @@
#include "gncal-week-view.h"
#include "month-view.h"
#include "year-view.h"
-#include "timeutil.h"
+#include "cal-util/timeutil.h"
#include "main.h"
#include "corba-cal.h"
diff --git a/calendar/gui/goto.c b/calendar/gui/goto.c
index 41609da678..ef756a5463 100644
--- a/calendar/gui/goto.c
+++ b/calendar/gui/goto.c
@@ -11,7 +11,7 @@
#include "gnome-month-item.h"
#include "main.h"
#include "mark.h"
-#include "timeutil.h"
+#include "cal-util/timeutil.h"
static GtkWidget *goto_win; /* The goto dialog window */
diff --git a/calendar/gui/main.c b/calendar/gui/main.c
index eb1823fc6f..c4db8701ad 100644
--- a/calendar/gui/main.c
+++ b/calendar/gui/main.c
@@ -21,7 +21,7 @@
#include "eventedit.h"
#include "gnome-cal.h"
#include "main.h"
-#include "timeutil.h"
+#include "cal-util/timeutil.h"
#include "corba-cal-factory.h"
#define COOKIE_USER_HOME_DIR ((char *) -1)
diff --git a/calendar/gui/mark.c b/calendar/gui/mark.c
index 2de8e2b880..288b6d3b11 100644
--- a/calendar/gui/mark.c
+++ b/calendar/gui/mark.c
@@ -9,7 +9,7 @@
#include "gnome-cal.h"
#include "main.h"
#include "mark.h"
-#include "timeutil.h"
+#include "cal-util/timeutil.h"
/* Frees the specified data when an object is destroyed */
diff --git a/calendar/gui/month-view.c b/calendar/gui/month-view.c
index 5df7b7a23d..0a7386f9e4 100644
--- a/calendar/gui/month-view.c
+++ b/calendar/gui/month-view.c
@@ -14,7 +14,7 @@
#include "main.h"
#include "mark.h"
#include "quick-view.h"
-#include "timeutil.h"
+#include "cal-util/timeutil.h"
/* Spacing between title and calendar */
diff --git a/calendar/gui/year-view.c b/calendar/gui/year-view.c
index 5744b4a88f..567340bde1 100644
--- a/calendar/gui/year-view.c
+++ b/calendar/gui/year-view.c
@@ -14,7 +14,7 @@
#include "main.h"
#include "mark.h"
#include "quick-view.h"
-#include "timeutil.h"
+#include "cal-util/timeutil.h"
#define HEAD_SPACING 4 /* Spacing between year heading and months */
diff --git a/calendar/main.c b/calendar/main.c
index eb1823fc6f..c4db8701ad 100644
--- a/calendar/main.c
+++ b/calendar/main.c
@@ -21,7 +21,7 @@
#include "eventedit.h"
#include "gnome-cal.h"
#include "main.h"
-#include "timeutil.h"
+#include "cal-util/timeutil.h"
#include "corba-cal-factory.h"
#define COOKIE_USER_HOME_DIR ((char *) -1)
diff --git a/calendar/mark.c b/calendar/mark.c
index 2de8e2b880..288b6d3b11 100644
--- a/calendar/mark.c
+++ b/calendar/mark.c
@@ -9,7 +9,7 @@
#include "gnome-cal.h"
#include "main.h"
#include "mark.h"
-#include "timeutil.h"
+#include "cal-util/timeutil.h"
/* Frees the specified data when an object is destroyed */
diff --git a/calendar/month-view.c b/calendar/month-view.c
index 5df7b7a23d..0a7386f9e4 100644
--- a/calendar/month-view.c
+++ b/calendar/month-view.c
@@ -14,7 +14,7 @@
#include "main.h"
#include "mark.h"
#include "quick-view.h"
-#include "timeutil.h"
+#include "cal-util/timeutil.h"
/* Spacing between title and calendar */
diff --git a/calendar/pcs/Makefile.am b/calendar/pcs/Makefile.am
index dd9e3302b9..69f718b4a4 100644
--- a/calendar/pcs/Makefile.am
+++ b/calendar/pcs/Makefile.am
@@ -4,6 +4,23 @@
bin_PROGRAMS = tlacuache
+#INCLUDES = \
+# -DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
+# -I$(top_srcdir)/libical/src/libical \
+# -I$(top_srcdir)/libversit \
+# -I$(top_srcdir)/calendar \
+# -I. \
+# -I$(top_srcdir)/calendar/cal-client \
+# $(GNOME_INCLUDEDIR)
+
+INCLUDES = \
+ -I$(top_srcdir)/calendar/cal-client \
+ -I$(top_srcdir)/calendar/cal-util \
+ -I$(top_srcdir)/calendar \
+ -I$(top_srcdir)/libical/src/libical \
+ $(GNOME_INCLUDEDIR) \
+ -DGNOMELOCALEDIR=\""$(datadir)/locale"\"
+
CORBA_GENERATED = \
evolution-calendar.h \
evolution-calendar-common.c \
@@ -18,19 +35,17 @@ idl_flags = `$(GNOME_CONFIG) --cflags idl`
$(CORBA_GENERATED): $(idls)
$(ORBIT_IDL) $(idl_flags) $(srcdir)/../idl/evolution-calendar.idl
-tlacuache_INCLUDES = \
- -DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
- -I$(srcdir) -I$(top_srcdir) \
- -I. \
- -I.. \
- -I$(top_builddir) \
- -I$(includedir) \
- $(GNOME_INCLUDEDIR)
+#tlacuache_INCLUDES = \
+# -DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
+# -I$(srcdir) -I$(top_srcdir) \
+# -I. \
+# -I.. \
+# -I$(top_builddir) \
+# -I$(includedir) \
+# $(GNOME_INCLUDEDIR)
tlacuache_SOURCES = \
$(CORBA_GENERATED) \
- alarm.c \
- alarm.h \
cal.c \
cal.h \
cal-backend.c \
@@ -38,23 +53,26 @@ tlacuache_SOURCES = \
cal-common.h \
cal-factory.c \
cal-factory.h \
- cal-util.c \
- cal-util.h \
calobj.c \
calobj.h \
icalendar.c \
icalendar.h \
job.c \
job.h \
- timeutil.c \
- timeutil.h \
tlacuache.c
+# alarm.c \
+# alarm.h \
+# cal-util.c \
+# cal-util.h \
+
+
ICAL_LINK_FLAGS = $(top_builddir)/libical/src/libical/libical.la
-tlacuache_LDADD = \
- $(BONOBO_VFS_GNOME_LIBS) \
- ../libversit/libversit.la \
+tlacuache_LDADD = \
+ $(BONOBO_VFS_GNOME_LIBS) \
+ $(top_srcdir)/calendar/cal-util/libcalutil.la \
+ $(top_srcdir)/libversit/libversit.la \
$(ICAL_LINK_FLAGS)
gnorbadir = $(sysconfdir)/CORBA/servers
diff --git a/calendar/pcs/icalendar.c b/calendar/pcs/icalendar.c
new file mode 100644
index 0000000000..0a0f39c636
--- /dev/null
+++ b/calendar/pcs/icalendar.c
@@ -0,0 +1,657 @@
+/*
+ * icalendar server for gnomecal
+ *
+ * This module interfaces between libical and the gnomecal internal
+ * representation
+ *
+ * Copyright (C) 1999 The Free Software Foundation
+ * Authors:
+ * Russell Steinthal (rms39@columbia.edu)
+ *
+ */
+
+#include <config.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include "icalendar.h"
+
+static time_t icaltime_to_timet (struct icaltimetype* i);
+static CalendarAlarm* parse_alarm (icalproperty *prop);
+static iCalPerson* parse_person (icalproperty *prop, gchar *value);
+static iCalRelation* parse_related (icalproperty *prop);
+
+/* Duplicate a string without memory leaks */
+static gchar* copy_str (gchar** store, gchar* src)
+{
+ if (*store)
+ g_free (*store);
+ return (*store = g_strdup (src));
+}
+
+static GList*
+copy_to_list (GList** store, gchar* src)
+{
+ *store = g_list_prepend (*store, g_strdup (src));
+ return *store;
+}
+
+
+iCalObject *
+ical_object_create_from_icalcomponent (icalcomponent* comp)
+{
+ iCalObject *ical = NULL;
+ iCalPerson *person;
+ icalcomponent *subcomp;
+ icalproperty *prop;
+ icalparameter *param;
+ struct icaltimetype ictime;
+ time_t *pt;
+ CalendarAlarm *alarm = NULL;
+ icalcomponent_kind compType;
+ struct icalgeotype geo;
+ struct icalperiodtype period;
+
+ gboolean root = FALSE;
+ gboolean attachment = FALSE;
+
+ char *tmpStr; /* this is a library-owned string */
+
+ ical = g_new0 (iCalObject, 1);
+
+ compType = icalcomponent_isa (comp);
+
+ switch (compType) {
+ case ICAL_XROOT_COMPONENT:
+ root = TRUE;
+ break;
+ case ICAL_XATTACH_COMPONENT:
+ attachment = TRUE;
+ break;
+ case ICAL_VEVENT_COMPONENT:
+ ical->type = ICAL_EVENT;
+ break;
+ case ICAL_VTODO_COMPONENT:
+ ical->type = ICAL_TODO;
+ break;
+ case ICAL_VJOURNAL_COMPONENT:
+ ical->type = ICAL_JOURNAL;
+ break;
+ case ICAL_VCALENDAR_COMPONENT:
+ /* FIXME: what does this mean? */
+ break;
+ case ICAL_VFREEBUSY_COMPONENT:
+ ical->type = ICAL_FBREQUEST;
+ /* NOTE: This is not conclusive- you need to analyze
+ properties to determine whether this is an
+ FBREQUEST or an FBREPLY */
+ break;
+ case ICAL_VTIMEZONE_COMPONENT:
+ ical->type = ICAL_TIMEZONE;
+ break;
+ case ICAL_VALARM_COMPONENT:
+ case ICAL_XAUDIOALARM_COMPONENT:
+ case ICAL_XDISPLAYALARM_COMPONENT:
+ case ICAL_XEMAILALARM_COMPONENT:
+ case ICAL_XPROCEDUREALARM_COMPONENT:
+ /* this should not be reached, since this loop should
+ only be processing first level components */
+ break;
+ case ICAL_XSTANDARD_COMPONENT:
+ /* FIXME: what does this mean? */
+ break;
+ case ICAL_XDAYLIGHT_COMPONENT:
+ /* FIXME: what does this mean? */
+ break;
+ case ICAL_X_COMPONENT:
+ /* FIXME: what does this mean? */
+ break;
+ case ICAL_VSCHEDULE_COMPONENT:
+ /* FIXME: what does this mean? */
+ break;
+ case ICAL_XLICINVALID_COMPONENT:
+ /* FIXME: what does this mean? */
+ break;
+ case ICAL_NO_COMPONENT:
+ case ICAL_ANY_COMPONENT:
+ /* should not occur */
+ break;
+ case ICAL_VQUERY_COMPONENT:
+ case ICAL_VCAR_COMPONENT:
+ case ICAL_VCOMMAND_COMPONENT:
+ /* FIXME: what does this mean? */
+ break;
+ }
+
+ prop = icalcomponent_get_first_property (comp, ICAL_ANY_PROPERTY);
+ while (prop) {
+ switch (icalproperty_isa (prop)) {
+ case ICAL_CALSCALE_PROPERTY:
+ if (g_strcasecmp (icalproperty_get_calscale (prop),
+ "GREGORIAN"))
+ g_warning ("Unknown calendar format.");
+ break;
+ case ICAL_METHOD_PROPERTY:
+ /* FIXME: implement something here */
+ break;
+ case ICAL_ATTACH_PROPERTY:
+ /* FIXME: not yet implemented */
+ break;
+ case ICAL_CATEGORIES_PROPERTY:
+ copy_to_list (&ical->categories,
+ icalproperty_get_categories (prop));
+ break;
+ case ICAL_CLASS_PROPERTY:
+ copy_str (&ical->class, icalproperty_get_class (prop));
+ break;
+ case ICAL_COMMENT_PROPERTY:
+ /*tmpStr = icalproperty_get_comment (prop);*/
+ tmpStr = g_strconcat (icalproperty_get_comment (prop),
+ ical->comment,
+ NULL);
+ if (ical->comment)
+ g_free (ical->comment);
+ ical->comment = tmpStr;
+ break;
+ case ICAL_DESCRIPTION_PROPERTY:
+ copy_str (&ical->desc,
+ icalproperty_get_description (prop));
+ break;
+ case ICAL_GEO_PROPERTY:
+ geo = icalproperty_get_geo (prop);
+ ical->geo.latitude = geo.lat;
+ ical->geo.longitude = geo.lon;
+ ical->geo.valid = TRUE;
+ break;
+ case ICAL_LOCATION_PROPERTY:
+ copy_str (&ical->location,
+ icalproperty_get_location (prop));
+ break;
+ case ICAL_PERCENTCOMPLETE_PROPERTY:
+ ical->percent = icalproperty_get_percentcomplete (prop);
+ break;
+ case ICAL_PRIORITY_PROPERTY:
+ ical->priority = icalproperty_get_priority (prop);
+ if (ical->priority < 0 || ical->priority > 9)
+ g_warning ("Priority out-of-range (see RFC2445)");
+ break;
+ case ICAL_RESOURCES_PROPERTY:
+ copy_to_list (&ical->resources,
+ icalproperty_get_resources (prop));
+ break;
+ case ICAL_STATUS_PROPERTY:
+ copy_str (&ical->status,
+ icalproperty_get_status (prop));
+ break;
+ case ICAL_SUMMARY_PROPERTY:
+ copy_str (&ical->summary,
+ icalproperty_get_summary (prop));
+ break;
+ case ICAL_COMPLETED_PROPERTY:
+ ictime = icalproperty_get_completed (prop);
+ ical->completed = icaltime_to_timet (&ictime);
+ break;
+ case ICAL_DTEND_PROPERTY:
+ ictime = icalproperty_get_dtend (prop);
+ ical->dtend = icaltime_to_timet (&ictime);
+ param = icalproperty_get_first_parameter (prop,
+ ICAL_VALUE_PARAMETER);
+ ical->date_only = (icalparameter_get_value (param) ==
+ ICAL_VALUE_DATE);
+ /* FIXME: We should handle timezone specifiers */
+ break;
+ case ICAL_DUE_PROPERTY:
+ ictime = icalproperty_get_due (prop);
+ ical->dtend = icaltime_to_timet (&ictime);
+ param = icalproperty_get_first_parameter (prop,
+ ICAL_VALUE_PARAMETER);
+ ical->date_only = (icalparameter_get_value (param) ==
+ ICAL_VALUE_DATE);
+ /* FIXME: We should handle timezone specifiers */
+ break;
+ case ICAL_DTSTART_PROPERTY:
+ ictime = icalproperty_get_dtstart (prop);
+ ical->dtstart = icaltime_to_timet (&ictime);
+ param = icalproperty_get_first_parameter (prop,
+ ICAL_VALUE_PARAMETER);
+ ical->date_only = (icalparameter_get_value (param) ==
+ ICAL_VALUE_DATE);
+ /* FIXME: We should handle timezone specifiers */
+ break;
+ case ICAL_DURATION_PROPERTY:
+ /* FIXME: I don't see the necessary libical function */
+ break;
+ case ICAL_FREEBUSY_PROPERTY:
+ period = icalproperty_get_freebusy (prop);
+ ical->dtstart = icaltime_to_timet (&(period.start));
+ /* FIXME: period.end is specified as being relative to start, so
+this may not be correct */
+ ical->dtend = icaltime_to_timet (&(period.end));
+ break;
+ case ICAL_TRANSP_PROPERTY:
+ tmpStr = icalproperty_get_transp (prop);
+ /* do not i18n the following string constant! */
+ if (!g_strcasecmp (tmpStr, "TRANSPARENT"))
+ ical->transp = ICAL_TRANSPARENT;
+ else
+ ical->transp = ICAL_OPAQUE;
+ break;
+ case ICAL_TZID_PROPERTY:
+ case ICAL_TZNAME_PROPERTY:
+ case ICAL_TZOFFSETFROM_PROPERTY:
+ case ICAL_TZOFFSETTO_PROPERTY:
+ case ICAL_TZURL_PROPERTY:
+ /* no implementation for now */
+ break;
+ case ICAL_ATTENDEE_PROPERTY:
+ tmpStr = icalproperty_get_attendee (prop);
+ person = parse_person (prop, tmpStr);
+ ical->attendee = g_list_prepend (ical->attendee,
+ person);
+ break;
+ case ICAL_CONTACT_PROPERTY:
+ tmpStr = icalproperty_get_contact (prop);
+ person = parse_person (prop, tmpStr);
+ ical->contact = g_list_prepend (ical->contact, person);
+ break;
+ case ICAL_ORGANIZER_PROPERTY:
+ tmpStr = icalproperty_get_organizer (prop);
+ person = parse_person (prop, tmpStr);
+ if (ical->organizer)
+ g_free (ical->organizer);
+ ical->organizer = person;
+ break;
+ case ICAL_RECURRENCEID_PROPERTY:
+ ictime = icalproperty_get_recurrenceid (prop);
+ ical->recurid = icaltime_to_timet (&ictime);
+ /* FIXME: Range parameter not implemented */
+ break;
+ case ICAL_RELATEDTO_PROPERTY:
+ ical->related = g_list_prepend (ical->related,
+ parse_related (prop));
+ break;
+ case ICAL_URL_PROPERTY:
+ copy_str (&ical->url,
+ icalproperty_get_url (prop));
+ break;
+ case ICAL_UID_PROPERTY:
+ copy_str (&ical->uid,
+ icalproperty_get_uid (prop));
+ break;
+ case ICAL_EXDATE_PROPERTY:
+ /* FIXME: This does not appear to parse
+ multiple exdate values in one property, as
+ allowed by the RFC; needs a libical fix */
+ ictime = icalproperty_get_exdate (prop);
+ pt = g_new0 (time_t, 1);
+ *pt = icaltime_to_timet (&ictime);
+ ical->exdate = g_list_prepend (ical->exdate, pt);
+ break;
+ case ICAL_EXRULE_PROPERTY:
+ case ICAL_RDATE_PROPERTY:
+ case ICAL_RRULE_PROPERTY:
+ /* FIXME: need recursion processing */
+ break;
+ case ICAL_ACTION_PROPERTY:
+ case ICAL_REPEAT_PROPERTY:
+ case ICAL_TRIGGER_PROPERTY:
+ /* should only occur in VALARM's, handled below */
+ g_assert_not_reached();
+ break;
+ case ICAL_CREATED_PROPERTY:
+ ictime = icalproperty_get_created (prop);
+ ical->created = icaltime_to_timet (&ictime);
+ break;
+ case ICAL_DTSTAMP_PROPERTY:
+ ictime = icalproperty_get_dtstamp (prop);
+ ical->dtstamp = icaltime_to_timet (&ictime);
+ break;
+ case ICAL_LASTMODIFIED_PROPERTY:
+ ictime = icalproperty_get_lastmodified (prop);
+ ical->last_mod = icaltime_to_timet (&ictime);
+ break;
+ case ICAL_SEQUENCE_PROPERTY:
+ ical->seq = icalproperty_get_sequence (prop);
+ break;
+ case ICAL_REQUESTSTATUS_PROPERTY:
+ copy_str (&ical->rstatus,
+ icalproperty_get_requeststatus (prop));
+ break;
+ case ICAL_X_PROPERTY:
+ g_warning ("Unsupported X-property: %s",
+ icalproperty_as_ical_string (prop));
+ break;
+ case ICAL_XLICERROR_PROPERTY:
+ g_warning ("Unsupported property: %s",
+ icalproperty_get_xlicerror (prop));
+ break;
+ case ICAL_PRODID_PROPERTY:
+ case ICAL_VERSION_PROPERTY:
+ /* nothing to do for this property */
+ break;
+ default:
+ g_warning ("Unsupported property: %s", icalproperty_as_ical_string
+(prop));
+ break;
+
+ }
+
+ prop = icalcomponent_get_next_property (comp,
+ ICAL_ANY_PROPERTY);
+ }
+
+ /* now parse subcomponents --- should only be VALARM's */
+ subcomp = icalcomponent_get_first_component (comp,
+ ICAL_ANY_COMPONENT);
+ while (subcomp) {
+ compType = icalcomponent_isa (subcomp);
+ switch (compType) {
+ case ICAL_VALARM_COMPONENT:
+ alarm = parse_alarm (subcomp);
+ if (alarm)
+ ical->alarms = g_list_prepend (ical->alarms,
+ alarm);
+ break;
+ default:
+ g_warning ("Only nested VALARM components are supported.");
+ }
+
+ subcomp = icalcomponent_get_next_component (comp,
+ ICAL_ANY_COMPONENT);
+ }
+
+ return ical;
+}
+
+
+static time_t icaltime_to_timet (struct icaltimetype* i)
+{
+ extern long timezone;
+ struct tm t;
+ time_t ret;
+
+ t.tm_year = i->year - 1900;
+ t.tm_mon = i->month - 1;
+ t.tm_mday = i->day;
+ if (!i->is_date) {
+ t.tm_hour = i->hour;
+ t.tm_min = i->minute;
+ t.tm_sec = i->second;
+ } else {
+ t.tm_hour = 0;
+ t.tm_min = 0;
+ t.tm_sec = 0;
+ }
+
+ ret = mktime(&t);
+
+ return ret - (i->is_utc ? timezone : 0);
+}
+
+static iCalPerson*
+parse_person (icalproperty* prop, gchar* value)
+{
+ icalparameter* param;
+ icalparameter_role role;
+ icalparameter_partstat partstat;
+ icalparameter_cutype cutype;
+
+ iCalPerson* ret;
+
+ ret = g_new0 (iCalPerson, 1);
+
+ ret->addr = g_strdup (value);
+
+ param = icalproperty_get_first_parameter (prop,
+ ICAL_CN_PARAMETER);
+ ret->name = g_strdup (icalparameter_get_cn (param));
+
+ param = icalproperty_get_first_parameter (prop,
+ ICAL_ROLE_PARAMETER);
+ if (param) {
+ role = icalparameter_get_role (param);
+ switch (role) {
+ case ICAL_ROLE_CHAIR:
+ ret->role = g_strdup ("CHAIR");
+ break;
+ case ICAL_ROLE_REQPARTICIPANT:
+ ret->role = g_strdup ("REQPARTICIPANT");
+ break;
+ case ICAL_ROLE_OPTPARTICIPANT:
+ ret->role = g_strdup ("OPTPARTICIPANT");
+ break;
+ case ICAL_ROLE_NONPARTICIPANT:
+ ret->role = g_strdup ("NONPARTICIPANT");
+ break;
+ case ICAL_ROLE_XNAME:
+ default:
+ ret->role = g_strdup ("UNKNOWN");
+ break;
+ }
+ } else
+ ret->role = g_strdup ("REQPARTICIPANT");
+
+ param = icalproperty_get_first_parameter (prop, ICAL_PARTSTAT_PARAMETER);
+ if (param) {
+ partstat = icalparameter_get_partstat (param);
+ switch (partstat) {
+ case ICAL_PARTSTAT_NEEDSACTION:
+ ret->partstat = g_strdup ("NEEDSACTION");
+ break;
+ case ICAL_PARTSTAT_ACCEPTED:
+ ret->partstat = g_strdup ("ACCEPTED");
+ break;
+ case ICAL_PARTSTAT_DECLINED:
+ ret->partstat = g_strdup ("DECLINED");
+ break;
+ case ICAL_PARTSTAT_TENTATIVE:
+ ret->partstat = g_strdup ("TENTATIVE");
+ break;
+ case ICAL_PARTSTAT_DELEGATED:
+ ret->partstat = g_strdup ("DELEGATED");
+ break;
+ case ICAL_PARTSTAT_COMPLETED:
+ ret->partstat = g_strdup ("COMPLETED");
+ break;
+ case ICAL_PARTSTAT_INPROCESS:
+ ret->partstat = g_strdup ("INPROCESS");
+ break;
+ case ICAL_PARTSTAT_XNAME:
+ ret->partstat = g_strdup (icalparameter_get_xvalue (param));
+ break;
+ default:
+ ret->partstat = g_strdup ("UNKNOWN");
+ break;
+ }
+ } else
+ ret->partstat = g_strdup ("NEEDSACTION");
+
+ param = icalproperty_get_first_parameter (prop, ICAL_RSVP_PARAMETER);
+ if (param)
+ ret->rsvp = icalparameter_get_rsvp (param);
+ else
+ ret->rsvp = FALSE;
+
+ param = icalproperty_get_first_parameter (prop, ICAL_CUTYPE_PARAMETER
+);
+ if (param) {
+ cutype = icalparameter_get_cutype (param);
+ switch (cutype) {
+ case ICAL_CUTYPE_INDIVIDUAL:
+ ret->cutype = g_strdup ("INDIVIDUAL");
+ break;
+ case ICAL_CUTYPE_GROUP:
+ ret->cutype = g_strdup ("GROUP");
+ break;
+ case ICAL_CUTYPE_RESOURCE:
+ ret->cutype = g_strdup ("RESOURCE");
+ break;
+ case ICAL_CUTYPE_ROOM:
+ ret->cutype = g_strdup ("ROOM");
+ break;
+ case ICAL_CUTYPE_UNKNOWN:
+ case ICAL_CUTYPE_XNAME:
+ default:
+ ret->cutype = g_strdup ("UNKNOWN");
+ break;
+ }
+ } else
+ ret->cutype = g_strdup ("INDIVIDUAL");
+
+ param = icalproperty_get_first_parameter (prop, ICAL_MEMBER_PARAMETER
+);
+ while (param) {
+ copy_to_list (&ret->member, icalparameter_get_member (param));
+ param = icalproperty_get_next_parameter (prop,
+ ICAL_MEMBER_PARAMETER);
+ }
+
+ param = icalproperty_get_first_parameter (prop, ICAL_DELEGATEDTO_PARAMETER);
+ while (param) {
+ copy_to_list (&ret->deleg_to,
+ icalparameter_get_delegatedto (param));
+ param = icalproperty_get_next_parameter (prop,
+ ICAL_DELEGATEDTO_PARAMETER);
+ }
+
+ param = icalproperty_get_first_parameter (prop, ICAL_DELEGATEDFROM_PARAMETER);
+ while (param) {
+ copy_to_list (&ret->deleg_from,
+ icalparameter_get_delegatedfrom (param));
+ param = icalproperty_get_next_parameter (prop,
+ ICAL_DELEGATEDFROM_PARAMETER);
+ }
+
+ param = icalproperty_get_first_parameter (prop, ICAL_SENTBY_PARAMETER
+);
+ copy_str (&ret->sent_by,
+ icalparameter_get_sentby (param));
+
+ param = icalproperty_get_first_parameter (prop, ICAL_DIR_PARAMETER);
+ while (param) {
+ copy_to_list (&ret->deleg_to,
+ icalparameter_get_delegatedto (param));
+ param = icalproperty_get_next_parameter (prop,
+ ICAL_DIR_PARAMETER);
+ }
+
+ return ret;
+}
+
+static iCalRelation*
+parse_related (icalproperty* prop)
+{
+ iCalRelation* rel;
+ icalparameter* param;
+ icalparameter_reltype type;
+
+ rel = g_new0 (iCalRelation, 1);
+ rel->uid = g_strdup (icalproperty_get_relatedto (prop));
+
+ param = icalproperty_get_first_parameter (prop,
+ ICAL_RELTYPE_PARAMETER);
+ if (param) {
+ type = icalparameter_get_reltype (param);
+ switch (type) {
+ case ICAL_RELTYPE_PARENT:
+ rel->reltype = g_strdup ("PARENT");
+ break;
+ case ICAL_RELTYPE_CHILD:
+ rel->reltype = g_strdup ("CHILD");
+ break;
+ case ICAL_RELTYPE_SIBLING:
+ rel->reltype = g_strdup ("SIBLING");
+ break;
+ case ICAL_RELTYPE_XNAME:
+ rel->reltype = g_strdup (icalparameter_get_xvalue (param));
+ break;
+ default:
+ rel->reltype = g_strdup ("UNKNOWN");
+ break;
+ }
+ } else
+ rel->reltype = g_strdup ("PARENT");
+
+ return rel;
+}
+
+#ifdef TEST
+
+int main(int argc, char* argv[])
+{
+ icalcomponent* comp;
+ comp = icalendar_parse_file (argv[1]);
+ printf ("%s\n", icalcomponent_as_ical_string (comp));
+ return 0;
+}
+
+#endif
+
+
+static CalendarAlarm*
+parse_alarm (icalcomponent* comp)
+{
+ CalendarAlarm *alarm;
+ icalproperty *prop;
+ char *tmpStr;
+ struct icaldurationtype dur;
+ struct icalattachtype attach;
+
+ g_return_val_if_fail (comp != NULL, NULL);
+
+ alarm = g_new0 (CalendarAlarm, 1);
+
+ prop = icalcomponent_get_first_property (comp, ICAL_ANY_PROPERTY);
+ while (prop) {
+ switch (icalproperty_isa (prop)) {
+ case ICAL_ACTION_PROPERTY:
+ tmpStr = icalproperty_get_action (prop);
+ if (!g_strcasecmp (tmpStr, "AUDIO"))
+ alarm->type = ALARM_AUDIO;
+ else if (!g_strcasecmp (tmpStr, "DISPLAY"))
+ alarm->type = ALARM_DISPLAY;
+ else if (!g_strcasecmp (tmpStr, "EMAIL"))
+ alarm->type = ALARM_MAIL;
+ else if (!g_strcasecmp (tmpStr, "PROCEDURE"))
+ alarm->type = ALARM_PROGRAM;
+ else
+ g_warning ("Unsupported alarm type!");
+ break;
+ case ICAL_TRIGGER_PROPERTY:
+ /* FIXME: waiting on proper libical support */
+ break;
+ case ICAL_REPEAT_PROPERTY:
+ alarm->snooze_repeat = icalproperty_get_repeat (prop);
+ break;
+ case ICAL_DURATION_PROPERTY:
+ dur = icalproperty_get_duration (prop);
+ alarm->snooze_secs = icaldurationtype_as_timet (dur);
+ break;
+ case ICAL_ATTACH_PROPERTY:
+ attach = icalproperty_get_attach (prop);
+ copy_str (&alarm->attach,
+ icalattachtype_get_url (&attach));
+ break;
+ case ICAL_DESCRIPTION_PROPERTY:
+ copy_str (&alarm->desc,
+ icalproperty_get_description (prop));
+ break;
+ case ICAL_SUMMARY_PROPERTY:
+ copy_str (&alarm->summary,
+ icalproperty_get_summary (prop));
+ break;
+ case ICAL_ATTENDEE_PROPERTY:
+ copy_str (&alarm->attendee,
+ icalproperty_get_attendee (prop));
+ break;
+ default:
+ g_warning ("Unsupported alarm property: %s",
+ icalproperty_as_ical_string (prop));
+ break;
+ }
+
+ prop = icalcomponent_get_next_property (comp,
+ ICAL_ANY_PROPERTY);
+ }
+
+ return alarm;
+}
diff --git a/calendar/pcs/icalendar.h b/calendar/pcs/icalendar.h
new file mode 100644
index 0000000000..09bfa06fad
--- /dev/null
+++ b/calendar/pcs/icalendar.h
@@ -0,0 +1,13 @@
+#ifndef ICALENDAR_H
+#define ICALENDAR_H
+
+#include <ical.h>
+#include "calobj.h"
+
+
+
+iCalObject *ical_object_create_from_icalcomponent (icalcomponent* comp);
+
+
+
+#endif
diff --git a/calendar/year-view.c b/calendar/year-view.c
index 5744b4a88f..567340bde1 100644
--- a/calendar/year-view.c
+++ b/calendar/year-view.c
@@ -14,7 +14,7 @@
#include "main.h"
#include "mark.h"
#include "quick-view.h"
-#include "timeutil.h"
+#include "cal-util/timeutil.h"
#define HEAD_SPACING 4 /* Spacing between year heading and months */