...
 
Commits (2)
  • Rob Swindell's avatar
    Some message attributes (auxiliary and network) weren't shown · 1806aaf9
    Rob Swindell authored
    Copy some code from atcodes.cpp to show all the aux and network attributes.
    
    Also, the MsgAttr text.dat string only contains 17 %s's but we were passing 18, so the last attribute (KillSent) would never be shown.
    
    Instead, split this into 3 strings and just pass those 3 strings to the MsgAttr format string along with a ton of blank strings. So we don't have to keep updating the MsgAttr text.dat string every time we add more attribute flags (that was kind of ridiculous).
    1806aaf9
  • Rob Swindell's avatar
    Support forwarding of local email msg to networked mail. · ed16fc7e
    Rob Swindell authored
    Closes #83, #108, #141.
    Still to do: expose via JS (e.g. for use in msglist.js).
    ed16fc7e
/* Synchronet (oh, so old) data access routines */
/* $Id: data.cpp,v 1.32 2020/04/27 07:42:23 rswindell Exp $ */
/****************************************************************************
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
......@@ -15,21 +13,9 @@
* See the GNU General Public License for more details: gpl.txt or *
* http://www.fsf.org/copyleft/gpl.html *
* *
* Anonymous FTP access to the most recent released source is available at *
* ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net *
* *
* Anonymous CVS access to the development source and modification history *
* is available at cvs.synchro.net:/cvsroot/sbbs, example: *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs login *
* (just hit return, no password is necessary) *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs checkout src *
* *
* For Synchronet coding style and modification guidelines, see *
* http://www.synchro.net/source.html *
* *
* You are encouraged to submit any modifications (preferably in Unix diff *
* format) via e-mail to mods@synchro.net *
* *
* Note: If this box doesn't appear square, then you need to fix your tabs. *
****************************************************************************/
......@@ -45,7 +31,7 @@
/* Returns the number of the matched user or 0 if unsuccessful */
/* Called from functions main_sec, useredit and readmailw */
/****************************************************************************/
uint sbbs_t::finduser(char *instr, bool silent_failure)
uint sbbs_t::finduser(const char* instr, bool silent_failure)
{
int file,i;
char str[128],str2[256],str3[256],ynq[25],c,pass=1;
......
......@@ -97,7 +97,8 @@ void sbbs_t::show_msgattr(smbmsg_t* msg)
uint32_t auxattr = msg->hdr.auxattr;
uint32_t netattr = msg->hdr.netattr;
bprintf(text[MsgAttr]
char attr_str[64];
safe_snprintf(attr_str, sizeof(attr_str), "%s%s%s%s%s%s%s%s%s%s%s%s%s%s"
,attr&MSG_PRIVATE ? "Private " :nulstr
,attr&MSG_SPAM ? "SPAM " :nulstr
,attr&MSG_READ ? "Read " :nulstr
......@@ -112,11 +113,35 @@ void sbbs_t::show_msgattr(smbmsg_t* msg)
,attr&MSG_NOREPLY ? "NoReply " :nulstr
,poll == MSG_POLL ? "Poll " :nulstr
,poll == MSG_POLL && auxattr&POLL_CLOSED ? "(Closed) " :nulstr
,auxattr&(MSG_FILEATTACH|MSG_MIMEATTACH) ? "Attach " :nulstr
,netattr&MSG_SENT ? "Sent " :nulstr
,netattr&MSG_INTRANSIT ? "InTransit ":nulstr
,netattr&MSG_KILLSENT ? "KillSent " :nulstr
);
char auxattr_str[64];
safe_snprintf(auxattr_str, sizeof(auxattr_str), "%s%s%s%s%s%s%s"
,auxattr&MSG_FILEREQUEST? "FileRequest " :nulstr
,auxattr&MSG_FILEATTACH ? "FileAttach " :nulstr
,auxattr&MSG_MIMEATTACH ? "MimeAttach " :nulstr
,auxattr&MSG_KILLFILE ? "KillFile " :nulstr
,auxattr&MSG_RECEIPTREQ ? "ReceiptReq " :nulstr
,auxattr&MSG_CONFIRMREQ ? "ConfirmReq " :nulstr
,auxattr&MSG_NODISP ? "DontDisplay " :nulstr
);
char netattr_str[64];
safe_snprintf(netattr_str, sizeof(netattr_str), "%s%s%s%s%s%s%s%s"
,netattr&MSG_LOCAL ? "Local " :nulstr
,netattr&MSG_INTRANSIT ? "InTransit " :nulstr
,netattr&MSG_SENT ? "Sent " :nulstr
,netattr&MSG_KILLSENT ? "KillSent " :nulstr
,netattr&MSG_HOLD ? "Hold " :nulstr
,netattr&MSG_CRASH ? "Crash " :nulstr
,netattr&MSG_IMMEDIATE ? "Immediate " :nulstr
,netattr&MSG_DIRECT ? "Direct " :nulstr
);
bprintf(text[MsgAttr], attr_str, auxattr_str, netattr_str
,nulstr, nulstr, nulstr, nulstr, nulstr, nulstr, nulstr, nulstr, nulstr, nulstr, nulstr
,nulstr, nulstr, nulstr, nulstr, nulstr, nulstr, nulstr, nulstr, nulstr, nulstr, nulstr
,nulstr, nulstr, nulstr, nulstr, nulstr, nulstr, nulstr, nulstr, nulstr, nulstr, nulstr);
}
/* Returns a CP437 text.dat string converted to UTF-8, when appropriate */
......
/* readmail.cpp */
/* Synchronet private mail reading function */
/* $Id: readmail.cpp,v 1.101 2020/05/11 05:01:01 rswindell Exp $ */
/****************************************************************************
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
......@@ -17,21 +13,9 @@
* See the GNU General Public License for more details: gpl.txt or *
* http://www.fsf.org/copyleft/gpl.html *
* *
* Anonymous FTP access to the most recent released source is available at *
* ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net *
* *
* Anonymous CVS access to the development source and modification history *
* is available at cvs.synchro.net:/cvsroot/sbbs, example: *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs login *
* (just hit return, no password is necessary) *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs checkout src *
* *
* For Synchronet coding style and modification guidelines, see *
* http://www.synchro.net/source.html *
* *
* You are encouraged to submit any modifications (preferably in Unix diff *
* format) via e-mail to mods@synchro.net *
* *
* Note: If this box doesn't appear square, then you need to fix your tabs. *
****************************************************************************/
......@@ -435,24 +419,20 @@ void sbbs_t::readmail(uint usernumber, int which, long lm_mode)
case 'F': /* Forward last piece */
domsg=0;
bputs(text[ForwardMailTo]);
if(!getstr(str,LEN_ALIAS,cfg.uq&UQ_NOUPRLWR ? K_NONE:K_UPRLWR))
if(!getstr(str, sizeof(str) - 1, K_TRIM))
break;
i=finduser(str);
if(!i)
smb_getmsgidx(&smb,&msg);
if(!forwardmail(&msg, str))
break;
domsg=1;
if(smb.curmsg<smb.msgs-1) smb.curmsg++;
else done=1;
smb_getmsgidx(&smb,&msg);
forwardmail(&msg,i);
if(msg.hdr.attr&MSG_PERMANENT)
if(msg.hdr.attr&(MSG_PERMANENT | MSG_DELETE))
break;
SAFEPRINTF(str2,text[DeleteMailQ],msghdr_field(&msg, msg.from));
if(!yesno(str2))
break;
if(msg.total_hfields)
smb_freemsgmem(&msg);
msg.total_hfields=0;
smb_freemsgmem(&msg);
msg.idx.offset=0;
if(smb_locksmbhdr(&smb)==SMB_SUCCESS) { /* Lock the entire base */
if(loadmsg(&msg,msg.idx.number) >= 0) {
......@@ -465,7 +445,6 @@ void sbbs_t::readmail(uint usernumber, int which, long lm_mode)
}
smb_unlocksmbhdr(&smb);
}
break;
case 'H':
domsg=0;
......
......@@ -623,7 +623,7 @@ public:
void reset_logon_vars(void);
uint finduser(char *str, bool silent_failure = false);
uint finduser(const char* str, bool silent_failure = false);
int sub_op(uint subnum);
......@@ -681,7 +681,7 @@ public:
bool msgabort(void);
bool email(int usernumber, const char *top = NULL, const char *title = NULL
, long mode = WM_NONE, smb_t* resmb = NULL, smbmsg_t* remsg = NULL);
void forwardmail(smbmsg_t* msg, int usernum);
bool forwardmail(smbmsg_t* msg, const char* to);
void removeline(char *str, char *str2, char num, char skip);
ulong msgeditor(char *buf, const char *top, char *title);
bool editfile(char *path, bool msg=false);
......
/* Synchronet message creation routines */
// vi: tabstop=4
/* $Id: writemsg.cpp,v 1.175 2020/05/24 19:34:02 rswindell Exp $ */
/****************************************************************************
* @format.tab-size 4 (Plain Text/Source Code File Header) *
......@@ -16,21 +13,9 @@
* See the GNU General Public License for more details: gpl.txt or *
* http://www.fsf.org/copyleft/gpl.html *
* *
* Anonymous FTP access to the most recent released source is available at *
* ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net *
* *
* Anonymous CVS access to the development source and modification history *
* is available at cvs.synchro.net:/cvsroot/sbbs, example: *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs login *
* (just hit return, no password is necessary) *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs checkout src *
* *
* For Synchronet coding style and modification guidelines, see *
* http://www.synchro.net/source.html *
* *
* You are encouraged to submit any modifications (preferably in Unix diff *
* format) via e-mail to mods@synchro.net *
* *
* Note: If this box doesn't appear square, then you need to fix your tabs. *
****************************************************************************/
......@@ -1338,10 +1323,9 @@ void sbbs_t::copyfattach(uint to, uint from, char *title)
/****************************************************************************/
/* Forwards mail (fname) to usernumber */
/* Called from function readmail */
/* Forwards mail 'msg' to 'to' */
/****************************************************************************/
void sbbs_t::forwardmail(smbmsg_t *msg, int usernumber)
bool sbbs_t::forwardmail(smbmsg_t* msg, const char* to)
{
char str[256],touser[128];
char tmp[512];
......@@ -1350,27 +1334,44 @@ void sbbs_t::forwardmail(smbmsg_t *msg, int usernumber)
msghdr_t hdr=msg->hdr;
idxrec_t idx=msg->idx;
time32_t now32;
uint usernumber = 0;
if(to == NULL)
return false;
uint16_t net_type = smb_netaddr_type(to);
if(net_type == NET_NONE || net_type == NET_UNKNOWN) {
usernumber = finduser(to);
if(usernumber < 1)
return false;
net_type = NET_NONE;
} else if(!is_supported_netmail_addr(&cfg, to)) {
bprintf(text[InvalidNetMailAddr], to);
return false;
}
if(useron.etoday>=cfg.level_emailperday[useron.level] && !SYSOP && !(useron.exempt&FLAG('M'))) {
bputs(text[TooManyEmailsToday]);
return;
return false;
}
if(useron.rest&FLAG('F')) {
bputs(text[R_Forward]);
return;
return false;
}
if(usernumber==1 && useron.rest&FLAG('S')) {
bprintf(text[R_Feedback],cfg.sys_op);
return;
return false;
}
if(usernumber!=1 && useron.rest&FLAG('E')) {
bputs(text[R_Email]);
return;
return false;
}
msg->idx.attr&=~(MSG_READ|MSG_DELETE);
msg->hdr.attr=msg->idx.attr;
now32=time32(NULL);
smb_hfield(msg,FORWARDED,sizeof(now32),&now32);
smb_hfield_str(msg,SENDER,useron.alias);
SAFEPRINTF(str,"%u",useron.number);
......@@ -1380,45 +1381,43 @@ void sbbs_t::forwardmail(smbmsg_t *msg, int usernumber)
msg_client_hfields(msg,&client);
smb_hfield_str(msg,SENDERSERVER, server_host_name());
username(&cfg,usernumber,touser);
smb_hfield_str(msg,RECIPIENT,touser);
SAFEPRINTF(str,"%u",usernumber);
smb_hfield_str(msg,RECIPIENTEXT,str);
msg->idx.to=usernumber;
now32=time32(NULL);
smb_hfield(msg,FORWARDED,sizeof(time32_t),&now32);
if(usernumber > 0) {
username(&cfg,usernumber,touser);
smb_hfield_str(msg,RECIPIENT,touser);
SAFEPRINTF(str,"%u",usernumber);
smb_hfield_str(msg,RECIPIENTEXT,str);
msg->idx.to=usernumber;
} else {
SAFECOPY(touser, to);
smb_hfield_netaddr(msg, RECIPIENTNETADDR, to, NULL);
msg->idx.to=0;
}
if((i=smb_open_da(&smb))!=SMB_SUCCESS) {
errormsg(WHERE,ERR_OPEN,smb.file,i,smb.last_error);
return;
return false;
}
if((i=smb_incmsg_dfields(&smb,msg,1))!=SMB_SUCCESS) {
errormsg(WHERE,ERR_WRITE,smb.file,i);
return;
return false;
}
smb_close_da(&smb);
if((i=smb_addmsghdr(&smb,msg,smb_storage_mode(&cfg, &smb)))!=SMB_SUCCESS) {
errormsg(WHERE,ERR_WRITE,smb.file,i,smb.last_error);
smb_freemsg_dfields(&smb,msg,1);
return;
return false;
}
if(msg->hdr.auxattr&MSG_FILEATTACH)
copyfattach(usernumber,useron.number,msg->subj);
bprintf(text[Forwarded],username(&cfg,usernumber,str),usernumber);
SAFEPRINTF2(str,"forwarded mail to %s #%d"
,username(&cfg,usernumber,tmp)
,usernumber);
bprintf(text[Forwarded], touser, usernumber);
SAFEPRINTF(str, "forwarded mail to %s", touser);
logline("E+",str);
msg->idx=idx;
msg->hdr=hdr;
if(usernumber==1) {
useron.fbacks++;
logon_fbacks++;
......@@ -1445,6 +1444,7 @@ void sbbs_t::forwardmail(smbmsg_t *msg, int usernumber)
SAFEPRINTF(str,text[UserSentYouMail],useron.alias);
putsmsg(&cfg,usernumber,str);
}
return true;
}
/****************************************************************************/
......