- added a new function to the database interface, cdb_close_cursor(). always
[citadel.git] / citadel / room_ops.c
index 4cfeae3125a8a7bc6cac3f3d974f4d1934962b85..51b8cf4c081da7fcb352eee4f716be68362698ce 100644 (file)
 #include <stdio.h>
 #include <sys/stat.h>
 #include <string.h>
-#include <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 <limits.h>
 #include <errno.h>
 #include "citadel.h"
@@ -113,7 +124,7 @@ int CtdlRoomAccess(struct quickroom *roombuf, struct usersupp *userbuf)
        }
 
 NEWMSG:        /* By the way, we also check for the presence of new messages */
-       if ((roombuf->QRhighest) > (vbuf.v_lastseen)) {
+       if (is_msg_in_mset(vbuf.v_seen, roombuf->QRhighest) == 0) {
                retval = retval | UA_HASNEWMSGS;
        }
        return (retval);
@@ -343,7 +354,6 @@ void ForEachRoom(void (*CallBack) (struct quickroom *EachRoom, void *out_data),
        struct quickroom qrbuf;
        struct cdbdata *cdbqr;
 
-       cdb_begin_transaction();
        cdb_rewind(CDB_QUICKROOM);
 
        while (cdbqr = cdb_next_item(CDB_QUICKROOM), cdbqr != NULL) {
@@ -356,7 +366,6 @@ void ForEachRoom(void (*CallBack) (struct quickroom *EachRoom, void *out_data),
                if (qrbuf.QRflags & QR_INUSE)
                        (*CallBack)(&qrbuf, in_data);
        }
-       cdb_end_transaction();
 }
 
 
@@ -698,7 +707,7 @@ void usergoto(char *where, int display_result, int *retmsgs, int *retnew)
        if (num_msgs > 0) for (a = 0; a < num_msgs; ++a) {
                if (msglist[a] > 0L) {
                        ++total_messages;
-                       if (msglist[a] > vbuf.v_lastseen) {
+                       if (is_msg_in_mset(vbuf.v_seen, msglist[a]) == 0) {
                                ++new_messages;
                        }
                }
@@ -830,7 +839,6 @@ void cmd_whok(void)
        struct usersupp temp;
        struct cdbdata *cdbus;
 
-       cdb_begin_transaction();
        getuser(&CC->usersupp, CC->curr_user);
        if (CtdlAccessCheck(ac_room_aide)) return;
 
@@ -846,7 +854,6 @@ void cmd_whok(void)
                    )
                        cprintf("%s\n", temp.fullname);
        }
-       cdb_end_transaction();
        cprintf("000\n");
 }
 
@@ -1326,11 +1333,6 @@ unsigned create_room(char *new_room_name,
         */
        if (!really_create) return (qrbuf.QRflags);
 
-       /* cdb_begin_transaction();  commented out because a transaction
-          is already open when creating __CtdlSMTPspoolout__ while
-          initializing serv_smtp.c
-        */
-
        qrbuf.QRnumber = get_new_room_number();
        qrbuf.QRhighest = 0L;   /* No messages in this room yet */
        time(&qrbuf.QRgen);     /* Use a timestamp as the generation number */
@@ -1353,7 +1355,6 @@ unsigned create_room(char *new_room_name,
        lputuser(&CC->usersupp);
 
        /* resume our happy day */
-       /* cdb_end_transaction(); */
        return (qrbuf.QRflags);
 }