$Log$
+Revision 655.1 2005/09/14 03:48:32 ajc
+* Bumped internal version number to 5.66
+* Checked in an initial but incomplete version of the AUTO command
+ (to be used for address autocompletion)
+
Revision 655.0 2005/09/13 14:00:12 ajc
* THIS IS 6.55
Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
* Initial CVS import
+
serv_vandelay.o \
serv_calendar.o \
ical_dezonify.o \
- serv_ldap.o
+ serv_ldap.o \
+ serv_autocompletion.o
UTIL_TARGETS=aidepost msgform \
citmail userlist sendcommand \
domain.c serv_extensions.c file_ops.c genstamp.c getutline.c \
housekeeping.c html.c ical_dezonify.c imap_fetch.c imap_misc.c \
imap_search.c imap_store.c imap_tools.c internet_addressing.c \
- ipc_c_tcp.c locate_host.c md5.c messages.c \
+ ipc_c_tcp.c locate_host.c md5.c messages.c serv_autocompletion.c \
mime_parser.c msgbase.c msgform.c parsedate.c policy.c \
room_ops.c rooms.c routines.c routines2.c \
screen.c sendcommand.c serv_bio.c serv_calendar.c serv_chat.c \
* usually more strict because you're not really supposed to dump/load and
* upgrade at the same time.
*/
-#define REV_LEVEL 655 /* This version */
+#define REV_LEVEL 656 /* This version */
#define REV_MIN 591 /* Oldest compatible database */
#define EXPORT_REV_MIN 655 /* Oldest compatible export files */
--- /dev/null
+/*
+ * $Id$
+ *
+ * Autocompletion of email recipients, etc.
+ */
+
+#ifdef DLL_EXPORT
+#define IN_LIBCIT
+#endif
+
+#include "sysdep.h"
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <ctype.h>
+#include <signal.h>
+#include <pwd.h>
+#include <errno.h>
+#include <sys/types.h>
+
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# if HAVE_SYS_TIME_H
+# include <sys/time.h>
+# else
+# include <time.h>
+# endif
+#endif
+
+#include <sys/wait.h>
+#include <string.h>
+#include <limits.h>
+#include "citadel.h"
+#include "server.h"
+#include "serv_extensions.h"
+#include "sysdep_decls.h"
+#include "citserver.h"
+#include "support.h"
+#include "config.h"
+#include "tools.h"
+#include "msgbase.h"
+#include "user_ops.h"
+#include "room_ops.h"
+#include "database.h"
+#include "vcard.h"
+#include "serv_autocompletion.h"
+
+
+#ifndef HAVE_SNPRINTF
+#include "snprintf.h"
+#endif
+
+
+/*
+ * Back end for cmd_auto()
+ */
+void hunt_for_autocomplete(long msgnum, void *data) {
+ char *search_string;
+ struct CtdlMessage *msg;
+ struct vCard *v;
+
+ search_string = (char *) data;
+
+ msg = CtdlFetchMessage(msgnum, 1);
+ if (msg == NULL) return;
+
+ v = vcard_load(msg->cm_fields['M']);
+ CtdlFreeMessage(msg);
+
+ /*
+ * Try to match from a display name or something like that
+ */
+ if (
+ (bmstrcasestr(vcard_get_prop(v, "n", 0, 0, 0), search_string))
+ ) {
+ cprintf("%s\n", vcard_get_prop(v, "email", 1, 0, 0));
+ }
+
+ vcard_free(v);
+}
+
+
+
+/*
+ * Attempt to autocomplete an address based on a partial...
+ */
+void cmd_auto(char *argbuf) {
+ char hold_rm[ROOMNAMELEN];
+ char search_string[256];
+
+ if (CtdlAccessCheck(ac_logged_in)) return;
+ extract_token(search_string, argbuf, 0, '|', sizeof search_string);
+ if (strlen(search_string) == 0) {
+ cprintf("%d You supplied an empty partial.\n", ERROR + ILLEGAL_VALUE);
+ return;
+ }
+
+ strcpy(hold_rm, CC->room.QRname); /* save current room */
+
+ if (getroom(&CC->room, USERCONTACTSROOM) != 0) {
+ getroom(&CC->room, hold_rm);
+ lprintf(CTDL_CRIT, "cannot get user contacts room\n");
+ cprintf("%d Your address book was not found.\n", ERROR + ROOM_NOT_FOUND);
+ return;
+ }
+
+ cprintf("%d try these:\n", LISTING_FOLLOWS);
+ CtdlForEachMessage(MSGS_ALL, 0, "text/x-vcard", NULL, hunt_for_autocomplete, search_string);
+ cprintf("000\n");
+
+ getroom(&CC->room, hold_rm); /* return to saved room */
+}
+
+
+char *serv_autocompletion_init(void)
+{
+ CtdlRegisterProtoHook(cmd_auto, "AUTO", "Perform recipient autocompletion");
+ return "$Id$";
+}
--- /dev/null
+/*
+ * $Id$
+ *
+ */
+
+
+char *serv_autocompletion_init(void);
void initialize_server_extensions(void)
{
- serv_bio_init();
- serv_calendar_init();
- serv_notes_init();
- serv_ldap_init();
- serv_chat_init();
- serv_expire_init();
- serv_imap_init();
- serv_inetcfg_init();
- serv_listsub_init();
- serv_mrtg_init();
- serv_netfilter_init();
- serv_network_init();
- serv_newuser_init();
- serv_pas2_init();
- serv_pop3_init();
- serv_rwho_init();
- serv_smtp_init();
- serv_spam_init();
- /* serv_test_init(); */
- serv_upgrade_init();
- serv_vandelay_init();
- serv_vcard_init();
- serv_fulltext_init();
+ lprintf(CTDL_INFO, "%s\n", serv_bio_init());
+ lprintf(CTDL_INFO, "%s\n", serv_calendar_init());
+ lprintf(CTDL_INFO, "%s\n", serv_notes_init());
+ lprintf(CTDL_INFO, "%s\n", serv_ldap_init());
+ lprintf(CTDL_INFO, "%s\n", serv_chat_init());
+ lprintf(CTDL_INFO, "%s\n", serv_expire_init());
+ lprintf(CTDL_INFO, "%s\n", serv_imap_init());
+ lprintf(CTDL_INFO, "%s\n", serv_inetcfg_init());
+ lprintf(CTDL_INFO, "%s\n", serv_listsub_init());
+ lprintf(CTDL_INFO, "%s\n", serv_mrtg_init());
+ lprintf(CTDL_INFO, "%s\n", serv_netfilter_init());
+ lprintf(CTDL_INFO, "%s\n", serv_network_init());
+ lprintf(CTDL_INFO, "%s\n", serv_newuser_init());
+ lprintf(CTDL_INFO, "%s\n", serv_pas2_init());
+ lprintf(CTDL_INFO, "%s\n", serv_pop3_init());
+ lprintf(CTDL_INFO, "%s\n", serv_rwho_init());
+ lprintf(CTDL_INFO, "%s\n", serv_smtp_init());
+ lprintf(CTDL_INFO, "%s\n", serv_spam_init());
+ /* lprintf(CTDL_INFO, "%s\n", serv_test_init()); */
+ lprintf(CTDL_INFO, "%s\n", serv_upgrade_init());
+ lprintf(CTDL_INFO, "%s\n", serv_vandelay_init());
+ lprintf(CTDL_INFO, "%s\n", serv_vcard_init());
+ lprintf(CTDL_INFO, "%s\n", serv_fulltext_init());
+ lprintf(CTDL_INFO, "%s\n", serv_autocompletion_init());
}
char *serv_vandelay_init(void);
char *serv_vcard_init(void);
char *serv_fulltext_init(void);
+char *serv_autocompletion_init(void);
/*
*/
+ AUTO (AUTOcompletion of email addresses)
+
+ The AUTO command is used by clients which want to request a list of email
+recipients whose names or email addresses match a partial string supplied by
+the client. This string is the only parameter passed to this command. The
+command will return ERROR if no user is logged in or if no address book could
+be found; otherwise, it returns LISTING_FOLLOWS followed by zero or more
+candidate recipients.
+
+
+
SRCH (SeaRCH the message base)
This command's implementation is incomplete and will be documented when it