Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

TelnetCfgDlgUnit.cpp 9.57 KB
Newer Older
1 2
/* Synchronet Control Panel (GUI Borland C++ Builder Project for Win32) */

3
/* $Id: TelnetCfgDlgUnit.cpp,v 1.26 2019/01/12 23:45:21 rswindell Exp $ */
4 5 6 7 8

/****************************************************************************
 * @format.tab-size 4		(Plain Text/Source Code File Header)			*
 * @format.use-tabs true	(see http://www.synchro.net/ptsc_hdr.html)		*
 *																			*
9
 * Copyright Rob Swindell - http://www.synchro.net/copyright.html		    *
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
 *																			*
 * This program is free software; you can redistribute it and/or			*
 * modify it under the terms of the GNU General Public License				*
 * as published by the Free Software Foundation; either version 2			*
 * of the License, or (at your option) any later version.					*
 * See the GNU General Public License for more details: gpl.txt or			*
 * http://www.fsf.org/copyleft/gpl.html										*
 *																			*
 * Anonymous FTP access to the most recent released source is available at	*
 * ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net	*
 *																			*
 * Anonymous CVS access to the development source and modification history	*
 * is available at cvs.synchro.net:/cvsroot/sbbs, example:					*
 * cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs login			*
 *     (just hit return, no password is necessary)							*
 * cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs checkout src		*
 *																			*
 * For Synchronet coding style and modification guidelines, see				*
 * http://www.synchro.net/source.html										*
 *																			*
 * You are encouraged to submit any modifications (preferably in Unix diff	*
 * format) via e-mail to mods@synchro.net									*
 *																			*
 * Note: If this box doesn't appear square, then you need to fix your tabs.	*
 ****************************************************************************/

//---------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop

#include "MainFormUnit.h"
41
#include "TextFileEditUnit.h"
42
#include "TelnetCfgDlgUnit.h"
43
#include "soundCfgDlgUnit.h"
44 45 46 47 48 49 50 51 52 53 54 55 56
#include <stdio.h>			// sprintf()
#include <mmsystem.h>		// sndPlaySound()
//---------------------------------------------------------------------
#pragma resource "*.dfm"
TTelnetCfgDlg *TelnetCfgDlg;
//--------------------------------------------------------------------- 
__fastcall TTelnetCfgDlg::TTelnetCfgDlg(TComponent* AOwner)
	: TForm(AOwner)
{
}
//---------------------------------------------------------------------
void __fastcall TTelnetCfgDlg::FormShow(TObject *Sender)
{
57
    char str[256];
58

59
    if(MainForm->bbs_startup.telnet_interfaces==NULL)
60
        TelnetInterfaceEdit->Text="<ANY>";
61
    else {
62
        strListCombine(MainForm->bbs_startup.telnet_interfaces, str, sizeof(str)-1, ",");
63 64
        TelnetInterfaceEdit->Text=AnsiString(str);
    }
65 66

    if(MainForm->bbs_startup.rlogin_interfaces==NULL)
67 68
        RLoginInterfaceEdit->Text="<ANY>";
    else {
69
        strListCombine(MainForm->bbs_startup.rlogin_interfaces, str, sizeof(str)-1, ",");
70
        RLoginInterfaceEdit->Text=AnsiString(str);
71
    }
rswindell's avatar
rswindell committed
72

73
    if(MainForm->bbs_startup.ssh_interfaces==NULL)
rswindell's avatar
rswindell committed
74 75
        SshInterfaceEdit->Text="<ANY>";
    else {
76
        strListCombine(MainForm->bbs_startup.ssh_interfaces, str, sizeof(str)-1, ",");
rswindell's avatar
rswindell committed
77 78
        SshInterfaceEdit->Text=AnsiString(str);
    }
79
    SshConnTimeoutEdit->Text=AnsiString((int)MainForm->bbs_startup.ssh_connect_timeout);
rswindell's avatar
rswindell committed
80

81
	TelnetPortEdit->Text=AnsiString((int)MainForm->bbs_startup.telnet_port);
82
	RLoginPortEdit->Text=AnsiString((int)MainForm->bbs_startup.rlogin_port);
rswindell's avatar
rswindell committed
83
	SshPortEdit->Text=AnsiString((int)MainForm->bbs_startup.ssh_port);
84

85 86
	FirstNodeEdit->Text=AnsiString((int)MainForm->bbs_startup.first_node);
	LastNodeEdit->Text=AnsiString((int)MainForm->bbs_startup.last_node);
87 88 89 90
    if(MainForm->bbs_startup.max_concurrent_connections == 0)
        MaxConConEdit->Text="N/A";
    else
        MaxConConEdit->Text=AnsiString((int)MainForm->bbs_startup.max_concurrent_connections);
91 92
    AutoStartCheckBox->Checked=MainForm->SysAutoStart;
    CmdLogCheckBox->Checked=MainForm->bbs_startup.options&BBS_OPT_DEBUG_TELNET;
93 94
    TelnetGaCheckBox->Checked
    	=!(MainForm->bbs_startup.options&BBS_OPT_NO_TELNET_GA);
95 96 97 98
	XtrnMinCheckBox->Checked=MainForm->bbs_startup.options&BBS_OPT_XTRN_MINIMIZED;
    AutoLogonCheckBox->Checked=MainForm->bbs_startup.options&BBS_OPT_AUTO_LOGON;
    HostnameCheckBox->Checked
        =!(MainForm->bbs_startup.options&BBS_OPT_NO_HOST_LOOKUP);
99 100
    DosSupportCheckBox->Checked
        =!(MainForm->bbs_startup.options&BBS_OPT_NO_DOS);
rswindell's avatar
rswindell committed
101

102 103
    RLoginEnabledCheckBox->Checked
        =MainForm->bbs_startup.options&BBS_OPT_ALLOW_RLOGIN;
rswindell's avatar
rswindell committed
104 105 106
    SshEnabledCheckBox->Checked
        =MainForm->bbs_startup.options&BBS_OPT_ALLOW_SSH;

107 108
    QWKEventsCheckBox->Checked
        =!(MainForm->bbs_startup.options&BBS_OPT_NO_QWK_EVENTS);
109 110
    EventsCheckBox->Checked
        =!(MainForm->bbs_startup.options&BBS_OPT_NO_EVENTS);
111

112
    RLoginEnabledCheckBoxClick(Sender);
rswindell's avatar
rswindell committed
113
    SshEnabledCheckBoxClick(Sender);
114 115 116 117 118 119
    PageControl->ActivePage=GeneralTabSheet;
}
//---------------------------------------------------------------------------

