diff options
-rw-r--r-- | calendar/cal-util/calobj.c | 48 | ||||
-rw-r--r-- | calendar/cal-util/calobj.h | 100 | ||||
-rw-r--r-- | calendar/calendar.c | 116 | ||||
-rw-r--r-- | calendar/calendar.h | 25 | ||||
-rw-r--r-- | calendar/calobj.c | 48 | ||||
-rw-r--r-- | calendar/calobj.h | 100 | ||||
-rw-r--r-- | calendar/gui/calendar.c | 116 | ||||
-rw-r--r-- | calendar/gui/calendar.h | 25 | ||||
-rw-r--r-- | calendar/gui/icalendar-types | 39 | ||||
-rw-r--r-- | calendar/icalendar-types | 39 | ||||
-rw-r--r-- | calendar/pcs/calobj.c | 48 | ||||
-rw-r--r-- | calendar/pcs/calobj.h | 100 |
12 files changed, 804 insertions, 0 deletions
diff --git a/calendar/cal-util/calobj.c b/calendar/cal-util/calobj.c new file mode 100644 index 0000000000..87dd8db78d --- /dev/null +++ b/calendar/cal-util/calobj.c @@ -0,0 +1,48 @@ +/* + * Calendar objects implementations. + * Copyright (C) 1998 the Free Software Foundation + * + * Authors: + * Miguel de Icaza (miguel@gnu.org) + * Federico Mena (federico@gimp.org) + */ +#include "calobj.h" + +iCalObject * +ical_object_new (void) +{ + iCalObject *ico; + + ico = g_new0 (iCalObject); + + ico->seq = -1; + ico->dtstamp = time (NULL); + + return ico; +} + +iCalObject * +ical_new (char *comment, char *organizer, char *summary) +{ + iCalObject *ico; + + ico = ical_object_new (); + + ico->comment = g_strdup (comment); + ico->organizer = g_strdup (organizer); + ico->summary = g_strdup (summary); + + return ico; +} + +#define free_if_defined(x) if (x){ g_free (x); x = 0; } + +void +ical_object_destroy (iCalObject *ico) +{ + free_if_defined (ico->comment); + free_if_defined (ico->organizer); + free_if_defined (ico->summary); + + g_free (ico); +} diff --git a/calendar/cal-util/calobj.h b/calendar/cal-util/calobj.h new file mode 100644 index 0000000000..fda3a1e4b5 --- /dev/null +++ b/calendar/cal-util/calobj.h @@ -0,0 +1,100 @@ +/* + * Internal representation of a Calendar object. This is modeled after the + * iCalendar/vCalendar specificiation + * + * Authors: Miguel de Icaza (miguel@gnu.org), Federico Mena (federico@gimp.org). + */ +#ifndef CALOBJ_H +#define CALOBJ_H + +BEGIN_GNOME_DECLS + +typedef struct { + char *alarm_audio_file; + char *alarm_script; + char *alarm_email; + char *alarm_text; /* Text to be displayed */ +} 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 struct { + int valid; /* true if the Geography was specified */ + double latitude; + double longitude; +} iCalGeo; + +typedef enum { + ICAL_OPAQUE, + ICAL_TRANSPARENT +}; + +typedef char NotYet; + +/* + * 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 */ + 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 *description; + time_t dtstamp; + time_t dtstart; + time_t dtend; + GList *exdate; /* type: one or more time_t's */ + GList *exrule; /* type: one or more RECUR */ + iCalGeo geo; + time_t last_mod; + char *location; + char *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; + + /* VALARM objects are always inside another object, never alone */ + CalendarAlarm *alarm; +} iCalObject; + +iCalObject *ical_new (char *comment, char *organizer, char *summary); +iCalObject *ical_object_new (void); + +END_GNOME_DECLS + +#endif + diff --git a/calendar/calendar.c b/calendar/calendar.c new file mode 100644 index 0000000000..8725d96081 --- /dev/null +++ b/calendar/calendar.c @@ -0,0 +1,116 @@ +/* + * Calendar manager object + * + * This keeps track of a given calendar. Eventually this will abtract everything + * related to getting calendars/saving calendars locally or to a remote Calendar Service + * + * Copyright (C) 1998 the Free Software Foundation + * + * Authors: + * Miguel de Icaza (miguel@gnu.org) + * Federico Mena (federico@gimp.org) + * + */ +#include "calobj.h" +#include "calendar.h" + +Calendar * +calendar_new (char *title) +{ + Calendar *cal; + + cal = g_new0 (Calendar, 1); + cal->title = g_strdup (title); + + return cal; +} + +void +calendar_add_object (Calendar *cal, iCalObject *obj) +{ + switch (obj->type){ + case ICAL_EVENT: + cal->events = g_list_prepend (cal->events, obj); + break; + + case ICAL_TODO: + cal->todo = g_list_prepend (cal->todo, obj); + break; + + case ICAL_JOURNAL: + cal->journal = g_list_prepend (cal->journal, obj); + break; + default: + g_assert_not_reached (); + } +} + +void +calendar_remove_object (Calendar *cal, iCalObject *obj) +{ + switch (obj->type){ + case ICAL_EVENT: + cal->events = g_list_remove (cal->events, obj); + break; + + case ICAL_TODO: + cal->todo = g_list_remove (cal->todo, obj); + break; + + case ICAL_JOURNAL: + cal->journal = g_list_remove (cal->journal, obj); + break; + default: + g_assert_not_reached (); + } +} + +void +calendar_destroy (Calendar *cal) +{ + g_list_foreach (cal->events, ical_object_destroy, NULL); + g_list_free (cal->events); + + g_list_foreach (cal->todo, ical_object_destroy, NULL); + g_list_free (cal->todo); + + g_list_foreach (cal->journal, ical_object_destroy, NULL); + g_list_free (cal->journal); + + if (cal->title) + g_free (cal->title); + if (cal->filename) + g_free (cal->filename); + + g_free (cal); +} + +static GList * +calendar_get_objects_in_range (GList *objects, time_t start, time_t end) +{ + GList *new_events = 0; + + for (; objects; objects = objects->next){ + iCalObject *object = objects->data; + + if ((start <= object->dtstart) && (end >= object->dtend)) + new_events = g_list_prepend (new_events, object); + } +} + +GList * +calendar_get_events_in_range (Calendar *cal, time_t start, time_t end) +{ + calendar_get_objects_in_range (cal->events, start, end); +} + +GList * +calendar_get_todo_in_range (Calendar *cal, time_t start, time_t end) +{ + calendar_get_objects_in_range (cal->todo, start, end); +} +GList * +calendar_get_journal_in_range (Calendar *cal, time_t start, time_t end) +{ + calendar_get_objects_in_range (cal->journal, start, end); +} diff --git a/calendar/calendar.h b/calendar/calendar.h new file mode 100644 index 0000000000..f854c69b7a --- /dev/null +++ b/calendar/calendar.h @@ -0,0 +1,25 @@ +#ifndef CALOBJ_H +#define CALOBJ_H + +BEGIN_GNOME_DECLS + +typedef struct { + char *title; + char *filename; + GList *events; + GList *todo; + GList *journal; +} Calendar; + +Calendar *calendar_new (char *title); +void calendar_add_object (Calendar *cal, iCalObject *obj); +void calendar_remove_object (Calendar *cal, iCalObject *obj); +void calendar_destroy (Calendar *cal); + +GList *calendar_get_events_in_range (Calendar *cal, time_t start, time_t end); +GList *calendar_get_todo_in_range (Calendar *cal, time_t start, time_t end); +GList *calendar_get_journal_in_range (Calendar *cal, time_t start, time_t end); + +END_GNOME_DECLS + +#endif diff --git a/calendar/calobj.c b/calendar/calobj.c new file mode 100644 index 0000000000..87dd8db78d --- /dev/null +++ b/calendar/calobj.c @@ -0,0 +1,48 @@ +/* + * Calendar objects implementations. + * Copyright (C) 1998 the Free Software Foundation + * + * Authors: + * Miguel de Icaza (miguel@gnu.org) + * Federico Mena (federico@gimp.org) + */ +#include "calobj.h" + +iCalObject * +ical_object_new (void) +{ + iCalObject *ico; + + ico = g_new0 (iCalObject); + + ico->seq = -1; + ico->dtstamp = time (NULL); + + return ico; +} + +iCalObject * +ical_new (char *comment, char *organizer, char *summary) +{ + iCalObject *ico; + + ico = ical_object_new (); + + ico->comment = g_strdup (comment); + ico->organizer = g_strdup (organizer); + ico->summary = g_strdup (summary); + + return ico; +} + +#define free_if_defined(x) if (x){ g_free (x); x = 0; } + +void +ical_object_destroy (iCalObject *ico) +{ + free_if_defined (ico->comment); + free_if_defined (ico->organizer); + free_if_defined (ico->summary); + + g_free (ico); +} diff --git a/calendar/calobj.h b/calendar/calobj.h new file mode 100644 index 0000000000..fda3a1e4b5 --- /dev/null +++ b/calendar/calobj.h @@ -0,0 +1,100 @@ +/* + * Internal representation of a Calendar object. This is modeled after the + * iCalendar/vCalendar specificiation + * + * Authors: Miguel de Icaza (miguel@gnu.org), Federico Mena (federico@gimp.org). + */ +#ifndef CALOBJ_H +#define CALOBJ_H + +BEGIN_GNOME_DECLS + +typedef struct { + char *alarm_audio_file; + char *alarm_script; + char *alarm_email; + char *alarm_text; /* Text to be displayed */ +} 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 struct { + int valid; /* true if the Geography was specified */ + double latitude; + double longitude; +} iCalGeo; + +typedef enum { + ICAL_OPAQUE, + ICAL_TRANSPARENT +}; + +typedef char NotYet; + +/* + * 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 */ + 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 *description; + time_t dtstamp; + time_t dtstart; + time_t dtend; + GList *exdate; /* type: one or more time_t's */ + GList *exrule; /* type: one or more RECUR */ + iCalGeo geo; + time_t last_mod; + char *location; + char *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; + + /* VALARM objects are always inside another object, never alone */ + CalendarAlarm *alarm; +} iCalObject; + +iCalObject *ical_new (char *comment, char *organizer, char *summary); +iCalObject *ical_object_new (void); + +END_GNOME_DECLS + +#endif + diff --git a/calendar/gui/calendar.c b/calendar/gui/calendar.c new file mode 100644 index 0000000000..8725d96081 --- /dev/null +++ b/calendar/gui/calendar.c @@ -0,0 +1,116 @@ +/* + * Calendar manager object + * + * This keeps track of a given calendar. Eventually this will abtract everything + * related to getting calendars/saving calendars locally or to a remote Calendar Service + * + * Copyright (C) 1998 the Free Software Foundation + * + * Authors: + * Miguel de Icaza (miguel@gnu.org) + * Federico Mena (federico@gimp.org) + * + */ +#include "calobj.h" +#include "calendar.h" + +Calendar * +calendar_new (char *title) +{ + Calendar *cal; + + cal = g_new0 (Calendar, 1); + cal->title = g_strdup (title); + + return cal; +} + +void +calendar_add_object (Calendar *cal, iCalObject *obj) +{ + switch (obj->type){ + case ICAL_EVENT: + cal->events = g_list_prepend (cal->events, obj); + break; + + case ICAL_TODO: + cal->todo = g_list_prepend (cal->todo, obj); + break; + + case ICAL_JOURNAL: + cal->journal = g_list_prepend (cal->journal, obj); + break; + default: + g_assert_not_reached (); + } +} + +void +calendar_remove_object (Calendar *cal, iCalObject *obj) +{ + switch (obj->type){ + case ICAL_EVENT: + cal->events = g_list_remove (cal->events, obj); + break; + + case ICAL_TODO: + cal->todo = g_list_remove (cal->todo, obj); + break; + + case ICAL_JOURNAL: + cal->journal = g_list_remove (cal->journal, obj); + break; + default: + g_assert_not_reached (); + } +} + +void +calendar_destroy (Calendar *cal) +{ + g_list_foreach (cal->events, ical_object_destroy, NULL); + g_list_free (cal->events); + + g_list_foreach (cal->todo, ical_object_destroy, NULL); + g_list_free (cal->todo); + + g_list_foreach (cal->journal, ical_object_destroy, NULL); + g_list_free (cal->journal); + + if (cal->title) + g_free (cal->title); + if (cal->filename) + g_free (cal->filename); + + g_free (cal); +} + +static GList * +calendar_get_objects_in_range (GList *objects, time_t start, time_t end) +{ + GList *new_events = 0; + + for (; objects; objects = objects->next){ + iCalObject *object = objects->data; + + if ((start <= object->dtstart) && (end >= object->dtend)) + new_events = g_list_prepend (new_events, object); + } +} + +GList * +calendar_get_events_in_range (Calendar *cal, time_t start, time_t end) +{ + calendar_get_objects_in_range (cal->events, start, end); +} + +GList * +calendar_get_todo_in_range (Calendar *cal, time_t start, time_t end) +{ + calendar_get_objects_in_range (cal->todo, start, end); +} +GList * +calendar_get_journal_in_range (Calendar *cal, time_t start, time_t end) +{ + calendar_get_objects_in_range (cal->journal, start, end); +} diff --git a/calendar/gui/calendar.h b/calendar/gui/calendar.h new file mode 100644 index 0000000000..f854c69b7a --- /dev/null +++ b/calendar/gui/calendar.h @@ -0,0 +1,25 @@ +#ifndef CALOBJ_H +#define CALOBJ_H + +BEGIN_GNOME_DECLS + +typedef struct { + char *title; + char *filename; + GList *events; + GList *todo; + GList *journal; +} Calendar; + +Calendar *calendar_new (char *title); +void calendar_add_object (Calendar *cal, iCalObject *obj); +void calendar_remove_object (Calendar *cal, iCalObject *obj); +void calendar_destroy (Calendar *cal); + +GList *calendar_get_events_in_range (Calendar *cal, time_t start, time_t end); +GList *calendar_get_todo_in_range (Calendar *cal, time_t start, time_t end); +GList *calendar_get_journal_in_range (Calendar *cal, time_t start, time_t end); + +END_GNOME_DECLS + +#endif diff --git a/calendar/gui/icalendar-types b/calendar/gui/icalendar-types new file mode 100644 index 0000000000..e11f4c1789 --- /dev/null +++ b/calendar/gui/icalendar-types @@ -0,0 +1,39 @@ +evento todo journal fbrequest fbreply busytime timezone + attach attach attach + attendee attendee attendee attendee attendee attendee + categories categories categories + class class class + comment comment comment comment comment comment comment + completed + contact contact contact + created created created created + description description description + dtstamp dtstamp + dtend/duration due->dtend dtend [duration] dtend dtend + dtstart dtstart dtstart dtstart dtstart dtstart dtstart + exdate exdate exdate + exrule exrule exrule + geo geo + last-mod last-mod last-mod last-mod last-mod + location location + organizer organizer organizer + percent + priority priority + rstatus rstatus rstatus rstatus + related related related + resources resources + rdate rdate rdate [rdate/rrule] + rrule rrule rrule + dtstamp dtstamp dtstamp dtstamp + seq seq seq seq seq + status status + summary summary summary + transp + uid uid uid uid uid + url url url url url + recurid recurid recurid + freebusy freebusy + tzname + tzoffset-to + tzoffset-from + diff --git a/calendar/icalendar-types b/calendar/icalendar-types new file mode 100644 index 0000000000..e11f4c1789 --- /dev/null +++ b/calendar/icalendar-types @@ -0,0 +1,39 @@ +evento todo journal fbrequest fbreply busytime timezone + attach attach attach + attendee attendee attendee attendee attendee attendee + categories categories categories + class class class + comment comment comment comment comment comment comment + completed + contact contact contact + created created created created + description description description + dtstamp dtstamp + dtend/duration due->dtend dtend [duration] dtend dtend + dtstart dtstart dtstart dtstart dtstart dtstart dtstart + exdate exdate exdate + exrule exrule exrule + geo geo + last-mod last-mod last-mod last-mod last-mod + location location + organizer organizer organizer + percent + priority priority + rstatus rstatus rstatus rstatus + related related related + resources resources + rdate rdate rdate [rdate/rrule] + rrule rrule rrule + dtstamp dtstamp dtstamp dtstamp + seq seq seq seq seq + status status + summary summary summary + transp + uid uid uid uid uid + url url url url url + recurid recurid recurid + freebusy freebusy + tzname + tzoffset-to + tzoffset-from + diff --git a/calendar/pcs/calobj.c b/calendar/pcs/calobj.c new file mode 100644 index 0000000000..87dd8db78d --- /dev/null +++ b/calendar/pcs/calobj.c @@ -0,0 +1,48 @@ +/* + * Calendar objects implementations. + * Copyright (C) 1998 the Free Software Foundation + * + * Authors: + * Miguel de Icaza (miguel@gnu.org) + * Federico Mena (federico@gimp.org) + */ +#include "calobj.h" + +iCalObject * +ical_object_new (void) +{ + iCalObject *ico; + + ico = g_new0 (iCalObject); + + ico->seq = -1; + ico->dtstamp = time (NULL); + + return ico; +} + +iCalObject * +ical_new (char *comment, char *organizer, char *summary) +{ + iCalObject *ico; + + ico = ical_object_new (); + + ico->comment = g_strdup (comment); + ico->organizer = g_strdup (organizer); + ico->summary = g_strdup (summary); + + return ico; +} + +#define free_if_defined(x) if (x){ g_free (x); x = 0; } + +void +ical_object_destroy (iCalObject *ico) +{ + free_if_defined (ico->comment); + free_if_defined (ico->organizer); + free_if_defined (ico->summary); + + g_free (ico); +} diff --git a/calendar/pcs/calobj.h b/calendar/pcs/calobj.h new file mode 100644 index 0000000000..fda3a1e4b5 --- /dev/null +++ b/calendar/pcs/calobj.h @@ -0,0 +1,100 @@ +/* + * Internal representation of a Calendar object. This is modeled after the + * iCalendar/vCalendar specificiation + * + * Authors: Miguel de Icaza (miguel@gnu.org), Federico Mena (federico@gimp.org). + */ +#ifndef CALOBJ_H +#define CALOBJ_H + +BEGIN_GNOME_DECLS + +typedef struct { + char *alarm_audio_file; + char *alarm_script; + char *alarm_email; + char *alarm_text; /* Text to be displayed */ +} 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 struct { + int valid; /* true if the Geography was specified */ + double latitude; + double longitude; +} iCalGeo; + +typedef enum { + ICAL_OPAQUE, + ICAL_TRANSPARENT +}; + +typedef char NotYet; + +/* + * 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 */ + 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 *description; + time_t dtstamp; + time_t dtstart; + time_t dtend; + GList *exdate; /* type: one or more time_t's */ + GList *exrule; /* type: one or more RECUR */ + iCalGeo geo; + time_t last_mod; + char *location; + char *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; + + /* VALARM objects are always inside another object, never alone */ + CalendarAlarm *alarm; +} iCalObject; + +iCalObject *ical_new (char *comment, char *organizer, char *summary); +iCalObject *ical_object_new (void); + +END_GNOME_DECLS + +#endif + |