From 2b8c2c39b63f724c88b23cdfdfdcb7be52e4b643 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Thu, 7 Oct 1999 02:58:50 +0000 Subject: [PATCH] * Semi-broken vCard replacement implementation in place. * Added "Z" (Zap, supersede) field to message format --- citadel/ChangeLog | 11 ++----- citadel/msgbase.c | 6 +++- citadel/serv_vcard.c | 70 ++++++++++++++++++++++++++++------------ citadel/techdoc/hack.txt | 3 ++ 4 files changed, 60 insertions(+), 30 deletions(-) diff --git a/citadel/ChangeLog b/citadel/ChangeLog index fb35a81d9..07c480735 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,12 +1,7 @@ $Log$ -Revision 1.379 1999/10/06 23:17:44 ajc -* vCard upload now copies the user's card to the global address book (but it - hangs the server if the target room doesn't exist) - -Revision 1.378 1999/10/06 03:51:01 ajc -* Figured out a way to get the user's vCard to automatically delete in the - global address book when it's replaced. Now to find a way to add the new - one... +Revision 1.380 1999/10/07 02:58:46 ajc +* Semi-broken vCard replacement implementation in place. +* Added "Z" (Zap, supersede) field to message format Revision 1.377 1999/10/04 03:19:52 ajc * We now have a housekeeping thread and a housekeeping queue. diff --git a/citadel/msgbase.c b/citadel/msgbase.c index 8e48ee92e..c703009d8 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -746,6 +746,9 @@ void output_message(char *msgid, int mode, int headers_only) if (TheMessage->cm_fields['U']) { cprintf("subj=%s\n", TheMessage->cm_fields['U']); } + if (TheMessage->cm_fields['Z']) { + cprintf("zaps=%s\n", TheMessage->cm_fields['Z']); + } } /* begin header processing loop for RFC822 transfer format */ @@ -1078,8 +1081,8 @@ void serialize_message(struct ser_ret *ret, /* return values */ ret->ser[1] = msg->cm_anon_type; ret->ser[2] = msg->cm_format_type; wlen = 3; - lprintf(9, "stuff\n"); + lprintf(9, "stuff\n"); for (i=0; i<26; ++i) if (msg->cm_fields[(int)forder[i]] != NULL) { ret->ser[wlen++] = (char)forder[i]; strcpy(&ret->ser[wlen], msg->cm_fields[(int)forder[i]]); @@ -1087,6 +1090,7 @@ void serialize_message(struct ser_ret *ret, /* return values */ } if (ret->len != wlen) lprintf(3, "ERROR: len=%d wlen=%d\n", ret->len, wlen); + lprintf(9, "done serializing\n"); return; } diff --git a/citadel/serv_vcard.c b/citadel/serv_vcard.c index cbd84c3f8..344ab1656 100644 --- a/citadel/serv_vcard.c +++ b/citadel/serv_vcard.c @@ -54,12 +54,10 @@ unsigned long SYM_VCARD; /* - * back end function used by vcard_upload_beforesave() + * back end function used for callbacks */ -void vcard_replace_backend(long msgnum) { - lprintf(9, "doing the replace thing for <%ld>\n", msgnum); - CtdlDeleteMessages(CONFIGROOM, msgnum, NULL); - CtdlDeleteMessages(ADDRESS_BOOK_ROOM, msgnum, NULL); +void vcard_gm_backend(long msgnum) { + VC->msgnum = msgnum; } @@ -74,6 +72,7 @@ int vcard_upload_beforesave(struct CtdlMessage *msg) { int linelen; char hold_rm[ROOMNAMELEN]; char config_rm[ROOMNAMELEN]; + char buf[256]; /* If this isn't the configuration room, or if this isn't a MIME * message, don't bother. @@ -99,8 +98,20 @@ int vcard_upload_beforesave(struct CtdlMessage *msg) { getroom(&CC->quickroom, hold_rm); return(1); /* abort */ } + VC->msgnum = (-1L); CtdlForEachMessage(MSGS_ALL, 0, - "text/x-vcard", vcard_replace_backend); + "text/x-vcard", vcard_gm_backend); + + if (VC->msgnum >= 0) { + if (msg->cm_fields['Z'] != NULL) + phree(msg->cm_fields['Z']); + sprintf(buf, "%ld@%s", VC->msgnum, NODENAME); + msg->cm_fields['Z'] = strdoop(buf); + lprintf(9, "replacing <%s>\n", buf); + } + + CtdlDeleteMessages(config_rm, 0L, "text/x-vcard"); + getroom(&CC->quickroom, hold_rm); /* return rm */ return(0); } @@ -123,8 +134,11 @@ int vcard_upload_beforesave(struct CtdlMessage *msg) { int vcard_upload_aftersave(struct CtdlMessage *msg) { char *ptr; int linelen; - long msgid; + long Z, I; struct quickroom qrbuf; + char buf[256]; + + lprintf(9, "entering aftersave hook\n"); /* If this isn't the configuration room, or if this isn't a MIME * message, don't bother. @@ -140,16 +154,36 @@ int vcard_upload_aftersave(struct CtdlMessage *msg) { if (!strncasecmp(ptr, "Content-type: text/x-vcard", 26)) { /* Bingo! The user is uploading a new vCard, so - * delete the old one. + * copy it to the Global Address Book room. */ + lprintf(9, "activated aftersave hook\n"); + + I = atol(msg->cm_fields['I']); + if (I < 0L) return(0); + + Z = (-1L); + if (msg->cm_fields['Z'] != NULL) { + extract_token(buf, msg->cm_fields['Z'], 1, '@'); + if (!strcasecmp(buf, NODENAME)) { + extract_token(buf, msg->cm_fields['Z'], + 0, '@'); + Z = atol(buf); + } + } - msgid = atol(msg->cm_fields['I']); - if (msgid < 0L) return(0); - + lprintf(9, "calling getroom\n"); if (getroom(&qrbuf, ADDRESS_BOOK_ROOM) != 0) return(0); - AddMessageToRoom(&qrbuf, msgid); - AdjRefCount(msgid, +1); + lprintf(9, "calling AddMessageToRoom\n"); + AddMessageToRoom(&qrbuf, I); + lprintf(9, "calling AdjRefCount\n"); + AdjRefCount(I, +1); + + if (Z > 0L) { + lprintf(9, "Deleting the old one\n"); + CtdlDeleteMessages(ADDRESS_BOOK_ROOM, Z, NULL); + } + lprintf(9, "finishing aftersave hook\n"); return(0); } @@ -157,19 +191,12 @@ int vcard_upload_aftersave(struct CtdlMessage *msg) { if (ptr != NULL) ++ptr; } + lprintf(9, "didn't do anything in hook\n"); return(0); } -/* - * back end function used by vcard_get_user() - */ -void vcard_gm_backend(long msgnum) { - VC->msgnum = msgnum; -} - - /* * If this user has a vcard on disk, read it into memory, otherwise allocate * and return an empty vCard. @@ -404,5 +431,6 @@ char *Dynamic_Module_Init(void) CtdlRegisterMessageHook(vcard_upload_aftersave, EVT_AFTERSAVE); CtdlRegisterProtoHook(cmd_regi, "REGI", "Enter registration info"); CtdlRegisterProtoHook(cmd_greg, "GREG", "Get registration info"); + create_room(ADDRESS_BOOK_ROOM, 0, "", 0); return "$Id$"; } diff --git a/citadel/techdoc/hack.txt b/citadel/techdoc/hack.txt index 321a2ea15..cad393b1f 100644 --- a/citadel/techdoc/hack.txt +++ b/citadel/techdoc/hack.txt @@ -113,6 +113,9 @@ T Date/Time A 32-bit integer containing the date and time of U Subject Optional. Developers may choose whether they wish to generate or display subject fields. Citadel/UX does not generate them, but it does print them when found. +Z Zap (supersede) Indicates a message which this message supersedes. + The format is "user@node" and if the specified message + is found, it should be deleted. EXAMPLE -- 2.30.2