From: Art Cancro Date: Sun, 18 Sep 2005 20:33:13 +0000 (+0000) Subject: * Now harvesting addresses, converting them to vCards, and storing them in X-Git-Tag: v7.86~4628 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=1755118cd22db26151ef9fff730a9f6f25b96619 * Now harvesting addresses, converting them to vCards, and storing them in the Aide> room. All that's left to do now is file the messages in the appropriate users' address books. --- diff --git a/citadel/ChangeLog b/citadel/ChangeLog index 0722424db..bd1cdf720 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,4 +1,9 @@ $Log$ +Revision 655.10 2005/09/18 20:33:13 ajc +* Now harvesting addresses, converting them to vCards, and storing them in + the Aide> room. All that's left to do now is file the messages in the + appropriate users' address books. + 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 @@ -7148,4 +7153,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant Fri Jul 10 1998 Art Cancro * Initial CVS import - diff --git a/citadel/msgbase.c b/citadel/msgbase.c index 59c11abb8..e20faa973 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -52,6 +52,7 @@ #include "genstamp.h" #include "internet_addressing.h" #include "serv_fulltext.h" +#include "vcard.h" long config_msgnum; @@ -2029,6 +2030,26 @@ int ReplicationChecks(struct CtdlMessage *msg) { +/* + * Turn an arbitrary RFC822 address into a struct vCard for possible + * inclusion into an address book. + */ +struct vCard *vcard_new_from_rfc822_addr(char *addr) { + struct vCard *v; + char user[256], node[256], name[256], email[256]; + + v = vcard_new(); + if (v == NULL) return(NULL); + + process_rfc822_addr(addr, user, node, name); + vcard_set_prop(v, "fn", name, 0); + snprintf(email, sizeof email, "%s@%s", user, node); + vcard_set_prop(v, "email;internet", email, 0); + + return(v); +} + + /* * Save a message to disk and submit it into the delivery system. */ @@ -2051,6 +2072,9 @@ long CtdlSubmitMsg(struct CtdlMessage *msg, /* message to save */ FILE *network_fp = NULL; static int seqnum = 1; struct CtdlMessage *imsg = NULL; + struct CtdlMessage *vmsg = NULL; + char *ser = NULL; + struct vCard *v = NULL; char *instr; struct ser_ret smr; char *hold_R, *hold_D; @@ -2357,14 +2381,44 @@ long CtdlSubmitMsg(struct CtdlMessage *msg, /* message to save */ } /* - * Any addresses to collect? (FIXME do something with them!!) + * Any addresses to harvest for someone's address book? + * (Don't do this if this is not a message with recipients, otherwise we will + * send this function into infinite recursion!!!!!) */ - collected_addresses = harvest_collected_addresses(msg); + if (recps != NULL) { + collected_addresses = harvest_collected_addresses(msg); + } + if (collected_addresses != NULL) { - lprintf(CTDL_DEBUG, "FIXME collected addresses: %s\n", collected_addresses); + for (i=0; icm_magic = CTDLMESSAGE_MAGIC; + vmsg->cm_anon_type = MES_NORMAL; + vmsg->cm_format_type = FMT_RFC822; + vmsg->cm_fields['A'] = strdup("Citadel"); + vmsg->cm_fields['E'] = strdup(recipient); /* this handles dups */ + ser = vcard_serialize(v); + if (ser != NULL) { + vmsg->cm_fields['M'] = malloc(strlen(ser) + 1024); + sprintf(vmsg->cm_fields['M'], + "Content-type: text/x-vcard" + "\r\n\r\n%s\r\n", ser); + free(ser); + } + vcard_free(v); + CtdlSubmitMsg(vmsg, NULL, "Aide"); /* FIXME */ + CtdlFreeMessage(vmsg); + } + } free(collected_addresses); } - return(newmsgid); } @@ -3385,7 +3439,6 @@ void AdjRefCount(long msgnum, int incr) /* If the reference count is now zero, delete the message * (and its supplementary record as well). - * FIXME ... defer this so it doesn't keep the user waiting. */ if (smi.meta_refcount == 0) { lprintf(CTDL_DEBUG, "Deleting message <%ld>\n", msgnum); diff --git a/citadel/sysconfig.h b/citadel/sysconfig.h index 895dc41c9..545ddfee1 100644 --- a/citadel/sysconfig.h +++ b/citadel/sysconfig.h @@ -107,7 +107,6 @@ #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"