* When submitting a message, harvest non-local addresses for potential
authorArt Cancro <ajc@citadel.org>
Sun, 18 Sep 2005 19:34:26 +0000 (19:34 +0000)
committerArt Cancro <ajc@citadel.org>
Sun, 18 Sep 2005 19:34:26 +0000 (19:34 +0000)
  inclusion in a user's Collected Addresses book.  Note: we don't actually
  do anything with these addresses yet.  That comes next.

citadel/ChangeLog
citadel/internet_addressing.c
citadel/internet_addressing.h
citadel/msgbase.c
citadel/sysconfig.h

index 71dbb7a214318db86979c5667fd16a655b96111d..0722424db739cf222f7142b2ff20575c7a40fd8b 100644 (file)
@@ -1,4 +1,9 @@
 $Log$
+Revision 655.9  2005/09/18 19:34:26  ajc
+* When submitting a message, harvest non-local addresses for potential
+  inclusion in a user's Collected Addresses book.  Note: we don't actually
+  do anything with these addresses yet.  That comes next.
+
 Revision 655.8  2005/09/18 17:50:05  ajc
 * serv_network.c: use a stat() call to determine the mtime of spoolin, and
   skip the scan if it hasn't been touched since the last time we looked.
@@ -7143,3 +7148,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 0a0de73a1054b19e091df3c5c845f5b5a8fc2ddb..0ec59ce34825674cd6a18a34407c7572b3604e75 100644 (file)
@@ -356,6 +356,12 @@ int convert_field(struct CtdlMessage *msg, int beg, int end) {
                processed = 1;
        }
 
