1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212
|
/* caldav_db.h -- abstract interface for per-user CalDAV database
*
* Copyright (c) 1994-2012 Carnegie Mellon University. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The name "Carnegie Mellon University" must not be used to
* endorse or promote products derived from this software without
* prior written permission. For permission or any legal
* details, please contact
* Carnegie Mellon University
* Center for Technology Transfer and Enterprise Creation
* 4615 Forbes Avenue
* Suite 302
* Pittsburgh, PA 15213
* (412) 268-7393, fax: (412) 268-7395
* innovation@andrew.cmu.edu
*
* 4. Redistributions of any form whatsoever must retain the following
* acknowledgment:
* "This product includes software developed by Computing Services
* at Carnegie Mellon University (http://www.cmu.edu/computing/)."
*
* CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
#ifndef CALDAV_DB_H
#define CALDAV_DB_H
#include <config.h>
extern time_t caldav_epoch;
extern time_t caldav_eternity;
#include <libical/ical.h>
#include "dav_db.h"
#include "ical_support.h"
#include "mboxlist.h"
/* Bitmask of calendar components */
enum {
/* "Real" components - MUST remain in this order (values used in DAV DB) */
CAL_COMP_VEVENT = (1<<0),
CAL_COMP_VTODO = (1<<1),
CAL_COMP_VJOURNAL = (1<<2),
CAL_COMP_VFREEBUSY = (1<<3),
CAL_COMP_VAVAILABILITY = (1<<4),
CAL_COMP_VPOLL = (1<<5),
/* Append additional "real" components here */
/* Other components - values don't matter - prepend here */
CAL_COMP_VALARM = (1<<13),
CAL_COMP_VTIMEZONE = (1<<14),
CAL_COMP_VCALENDAR = (1<<15)
};
/* Returns NULL for unknown type */
extern const char *caldav_comp_type_as_string(unsigned comp_type);
#define CAL_COMP_REAL 0xff /* All "real" components */
struct caldav_db;
struct comp_flags {
unsigned recurring : 1; /* Has RRULE property */
unsigned transp : 1; /* Is TRANSParent */
unsigned status : 2; /* STATUS property value (see below) */
unsigned tzbyref : 1; /* VTIMEZONEs by reference */
unsigned mattach : 1; /* Has managed ATTACHment(s) */
unsigned shared : 1; /* Is shared (per-user-data stripped) */
};
/* Status values */
enum {
CAL_STATUS_BUSY = 0,
CAL_STATUS_CANCELED,
CAL_STATUS_TENTATIVE,
CAL_STATUS_UNAVAILABLE
};
struct caldav_data {
struct dav_data dav; /* MUST be first so we can typecast */
unsigned comp_type;
const char *ical_uid;
const char *organizer;
const char *dtstart;
const char *dtend;
struct comp_flags comp_flags;
const char *sched_tag;
int jmapversion;
const char *jmapdata;
};
typedef int caldav_cb_t(void *rock, struct caldav_data *cdata);
/* prepare for caldav operations in this process */
int caldav_init(void);
/* done with all caldav operations for this process */
int caldav_done(void);
/* get a database handle corresponding to mailbox */
struct caldav_db *caldav_open_mailbox(struct mailbox *mailbox);
struct caldav_db *caldav_open_userid(const char *userid);
/* close this handle */
int caldav_close(struct caldav_db *caldavdb);
/* lookup an entry from 'caldavdb' by resource
(optionally inside a transaction for updates) */
int caldav_lookup_resource(struct caldav_db *caldavdb,
const mbentry_t *mbentry, const char *resource,
struct caldav_data **result,
int tombstones);
/* lookup an entry from 'caldavdb' by mailbox and IMAP uid
(optionally inside a transaction for updates) */
int caldav_lookup_imapuid(struct caldav_db *caldavdb,
const mbentry_t *mbentry, int uid,
struct caldav_data **result,
int tombstones);
/* lookup an entry from 'caldavdb' by iCal UID
(optionally inside a transaction for updates) */
int caldav_lookup_uid(struct caldav_db *caldavdb, const char *ical_uid,
struct caldav_data **result);
/* process each entry for 'mailbox' in 'caldavdb' with cb() */
int caldav_foreach(struct caldav_db *caldavdb, const mbentry_t *mbentry,
caldav_cb_t *cb, void *rock);
enum caldav_sort {
CAL_SORT_NONE = 0,
CAL_SORT_UID,
CAL_SORT_START,
CAL_SORT_MAILBOX,
CAL_SORT_DESC = 0x80 /* bit-flag for descending sort */
};
/* process each entry for 'mailbox' in 'caldavdb' with cb()
* which last recurrence ends after 'after' and first
* recurrence starts before 'before'. The largest possible
* timerange spans from caldav_epoch to caldav_eternity.
* The callback is called in order of sort, or by an
* arbitrary order if no sort is specified. */
int caldav_foreach_timerange(struct caldav_db *caldavdb,
const mbentry_t *mbentry,
time_t after, time_t before,
enum caldav_sort* sort, size_t nsort,
caldav_cb_t *cb, void *rock);
/* write an entry to 'caldavdb' */
int caldav_write(struct caldav_db *caldavdb, struct caldav_data *cdata);
int caldav_writeentry(struct caldav_db *caldavdb, struct caldav_data *cdata,
icalcomponent *ical);
/* delete an entry from 'caldavdb' */
int caldav_delete(struct caldav_db *caldavdb, unsigned rowid);
/* delete all entries for 'mailbox' from 'caldavdb' */
int caldav_delmbox(struct caldav_db *caldavdb, const mbentry_t *mbentry);
/* begin transaction */
int caldav_begin(struct caldav_db *caldavdb);
/* commit transaction */
int caldav_commit(struct caldav_db *caldavdb);
/* abort transaction */
int caldav_abort(struct caldav_db *caldavdb);
char *caldav_mboxname(const char *userid, const char *name);
int caldav_get_events(struct caldav_db *caldavdb, const char *asuserid,
const mbentry_t *mbentry, const char *ical_uid,
caldav_cb_t *cb, void *rock);
int caldav_write_jmapcache(struct caldav_db *caldavdb, int rowid,
const char *userid, int version, const char *data);
/* Process each entry for 'caldavdb' with a modseq higher than oldmodseq,
* in ascending order of modseq.
* If mailbox is not NULL, only process entries of this mailbox.
* If kind is non-negative, only process entries of this kind.
* If max_records is positive, only call cb for at most this entries. */
int caldav_get_updates(struct caldav_db *caldavdb,
modseq_t oldmodseq, const mbentry_t *mbentry, int kind,
int max_records, caldav_cb_t *cb, void *rock);
/* Update all the share ACLs */
int caldav_update_shareacls(const char *userid);
#endif /* CALDAV_DB_H */
|