|
|
1.1 root 1: /* Synchronet Control Panel (GUI Borland C++ Builder Project for Win32) */
2:
1.1.1.2 ! root 3: /* $Id: FtpCfgDlgUnit.cpp,v 1.6 2002/04/17 07:13:11 rswindell Exp $ */
1.1 root 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 "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: MaxClientsEdit->Text=AnsiString((int)MainForm->ftp_startup.max_clients);
70: MaxInactivityEdit->Text=AnsiString((int)MainForm->ftp_startup.max_inactivity);
1.1.1.2 ! root 71: QwkTimeoutEdit->Text=AnsiString((int)MainForm->ftp_startup.qwk_timeout);
1.1 root 72: PortEdit->Text=AnsiString((int)MainForm->ftp_startup.port);
73: AutoStartCheckBox->Checked=MainForm->FtpAutoStart;
74: LogFileCheckBox->Checked=MainForm->FtpLogFile;
75:
76: IndexFileNameEdit->Text=AnsiString(MainForm->ftp_startup.index_file_name);
1.1.1.2 ! root 77: HtmlFileNameEdit->Text=AnsiString(MainForm->ftp_startup.html_index_file);
! 78: HtmlJavaScriptEdit->Text=AnsiString(MainForm->ftp_startup.html_index_script);
1.1 root 79: AnswerSoundEdit->Text=AnsiString(MainForm->ftp_startup.answer_sound);
80: HangupSoundEdit->Text=AnsiString(MainForm->ftp_startup.hangup_sound);
1.1.1.2 ! root 81: HackAttemptSoundEdit->Text=AnsiString(MainForm->ftp_startup.hack_sound);
1.1 root 82: CmdLogCheckBox->Checked=MainForm->ftp_startup.options&FTP_OPT_DEBUG_RX;
83: DebugTxCheckBox->Checked=MainForm->ftp_startup.options&FTP_OPT_DEBUG_TX;
84: DebugDataCheckBox->Checked=MainForm->ftp_startup.options&FTP_OPT_DEBUG_DATA;
85: DirFilesCheckBox->Checked=MainForm->ftp_startup.options&FTP_OPT_DIR_FILES;
86: AllowQWKCheckBox->Checked
87: =MainForm->ftp_startup.options&FTP_OPT_ALLOW_QWK;
88: LocalFileSysCheckBox->Checked
89: =!(MainForm->ftp_startup.options&FTP_OPT_NO_LOCAL_FSYS);
90: HostnameCheckBox->Checked
91: =!(MainForm->ftp_startup.options&FTP_OPT_NO_HOST_LOOKUP);
92: AutoIndexCheckBox->Checked=MainForm->ftp_startup.options&FTP_OPT_INDEX_FILE;
93: AutoIndexCheckBoxClick(Sender);
1.1.1.2 ! root 94: HtmlIndexCheckBox->Checked
! 95: =MainForm->ftp_startup.options&FTP_OPT_HTML_INDEX_FILE;
! 96: HtmlIndexCheckBoxClick(Sender);
! 97:
1.1 root 98: PageControl->ActivePage=GeneralTabSheet;
99: }
100: //---------------------------------------------------------------------------
101:
102: void __fastcall TFtpCfgDlg::OKBtnClick(TObject *Sender)
103: {
104: char str[128],*p;
105: DWORD addr;
106:
1.1.1.2 ! root 107: SAFECOPY(str,NetworkInterfaceEdit->Text.c_str());
1.1 root 108: p=str;
109: while(*p && *p<=' ') p++;
110: if(*p && isdigit(*p)) {
111: addr=atoi(p)<<24;
112: while(*p && *p!='.') p++;
113: if(*p=='.') p++;
114: addr|=atoi(p)<<16;
115: while(*p && *p!='.') p++;
116: if(*p=='.') p++;
117: addr|=atoi(p)<<8;
118: while(*p && *p!='.') p++;
119: if(*p=='.') p++;
120: addr|=atoi(p);
121: MainForm->ftp_startup.interface_addr=addr;
122: } else
123: MainForm->ftp_startup.interface_addr=0;
124: MainForm->ftp_startup.max_clients=MaxClientsEdit->Text.ToIntDef(10);
125: MainForm->ftp_startup.max_inactivity=MaxInactivityEdit->Text.ToIntDef(300);
1.1.1.2 ! root 126: MainForm->ftp_startup.qwk_timeout=QwkTimeoutEdit->Text.ToIntDef(600);
1.1 root 127: MainForm->ftp_startup.port=PortEdit->Text.ToIntDef(23);
128: MainForm->FtpAutoStart=AutoStartCheckBox->Checked;
129: MainForm->FtpLogFile=LogFileCheckBox->Checked;
130:
1.1.1.2 ! root 131: SAFECOPY(MainForm->ftp_startup.index_file_name
1.1 root 132: ,IndexFileNameEdit->Text.c_str());
1.1.1.2 ! root 133: SAFECOPY(MainForm->ftp_startup.html_index_file
! 134: ,HtmlFileNameEdit->Text.c_str());
! 135: SAFECOPY(MainForm->ftp_startup.html_index_script
! 136: ,HtmlJavaScriptEdit->Text.c_str());
! 137:
! 138: SAFECOPY(MainForm->ftp_startup.answer_sound
1.1 root 139: ,AnswerSoundEdit->Text.c_str());
1.1.1.2 ! root 140: SAFECOPY(MainForm->ftp_startup.hangup_sound
1.1 root 141: ,HangupSoundEdit->Text.c_str());
1.1.1.2 ! root 142: SAFECOPY(MainForm->ftp_startup.hack_sound
! 143: ,HackAttemptSoundEdit->Text.c_str());
! 144:
1.1 root 145: if(DebugTxCheckBox->Checked==true)
146: MainForm->ftp_startup.options|=FTP_OPT_DEBUG_TX;
147: else
148: MainForm->ftp_startup.options&=~FTP_OPT_DEBUG_TX;
149: if(CmdLogCheckBox->Checked==true)
150: MainForm->ftp_startup.options|=FTP_OPT_DEBUG_RX;
151: else
152: MainForm->ftp_startup.options&=~FTP_OPT_DEBUG_RX;
153: if(DebugDataCheckBox->Checked==true)
154: MainForm->ftp_startup.options|=FTP_OPT_DEBUG_DATA;
155: else
156: MainForm->ftp_startup.options&=~FTP_OPT_DEBUG_DATA;
157: if(HostnameCheckBox->Checked==false)
158: MainForm->ftp_startup.options|=FTP_OPT_NO_HOST_LOOKUP;
159: else
160: MainForm->ftp_startup.options&=~FTP_OPT_NO_HOST_LOOKUP;
161: if(AllowQWKCheckBox->Checked==true)
162: MainForm->ftp_startup.options|=FTP_OPT_ALLOW_QWK;
163: else
164: MainForm->ftp_startup.options&=~FTP_OPT_ALLOW_QWK;
165: if(DirFilesCheckBox->Checked==true)
166: MainForm->ftp_startup.options|=FTP_OPT_DIR_FILES;
167: else
168: MainForm->ftp_startup.options&=~FTP_OPT_DIR_FILES;
169: if(LocalFileSysCheckBox->Checked==false)
170: MainForm->ftp_startup.options|=FTP_OPT_NO_LOCAL_FSYS;
171: else
172: MainForm->ftp_startup.options&=~FTP_OPT_NO_LOCAL_FSYS;
173: if(AutoIndexCheckBox->Checked==true)
174: MainForm->ftp_startup.options|=FTP_OPT_INDEX_FILE;
175: else
176: MainForm->ftp_startup.options&=~FTP_OPT_INDEX_FILE;
1.1.1.2 ! root 177: if(HtmlIndexCheckBox->Checked==true)
! 178: MainForm->ftp_startup.options|=FTP_OPT_HTML_INDEX_FILE;
! 179: else
! 180: MainForm->ftp_startup.options&=~FTP_OPT_HTML_INDEX_FILE;
1.1 root 181:
182: MainForm->SaveSettings(Sender);
183: }
184: //---------------------------------------------------------------------------
185:
186: void __fastcall TFtpCfgDlg::AnswerSoundButtonClick(TObject *Sender)
187: {
188: OpenDialog->FileName=AnswerSoundEdit->Text;
189: if(OpenDialog->Execute()==true) {
190: AnswerSoundEdit->Text=OpenDialog->FileName;
191: sndPlaySound(OpenDialog->FileName.c_str(),SND_ASYNC);
192: }
193: }
194: //---------------------------------------------------------------------------
195:
196: void __fastcall TFtpCfgDlg::HangupSoundButtonClick(TObject *Sender)
197: {
198: OpenDialog->FileName=HangupSoundEdit->Text;
199: if(OpenDialog->Execute()==true) {
200: HangupSoundEdit->Text=OpenDialog->FileName;
201: sndPlaySound(OpenDialog->FileName.c_str(),SND_ASYNC);
202: }
203: }
204: //---------------------------------------------------------------------------
1.1.1.2 ! root 205: void __fastcall TFtpCfgDlg::HackAttemptSoundButtonClick(TObject *Sender)
! 206: {
! 207: OpenDialog->FileName=HackAttemptSoundEdit->Text;
! 208: if(OpenDialog->Execute()==true) {
! 209: HackAttemptSoundEdit->Text=OpenDialog->FileName;
! 210: sndPlaySound(OpenDialog->FileName.c_str(),SND_ASYNC);
! 211: }
! 212: }
! 213: //---------------------------------------------------------------------------
1.1 root 214:
215: void __fastcall TFtpCfgDlg::AutoIndexCheckBoxClick(TObject *Sender)
216: {
217: IndexFileNameEdit->Enabled=AutoIndexCheckBox->Checked;
218: }
219: //---------------------------------------------------------------------------
220:
221:
1.1.1.2 ! root 222: void __fastcall TFtpCfgDlg::HtmlJavaScriptButtonClick(TObject *Sender)
! 223: {
! 224: OpenDialog->FileName=HtmlJavaScriptEdit->Text;
! 225: if(OpenDialog->Execute()==true) {
! 226: HtmlJavaScriptEdit->Text=OpenDialog->FileName;
! 227: }
! 228: }
! 229: //---------------------------------------------------------------------------
! 230:
! 231: void __fastcall TFtpCfgDlg::HtmlIndexCheckBoxClick(TObject *Sender)
! 232: {
! 233: HtmlFileNameEdit->Enabled=HtmlIndexCheckBox->Checked;
! 234: HtmlJavaScriptEdit->Enabled=HtmlIndexCheckBox->Checked;
! 235: HtmlJavaScriptLabel->Enabled=HtmlIndexCheckBox->Checked;
! 236: }
! 237: //---------------------------------------------------------------------------
! 238:
! 239:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.