$Log$
+Revision 655.11 2005/09/18 21:51:44 ajc
+* File the auto-generated vCards into the users' address books.
+
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
Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
* Initial CVS import
+
*/
struct vCard *vcard_new_from_rfc822_addr(char *addr) {
struct vCard *v;
- char user[256], node[256], name[256], email[256];
+ char user[256], node[256], name[256], email[256], n[256];
v = vcard_new();
if (v == NULL) return(NULL);
process_rfc822_addr(addr, user, node, name);
vcard_set_prop(v, "fn", name, 0);
+
+ vcard_fn_to_n(n, name, sizeof n);
+ vcard_set_prop(v, "n", n, 0);
+
snprintf(email, sizeof email, "%s@%s", user, node);
vcard_set_prop(v, "email;internet", email, 0);
long newmsgid;
char *mptr = NULL;
struct ctdluser userbuf;
- int a, i;
+ int a, i, j;
struct MetaData smi;
FILE *network_fp = NULL;
static int seqnum = 1;
struct CtdlMessage *imsg = NULL;
struct CtdlMessage *vmsg = NULL;
+ long vmsgnum = (-1L);
char *ser = NULL;
struct vCard *v = NULL;
char *instr;
free(ser);
}
vcard_free(v);
- CtdlSubmitMsg(vmsg, NULL, "Aide"); /* FIXME */
+
+ if (recps->num_local > 0) {
+ for (j=0; j<num_tokens(recps->recp_local, '|'); ++j) {
+ extract_token(recipient, recps->recp_local, j,
+ '|', sizeof recipient);
+ lprintf(CTDL_DEBUG, "Adding contact for <%s>\n", recipient);
+ if (getuser(&userbuf, recipient) == 0) {
+ MailboxName(actual_rm, sizeof actual_rm,
+ &userbuf, USERCONTACTSROOM);
+
+ if (vmsgnum < 0L) {
+ vmsgnum = CtdlSubmitMsg(vmsg,
+ NULL, actual_rm);
+ }
+ else {
+ CtdlSaveMsgPointerInRoom(actual_rm,
+ vmsgnum, 0);
+ }
+
+ }
+ }
+ }
CtdlFreeMessage(vmsg);
}
}
}
+
/*
* When a user is being created, create his/her vCard.
*/
void vcard_newuser(struct ctdluser *usbuf) {
- char buf[256];
char vname[256];
-
- char lastname[256];
- char firstname[256];
- char middlename[256];
- char honorific_prefixes[256];
- char honorific_suffixes[256];
-
- struct vCard *v;
+ char buf[256];
int i;
+ struct vCard *v;
- /* Try to intelligently convert the screen name to a
- * fully expanded vCard name based on the number of
- * words in the name
- */
- safestrncpy(lastname, "", sizeof lastname);
- safestrncpy(firstname, "", sizeof firstname);
- safestrncpy(middlename, "", sizeof middlename);
- safestrncpy(honorific_prefixes, "", sizeof honorific_prefixes);
- safestrncpy(honorific_suffixes, "", sizeof honorific_suffixes);
-
- safestrncpy(buf, usbuf->fullname, sizeof buf);
-
- /* Honorific suffixes */
- if (num_tokens(buf, ',') > 1) {
- extract_token(honorific_suffixes, buf, (num_tokens(buf, ' ') - 1), ',',
- sizeof honorific_suffixes);
- remove_token(buf, (num_tokens(buf, ',') - 1), ',');
- }
-
- /* Find a last name */
- extract_token(lastname, buf, (num_tokens(buf, ' ') - 1), ' ', sizeof lastname);
- remove_token(buf, (num_tokens(buf, ' ') - 1), ' ');
-
- /* Find honorific prefixes */
- if (num_tokens(buf, ' ') > 2) {
- extract_token(honorific_prefixes, buf, 0, ' ', sizeof honorific_prefixes);
- remove_token(buf, 0, ' ');
- }
-
- /* Find a middle name */
- if (num_tokens(buf, ' ') > 1) {
- extract_token(middlename, buf, (num_tokens(buf, ' ') - 1), ' ', sizeof middlename);
- remove_token(buf, (num_tokens(buf, ' ') - 1), ' ');
- }
-
- /* Anything left is probably the first name */
- safestrncpy(firstname, buf, sizeof firstname);
- striplt(firstname);
-
- /* Compose the structured name */
- snprintf(vname, sizeof vname, "%s;%s;%s;%s;%s", lastname, firstname, middlename,
- honorific_prefixes, honorific_suffixes);
-
+ vcard_fn_to_n(vname, usbuf->fullname, sizeof vname);
lprintf(CTDL_DEBUG, "Converted <%s> to <%s>\n", usbuf->fullname, vname);
/* Create and save the vCard */
*
* vCard implementation for Citadel
*
- * Copyright (C) 1999 by Art Cancro
+ * Copyright (C) 1999-2005 by Art Cancro
* This code is freely redistributable under the terms of the GNU General
* Public License. All other rights reserved.
*/
#include <string.h>
#include <errno.h>
#include <limits.h>
+#include <string.h>
#include "citadel.h"
#include "server.h"
#include "support.h"
#include "vcard.h"
+#include "tools.h"
/*
* Constructor (empty vCard)
return ser;
}
+
+
+
+/*
+ * Convert FN (Friendly Name) into N (Name)
+ */
+void vcard_fn_to_n(char *vname, char *n, size_t vname_size) {
+ char lastname[256];
+ char firstname[256];
+ char middlename[256];
+ char honorific_prefixes[256];
+ char honorific_suffixes[256];
+ char buf[256];
+
+ safestrncpy(buf, n, sizeof buf);
+
+ /* Try to intelligently convert the screen name to a
+ * fully expanded vCard name based on the number of
+ * words in the name
+ */
+ safestrncpy(lastname, "", sizeof lastname);
+ safestrncpy(firstname, "", sizeof firstname);
+ safestrncpy(middlename, "", sizeof middlename);
+ safestrncpy(honorific_prefixes, "", sizeof honorific_prefixes);
+ safestrncpy(honorific_suffixes, "", sizeof honorific_suffixes);
+
+ /* Honorific suffixes */
+ if (num_tokens(buf, ',') > 1) {
+ extract_token(honorific_suffixes, buf, (num_tokens(buf, ' ') - 1), ',',
+ sizeof honorific_suffixes);
+ remove_token(buf, (num_tokens(buf, ',') - 1), ',');
+ }
+
+ /* Find a last name */
+ extract_token(lastname, buf, (num_tokens(buf, ' ') - 1), ' ', sizeof lastname);
+ remove_token(buf, (num_tokens(buf, ' ') - 1), ' ');
+
+ /* Find honorific prefixes */
+ if (num_tokens(buf, ' ') > 2) {
+ extract_token(honorific_prefixes, buf, 0, ' ', sizeof honorific_prefixes);
+ remove_token(buf, 0, ' ');
+ }
+
+ /* Find a middle name */
+ if (num_tokens(buf, ' ') > 1) {
+ extract_token(middlename, buf, (num_tokens(buf, ' ') - 1), ' ', sizeof middlename);
+ remove_token(buf, (num_tokens(buf, ' ') - 1), ' ');
+ }
+
+ /* Anything left is probably the first name */
+ safestrncpy(firstname, buf, sizeof firstname);
+ striplt(firstname);
+
+ /* Compose the structured name */
+ snprintf(vname, vname_size, "%s;%s;%s;%s;%s", lastname, firstname, middlename,
+ honorific_prefixes, honorific_suffixes);
+}
+
+
+
+
char *vcard_get_prop(struct vCard *v, char *propname, int is_partial,
int instance, int return_propname);
char *vcard_serialize(struct vCard *);
+void vcard_fn_to_n(char *vname, char *n, size_t vname_size);