|
|
1.1 root 1: /* Synchronet Control Panel (GUI Borland C++ Builder Project for Win32) */
2:
1.1.1.2 ! root 3: /* $Id: TelnetCfgDlgUnit.cpp,v 1.16 2004/10/21 08:50:53 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: * *
1.1.1.2 ! root 9: * Copyright 2003 Rob Swindell - http://www.synchro.net/copyright.html *
1.1 root 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 "TextFileEditUnit.h"
42: #include "TelnetCfgDlgUnit.h"
43: #include <stdio.h> // sprintf()
44: #include <mmsystem.h> // sndPlaySound()
45: //---------------------------------------------------------------------
46: #pragma resource "*.dfm"
47: TTelnetCfgDlg *TelnetCfgDlg;
48: //---------------------------------------------------------------------
49: __fastcall TTelnetCfgDlg::TTelnetCfgDlg(TComponent* AOwner)
50: : TForm(AOwner)
51: {
52: }
53: //---------------------------------------------------------------------
54: void __fastcall TTelnetCfgDlg::FormShow(TObject *Sender)
55: {
56: char str[128];
57:
58: if(MainForm->bbs_startup.telnet_interface==0)
59: TelnetInterfaceEdit->Text="<ANY>";
60: else {
61: sprintf(str,"%d.%d.%d.%d"
62: ,(MainForm->bbs_startup.telnet_interface>>24)&0xff
63: ,(MainForm->bbs_startup.telnet_interface>>16)&0xff
64: ,(MainForm->bbs_startup.telnet_interface>>8)&0xff
65: ,MainForm->bbs_startup.telnet_interface&0xff
66: );
67: TelnetInterfaceEdit->Text=AnsiString(str);
68: }
69: if(MainForm->bbs_startup.rlogin_interface==0)
70: RLoginInterfaceEdit->Text="<ANY>";
71: else {
72: sprintf(str,"%d.%d.%d.%d"
73: ,(MainForm->bbs_startup.rlogin_interface>>24)&0xff
74: ,(MainForm->bbs_startup.rlogin_interface>>16)&0xff
75: ,(MainForm->bbs_startup.rlogin_interface>>8)&0xff
76: ,MainForm->bbs_startup.rlogin_interface&0xff
77: );
78: RLoginInterfaceEdit->Text=AnsiString(str);
79: }
80: TelnetPortEdit->Text=AnsiString((int)MainForm->bbs_startup.telnet_port);
81: RLoginPortEdit->Text=AnsiString((int)MainForm->bbs_startup.rlogin_port);
82:
83: FirstNodeEdit->Text=AnsiString((int)MainForm->bbs_startup.first_node);
84: LastNodeEdit->Text=AnsiString((int)MainForm->bbs_startup.last_node);
1.1.1.2 ! root 85: XtrnYieldEdit->Text=AnsiString(
! 86: (int)MainForm->bbs_startup.xtrn_polls_before_yield);
1.1 root 87: AutoStartCheckBox->Checked=MainForm->SysAutoStart;
88: AnswerSoundEdit->Text=AnsiString(MainForm->bbs_startup.answer_sound);
89: HangupSoundEdit->Text=AnsiString(MainForm->bbs_startup.hangup_sound);
90: CmdLogCheckBox->Checked=MainForm->bbs_startup.options&BBS_OPT_DEBUG_TELNET;
1.1.1.2 ! root 91: TelnetGaCheckBox->Checked
! 92: =!(MainForm->bbs_startup.options&BBS_OPT_NO_TELNET_GA);
1.1 root 93: XtrnMinCheckBox->Checked=MainForm->bbs_startup.options&BBS_OPT_XTRN_MINIMIZED;
94: AutoLogonCheckBox->Checked=MainForm->bbs_startup.options&BBS_OPT_AUTO_LOGON;
95: HostnameCheckBox->Checked
96: =!(MainForm->bbs_startup.options&BBS_OPT_NO_HOST_LOOKUP);
1.1.1.2 ! root 97: IdentityCheckBox->Checked
! 98: =MainForm->bbs_startup.options&BBS_OPT_GET_IDENT;
! 99:
1.1 root 100: RLoginEnabledCheckBox->Checked
101: =MainForm->bbs_startup.options&BBS_OPT_ALLOW_RLOGIN;
102: RLogin2ndNameCheckBox->Checked
103: =MainForm->bbs_startup.options&BBS_OPT_USE_2ND_RLOGIN;
1.1.1.2 ! root 104: QWKEventsCheckBox->Checked
! 105: =!(MainForm->bbs_startup.options&BBS_OPT_NO_QWK_EVENTS);
! 106: EventsCheckBox->Checked
! 107: =!(MainForm->bbs_startup.options&BBS_OPT_NO_EVENTS);
! 108: JavaScriptCheckBox->Checked
! 109: =!(MainForm->bbs_startup.options&BBS_OPT_NO_JAVASCRIPT);
1.1 root 110:
111: RLoginEnabledCheckBoxClick(Sender);
112: PageControl->ActivePage=GeneralTabSheet;
113: }
114: //---------------------------------------------------------------------------
115:
116: void __fastcall TTelnetCfgDlg::OKBtnClick(TObject *Sender)
117: {
118: char str[128],*p;
119: DWORD addr;
120:
1.1.1.2 ! root 121: SAFECOPY(str,TelnetInterfaceEdit->Text.c_str());
1.1 root 122: p=str;
123: while(*p && *p<=' ') p++;
124: if(*p && isdigit(*p)) {
125: addr=atoi(p)<<24;
126: while(*p && *p!='.') p++;
127: if(*p=='.') p++;
128: addr|=atoi(p)<<16;
129: while(*p && *p!='.') p++;
130: if(*p=='.') p++;
131: addr|=atoi(p)<<8;
132: while(*p && *p!='.') p++;
133: if(*p=='.') p++;
134: addr|=atoi(p);
135: MainForm->bbs_startup.telnet_interface=addr;
136: } else
137: MainForm->bbs_startup.telnet_interface=0;
138:
1.1.1.2 ! root 139: SAFECOPY(str,RLoginInterfaceEdit->Text.c_str());
1.1 root 140: p=str;
141: while(*p && *p<=' ') p++;
142: if(*p && isdigit(*p)) {
143: addr=atoi(p)<<24;
144: while(*p && *p!='.') p++;
145: if(*p=='.') p++;
146: addr|=atoi(p)<<16;
147: while(*p && *p!='.') p++;
148: if(*p=='.') p++;
149: addr|=atoi(p)<<8;
150: while(*p && *p!='.') p++;
151: if(*p=='.') p++;
152: addr|=atoi(p);
153: MainForm->bbs_startup.rlogin_interface=addr;
154: } else
155: MainForm->bbs_startup.rlogin_interface=0;
156:
157: MainForm->bbs_startup.telnet_port=TelnetPortEdit->Text.ToIntDef(23);
158: MainForm->bbs_startup.rlogin_port=RLoginPortEdit->Text.ToIntDef(513);
159:
160: MainForm->bbs_startup.first_node=FirstNodeEdit->Text.ToIntDef(1);
161: MainForm->bbs_startup.last_node=LastNodeEdit->Text.ToIntDef(1);
1.1.1.2 ! root 162: MainForm->bbs_startup.xtrn_polls_before_yield
! 163: =XtrnYieldEdit->Text.ToIntDef(10);
! 164:
1.1 root 165: MainForm->SysAutoStart=AutoStartCheckBox->Checked;
1.1.1.2 ! root 166: SAFECOPY(MainForm->bbs_startup.answer_sound
1.1 root 167: ,AnswerSoundEdit->Text.c_str());
1.1.1.2 ! root 168: SAFECOPY(MainForm->bbs_startup.hangup_sound
1.1 root 169: ,HangupSoundEdit->Text.c_str());
1.1.1.2 ! root 170: if(TelnetGaCheckBox->Checked==false)
! 171: MainForm->bbs_startup.options|=BBS_OPT_NO_TELNET_GA;
1.1 root 172: else
1.1.1.2 ! root 173: MainForm->bbs_startup.options&=~BBS_OPT_NO_TELNET_GA;
1.1 root 174: if(XtrnMinCheckBox->Checked==true)
175: MainForm->bbs_startup.options|=BBS_OPT_XTRN_MINIMIZED;
176: else
177: MainForm->bbs_startup.options&=~BBS_OPT_XTRN_MINIMIZED;
1.1.1.2 ! root 178: if(QWKEventsCheckBox->Checked==true)
! 179: MainForm->bbs_startup.options&=~BBS_OPT_NO_QWK_EVENTS;
! 180: else
! 181: MainForm->bbs_startup.options|=BBS_OPT_NO_QWK_EVENTS;
! 182: if(EventsCheckBox->Checked==true)
! 183: MainForm->bbs_startup.options&=~BBS_OPT_NO_EVENTS;
! 184: else
! 185: MainForm->bbs_startup.options|=BBS_OPT_NO_EVENTS;
! 186: if(JavaScriptCheckBox->Checked==true)
! 187: MainForm->bbs_startup.options&=~BBS_OPT_NO_JAVASCRIPT;
! 188: else
! 189: MainForm->bbs_startup.options|=BBS_OPT_NO_JAVASCRIPT;
! 190:
1.1 root 191: if(AutoLogonCheckBox->Checked==true)
192: MainForm->bbs_startup.options|=BBS_OPT_AUTO_LOGON;
193: else
194: MainForm->bbs_startup.options&=~BBS_OPT_AUTO_LOGON;
195: if(CmdLogCheckBox->Checked==true)
196: MainForm->bbs_startup.options|=BBS_OPT_DEBUG_TELNET;
197: else
198: MainForm->bbs_startup.options&=~BBS_OPT_DEBUG_TELNET;
199: if(HostnameCheckBox->Checked==false)
200: MainForm->bbs_startup.options|=BBS_OPT_NO_HOST_LOOKUP;
201: else
202: MainForm->bbs_startup.options&=~BBS_OPT_NO_HOST_LOOKUP;
1.1.1.2 ! root 203: if(IdentityCheckBox->Checked==true)
! 204: MainForm->bbs_startup.options|=BBS_OPT_GET_IDENT;
! 205: else
! 206: MainForm->bbs_startup.options&=~BBS_OPT_GET_IDENT;
! 207:
1.1 root 208: if(RLoginEnabledCheckBox->Checked==true)
209: MainForm->bbs_startup.options|=BBS_OPT_ALLOW_RLOGIN;
210: else
211: MainForm->bbs_startup.options&=~BBS_OPT_ALLOW_RLOGIN;
212: if(RLogin2ndNameCheckBox->Checked==true)
213: MainForm->bbs_startup.options|=BBS_OPT_USE_2ND_RLOGIN;
214: else
215: MainForm->bbs_startup.options&=~BBS_OPT_USE_2ND_RLOGIN;
216:
217: MainForm->SaveSettings(Sender);
218: }
219: //---------------------------------------------------------------------------
220:
221: void __fastcall TTelnetCfgDlg::AnswerSoundButtonClick(TObject *Sender)
222: {
223: OpenDialog->FileName=AnswerSoundEdit->Text;
224: if(OpenDialog->Execute()==true) {
225: AnswerSoundEdit->Text=OpenDialog->FileName;
226: sndPlaySound(OpenDialog->FileName.c_str(),SND_ASYNC);
227: }
228: }
229: //---------------------------------------------------------------------------
230:
231: void __fastcall TTelnetCfgDlg::HangupSoundButtonClick(TObject *Sender)
232: {
233: OpenDialog->FileName=HangupSoundEdit->Text;
234: if(OpenDialog->Execute()==true) {
235: HangupSoundEdit->Text=OpenDialog->FileName;
236: sndPlaySound(OpenDialog->FileName.c_str(),SND_ASYNC);
237: }
238: }
239: //---------------------------------------------------------------------------
240:
241: void __fastcall TTelnetCfgDlg::RLoginEnabledCheckBoxClick(TObject *Sender)
242: {
243: RLoginPortEdit->Enabled = RLoginEnabledCheckBox->Checked;
244: RLoginInterfaceEdit->Enabled = RLoginEnabledCheckBox->Checked;
245: RLoginIPallowButton->Enabled = RLoginEnabledCheckBox->Checked;
246: RLogin2ndNameCheckBox->Enabled = RLoginEnabledCheckBox->Checked;
1.1.1.2 ! root 247: RLoginPortLabel->Enabled = RLoginEnabledCheckBox->Checked;
! 248: RLoginInterfaceLabel->Enabled = RLoginEnabledCheckBox->Checked;
1.1 root 249: }
250: //---------------------------------------------------------------------------
251:
252: void __fastcall TTelnetCfgDlg::RLoginIPallowButtonClick(TObject *Sender)
253: {
1.1.1.2 ! root 254: char filename[MAX_PATH+1];
1.1 root 255:
1.1.1.2 ! root 256: sprintf(filename,"%srlogin.cfg"
! 257: ,MainForm->cfg.ctrl_dir);
1.1 root 258: Application->CreateForm(__classid(TTextFileEditForm), &TextFileEditForm);
259: TextFileEditForm->Filename=AnsiString(filename);
260: TextFileEditForm->Caption="Allowed IP addresses for RLogin";
261: TextFileEditForm->ShowModal();
262: delete TextFileEditForm;
263: }
264: //---------------------------------------------------------------------------
265:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.