* If a user has at least one valid Internet directory address, stamp it onto
authorArt Cancro <ajc@citadel.org>
Sat, 2 Feb 2002 21:44:04 +0000 (21:44 +0000)
committerArt Cancro <ajc@citadel.org>
Sat, 2 Feb 2002 21:44:04 +0000 (21:44 +0000)
  any outgoing messages.

citadel/ChangeLog
citadel/msgbase.c
citadel/serv_vcard.c
citadel/server.h
citadel/user_ops.c

index a6fb24357cadbc5d91980141cedfe847dc6d5af5..4ef55bd591e18e4aa611b193fc968957f8d26d48 100644 (file)
@@ -1,4 +1,8 @@
  $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.
@@ -3282,3 +3286,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import 
+
index 468b7079593f0ed533fc2aff4e4da4dd1378b11e..4c162d2b25ee5703cc1cd1c6e3c2267be9de06f8 100644 (file)
@@ -1123,14 +1123,16 @@ int CtdlOutputPreLoadedMsg(struct CtdlMessage *TheMessage,
                                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') {
@@ -2121,6 +2123,10 @@ static struct CtdlMessage *make_message(
                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);
 
index eeb9e192143b1e78e683540b4d82d4fdb514d146..275b4a8d04d95cc6a45634757df139f47b837916 100644 (file)
@@ -163,6 +163,49 @@ void cmd_igab(char *argbuf) {
 
 
 
+
+/*
+ * 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
@@ -242,6 +285,7 @@ int vcard_upload_aftersave(struct CtdlMessage *msg) {
        char *ptr;
        int linelen;
        long I;
+       struct vCard *v;
 
        if (!CC->logged_in) return(0);  /* Only do this if logged in. */
 
@@ -274,6 +318,11 @@ int vcard_upload_aftersave(struct CtdlMessage *msg) {
                        /* ...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);
                }
 
@@ -639,10 +688,36 @@ void vcard_session_startup_hook(void) {
 }
 
 
+/*
+ * 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);
index d1df876828b79f4fad8a8efc8500e11607e74a6f..583f55a2ccf4ad5f5d0fce97ee0b39c3b4815b1c 100644 (file)
@@ -111,8 +111,8 @@ struct CitContext {
        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;
@@ -123,6 +123,9 @@ struct CitContext {
        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;
@@ -138,7 +141,7 @@ struct CitContext {
        /* 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 */
@@ -353,7 +356,7 @@ extern DLEXP struct NetprocFunctionHook *NetprocHookTable;
  */
 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;
 
index f8aefce0d3426c8df61d5e3f7fd6cdb694618d5f..5930c71ad8733ef96c5f6a7004ae2b944c29169b 100644 (file)
@@ -454,6 +454,14 @@ void logout(struct CitContext *who)
                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);
 }