From 0c8706708324e1c6afdca71ac1228d5682f27a47 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Wed, 23 Nov 2022 16:40:18 -0500 Subject: [PATCH] GOTO no longer counts newly arrived mail in the inbox. BIFF now does this. --- citadel/server/modules/ctdlproto/serv_user.c | 6 ++++++ citadel/server/room_ops.c | 17 +++-------------- citadel/server/user_ops.c | 3 ++- textclient/citadel.c | 8 ++++---- textclient/citadel_ipc.c | 4 ++-- textclient/textclient.h | 1 - webcit/roomops.c | 2 +- webcit/roomops.h | 1 - 8 files changed, 18 insertions(+), 24 deletions(-) diff --git a/citadel/server/modules/ctdlproto/serv_user.c b/citadel/server/modules/ctdlproto/serv_user.c index 3ee1e79bc..aa560ee4d 100644 --- a/citadel/server/modules/ctdlproto/serv_user.c +++ b/citadel/server/modules/ctdlproto/serv_user.c @@ -774,6 +774,11 @@ void cmd_lout(char *argbuf) { } +void cmd_biff(char *argbuf) { // has new mail arrived? + cprintf("%d %d\n", CIT_OK, NewMailCount()); +} + + // Initialization function, called from modules_init.c char *ctdl_module_init_serv_user(void) { if (!threading) { @@ -804,6 +809,7 @@ char *ctdl_module_init_serv_user(void) { CtdlRegisterProtoHook(cmd_renu, "RENU", "Rename a user"); CtdlRegisterProtoHook(cmd_newu, "NEWU", "Log in as a new user"); CtdlRegisterProtoHook(cmd_isme, "ISME", "Determine whether an email address belongs to a user"); + CtdlRegisterProtoHook(cmd_biff, "BIFF", "Count new messages that have arrived in the inbox"); } /* return our Subversion id for the Log */ return "user"; diff --git a/citadel/server/room_ops.c b/citadel/server/room_ops.c index 53090b66c..f9abe8778 100644 --- a/citadel/server/room_ops.c +++ b/citadel/server/room_ops.c @@ -33,12 +33,7 @@ int CtdlDoIHavePermissionToReadMessagesInThisRoom(void) { // Check to see whether we have permission to post a message in the current // room. Returns a *CITADEL ERROR CODE* and puts a message in errmsgbuf, or // returns 0 on success. -int CtdlDoIHavePermissionToPostInThisRoom( - char *errmsgbuf, - size_t n, - PostType PostPublic, - int is_reply -) { +int CtdlDoIHavePermissionToPostInThisRoom(char *errmsgbuf, size_t n, PostType PostPublic, int is_reply) { int ra; if (!(CC->logged_in) && (PostPublic == POST_LOGGED_IN)) { @@ -620,9 +615,7 @@ int CtdlIsNonEditable(struct ctdlroom *qrbuf) { // Make the specified room the current room for this session. No validation // or access control is done here -- the caller should make sure that the // specified room exists and is ok to access. -void CtdlUserGoto(char *where, int display_result, int transiently, - int *retmsgs, int *retnew, long *retoldest, long *retnewest) -{ +void CtdlUserGoto(char *where, int display_result, int transiently, int *retmsgs, int *retnew, long *retoldest, long *retnewest) { int a; int new_messages = 0; int old_messages = 0; @@ -632,7 +625,6 @@ void CtdlUserGoto(char *where, int display_result, int transiently, int info = 0; int rmailflag; int raideflag; - int newmailcount = 0; visit vbuf; char truncated_roomname[ROOMNAMELEN]; struct cdbdata *cdbfr; @@ -680,9 +672,6 @@ void CtdlUserGoto(char *where, int display_result, int transiently, } end_critical_section(S_USERS); - // Check for new mail - newmailcount = NewMailCount(); - // Set info to 1 if the room banner is new since our last visit. // Some clients only want to display it when it changes. if (CC->room.msgnum_info > vbuf.v_lastseen) { @@ -776,7 +765,7 @@ void CtdlUserGoto(char *where, int display_result, int transiently, (long)vbuf.v_lastseen, (int)rmailflag, (int)raideflag, - (int)newmailcount, + 0, // new mail is no longer counted here (int)CC->room.QRfloor, (int)vbuf.v_view, (int)CC->room.QRdefaultview, diff --git a/citadel/server/user_ops.c b/citadel/server/user_ops.c index 62b11981c..d907074a4 100644 --- a/citadel/server/user_ops.c +++ b/citadel/server/user_ops.c @@ -1118,7 +1118,8 @@ void ForEachUser(void (*CallBack) (char *, void *out_data), void *in_data) { } -// Count the number of new mail messages the user has +// Return the number of new messages that have arrived in the user's inbox while they were logged in. +// Resets to zero when called. int NewMailCount() { int num_newmsgs = 0; num_newmsgs = CC->newmail; diff --git a/textclient/citadel.c b/textclient/citadel.c index 6559ef8eb..c5133b400 100644 --- a/textclient/citadel.c +++ b/textclient/citadel.c @@ -262,7 +262,6 @@ char *pop_march(int desired_floor, struct march *_march) { void dotgoto(CtdlIPC * ipc, char *towhere, int display_name, int fromungoto) { char aaa[SIZ], bbb[SIZ]; static long ls = 0L; - int newmailcount = 0; int partial_match, best_match; char from_floor; int ugpos = uglistsize; @@ -405,8 +404,7 @@ void dotgoto(CtdlIPC * ipc, char *towhere, int display_name, int fromungoto) { if (room->RRinfoupdated > 0) readinfo(ipc); - /* check for newly arrived mail if we can */ - newmailcount = room->RRnewmail; + /* check for newly arrived mail if we can FIXME use BIFF command for this if (newmailcount > 0) { color(BRIGHT_RED); if (newmailcount == 1) { @@ -422,12 +420,14 @@ void dotgoto(CtdlIPC * ipc, char *towhere, int display_name, int fromungoto) { scr_printf("*** failed to check for mail calling %s Reason %d.\n", rc_gotmail_cmd, rv); } } + */ + free(room); if (screenwidth > 5) snprintf(&status_line[1], screenwidth - 1, "%s | %s | %s | %s | %d new mail |", (secure ? "Encrypted" : "Unencrypted"), - ipc->ServInfo.humannode, ipc->ServInfo.site_location, room_name, newmailcount); + ipc->ServInfo.humannode, ipc->ServInfo.site_location, room_name, 0); // FIXME use BIFF } diff --git a/textclient/citadel_ipc.c b/textclient/citadel_ipc.c index f4a5695b8..007f8410f 100644 --- a/textclient/citadel_ipc.c +++ b/textclient/citadel_ipc.c @@ -488,11 +488,11 @@ int CtdlIPCGotoRoom(CtdlIPC * ipc, const char *room, const char *passwd, struct rret[0]->RRlastread = extract_long(cret, 6); rret[0]->RRismailbox = extract_int(cret, 7); rret[0]->RRaide = extract_int(cret, 8); - rret[0]->RRnewmail = extract_long(cret, 9); + // position 9 is no longer used rret[0]->RRfloor = extract_int(cret, 10); rret[0]->RRcurrentview = extract_int(cret, 11); rret[0]->RRdefaultview = extract_int(cret, 12); - /* position 13 is a trash folder flag ... irrelevant in this client */ + // position 13 is a trash folder flag ... irrelevant in this client rret[0]->RRflags2 = extract_int(cret, 14); } else { diff --git a/textclient/textclient.h b/textclient/textclient.h index 6ad0e002f..c8658c3fc 100644 --- a/textclient/textclient.h +++ b/textclient/textclient.h @@ -284,7 +284,6 @@ struct ctdlipcroom { long RRlastread; /* Highest message user has read */ char RRismailbox; /* Is this room a mailbox room? */ char RRaide; /* User can do aide commands in room */ - long RRnewmail; /* Number of new mail messages */ char RRfloor; /* Which floor this room is on */ char RRcurrentview; /* The user's current view for this room */ char RRdefaultview; /* The default view for this room */ diff --git a/webcit/roomops.c b/webcit/roomops.c index 059eadf80..9d8699c06 100644 --- a/webcit/roomops.c +++ b/webcit/roomops.c @@ -273,7 +273,7 @@ void ParseGoto(folder *room, StrBuf *Line) { room->RAFlags |= UA_ADMINALLOWED; } - room->UsersNewMAilboxMessages = StrBufExtractNext_long(Line, &Pos, '|'); + StrBufExtractNext_long(Line, &Pos, '|'); // position 9 is unused room->floorid = StrBufExtractNext_int(Line, &Pos, '|'); room->view = StrBufExtractNext_long(Line, &Pos, '|'); room->defview = StrBufExtractNext_long(Line, &Pos, '|'); diff --git a/webcit/roomops.h b/webcit/roomops.h index fd1f60e4a..c29a10189 100644 --- a/webcit/roomops.h +++ b/webcit/roomops.h @@ -104,7 +104,6 @@ typedef struct _folder { long LastMessageRead; long HighestRead; int ShowInfo; - int UsersNewMAilboxMessages; /* should we notify the user about new messages? */ int IsTrash; /* Only available if certain other commands ran */ int XHaveRoomPic; -- 2.30.2