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

1.1       root        1: /* Synchronet Control Panel (GUI Borland C++ Builder Project for Win32) */
                      2: 
                      3: /* $Id: TelnetCfgDlgUnit.cpp,v 1.19 2006/12/29 02:51:56 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 "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: 
                     81:     if(MainForm->bbs_startup.ssh_interface==0)
                     82:         SshInterfaceEdit->Text="<ANY>";
                     83:     else {
                     84:         sprintf(str,"%d.%d.%d.%d"
                     85:             ,(MainForm->bbs_startup.ssh_interface>>24)&0xff
                     86:             ,(MainForm->bbs_startup.ssh_interface>>16)&0xff
                     87:             ,(MainForm->bbs_startup.ssh_interface>>8)&0xff
                     88:             ,MainForm->bbs_startup.ssh_interface&0xff
                     89:         );
                     90:         SshInterfaceEdit->Text=AnsiString(str);
                     91:     }
                     92: 
                     93:        TelnetPortEdit->Text=AnsiString((int)MainForm->bbs_startup.telnet_port);
                     94:        RLoginPortEdit->Text=AnsiString((int)MainForm->bbs_startup.rlogin_port);
                     95:        SshPortEdit->Text=AnsiString((int)MainForm->bbs_startup.ssh_port);
                     96: 
                     97:        FirstNodeEdit->Text=AnsiString((int)MainForm->bbs_startup.first_node);
                     98:        LastNodeEdit->Text=AnsiString((int)MainForm->bbs_startup.last_node);
                     99:     AutoStartCheckBox->Checked=MainForm->SysAutoStart;
                    100:     AnswerSoundEdit->Text=AnsiString(MainForm->bbs_startup.answer_sound);
                    101:     HangupSoundEdit->Text=AnsiString(MainForm->bbs_startup.hangup_sound);
                    102:     CmdLogCheckBox->Checked=MainForm->bbs_startup.options&BBS_OPT_DEBUG_TELNET;
                    103:     TelnetGaCheckBox->Checked
                    104:        =!(MainForm->bbs_startup.options&BBS_OPT_NO_TELNET_GA);
                    105:        XtrnMinCheckBox->Checked=MainForm->bbs_startup.options&BBS_OPT_XTRN_MINIMIZED;
                    106:     AutoLogonCheckBox->Checked=MainForm->bbs_startup.options&BBS_OPT_AUTO_LOGON;
                    107:     HostnameCheckBox->Checked
                    108:         =!(MainForm->bbs_startup.options&BBS_OPT_NO_HOST_LOOKUP);
                    109:     IdentityCheckBox->Checked
                    110:         =MainForm->bbs_startup.options&BBS_OPT_GET_IDENT;
                    111: 
                    112:     RLoginEnabledCheckBox->Checked
                    113:         =MainForm->bbs_startup.options&BBS_OPT_ALLOW_RLOGIN;
                    114:     RLogin2ndNameCheckBox->Checked
                    115:         =MainForm->bbs_startup.options&BBS_OPT_USE_2ND_RLOGIN;
                    116:     SshEnabledCheckBox->Checked
                    117:         =MainForm->bbs_startup.options&BBS_OPT_ALLOW_SSH;
                    118: 
                    119:     QWKEventsCheckBox->Checked
                    120:         =!(MainForm->bbs_startup.options&BBS_OPT_NO_QWK_EVENTS);
                    121:     EventsCheckBox->Checked
                    122:         =!(MainForm->bbs_startup.options&BBS_OPT_NO_EVENTS);
                    123:     JavaScriptCheckBox->Checked
                    124:         =!(MainForm->bbs_startup.options&BBS_OPT_NO_JAVASCRIPT);
                    125: 
                    126:     RLoginEnabledCheckBoxClick(Sender);
                    127:     SshEnabledCheckBoxClick(Sender);
                    128:     PageControl->ActivePage=GeneralTabSheet;
                    129: }
                    130: //---------------------------------------------------------------------------
                    131: 
                    132: void __fastcall TTelnetCfgDlg::OKBtnClick(TObject *Sender)
                    133: {
                    134:     char    str[128],*p;
                    135:     DWORD   addr;
                    136: 
                    137:     SAFECOPY(str,TelnetInterfaceEdit->Text.c_str());
                    138:     p=str;
                    139:     while(*p && *p<=' ') p++;
                    140:     if(*p && isdigit(*p)) {
                    141:         addr=atoi(p)<<24;
                    142:         while(*p && *p!='.') p++;
                    143:         if(*p=='.') p++;
                    144:         addr|=atoi(p)<<16;
                    145:         while(*p && *p!='.') p++;
                    146:         if(*p=='.') p++;
                    147:         addr|=atoi(p)<<8;
                    148:         while(*p && *p!='.') p++;
                    149:         if(*p=='.') p++;
                    150:         addr|=atoi(p);
                    151:         MainForm->bbs_startup.telnet_interface=addr;
                    152:     } else
                    153:         MainForm->bbs_startup.telnet_interface=0;
                    154: 
                    155:     SAFECOPY(str,RLoginInterfaceEdit->Text.c_str());
                    156:     p=str;
                    157:     while(*p && *p<=' ') p++;
                    158:     if(*p && isdigit(*p)) {
                    159:         addr=atoi(p)<<24;
                    160:         while(*p && *p!='.') p++;
                    161:         if(*p=='.') p++;
                    162:         addr|=atoi(p)<<16;
                    163:         while(*p && *p!='.') p++;
                    164:         if(*p=='.') p++;
                    165:         addr|=atoi(p)<<8;
                    166:         while(*p && *p!='.') p++;
                    167:         if(*p=='.') p++;
                    168:         addr|=atoi(p);
                    169:         MainForm->bbs_startup.rlogin_interface=addr;
                    170:     } else
                    171:         MainForm->bbs_startup.rlogin_interface=0;
                    172: 
                    173:     SAFECOPY(str,SshInterfaceEdit->Text.c_str());
                    174:     p=str;
                    175:     while(*p && *p<=' ') p++;
                    176:     if(*p && isdigit(*p)) {
                    177:         addr=atoi(p)<<24;
                    178:         while(*p && *p!='.') p++;
                    179:         if(*p=='.') p++;
                    180:         addr|=atoi(p)<<16;
                    181:         while(*p && *p!='.') p++;
                    182:         if(*p=='.') p++;
                    183:         addr|=atoi(p)<<8;
                    184:         while(*p && *p!='.') p++;
                    185:         if(*p=='.') p++;
                    186:         addr|=atoi(p);
                    187:         MainForm->bbs_startup.ssh_interface=addr;
                    188:     } else
                    189:         MainForm->bbs_startup.ssh_interface=0;
                    190: 
                    191:     MainForm->bbs_startup.telnet_port=TelnetPortEdit->Text.ToIntDef(23);
                    192:     MainForm->bbs_startup.rlogin_port=RLoginPortEdit->Text.ToIntDef(513);
                    193:     MainForm->bbs_startup.ssh_port=SshPortEdit->Text.ToIntDef(22);
                    194: 
                    195:     MainForm->bbs_startup.first_node=FirstNodeEdit->Text.ToIntDef(1);
                    196:     MainForm->bbs_startup.last_node=LastNodeEdit->Text.ToIntDef(1);
                    197: 
                    198:     MainForm->SysAutoStart=AutoStartCheckBox->Checked;
                    199:     SAFECOPY(MainForm->bbs_startup.answer_sound
                    200:         ,AnswerSoundEdit->Text.c_str());
                    201:     SAFECOPY(MainForm->bbs_startup.hangup_sound
                    202:         ,HangupSoundEdit->Text.c_str());
                    203:        if(TelnetGaCheckBox->Checked==false)
                    204:        MainForm->bbs_startup.options|=BBS_OPT_NO_TELNET_GA;
                    205:     else
                    206:            MainForm->bbs_startup.options&=~BBS_OPT_NO_TELNET_GA;
                    207:     if(XtrnMinCheckBox->Checked==true)
                    208:        MainForm->bbs_startup.options|=BBS_OPT_XTRN_MINIMIZED;
                    209:     else
                    210:            MainForm->bbs_startup.options&=~BBS_OPT_XTRN_MINIMIZED;
                    211:     if(QWKEventsCheckBox->Checked==true)
                    212:         MainForm->bbs_startup.options&=~BBS_OPT_NO_QWK_EVENTS;
                    213:     else
                    214:         MainForm->bbs_startup.options|=BBS_OPT_NO_QWK_EVENTS;
                    215:     if(EventsCheckBox->Checked==true)
                    216:         MainForm->bbs_startup.options&=~BBS_OPT_NO_EVENTS;
                    217:     else
                    218:         MainForm->bbs_startup.options|=BBS_OPT_NO_EVENTS;
                    219:     if(JavaScriptCheckBox->Checked==true)
                    220:         MainForm->bbs_startup.options&=~BBS_OPT_NO_JAVASCRIPT;
                    221:     else
                    222:         MainForm->bbs_startup.options|=BBS_OPT_NO_JAVASCRIPT;
                    223: 
                    224:     if(AutoLogonCheckBox->Checked==true)
                    225:        MainForm->bbs_startup.options|=BBS_OPT_AUTO_LOGON;
                    226:     else
                    227:            MainForm->bbs_startup.options&=~BBS_OPT_AUTO_LOGON;
                    228:     if(CmdLogCheckBox->Checked==true)
                    229:        MainForm->bbs_startup.options|=BBS_OPT_DEBUG_TELNET;
                    230:     else
                    231:            MainForm->bbs_startup.options&=~BBS_OPT_DEBUG_TELNET;
                    232:        if(HostnameCheckBox->Checked==false)
                    233:        MainForm->bbs_startup.options|=BBS_OPT_NO_HOST_LOOKUP;
                    234:     else
                    235:            MainForm->bbs_startup.options&=~BBS_OPT_NO_HOST_LOOKUP;
                    236:        if(IdentityCheckBox->Checked==true)
                    237:        MainForm->bbs_startup.options|=BBS_OPT_GET_IDENT;
                    238:     else
                    239:            MainForm->bbs_startup.options&=~BBS_OPT_GET_IDENT;
                    240: 
                    241:        if(RLoginEnabledCheckBox->Checked==true)
                    242:        MainForm->bbs_startup.options|=BBS_OPT_ALLOW_RLOGIN;
                    243:     else
                    244:            MainForm->bbs_startup.options&=~BBS_OPT_ALLOW_RLOGIN;
                    245:        if(RLogin2ndNameCheckBox->Checked==true)
                    246:        MainForm->bbs_startup.options|=BBS_OPT_USE_2ND_RLOGIN;
                    247:     else
                    248:            MainForm->bbs_startup.options&=~BBS_OPT_USE_2ND_RLOGIN;
                    249: 
                    250:        if(SshEnabledCheckBox->Checked==true)
                    251:        MainForm->bbs_startup.options|=BBS_OPT_ALLOW_SSH;
                    252:     else
                    253:            MainForm->bbs_startup.options&=~BBS_OPT_ALLOW_SSH;
                    254: 
                    255:     MainForm->SaveIniSettings(Sender);
                    256: }
                    257: //---------------------------------------------------------------------------
                    258: 
                    259: void __fastcall TTelnetCfgDlg::AnswerSoundButtonClick(TObject *Sender)
                    260: {
                    261:        OpenDialog->FileName=AnswerSoundEdit->Text;
                    262:        if(OpenDialog->Execute()==true) {
                    263:        AnswerSoundEdit->Text=OpenDialog->FileName;
                    264:         sndPlaySound(OpenDialog->FileName.c_str(),SND_ASYNC);
                    265:     }
                    266: }
                    267: //---------------------------------------------------------------------------
                    268: 
                    269: void __fastcall TTelnetCfgDlg::HangupSoundButtonClick(TObject *Sender)
                    270: {
                    271:        OpenDialog->FileName=HangupSoundEdit->Text;
                    272:        if(OpenDialog->Execute()==true) {
                    273:        HangupSoundEdit->Text=OpenDialog->FileName;
                    274:         sndPlaySound(OpenDialog->FileName.c_str(),SND_ASYNC);
                    275:        }
                    276: }
                    277: //---------------------------------------------------------------------------
                    278: 
                    279: void __fastcall TTelnetCfgDlg::RLoginEnabledCheckBoxClick(TObject *Sender)
                    280: {
                    281:     RLoginPortEdit->Enabled = RLoginEnabledCheckBox->Checked;
                    282:     RLoginInterfaceEdit->Enabled = RLoginEnabledCheckBox->Checked;
                    283:     RLoginIPallowButton->Enabled = RLoginEnabledCheckBox->Checked;
                    284:     RLogin2ndNameCheckBox->Enabled = RLoginEnabledCheckBox->Checked;
                    285:     RLoginPortLabel->Enabled = RLoginEnabledCheckBox->Checked;
                    286:     RLoginInterfaceLabel->Enabled = RLoginEnabledCheckBox->Checked;
                    287: }
                    288: //---------------------------------------------------------------------------
                    289: 
                    290: void __fastcall TTelnetCfgDlg::RLoginIPallowButtonClick(TObject *Sender)
                    291: {
                    292:        char filename[MAX_PATH+1];
                    293: 
                    294:     sprintf(filename,"%srlogin.cfg"
                    295:        ,MainForm->cfg.ctrl_dir);
                    296:        Application->CreateForm(__classid(TTextFileEditForm), &TextFileEditForm);
                    297:        TextFileEditForm->Filename=AnsiString(filename);
                    298:     TextFileEditForm->Caption="Allowed IP addresses for RLogin";
                    299:        TextFileEditForm->ShowModal();
                    300:     delete TextFileEditForm;
                    301: }
                    302: //---------------------------------------------------------------------------
                    303: 
                    304: void __fastcall TTelnetCfgDlg::SshEnabledCheckBoxClick(TObject *Sender)
                    305: {
                    306:     SshPortEdit->Enabled = SshEnabledCheckBox->Checked;
                    307:     SshInterfaceEdit->Enabled = SshEnabledCheckBox->Checked;
                    308:     SshPortLabel->Enabled = SshEnabledCheckBox->Checked;
                    309:     SshInterfaceLabel->Enabled = SshEnabledCheckBox->Checked;
                    310: }
                    311: //---------------------------------------------------------------------------
                    312: 
                    313: 

unix.superglobalmegacorp.com

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