1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 /* Copyright (C) 2002-2004 Novell, Inc.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of version 2 of the GNU General Public
7 * License as published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public
15 * License along with this program; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
20 /* Free/Busy test program. Note though that this uses the code in
21 * e2k-freebusy.c, which is not currently used by Connector itself.
32 #include "e2k-freebusy.h"
33 #include "e2k-global-catalog.h"
34 #include "test-utils.h"
36 const char *test_program_name = "fbtest";
39 test_main (int argc, char **argv)
42 E2kGlobalCatalogStatus status;
43 E2kGlobalCatalogEntry *entry;
44 const char *server, *email;
47 E2kFreebusyEvent event;
54 fprintf (stderr, "Usage: %s server email-addr\n", argv[0]);
61 gc = test_get_gc (server);
63 status = e2k_global_catalog_lookup (
64 gc, NULL, E2K_GLOBAL_CATALOG_LOOKUP_BY_EMAIL,
65 email, E2K_GLOBAL_CATALOG_LOOKUP_LEGACY_EXCHANGE_DN,
68 if (status != E2K_GLOBAL_CATALOG_OK) {
69 fprintf (stderr, "Lookup failed: %d\n", status);
74 public_uri = g_strdup_printf ("http://%s/public", server);
75 ctx = test_get_context (public_uri);
76 fb = e2k_freebusy_new (ctx, public_uri, entry->legacy_exchange_dn);
81 fprintf (stderr, "Could not get fb props\n");
86 if (!fb->events[E2K_BUSYSTATUS_ALL]->len) {
92 printf (" 6am 9am noon 3pm 6pm\n");
95 for (t = fb->start; t < fb->end; t += 30 * 60) {
96 if ((t - fb->start) % (24 * 60 * 60) == 0) {
98 printf ("\n%02d-%02d: ", tm.tm_mon + 1, tm.tm_mday);
101 for (; oi < fb->events[E2K_BUSYSTATUS_OOF]->len; oi++) {
102 event = g_array_index (fb->events[E2K_BUSYSTATUS_OOF],
103 E2kFreebusyEvent, oi);
106 if (event.start < t + (30 * 60)) {
113 for (; bi < fb->events[E2K_BUSYSTATUS_BUSY]->len; bi++) {
114 event = g_array_index (fb->events[E2K_BUSYSTATUS_BUSY],
115 E2kFreebusyEvent, bi);
118 if (event.start < t + (30 * 60)) {
125 for (; ti < fb->events[E2K_BUSYSTATUS_TENTATIVE]->len; ti++) {
126 event = g_array_index (fb->events[E2K_BUSYSTATUS_TENTATIVE],
127 E2kFreebusyEvent, ti);
130 if (event.start < t + (30 * 60)) {
140 if ((t - fb->start) % (60 * 60))