Permalink
Browse files

fastmailsharing: nasty zzzz hack and namespacing

  • Loading branch information...
brong committed Mar 15, 2016
1 parent 38d9b7a commit 64826ce4cf6a458cb148ca8c8b70d081c9b88e94
Showing with 33 additions and 14 deletions.
  1. +30 −14 imap/http_dav.c
  2. +3 −0 lib/imapoptions
View
@@ -530,7 +530,9 @@ EXPORTED int calcarddav_parse_path(const char *path,
/* Check if we're in user space */
len = strcspn(p, "/");
if (!strncmp(p, USER_COLLECTION_PREFIX, len)) {
/* zzzz is part of the FastMail sorting hack to make shared collections
* always appear later */
if (!strncmp(p, USER_COLLECTION_PREFIX, len) || !strncmp(p, "zzzz", len)) {
p += len;
if (!*p || !*++p) return 0;
@@ -5046,25 +5048,31 @@ static size_t make_collection_url(struct buf *buf, const char *urlprefix,
buf_printf(buf, "%s/", urlprefix);
if (userid) {
const char *owner;
buf_printf(buf, "%s/", USER_COLLECTION_PREFIX);
if (!mbname_domain(mbname)) mbname_set_domain(mbname, httpd_extradomain);
owner = mbname_userid(mbname);
const char *owner = mbname_userid(mbname);
if (!owner) owner = "";
if (*userid) {
buf_printf(buf, "%s/", userid);
if (mbox_owner) *mbox_owner = xstrdup(owner);
if (strcmp(owner, userid)) {
/* Encode shared collection as: <owner> "." <mboxname> */
buf_printf(buf, "%s%c", owner, SHARED_COLLECTION_DELIM);
}
if (config_getswitch(IMAPOPT_FASTMAILSHARING)) {
if (strcmp(owner, userid))
buf_printf(buf, "%s/%s/", "zzzz", owner);
else
buf_printf(buf, "%s/%s/", USER_COLLECTION_PREFIX, owner);
}
else buf_printf(buf, "%s/", owner);
else {
buf_printf(buf, "%s/", USER_COLLECTION_PREFIX);
if (mbox_owner) *mbox_owner = xstrdup(owner);
if (*userid) {
buf_printf(buf, "%s/", userid);
if (strcmp(owner, userid)) {
/* Encode shared collection as: <owner> "." <mboxname> */
buf_printf(buf, "%s%c", owner, SHARED_COLLECTION_DELIM);
}
}
else buf_printf(buf, "%s/", owner);
}
}
len = buf_len(buf);
@@ -5136,6 +5144,10 @@ int propfind_by_collection(const mbentry_t *mbentry, void *rock)
break;
}
/* skip toplevels */
if (config_getswitch(IMAPOPT_FASTMAILSHARING) && *p == '#')
goto done;
/* Open mailbox for reading */
if ((r = mailbox_open_irl(mboxname, &mailbox))) {
@@ -5434,6 +5446,10 @@ EXPORTED int meth_propfind(struct transaction_t *txn, void *params)
/* Add response for target collection */
propfind_by_collection(txn->req_tgt.mbentry, &fctx);
}
else if (config_getswitch(IMAPOPT_FASTMAILSHARING)) {
/* Add responses for all contained collections */
mboxlist_allmbox("", propfind_by_collection, &fctx, 0);
}
else if (txn->req_tgt.mbentry) {
/* Add responses for all contained collections */
fctx.prefer &= ~PREFER_NOROOT;
View
@@ -2267,6 +2267,9 @@ product version in the capabilities */
{ "caringo_port", 80, INT }
/* The port of the caringo server (caringo_hostname); default is 80. */
{ "fastmailsharing", 0, SWITCH }
/* If enabled, use FastMail style sharing (oldschool full server paths) */
/*
.SH SEE ALSO
.PP

0 comments on commit 64826ce

Please sign in to comment.