--- sbbs/sbbs3/readmail.cpp 2018/04/24 16:39:34 1.1.1.1 +++ sbbs/sbbs3/readmail.cpp 2018/04/24 16:40:16 1.1.1.2 @@ -2,7 +2,7 @@ /* Synchronet private mail reading function */ -/* $Id: readmail.cpp,v 1.1.1.1 2018/04/24 16:39:34 root Exp $ */ +/* $Id: readmail.cpp,v 1.1.1.2 2018/04/24 16:40:16 root Exp $ */ /**************************************************************************** * @format.tab-size 4 (Plain Text/Source Code File Header) * @@ -46,6 +46,7 @@ void sbbs_t::readmail(uint usernumber, i ,*p,*tp,*sp,ch; char tmp[512]; int i,j; + int error; int mismatches=0,act; ulong msgs,curmsg; long length,l,lm_mode; @@ -55,6 +56,11 @@ void sbbs_t::readmail(uint usernumber, i mail_t *mail; smbmsg_t msg; + if(which==MAIL_SENT && useron.rest&FLAG('K')) { + bputs(text[R_ReadSentMail]); + return; + } + msg.total_hfields=0; /* init to NULL, cause not allocated yet */ fd.dir=cfg.total_dirs+1; /* temp dir for file attachments */ @@ -64,6 +70,7 @@ void sbbs_t::readmail(uint usernumber, i return; } sprintf(smb.file,"%smail",cfg.data_dir); smb.retry_time=cfg.smb_retry_time; + smb.subnum=INVALID_SUB; if((i=smb_open(&smb))!=0) { smb_stack(&smb,SMB_STACK_POP); errormsg(WHERE,ERR_OPEN,smb.file,i,smb.last_error); @@ -124,7 +131,7 @@ void sbbs_t::readmail(uint usernumber, i bprintf(text[StartWithN],1L); if((long)(curmsg=getnum(msgs))>0) curmsg--; - else if(curmsg==-1) { + else if((long)curmsg==-1) { FREE(mail); smb_close(&smb); smb_stack(&smb,SMB_STACK_POP); @@ -134,15 +141,19 @@ void sbbs_t::readmail(uint usernumber, i curmsg=0; if(which==MAIL_ALL) domsg=0; } - if(which==MAIL_SENT) - logline("E","Read sent mail"); - else if(which==MAIL_ALL) - logline("S+","Read all mail"); - else - logline("E","Read mail"); + if(which==MAIL_SENT) { + sprintf(str,"%s read sent mail",useron.alias); + logline("E",str); + } else if(which==MAIL_ALL) { + sprintf(str,"%s read all mail",useron.alias); + logline("S+",str); + } else { + sprintf(str,"%s read mail",useron.alias); + logline("E",str); + } if(useron.misc&RIP) { - strcpy(str,which==MAIL_YOUR ? "MAILREAD" : which==MAIL_ALL ? - "ALLMAIL" : "SENTMAIL"); + strcpy(str,which==MAIL_YOUR ? "mailread" : which==MAIL_ALL ? + "allmail" : "sentmail"); menu(str); } while(online && !done) { action=act; @@ -206,10 +217,10 @@ void sbbs_t::readmail(uint usernumber, i if(msg.hdr.auxattr&MSG_FILEATTACH) { /* Attached file */ smb_getmsgidx(&smb,&msg); strcpy(str,msg.subj); /* filenames in title */ - strupr(str); +// strupr(str); tp=str; while(online) { - p=strchr(tp,SP); + p=strchr(tp,' '); if(p) *p=0; sp=strrchr(tp,'/'); /* sp is slash pointer */ if(!sp) sp=strrchr(tp,'\\'); @@ -243,7 +254,7 @@ void sbbs_t::readmail(uint usernumber, i ,fd.name,ultoac(length,tmp)); } } } else { /* Remote User */ - menu("dlprot"); + xfer_prot_menu(XFER_DOWNLOAD); mnemonics(text[ProtocolOrQuit]); strcpy(str3,"Q"); for(i=0;iar,&useron)) break; if(idlcmd,str2,nulstr - ,NULL),0); - if((cfg.prot[i]->misc&PROT_DSZLOG - && checkprotlog(&fd)) - || (!(cfg.prot[i]->misc&PROT_DSZLOG) && !j)) { - if(which==MAIL_YOUR) - remove(str2); - logon_dlb+=length; /* Update stats */ - logon_dls++; - useron.dls=(ushort)adjustuserrec(&cfg,useron.number - ,U_DLS,5,1); - useron.dlb=adjustuserrec(&cfg,useron.number - ,U_DLB,10,length); - bprintf(text[FileNBytesSent] - ,fd.name,ultoac(length,tmp)); - sprintf(str3 - ,"Downloaded attached file: %s" - ,fd.name); - logline("D-",str3); } - autohangup(); } } } } - if(!p) - break; - tp=p+1; - while(*tp==SP) tp++; } + error=protocol(cfg.prot[i],XFER_DOWNLOAD,str2,nulstr,false); + if(checkprotresult(cfg.prot[i],error,&fd)) { + if(which==MAIL_YOUR) + remove(str2); + logon_dlb+=length; /* Update stats */ + logon_dls++; + useron.dls=(ushort)adjustuserrec(&cfg,useron.number + ,U_DLS,5,1); + useron.dlb=adjustuserrec(&cfg,useron.number + ,U_DLB,10,length); + bprintf(text[FileNBytesSent] + ,fd.name,ultoac(length,tmp)); + sprintf(str3 + ,"%s downloaded attached file: %s" + ,useron.alias + ,fd.name); + logline("D-",str3); + } + autohangup(); + } + } + } + } + if(!p) + break; + tp=p+1; + while(*tp==' ') tp++; + } sprintf(str,"%sfile/%04u.in",cfg.data_dir,usernumber); rmdir(str); } if(which==MAIL_YOUR && !(msg.hdr.attr&MSG_READ)) { @@ -306,8 +321,8 @@ void sbbs_t::readmail(uint usernumber, i else domsg=1; if(useron.misc&WIP) { - strcpy(str,which==MAIL_YOUR ? "MAILREAD" : which==MAIL_ALL ? - "ALLMAIL" : "SENTMAIL"); + strcpy(str,which==MAIL_YOUR ? "mailread" : which==MAIL_ALL ? + "allmail" : "sentmail"); menu(str); } ASYNC; @@ -319,7 +334,7 @@ void sbbs_t::readmail(uint usernumber, i bprintf(text[ReadingMail],curmsg+1,msgs); sprintf(str,"ADFLNQRT?<>[]{}-+"); if(SYSOP) - strcat(str,"CUSP"); + strcat(str,"CUSPH"); if(which!=MAIL_YOUR) strcat(str,"E"); l=getkeys(str,msgs); @@ -342,15 +357,15 @@ void sbbs_t::readmail(uint usernumber, i quotemsg(&msg,1); - if(msg.from_net.type==NET_FIDO) /* FidoNet type */ - sprintf(str,"%s @%s",msg.from - ,faddrtoa(*(faddr_t *)msg.from_net.addr)); + if(msg.from_net.addr==NULL) + strcpy(str,msg.from); + else if(msg.from_net.type==NET_FIDO) /* FidoNet type */ + sprintf(str,"%s@%s",msg.from + ,smb_faddrtoa((faddr_t *)msg.from_net.addr,tmp)); else if(msg.from_net.type==NET_INTERNET) strcpy(str,(char *)msg.from_net.addr); - else if(msg.from_net.type) - sprintf(str,"%s@%s",msg.from,msg.from_net.addr); - else /* No net */ - strcpy(str,msg.from); + else + sprintf(str,"%s@%s",msg.from,(char*)msg.from_net.addr); strcpy(str2,str); @@ -377,6 +392,8 @@ void sbbs_t::readmail(uint usernumber, i replied=email(1,str2,msg.subj,WM_EMAIL|WM_QUOTE); else if((i=finduser(str))!=0) replied=email(i,str2,msg.subj,WM_EMAIL|WM_QUOTE); + else + replied=false; sprintf(str2,text[DeleteMailQ],msg.from); } if(replied==true && !(msg.hdr.attr&MSG_REPLIED)) { @@ -392,7 +409,7 @@ void sbbs_t::readmail(uint usernumber, i smb_unlockmsghdr(&smb,&msg); } } - if(!yesno(str2)) { + if(msg.hdr.attr&MSG_DELETE || !yesno(str2)) { if(curmsg-1;i--) + for(i=curmsg-1;i>-1;i--) if(mail[i].to==msg.idx.to) break; - if((ulong)i>-1) + if(i>-1) curmsg=i; else domsg=0; @@ -620,7 +641,7 @@ void sbbs_t::readmail(uint usernumber, i bprintf(text[MailOnSystemLstFmt] ,i+1,msg.from,msg.to ,msg.hdr.attr&MSG_DELETE ? '-' : msg.hdr.attr&MSG_REPLIED ? 'R' - : msg.hdr.attr&MSG_READ ? SP + : msg.hdr.attr&MSG_READ ? ' ' : msg.from_net.type || msg.to_net.type ? 'N':'*' ,msg.subj); else @@ -629,7 +650,7 @@ void sbbs_t::readmail(uint usernumber, i : (msg.hdr.attr&MSG_ANONYMOUS) && !SYSOP ? text[Anonymous] : msg.from ,msg.hdr.attr&MSG_DELETE ? '-' : msg.hdr.attr&MSG_REPLIED ? 'R' - : msg.hdr.attr&MSG_READ ? SP + : msg.hdr.attr&MSG_READ ? ' ' : msg.from_net.type || msg.to_net.type ? 'N':'*' ,msg.subj); smb_freemsgmem(&msg); @@ -639,7 +660,7 @@ void sbbs_t::readmail(uint usernumber, i case 'U': /* user edit */ msg.hdr.number=msg.idx.number; smb_getmsgidx(&smb,&msg); - useredit(which==MAIL_SENT ? msg.idx.to : msg.idx.from,0); + useredit(which==MAIL_SENT ? msg.idx.to : msg.idx.from); break; case 'P': /* Purge author and all mail to/from */ if(noyes(text[AreYouSureQ])) @@ -650,8 +671,8 @@ void sbbs_t::readmail(uint usernumber, i if(curmsg