Annotation of sbbs/src/sbbs3/ctrl/ftpcfgdlgunit.cpp, revision 1.1.1.1

1.1       root        1: /* Synchronet Control Panel (GUI Borland C++ Builder Project for Win32) */
                      2: 
                      3: /* $Id: FtpCfgDlgUnit.cpp,v 1.10 2006/05/10 22:25:43 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 2006 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 "FtpCfgDlgUnit.h"
                     42: #include "TextFileEditUnit.h"
                     43: #include <stdio.h>                     // sprintf()
                     44: #include <mmsystem.h>          // sndPlaySound()
                     45: //---------------------------------------------------------------------
                     46: #pragma resource "*.dfm"
                     47: TFtpCfgDlg *FtpCfgDlg;
                     48: //---------------------------------------------------------------------
                     49: __fastcall TFtpCfgDlg::TFtpCfgDlg(TComponent* AOwner)
                     50:        : TForm(AOwner)
                     51: {
                     52: }
                     53: //---------------------------------------------------------------------
                     54: void __fastcall TFtpCfgDlg::FormShow(TObject *Sender)
                     55: {
                     56:     char str[128];
                     57: 
                     58:     if(MainForm->ftp_startup.interface_addr==0)
                     59:         NetworkInterfaceEdit->Text="<ANY>";
                     60:     else {
                     61:         sprintf(str,"%d.%d.%d.%d"
                     62:             ,(MainForm->ftp_startup.interface_addr>>24)&0xff
                     63:             ,(MainForm->ftp_startup.interface_addr>>16)&0xff
                     64:             ,(MainForm->ftp_startup.interface_addr>>8)&0xff
                     65:             ,MainForm->ftp_startup.interface_addr&0xff
                     66:         );
                     67:         NetworkInterfaceEdit->Text=AnsiString(str);
                     68:     }
                     69:     if(MainForm->ftp_startup.pasv_ip_addr==0)
                     70:         PasvIpAddrEdit->Text="<unspecified>";
                     71:     else {
                     72:         sprintf(str,"%d.%d.%d.%d"
                     73:             ,(MainForm->ftp_startup.pasv_ip_addr>>24)&0xff
                     74:             ,(MainForm->ftp_startup.pasv_ip_addr>>16)&0xff
                     75:             ,(MainForm->ftp_startup.pasv_ip_addr>>8)&0xff
                     76:             ,MainForm->ftp_startup.pasv_ip_addr&0xff
                     77:         );
                     78:         PasvIpAddrEdit->Text=AnsiString(str);
                     79:     }
                     80: 
                     81:     MaxClientsEdit->Text=AnsiString((int)MainForm->ftp_startup.max_clients);
                     82:     MaxInactivityEdit->Text=AnsiString((int)MainForm->ftp_startup.max_inactivity);
                     83:     QwkTimeoutEdit->Text=AnsiString((int)MainForm->ftp_startup.qwk_timeout);
                     84:        PortEdit->Text=AnsiString((int)MainForm->ftp_startup.port);
                     85:     AutoStartCheckBox->Checked=MainForm->FtpAutoStart;
                     86:     LogFileCheckBox->Checked=MainForm->FtpLogFile;
                     87: 
                     88:     PasvIpLookupCheckBox->Checked=MainForm->ftp_startup.options&FTP_OPT_LOOKUP_PASV_IP;
                     89:        PasvPortLowEdit->Text=AnsiString((int)MainForm->ftp_startup.pasv_port_low);
                     90:        PasvPortHighEdit->Text=AnsiString((int)MainForm->ftp_startup.pasv_port_high);
                     91: 
                     92:     IndexFileNameEdit->Text=AnsiString(MainForm->ftp_startup.index_file_name);
                     93:     HtmlFileNameEdit->Text=AnsiString(MainForm->ftp_startup.html_index_file);
                     94:     HtmlJavaScriptEdit->Text=AnsiString(MainForm->ftp_startup.html_index_script);
                     95:     AnswerSoundEdit->Text=AnsiString(MainForm->ftp_startup.answer_sound);
                     96:     HangupSoundEdit->Text=AnsiString(MainForm->ftp_startup.hangup_sound);
                     97:     HackAttemptSoundEdit->Text=AnsiString(MainForm->ftp_startup.hack_sound);    
                     98:     CmdLogCheckBox->Checked=MainForm->ftp_startup.options&FTP_OPT_DEBUG_RX;
                     99:        DebugTxCheckBox->Checked=MainForm->ftp_startup.options&FTP_OPT_DEBUG_TX;
                    100:        DebugDataCheckBox->Checked=MainForm->ftp_startup.options&FTP_OPT_DEBUG_DATA;
                    101:     DirFilesCheckBox->Checked=MainForm->ftp_startup.options&FTP_OPT_DIR_FILES;
                    102:     AllowQWKCheckBox->Checked
                    103:         =MainForm->ftp_startup.options&FTP_OPT_ALLOW_QWK;
                    104:     LocalFileSysCheckBox->Checked
                    105:         =!(MainForm->ftp_startup.options&FTP_OPT_NO_LOCAL_FSYS);
                    106:     HostnameCheckBox->Checked
                    107:         =!(MainForm->ftp_startup.options&FTP_OPT_NO_HOST_LOOKUP);
                    108:        AutoIndexCheckBox->Checked=MainForm->ftp_startup.options&FTP_OPT_INDEX_FILE;
                    109:        AutoIndexCheckBoxClick(Sender);
                    110:        HtmlIndexCheckBox->Checked
                    111:         =MainForm->ftp_startup.options&FTP_OPT_HTML_INDEX_FILE;
                    112:        HtmlIndexCheckBoxClick(Sender);
                    113:     PasvIpLookupCheckBoxClick(Sender);
                    114: 
                    115:     PageControl->ActivePage=GeneralTabSheet;
                    116: }
                    117: //---------------------------------------------------------------------------
                    118: 
                    119: void __fastcall TFtpCfgDlg::OKBtnClick(TObject *Sender)
                    120: {
                    121:     char    str[128],*p;
                    122:     DWORD   addr;
                    123: 
                    124:     SAFECOPY(str,NetworkInterfaceEdit->Text.c_str());
                    125:     p=str;
                    126:     while(*p && *p<=' ') p++;
                    127:     if(*p && isdigit(*p)) {
                    128:         addr=atoi(p)<<24;
                    129:         while(*p && *p!='.') p++;
                    130:         if(*p=='.') p++;
                    131:         addr|=atoi(p)<<16;
                    132:         while(*p && *p!='.') p++;
                    133:         if(*p=='.') p++;
                    134:         addr|=atoi(p)<<8;
                    135:         while(*p && *p!='.') p++;
                    136:         if(*p=='.') p++;
                    137:         addr|=atoi(p);
                    138:         MainForm->ftp_startup.interface_addr=addr;
                    139:     } else
                    140:         MainForm->ftp_startup.interface_addr=0;
                    141:     SAFECOPY(str,PasvIpAddrEdit->Text.c_str());
                    142:     p=str;
                    143:     while(*p && *p<=' ') p++;
                    144:     if(*p && isdigit(*p)) {
                    145:         addr=atoi(p)<<24;
                    146:         while(*p && *p!='.') p++;
                    147:         if(*p=='.') p++;
                    148:         addr|=atoi(p)<<16;
                    149:         while(*p && *p!='.') p++;
                    150:         if(*p=='.') p++;
                    151:         addr|=atoi(p)<<8;
                    152:         while(*p && *p!='.') p++;
                    153:         if(*p=='.') p++;
                    154:         addr|=atoi(p);
                    155:         MainForm->ftp_startup.pasv_ip_addr=addr;
                    156:     } else
                    157:         MainForm->ftp_startup.pasv_ip_addr=0;
                    158: 
                    159:     MainForm->ftp_startup.max_clients=MaxClientsEdit->Text.ToIntDef(10);
                    160:     MainForm->ftp_startup.max_inactivity=MaxInactivityEdit->Text.ToIntDef(300);
                    161:     MainForm->ftp_startup.qwk_timeout=QwkTimeoutEdit->Text.ToIntDef(600);
                    162:     MainForm->ftp_startup.port=PortEdit->Text.ToIntDef(23);
                    163:     MainForm->FtpAutoStart=AutoStartCheckBox->Checked;
                    164:     MainForm->FtpLogFile=LogFileCheckBox->Checked;
                    165: 
                    166:     MainForm->ftp_startup.pasv_port_low=PasvPortLowEdit->Text.ToIntDef(IPPORT_RESERVED);
                    167:     MainForm->ftp_startup.pasv_port_high=PasvPortHighEdit->Text.ToIntDef(0xffff);
                    168: 
                    169:     SAFECOPY(MainForm->ftp_startup.index_file_name
                    170:         ,IndexFileNameEdit->Text.c_str());
                    171:     SAFECOPY(MainForm->ftp_startup.html_index_file
                    172:         ,HtmlFileNameEdit->Text.c_str());
                    173:     SAFECOPY(MainForm->ftp_startup.html_index_script
                    174:         ,HtmlJavaScriptEdit->Text.c_str());
                    175: 
                    176:     SAFECOPY(MainForm->ftp_startup.answer_sound
                    177:         ,AnswerSoundEdit->Text.c_str());
                    178:     SAFECOPY(MainForm->ftp_startup.hangup_sound
                    179:         ,HangupSoundEdit->Text.c_str());
                    180:     SAFECOPY(MainForm->ftp_startup.hack_sound
                    181:         ,HackAttemptSoundEdit->Text.c_str());
                    182: 
                    183:        if(DebugTxCheckBox->Checked==true)
                    184:        MainForm->ftp_startup.options|=FTP_OPT_DEBUG_TX;
                    185:     else
                    186:            MainForm->ftp_startup.options&=~FTP_OPT_DEBUG_TX;
                    187:        if(CmdLogCheckBox->Checked==true)
                    188:        MainForm->ftp_startup.options|=FTP_OPT_DEBUG_RX;
                    189:     else
                    190:            MainForm->ftp_startup.options&=~FTP_OPT_DEBUG_RX;
                    191:        if(DebugDataCheckBox->Checked==true)
                    192:        MainForm->ftp_startup.options|=FTP_OPT_DEBUG_DATA;
                    193:     else
                    194:            MainForm->ftp_startup.options&=~FTP_OPT_DEBUG_DATA;
                    195:        if(HostnameCheckBox->Checked==false)
                    196:        MainForm->ftp_startup.options|=FTP_OPT_NO_HOST_LOOKUP;
                    197:     else
                    198:            MainForm->ftp_startup.options&=~FTP_OPT_NO_HOST_LOOKUP;
                    199:        if(AllowQWKCheckBox->Checked==true)
                    200:        MainForm->ftp_startup.options|=FTP_OPT_ALLOW_QWK;
                    201:     else
                    202:            MainForm->ftp_startup.options&=~FTP_OPT_ALLOW_QWK;
                    203:        if(DirFilesCheckBox->Checked==true)
                    204:        MainForm->ftp_startup.options|=FTP_OPT_DIR_FILES;
                    205:     else
                    206:            MainForm->ftp_startup.options&=~FTP_OPT_DIR_FILES;
                    207:        if(LocalFileSysCheckBox->Checked==false)
                    208:        MainForm->ftp_startup.options|=FTP_OPT_NO_LOCAL_FSYS;
                    209:     else
                    210:            MainForm->ftp_startup.options&=~FTP_OPT_NO_LOCAL_FSYS;
                    211:        if(AutoIndexCheckBox->Checked==true)
                    212:        MainForm->ftp_startup.options|=FTP_OPT_INDEX_FILE;
                    213:     else
                    214:            MainForm->ftp_startup.options&=~FTP_OPT_INDEX_FILE;
                    215:        if(HtmlIndexCheckBox->Checked==true)
                    216:        MainForm->ftp_startup.options|=FTP_OPT_HTML_INDEX_FILE;
                    217:     else
                    218:            MainForm->ftp_startup.options&=~FTP_OPT_HTML_INDEX_FILE;
                    219:     if(PasvIpLookupCheckBox->Checked==true)
                    220:         MainForm->ftp_startup.options|=FTP_OPT_LOOKUP_PASV_IP;
                    221:     else
                    222:         MainForm->ftp_startup.options&=~FTP_OPT_LOOKUP_PASV_IP;
                    223: 
                    224:     MainForm->SaveIniSettings(Sender);
                    225: }
                    226: //---------------------------------------------------------------------------
                    227: 
                    228: void __fastcall TFtpCfgDlg::AnswerSoundButtonClick(TObject *Sender)
                    229: {
                    230:        OpenDialog->FileName=AnswerSoundEdit->Text;
                    231:        if(OpenDialog->Execute()==true) {
                    232:        AnswerSoundEdit->Text=OpenDialog->FileName;
                    233:         sndPlaySound(OpenDialog->FileName.c_str(),SND_ASYNC);
                    234:     }
                    235: }
                    236: //---------------------------------------------------------------------------
                    237: 
                    238: void __fastcall TFtpCfgDlg::HangupSoundButtonClick(TObject *Sender)
                    239: {
                    240:        OpenDialog->FileName=HangupSoundEdit->Text;
                    241:        if(OpenDialog->Execute()==true) {
                    242:        HangupSoundEdit->Text=OpenDialog->FileName;
                    243:         sndPlaySound(OpenDialog->FileName.c_str(),SND_ASYNC);
                    244:        }
                    245: }
                    246: //---------------------------------------------------------------------------
                    247: void __fastcall TFtpCfgDlg::HackAttemptSoundButtonClick(TObject *Sender)
                    248: {
                    249:        OpenDialog->FileName=HackAttemptSoundEdit->Text;
                    250:        if(OpenDialog->Execute()==true) {
                    251:        HackAttemptSoundEdit->Text=OpenDialog->FileName;
                    252:         sndPlaySound(OpenDialog->FileName.c_str(),SND_ASYNC);
                    253:        }
                    254: }
                    255: //---------------------------------------------------------------------------
                    256: 
                    257: void __fastcall TFtpCfgDlg::AutoIndexCheckBoxClick(TObject *Sender)
                    258: {
                    259:     IndexFileNameEdit->Enabled=AutoIndexCheckBox->Checked;
                    260: }
                    261: //---------------------------------------------------------------------------
                    262: 
                    263: 
                    264: void __fastcall TFtpCfgDlg::HtmlJavaScriptButtonClick(TObject *Sender)
                    265: {
                    266:        OpenDialog->FileName=HtmlJavaScriptEdit->Text;
                    267:        if(OpenDialog->Execute()==true) {
                    268:        HtmlJavaScriptEdit->Text=OpenDialog->FileName;
                    269:        }
                    270: }
                    271: //---------------------------------------------------------------------------
                    272: 
                    273: void __fastcall TFtpCfgDlg::HtmlIndexCheckBoxClick(TObject *Sender)
                    274: {
                    275:     HtmlFileNameEdit->Enabled=HtmlIndexCheckBox->Checked;
                    276:     HtmlJavaScriptEdit->Enabled=HtmlIndexCheckBox->Checked;
                    277:     HtmlJavaScriptLabel->Enabled=HtmlIndexCheckBox->Checked;
                    278: }
                    279: //---------------------------------------------------------------------------
                    280: 
                    281: void __fastcall TFtpCfgDlg::PasvIpLookupCheckBoxClick(TObject *Sender)
                    282: {
                    283:     PasvIpAddrEdit->Enabled = !PasvIpLookupCheckBox->Checked;
                    284: }
                    285: //---------------------------------------------------------------------------
                    286: 

unix.superglobalmegacorp.com

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