Commit 56059107 authored by rswindell's avatar rswindell
Browse files

Added support for a "list messages module" which is an optional module (Baja or

JS) which will be executed when a users uses the the (L)ist msgs command from
the "Reading" sub or "Reading E-mail" prompt.
The arguments passed to the module are: <sub-code> [which]  [usernum]  [lm_mode]
The additional optional arguments are the same values as would be passed to a
readmail_mod, if one were to be used instead.
parent d16950b8
......@@ -469,6 +469,14 @@ void sbbs_t::readmail(uint usernumber, int which, long lm_mode)
break;
case 'L': /* List mail */
domsg=0;
if(cfg.listmsgs_mod[0]) {
char cmdline[256];
safe_snprintf(cmdline, sizeof(cmdline), "%s %s %d %u %lu", cfg.listmsgs_mod, "mail", which, usernumber, lm_mode);
exec_bin(cmdline, &main_csi);
break;
}
bprintf(text[StartWithN],(long)smb.curmsg+1);
if((i=getnum(smb.msgs))>0)
i--;
......
......@@ -60,12 +60,12 @@ uchar sbbs_t::msg_listing_flag(uint subnum, smbmsg_t* msg, post_t* post)
return ' ';
}
long sbbs_t::listmsgs(uint subnum, long mode, post_t *post, long i, long posts, bool reading)
long sbbs_t::listmsgs(uint subnum, long mode, post_t *post, long start, long posts, bool reading)
{
smbmsg_t msg;
long listed=0;
for(;i<posts && !msgabort();i++) {
for(long i = start; i<posts && !msgabort(); i++) {
if(mode&SCAN_NEW && post[i].idx.number<=subscan[subnum].ptr)
continue;
msg.idx.offset=post[i].idx.offset;
......@@ -1077,6 +1077,13 @@ int sbbs_t::scanposts(uint subnum, long mode, const char *find)
break;
case 'L': /* List messages */
domsg=0;
if(cfg.listmsgs_mod[0]) {
char cmdline[256];
safe_snprintf(cmdline, sizeof(cmdline), "%s %s %ld", cfg.listmsgs_mod, cfg.sub[subnum]->code, mode);
exec_bin(cmdline, &main_csi);
break;
}
if((i64=get_start_msgnum(&smb, 1))<0)
break;
i=(int)i64;
......
......@@ -1634,6 +1634,7 @@ void sys_cfg(void)
sprintf(opt[i++],"%-16.16s%s","Read Mail",cfg.readmail_mod);
sprintf(opt[i++],"%-16.16s%s","Scan Msgs",cfg.scanposts_mod);
sprintf(opt[i++],"%-16.16s%s","Scan Subs",cfg.scansubs_mod);
sprintf(opt[i++],"%-16.16s%s","List Msgs",cfg.listmsgs_mod);
opt[i][0]=0;
uifc.helpbuf=
"`Loadable Modules:`\n"
......@@ -1656,6 +1657,7 @@ void sys_cfg(void)
"`Read Mail` Executed when a user reads email/netmail\n"
"`Scan Msgs` Executed when a user reads or scans a message sub-board\n"
"`Scan Subs` Executed when a user scans one or more sub-boards for msgs\n"
"`List Msgs` Executed when a user list msgs from the msg read prompt\n"
"\n"
"`Note:` JavaScript modules take precedence over Baja modules if both exist\n"
"in your `exec` or `mods` directories.\n"
......@@ -1707,6 +1709,10 @@ void sys_cfg(void)
uifc.input(WIN_MID|WIN_SAV,0,0,"Scan Subs Command"
,cfg.scansubs_mod,sizeof(cfg.scansubs_mod)-1,K_EDIT);
break;
case 10:
uifc.input(WIN_MID|WIN_SAV,0,0,"List Msgs Command"
,cfg.listmsgs_mod,sizeof(cfg.listmsgs_mod)-1,K_EDIT);
break;
}
}
break;
......
......@@ -598,6 +598,7 @@ typedef struct
char readmail_mod[LEN_CMD+1]; /* Reading mail module */
char scanposts_mod[LEN_CMD+1]; /* Scanning posts (in a single sub) module */
char scansubs_mod[LEN_CMD+1]; /* Scanning sub-boards module */
char listmsgs_mod[LEN_CMD+1]; /* Listing messages module */
char scfg_cmd[LEN_CMD+1]; /* SCFG command line - unused! */
uchar smb_retry_time; /* Seconds to retry on SMBs */
uint16_t sec_warn; /* Seconds before inactivity warning */
......
......@@ -304,9 +304,10 @@ BOOL read_main_cfg(scfg_t* cfg, char* error)
get_str(cfg->readmail_mod, instream);
get_str(cfg->scanposts_mod, instream);
get_str(cfg->scansubs_mod, instream);
get_str(cfg->listmsgs_mod, instream);
get_int(c,instream);
for(i=0;i<62;i++) /* unused - initialized to NULL */
for(i=0;i<30;i++) /* unused - initialized to NULL */
get_int(n,instream);
for(i=0;i<254;i++) /* unused - initialized to 0xff */
get_int(n,instream);
......
......@@ -271,10 +271,11 @@ BOOL DLLCALL write_main_cfg(scfg_t* cfg, int backup_level)
put_str(cfg->readmail_mod, stream);
put_str(cfg->scanposts_mod, stream);
put_str(cfg->scansubs_mod, stream);
put_str(cfg->listmsgs_mod, stream);
put_int(c,stream);
n=0;
for(i=0;i<62;i++)
for(i=0;i<30;i++)
put_int(n,stream);
n=0xffff;
for(i=0;i<254;i++)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment