From: Art Cancro Date: Fri, 8 Oct 1999 02:55:57 +0000 (+0000) Subject: * More vCard-related debugging X-Git-Tag: v7.86~7508 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=ee828f9452412a5228d064ab7fd5b1c1f5ff9ca8 * More vCard-related debugging --- diff --git a/citadel/ChangeLog b/citadel/ChangeLog index 07c480735..6ef0bb94e 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,4 +1,7 @@ $Log$ +Revision 1.381 1999/10/08 02:55:57 ajc +* More vCard-related debugging + 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 @@ -1298,3 +1301,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant Fri Jul 10 1998 Art Cancro * Initial CVS import + diff --git a/citadel/dynloader.c b/citadel/dynloader.c index f6da4d7b2..1993328c8 100644 --- a/citadel/dynloader.c +++ b/citadel/dynloader.c @@ -267,6 +267,18 @@ int PerformMessageHooks(struct CtdlMessage *msg, int EventType) struct MessageFunctionHook *fcn; int total_retval = 0; + /* Other code may elect to protect this message from server-side + * handlers; if this is the case, don't do anything. + */ + lprintf(9, "** Event type is %d, flags are %d\n", + EventType, msg->cm_flags); + if (msg->cm_flags & CM_SKIP_HOOKS) { + lprintf(9, "Skipping hooks\n"); + return(0); + } + + /* Otherwise, run all the hooks appropriate to this event type. + */ for (fcn = MessageHookTable; fcn != NULL; fcn = fcn->next) { if (fcn->eventtype == EventType) { total_retval = total_retval + @@ -274,9 +286,15 @@ int PerformMessageHooks(struct CtdlMessage *msg, int EventType) } } + /* Return the sum of the return codes from the hook functions. If + * this is an EVT_BEFORESAVE event, a nonzero return code will cause + * the save operation to abort. + */ return total_retval; } + + int PerformXmsgHooks(char *sender, char *recp, char *msg) { struct XmsgFunctionHook *fcn; diff --git a/citadel/msgbase.c b/citadel/msgbase.c index c703009d8..796c725e7 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -1922,7 +1922,8 @@ void CtdlWriteObject(char *req_room, /* Room to stuff it in */ char *tempfilename, /* Where to fetch it from */ struct usersupp *is_mailbox, /* Mailbox room? */ int is_binary, /* Is encoding necessary? */ - int is_unique /* Del others of this type? */ + int is_unique, /* Del others of this type? */ + unsigned int flags /* Internal save flags */ ) { @@ -1939,7 +1940,7 @@ void CtdlWriteObject(char *req_room, /* Room to stuff it in */ MailboxName(roomname, is_mailbox, req_room); else safestrncpy(roomname, req_room, sizeof(roomname)); - lprintf(9, "CtdlWriteObject() to <%s>\n", roomname); + lprintf(9, "CtdlWriteObject() to <%s> (flags=%d)\n", roomname, flags); strcpy(filename, tmpnam(NULL)); fp = fopen(filename, "w"); @@ -1982,6 +1983,7 @@ void CtdlWriteObject(char *req_room, /* Room to stuff it in */ msg->cm_fields['O'] = strdoop(req_room); msg->cm_fields['N'] = strdoop(config.c_nodename); msg->cm_fields['H'] = strdoop(config.c_humannode); + msg->cm_flags = flags; lprintf(9, "Loading\n"); fp = fopen(filename, "rb"); diff --git a/citadel/msgbase.h b/citadel/msgbase.h index df8dec825..99670f9bd 100644 --- a/citadel/msgbase.h +++ b/citadel/msgbase.h @@ -50,7 +50,8 @@ void CtdlForEachMessage(int mode, long ref, char *content_type, void (*CallBack) (long msgnum) ); int CtdlDeleteMessages(char *, long, char *); -void CtdlWriteObject(char *, char *, char *, struct usersupp *, int, int); +void CtdlWriteObject(char *, char *, char *, struct usersupp *, + int, int, unsigned int); struct CtdlMessage *CtdlFetchMessage(long msgnum); void CtdlFreeMessage(struct CtdlMessage *msg); void serialize_message(struct ser_ret *, struct CtdlMessage *); diff --git a/citadel/serv_icq.c b/citadel/serv_icq.c index 55bacae56..93860e800 100644 --- a/citadel/serv_icq.c +++ b/citadel/serv_icq.c @@ -1824,7 +1824,7 @@ void CtdlICQ_Write_Config(void) { fclose(fp); /* this handy API function does all the work for us */ - CtdlWriteObject(CONFIGROOM, ICQMIME, temp, &CC->usersupp, 0, 1); + CtdlWriteObject(CONFIGROOM, ICQMIME, temp, &CC->usersupp, 0, 1, 0); unlink(temp); } @@ -1854,7 +1854,7 @@ void CtdlICQ_Write_CL(void) { fclose(fp); /* this handy API function does all the work for us */ - CtdlWriteObject(CONFIGROOM, ICQCLMIME, temp, &CC->usersupp, 0, 1); + CtdlWriteObject(CONFIGROOM, ICQCLMIME, temp, &CC->usersupp, 0, 1, 0); unlink(temp); } diff --git a/citadel/serv_upgrade.c b/citadel/serv_upgrade.c index cf2453340..eeb997b80 100644 --- a/citadel/serv_upgrade.c +++ b/citadel/serv_upgrade.c @@ -60,6 +60,7 @@ void do_pre555_usersupp_upgrade(void) { /* ...and overwrite the records with new format records */ rewind(fp); while (fread(&usbuf, sizeof(struct pre555usersupp), 1, fp) > 0) { + if (strlen(usbuf.fullname) > 0) { lprintf(9, "Upgrading <%s>\n", usbuf.fullname); memset(&newus, 0, sizeof(struct usersupp)); @@ -100,9 +101,9 @@ void do_pre555_usersupp_upgrade(void) { fclose(tp); CtdlWriteObject(CONFIGROOM, "text/x-vcard", - tempfilename, &newus, 0, 1); + tempfilename, &newus, 0, 1, CM_SKIP_HOOKS); unlink(tempfilename); - + } } fclose(fp); /* this file deletes automatically */ diff --git a/citadel/serv_vcard.c b/citadel/serv_vcard.c index 344ab1656..d9fa1da71 100644 --- a/citadel/serv_vcard.c +++ b/citadel/serv_vcard.c @@ -74,6 +74,8 @@ int vcard_upload_beforesave(struct CtdlMessage *msg) { char config_rm[ROOMNAMELEN]; char buf[256]; + lprintf(9, "entering beforesave hook\n"); + /* If this isn't the configuration room, or if this isn't a MIME * message, don't bother. */ @@ -267,7 +269,8 @@ void vcard_write_user(struct usersupp *u, struct vCard *v) { temp, /* temp file */ u, /* which user */ 0, /* not binary */ - 0); /* don't delete others of this type */ + 0, /* don't delete others of this type */ + 0); /* no flags */ unlink(temp); } diff --git a/citadel/server.h b/citadel/server.h index f12c23fca..94c9fce4f 100644 --- a/citadel/server.h +++ b/citadel/server.h @@ -6,7 +6,20 @@ typedef pthread_t THREAD; */ #define DEBUG_MEMORY_LEAKS -struct CtdlMessage; +/* + * New format for a message in memory + */ +#define CTDLMESSAGE_MAGIC 0x159d +struct CtdlMessage { + int cm_magic; /* Self-check */ + char cm_anon_type; /* Anonymous or author-visible */ + char cm_format_type; /* Format type */ + char *cm_fields[256]; /* Data fields */ + unsigned int cm_flags; /* How to handle (NOT SAVED TO DISK) */ +}; + +#define CM_SKIP_HOOKS 0x01 /* Don't run server-side handlers */ + /* * Generic per-session variable or data structure storage @@ -363,17 +376,6 @@ struct ser_ret { }; -/* - * New format for a message in memory - */ -#define CTDLMESSAGE_MAGIC 0x159d -struct CtdlMessage { - int cm_magic; /* Self-check */ - char cm_anon_type; /* Anonymous or author-visible */ - char cm_format_type; /* Format type */ - char *cm_fields[256]; /* Data fields */ -}; - /* Preferred field order */ /* ********* Important fields */ /* **************** Semi-important fields */