]> code.citadel.org Git - citadel.git/blobdiff - citadel/user_ops.c
* When sending mail, copy to the sender's "Sent Items>" room instead of to
[citadel.git] / citadel / user_ops.c
index cbc39e68b6d87f8bdcc254df784e8de3236cca29..f154425078d9b29f2ec4bec8c1b8ea9eb5e1228a 100644 (file)
@@ -5,6 +5,10 @@
  *
  */
 
+#ifdef DLL_EXPORT
+#define IN_LIBCIT
+#endif
+
 #include "sysdep.h"
 #include <errno.h>
 #include <stdlib.h>
 #include <pwd.h>
 #include <sys/types.h>
 #include <sys/wait.h>
-#include <sys/time.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 <string.h>
 #include <syslog.h>
 #include <limits.h>
@@ -26,6 +41,7 @@
 #include "server.h"
 #include "database.h"
 #include "user_ops.h"
+#include "dynloader.h"
 #include "sysdep_decls.h"
 #include "support.h"
 #include "room_ops.h"
@@ -34,7 +50,6 @@
 #include "control.h"
 #include "msgbase.h"
 #include "config.h"
-#include "dynloader.h"
 #include "tools.h"
 #include "citserver.h"
 
@@ -269,7 +284,6 @@ int getuserbynumber(struct usersupp *usbuf, long int number)
 {
        struct cdbdata *cdbus;
 
-       cdb_begin_transaction();
        cdb_rewind(CDB_USERSUPP);
 
        while (cdbus = cdb_next_item(CDB_USERSUPP), cdbus != NULL) {
@@ -279,11 +293,10 @@ int getuserbynumber(struct usersupp *usbuf, long int number)
                        sizeof(struct usersupp) : cdbus->len));
                cdb_free(cdbus);
                if (usbuf->usernum == number) {
-                       cdb_end_transaction();
+                       cdb_close_cursor(CDB_USERSUPP);
                        return (0);
                }
        }
-       cdb_end_transaction();
        return (-1);
 }
 
@@ -387,17 +400,23 @@ void session_startup(void)
        }
        lputuser(&CC->usersupp);
 
-       /* Run any cleanup routines registered by loadable modules */
+       /* Run any startup routines registered by loadable modules */
        PerformSessionHooks(EVT_LOGIN);
 
