* Minor updates for directory service
authorArt Cancro <ajc@citadel.org>
Thu, 10 Jan 2002 04:29:28 +0000 (04:29 +0000)
committerArt Cancro <ajc@citadel.org>
Thu, 10 Jan 2002 04:29:28 +0000 (04:29 +0000)
citadel/ChangeLog
citadel/database.c
citadel/serv_vcard.c
citadel/server.h

index a420d530f711299a84914734f68b4205b70f9f00..97543b6b9d634c71b48d5b6d0838d1e2a451aec0 100644 (file)
@@ -1,4 +1,7 @@
  $Log$
+ Revision 590.52  2002/01/10 04:29:28  ajc
+ * Minor updates for directory service
+
  Revision 590.51  2002/01/09 23:12:40  ajc
  * Allow users to zap mailbox rooms
 
@@ -3121,4 +3124,3 @@ 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 c9e4264bc4c5c97386ee24c11a7f724230293fcc..f4050722aee171b2dff9cdf8a59e369159bffc72 100644 (file)
@@ -95,6 +95,12 @@ void defrag_databases(void)
        gdbm_reorganize(gdbms[CDB_FLOORTAB]);
        end_critical_section(S_DATABASE);
        end_critical_section(S_FLOORTAB);
+
+       /* defrag the directory */
+       lprintf(7, "Defragmenting the directory\n");
+       begin_critical_section(S_DIRECTORY);
+       gdbm_reorganize(gdbms[CDB_DIRECTORY]);
+       end_critical_section(S_DIRECTORY);
 }
 
 
@@ -161,6 +167,13 @@ void open_databases(void)
                        gdbm_strerror(gdbm_errno));
                exit(1);
        }
+       gdbms[CDB_DIRECTORY] = gdbm_open("data/directory.gdbm", 0,
+                                       GDBM_WRCREAT, 0600, NULL);
+       if (gdbms[CDB_DIRECTORY] == NULL) {
+               lprintf(2, "Cannot open directory: %s\n",
+                       gdbm_strerror(gdbm_errno));
+               exit(1);
+       }
        /*
           end_critical_section(S_DATABASE);
         */
index d3c571d2c4c1f4c711cdd43e1e9c40ba0854d562..c577aaa385f31334bc108e1730e8d70f9a1daf77 100644 (file)
@@ -114,7 +114,7 @@ void vcard_extract_internet_addresses(struct CtdlMessage *msg,
  * Back end function for cmd_igab()
  * FIXME use a callback that actually writes to the database, dumbass...
  */
-void vcard_igab_backend(long msgnum, void *data) {
+void vcard_add_to_directory(long msgnum, void *data) {
        struct CtdlMessage *msg;
 
        msg = CtdlFetchMessage(msgnum);
@@ -152,7 +152,7 @@ void cmd_igab(char *argbuf) {
 
         /* We want the last (and probably only) vcard in this room */
         CtdlForEachMessage(MSGS_ALL, 0, (-127), "text/x-vcard",
-               NULL, vcard_igab_backend, NULL);
+               NULL, vcard_add_to_directory, NULL);
 
         getroom(&CC->quickroom, hold_rm);      /* return to saved room */
        cprintf("000\n");
@@ -264,9 +264,13 @@ int vcard_upload_aftersave(struct CtdlMessage *msg) {
                        I = atol(msg->cm_fields['I']);
                        if (I < 0L) return(0);
 
+                       /* Put it in the Global Address Book room... */
                        CtdlSaveMsgPointerInRoom(ADDRESS_BOOK_ROOM, I,
                                (SM_VERIFY_GOODNESS | SM_DO_REPL_CHECK) );
 
+                       /* ...and also in the directory database. */
+                       vcard_add_to_directory(I, NULL);
+
                        return(0);
                }
 
index 1a1655ae684718e32de04089affd8cc1bb20c197..86fcf4e386d86e409e1236fc6eb8e91c97259957 100644 (file)
@@ -205,6 +205,7 @@ enum {
        S_WORKER_LIST,
        S_HOUSEKEEPING,
        S_NTTLIST,
+       S_DIRECTORY,
        MAX_SEMAPHORES
 };
 
@@ -245,6 +246,7 @@ enum {
        CDB_FLOORTAB,           /* floor index                   */
        CDB_MSGLISTS,           /* room message lists            */
        CDB_VISIT,              /* user/room relationships       */
+       CDB_DIRECTORY,          /* address book directory        */
        MAXCDB                  /* total number of CDB's defined */
 };