/*
* Server functions which perform operations on room objects.
*
- * Copyright (c) 1987-2012 by the citadel.org team
+ * Copyright (c) 1987-2015 by the citadel.org team
*
* This program is open source software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 3.
* GNU General Public License for more details.
*/
-#include "sysdep.h"
-#include <stdlib.h>
-#include <unistd.h>
#include <stdio.h>
-#include <sys/stat.h>
-#include <ctype.h>
-#include <string.h>
-#include <dirent.h> /* for cmd_rdir to read contents of the directory */
-
-#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"
#include <libcitadel.h>
-#include "server.h"
-#include "database.h"
-#include "config.h"
-#include "room_ops.h"
-#include "sysdep_decls.h"
-#include "support.h"
-#include "msgbase.h"
+
#include "citserver.h"
-#include "control.h"
-#include "citadel_dirs.h"
-#include "threads.h"
#include "ctdl_module.h"
+#include "config.h"
+#include "control.h"
#include "user_ops.h"
+#include "room_ops.h"
struct floor *floorcache[MAXFLOORS];
int CtdlDoIHavePermissionToReadMessagesInThisRoom(void) {
if ( (!(CC->logged_in))
&& (!(CC->internal_pgm))
- && (!config.c_guest_logins)
+ && (!CtdlGetConfigInt("c_guest_logins"))
) {
return(om_not_logged_in);
}
is_me = 1;
}
- if ((is_me) && (config.c_guest_logins) && (!CC->logged_in)) {
+ if ((is_me) && (CtdlGetConfigInt("c_guest_logins")) && (!CC->logged_in)) {
is_guest = 1;
}
}
/* Force the properties of the Aide room */
- if (!strcasecmp(roombuf->QRname, config.c_aideroom)) {
+ if (!strcasecmp(roombuf->QRname, CtdlGetConfigStr("c_aideroom"))) {
if (userbuf->axlevel >= AxAideU) {
retval = UA_KNOWN | UA_GOTOALLOWED | UA_POSTALLOWED | UA_DELETEALLOWED | UA_REPLYALLOWED;
} else {
/* Listing order of 0 is illegal except for base rooms */
if (qrbuf->QRorder == 0)
if (!(qrbuf->QRflags & QR_MAILBOX) &&
- strncasecmp(qrbuf->QRname, config.c_baseroom, ROOMNAMELEN)
+ strncasecmp(qrbuf->QRname, CtdlGetConfigStr("c_baseroom"), ROOMNAMELEN)
&&
- strncasecmp(qrbuf->QRname, config.c_aideroom, ROOMNAMELEN))
+ strncasecmp(qrbuf->QRname, CtdlGetConfigStr("c_aideroom"), ROOMNAMELEN))
qrbuf->QRorder = 64;
}
/*
* CtdlGetRoomLock() - same as getroom() but locks the record (if supported)
*/
-int CtdlGetRoomLock(struct ctdlroom *qrbuf, char *room_name)
+int CtdlGetRoomLock(struct ctdlroom *qrbuf, const char *room_name)
{
register int retval;
retval = CtdlGetRoom(qrbuf, room_name);
* specified room exists and is ok to access.
*/
void CtdlUserGoto(char *where, int display_result, int transiently,
- int *retmsgs, int *retnew)
+ int *retmsgs, int *retnew, long *retoldest, long *retnewest)
{
struct CitContext *CCC = CC;
int a;
int new_messages = 0;
int old_messages = 0;
int total_messages = 0;
+ long oldest_message = 0;
+ long newest_message = 0;
int info = 0;
int rmailflag;
int raideflag;
/* Know the room ... but not if it's the page log room, or if the
* caller specified that we're only entering this room transiently.
*/
- if ((strcasecmp(CCC->room.QRname, config.c_logpages))
- && (transiently == 0) ) {
+ if ((strcasecmp(CCC->room.QRname, CtdlGetConfigStr("c_logpages"))) && (transiently == 0))
+ {
vbuf.v_flags = vbuf.v_flags & ~V_FORGET & ~V_LOCKOUT;
vbuf.v_flags = vbuf.v_flags | V_ACCESS;
}
if (msglist[a] > 0L) ++total_messages;
}
+ if (total_messages > 0) {
+ oldest_message = msglist[0];
+ newest_message = msglist[num_msgs - 1];
+ }
+
num_sets = num_tokens(vbuf.v_seen, ',');
for (s=0; s<num_sets; ++s) {
extract_token(setstr, vbuf.v_seen, s, ',', sizeof setstr);
if (retmsgs != NULL) *retmsgs = total_messages;
if (retnew != NULL) *retnew = new_messages;
- MSG_syslog(LOG_INFO, "<%s> %d new of %d total messages\n",
- CCC->room.QRname,
- new_messages, total_messages
- );
+ if (retoldest != NULL) *retoldest = oldest_message;
+ if (retnewest != NULL) *retnewest = newest_message;
+ MSG_syslog(LOG_INFO, "<%s> %d new of %d total messages, oldest=%ld, newest=%ld\n",
+ CCC->room.QRname, new_messages, total_messages, oldest_message, newest_message
+ );
CCC->curr_view = (int)vbuf.v_view;
*/
void convert_room_name_macros(char *towhere, size_t maxlen) {
if (!strcasecmp(towhere, "_BASEROOM_")) {
- safestrncpy(towhere, config.c_baseroom, maxlen);
+ safestrncpy(towhere, CtdlGetConfigStr("c_baseroom"), maxlen);
}
else if (!strcasecmp(towhere, "_MAIL_")) {
safestrncpy(towhere, MAILROOM, maxlen);
safestrncpy(towhere, USERDRAFTROOM, maxlen);
}
else if (!strcasecmp(towhere, "_BITBUCKET_")) {
- safestrncpy(towhere, config.c_twitroom, maxlen);
+ safestrncpy(towhere, CtdlGetConfigStr("c_twitroom"), maxlen);
}
else if (!strcasecmp(towhere, "_CALENDAR_")) {
safestrncpy(towhere, USERCALENDARROOM, maxlen);
}
/* Reject change of floor for baseroom/aideroom */
- if (!strncasecmp(old_name, config.c_baseroom, ROOMNAMELEN) ||
- !strncasecmp(old_name, config.c_aideroom, ROOMNAMELEN)) {
+ if (!strncasecmp(old_name, CtdlGetConfigStr("c_baseroom"), ROOMNAMELEN) ||
+ !strncasecmp(old_name, CtdlGetConfigStr("c_aideroom"), ROOMNAMELEN)) {
new_floor = 0;
}
begin_critical_section(S_CONFIG);
/* If baseroom/aideroom name changes, update config */
- if (!strncasecmp(old_name, config.c_baseroom, ROOMNAMELEN)) {
- safestrncpy(config.c_baseroom, new_name, ROOMNAMELEN);
- put_config();
+ if (!strncasecmp(old_name, CtdlGetConfigStr("c_baseroom"), ROOMNAMELEN)) {
+ CtdlSetConfigStr("c_baseroom", new_name);
}
- if (!strncasecmp(old_name, config.c_aideroom, ROOMNAMELEN)) {
- safestrncpy(config.c_aideroom, new_name, ROOMNAMELEN);
- put_config();
+ if (!strncasecmp(old_name, CtdlGetConfigStr("c_aideroom"), ROOMNAMELEN)) {
+ CtdlSetConfigStr("c_aideroom", new_name);
}
end_critical_section(S_CONFIG);