--- /dev/null
+/*
+ * Copyright (C) 2016 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 "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");
+}
--- /dev/null
+Microsoft Exhange Calendars
+
+Overview
+--------
+- Use Exchange Web Services
+- Use HTTP basic authentication
+
+For calendars:
+ 1. Use FindItem and CalendarView
+ - supply date range and fields
+ - returns a list of item IDs
+ 2. Use GetItem to get details
+ - supply all IDs return by FindItem
+ - need to request field for details
+
+Alternately:
+ 1. Request everything with FindItem
+
+
+SOAP Requests
+-------------
+# For email (mostly)
+SyncFolderItems:
+ ItemShape
+ BaseShape
+
+# Common
+GetItem:
+ ItemIds :: list
+ ItemId
+ Id
+ ChangeKey
+ ItemShape :: struct
+ BaseShape="IdOnly"
+ BodyType="Best"
+
+# For Calendars
+FindItem:
+ ParentFolderIds
+ DistinguishedFolderId
+ Id
+
+ ItemShape:
+ BaseShape = IdOnly
+ AdditionalProperties :: list
+ calendar:UID
+ calendar:CalendarItemType
+ calendar:Start
+ calendar:End
+ item:ItemClass
+ item:Subject
+
+ CalendarView:
+ StartDate
+ EndDate
+ MaxEntriesReturned
+
+ returns:
+ /t:Items/t:CalendarItem :: CalendarItem
+
+CalendarItem:
+ t:UID
+ t:Start
+ t:End
+ t:ItemId :: tag
+ Id
+ ChangeKey
+ t:CalendarItemType :: enum
+ Occurrence
+ Exception
+ RecurringMaster
+ Single
+
+# vim: ft=txt
TEST ?= test
TEST_SRC ?= test util conf date cal daemon
VIEWS ?= day week month year events todo settings help edit
-CALS ?= dummy ical
+CALS ?= dummy ical ews
# Objects
views/%.o cals/%.o: CFLAGS += -Isrc
/* Prototypes */
CAL(dummy);
CAL(ical);
+CAL(ews);
/* Global data */
cal_t *CAL, *CALS;
void cal_init(void)
{
/* Load calendars */
- CALS = merge_cals(
- dummy_cals(),
- ical_cals());
+ CALS = merge_cals(CALS, dummy_cals());
+ CALS = merge_cals(CALS, ical_cals());
+ CALS = merge_cals(CALS, ews_cals());
/* Load data */
cal_load(SEL.year, SEL.month, SEL.day, 1);
end = (date_t){eyear, emonth, eday};
/* Load events */
- EVENTS = merge_events(
- dummy_events(start, end),
- ical_events(start, end));
+ EVENTS = merge_events(NULL, dummy_events(start, end));
+ EVENTS = merge_events(EVENTS, ical_events(start, end));
+ EVENTS = merge_events(EVENTS, ews_events(start, end));
/* Load todos */
- TODOS = merge_todos(
- dummy_todos(start, end),
- ical_todos(start, end));
+ TODOS = merge_todos(NULL, dummy_todos(start, end));
+ TODOS = merge_todos(TODOS, ical_todos(start, end));
+ TODOS = merge_todos(TODOS, ews_todos(start, end));
/* Verify events and todos*/
#ifdef CAL_ERROR
dummy_config(group, name, key, value);
else if (match(group, "ical"))
ical_config(group, name, key, value);
+ else if (match(group, "ews"))
+ ews_config(group, name, key, value);
}
/* Find event for matching target date */
void date_test(void);
void conf_test(void);
void ical_test(void *path);
+void ews_test(char *url, char *user, char *pass);
void daemon_test();
int main(int argc, char **argv)
{
for (int i = 1; i < argc; i++) {
- if (match(argv[i], "date")) date_test();
- if (match(argv[i], "conf")) conf_test();
- if (match(argv[i], "ical")) ical_test(argv[++i]);
- if (match(argv[i], "daemon")) daemon_test();
+ if (match(argv[i], "date")) {
+ date_test();
+ }
+ if (match(argv[i], "conf")) {
+ conf_test();
+ }
+ if (match(argv[i], "ical")) {
+ char *path = argv[++i];
+ ical_test(path);
+ }
+ if (match(argv[i], "ews")) {
+ char *url = argv[++i];
+ char *user = argv[++i];
+ char *pass = argv[++i];
+ ews_test(url, user, pass);
+ }
+ if (match(argv[i], "daemon")) {
+ daemon_test();
+ }
}
return 0;
}