Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http_caldav.c: make property scheduling-enabled live #5074

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions imap/http_caldav.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@ static int propfind_scheduser(const xmlChar *name, xmlNsPtr ns,
struct propfind_ctx *fctx,
xmlNodePtr prop, xmlNodePtr resp,
struct propstat propstat[], void *rock);
static int proppatch_scheduling_enabled(xmlNodePtr, unsigned,
struct proppatch_ctx*,
struct propstat[], void*);
static int propfind_caldata(const xmlChar *name, xmlNsPtr ns,
struct propfind_ctx *fctx,
xmlNodePtr prop, xmlNodePtr resp,
Expand Down Expand Up @@ -475,6 +478,9 @@ static const struct prop_entry caldav_props[] = {
{ "schedule-user-address", NS_CYRUS,
PROP_RESOURCE,
propfind_scheduser, NULL, NULL },
{ "scheduling-enabled", NS_CYRUS,
PROP_COLLECTION,
propfind_fromdb, proppatch_scheduling_enabled, NULL },
{ "calendar-description", NS_CALDAV,
PROP_COLLECTION | PROP_PERUSER,
propfind_fromdb, proppatch_todb, NULL },
Expand Down Expand Up @@ -5506,6 +5512,36 @@ static int propfind_scheduser(const xmlChar *name, xmlNsPtr ns,
return rc;
}

/* Callback to write CYRUS_NS:scheduling-enabled */
static int proppatch_scheduling_enabled(xmlNodePtr prop, unsigned set,
struct proppatch_ctx *pctx,
struct propstat propstat[],
void *rock __attribute__((unused)))
{
if (pctx->txn->req_tgt.collection && !pctx->txn->req_tgt.resource
&& !(pctx->txn->req_tgt.flags & (TGT_MANAGED_ATTACH | TGT_SCHED_INBOX | TGT_SCHED_OUTBOX))) {
if (set) {
if (!prop->children || prop->children->next || prop->children->type != XML_TEXT_NODE
|| (xmlStrcasecmp(prop->children->content, BAD_CAST "F") && xmlStrcasecmp(prop->children->content, BAD_CAST "no"))) {
xml_add_prop(HTTP_CONFLICT, pctx->ns[NS_DAV],
&propstat[PROPSTAT_CONFLICT],
prop->name, prop->ns, NULL, 0);
xmlNewTextChild(propstat[PROPSTAT_CONFLICT].root, NULL, BAD_CAST "responsedescription",
BAD_CAST "Only F as value is allowed");
*pctx->ret = HTTP_CONFLICT;

return 0;
}
}
return proppatch_todb_nomask(prop, set, pctx, propstat, "F");
}
xml_add_prop(HTTP_FORBIDDEN, pctx->ns[NS_DAV], &propstat[PROPSTAT_FORBID], prop->name, prop->ns, NULL, 0);
*pctx->ret = HTTP_FORBIDDEN;

return 0;
}


/* Callback to prescreen/fetch CALDAV:calendar-data */
static int propfind_caldata(const xmlChar *name, xmlNsPtr ns,
struct propfind_ctx *fctx,
Expand Down