* Bumped internal version number to 5.66
authorArt Cancro <ajc@citadel.org>
Wed, 14 Sep 2005 03:48:33 +0000 (03:48 +0000)
committerArt Cancro <ajc@citadel.org>
Wed, 14 Sep 2005 03:48:33 +0000 (03:48 +0000)
* Checked in an initial but incomplete version of the AUTO command
  (to be used for address autocompletion)

citadel/ChangeLog
citadel/Makefile.in
citadel/citadel.h
citadel/serv_autocompletion.c [new file with mode: 0644]
citadel/serv_autocompletion.h [new file with mode: 0644]
citadel/serv_extensions.c
citadel/serv_extensions.h
citadel/techdoc/protocol.txt

index 95b531e347ac25afb9ddb5b90bf29a8ffc3faa03..d0ce07a428cfd80372a7b3ddf383b1241a2cd27b 100644 (file)
@@ -1,4 +1,9 @@
 $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
 
@@ -7105,3 +7110,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 b4f5c1adc8e6226839cccfe1f53975a55a43616f..0be26f9f2278da2ddda408ed0a17bad42bc44dbc 100644 (file)
@@ -50,7 +50,8 @@ SERV_MODULES=serv_chat.o \
        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 \
@@ -90,7 +91,7 @@ SOURCES=aidepost.c auth.c base64.c chkpwd.c citadel.c citadel_ipc.c \
        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 \
index 2a631747ff46df4c8accbb3cb5227a6ec073c97c..78eb2a4cf597b774ad6d2755dd76216b52a7905e 100644 (file)
@@ -45,7 +45,7 @@ extern "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 */
 
diff --git a/citadel/serv_autocompletion.c b/citadel/serv_autocompletion.c
new file mode 100644 (file)
index 0000000..60b3690
--- /dev/null
@@ -0,0 +1,122 @@
+/*
+ * $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$";
+}
diff --git a/citadel/serv_autocompletion.h b/citadel/serv_autocompletion.h
new file mode 100644 (file)
index 0000000..62f5503
--- /dev/null
@@ -0,0 +1,7 @@
+/* 
+ * $Id$
+ *
+ */
+
+
+char *serv_autocompletion_init(void);
index e6922b8cefe8020b7af3bae736cc6081f6323ccc..e5cf68524315533a7c25f154660bee8f915005eb 100644 (file)
@@ -101,29 +101,30 @@ int DLoader_Exec_Cmd(char *cmdbuf)
 
 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());
 }
 
 
index 6f6543ab93a9d1a7fc94d52acc6d04d3b44f678d..a3974ecaed36fafb31ff55ad6e562dd1d094cedb 100644 (file)
@@ -33,6 +33,7 @@ char *serv_upgrade_init(void);
 char *serv_vandelay_init(void);
 char *serv_vcard_init(void);
 char *serv_fulltext_init(void);
+char *serv_autocompletion_init(void);
 /*
  */
 
index 85e6de4dc6479bc5856d8c3094891914e397a449..fac6a6bbe8f65926c1134ee1ce55edf7eb31278b 100644 (file)
@@ -2183,6 +2183,17 @@ asynchronous messages as they arrive, before doing anything else.
 
 
 
+ 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