+       else if (!strcasecmp(key, "CC")) {
+               if (msg->cm_fields['Y'] == NULL)
+                       msg->cm_fields['Y'] = strdup(value);
+               processed = 1;
+       }
+
        else if (!strcasecmp(key, "Message-ID")) {
                if (msg->cm_fields['I'] != NULL) {
                        lprintf(CTDL_WARNING, "duplicate message id\n");
@@ -633,3 +639,71 @@ int CtdlDirectoryLookup(char *target, char *internet_addr, size_t targbuflen) {
 
        return(-1);
 }
+
+
+/*
+ * Harvest any email addresses that someone might want to have in their
+ * "collected addresses" book.
+ */
+char *harvest_collected_addresses(struct CtdlMessage *msg) {
+       char *coll = NULL;
+       char addr[256];
+       char user[256], node[256], name[256];
+       int is_harvestable;
+       int i, j, h;
+       int field = 0;
+
+       if (msg == NULL) return(NULL);
+
+       is_harvestable = 1;
+       strcpy(addr, "");       
+       if (msg->cm_fields['A'] != NULL) {
+               strcat(addr, msg->cm_fields['A']);
+       }
+       if (msg->cm_fields['F'] != NULL) {
+               strcat(addr, " <");
+               strcat(addr, msg->cm_fields['F']);
+               strcat(addr, ">");
+               if (IsDirectory(msg->cm_fields['F'])) {
+                       is_harvestable = 0;
+               }
+       }
+
+       if (is_harvestable) {
+               coll = strdup(addr);
+       }
+       else {
+               coll = strdup("");
+       }
+
+       if (coll == NULL) return(NULL);
+
+       /* Scan both the R (To) and Y (CC) fields */
+       for (i = 0; i < 2; ++i) {
+               if (i == 0) field = 'R' ;
+               if (i == 1) field = 'Y' ;
+
+               if (msg->cm_fields[field] != NULL) {
+                       for (j=0; j<num_tokens(msg->cm_fields[field], ','); ++j) {
+                               extract_token(addr, msg->cm_fields[field], j, ',', sizeof addr);
+                               process_rfc822_addr(addr, user, node, name);
+                               h = CtdlHostAlias(node);
+                               if ( (h != hostalias_localhost) && (h != hostalias_directory) ) {
+                                       coll = realloc(coll, strlen(coll) + strlen(addr) + 4);
+                                       if (coll == NULL) return(NULL);
+                                       if (strlen(coll) > 0) {
+                                               strcat(coll, ",");
+                                       }
+                                       striplt(addr);
+                                       strcat(coll, addr);
+                               }
+                       }
+               }
+       }
+
+       if (strlen(coll) == 0) {
+               free(coll);
+               return(NULL);
+       }
+       return(coll);
+}
index 6e7b227cfa4de8ee29f93f77d97a4ddf9565d69b..009e73baed4fdbf54c1c9af474101f1fee3aaa1a 100644 (file)
@@ -24,6 +24,7 @@ void CtdlDirectoryDelUser(char *internet_addr, char *citadel_addr);
 int CtdlDirectoryLookup(char *target, char *internet_addr, size_t targbuflen);
 struct CtdlMessage *convert_internet_message(char *rfc822);
 int CtdlHostAlias(char *fqdn);
+char *harvest_collected_addresses(struct CtdlMessage *msg);
 
 /* 
  * Values that can be returned by CtdlHostAlias()
index 50aeaa1ae5766316e416e66933df84867b382526..59c11abb8c330744587c22165d632f4b668c9910 100644 (file)
@@ -1479,19 +1479,15 @@ int CtdlOutputPreLoadedMsg(
                cprintf(">%s", nl);
 
                if (!is_room_aide() && (TheMessage->cm_anon_type == MES_ANONONLY)) {
-                       // cprintf("From: x@x.org (----)%s", nl);
                        cprintf("From: \"----\" <x@x.org>%s", nl);
                }
                else if (!is_room_aide() && (TheMessage->cm_anon_type == MES_ANONOPT)) {
-                       // cprintf("From: x@x.org (anonymous)%s", nl);
                        cprintf("From: \"anonymous\" <x@x.org>%s", nl);
                }
                else if (strlen(fuser) > 0) {
-                       // cprintf("From: %s (%s)%s", fuser, luser, nl);
                        cprintf("From: \"%s\" <%s>%s", luser, fuser, nl);
                }
                else {
-                       // cprintf("From: %s@%s (%s)%s", suser, snode, luser, nl);
                        cprintf("From: \"%s\" <%s@%s>%s", luser, suser, snode, nl);
                }
 
@@ -2033,9 +2029,6 @@ int ReplicationChecks(struct CtdlMessage *msg) {
 
 
 
-
-
-
 /*
  * Save a message to disk and submit it into the delivery system.
  */
@@ -2061,6 +2054,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,       /* message to save */
        char *instr;
        struct ser_ret smr;
        char *hold_R, *hold_D;
+       char *collected_addresses = NULL;
 
        lprintf(CTDL_DEBUG, "CtdlSubmitMsg() called\n");
        if (is_valid_message(msg) == 0) return(-1);     /* self check */
@@ -2362,6 +2356,15 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,      /* message to save */
                CtdlFreeMessage(imsg);
        }
 
+       /*
+        * Any addresses to collect?  (FIXME do something with them!!)
+        */
+       collected_addresses = harvest_collected_addresses(msg);
+       if (collected_addresses != NULL) {
+               lprintf(CTDL_DEBUG, "FIXME collected addresses: %s\n", collected_addresses);
+               free(collected_addresses);
+       }
+
        return(newmsgid);
 }
 
index 545ddfee16a4139b471a83c3bf0ccab8aa49c562..895dc41c97ea21a9e2cec152ad9f320d491b8a4b 100644 (file)
 #define USERCALENDARROOM       "Calendar"
 #define USERTASKSROOM          "Tasks"
 #define USERCONTACTSROOM       "Contacts"
+#define USERCOLLECTEDROOM      "Collected Addresses"
 #define USERNOTESROOM          "Notes"
 #define PAGELOGROOM            "Sent/Received Pages"
 #define SYSCONFIGROOM          "Local System Configuration"