Add to git.
[monolith.git] / calendar / ml_calendar.h
1 /* Monolith calendar widget.
2  * - by Richard W.M. Jones <rich@annexia.org>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library 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  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the Free
16  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17  *
18  * $Id: ml_calendar.h,v 1.4 2003/02/22 15:34:25 rich Exp $
19  */
20
21 #ifndef ML_CALENDAR_H
22 #define ML_CALENDAR_H
23
24 #include <vector.h>
25
26 #include <monolith.h>
27
28 struct ml_calendar;
29 typedef struct ml_calendar *ml_calendar;
30
31 /* Function: new_ml_calendar - monolith calendar widget
32  * Function: ml_calendar_add_calendar
33  * Function: ml_calendar_del_calendar
34  * Function: ml_calendar_set_date
35  * Function: ml_calendar_get_date
36  *
37  * This is the monolith calendar widget. It supports single and
38  * recurring events, alerts, shared calendars, and views of multiple
39  * calendars.
40  *
41  * The schema for this widget can be found in
42  * @code{sql/ml_calendar_create.sql}.
43  *
44  * @code{new_ml_calendar} creates a new calendar widget. @code{pool}
45  * is the pool for allocations, @code{session} is the current session, and
46  * @code{dhf} is a database handle factory. @code{res_name} is the name
47  * of the calendar resource (from the @code{ml_resources} table).
48  *
49  * The function returns the calendar widget, or @code{NULL} if there
50  * was a problem, such as the calendar not existing.
51  *
52  * The calendar widget can view multiple calendars (there must be
53  * at least one calendar in view at all times).
54  * @code{ml_calendar_add_calendar} adds another calendar to the
55  * list of calendars visible. @code{ml_calendar_del_calendar}
56  * removes a calendar. These functions return 0 on success or
57  * -1 on failure (including attempting to delete all the visible
58  * calendars).
59  *
60  * @code{ml_calendar_(set|get)_date} updates the currently displayed
61  * date in the calendar. The @code{ml_calendar_set_date} function changes
62  * the displayed date to the given @code{yyyy/mm/dd}. This date
63  * must be correct, else the calendar throws an assertion error.
64  * Note in particular that the calendar does not support dates
65  * prior to 1900/1/1 and will throw an error if given such a date.
66  * Note also that @code{yyyy} must be a full four-digit year.
67  * @code{ml_calendar_get_date} returns the current date in the
68  * variables pointed to by @code{yyyy}, @code{mm} and @code{dd} (which
69  * are all pointers to @code{int}).
70  */
71 extern ml_calendar new_ml_calendar (pool, ml_session, const char *conninfo, const char *res_name);
72 extern int ml_calendar_add_calendar (ml_calendar, const char *res_name);
73 extern int ml_calendar_del_calendar (ml_calendar, const char *res_name);
74 extern void ml_calendar_set_date (ml_calendar, int yyyy, int mm, int dd);
75 extern void ml_calendar_get_date (ml_calendar, int *yyyy, int *mm, int *dd);
76
77 /* This function returns a list of all calendar resources. */
78 extern const vector _ml_calendar_get_calendars (ml_calendar);
79
80 #endif /* ML_CALENDAR_H */