any outgoing messages.
$Log$
+ Revision 590.98 2002/02/02 21:44:04 ajc
+ * If a user has at least one valid Internet directory address, stamp it onto
+ any outgoing messages.
+
Revision 590.97 2002/02/01 05:11:26 ajc
* Added a QDIR protocol command to do quick-and-dirty queries of the directory
* In the client, check the directory for conflicts when selecting email addr.
Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
* Initial CVS import
+
else if (i == 'U')
cprintf("Subject: %s%s", mptr, nl);
else if (i == 'I')
- strcpy(mid, mptr);
+ safestrncpy(mid, mptr, sizeof mid);
else if (i == 'H')
- strcpy(lnode, mptr);
+ safestrncpy(lnode, mptr, sizeof lnode);
+ else if (i == 'F')
+ safestrncpy(fuser, mptr, sizeof fuser);
else if (i == 'O')
cprintf("X-Citadel-Room: %s%s",
mptr, nl);
else if (i == 'N')
- strcpy(snode, mptr);
+ safestrncpy(snode, mptr, sizeof snode);
else if (i == 'R')
cprintf("To: %s%s", mptr, nl);
else if (i == 'T') {
msg->cm_fields['D'] = strdoop(dest_node);
}
+ if (author == &CC->usersupp) {
+ msg->cm_fields['F'] = strdoop(CC->cs_inet_email);
+ }
+
msg->cm_fields['M'] = CtdlReadMessageBody("000",
config.c_maxmsglen, NULL);
+
+/*
+ * See if there is a valid Internet address in a vCard to use for outbound
+ * Interet messages. If there is, stick it in CC->cs_inet_email.
+ */
+void vcard_populate_cs_inet_email(struct vCard *v) {
+ char *s, *addr;
+ int continue_searching = 1;
+ int instance = 0;
+
+ /*
+ * Clear whatever was in there previously.
+ */
+ if (CC->cs_inet_email != NULL) {
+ phree(CC->cs_inet_email);
+ CC->cs_inet_email = NULL;
+ }
+
+ /* Go through the vCard searching for *all* instances of
+ * the "email;internet" key
+ */
+ do {
+ s = vcard_get_prop(v, "email;internet", 0, instance++);
+ if (s != NULL) {
+ continue_searching = 1;
+ addr = strdoop(s);
+ striplt(addr);
+ if (strlen(addr) > 0) {
+ if (IsDirectory(addr)) {
+ continue_searching = 0;
+ CC->cs_inet_email = strdoop(addr);
+ }
+ }
+ phree(addr);
+ }
+ else {
+ continue_searching = 0;
+ }
+ } while(continue_searching);
+}
+
+
+
/*
* This handler detects whether the user is attempting to save a new
* vCard as part of his/her personal configuration, and handles the replace
char *ptr;
int linelen;
long I;
+ struct vCard *v;
if (!CC->logged_in) return(0); /* Only do this if logged in. */
/* ...and also in the directory database. */
vcard_add_to_directory(I, NULL);
+ /* Store our Internet return address in memory */
+ v = vcard_load(msg->cm_fields['M']);
+ vcard_populate_cs_inet_email(v);
+ vcard_free(v);
+
return(0);
}
}
+/*
+ * When a user logs in...
+ */
+void vcard_session_login_hook(void) {
+ struct vCard *v;
+
+ v = vcard_get_user(&CC->usersupp);
+ vcard_populate_cs_inet_email(v);
+
+ vcard_free(v);
+}
+
+
+/*
+ * When a user logs out...
+ */
+void vcard_session_logout_hook(void) {
+ if (CC->cs_inet_email != NULL) {
+ phree(CC->cs_inet_email);
+ CC->cs_inet_email = NULL;
+ }
+}
+
+
char *Dynamic_Module_Init(void)
{
SYM_VCARD = CtdlGetDynamicSymbol();
CtdlRegisterSessionHook(vcard_session_startup_hook, EVT_START);
+ CtdlRegisterSessionHook(vcard_session_login_hook, EVT_LOGIN);
+ CtdlRegisterSessionHook(vcard_session_logout_hook, EVT_LOGOUT);
CtdlRegisterMessageHook(vcard_upload_beforesave, EVT_BEFORESAVE);
CtdlRegisterMessageHook(vcard_upload_aftersave, EVT_AFTERSAVE);
CtdlRegisterDeleteHook(vcard_delete_remove);
char cs_clientname[32]; /* name of client software */
char cs_host[64]; /* host logged in from */
- /* Beginning of cryptography - session nonce */
- char cs_nonce[NONCE_SIZE]; /* The nonce for this session's next auth transaction */
+ /* The Internet type of thing */
+ char *cs_inet_email; /* Return address of outbound Internet mail */
FILE *download_fp; /* Fields relating to file transfer */
FILE *upload_fp;
char dl_is_net;
char upload_type;
+ /* Beginning of cryptography - session nonce */
+ char cs_nonce[NONCE_SIZE]; /* The nonce for this session's next auth transaction */
+
/* Redirect this session's output to somewhere else? */
FILE *redirect_fp;
int redirect_sock;
/* Masquerade... */
char fake_username[USERNAME_SIZE]; /* Fake username <bc> */
char fake_postname[USERNAME_SIZE]; /* Fake postname <bc> */
- char fake_hostname[25]; /* Fake hostname <bc> */
+ char fake_hostname[64]; /* Fake hostname <bc> */
char fake_roomname[ROOMNAMELEN]; /* Fake roomname <bc> */
/* Dynamically allocated session data */
*/
struct DeleteFunctionHook {
struct DeleteFunctionHook *next;
- int (*h_function_pointer) (char *target_room, long msgnum);
+ void (*h_function_pointer) (char *target_room, long msgnum);
};
extern DLEXP struct DeleteFunctionHook *DeleteHookTable;
network_talking_to(who->net_node, NTT_REMOVE);
}
+ /*
+ * Yes, we really need to free EVERY LAST BYTE we allocated.
+ */
+ if (who->cs_inet_email != NULL) {
+ phree(who->cs_inet_email);
+ who->cs_inet_email = NULL;
+ }
+
/* Do modular stuff... */
PerformSessionHooks(EVT_LOGOUT);
}