aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/cal-util
diff options
context:
space:
mode:
authorSeth Alves <alves@src.gnome.org>2000-06-07 05:56:20 +0800
committerSeth Alves <alves@src.gnome.org>2000-06-07 05:56:20 +0800
commitc219c79496fca669af1ae093a660a1ce4d81a682 (patch)
treef93a2842d0914f396b5a2872ed48536cbfec1f91 /calendar/cal-util
parenta8b296282e5f93562c85b00b11d006b0eb7f1653 (diff)
downloadgsoc2013-evolution-c219c79496fca669af1ae093a660a1ce4d81a682.tar
gsoc2013-evolution-c219c79496fca669af1ae093a660a1ce4d81a682.tar.gz
gsoc2013-evolution-c219c79496fca669af1ae093a660a1ce4d81a682.tar.bz2
gsoc2013-evolution-c219c79496fca669af1ae093a660a1ce4d81a682.tar.lz
gsoc2013-evolution-c219c79496fca669af1ae093a660a1ce4d81a682.tar.xz
gsoc2013-evolution-c219c79496fca669af1ae093a660a1ce4d81a682.tar.zst
gsoc2013-evolution-c219c79496fca669af1ae093a660a1ce4d81a682.zip
fixed a bunch of problems use libical instead of libversit
* cal-util/icalendar.c, icalendar-save.c: fixed a bunch of problems * cal-util/calobj.c (ical_object_find_in_string): use libical instead of libversit (ical_object_to_string): same (dump_icalobject): prints the contents of an icalobject for debugging * gui/Makefile.am (LINK_FLAGS): link libical.a instead of libical.la so we don't have to modify the build system of the released libical * cal-client/Makefile.am (client_test_LDADD): same * cal-util/Makefile.am (icalendar_test_LDADD): same svn path=/trunk/; revision=3446
Diffstat (limited to 'calendar/cal-util')
-rw-r--r--calendar/cal-util/Makefile.am25
-rw-r--r--calendar/cal-util/calobj.c183
-rw-r--r--calendar/cal-util/calobj.h2
-rw-r--r--calendar/cal-util/icalendar-save.c89
4 files changed, 254 insertions, 45 deletions
diff --git a/calendar/cal-util/Makefile.am b/calendar/cal-util/Makefile.am
index d3517c2102..1bcab2b5ad 100644
--- a/calendar/cal-util/Makefile.am
+++ b/calendar/cal-util/Makefile.am
@@ -13,10 +13,14 @@ INCLUDES = \
lib_LTLIBRARIES = libcal-util.la
-libcal_util_la_SOURCES = \
- cal-recur.c \
- cal-util.c \
- calobj.c \
+libcal_util_la_SOURCES = \
+ cal-recur.c \
+ cal-util.c \
+ calobj.c \
+ icalendar.c \
+ icalendar.h \
+ icalendar-save.c \
+ icalendar-save.h \
timeutil.c
libcal_utilincludedir = $(includedir)/evolution/cal-util
@@ -27,6 +31,19 @@ libcal_utilinclude_HEADERS = \
calobj.h \
timeutil.h
+noinst_PROGRAMS = icalendar-test
+
+icalendar_test_SOURCES = \
+ icalendar-test.c \
+ icalendar.c \
+ icalendar-save.c
+
+icalendar_test_LDADD = \
+ $(EXTRA_GNOME_LIBS) \
+ $(top_builddir)/libversit/libversit.la \
+ $(top_builddir)/libical/src/libical/libical.a
+
+# $(top_builddir)/calendar/cal-util/libcal-util.la \
test_recur_SOURCES = \
test-recur.c
diff --git a/calendar/cal-util/calobj.c b/calendar/cal-util/calobj.c
index 9e86011d9f..3c1e10689b 100644
--- a/calendar/cal-util/calobj.c
+++ b/calendar/cal-util/calobj.c
@@ -12,9 +12,12 @@
#include <glib.h>
#include <ctype.h>
#include <unistd.h>
+#include <time.h>
#include "calobj.h"
#include "timeutil.h"
#include "libversit/vcc.h"
+#include "icalendar-save.h"
+#include "icalendar.h"
@@ -1565,6 +1568,56 @@ alarm_compute_offset (CalendarAlarm *a)
CalObjFindStatus
ical_object_find_in_string (const char *uid, const char *vcalobj, iCalObject **ico)
{
+#if 1
+ icalcomponent* comp = NULL;
+ icalcomponent *subcomp;
+ iCalObject *ical;
+
+ g_return_val_if_fail (vcalobj != NULL, CAL_OBJ_FIND_NOT_FOUND);
+
+ comp = icalparser_parse_string (vcalobj);
+
+ if (!comp) {
+ printf ("CAL_OBJ_FIND_SYNTAX_ERROR #1\n");
+ return CAL_OBJ_FIND_SYNTAX_ERROR;
+ }
+
+ subcomp = icalcomponent_get_first_component (comp,
+ ICAL_ANY_COMPONENT);
+ if (!subcomp) {
+ printf ("CAL_OBJ_FIND_SYNTAX_ERROR #2\n");
+ return CAL_OBJ_FIND_SYNTAX_ERROR;
+ }
+
+ while (subcomp) {
+ ical = ical_object_create_from_icalcomponent (subcomp);
+ if (ical->type != ICAL_EVENT &&
+ ical->type != ICAL_TODO &&
+ ical->type != ICAL_JOURNAL) {
+ g_warning ("Skipping unsupported iCalendar component");
+ } else {
+ if (strcasecmp (ical->uid, uid) == 0) {
+ (*ico) = ical;
+ (*ico)->ref_count = 1;
+ printf ("CAL_OBJ_FIND_SUCCESS\n");
+
+ printf ("ical_object_find_in_string:\n");
+ printf ("-----------------------------------------------------\n");
+ dump_icalobject (*ico);
+ printf ("-----------------------------------------------------\n");
+
+
+ return CAL_OBJ_FIND_SUCCESS;
+ }
+ }
+ subcomp = icalcomponent_get_next_component (comp,
+ ICAL_ANY_COMPONENT);
+ }
+
+ printf ("CAL_OBJ_FIND_NOT_FOUND\n");
+ return CAL_OBJ_FIND_NOT_FOUND;
+
+#else /* 0 */
VObject *vcal;
VObjectIterator i;
CalObjFindStatus status;
@@ -1619,6 +1672,7 @@ ical_object_find_in_string (const char *uid, const char *vcalobj, iCalObject **i
cleanStrTbl ();
return status;
+#endif /* 0 */
}
/* Creates a VObject with the base information of a calendar */
@@ -1663,6 +1717,22 @@ get_calendar_base_vobject (void)
char *
ical_object_to_string (iCalObject *ico)
{
+#if 1
+ icalcomponent *top = icalcomponent_new (ICAL_VCALENDAR_COMPONENT);
+ char *out_cal_string;
+ icalcomponent *comp;
+
+ printf ("ical_object_to_string:\n");
+ printf ("-----------------------------------------------------\n");
+ dump_icalobject (ico);
+ printf ("-----------------------------------------------------\n");
+
+ comp = icalcomponent_create_from_ical_object (ico);
+ icalcomponent_add_component (top, comp);
+ out_cal_string = icalcomponent_as_ical_string (top);
+ return g_strdup (out_cal_string);
+
+#else /* 0 */
VObject *vcalobj, *vobj;
char *buf, *gbuf;
@@ -1682,6 +1752,7 @@ ical_object_to_string (iCalObject *ico)
free (buf);
return gbuf;
+#endif /* 0 */
}
@@ -1808,3 +1879,115 @@ ical_object_normalize_summary (iCalObject *ico)
}
*dest = '\0';
}
+
+
+void dump_icalobject (iCalObject *ico)
+{
+ if (!ico) {
+ printf ("<<NULL>>\n");
+ return;
+ }
+
+ printf ("type ");
+ switch (ico->type) {
+ case ICAL_EVENT: printf ("event"); break;
+ case ICAL_TODO: printf ("todo"); break;
+ case ICAL_JOURNAL: printf ("journal"); break;
+ case ICAL_FBREQUEST: printf ("fbrequest"); break;
+ case ICAL_FBREPLY: printf ("fbreply"); break;
+ case ICAL_BUSYTIME: printf ("busytime"); break;
+ case ICAL_TIMEZONE: printf ("timezone"); break;
+ }
+ printf ("\n");
+
+ printf ("attach-length %d\n", g_list_length (ico->attach));
+
+ printf ("attendee-length %d\n", g_list_length (ico->attendee));
+
+ printf ("catagories-length %d\n", g_list_length (ico->categories));
+
+ printf ("class '%s'\n", ico->class ? ico->class : "NULL");
+
+ printf ("comment '%s'\n", ico->comment ? ico->comment : "NULL");
+
+ printf ("completed %ld=%s",
+ ico->completed, ctime (&ico->completed));
+
+ printf ("created %ld=%s", ico->created, ctime (&ico->created));
+
+ printf ("contact-length %d\n", g_list_length (ico->contact));
+
+ printf ("desc '%s'\n", ico->desc ? ico->desc : "NULL");
+
+ printf ("dtstamp %ld=%s", ico->dtstamp, ctime (&ico->dtstamp));
+
+ printf ("dtstart %ld=%s", ico->dtstart, ctime (&ico->dtstart));
+
+ printf ("dtend %ld=%s", ico->dtend, ctime (&ico->dtend));
+
+ printf ("date_only %d\n", ico->date_only);
+
+ printf ("exdate-length %d\n", g_list_length (ico->exdate));
+
+ printf ("exrule-length %d\n", g_list_length (ico->exrule));
+
+ printf ("iCalGeo %d %f %f\n",
+ ico->geo.valid, ico->geo.latitude, ico->geo.longitude);
+
+ printf ("last_mod %ld=%s", ico->last_mod, ctime (&ico->last_mod));
+
+ printf ("location '%s'\n", ico->location ? ico->location : "NULL");
+
+ printf ("organizer %p\n", ico->organizer);
+
+ printf ("percent %d\n", ico->percent);
+
+ printf ("priority %d\n", ico->priority);
+
+ printf ("rstatus '%s'\n", ico->rstatus ? ico->rstatus : "NULL");
+
+ printf ("related-length %d\n", g_list_length (ico->related));
+
+ printf ("resources-length %d\n", g_list_length (ico->resources));
+
+ printf ("rdate-length %d\n", g_list_length (ico->rdate));
+
+ printf ("rrule-length %d\n", g_list_length (ico->rrule));
+
+ printf ("seq %d\n", ico->seq);
+
+ printf ("status '%s'\n", ico->status ? ico->status : "NULL");
+
+ printf ("summary '%s'\n", ico->summary ? ico->summary : "NULL");
+
+ printf ("transp ");
+ switch (ico->transp) {
+ case ICAL_OPAQUE: printf ("opaque"); break;
+ case ICAL_TRANSPARENT: printf ("transparent"); break;
+ }
+ printf ("\n");
+
+ printf ("uid '%s'\n", ico->uid ? ico->uid : "NULL");
+
+ printf ("url '%s'\n", ico->url ? ico->url : "NULL");
+
+ printf ("recurid %ld=%s", ico->recurid, ctime (&ico->recurid));
+
+ printf ("dalarm %d\n", ico->dalarm.enabled);
+
+ printf ("aalarm %d\n", ico->aalarm.enabled);
+
+ printf ("palarm %d\n", ico->palarm.enabled);
+
+ printf ("malarm %d\n", ico->malarm.enabled);
+
+ printf ("alarms-length %d\n", g_list_length (ico->alarms));
+
+ printf ("recur %p\n", ico->recur);
+
+ printf ("new %d\n", ico->new);
+
+ printf ("user_data %p\n", ico->user_data);
+
+ printf ("ref_count %d\n", ico->ref_count);
+}
diff --git a/calendar/cal-util/calobj.h b/calendar/cal-util/calobj.h
index f2e5dbe00c..57514250e5 100644
--- a/calendar/cal-util/calobj.h
+++ b/calendar/cal-util/calobj.h
@@ -275,6 +275,8 @@ char *ical_gen_uid (void);
void ical_object_reset_recurrence (iCalObject *ico);
+void dump_icalobject (iCalObject *ico);
+
END_GNOME_DECLS
#endif
diff --git a/calendar/cal-util/icalendar-save.c b/calendar/cal-util/icalendar-save.c
index 8fae9a02f5..8f2335763f 100644
--- a/calendar/cal-util/icalendar-save.c
+++ b/calendar/cal-util/icalendar-save.c
@@ -311,7 +311,8 @@ struct icaltimetype timet_to_icaltime (time_t tt)
struct tm *t;
struct icaltimetype i;
- t = gmtime (&tt);
+ //t = gmtime (&tt);
+ t = localtime (&tt);
/*return tt - (i->is_utc ? timezone : 0); */
i.is_utc = 0;
@@ -351,52 +352,58 @@ void unparse_person (iCalPerson *person, icalproperty *person_prop)
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->role) {
+ 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 (person->partstat) {
+ 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);
+ if (person->cutype) {
+ 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) {