-       usergoto(BASEROOM, 0, NULL, NULL);      /* Enter the lobby */
+       /* Create any personal rooms required by the system */
+       create_room(SENTITEMS, 4, "", 0, 1);
+
+       /* Enter the lobby */
+       usergoto(BASEROOM, 0, NULL, NULL);
+
+       /* Record this login in the Citadel log */
        rec_log(CL_LOGIN, CC->curr_user);
 }
 
 
 void logged_in_response(void)
 {
-       cprintf("%d %s|%d|%d|%d|%u|%ld\n",
+       cprintf("%d %s|%d|%ld|%ld|%u|%ld\n",
                OK, CC->usersupp.fullname, CC->usersupp.axlevel,
                CC->usersupp.timescalled, CC->usersupp.posted,
                CC->usersupp.flags,
@@ -412,13 +431,29 @@ void logged_in_response(void)
 void logout(struct CitContext *who)
 {
        who->logged_in = 0;
+
+       /*
+        * If there is a download in progress, abort it.
+        */
        if (who->download_fp != NULL) {
                fclose(who->download_fp);
                who->download_fp = NULL;
        }
+
+       /*
+        * If there is an upload in progress, abort it.
+        */
        if (who->upload_fp != NULL) {
                abort_upl(who);
        }
+
+       /*
+        * If we were talking to a network node, we're not anymore...
+        */
+       if (strlen(who->net_node) > 0) {
+               network_talking_to(who->net_node, NTT_REMOVE);
+       }
+
        /* Do modular stuff... */
        PerformSessionHooks(EVT_LOGOUT);
 }
@@ -721,7 +756,7 @@ void cmd_newu(char *cmdbuf)
        if ((!strcasecmp(username, "bbs")) ||
            (!strcasecmp(username, "new")) ||
            (!strcasecmp(username, "."))) {
-               cprintf("%d '%s' is an invalid login name.\n", ERROR);
+               cprintf("%d '%s' is an invalid login name.\n", ERROR, username);
                return;
        }
        if (a == ERROR + ALREADY_EXISTS) {
@@ -861,6 +896,27 @@ void cmd_slrp(char *new_ptr)
 }
 
 
+void cmd_seen(char *argbuf) {
+       long target_msgnum = 0L;
+       int target_setting = 0;
+
+       if (CtdlAccessCheck(ac_logged_in)) {
+               return;
+       }
+
+       if (num_parms(argbuf) != 2) {
+               cprintf("%d Invalid parameters\n", ERROR);
+               return;
+       }
+
+       target_msgnum = extract_long(argbuf, 0);
+       target_setting = extract_int(argbuf, 1);
+
+       CtdlSetSeen(target_msgnum, target_setting);
+       cprintf("%d OK\n", OK);
+}
+
+
 /*
  * INVT and KICK commands
  */
@@ -974,7 +1030,6 @@ void cmd_gnur(void)
        /* There are unvalidated users.  Traverse the usersupp database,
         * and return the first user we find that needs validation.
         */
-       cdb_begin_transaction();
        cdb_rewind(CDB_USERSUPP);
        while (cdbus = cdb_next_item(CDB_USERSUPP), cdbus != NULL) {
                memset(&usbuf, 0, sizeof(struct usersupp));
@@ -985,11 +1040,10 @@ void cmd_gnur(void)
                if ((usbuf.flags & US_NEEDVALID)
                    && (usbuf.axlevel > 0)) {
                        cprintf("%d %s\n", MORE_DATA, usbuf.fullname);
-                       cdb_end_transaction();
+                       cdb_close_cursor(CDB_USERSUPP);
                        return;
                }
        }
-       cdb_end_transaction();
 
        /* If we get to this point, there are no more unvalidated users.
         * Therefore we clear the "users need validation" flag.
@@ -1053,7 +1107,6 @@ void ForEachUser(void (*CallBack) (struct usersupp * EachUser, void *out_data),
        struct usersupp usbuf;
        struct cdbdata *cdbus;
 
-       cdb_begin_transaction();
        cdb_rewind(CDB_USERSUPP);
 
        while (cdbus = cdb_next_item(CDB_USERSUPP), cdbus != NULL) {
@@ -1064,7 +1117,6 @@ void ForEachUser(void (*CallBack) (struct usersupp * EachUser, void *out_data),
                cdb_free(cdbus);
                (*CallBack) (&usbuf, in_data);
        }
-       cdb_end_transaction();
 }
 
 
@@ -1077,11 +1129,11 @@ void ListThisUser(struct usersupp *usbuf, void *data)
                if ((CC->usersupp.axlevel >= 6)
                    || ((usbuf->flags & US_UNLISTED) == 0)
                    || ((CC->internal_pgm))) {
-                       cprintf("%s|%d|%ld|%ld|%d|%d|",
+                       cprintf("%s|%d|%ld|%ld|%ld|%ld|",
                                usbuf->fullname,
                                usbuf->axlevel,
                                usbuf->usernum,
-                               usbuf->lastcall,
+                               (long)usbuf->lastcall,
                                usbuf->timescalled,
                                usbuf->posted);
                        if (CC->usersupp.axlevel >= 6)
@@ -1166,7 +1218,7 @@ void cmd_agup(char *cmdbuf)
                cprintf("%d No such user.\n", ERROR + NO_SUCH_USER);
                return;
        }
-       cprintf("%d %s|%s|%u|%d|%d|%d|%ld|%ld|%d\n",
+       cprintf("%d %s|%s|%u|%ld|%ld|%d|%ld|%ld|%d\n",
                OK,
                usbuf.fullname,
                usbuf.password,
@@ -1175,7 +1227,7 @@ void cmd_agup(char *cmdbuf)
                usbuf.posted,
                (int) usbuf.axlevel,
                usbuf.usernum,
-               usbuf.lastcall,
+               (long)usbuf.lastcall,
                usbuf.USuserpurge);
 }