void __fastcall TTelnetCfgDlg::OKBtnClick(TObject *Sender)
{
120 121
    iniFreeStringList(MainForm->bbs_startup.telnet_interfaces);
    MainForm->bbs_startup.telnet_interfaces = strListSplitCopy(NULL, TelnetInterfaceEdit->Text.c_str(), ",");
122

123 124
    iniFreeStringList(MainForm->bbs_startup.rlogin_interfaces);
    MainForm->bbs_startup.rlogin_interfaces = strListSplitCopy(NULL, RLoginInterfaceEdit->Text.c_str(), ",");
125

126 127
    iniFreeStringList(MainForm->bbs_startup.ssh_interfaces);
    MainForm->bbs_startup.ssh_interfaces = strListSplitCopy(NULL, SshInterfaceEdit->Text.c_str(), ",");
128
    MainForm->bbs_startup.ssh_connect_timeout=SshConnTimeoutEdit->Text.ToIntDef(0);
rswindell's avatar
rswindell committed
129

130
    MainForm->bbs_startup.telnet_port=TelnetPortEdit->Text.ToIntDef(23);
131
    MainForm->bbs_startup.rlogin_port=RLoginPortEdit->Text.ToIntDef(513);
rswindell's avatar
rswindell committed
132
    MainForm->bbs_startup.ssh_port=SshPortEdit->Text.ToIntDef(22);
133

134 135
    MainForm->bbs_startup.first_node=FirstNodeEdit->Text.ToIntDef(1);
    MainForm->bbs_startup.last_node=LastNodeEdit->Text.ToIntDef(1);
136
    MainForm->bbs_startup.max_concurrent_connections=MaxConConEdit->Text.ToIntDef(0);
137

138
    MainForm->SysAutoStart=AutoStartCheckBox->Checked;
139 140
	if(TelnetGaCheckBox->Checked==false)
    	MainForm->bbs_startup.options|=BBS_OPT_NO_TELNET_GA;
141
    else
142
	    MainForm->bbs_startup.options&=~BBS_OPT_NO_TELNET_GA;
143 144 145 146
    if(XtrnMinCheckBox->Checked==true)
    	MainForm->bbs_startup.options|=BBS_OPT_XTRN_MINIMIZED;
    else
	    MainForm->bbs_startup.options&=~BBS_OPT_XTRN_MINIMIZED;
147 148 149 150
    if(QWKEventsCheckBox->Checked==true)
        MainForm->bbs_startup.options&=~BBS_OPT_NO_QWK_EVENTS;
    else
        MainForm->bbs_startup.options|=BBS_OPT_NO_QWK_EVENTS;
151 152 153 154
    if(EventsCheckBox->Checked==true)
        MainForm->bbs_startup.options&=~BBS_OPT_NO_EVENTS;
    else
        MainForm->bbs_startup.options|=BBS_OPT_NO_EVENTS;
155 156 157 158
    if(DosSupportCheckBox->Checked==true)
        MainForm->bbs_startup.options&=~BBS_OPT_NO_DOS;
    else
        MainForm->bbs_startup.options|=BBS_OPT_NO_DOS;
159

160 161 162 163 164 165 166 167 168 169 170 171
    if(AutoLogonCheckBox->Checked==true)
    	MainForm->bbs_startup.options|=BBS_OPT_AUTO_LOGON;
    else
	    MainForm->bbs_startup.options&=~BBS_OPT_AUTO_LOGON;
    if(CmdLogCheckBox->Checked==true)
    	MainForm->bbs_startup.options|=BBS_OPT_DEBUG_TELNET;
    else
	    MainForm->bbs_startup.options&=~BBS_OPT_DEBUG_TELNET;
	if(HostnameCheckBox->Checked==false)
    	MainForm->bbs_startup.options|=BBS_OPT_NO_HOST_LOOKUP;
    else
	    MainForm->bbs_startup.options&=~BBS_OPT_NO_HOST_LOOKUP;
rswindell's avatar
rswindell committed
172

173 174 175 176
	if(RLoginEnabledCheckBox->Checked==true)
    	MainForm->bbs_startup.options|=BBS_OPT_ALLOW_RLOGIN;
    else
	    MainForm->bbs_startup.options&=~BBS_OPT_ALLOW_RLOGIN;
177

rswindell's avatar
rswindell committed
178 179 180 181 182
	if(SshEnabledCheckBox->Checked==true)
    	MainForm->bbs_startup.options|=BBS_OPT_ALLOW_SSH;
    else
	    MainForm->bbs_startup.options&=~BBS_OPT_ALLOW_SSH;

183
    MainForm->SaveIniSettings(Sender);
184 185 186
}
//---------------------------------------------------------------------------

