aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
authorSeth Alves <alves@src.gnome.org>2000-04-22 08:18:27 +0800
committerSeth Alves <alves@src.gnome.org>2000-04-22 08:18:27 +0800
commit05a7bb9ef8ed8327fde0b04a0cab854d2c4a5d36 (patch)
treeac2354a0ca03bb20c9d80f28816188c6324f0240 /calendar
parented4fea3fe3bdd9eb41feae648a0dbe84f410ad1c (diff)
downloadgsoc2013-evolution-05a7bb9ef8ed8327fde0b04a0cab854d2c4a5d36.tar.gz
gsoc2013-evolution-05a7bb9ef8ed8327fde0b04a0cab854d2c4a5d36.tar.zst
gsoc2013-evolution-05a7bb9ef8ed8327fde0b04a0cab854d2c4a5d36.zip
start on code to do the opposite of icalendar.c (convert from iCalObjects
* pcs/icalendar-save.c: start on code to do the opposite of icalendar.c (convert from iCalObjects to libical's icalcomponents). svn path=/trunk/; revision=2550
Diffstat (limited to 'calendar')
-rw-r--r--calendar/ChangeLog3
-rw-r--r--calendar/cal-util/icalendar-save.c361
-rw-r--r--calendar/cal-util/icalendar-save.h13
-rw-r--r--calendar/cal-util/icalendar.c6
-rw-r--r--calendar/pcs/Makefile.am2
-rw-r--r--calendar/pcs/icalendar-save.c361
-rw-r--r--calendar/pcs/icalendar-save.h13
-rw-r--r--calendar/pcs/icalendar.c6
8 files changed, 759 insertions, 6 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index e7b95e8f8a..d634b67ce6 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,5 +1,8 @@
2000-04-21 Seth Alves <alves@hungry.com>
+ * pcs/icalendar-save.c: start on code to do the opposite of
+ icalendar.c (convert from iCalObjects to libical's icalcomponents).
+
* gui/calendar-commands.c (calendar_control_activate): moved
"About Calendar" into the View menu so it shows up.
diff --git a/calendar/cal-util/icalendar-save.c b/calendar/cal-util/icalendar-save.c
new file mode 100644
index 0000000000..a639e5ef1d
--- /dev/null
+++ b/calendar/cal-util/icalendar-save.c
@@ -0,0 +1,361 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+#include <config.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include "icalendar-save.h"
+
+
+static void unparse_person (iCalPerson *person, icalproperty *person_prop);
+
+static struct icaltimetype timet_to_icaltime (time_t tt);
+
+
+
+icalcomponent*
+icalcomponent_create_from_ical_object (iCalObject *ical)
+{
+ icalcomponent_kind kind;
+ icalcomponent *comp;
+ icalproperty *prop;
+
+ switch (ical->type) {
+ case ICAL_EVENT: kind = ICAL_VEVENT_COMPONENT; break;
+ case ICAL_TODO: kind = ICAL_VTODO_COMPONENT; break;
+ case ICAL_JOURNAL: kind = ICAL_VJOURNAL_COMPONENT; break;
+ case ICAL_FBREQUEST: kind = ICAL_VFREEBUSY_COMPONENT; break;
+ case ICAL_TIMEZONE: kind = ICAL_VTIMEZONE_COMPONENT; break;
+ default:
+ kind = ICAL_NO_COMPONENT; break;
+ }
+
+ comp = icalcomponent_new (kind);
+
+ /*** calscale ***/
+ prop = icalproperty_new_calscale ("GREGORIAN");
+ icalcomponent_add_property (comp, prop);
+
+ /*** catagories ***/
+ if (ical->categories) {
+ /* ical->categories is a GList of (char *) */
+ GList *cur;
+ for (cur = ical->categories; cur; cur = cur->next) {
+ prop = icalproperty_new_categories ((char *) cur);
+ icalcomponent_add_property (comp, prop);
+ }
+ }
+
+ /*** class ***/
+ if (ical->class) {
+ prop = icalproperty_new_class (ical->class);
+ icalcomponent_add_property (comp, prop);
+ }
+
+ /*** comment ***/
+ if (ical->comment) {
+ prop = icalproperty_new_comment (ical->comment);
+ icalcomponent_add_property (comp, prop);
+ }
+
+ /*** description ***/
+ if (ical->desc) {
+ prop = icalproperty_new_description (ical->desc);
+ icalcomponent_add_property (comp, prop);
+ }
+
+ /*** geo ***/
+ if (ical->geo.valid) {
+ struct icalgeotype v;
+ v.lat = ical->geo.latitude;
+ v.lon = ical->geo.longitude;
+ prop = icalproperty_new_geo (v);
+ icalcomponent_add_property (comp, prop);
+ }
+
+ /*** location ***/
+ if (ical->location) {
+ prop = icalproperty_new_location (ical->location);
+ icalcomponent_add_property (comp, prop);
+ }
+
+ /*** percentcomplete ***/
+ prop = icalproperty_new_percentcomplete (ical->percent);
+ icalcomponent_add_property (comp, prop);
+
+ /*** priority ***/
+ if (ical->priority) {
+ prop = icalproperty_new_priority (ical->priority);
+ icalcomponent_add_property (comp, prop);
+ }
+
+ /*** resources ***/
+ if (ical->resources) {
+ /* ical->resources is a GList of (char *) */
+ GList *cur;
+ for (cur = ical->resources; cur; cur = cur->next) {
+ prop = icalproperty_new_resources ((char *) cur);
+ icalcomponent_add_property (comp, prop);
+ }
+ }
+
+ /*** status ***/
+ if (ical->status) {
+ prop = icalproperty_new_status (ical->status);
+ icalcomponent_add_property (comp, prop);
+ }
+
+ /*** summary ***/
+ if (ical->summary) {
+ prop = icalproperty_new_summary (ical->summary);
+ icalcomponent_add_property (comp, prop);
+ }
+
+ /*** completed ***/
+ if (ical->completed) {
+ struct icaltimetype ictime;
+ ictime = timet_to_icaltime (ical->completed);
+ prop = icalproperty_new_completed (ictime);
+ icalcomponent_add_property (comp, prop);
+ }
+
+ /*** dtend ***/ /*** due ***/
+ if (ical->dtend) {
+ /* FIXME: We should handle timezone specifiers */
+ struct icaltimetype ictime;
+ ictime = timet_to_icaltime (ical->dtend);
+ if (ical->type == ICAL_TODO)
+ prop = icalproperty_new_due (ictime);
+ else
+ prop = icalproperty_new_dtend (ictime);
+ if (ical->date_only) {
+ icalparameter *param;
+ param = icalparameter_new (ICAL_VALUE_PARAMETER);
+ icalparameter_set_value (param, ICAL_VALUE_DATE);
+ icalproperty_add_parameter (prop, param);
+ }
+ icalcomponent_add_property (comp, prop);
+ }
+
+ /*** dtstart ***/
+ if (ical->dtstart) {
+ /* FIXME: We should handle timezone specifiers */
+ struct icaltimetype ictime;
+ ictime = timet_to_icaltime (ical->dtstart);
+ prop = icalproperty_new_dtstart (ictime);
+ if (ical->date_only) {
+ icalparameter *param;
+ param = icalparameter_new (ICAL_VALUE_PARAMETER);
+ icalparameter_set_value (param, ICAL_VALUE_DATE);
+ icalproperty_add_parameter (prop, param);
+ }
+ icalcomponent_add_property (comp, prop);
+ }
+
+ /*** duration ***/
+ {
+ /* FIX ME */
+ }
+
+ /*** freebusy ***/
+ {
+ /* FIX ME */
+ }
+
+ /*** transp ***/
+ {
+ if (ical->transp == ICAL_TRANSP_PROPERTY)
+ icalproperty_set_transp (prop, "TRANSPARENT");
+ else
+ icalproperty_set_transp (prop, "OPAQUE");
+ icalcomponent_add_property (comp, prop);
+ }
+
+ /*
+ ICAL_TZID_PROPERTY:
+ ICAL_TZNAME_PROPERTY:
+ ICAL_TZOFFSETFROM_PROPERTY:
+ ICAL_TZOFFSETTO_PROPERTY:
+ ICAL_TZURL_PROPERTY:
+ */
+
+ /*** attendee ***/
+ if (ical->attendee) {
+ /* a list of (iCalPerson *) */
+ GList *cur;
+ for (cur = ical->attendee; cur; cur = cur->next) {
+ iCalPerson *person = (iCalPerson *) cur->data;
+ prop = icalproperty_new_attendee ("FIX ME");
+ unparse_person (person, prop);
+ icalcomponent_add_property (comp, prop);
+ }
+ }
+
+ /*** contact ***/
+ if (ical->contact) {
+ /* a list of (iCalPerson *) */
+ GList *cur;
+ for (cur = ical->contact; cur; cur = cur->next) {
+ iCalPerson *person = (iCalPerson *) cur->data;
+ prop = icalproperty_new_contact ("FIX ME");
+ unparse_person (person, prop);
+ icalcomponent_add_property (comp, prop);
+ }
+ }
+
+ /*** organizer ***/
+ if (ical->organizer) {
+ prop = icalproperty_new_organizer ("FIX ME");
+ unparse_person (ical->organizer, prop);
+ icalcomponent_add_property (comp, prop);
+ }
+
+ /*** recurrenceid ***/
+ if (ical->recurid) {
+ struct icaltimetype ictime;
+ ictime = timet_to_icaltime (ical->recurid);
+ prop = icalproperty_new_recurrenceid (ictime);
+ }
+
+ /*** relatedto ***/
+
+ /*** url ***/
+
+ /*** uid ***/
+
+ /*** exdate ***/
+
+ /*** created ***/
+
+ /*** dtstamp ***/
+
+ /*** lastmodified ***/
+
+ /*** sequence ***/
+
+ /*** requeststatus ***/
+
+
+ /* then do subcomponents? valarms? */
+
+ return comp;
+}
+
+
+static
+struct icaltimetype timet_to_icaltime (time_t tt)
+{
+ extern long timezone;
+ struct tm *t;
+ struct icaltimetype i;
+
+ t = gmtime (&tt);
+
+ /*return tt - (i->is_utc ? timezone : 0); */
+ i.is_utc = 0;
+
+ i.year = t->tm_year + 1900;
+ i.month = t->tm_mon + 1;
+ i.day = t->tm_mday;
+
+ if (t->tm_hour == 0 && t->tm_min == 0 && t->tm_sec == 0) {
+ i.is_date = 1;
+ i.hour = 0;
+ i.minute = 0;
+ i.second = 0;
+ } else {
+ i.is_date = 0;
+ i.hour = t->tm_hour;
+ i.minute = t->tm_min;
+ i.second = t->tm_sec;
+ }
+
+ return i;
+}
+
+
+/* fills in "person_prop" with information from "person" */
+
+static
+void unparse_person (iCalPerson *person, icalproperty *person_prop)
+{
+ icalparameter *param;
+ GList *cur;
+
+ /* convert iCalPerson to an icalproperty */
+
+ param = icalparameter_new_cn (person->name);
+ icalproperty_add_parameter (person_prop, param);
+
+ if (g_strcasecmp (person->role, "CHAIR") == 0)
+ param = icalparameter_new_role (ICAL_ROLE_CHAIR);
+ else if (g_strcasecmp (person->role, "REQPARTICIPANT") == 0)
+ param = icalparameter_new_role (ICAL_ROLE_REQPARTICIPANT);
+ else if (g_strcasecmp (person->role, "OPTPARTICIPANT") == 0)
+ param = icalparameter_new_role (ICAL_ROLE_OPTPARTICIPANT);
+ else if (g_strcasecmp (person->role, "NONPARTICIPANT") == 0)
+ param = icalparameter_new_role (ICAL_ROLE_NONPARTICIPANT);
+ else
+ param = icalparameter_new_role (ICAL_ROLE_XNAME);
+ icalproperty_add_parameter (person_prop, param);
+
+ if (g_strcasecmp (person->partstat, "NEEDSACTION") == 0)
+ param = icalparameter_new_partstat (ICAL_PARTSTAT_NEEDSACTION);
+ else if (g_strcasecmp (person->partstat, "ACCEPTED") == 0)
+ param = icalparameter_new_partstat (ICAL_PARTSTAT_ACCEPTED);
+ else if (g_strcasecmp (person->partstat, "DECLINED") == 0)
+ param = icalparameter_new_partstat (ICAL_PARTSTAT_DECLINED);
+ else if (g_strcasecmp (person->partstat, "TENTATIVE") == 0)
+ param = icalparameter_new_partstat (ICAL_PARTSTAT_TENTATIVE);
+ else if (g_strcasecmp (person->partstat, "DELEGATED") == 0)
+ param = icalparameter_new_partstat (ICAL_PARTSTAT_DELEGATED);
+ else if (g_strcasecmp (person->partstat, "COMPLETED") == 0)
+ param = icalparameter_new_partstat (ICAL_PARTSTAT_COMPLETED);
+ else if (g_strcasecmp (person->partstat, "INPROCESS") == 0)
+ param = icalparameter_new_partstat (ICAL_PARTSTAT_INPROCESS);
+ else /* FIX ME, NEEDSACTION instead? */
+ param = icalparameter_new_partstat (ICAL_PARTSTAT_XNAME);
+ icalproperty_add_parameter (person_prop, param);
+
+ if (person->rsvp != FALSE) {
+ param = icalparameter_new_rsvp (TRUE);
+ icalproperty_add_parameter (person_prop, param);
+ }
+
+ if (g_strcasecmp (person->cutype, "INDIVIDUAL") == 0)
+ param = icalparameter_new_cutype (ICAL_CUTYPE_INDIVIDUAL);
+ else if (g_strcasecmp (person->cutype, "GROUP") == 0)
+ param = icalparameter_new_cutype (ICAL_CUTYPE_GROUP);
+ else if (g_strcasecmp (person->cutype, "RESOURCE") == 0)
+ param = icalparameter_new_cutype (ICAL_CUTYPE_RESOURCE);
+ else if (g_strcasecmp (person->cutype, "ROOM") == 0)
+ param = icalparameter_new_cutype (ICAL_CUTYPE_ROOM);
+ else /* FIX ME, INDIVIDUAL instead? */
+ param = icalparameter_new_cutype (ICAL_CUTYPE_UNKNOWN);
+ icalproperty_add_parameter (person_prop, param);
+
+ /* person->member is a list of ICAL_MEMBER_PARAMETER */
+ for (cur = person->member; cur; cur = cur->next) {
+ gchar *member = (gchar *) cur->data;
+ param = icalparameter_new_member (member);
+ icalproperty_add_parameter (person_prop, param);
+ }
+
+ /* person->deleg_to is a list of ICAL_DELEGATEDTO_PARAMETER */
+ for (cur = person->deleg_to; cur; cur = cur->next) {
+ gchar *deleg_to = (gchar *) cur->data;
+ param = icalparameter_new_delegatedto (deleg_to);
+ icalproperty_add_parameter (person_prop, param);
+ }
+
+ /* ret->deleg_from is a list of ICAL_DELEGATEDFROM_PARAMETER */
+ for (cur = person->deleg_from; cur; cur = cur->next) {
+ gchar *deleg_from = (gchar *) cur->data;
+ param = icalparameter_new_delegatedfrom (deleg_from);
+ icalproperty_add_parameter (person_prop, param);
+ }
+
+ param = icalparameter_new_sentby (person->sent_by);
+
+ /* ret->deleg_to is a list of ICAL_DIR_PARAMETER */
+ /* FIX ME ... */
+}
diff --git a/calendar/cal-util/icalendar-save.h b/calendar/cal-util/icalendar-save.h
new file mode 100644
index 0000000000..1e0ab59e70
--- /dev/null
+++ b/calendar/cal-util/icalendar-save.h
@@ -0,0 +1,13 @@
+#ifndef ICALENDAR_SAVE_H
+#define ICALENDAR_SAVE_H
+
+#include <ical.h>
+#include <cal-util/calobj.h>
+
+
+
+icalcomponent *icalcomponent_create_from_ical_object (iCalObject *ical);
+
+
+
+#endif
diff --git a/calendar/cal-util/icalendar.c b/calendar/cal-util/icalendar.c
index 1dcbadc817..8a15bb3cb4 100644
--- a/calendar/cal-util/icalendar.c
+++ b/calendar/cal-util/icalendar.c
@@ -223,8 +223,8 @@ ical_object_create_from_icalcomponent (icalcomponent* comp)
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 */
+ /* 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:
@@ -534,7 +534,7 @@ parse_person (icalproperty* prop, gchar* value)
param = icalproperty_get_first_parameter (prop, ICAL_SENTBY_PARAMETER
);
- copy_str (&ret->sent_by,
+ copy_str (&ret->sent_by,
icalparameter_get_sentby (param));
param = icalproperty_get_first_parameter (prop, ICAL_DIR_PARAMETER);
diff --git a/calendar/pcs/Makefile.am b/calendar/pcs/Makefile.am
index 16b4f22dbd..545e403201 100644
--- a/calendar/pcs/Makefile.am
+++ b/calendar/pcs/Makefile.am
@@ -33,6 +33,8 @@ libpcs_a_SOURCES = \
cal-factory.h \
icalendar.c \
icalendar.h \
+ icalendar-save.c \
+ icalendar-save.h \
job.c \
job.h
diff --git a/calendar/pcs/icalendar-save.c b/calendar/pcs/icalendar-save.c
new file mode 100644
index 0000000000..a639e5ef1d
--- /dev/null
+++ b/calendar/pcs/icalendar-save.c
@@ -0,0 +1,361 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+#include <config.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include "icalendar-save.h"
+
+
+static void unparse_person (iCalPerson *person, icalproperty *person_prop);
+
+static struct icaltimetype timet_to_icaltime (time_t tt);
+
+
+
+icalcomponent*
+icalcomponent_create_from_ical_object (iCalObject *ical)
+{
+ icalcomponent_kind kind;
+ icalcomponent *comp;
+ icalproperty *prop;
+
+ switch (ical->type) {
+ case ICAL_EVENT: kind = ICAL_VEVENT_COMPONENT; break;
+ case ICAL_TODO: kind = ICAL_VTODO_COMPONENT; break;
+ case ICAL_JOURNAL: kind = ICAL_VJOURNAL_COMPONENT; break;
+ case ICAL_FBREQUEST: kind = ICAL_VFREEBUSY_COMPONENT; break;
+ case ICAL_TIMEZONE: kind = ICAL_VTIMEZONE_COMPONENT; break;
+ default:
+ kind = ICAL_NO_COMPONENT; break;
+ }
+
+ comp = icalcomponent_new (kind);
+
+ /*** calscale ***/
+ prop = icalproperty_new_calscale ("GREGORIAN");
+ icalcomponent_add_property (comp, prop);
+
+ /*** catagories ***/
+ if (ical->categories) {
+ /* ical->categories is a GList of (char *) */
+ GList *cur;
+ for (cur = ical->categories; cur; cur = cur->next) {
+ prop = icalproperty_new_categories ((char *) cur);
+ icalcomponent_add_property (comp, prop);
+ }
+ }
+
+ /*** class ***/
+ if (ical->class) {
+ prop = icalproperty_new_class (ical->class);
+ icalcomponent_add_property (comp, prop);
+ }
+
+ /*** comment ***/
+ if (ical->comment) {
+ prop = icalproperty_new_comment (ical->comment);
+ icalcomponent_add_property (comp, prop);
+ }
+
+ /*** description ***/
+ if (ical->desc) {
+ prop = icalproperty_new_description (ical->desc);
+ icalcomponent_add_property (comp, prop);
+ }
+
+ /*** geo ***/
+ if (ical->geo.valid) {
+ struct icalgeotype v;
+ v.lat = ical->geo.latitude;
+ v.lon = ical->geo.longitude;
+ prop = icalproperty_new_geo (v);
+ icalcomponent_add_property (comp, prop);
+ }
+
+ /*** location ***/
+ if (ical->location) {
+ prop = icalproperty_new_location (ical->location);
+ icalcomponent_add_property (comp, prop);
+ }
+
+ /*** percentcomplete ***/
+ prop = icalproperty_new_percentcomplete (ical->percent);
+ icalcomponent_add_property (comp, prop);
+
+ /*** priority ***/
+ if (ical->priority) {
+ prop = icalproperty_new_priority (ical->priority);
+ icalcomponent_add_property (comp, prop);
+ }
+
+ /*** resources ***/
+ if (ical->resources) {
+ /* ical->resources is a GList of (char *) */
+ GList *cur;
+ for (cur = ical->resources; cur; cur = cur->next) {
+ prop = icalproperty_new_resources ((char *) cur);
+ icalcomponent_add_property (comp, prop);
+ }
+ }
+
+ /*** status ***/
+ if (ical->status) {
+ prop = icalproperty_new_status (ical->status);
+ icalcomponent_add_property (comp, prop);
+ }
+
+ /*** summary ***/
+ if (ical->summary) {
+ prop = icalproperty_new_summary (ical->summary);
+ icalcomponent_add_property (comp, prop);
+ }
+
+ /*** completed ***/
+ if (ical->completed) {
+ struct icaltimetype ictime;
+ ictime = timet_to_icaltime (ical->completed);
+ prop = icalproperty_new_completed (ictime);
+ icalcomponent_add_property (comp, prop);
+ }
+
+ /*** dtend ***/ /*** due ***/
+ if (ical->dtend) {
+ /* FIXME: We should handle timezone specifiers */
+ struct icaltimetype ictime;
+ ictime = timet_to_icaltime (ical->dtend);
+ if (ical->type == ICAL_TODO)
+ prop = icalproperty_new_due (ictime);
+ else
+ prop = icalproperty_new_dtend (ictime);
+ if (ical->date_only) {
+ icalparameter *param;
+ param = icalparameter_new (ICAL_VALUE_PARAMETER);
+ icalparameter_set_value (param, ICAL_VALUE_DATE);
+ icalproperty_add_parameter (prop, param);
+ }
+ icalcomponent_add_property (comp, prop);
+ }
+
+ /*** dtstart ***/
+ if (ical->dtstart) {
+ /* FIXME: We should handle timezone specifiers */
+ struct icaltimetype ictime;
+ ictime = timet_to_icaltime (ical->dtstart);
+ prop = icalproperty_new_dtstart (ictime);
+ if (ical->date_only) {
+ icalparameter *param;
+ param = icalparameter_new (ICAL_VALUE_PARAMETER);
+ icalparameter_set_value (param, ICAL_VALUE_DATE);
+ icalproperty_add_parameter (prop, param);
+ }
+ icalcomponent_add_property (comp, prop);
+ }
+
+ /*** duration ***/
+ {
+ /* FIX ME */
+ }
+
+ /*** freebusy ***/
+ {
+ /* FIX ME */
+ }
+
+ /*** transp ***/
+ {
+ if (ical->transp == ICAL_TRANSP_PROPERTY)
+ icalproperty_set_transp (prop, "TRANSPARENT");
+ else
+ icalproperty_set_transp (prop, "OPAQUE");
+ icalcomponent_add_property (comp, prop);
+ }
+
+ /*
+ ICAL_TZID_PROPERTY:
+ ICAL_TZNAME_PROPERTY:
+ ICAL_TZOFFSETFROM_PROPERTY:
+ ICAL_TZOFFSETTO_PROPERTY:
+ ICAL_TZURL_PROPERTY:
+ */
+
+ /*** attendee ***/
+ if (ical->attendee) {
+ /* a list of (iCalPerson *) */
+ GList *cur;
+ for (cur = ical->attendee; cur; cur = cur->next) {
+ iCalPerson *person = (iCalPerson *) cur->data;
+ prop = icalproperty_new_attendee ("FIX ME");
+ unparse_person (person, prop);
+ icalcomponent_add_property (comp, prop);
+ }
+ }
+
+ /*** contact ***/
+ if (ical->contact) {
+ /* a list of (iCalPerson *) */
+ GList *cur;
+ for (cur = ical->contact; cur; cur = cur->next) {
+ iCalPerson *person = (iCalPerson *) cur->data;
+ prop = icalproperty_new_contact ("FIX ME");
+ unparse_person (person, prop);
+ icalcomponent_add_property (comp, prop);
+ }
+ }
+
+ /*** organizer ***/
+ if (ical->organizer) {
+ prop = icalproperty_new_organizer ("FIX ME");
+ unparse_person (ical->organizer, prop);
+ icalcomponent_add_property (comp, prop);
+ }
+
+ /*** recurrenceid ***/
+ if (ical->recurid) {
+ struct icaltimetype ictime;
+ ictime = timet_to_icaltime (ical->recurid);
+ prop = icalproperty_new_recurrenceid (ictime);
+ }
+
+ /*** relatedto ***/
+
+ /*** url ***/
+
+ /*** uid ***/
+
+ /*** exdate ***/
+
+ /*** created ***/
+
+ /*** dtstamp ***/
+
+ /*** lastmodified ***/
+
+ /*** sequence ***/
+
+ /*** requeststatus ***/
+
+
+ /* then do subcomponents? valarms? */
+
+ return comp;
+}
+
+
+static
+struct icaltimetype timet_to_icaltime (time_t tt)
+{
+ extern long timezone;
+ struct tm *t;
+ struct icaltimetype i;
+
+ t = gmtime (&tt);
+
+ /*return tt - (i->is_utc ? timezone : 0); */
+ i.is_utc = 0;
+
+ i.year = t->tm_year + 1900;
+ i.month = t->tm_mon + 1;
+ i.day = t->tm_mday;
+
+ if (t->tm_hour == 0 && t->tm_min == 0 && t->tm_sec == 0) {
+ i.is_date = 1;
+ i.hour = 0;
+ i.minute = 0;
+ i.second = 0;
+ } else {
+ i.is_date = 0;
+ i.hour = t->tm_hour;
+ i.minute = t->tm_min;
+ i.second = t->tm_sec;
+ }
+
+ return i;
+}
+
+
+/* fills in "person_prop" with information from "person" */
+
+static
+void unparse_person (iCalPerson *person, icalproperty *person_prop)
+{
+ icalparameter *param;
+ GList *cur;
+
+ /* convert iCalPerson to an icalproperty */
+
+ param = icalparameter_new_cn (person->name);
+ icalproperty_add_parameter (person_prop, param);
+
+ if (g_strcasecmp (person->role, "CHAIR") == 0)
+ param = icalparameter_new_role (ICAL_ROLE_CHAIR);
+ else if (g_strcasecmp (person->role, "REQPARTICIPANT") == 0)
+ param = icalparameter_new_role (ICAL_ROLE_REQPARTICIPANT);
+ else if (g_strcasecmp (person->role, "OPTPARTICIPANT") == 0)
+ param = icalparameter_new_role (ICAL_ROLE_OPTPARTICIPANT);
+ else if (g_strcasecmp (person->role, "NONPARTICIPANT") == 0)
+ param = icalparameter_new_role (ICAL_ROLE_NONPARTICIPANT);
+ else
+ param = icalparameter_new_role (ICAL_ROLE_XNAME);
+ icalproperty_add_parameter (person_prop, param);
+
+ if (g_strcasecmp (person->partstat, "NEEDSACTION") == 0)
+ param = icalparameter_new_partstat (ICAL_PARTSTAT_NEEDSACTION);
+ else if (g_strcasecmp (person->partstat, "ACCEPTED") == 0)
+ param = icalparameter_new_partstat (ICAL_PARTSTAT_ACCEPTED);
+ else if (g_strcasecmp (person->partstat, "DECLINED") == 0)
+ param = icalparameter_new_partstat (ICAL_PARTSTAT_DECLINED);
+ else if (g_strcasecmp (person->partstat, "TENTATIVE") == 0)
+ param = icalparameter_new_partstat (ICAL_PARTSTAT_TENTATIVE);
+ else if (g_strcasecmp (person->partstat, "DELEGATED") == 0)
+ param = icalparameter_new_partstat (ICAL_PARTSTAT_DELEGATED);
+ else if (g_strcasecmp (person->partstat, "COMPLETED") == 0)
+ param = icalparameter_new_partstat (ICAL_PARTSTAT_COMPLETED);
+ else if (g_strcasecmp (person->partstat, "INPROCESS") == 0)
+ param = icalparameter_new_partstat (ICAL_PARTSTAT_INPROCESS);
+ else /* FIX ME, NEEDSACTION instead? */
+ param = icalparameter_new_partstat (ICAL_PARTSTAT_XNAME);
+ icalproperty_add_parameter (person_prop, param);
+
+ if (person->rsvp != FALSE) {
+ param = icalparameter_new_rsvp (TRUE);
+ icalproperty_add_parameter (person_prop, param);
+ }
+
+ if (g_strcasecmp (person->cutype, "INDIVIDUAL") == 0)
+ param = icalparameter_new_cutype (ICAL_CUTYPE_INDIVIDUAL);
+ else if (g_strcasecmp (person->cutype, "GROUP") == 0)
+ param = icalparameter_new_cutype (ICAL_CUTYPE_GROUP);
+ else if (g_strcasecmp (person->cutype, "RESOURCE") == 0)
+ param = icalparameter_new_cutype (ICAL_CUTYPE_RESOURCE);
+ else if (g_strcasecmp (person->cutype, "ROOM") == 0)
+ param = icalparameter_new_cutype (ICAL_CUTYPE_ROOM);
+ else /* FIX ME, INDIVIDUAL instead? */
+ param = icalparameter_new_cutype (ICAL_CUTYPE_UNKNOWN);
+ icalproperty_add_parameter (person_prop, param);
+
+ /* person->member is a list of ICAL_MEMBER_PARAMETER */
+ for (cur = person->member; cur; cur = cur->next) {
+ gchar *member = (gchar *) cur->data;
+ param = icalparameter_new_member (member);
+ icalproperty_add_parameter (person_prop, param);
+ }
+
+ /* person->deleg_to is a list of ICAL_DELEGATEDTO_PARAMETER */
+ for (cur = person->deleg_to; cur; cur = cur->next) {
+ gchar *deleg_to = (gchar *) cur->data;
+ param = icalparameter_new_delegatedto (deleg_to);
+ icalproperty_add_parameter (person_prop, param);
+ }
+
+ /* ret->deleg_from is a list of ICAL_DELEGATEDFROM_PARAMETER */
+ for (cur = person->deleg_from; cur; cur = cur->next) {
+ gchar *deleg_from = (gchar *) cur->data;
+ param = icalparameter_new_delegatedfrom (deleg_from);
+ icalproperty_add_parameter (person_prop, param);
+ }
+
+ param = icalparameter_new_sentby (person->sent_by);
+
+ /* ret->deleg_to is a list of ICAL_DIR_PARAMETER */
+ /* FIX ME ... */
+}
diff --git a/calendar/pcs/icalendar-save.h b/calendar/pcs/icalendar-save.h
new file mode 100644
index 0000000000..1e0ab59e70
--- /dev/null
+++ b/calendar/pcs/icalendar-save.h
@@ -0,0 +1,13 @@
+#ifndef ICALENDAR_SAVE_H
+#define ICALENDAR_SAVE_H
+
+#include <ical.h>
+#include <cal-util/calobj.h>
+
+
+
+icalcomponent *icalcomponent_create_from_ical_object (iCalObject *ical);
+
+
+
+#endif
diff --git a/calendar/pcs/icalendar.c b/calendar/pcs/icalendar.c
index 1dcbadc817..8a15bb3cb4 100644
--- a/calendar/pcs/icalendar.c
+++ b/calendar/pcs/icalendar.c
@@ -223,8 +223,8 @@ ical_object_create_from_icalcomponent (icalcomponent* comp)
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 */
+ /* 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:
@@ -534,7 +534,7 @@ parse_person (icalproperty* prop, gchar* value)
param = icalproperty_get_first_parameter (prop, ICAL_SENTBY_PARAMETER
);
- copy_str (&ret->sent_by,
+ copy_str (&ret->sent_by,
icalparameter_get_sentby (param));
param = icalproperty_get_first_parameter (prop, ICAL_DIR_PARAMETER);