aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
authorSeth Alves <alves@src.gnome.org>2000-04-25 00:57:48 +0800
committerSeth Alves <alves@src.gnome.org>2000-04-25 00:57:48 +0800
commit30c8970ceebddcac6772eb2b9531e224c4feb46b (patch)
tree7b1fa60f94f03b9d2e17fd0c64248c92b6d743f3 /calendar
parent94a486a7b4207e617da30b172aa9873e0fbb0215 (diff)
downloadgsoc2013-evolution-30c8970ceebddcac6772eb2b9531e224c4feb46b.tar.gz
gsoc2013-evolution-30c8970ceebddcac6772eb2b9531e224c4feb46b.tar.zst
gsoc2013-evolution-30c8970ceebddcac6772eb2b9531e224c4feb46b.zip
finished first stab at iCalObject to icalcomponent conversion.
svn path=/trunk/; revision=2584
Diffstat (limited to 'calendar')
-rw-r--r--calendar/cal-util/icalendar-save.c150
-rw-r--r--calendar/pcs/icalendar-save.c150
2 files changed, 294 insertions, 6 deletions
diff --git a/calendar/cal-util/icalendar-save.c b/calendar/cal-util/icalendar-save.c
index a639e5ef1d..a3b2505778 100644
--- a/calendar/cal-util/icalendar-save.c
+++ b/calendar/cal-util/icalendar-save.c
@@ -7,9 +7,9 @@
static void unparse_person (iCalPerson *person, icalproperty *person_prop);
-
static struct icaltimetype timet_to_icaltime (time_t tt);
-
+static icalproperty *unparse_related (iCalRelation *rel);
+static icalcomponent *unparse_alarm (CalendarAlarm *alarm);
icalcomponent*
@@ -218,29 +218,93 @@ icalcomponent_create_from_ical_object (iCalObject *ical)
/*** relatedto ***/
+ if (ical->related) {
+ /* a list of (iCalPerson *) */
+ GList *cur;
+ for (cur = ical->related; cur; cur = cur->next) {
+ iCalRelation *related = (iCalRelation *) cur->data;
+ prop = unparse_related (related);
+ icalcomponent_add_property (comp, prop);
+ }
+ }
+
+
/*** url ***/
+ if (ical->url) {
+ prop = icalproperty_new_url (ical->url);
+ icalcomponent_add_property (comp, prop);
+ }
/*** uid ***/
+ if (ical->uid) {
+ prop = icalproperty_new_uid (ical->uid);
+ icalcomponent_add_property (comp, prop);
+ }
/*** exdate ***/
+ if (ical->exdate) {
+ struct icaltimetype v;
+ GList *cur;
+ for (cur = ical->exdate; cur; cur = cur->next) {
+ time_t t = (time_t) cur->data;
+ v = timet_to_icaltime (t);
+ prop = icalproperty_new_exdate (v);
+ icalcomponent_add_property (comp, prop);
+ }
+ }
/*** created ***/
+ if (ical->created) {
+ struct icaltimetype v;
+ v = timet_to_icaltime (ical->created);
+ prop = icalproperty_new_created (v);
+ icalcomponent_add_property (comp, prop);
+ }
/*** dtstamp ***/
+ if (ical->dtstamp) {
+ struct icaltimetype v;
+ v = timet_to_icaltime (ical->dtstamp);
+ prop = icalproperty_new_created (v);
+ icalcomponent_add_property (comp, prop);
+ }
/*** lastmodified ***/
+ if (ical->last_mod) {
+ struct icaltimetype v;
+ v = timet_to_icaltime (ical->last_mod);
+ prop = icalproperty_new_created (v);
+ icalcomponent_add_property (comp, prop);
+ }
/*** sequence ***/
+ if (ical->seq) {
+ prop = icalproperty_new_sequence (ical->seq);
+ icalcomponent_add_property (comp, prop);
+ }
/*** requeststatus ***/
+ if (ical->rstatus) {
+ prop = icalproperty_new_requeststatus (ical->rstatus);
+ icalcomponent_add_property (comp, prop);
+ }
+ /* if there is a VALARM subcomponent, add it here */
- /* then do subcomponents? valarms? */
+ if (ical->alarms) {
+ GList *cur;
+ for (cur = ical->alarms; cur; cur = cur->next) {
+ CalendarAlarm *alarm = (CalendarAlarm *) cur->data;
+ icalcomponent *subcomp = unparse_alarm (alarm);
+ icalcomponent_add_component (comp, subcomp);
+ }
+ }
return comp;
}
+/* FIX ME -- same as icaltimetype_from_timet in icaltypes.c */
static
struct icaltimetype timet_to_icaltime (time_t tt)
{
@@ -359,3 +423,83 @@ void unparse_person (iCalPerson *person, icalproperty *person_prop)
/* ret->deleg_to is a list of ICAL_DIR_PARAMETER */
/* FIX ME ... */
}
+
+
+static
+icalproperty *unparse_related (iCalRelation *rel)
+{
+ icalproperty *prop;
+
+ prop = icalproperty_new_relatedto (rel->reltype);
+
+ icalproperty_set_relatedto (prop, rel->uid);
+
+ /* FIX ME RELTYPE_XNAME ? */
+
+ return prop;
+}
+
+
+static
+icalcomponent *unparse_alarm (CalendarAlarm *alarm)
+{
+ icalcomponent *comp = icalcomponent_new (ICAL_VALARM_COMPONENT);
+ icalproperty *prop;
+
+ prop = NULL;
+ switch (alarm->type){
+ case ALARM_AUDIO:
+ prop = icalproperty_new_action ("AUDIO");
+ break;
+ case ALARM_DISPLAY:
+ prop = icalproperty_new_action ("DISPLAY");
+ break;
+ case ALARM_MAIL:
+ prop = icalproperty_new_action ("EMAIL");
+ break;
+ case ALARM_PROGRAM:
+ prop = icalproperty_new_action ("PROCEDURE");
+ break;
+ default:
+ g_warning ("Unsupported alarm type!");
+ break;
+ }
+ if (prop)
+ icalcomponent_add_property (comp, prop);
+
+ if (alarm->snooze_repeat)
+ prop = icalproperty_new_repeat (alarm->snooze_repeat);
+
+ if (alarm->snooze_secs) {
+ struct icaldurationtype dur;
+ dur = icaldurationtype_from_timet (alarm->snooze_secs);
+ prop = icalproperty_new_duration (dur);
+ icalcomponent_add_property (comp, prop);
+ }
+
+ if (alarm->attach) {
+ struct icalattachtype *attach;
+ attach = icalattachtype_new ();
+ icalattachtype_set_url (attach, alarm->attach);
+ prop = icalproperty_new_attach (*attach);
+ icalattachtype_free (attach);
+ icalcomponent_add_property (comp, prop);
+ }
+
+ if (alarm->desc) {
+ prop = icalproperty_new_description (alarm->desc);
+ icalcomponent_add_property (comp, prop);
+ }
+
+ if (alarm->summary) {
+ prop = icalproperty_new_summary (alarm->summary);
+ icalcomponent_add_property (comp, prop);
+ }
+
+ if (alarm->attendee) {
+ icalproperty_new_attendee (alarm->attendee);
+ icalcomponent_add_property (comp, prop);
+ }
+
+ return comp;
+}
diff --git a/calendar/pcs/icalendar-save.c b/calendar/pcs/icalendar-save.c
index a639e5ef1d..a3b2505778 100644
--- a/calendar/pcs/icalendar-save.c
+++ b/calendar/pcs/icalendar-save.c
@@ -7,9 +7,9 @@
static void unparse_person (iCalPerson *person, icalproperty *person_prop);
-
static struct icaltimetype timet_to_icaltime (time_t tt);
-
+static icalproperty *unparse_related (iCalRelation *rel);
+static icalcomponent *unparse_alarm (CalendarAlarm *alarm);
icalcomponent*
@@ -218,29 +218,93 @@ icalcomponent_create_from_ical_object (iCalObject *ical)
/*** relatedto ***/
+ if (ical->related) {
+ /* a list of (iCalPerson *) */
+ GList *cur;
+ for (cur = ical->related; cur; cur = cur->next) {
+ iCalRelation *related = (iCalRelation *) cur->data;
+ prop = unparse_related (related);
+ icalcomponent_add_property (comp, prop);
+ }
+ }
+
+
/*** url ***/
+ if (ical->url) {
+ prop = icalproperty_new_url (ical->url);
+ icalcomponent_add_property (comp, prop);
+ }
/*** uid ***/
+ if (ical->uid) {
+ prop = icalproperty_new_uid (ical->uid);
+ icalcomponent_add_property (comp, prop);
+ }
/*** exdate ***/
+ if (ical->exdate) {
+ struct icaltimetype v;
+ GList *cur;
+ for (cur = ical->exdate; cur; cur = cur->next) {
+ time_t t = (time_t) cur->data;
+ v = timet_to_icaltime (t);
+ prop = icalproperty_new_exdate (v);
+ icalcomponent_add_property (comp, prop);
+ }
+ }
/*** created ***/
+ if (ical->created) {
+ struct icaltimetype v;
+ v = timet_to_icaltime (ical->created);
+ prop = icalproperty_new_created (v);
+ icalcomponent_add_property (comp, prop);
+ }
/*** dtstamp ***/
+ if (ical->dtstamp) {
+ struct icaltimetype v;
+ v = timet_to_icaltime (ical->dtstamp);
+ prop = icalproperty_new_created (v);
+ icalcomponent_add_property (comp, prop);
+ }
/*** lastmodified ***/
+ if (ical->last_mod) {
+ struct icaltimetype v;
+ v = timet_to_icaltime (ical->last_mod);
+ prop = icalproperty_new_created (v);
+ icalcomponent_add_property (comp, prop);
+ }
/*** sequence ***/
+ if (ical->seq) {
+ prop = icalproperty_new_sequence (ical->seq);
+ icalcomponent_add_property (comp, prop);
+ }
/*** requeststatus ***/
+ if (ical->rstatus) {
+ prop = icalproperty_new_requeststatus (ical->rstatus);
+ icalcomponent_add_property (comp, prop);
+ }
+ /* if there is a VALARM subcomponent, add it here */
- /* then do subcomponents? valarms? */
+ if (ical->alarms) {
+ GList *cur;
+ for (cur = ical->alarms; cur; cur = cur->next) {
+ CalendarAlarm *alarm = (CalendarAlarm *) cur->data;
+ icalcomponent *subcomp = unparse_alarm (alarm);
+ icalcomponent_add_component (comp, subcomp);
+ }
+ }
return comp;
}
+/* FIX ME -- same as icaltimetype_from_timet in icaltypes.c */
static
struct icaltimetype timet_to_icaltime (time_t tt)
{
@@ -359,3 +423,83 @@ void unparse_person (iCalPerson *person, icalproperty *person_prop)
/* ret->deleg_to is a list of ICAL_DIR_PARAMETER */
/* FIX ME ... */
}
+
+
+static
+icalproperty *unparse_related (iCalRelation *rel)
+{
+ icalproperty *prop;
+
+ prop = icalproperty_new_relatedto (rel->reltype);
+
+ icalproperty_set_relatedto (prop, rel->uid);
+
+ /* FIX ME RELTYPE_XNAME ? */
+
+ return prop;
+}
+
+
+static
+icalcomponent *unparse_alarm (CalendarAlarm *alarm)
+{
+ icalcomponent *comp = icalcomponent_new (ICAL_VALARM_COMPONENT);
+ icalproperty *prop;
+
+ prop = NULL;
+ switch (alarm->type){
+ case ALARM_AUDIO:
+ prop = icalproperty_new_action ("AUDIO");
+ break;
+ case ALARM_DISPLAY:
+ prop = icalproperty_new_action ("DISPLAY");
+ break;
+ case ALARM_MAIL:
+ prop = icalproperty_new_action ("EMAIL");
+ break;
+ case ALARM_PROGRAM:
+ prop = icalproperty_new_action ("PROCEDURE");
+ break;
+ default:
+ g_warning ("Unsupported alarm type!");
+ break;
+ }
+ if (prop)
+ icalcomponent_add_property (comp, prop);
+
+ if (alarm->snooze_repeat)
+ prop = icalproperty_new_repeat (alarm->snooze_repeat);
+
+ if (alarm->snooze_secs) {
+ struct icaldurationtype dur;
+ dur = icaldurationtype_from_timet (alarm->snooze_secs);
+ prop = icalproperty_new_duration (dur);
+ icalcomponent_add_property (comp, prop);
+ }
+
+ if (alarm->attach) {
+ struct icalattachtype *attach;
+ attach = icalattachtype_new ();
+ icalattachtype_set_url (attach, alarm->attach);
+ prop = icalproperty_new_attach (*attach);
+ icalattachtype_free (attach);
+ icalcomponent_add_property (comp, prop);
+ }
+
+ if (alarm->desc) {
+ prop = icalproperty_new_description (alarm->desc);
+ icalcomponent_add_property (comp, prop);
+ }
+
+ if (alarm->summary) {
+ prop = icalproperty_new_summary (alarm->summary);
+ icalcomponent_add_property (comp, prop);
+ }
+
+ if (alarm->attendee) {
+ icalproperty_new_attendee (alarm->attendee);
+ icalcomponent_add_property (comp, prop);
+ }
+
+ return comp;
+}
95ce'>Update pkg to 1.4.2 and pkg-devel to 1.4.99.2:bapt2014-12-274-6/+6 * Update to 1.01gblach2014-12-262-4/+3 * - Add LICENSEsunpoet2014-12-261-0/+3 * Get rid of gnomehierbapt2014-12-231-2/+2 * Release pkg 1.4.1 and 1.4.99.1bapt2014-12-234-6/+6 * Remove useless USESbapt2014-12-221-2/+0 * cleanup plistbapt2014-12-212-3/+0 * Update to version 20141218pawel2014-12-202-3/+3 * - Deprecate and set expiration date to 2015-01-12: Does not support pkgngak2014-12-121-0/+3 * Disable Werror to calm down gccbapt2014-12-092-1/+2 * Update pkg to 1.4.0bapt2014-12-097-81/+7 * - Update to 3.1.1 which fixes pkg(8) crashing in 8.4 jails.bdrewery2014-12-094-8/+8 * Update to 1.4.0 rc3bapt2014-12-082-3/+3 * Update "BSD" license in ports-mgmt categoryfeld2014-12-072-2/+2 * Update "BSD" license.feld2014-12-071-1/+4 * Canonicalize a few licensesantoine2014-12-072-2/+2 * - Deprecate ports and set expiration date to 2015-01-06:ak2014-12-078-0/+24 * Allow building WITH_PKG=develantoine2014-12-062-2/+2 * Update to 1.4.0 rc2bapt2014-12-062-3/+3 * Remove expired port:rene2014-12-068-161/+0 * Update to 1.4.0 rc1bapt2014-12-062-3/+3 * - Resurrect ports-mgmt/pkg-plist, update to 1.4amdmi32014-12-064-0/+49 * Sort subdir listamdmi32014-12-061-1/+1 * Update to 3.1.0.bdrewery2014-12-046-64/+85 * - Update to 3.1.0bdrewery2014-12-042-4/+4 * - Update to 3.1-RC3bdrewery2014-12-022-4/+4 * Remove expired ports:rene2014-12-024-34/+0 * Mark a few ports BROKEN after GNOME 2 removalantoine2014-11-281-0/+2 * Change the way Perl modules are installed, update the default Perl to 5.18.mat2014-11-2616-45/+19 * Finally retire USE_PGSQLcrees2014-11-233-3/+3 * - Update to 20141117danilo2014-11-232-3/+3 * - Update to checkin e3445da which is 3.1-RC2bdrewery2014-11-202-4/+4 * The FreeBSD GNOME team proudly presents GNOME 3.14 and Cinnamon 2.2.kwm2014-11-191-0/+2 * Cleanup the @dirrmbapt2014-11-191-7/+0 * Reroll the tarball I was mising some dfly only commits:bapt2014-11-191-2/+2 * Update to 1.4.0.b2bapt2014-11-192-3/+3 * Update to 1.4.0.b1bapt2014-11-182-3/+3 * - Update to checkin 7851588, which is 3.1-RC1bdrewery2014-11-182-4/+5 * - Update to checkin 8d28349bdrewery2014-11-182-4/+4 * Cleanup plistantoine2014-11-1314-147/+4 * Cleanup plistantoine2014-11-121-4/+1 * - update to 1.79dinoex2014-11-114-15/+45 * Remove unneeded @dir entriesbdrewery2014-11-071-6/+0 * - Deprecate and set expiration date to 2014-12-06: Does not work with tcl/tk ...ak2014-11-071-0/+3 * Deprecate.mat2014-11-051-0/+3 * Simplify plistbapt2014-10-311-3/+1 * Simplify plistbapt2014-10-311-4/+1 * Update to 1.4.0.a4bapt2014-10-302-3/+3 * ports-mgmt/portsearch: Update the distfile checksum after thevd2014-10-302-4/+4 * Fix segfault caused by passing a string literal pointer to mkstemp()shurd2014-10-302-2/+2 * Update to 1.4.0 alpha3:bapt2014-10-292-3/+3 * - new port pkgcompareohauer2014-10-295-0/+69 * Sorry I didn't checksum the right filebapt2014-10-291-2/+2 * Update to checkin d2f5c83bdrewery2014-10-292-4/+4 * Update to 1.4.0.alpha2bapt2014-10-292-3/+3 * Update to 2.16.1.marcus2014-10-282-7/+7 * ports-mgmt/porttools: upgrade to 1.03xmj2014-10-272-4/+5 * Update to pkg 1.4.0.alpha1bapt2014-10-272-3/+3 * Update to 2.16.0marcus2014-10-272-390/+136 * - Update to 20141022 [1]ak2014-10-242-4/+3