187 188 189 190 191
void __fastcall TTelnetCfgDlg::RLoginEnabledCheckBoxClick(TObject *Sender)
{
    RLoginPortEdit->Enabled = RLoginEnabledCheckBox->Checked;
    RLoginInterfaceEdit->Enabled = RLoginEnabledCheckBox->Checked;
    RLoginIPallowButton->Enabled = RLoginEnabledCheckBox->Checked;
192 193
    RLoginPortLabel->Enabled = RLoginEnabledCheckBox->Checked;
    RLoginInterfaceLabel->Enabled = RLoginEnabledCheckBox->Checked;
194 195 196 197 198
}
//---------------------------------------------------------------------------

void __fastcall TTelnetCfgDlg::RLoginIPallowButtonClick(TObject *Sender)
{
199
	char filename[MAX_PATH+1];
200

201 202
    sprintf(filename,"%srlogin.cfg"
    	,MainForm->cfg.ctrl_dir);
203 204 205 206 207 208 209 210
	Application->CreateForm(__classid(TTextFileEditForm), &TextFileEditForm);
	TextFileEditForm->Filename=AnsiString(filename);
    TextFileEditForm->Caption="Allowed IP addresses for RLogin";
	TextFileEditForm->ShowModal();
    delete TextFileEditForm;
}
//---------------------------------------------------------------------------

rswindell's avatar
rswindell committed
211 212 213 214 215 216 217 218 219
void __fastcall TTelnetCfgDlg::SshEnabledCheckBoxClick(TObject *Sender)
{
    SshPortEdit->Enabled = SshEnabledCheckBox->Checked;
    SshInterfaceEdit->Enabled = SshEnabledCheckBox->Checked;
    SshPortLabel->Enabled = SshEnabledCheckBox->Checked;
    SshInterfaceLabel->Enabled = SshEnabledCheckBox->Checked;
}
//---------------------------------------------------------------------------

220 221 222 223 224 225 226
void __fastcall TTelnetCfgDlg::ConfigureSoundButtonClick(TObject *Sender)
{
    SoundCfgDlg->sound = &MainForm->bbs_startup.sound;
    SoundCfgDlg->Caption = "Terminal Server Sound Configuration";
    SoundCfgDlg->ShowModal();
}
//---------------------------------------------------------------------------
227