* Semi-broken vCard replacement implementation in place.
authorArt Cancro <ajc@citadel.org>
Thu, 7 Oct 1999 02:58:50 +0000 (02:58 +0000)
committerArt Cancro <ajc@citadel.org>
Thu, 7 Oct 1999 02:58:50 +0000 (02:58 +0000)
* Added "Z" (Zap, supersede) field to message format

citadel/ChangeLog
citadel/msgbase.c
citadel/serv_vcard.c
citadel/techdoc/hack.txt

index fb35a81d95330a61f86c9c8c94e29c8a4d596a1e..07c480735d90ac46b2edd7cd5bd92020cde56c9d 100644 (file)
@@ -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.
index 8e48ee92e3bfc6e3ed175074d11dc2e8b56013e9..c703009d82691b58e9ed403e6451e36e1a496eb0 100644 (file)
@@ -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;
 }
index cbd84c3f87846774dfe1f3b135087ad5cb0b9b60..344ab16561e40548537818d9153c0b1cab5b5fc1 100644 (file)
@@ -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$";
 }
index 321a2ea1579a7d04eca80595e15d3865095a25ea..cad393b1fcb00b4283b76dd021acd2d112794389 100644 (file)
@@ -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