old way was making KOrganizer choke.
$Log$
+Revision 528.36 2005/02/02 23:25:21 ajc
+* Encode GroupDAV uid's using more concise string escaping, because the
+ old way was making KOrganizer choke.
+
Revision 528.35 2005/02/02 04:13:36 ajc
* Debugged the GroupDAV service with KOrganizer. It's mostly working now.
1998-12-03 Nathan Bryant <bryant@cs.usm.maine.edu>
* webserver.c: warning fix
-
void groupdav_propfind(char *);
long locate_message_by_uid(char *);
void groupdav_folder_list(void);
+void euid_escapize(char *, char *);
+void euid_unescapize(char *, char *);
+
}
dav_msgnum = locate_message_by_uid(dav_uid);
+ lprintf(9, "* That maps to msgnum %ld\n", dav_msgnum);
serv_printf("MSG2 %ld", dav_msgnum);
serv_gets(buf);
if (buf[0] != '1') {
+ lprintf(9, "* and it was not found.\n");
wprintf("HTTP/1.1 404 not found\n");
groupdav_common_headers();
wprintf(
return;
}
+ lprintf(9, "* and it was retrieved successfully.\n");
wprintf("HTTP/1.1 200 OK\n");
groupdav_common_headers();
wprintf("ETag: \"%ld\"\n", dav_msgnum);
}
+
+/*
+ * string conversion function
+ */
+void euid_escapize(char *target, char *source) {
+ int i;
+ int target_length = 0;
+
+ strcpy(target, "");
+ for (i=0; i<strlen(source); ++i) {
+ if (isalnum(source[i])) {
+ target[target_length] = source[i];
+ target[++target_length] = 0;
+ }
+ else {
+ sprintf(&target[target_length], "_%02X", source[i]);
+ target_length += 3;
+ }
+ }
+}
+
+/*
+ * string conversion function
+ */
+void euid_unescapize(char *target, char *source) {
+ int a, b;
+ char hex[3];
+ int target_length = 0;
+
+ strcpy(target, "");
+
+ for (a = 0; a < strlen(source); ++a) {
+ if (source[a] == '_') {
+ hex[0] = source[a + 1];
+ hex[1] = source[a + 2];
+ hex[2] = 0;
+ b = 0;
+ sscanf(hex, "%02x", &b);
+ target[target_length] = b;
+ target[++target_length] = 0;
+ a += 2;
+ }
+ else {
+ target[target_length] = source[a];
+ target[++target_length] = 0;
+ }
+ }
+}
+
+
+
+
/*
* Main entry point for GroupDAV requests
*/
long retval = (-1L);
/* Decode the uid */
- j=0;
- for (i=0; i<strlen(uid); i=i+2) {
- ch = 0;
- sscanf(&uid[i], "%02x", &ch);
- decoded_uid[j] = ch;
- decoded_uid[j+1] = 0;
- ++j;
- }
+ euid_unescapize(decoded_uid, uid);
serv_puts("MSGS ALL|0|1");
serv_gets(buf);
char msgnum[SIZ];
char buf[SIZ];
char uid[SIZ];
+ char encoded_uid[SIZ];
long *msgs = NULL;
int num_msgs = 0;
int i, j;
}
wprintf("/groupdav/");
urlescputs(WC->wc_roomname);
- wprintf("/");
- for (j=0; j<strlen(uid); ++j) {
- wprintf("%02X", uid[j]);
- }
+ euid_escapize(encoded_uid, uid);
+ wprintf("/%s", encoded_uid);
wprintf("</D:href>\n");
wprintf(" <D:propstat>\n");
wprintf(" <D:status>HTTP/1.1 200 OK</D:status>\n");
* version, so we fail...
*/
if (strlen(dav_ifmatch) > 0) {
+ lprintf(9, "* ifmatch failed, bailing out\n");
old_msgnum = locate_message_by_uid(dav_uid);
if (atol(dav_ifmatch) != old_msgnum) {
wprintf("HTTP/1.1 412 Precondition Failed\n");
* which allows a confirmation to be sent back to us. That's how we
* extract the message ID.
*/
+ lprintf(9, "* I am %s/%s/%s\n",
+ WC->wc_username,
+ WC->wc_password,
+ WC->wc_roomname
+ );
+ lprintf(9, "* allowing upload (old_msgnum=%ld, ifmatch=%s)\n", old_msgnum, dav_ifmatch);
serv_puts("ENT0 1|||4|||1|");
serv_gets(buf);
if (buf[0] != '8') {
}
/* Tell the client what happened. */
+ lprintf(9, "* new_msgnum = %ld\n", new_msgnum);
/* Citadel failed in some way? */
if (new_msgnum < 0L) {
/* We created this item for the first time. */
if (old_msgnum < 0L) {
+ lprintf(9, "* new item created\n");
wprintf("HTTP/1.1 201 Created\n");
groupdav_common_headers();
wprintf("Content-Length: 0\n");
}
/* We modified an existing item. */
+ lprintf(9, "* existing item replaced\n");
wprintf("HTTP/1.1 204 No Content\n");
groupdav_common_headers();
wprintf("Content-Length: 0\n\n");