]> Pileus Git - lackey/commitdiff
Start on iCalendar support
authorAndy Spencer <andy753421@gmail.com>
Fri, 12 Oct 2012 07:15:26 +0000 (07:15 +0000)
committerAndy Spencer <andy753421@gmail.com>
Fri, 12 Oct 2012 07:15:26 +0000 (07:15 +0000)
.gitignore
cal/ical.c [new file with mode: 0644]
makefile
src/date.c
src/date.h
src/event.h
src/test.c

index 01bc8a514fe32c425d1a475235a0208b46eec0c4..c06ce8faee2a669036143c6c4ba2854ec8b200bd 100644 (file)
@@ -1,3 +1,4 @@
+*.ics
 *.log
 *.o
 *.swp
diff --git a/cal/ical.c b/cal/ical.c
new file mode 100644 (file)
index 0000000..f4709a9
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2012 Andy Spencer <andy753421@gmail.com>
+ * 
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <libical/ical.h>
+
+#include "util.h"
+#include "date.h"
+#include "event.h"
+
+/* Helper functions */
+static event_t *to_event(icalcomponent *comp)
+{
+       event_t *event = calloc(1, sizeof(event));
+       return event;
+}
+
+/* Event functions */
+event_t *ical_get(cal_t *cal, year_t year, month_t month, day_t day, int days)
+{
+       (void)to_event;
+       return NULL;
+}
+
+/* Test functions */
+void ical_printr(icalcomponent *comp, int depth)
+{
+       /* Print component */
+       icalcomponent_kind kind = icalcomponent_isa(comp);
+       printf("%*s", depth, "");
+       printf("%s",  icalcomponent_kind_to_string(kind));
+       if (kind == ICAL_VEVENT_COMPONENT ||
+           kind == ICAL_VTODO_COMPONENT)
+               printf(" - %s", icalcomponent_get_summary(comp) ?: "[no summary]");
+       printf("\n");
+
+       /* Print children */
+       icalcomponent_kind find = ICAL_ANY_COMPONENT;
+       icalcomponent *child = icalcomponent_get_first_component(comp, find);
+       while (child) {
+               ical_printr(child, depth+2);
+               child = icalcomponent_get_next_component(comp, find);
+       }
+}
+
+void ical_test(void)
+{
+       FILE *file = fopen("data/all.ics", "r");
+       icalparser *parser = icalparser_new();
+       icalparser_set_gen_data(parser, file);
+       icalcomponent *ical = icalparser_parse(parser, (void*)fgets);
+       ical_printr(ical, 0);
+       icalparser_free(parser);
+}
index e8bd692a458ac43933e03c9b346b56ece658dff1..0162b3a9d80ffb4fc2a5e8faeeb07dd867d55baa 100644 (file)
--- a/makefile
+++ b/makefile
@@ -4,7 +4,7 @@
 CC       ?= gcc
 CFLAGS   ?= -Wall --std=c99
 CPPFLAGS ?= -Isrc
-LDFLAGS  ?= -lncursesw
+LDFLAGS  ?= -lncursesw -lical
 
 # Sources
 PROG      = lackey
@@ -12,7 +12,7 @@ PROG_SRC  = main screen date event util
 TEST      = test
 TEST_SRC  = test date
 VIEWS     = day week month year todo notes settings help
-CALS      = dummy
+CALS      = dummy ical
 
 # Targets
 all: $(PROG) $(TEST)
index eebbe7968c72fb8a22ed330dedf3202a895fdc2c..ec71579d359380fe9054ad2dbfba6811437b6661 100644 (file)
@@ -144,7 +144,7 @@ const char *day_to_string(wday_t day)
 }
 
 /* Test functions */
-void test_time(void)
+void date_test(void)
 {
        printf("Info\n");
        printf("  Year Month     Start Weeks Days\n");
index 77f7341b1b0ffc40752bc1a0f53fc04ca62673d0..9b4d278fd23d0e64d5497963c4b2ab690574fe42 100644 (file)
@@ -73,4 +73,4 @@ const char *day_to_str(wday_t day);
 const char *day_to_string(wday_t day);
 
 /* Tests */
-void test_time(void);
+void date_test(void);
index 199e1dc9da9998960452ca6c51c3ebc270ed75ef..b75f890f43a86633d29c7745e64f41a4fe221d6a 100644 (file)
@@ -49,3 +49,7 @@ event_t *event_get(year_t year, month_t month, day_t day, int days);
 
 /* Calendar implementation functions */
 event_t *dummy_get(cal_t *cal, year_t year, month_t month, day_t day, int days);
+event_t *ical_get(cal_t *cal, year_t year, month_t month, day_t day, int days);
+
+/* Test fuctions */
+void ical_test(void);
index 9255c9417d3eff1adb5044985ca4c6289cac6087..53822f92eb1b4c5d93f6b7a222e6092eaced6c32 100644 (file)
  */
 
 #include "date.h"
+#include "event.h"
 
 int main(int argc, char **argv)
 {
-       test_time();
+       //date_test();
+       ical_test();
        return 0;
 }