* A server-side module for Citadel which supports address book information
* using the standard vCard format.
*
- * Copyright (c) 1999-2002 / released under the GNU General Public License
+ * Copyright (c) 1999-2007 / released under the GNU General Public License
*/
/*
CtdlDirectoryInit();
/* We want *all* vCards in this room */
- CtdlForEachMessage(MSGS_ALL, 0, "text/x-vcard",
+ CtdlForEachMessage(MSGS_ALL, 0, NULL, "text/x-vcard",
NULL, vcard_add_to_directory, NULL);
getroom(&CC->room, hold_rm); /* return to saved room */
+/*
+ * See if there is a name / screen name / friendly name in a vCard to use for outbound
+ * Internet messages. If there is, stick it in the buffer.
+ */
+void extract_friendly_name(char *namebuf, size_t namebuf_len, struct vCard *v)
+{
+ char *s;
+
+ s = vcard_get_prop(v, "fn", 0, 0, 0);
+ if (s == NULL) {
+ s = vcard_get_prop(v, "n", 0, 0, 0);
+ }
+
+ if (s != NULL) {
+ safestrncpy(namebuf, s, namebuf_len);
+ }
+}
+
+
+
/*
* This handler detects whether the user is attempting to save a new
* vCard as part of his/her personal configuration, and handles the replace
* want to make sure there is absolutely only one
* vCard in the user's config room at all times.
*/
- CtdlDeleteMessages(CC->room.QRname,
- NULL, 0, "text/x-vcard", 1);
+ CtdlDeleteMessages(CC->room.QRname, NULL, 0, "text/x-vcard");
/* Make the author of the message the name of the user.
*/
/* Store our Internet return address in memory */
v = vcard_load(msg->cm_fields['M']);
- extract_primary_inet_email(CC->cs_inet_email,
- sizeof CC->cs_inet_email, v);
+ extract_primary_inet_email(CC->cs_inet_email, sizeof CC->cs_inet_email, v);
+ extract_friendly_name(CC->cs_inet_fn, sizeof CC->cs_inet_fn, v);
vcard_free(v);
/* Put it in the Global Address Book room... */
struct vCard *vcard_get_user(struct ctdluser *u) {
char hold_rm[ROOMNAMELEN];
char config_rm[ROOMNAMELEN];
- struct CtdlMessage *msg;
+ struct CtdlMessage *msg = NULL;
struct vCard *v;
long VCmsgnum;
/* We want the last (and probably only) vcard in this room */
VCmsgnum = (-1);
- CtdlForEachMessage(MSGS_LAST, 1, "text/x-vcard",
+ CtdlForEachMessage(MSGS_LAST, 1, NULL, "text/x-vcard",
NULL, vcard_gu_backend, (void *)&VCmsgnum );
getroom(&CC->room, hold_rm); /* return to saved room */
+/*
+ * Get Valid Screen Names
+ */
+void cmd_gvsn(char *argbuf)
+{
+ if (CtdlAccessCheck(ac_logged_in)) return;
+
+ cprintf("%d valid screen names:\n", LISTING_FOLLOWS);
+ cprintf("%s\n", CC->user.fullname);
+ if ( (strlen(CC->cs_inet_fn) > 0) && (strcasecmp(CC->user.fullname, CC->cs_inet_fn)) ) {
+ cprintf("%s\n", CC->cs_inet_fn);
+ }
+ cprintf("000\n");
+}
+
+
/*
* Query Directory
*/
* Query Directory, in fact an alias to match postfix tcp auth.
*/
void check_get(void) {
- char citadel_addr[256];
char internet_addr[256];
char cmdbuf[SIZ];
if (strcasecmp(cmdbuf, "GET "));
{
-
+ struct recptypes *rcpt;
char *argbuf = &cmdbuf[4];
- //// if (CtdlAccessCheck(ac_logged_in)) return;
extract_token(internet_addr, argbuf, 0, '|', sizeof internet_addr);
-
- if (CtdlDirectoryLookup(citadel_addr, internet_addr, sizeof citadel_addr) != 0) {
- cprintf("500 %s was not found.\r\n",
- internet_addr);
+ rcpt = validate_recipients(internet_addr);
+ if ((rcpt != NULL)&&
+ (
+ (*rcpt->recp_local != '\0')||
+ (*rcpt->recp_room != '\0')||
+ (*rcpt->recp_ignet != '\0')))
+ {
+
+ cprintf("200 OK %s\n", internet_addr);
+ lprintf(CTDL_INFO, "sending 200 OK for the room %s\n", rcpt->display_recp);
+ }
+ else
+ {
+ cprintf("500 REJECT noone here by that name.\n");
+ lprintf(CTDL_INFO, "sending 500 REJECT noone here by that name: %s\n", internet_addr);
}
-
- else cprintf("200 OK %s\r\n", internet_addr);//,citadel_addr);
+ if (rcpt != NULL) free (rcpt);
}
- CC->kill_me = 1;
+/// CC->kill_me = 1;
}
void check_get_greeting(void) {
* When a user logs in...
*/
void vcard_session_login_hook(void) {
- struct vCard *v;
+ struct vCard *v = NULL;
v = vcard_get_user(&CC->user);
- extract_primary_inet_email(CC->cs_inet_email,
- sizeof CC->cs_inet_email, v);
+ extract_primary_inet_email(CC->cs_inet_email, sizeof CC->cs_inet_email, v);
+ extract_friendly_name(CC->cs_inet_fn, sizeof CC->cs_inet_fn, v);
vcard_free(v);
vcard_create_room();
*/
void strip_addresses_already_have(long msgnum, void *userdata) {
char *collected_addresses;
- struct CtdlMessage *msg;
+ struct CtdlMessage *msg = NULL;
struct vCard *v;
char *value = NULL;
int i, j;
/* First remove any addresses we already have in the address book */
usergoto(aptr->roomname, 0, 0, NULL, NULL);
- CtdlForEachMessage(MSGS_ALL, 0, "text/x-vcard", NULL,
+ CtdlForEachMessage(MSGS_ALL, 0, NULL, "text/x-vcard", NULL,
strip_addresses_already_have, aptr->collected_addresses);
if (strlen(aptr->collected_addresses) > 0)
}
+char *serv_postfix_tcpdict(void)
+{
+ CtdlRegisterServiceHook(config.c_pftcpdict_port, /* Postfix */
+ NULL,
+ check_get_greeting,
+ check_get,
+ NULL);
+ return "$Id$";
+}
+
+
char *serv_vcard_init(void)
{
CtdlRegisterProtoHook(cmd_igab, "IGAB",
"Initialize Global Address Book");
CtdlRegisterProtoHook(cmd_qdir, "QDIR", "Query Directory");
+ CtdlRegisterProtoHook(cmd_gvsn, "GVSN", "Get Valid Screen Names");
CtdlRegisterUserHook(vcard_newuser, EVT_NEWUSER);
CtdlRegisterUserHook(vcard_purge, EVT_PURGEUSER);
CtdlRegisterNetprocHook(vcard_extract_from_network);
return "$Id$";
}
-
-
-char *serv_postfix_tcpdict(void)
-{
- CtdlRegisterServiceHook(config.c_pftcpdict_port, /* Postfix */
- NULL,
- check_get_greeting,
- check_get,
- NULL);
- return "$Id$";
-}