/* * (c) Copyright 2016 Olliver Schinagl * Author: Olliver Schinagl * * SPDX-License-Identifier: AGPL-3.0+ */ #include #include #include #include #include "gettext.h" #ifdef __cplusplus extern "C" { #endif char *line_gen_func(char *str, size_t size, void *data) { return fgets(str, (int)size, (FILE *)data); } bool ical_load(void) { icalparser *parser; icalcomponent *comp, *cal, *event; FILE *stream; printf("Plugin loaded\n"); stream = fopen("test-data/large.ics", "r"); if (stream == NULL) { fprintf(stderr, "Cannot open file for reading"); return 1; } parser = icalparser_new(); icalparser_set_gen_data(parser, stream); comp = icalparser_parse(parser, line_gen_func); for (event = icalcomponent_get_first_real_component(comp); event != NULL; event = icalcomponent_get_next_component(comp, ICAL_ANY_COMPONENT)) { icalproperty *prop; printf("\n---Event---\n%s", icalcomponent_as_ical_string(event)); for (prop = icalcomponent_get_first_property(event, ICAL_ANY_PROPERTY); prop != NULL; prop = icalcomponent_get_next_property(event, ICAL_ANY_PROPERTY)) { icalparameter *param; printf("prop: %s %d (%s) %s\n", icalproperty_as_ical_string(prop), icalproperty_count_parameters(prop), icalproperty_get_property_name(prop), icalvalue_as_ical_string(icalproperty_get_value(prop))); for (param = icalproperty_get_first_parameter(prop, ICAL_ANY_PARAMETER); param != NULL; param = icalproperty_get_next_parameter(prop, ICAL_ANY_PARAMETER)) { printf("param: %s\n", icalparameter_as_ical_string(param)); } if (icalerrno != ICAL_NO_ERROR) fprintf(stderr, "Error with parameter %s\n", icalerror_strerror(icalerrno)); } if (icalerrno != ICAL_NO_ERROR) fprintf(stderr, "Error with property %s\n", icalerror_strerror(icalerrno)); } if (icalerrno != ICAL_NO_ERROR) fprintf(stderr, "Error with component. %s\n", icalerror_strerror(icalerrno)); icalparser_free(parser); fclose(stream); return true; } bool ical_unload(void) { printf("Plugin unloaded\n"); return true; } struct plugin calendar_plugin = { .magic = PLUGIN_MAGIC, .type = PLUGIN_TYPE_CALENDAR, .id = "connector-ical", .version = { .major = PLUGIN_VERSION_MAJOR, .minor = PLUGIN_VERSION_MINOR, .micro = 1, }, .info = { .name = N_("Caldav connector plugin"), .summary = N_("Caldav connector plugin summary"), .description = N_("Caldav connector plugin description"), .help = N_("Caldav connector plugin help text"), .author = N_("Olliver Schinagl"), .email = "oliver@schinagl.nl", .url = "http://git.schinagl.nl/engagement.git", }, .load = &ical_load, .unload = &ical_unload, }; void __attribute__((constructor)) ical_create(void) { printf("Plugin created\n"); return; } void __attribute__((destructor)) ical_destroy(void) { printf("Plugin destroyed\n"); return; } PLUGIN_INIT(ical_plugin); #ifdef __cplusplus } #endif