From 0e8ec762bfe6a3a8f8330b917f4711f6758c8626 Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Thu, 21 Sep 2017 16:07:31 +1000 Subject: [PATCH] Reset Msg Pointers --- bbs.h | 2 ++ mail_menu.c | 28 ++++++++++++++++++++++++++++ menus.c | 12 ++++++++++++ menus_default/mail.mnu | 5 +++++ 4 files changed, 47 insertions(+) diff --git a/bbs.h b/bbs.h index 87d508a..2092357 100644 --- a/bbs.h +++ b/bbs.h @@ -280,6 +280,8 @@ extern void next_mail_area(struct user_record *user); extern void prev_mail_area(struct user_record *user); extern void post_message(struct user_record *user); extern void msg_conf_sub_bases(); +extern void msgbase_reset_pointers(int conference, int msgarea); +extern void msgbase_reset_all_pointers(); extern void rundoor(struct user_record *user, char *cmd, int stdio, char *codepage); extern void runexternal(struct user_record *user, char *cmd, int stdio, char **argv, char *cwd, int raw, char *codepage); diff --git a/mail_menu.c b/mail_menu.c index 6cdd159..928e20b 100644 --- a/mail_menu.c +++ b/mail_menu.c @@ -2680,3 +2680,31 @@ void msg_conf_sub_bases() { } } while (!done); } + +void msgbase_reset_pointers(int conference, int msgarea) { + s_JamBase *jb; + s_JamBaseHeader jbh; + s_JamLastRead jlr; + + jb = open_jam_base(conf.mail_conferences[conference]->mail_areas[msgarea]->path); + if (!jb) { + dolog("Unable to open message base"); + return; + } + if (JAM_ReadLastRead(jb, gUser->id, &jlr) != JAM_NO_USER) { + jlr.LastReadMsg = 0; + jlr.HighReadMsg = 0; + JAM_WriteLastRead(jb, gUser->id, &jlr); + } + JAM_CloseMB(jb); +} + +void msgbase_reset_all_pointers() { + int i, j; + + for (i=0;imail_area_count;j++) { + msgbase_reset_pointers(i, j); + } + } +} diff --git a/menus.c b/menus.c index ef59e46..0290b8c 100644 --- a/menus.c +++ b/menus.c @@ -47,6 +47,8 @@ #define MENU_DOSCRIPT 37 #define MENU_SENDNODEMSG 38 #define MENU_SUBUNSUBCONF 39 +#define MENU_RESETPOINTERS 40 +#define MENU_RESETALLPOINTERS 41 extern struct bbs_config conf; extern struct user_record *gUser; @@ -190,6 +192,10 @@ int menu_system(char *menufile) { menu[menu_items-1]->command = MENU_SENDNODEMSG; } else if (strncasecmp(&buffer[8], "SUBUNSUBCONF", 12) == 0) { menu[menu_items-1]->command = MENU_SUBUNSUBCONF; + } else if (strncasecmp(&buffer[8], "RESETMSGPTRS", 12) == 0) { + menu[menu_items-1]->command = MENU_RESETPOINTERS; + } else if (strncasecmp(&buffer[8], "RESETALLMSGPTRS", 15) == 0) { + menu[menu_items-1]->command = MENU_RESETALLPOINTERS; } } else if (strncasecmp(buffer, "SECLEVEL", 8) == 0) { menu[menu_items-1]->seclevel = atoi(&buffer[9]); @@ -474,6 +480,12 @@ int menu_system(char *menufile) { case MENU_SUBUNSUBCONF: msg_conf_sub_bases(); break; + case MENU_RESETPOINTERS: + msgbase_reset_pointers(gUser->cur_mail_conf, gUser->cur_mail_area); + break; + case MENU_RESETALLPOINTERS: + msgbase_reset_all_pointers(); + break; default: break; } diff --git a/menus_default/mail.mnu b/menus_default/mail.mnu index 026cffc..9b3e29b 100644 --- a/menus_default/mail.mnu +++ b/menus_default/mail.mnu @@ -53,3 +53,8 @@ COMMAND BLUEWAVEUPLOAD HOTKEY S COMMAND SUBUNSUBCONF +HOTKEY Z +COMMAND RESETMSGPTRS + +HOTKEY X +COMMAND RESETALLMSGPTRS