X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=cals%2Fews.c;fp=cals%2Fews.c;h=b8ecaa3b3d5220da2fd1ea61e25a141e64b1c5a4;hb=2ee2a3be99a1699549c25752ab47ede7bcb928b3;hp=0000000000000000000000000000000000000000;hpb=d45541aeb31a0e34a2a43df0e112f1f720f80abf;p=lackey diff --git a/cals/ews.c b/cals/ews.c new file mode 100644 index 0000000..b8ecaa3 --- /dev/null +++ b/cals/ews.c @@ -0,0 +1,117 @@ +/* + * Copyright (C) 2016 Andy Spencer + * + * 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 . + */ + +#include + +#include "util.h" +#include "conf.h" +#include "date.h" +#include "cal.h" + +/* Local Types */ +typedef struct ews_t { + cal_t cal; + struct ews_t *next; + + // Config + char *username; + char *password; + char *location; + char *domain; +} ews_t; + +/* Static data */ +static ews_t *calendars; + +/* Local functions */ +static void sync_ews(ews_t *cal) +{ + debug("Loading EWS:"); + debug(" type = %s", cal->cal.type); + debug(" name = %s", cal->cal.name); + debug(" desc = %s", cal->cal.desc); + debug(" username = %s", cal->username); + debug(" password = %s", cal->password); + debug(" location = %s", cal->location); + debug(" domain = %s", cal->domain); +} + +/* Config parser */ +void ews_config(const char *group, const char *name, const char *key, const char *value) +{ + ews_t *cal = NULL, *last = NULL; + + /* Make sure it's valid */ + if (!match(group, "ews") || !name) + return; + + /* Find existing calendar */ + for (cal = calendars; cal; last = cal, cal = cal->next) + if (match(cal->cal.name, name)) + break; + + /* Create new calendar */ + if (!cal) { + cal = new0(ews_t); + cal->cal.type = "ews"; + cal->cal.name = get_name(name); + if (last) + last->next = cal; + else + calendars = cal; + } + + /* Set calendar values */ + if (match(key, "location")) + cal->location = get_string(value); + else if (match(key, "username")) + cal->username = get_string(value); + else if (match(key, "password")) + cal->password = get_string(value); + else if (match(key, "domain")) + cal->domain = get_string(value); +} + +/* Cal functions */ +cal_t *ews_cals(void) +{ + for (ews_t *cal = calendars; cal; cal = cal->next) { + sync_ews(cal); + cal->cal.next = &cal->next->cal; + } + + return &calendars->cal; +} + +/* Event functions */ +event_t *ews_events(date_t start, date_t end) +{ + return NULL; +} + +/* Todo functions */ +todo_t *ews_todos(date_t start, date_t end) +{ + return NULL; +} + +/* Test functions */ +void ews_test(char *url, char *user, char *pass) +{ + printf("EWS -- test start\n"); + printf("EWS -- test end\n"); +}