Annotation of sbbs/sbbs3/ctrl/mailcfgdlgunit.cpp, revision 1.1

1.1     ! root        1: /* Synchronet Control Panel (GUI Borland C++ Builder Project for Win32) */
        !             2: 
        !             3: /* $Id: MailCfgDlgUnit.cpp,v 1.5 2000/11/17 04:31:18 rswindell Exp $ */
        !             4: 
        !             5: /****************************************************************************
        !             6:  * @format.tab-size 4          (Plain Text/Source Code File Header)                    *
        !             7:  * @format.use-tabs true       (see http://www.synchro.net/ptsc_hdr.html)              *
        !             8:  *                                                                                                                                                     *
        !             9:  * Copyright 2000 Rob Swindell - http://www.synchro.net/copyright.html         *
        !            10:  *                                                                                                                                                     *
        !            11:  * This program is free software; you can redistribute it and/or                       *
        !            12:  * modify it under the terms of the GNU General Public License                         *
        !            13:  * as published by the Free Software Foundation; either version 2                      *
        !            14:  * of the License, or (at your option) any later version.                                      *
        !            15:  * See the GNU General Public License for more details: gpl.txt or                     *
        !            16:  * http://www.fsf.org/copyleft/gpl.html                                                                                *
        !            17:  *                                                                                                                                                     *
        !            18:  * Anonymous FTP access to the most recent released source is available at     *
        !            19:  * ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net     *
        !            20:  *                                                                                                                                                     *
        !            21:  * Anonymous CVS access to the development source and modification history     *
        !            22:  * is available at cvs.synchro.net:/cvsroot/sbbs, example:                                     *
        !            23:  * cvs -d :pserver:[email protected]:/cvsroot/sbbs login                       *
        !            24:  *     (just hit return, no password is necessary)                                                     *
        !            25:  * cvs -d :pserver:[email protected]:/cvsroot/sbbs checkout src                *
        !            26:  *                                                                                                                                                     *
        !            27:  * For Synchronet coding style and modification guidelines, see                                *
        !            28:  * http://www.synchro.net/source.html                                                                          *
        !            29:  *                                                                                                                                                     *
        !            30:  * You are encouraged to submit any modifications (preferably in Unix diff     *
        !            31:  * format) via e-mail to [email protected]                                                                      *
        !            32:  *                                                                                                                                                     *
        !            33:  * Note: If this box doesn't appear square, then you need to fix your tabs.    *
        !            34:  ****************************************************************************/
        !            35: 
        !            36: //---------------------------------------------------------------------
        !            37: #include <vcl.h>
        !            38: #pragma hdrstop
        !            39: 
        !            40: #include "MainFormUnit.h"
        !            41: #include "MailCfgDlgUnit.h"
        !            42: #include <stdio.h>                     // sprintf()
        !            43: #include <mmsystem.h>          // sndPlaySound()
        !            44: //---------------------------------------------------------------------
        !            45: #pragma resource "*.dfm"
        !            46: TMailCfgDlg *MailCfgDlg;
        !            47: //---------------------------------------------------------------------
        !            48: __fastcall TMailCfgDlg::TMailCfgDlg(TComponent* AOwner)
        !            49:        : TForm(AOwner)
        !            50: {
        !            51: }
        !            52: //---------------------------------------------------------------------
        !            53: void __fastcall TMailCfgDlg::InboundSoundButtonClick(TObject *Sender)
        !            54: {
        !            55:        OpenDialog->FileName=InboundSoundEdit->Text;
        !            56:        if(OpenDialog->Execute()==true) {
        !            57:        InboundSoundEdit->Text=OpenDialog->FileName;
        !            58:         sndPlaySound(OpenDialog->FileName.c_str(),SND_ASYNC);
        !            59:     }
        !            60: }
        !            61: //---------------------------------------------------------------------------
        !            62: 
        !            63: void __fastcall TMailCfgDlg::OutboundSoundButtonClick(TObject *Sender)
        !            64: {
        !            65:        OpenDialog->FileName=OutboundSoundEdit->Text;
        !            66:        if(OpenDialog->Execute()==true) {
        !            67:        OutboundSoundEdit->Text=OpenDialog->FileName;
        !            68:         sndPlaySound(OpenDialog->FileName.c_str(),SND_ASYNC);
        !            69:        }
        !            70: }
        !            71: //---------------------------------------------------------------------------
        !            72: 
        !            73: void __fastcall TMailCfgDlg::FormShow(TObject *Sender)
        !            74: {
        !            75:     char str[128];
        !            76: 
        !            77:     if(MainForm->mail_startup.interface_addr==0)
        !            78:         NetworkInterfaceEdit->Text="<ANY>";
        !            79:     else {
        !            80:         sprintf(str,"%d.%d.%d.%d"
        !            81:             ,(MainForm->mail_startup.interface_addr>>24)&0xff
        !            82:             ,(MainForm->mail_startup.interface_addr>>16)&0xff
        !            83:             ,(MainForm->mail_startup.interface_addr>>8)&0xff
        !            84:             ,MainForm->mail_startup.interface_addr&0xff
        !            85:         );
        !            86:         NetworkInterfaceEdit->Text=AnsiString(str);
        !            87:     }
        !            88:     MaxClientsEdit->Text=AnsiString(MainForm->mail_startup.max_clients);
        !            89:     MaxInactivityEdit->Text=AnsiString(MainForm->mail_startup.max_inactivity);
        !            90: 
        !            91:     AutoStartCheckBox->Checked=MainForm->MailAutoStart;
        !            92:     LogFileCheckBox->Checked=MainForm->MailLogFile;
        !            93:     HostnameCheckBox->Checked
        !            94:         =!(MainForm->mail_startup.options&MAIL_OPT_NO_HOST_LOOKUP);
        !            95: 
        !            96:     RelayServerEdit->Text=AnsiString(MainForm->mail_startup.relay_server);
        !            97:     SMTPPortEdit->Text=AnsiString(MainForm->mail_startup.smtp_port);
        !            98:     POP3PortEdit->Text=AnsiString(MainForm->mail_startup.pop3_port);
        !            99:     RelayPortEdit->Text=AnsiString(MainForm->mail_startup.relay_port);
        !           100:     DNSServerEdit->Text=AnsiString(MainForm->mail_startup.dns_server);
        !           101:     InboundSoundEdit->Text=AnsiString(MainForm->mail_startup.inbound_sound);
        !           102:     OutboundSoundEdit->Text=AnsiString(MainForm->mail_startup.outbound_sound);
        !           103:     DeliveryAttemptsEdit->Text
        !           104:         =AnsiString(MainForm->mail_startup.max_delivery_attempts);
        !           105:     RescanFreqEdit->Text=AnsiString(MainForm->mail_startup.rescan_frequency);
        !           106: 
        !           107:     DebugTXCheckBox->Checked=MainForm->mail_startup.options
        !           108:         &MAIL_OPT_DEBUG_TX;
        !           109:     DebugHeadersCheckBox->Checked=MainForm->mail_startup.options
        !           110:         &MAIL_OPT_DEBUG_RX_HEADER;
        !           111:     POP3EnabledCheckBox->Checked=MainForm->mail_startup.options
        !           112:         &MAIL_OPT_ALLOW_POP3;
        !           113:     POP3LogCheckBox->Checked=MainForm->mail_startup.options
        !           114:         &MAIL_OPT_DEBUG_POP3;
        !           115:     RelayRadioButton->Checked=MainForm->mail_startup.options
        !           116:        &MAIL_OPT_RELAY_TX;
        !           117:     UserNumberCheckBox->Checked=MainForm->mail_startup.options
        !           118:        &MAIL_OPT_ALLOW_RX_BY_NUMBER;
        !           119:     RBLCheckBox->Checked=MainForm->mail_startup.options
        !           120:        &MAIL_OPT_USE_RBL;
        !           121:     DULCheckBox->Checked=MainForm->mail_startup.options
        !           122:        &MAIL_OPT_USE_DUL;
        !           123:     RSSCheckBox->Checked=MainForm->mail_startup.options
        !           124:        &MAIL_OPT_USE_RSS;
        !           125:     TcpDnsCheckBox->Checked=MainForm->mail_startup.options
        !           126:        &MAIL_OPT_USE_TCP_DNS;
        !           127:     SendMailCheckBox->Checked=
        !           128:         !(MainForm->mail_startup.options&MAIL_OPT_NO_SENDMAIL);
        !           129: 
        !           130:     DNSRadioButtonClick(Sender);
        !           131:        POP3EnabledCheckBoxClick(Sender);
        !           132:     SendMailCheckBoxClick(Sender);
        !           133:     PageControl->ActivePage=GeneralTabSheet;
        !           134: }
        !           135: //---------------------------------------------------------------------------
        !           136: 
        !           137: void __fastcall TMailCfgDlg::OKBtnClick(TObject *Sender)
        !           138: {
        !           139:     char    str[128],*p;
        !           140:     DWORD   addr;
        !           141: 
        !           142:     sprintf(str,"%.*s",sizeof(str)-1
        !           143:         ,NetworkInterfaceEdit->Text.c_str());
        !           144:     p=str;
        !           145:     while(*p && *p<=' ') p++;
        !           146:     if(*p && isdigit(*p)) {
        !           147:         addr=atoi(p)<<24;
        !           148:         while(*p && *p!='.') p++;
        !           149:         if(*p=='.') p++;
        !           150:         addr|=atoi(p)<<16;
        !           151:         while(*p && *p!='.') p++;
        !           152:         if(*p=='.') p++;
        !           153:         addr|=atoi(p)<<8;
        !           154:         while(*p && *p!='.') p++;
        !           155:         if(*p=='.') p++;
        !           156:         addr|=atoi(p);
        !           157:         MainForm->mail_startup.interface_addr=addr;
        !           158:     } else
        !           159:         MainForm->mail_startup.interface_addr=0;
        !           160: 
        !           161:        MainForm->mail_startup.smtp_port=SMTPPortEdit->Text.ToIntDef(25);
        !           162:     MainForm->mail_startup.pop3_port=POP3PortEdit->Text.ToIntDef(110);
        !           163:     MainForm->mail_startup.relay_port=RelayPortEdit->Text.ToIntDef(25);
        !           164:     MainForm->mail_startup.max_clients=MaxClientsEdit->Text.ToIntDef(10);
        !           165:     MainForm->mail_startup.max_inactivity=MaxInactivityEdit->Text.ToIntDef(120);
        !           166:     MainForm->mail_startup.max_delivery_attempts
        !           167:         =DeliveryAttemptsEdit->Text.ToIntDef(10);
        !           168:     MainForm->mail_startup.rescan_frequency=RescanFreqEdit->Text.ToIntDef(300);
        !           169: 
        !           170:     sprintf(MainForm->mail_startup.dns_server,"%.*s"
        !           171:            ,sizeof(MainForm->mail_startup.dns_server)-1
        !           172:         ,DNSServerEdit->Text.c_str());
        !           173:     sprintf(MainForm->mail_startup.relay_server,"%.*s"
        !           174:            ,sizeof(MainForm->mail_startup.relay_server)-1
        !           175:         ,RelayServerEdit->Text.c_str());
        !           176:     sprintf(MainForm->mail_startup.inbound_sound,"%.*s"
        !           177:            ,sizeof(MainForm->mail_startup.inbound_sound)-1
        !           178:         ,InboundSoundEdit->Text.c_str());
        !           179:     sprintf(MainForm->mail_startup.outbound_sound,"%.*s"
        !           180:            ,sizeof(MainForm->mail_startup.outbound_sound)-1
        !           181:         ,OutboundSoundEdit->Text.c_str());
        !           182:     sprintf(MainForm->mail_startup.pop3_sound,"%.*s"
        !           183:            ,sizeof(MainForm->mail_startup.pop3_sound)-1
        !           184:         ,POP3SoundEdit->Text.c_str());
        !           185: 
        !           186:        if(RelayRadioButton->Checked==true)
        !           187:        MainForm->mail_startup.options|=MAIL_OPT_RELAY_TX;
        !           188:     else
        !           189:            MainForm->mail_startup.options&=~MAIL_OPT_RELAY_TX;
        !           190:        if(DebugTXCheckBox->Checked==true)
        !           191:        MainForm->mail_startup.options|=MAIL_OPT_DEBUG_TX;
        !           192:     else
        !           193:            MainForm->mail_startup.options&=~MAIL_OPT_DEBUG_TX;
        !           194:        if(DebugHeadersCheckBox->Checked==true)
        !           195:        MainForm->mail_startup.options|=MAIL_OPT_DEBUG_RX_HEADER;
        !           196:     else
        !           197:            MainForm->mail_startup.options&=~MAIL_OPT_DEBUG_RX_HEADER;
        !           198:        if(POP3EnabledCheckBox->Checked==true)
        !           199:        MainForm->mail_startup.options|=MAIL_OPT_ALLOW_POP3;
        !           200:     else
        !           201:            MainForm->mail_startup.options&=~MAIL_OPT_ALLOW_POP3;
        !           202:        if(POP3LogCheckBox->Checked==true)
        !           203:        MainForm->mail_startup.options|=MAIL_OPT_DEBUG_POP3;
        !           204:     else
        !           205:            MainForm->mail_startup.options&=~MAIL_OPT_DEBUG_POP3;
        !           206:        if(UserNumberCheckBox->Checked==true)
        !           207:        MainForm->mail_startup.options|=MAIL_OPT_ALLOW_RX_BY_NUMBER;
        !           208:     else
        !           209:            MainForm->mail_startup.options&=~MAIL_OPT_ALLOW_RX_BY_NUMBER;
        !           210:        if(RBLCheckBox->Checked==true)
        !           211:        MainForm->mail_startup.options|=MAIL_OPT_USE_RBL;
        !           212:     else
        !           213:            MainForm->mail_startup.options&=~MAIL_OPT_USE_RBL;
        !           214:        if(DULCheckBox->Checked==true)
        !           215:        MainForm->mail_startup.options|=MAIL_OPT_USE_DUL;
        !           216:     else
        !           217:            MainForm->mail_startup.options&=~MAIL_OPT_USE_DUL;
        !           218:        if(RSSCheckBox->Checked==true)
        !           219:        MainForm->mail_startup.options|=MAIL_OPT_USE_RSS;
        !           220:     else
        !           221:            MainForm->mail_startup.options&=~MAIL_OPT_USE_RSS;
        !           222:        if(HostnameCheckBox->Checked==false)
        !           223:        MainForm->mail_startup.options|=MAIL_OPT_NO_HOST_LOOKUP;
        !           224:     else
        !           225:            MainForm->mail_startup.options&=~MAIL_OPT_NO_HOST_LOOKUP;
        !           226:        if(TcpDnsCheckBox->Checked==true)
        !           227:        MainForm->mail_startup.options|=MAIL_OPT_USE_TCP_DNS;
        !           228:     else
        !           229:            MainForm->mail_startup.options&=~MAIL_OPT_USE_TCP_DNS;
        !           230:     if(SendMailCheckBox->Checked==false)
        !           231:         MainForm->mail_startup.options|=MAIL_OPT_NO_SENDMAIL;
        !           232:     else
        !           233:         MainForm->mail_startup.options&=~MAIL_OPT_NO_SENDMAIL;
        !           234: 
        !           235:     MainForm->MailAutoStart=AutoStartCheckBox->Checked;
        !           236:     MainForm->MailLogFile=LogFileCheckBox->Checked;
        !           237: 
        !           238:     MainForm->SaveSettings(Sender);
        !           239: }
        !           240: //---------------------------------------------------------------------------
        !           241: 
        !           242: 
        !           243: void __fastcall TMailCfgDlg::POP3SoundButtonClick(TObject *Sender)
        !           244: {
        !           245:        OpenDialog->FileName=POP3SoundEdit->Text;
        !           246:        if(OpenDialog->Execute()==true) {
        !           247:        POP3SoundEdit->Text=OpenDialog->FileName;
        !           248:         sndPlaySound(OpenDialog->FileName.c_str(),SND_ASYNC);
        !           249:     }
        !           250: }
        !           251: //---------------------------------------------------------------------------
        !           252: 
        !           253: void __fastcall TMailCfgDlg::DNSRadioButtonClick(TObject *Sender)
        !           254: {
        !           255:     RelayServerEdit->Enabled=RelayRadioButton->Checked;
        !           256:     RelayPortEdit->Enabled=RelayRadioButton->Checked;
        !           257:     RelayPortLabel->Enabled=RelayRadioButton->Checked;
        !           258:     DNSServerEdit->Enabled=!RelayRadioButton->Checked;
        !           259:     TcpDnsCheckBox->Enabled=!RelayRadioButton->Checked;
        !           260: }
        !           261: //---------------------------------------------------------------------------
        !           262: 
        !           263: void __fastcall TMailCfgDlg::POP3EnabledCheckBoxClick(TObject *Sender)
        !           264: {
        !           265:        POP3PortEdit->Enabled=POP3EnabledCheckBox->Checked;
        !           266:     POP3PortLabel->Enabled=POP3EnabledCheckBox->Checked;
        !           267:     POP3SoundEdit->Enabled=POP3EnabledCheckBox->Checked;
        !           268:     POP3SoundLabel->Enabled=POP3EnabledCheckBox->Checked;
        !           269:     POP3SoundButton->Enabled=POP3EnabledCheckBox->Checked;
        !           270:     POP3LogCheckBox->Enabled=POP3EnabledCheckBox->Checked;
        !           271: }
        !           272: //---------------------------------------------------------------------------
        !           273: 
        !           274: 
        !           275: void __fastcall TMailCfgDlg::SendMailCheckBoxClick(TObject *Sender)
        !           276: {
        !           277:     bool checked=SendMailCheckBox->Checked;
        !           278: 
        !           279:     DeliveryAttemptsEdit->Enabled=checked;
        !           280:     DeliveryAttemptsLabel->Enabled=checked;
        !           281:     RescanFreqEdit->Enabled=checked;
        !           282:     RescanFreqLabel->Enabled=checked;
        !           283:     DNSRadioButton->Enabled=checked;
        !           284:     DNSServerEdit->Enabled=checked;
        !           285:     TcpDnsCheckBox->Enabled=checked;
        !           286:     RelayRadioButton->Enabled=checked;
        !           287:     RelayServerEdit->Enabled=checked;
        !           288:     RelayPortEdit->Enabled=checked;
        !           289:     RelayPortLabel->Enabled=checked;
        !           290:     OutboundSoundEdit->Enabled=checked;
        !           291:     OutboundSoundLabel->Enabled=checked;
        !           292:     OutboundSoundButton->Enabled=checked;
        !           293: 
        !           294:     if(checked)
        !           295:         DNSRadioButtonClick(Sender);
        !           296: }
        !           297: //---------------------------------------------------------------------------
        !           298: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.