--- sbbs/sbbs3/ctrl/mailcfgdlgunit.cpp 2018/04/24 16:39:34 1.1 +++ sbbs/sbbs3/ctrl/mailcfgdlgunit.cpp 2018/04/24 16:40:45 1.1.1.2 @@ -1,12 +1,12 @@ /* Synchronet Control Panel (GUI Borland C++ Builder Project for Win32) */ -/* $Id: mailcfgdlgunit.cpp,v 1.1 2018/04/24 16:39:34 root Exp $ */ +/* $Id: mailcfgdlgunit.cpp,v 1.1.1.2 2018/04/24 16:40:45 root Exp $ */ /**************************************************************************** * @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * * * - * Copyright 2000 Rob Swindell - http://www.synchro.net/copyright.html * + * Copyright 2004 Rob Swindell - http://www.synchro.net/copyright.html * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License * @@ -39,6 +39,7 @@ #include "MainFormUnit.h" #include "MailCfgDlgUnit.h" +#include "TextFileEditUnit.h" #include // sprintf() #include // sndPlaySound() //--------------------------------------------------------------------- @@ -87,6 +88,9 @@ void __fastcall TMailCfgDlg::FormShow(TO } MaxClientsEdit->Text=AnsiString(MainForm->mail_startup.max_clients); MaxInactivityEdit->Text=AnsiString(MainForm->mail_startup.max_inactivity); + MaxRecipientsEdit->Text=AnsiString(MainForm->mail_startup.max_recipients); + MaxMsgSizeEdit->Text=AnsiString(MainForm->mail_startup.max_msg_size); + LinesPerYieldEdit->Text=AnsiString(MainForm->mail_startup.lines_per_yield); AutoStartCheckBox->Checked=MainForm->MailAutoStart; LogFileCheckBox->Checked=MainForm->MailLogFile; @@ -94,42 +98,73 @@ void __fastcall TMailCfgDlg::FormShow(TO =!(MainForm->mail_startup.options&MAIL_OPT_NO_HOST_LOOKUP); RelayServerEdit->Text=AnsiString(MainForm->mail_startup.relay_server); + RelayAuthNameEdit->Text=AnsiString(MainForm->mail_startup.relay_user); + RelayAuthPassEdit->Text=AnsiString(MainForm->mail_startup.relay_pass); SMTPPortEdit->Text=AnsiString(MainForm->mail_startup.smtp_port); POP3PortEdit->Text=AnsiString(MainForm->mail_startup.pop3_port); RelayPortEdit->Text=AnsiString(MainForm->mail_startup.relay_port); DNSServerEdit->Text=AnsiString(MainForm->mail_startup.dns_server); InboundSoundEdit->Text=AnsiString(MainForm->mail_startup.inbound_sound); OutboundSoundEdit->Text=AnsiString(MainForm->mail_startup.outbound_sound); + POP3SoundEdit->Text=AnsiString(MainForm->mail_startup.pop3_sound); DeliveryAttemptsEdit->Text =AnsiString(MainForm->mail_startup.max_delivery_attempts); RescanFreqEdit->Text=AnsiString(MainForm->mail_startup.rescan_frequency); + DefaultUserEdit->Text=AnsiString(MainForm->mail_startup.default_user); + BLSubjectEdit->Text=AnsiString(MainForm->mail_startup.dnsbl_tag); + BLHeaderEdit->Text=AnsiString(MainForm->mail_startup.dnsbl_hdr); DebugTXCheckBox->Checked=MainForm->mail_startup.options &MAIL_OPT_DEBUG_TX; + DebugRXCheckBox->Checked=MainForm->mail_startup.options + &MAIL_OPT_DEBUG_RX_RSP; DebugHeadersCheckBox->Checked=MainForm->mail_startup.options &MAIL_OPT_DEBUG_RX_HEADER; + NotifyCheckBox->Checked + =!(MainForm->mail_startup.options&MAIL_OPT_NO_NOTIFY); POP3EnabledCheckBox->Checked=MainForm->mail_startup.options &MAIL_OPT_ALLOW_POP3; POP3LogCheckBox->Checked=MainForm->mail_startup.options &MAIL_OPT_DEBUG_POP3; RelayRadioButton->Checked=MainForm->mail_startup.options &MAIL_OPT_RELAY_TX; + RelayAuthPlainRadioButton->Checked=MainForm->mail_startup.options + &MAIL_OPT_RELAY_AUTH_PLAIN; + RelayAuthLoginRadioButton->Checked=MainForm->mail_startup.options + &MAIL_OPT_RELAY_AUTH_LOGIN; + RelayAuthCramMD5RadioButton->Checked=MainForm->mail_startup.options + &MAIL_OPT_RELAY_AUTH_CRAM_MD5; + +#if 0 /* this is a stupid option */ UserNumberCheckBox->Checked=MainForm->mail_startup.options &MAIL_OPT_ALLOW_RX_BY_NUMBER; - RBLCheckBox->Checked=MainForm->mail_startup.options - &MAIL_OPT_USE_RBL; - DULCheckBox->Checked=MainForm->mail_startup.options - &MAIL_OPT_USE_DUL; - RSSCheckBox->Checked=MainForm->mail_startup.options - &MAIL_OPT_USE_RSS; +#endif + AllowRelayCheckBox->Checked=MainForm->mail_startup.options + &MAIL_OPT_ALLOW_RELAY; + AuthViaIpCheckBox->Checked=MainForm->mail_startup.options + &MAIL_OPT_SMTP_AUTH_VIA_IP; + if(MainForm->mail_startup.options&MAIL_OPT_DNSBL_REFUSE) + BLRefuseRadioButton->Checked=true; + else if(MainForm->mail_startup.options&MAIL_OPT_DNSBL_BADUSER) + BLBadUserRadioButton->Checked=true; + else if(MainForm->mail_startup.options&MAIL_OPT_DNSBL_IGNORE) + BLIgnoreRadioButton->Checked=true; + else + BLTagRadioButton->Checked=true; + BLDebugCheckBox->Checked=MainForm->mail_startup.options + &MAIL_OPT_DNSBL_DEBUG; + TcpDnsCheckBox->Checked=MainForm->mail_startup.options &MAIL_OPT_USE_TCP_DNS; SendMailCheckBox->Checked= !(MainForm->mail_startup.options&MAIL_OPT_NO_SENDMAIL); + DNSBLRadioButtonClick(Sender); DNSRadioButtonClick(Sender); POP3EnabledCheckBoxClick(Sender); SendMailCheckBoxClick(Sender); + AllowRelayCheckBoxClick(Sender); + RelayAuthRadioButtonClick(Sender); PageControl->ActivePage=GeneralTabSheet; } //--------------------------------------------------------------------------- @@ -139,8 +174,7 @@ void __fastcall TMailCfgDlg::OKBtnClick( char str[128],*p; DWORD addr; - sprintf(str,"%.*s",sizeof(str)-1 - ,NetworkInterfaceEdit->Text.c_str()); + SAFECOPY(str,NetworkInterfaceEdit->Text.c_str()); p=str; while(*p && *p<=' ') p++; if(*p && isdigit(*p)) { @@ -163,34 +197,58 @@ void __fastcall TMailCfgDlg::OKBtnClick( MainForm->mail_startup.relay_port=RelayPortEdit->Text.ToIntDef(25); MainForm->mail_startup.max_clients=MaxClientsEdit->Text.ToIntDef(10); MainForm->mail_startup.max_inactivity=MaxInactivityEdit->Text.ToIntDef(120); + MainForm->mail_startup.max_recipients=MaxRecipientsEdit->Text.ToIntDef(100); + MainForm->mail_startup.max_msg_size + =MaxMsgSizeEdit->Text.ToIntDef(MainForm->mail_startup.max_msg_size); MainForm->mail_startup.max_delivery_attempts =DeliveryAttemptsEdit->Text.ToIntDef(10); MainForm->mail_startup.rescan_frequency=RescanFreqEdit->Text.ToIntDef(300); + MainForm->mail_startup.lines_per_yield=LinesPerYieldEdit->Text.ToIntDef(10); - sprintf(MainForm->mail_startup.dns_server,"%.*s" - ,sizeof(MainForm->mail_startup.dns_server)-1 + SAFECOPY(MainForm->mail_startup.default_user + ,DefaultUserEdit->Text.c_str()); + SAFECOPY(MainForm->mail_startup.dns_server ,DNSServerEdit->Text.c_str()); - sprintf(MainForm->mail_startup.relay_server,"%.*s" - ,sizeof(MainForm->mail_startup.relay_server)-1 + SAFECOPY(MainForm->mail_startup.relay_server ,RelayServerEdit->Text.c_str()); - sprintf(MainForm->mail_startup.inbound_sound,"%.*s" - ,sizeof(MainForm->mail_startup.inbound_sound)-1 + SAFECOPY(MainForm->mail_startup.relay_user + ,RelayAuthNameEdit->Text.c_str()); + SAFECOPY(MainForm->mail_startup.relay_pass + ,RelayAuthPassEdit->Text.c_str()); + SAFECOPY(MainForm->mail_startup.inbound_sound ,InboundSoundEdit->Text.c_str()); - sprintf(MainForm->mail_startup.outbound_sound,"%.*s" - ,sizeof(MainForm->mail_startup.outbound_sound)-1 + SAFECOPY(MainForm->mail_startup.outbound_sound ,OutboundSoundEdit->Text.c_str()); - sprintf(MainForm->mail_startup.pop3_sound,"%.*s" - ,sizeof(MainForm->mail_startup.pop3_sound)-1 + SAFECOPY(MainForm->mail_startup.pop3_sound ,POP3SoundEdit->Text.c_str()); + SAFECOPY(MainForm->mail_startup.dnsbl_tag + ,BLSubjectEdit->Text.c_str()); + SAFECOPY(MainForm->mail_startup.dnsbl_hdr + ,BLHeaderEdit->Text.c_str()); if(RelayRadioButton->Checked==true) MainForm->mail_startup.options|=MAIL_OPT_RELAY_TX; else MainForm->mail_startup.options&=~MAIL_OPT_RELAY_TX; + MainForm->mail_startup.options&=~(MAIL_OPT_RELAY_AUTH_MASK); + if(RelayAuthLoginRadioButton->Checked==true) + MainForm->mail_startup.options|=MAIL_OPT_RELAY_AUTH_LOGIN; + else if(RelayAuthPlainRadioButton->Checked==true) + MainForm->mail_startup.options|=MAIL_OPT_RELAY_AUTH_PLAIN; + else if(RelayAuthCramMD5RadioButton->Checked==true) + MainForm->mail_startup.options|=MAIL_OPT_RELAY_AUTH_CRAM_MD5; if(DebugTXCheckBox->Checked==true) MainForm->mail_startup.options|=MAIL_OPT_DEBUG_TX; else MainForm->mail_startup.options&=~MAIL_OPT_DEBUG_TX; + if(DebugRXCheckBox->Checked==true) + MainForm->mail_startup.options|=MAIL_OPT_DEBUG_RX_RSP; + else + MainForm->mail_startup.options&=~MAIL_OPT_DEBUG_RX_RSP; + if(NotifyCheckBox->Checked==false) + MainForm->mail_startup.options|=MAIL_OPT_NO_NOTIFY; + else + MainForm->mail_startup.options&=~MAIL_OPT_NO_NOTIFY; if(DebugHeadersCheckBox->Checked==true) MainForm->mail_startup.options|=MAIL_OPT_DEBUG_RX_HEADER; else @@ -203,22 +261,35 @@ void __fastcall TMailCfgDlg::OKBtnClick( MainForm->mail_startup.options|=MAIL_OPT_DEBUG_POP3; else MainForm->mail_startup.options&=~MAIL_OPT_DEBUG_POP3; +#if 0 /* this is a stupid option */ if(UserNumberCheckBox->Checked==true) MainForm->mail_startup.options|=MAIL_OPT_ALLOW_RX_BY_NUMBER; else MainForm->mail_startup.options&=~MAIL_OPT_ALLOW_RX_BY_NUMBER; - if(RBLCheckBox->Checked==true) - MainForm->mail_startup.options|=MAIL_OPT_USE_RBL; - else - MainForm->mail_startup.options&=~MAIL_OPT_USE_RBL; - if(DULCheckBox->Checked==true) - MainForm->mail_startup.options|=MAIL_OPT_USE_DUL; - else - MainForm->mail_startup.options&=~MAIL_OPT_USE_DUL; - if(RSSCheckBox->Checked==true) - MainForm->mail_startup.options|=MAIL_OPT_USE_RSS; +#endif + if(AllowRelayCheckBox->Checked==true) + MainForm->mail_startup.options|=MAIL_OPT_ALLOW_RELAY; + else + MainForm->mail_startup.options&=~MAIL_OPT_ALLOW_RELAY; + if(AuthViaIpCheckBox->Checked==true) + MainForm->mail_startup.options|=MAIL_OPT_SMTP_AUTH_VIA_IP; + else + MainForm->mail_startup.options&=~MAIL_OPT_SMTP_AUTH_VIA_IP; + + /* DNSBL */ + MainForm->mail_startup.options&= + ~(MAIL_OPT_DNSBL_IGNORE|MAIL_OPT_DNSBL_REFUSE|MAIL_OPT_DNSBL_BADUSER); + if(BLIgnoreRadioButton->Checked==true) + MainForm->mail_startup.options|=MAIL_OPT_DNSBL_IGNORE; + else if(BLRefuseRadioButton->Checked==true) + MainForm->mail_startup.options|=MAIL_OPT_DNSBL_REFUSE; + else if(BLBadUserRadioButton->Checked==true) + MainForm->mail_startup.options|=MAIL_OPT_DNSBL_BADUSER; + if(BLDebugCheckBox->Checked==true) + MainForm->mail_startup.options|=MAIL_OPT_DNSBL_DEBUG; else - MainForm->mail_startup.options&=~MAIL_OPT_USE_RSS; + MainForm->mail_startup.options&=~MAIL_OPT_DNSBL_DEBUG; + if(HostnameCheckBox->Checked==false) MainForm->mail_startup.options|=MAIL_OPT_NO_HOST_LOOKUP; else @@ -252,11 +323,13 @@ void __fastcall TMailCfgDlg::POP3SoundBu void __fastcall TMailCfgDlg::DNSRadioButtonClick(TObject *Sender) { - RelayServerEdit->Enabled=RelayRadioButton->Checked; - RelayPortEdit->Enabled=RelayRadioButton->Checked; - RelayPortLabel->Enabled=RelayRadioButton->Checked; - DNSServerEdit->Enabled=!RelayRadioButton->Checked; - TcpDnsCheckBox->Enabled=!RelayRadioButton->Checked; + bool checked = RelayRadioButton->Checked && SendMailCheckBox->Checked; + RelayTabSheet->TabVisible=checked; + RelayPortEdit->Enabled=checked; + RelayPortLabel->Enabled=checked; + DNSServerEdit->Enabled=!checked; + DNSServerLabel->Enabled=!checked; + TcpDnsCheckBox->Enabled=!checked; } //--------------------------------------------------------------------------- @@ -284,15 +357,65 @@ void __fastcall TMailCfgDlg::SendMailChe DNSServerEdit->Enabled=checked; TcpDnsCheckBox->Enabled=checked; RelayRadioButton->Enabled=checked; - RelayServerEdit->Enabled=checked; - RelayPortEdit->Enabled=checked; - RelayPortLabel->Enabled=checked; OutboundSoundEdit->Enabled=checked; OutboundSoundLabel->Enabled=checked; OutboundSoundButton->Enabled=checked; - if(checked) - DNSRadioButtonClick(Sender); + DNSRadioButtonClick(Sender); +} +//--------------------------------------------------------------------------- + + +void __fastcall TMailCfgDlg::DNSBLRadioButtonClick(TObject *Sender) +{ + BLSubjectEdit->Enabled=BLTagRadioButton->Checked; + BLHeaderEdit->Enabled=BLTagRadioButton->Checked; + BLSubjectLabel->Enabled=BLTagRadioButton->Checked; + BLHeaderLabel->Enabled=BLTagRadioButton->Checked; +} +//--------------------------------------------------------------------------- + +void __fastcall TMailCfgDlg::DNSBLServersButtonClick(TObject *Sender) +{ + char filename[MAX_PATH+1]; + + sprintf(filename,"%sdns_blacklist.cfg",MainForm->cfg.ctrl_dir); + Application->CreateForm(__classid(TTextFileEditForm), &TextFileEditForm); + TextFileEditForm->Filename=AnsiString(filename); + TextFileEditForm->Caption="Services Configuration"; + TextFileEditForm->ShowModal(); + delete TextFileEditForm; +} +//--------------------------------------------------------------------------- + + +void __fastcall TMailCfgDlg::DNSBLExemptionsButtonClick(TObject *Sender) +{ + char filename[MAX_PATH+1]; + + sprintf(filename,"%sdnsbl_exempt.cfg",MainForm->cfg.ctrl_dir); + Application->CreateForm(__classid(TTextFileEditForm), &TextFileEditForm); + TextFileEditForm->Filename=AnsiString(filename); + TextFileEditForm->Caption="Services Configuration"; + TextFileEditForm->ShowModal(); + delete TextFileEditForm; +} +//--------------------------------------------------------------------------- + +void __fastcall TMailCfgDlg::AllowRelayCheckBoxClick(TObject *Sender) +{ + AuthViaIpCheckBox->Enabled=AllowRelayCheckBox->Checked; +} +//--------------------------------------------------------------------------- + +void __fastcall TMailCfgDlg::RelayAuthRadioButtonClick(TObject *Sender) +{ + bool enabled = !RelayAuthNoneRadioButton->Checked; + + RelayAuthNameEdit->Enabled=enabled; + RelayAuthPassEdit->Enabled=enabled; + RelayAuthNameLabel->Enabled=enabled; + RelayAuthPassLabel->Enabled=enabled; } //---------------------------------------------------------------------------