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 */
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]]);
}
if (ret->len != wlen) lprintf(3, "ERROR: len=%d wlen=%d\n",
ret->len, wlen);
+ lprintf(9, "done serializing\n");
return;
}
/*
- * 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;
}
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.
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);
}
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.
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);
}
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.
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$";
}