Annotation of sbbs/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.4 2000/11/02 03:42:04 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 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 "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);
                     85:     AutoStartCheckBox->Checked=MainForm->SysAutoStart;
                     86:     AnswerSoundEdit->Text=AnsiString(MainForm->bbs_startup.answer_sound);
                     87:     HangupSoundEdit->Text=AnsiString(MainForm->bbs_startup.hangup_sound);
                     88:     CmdLogCheckBox->Checked=MainForm->bbs_startup.options&BBS_OPT_DEBUG_TELNET;
                     89:     KeepAliveCheckBox->Checked=MainForm->bbs_startup.options&BBS_OPT_KEEP_ALIVE;
                     90:        XtrnMinCheckBox->Checked=MainForm->bbs_startup.options&BBS_OPT_XTRN_MINIMIZED;
                     91:     AutoLogonCheckBox->Checked=MainForm->bbs_startup.options&BBS_OPT_AUTO_LOGON;
                     92:     HostnameCheckBox->Checked
                     93:         =!(MainForm->bbs_startup.options&BBS_OPT_NO_HOST_LOOKUP);
                     94:     RLoginEnabledCheckBox->Checked
                     95:         =MainForm->bbs_startup.options&BBS_OPT_ALLOW_RLOGIN;
                     96:     RLogin2ndNameCheckBox->Checked
                     97:         =MainForm->bbs_startup.options&BBS_OPT_USE_2ND_RLOGIN;
                     98: 
                     99:     RLoginEnabledCheckBoxClick(Sender);
                    100:     PageControl->ActivePage=GeneralTabSheet;
                    101: }
                    102: //---------------------------------------------------------------------------
                    103: 
                    104: void __fastcall TTelnetCfgDlg::OKBtnClick(TObject *Sender)
                    105: {
                    106:     char    str[128],*p;
                    107:     DWORD   addr;
                    108: 
                    109:     sprintf(str,"%.*s",sizeof(str)-1
                    110:         ,TelnetInterfaceEdit->Text.c_str());
                    111:     p=str;
                    112:     while(*p && *p<=' ') p++;
                    113:     if(*p && isdigit(*p)) {
                    114:         addr=atoi(p)<<24;
                    115:         while(*p && *p!='.') p++;
                    116:         if(*p=='.') p++;
                    117:         addr|=atoi(p)<<16;
                    118:         while(*p && *p!='.') p++;
                    119:         if(*p=='.') p++;
                    120:         addr|=atoi(p)<<8;
                    121:         while(*p && *p!='.') p++;
                    122:         if(*p=='.') p++;
                    123:         addr|=atoi(p);
                    124:         MainForm->bbs_startup.telnet_interface=addr;
                    125:     } else
                    126:         MainForm->bbs_startup.telnet_interface=0;
                    127: 
                    128:     sprintf(str,"%.*s",sizeof(str)-1
                    129:         ,RLoginInterfaceEdit->Text.c_str());
                    130:     p=str;
                    131:     while(*p && *p<=' ') p++;
                    132:     if(*p && isdigit(*p)) {
                    133:         addr=atoi(p)<<24;
                    134:         while(*p && *p!='.') p++;
                    135:         if(*p=='.') p++;
                    136:         addr|=atoi(p)<<16;
                    137:         while(*p && *p!='.') p++;
                    138:         if(*p=='.') p++;
                    139:         addr|=atoi(p)<<8;
                    140:         while(*p && *p!='.') p++;
                    141:         if(*p=='.') p++;
                    142:         addr|=atoi(p);
                    143:         MainForm->bbs_startup.rlogin_interface=addr;
                    144:     } else
                    145:         MainForm->bbs_startup.rlogin_interface=0;
                    146: 
                    147:     MainForm->bbs_startup.telnet_port=TelnetPortEdit->Text.ToIntDef(23);
                    148:     MainForm->bbs_startup.rlogin_port=RLoginPortEdit->Text.ToIntDef(513);
                    149: 
                    150:     MainForm->bbs_startup.first_node=FirstNodeEdit->Text.ToIntDef(1);
                    151:     MainForm->bbs_startup.last_node=LastNodeEdit->Text.ToIntDef(1);
                    152:     MainForm->SysAutoStart=AutoStartCheckBox->Checked;
                    153:     sprintf(MainForm->bbs_startup.answer_sound,"%.*s"
                    154:            ,sizeof(MainForm->bbs_startup.answer_sound)-1
                    155:         ,AnswerSoundEdit->Text.c_str());
                    156:     sprintf(MainForm->bbs_startup.hangup_sound,"%.*s"
                    157:            ,sizeof(MainForm->bbs_startup.hangup_sound)-1
                    158:         ,HangupSoundEdit->Text.c_str());
                    159:        if(KeepAliveCheckBox->Checked==true)
                    160:        MainForm->bbs_startup.options|=BBS_OPT_KEEP_ALIVE;
                    161:     else
                    162:            MainForm->bbs_startup.options&=~BBS_OPT_KEEP_ALIVE;
                    163:     if(XtrnMinCheckBox->Checked==true)
                    164:        MainForm->bbs_startup.options|=BBS_OPT_XTRN_MINIMIZED;
                    165:     else
                    166:            MainForm->bbs_startup.options&=~BBS_OPT_XTRN_MINIMIZED;
                    167:     if(AutoLogonCheckBox->Checked==true)
                    168:        MainForm->bbs_startup.options|=BBS_OPT_AUTO_LOGON;
                    169:     else
                    170:            MainForm->bbs_startup.options&=~BBS_OPT_AUTO_LOGON;
                    171:     if(CmdLogCheckBox->Checked==true)
                    172:        MainForm->bbs_startup.options|=BBS_OPT_DEBUG_TELNET;
                    173:     else
                    174:            MainForm->bbs_startup.options&=~BBS_OPT_DEBUG_TELNET;
                    175:        if(HostnameCheckBox->Checked==false)
                    176:        MainForm->bbs_startup.options|=BBS_OPT_NO_HOST_LOOKUP;
                    177:     else
                    178:            MainForm->bbs_startup.options&=~BBS_OPT_NO_HOST_LOOKUP;
                    179:        if(RLoginEnabledCheckBox->Checked==true)
                    180:        MainForm->bbs_startup.options|=BBS_OPT_ALLOW_RLOGIN;
                    181:     else
                    182:            MainForm->bbs_startup.options&=~BBS_OPT_ALLOW_RLOGIN;
                    183:        if(RLogin2ndNameCheckBox->Checked==true)
                    184:        MainForm->bbs_startup.options|=BBS_OPT_USE_2ND_RLOGIN;
                    185:     else
                    186:            MainForm->bbs_startup.options&=~BBS_OPT_USE_2ND_RLOGIN;
                    187: 
                    188:     MainForm->SaveSettings(Sender);
                    189: }
                    190: //---------------------------------------------------------------------------
                    191: 
                    192: void __fastcall TTelnetCfgDlg::AnswerSoundButtonClick(TObject *Sender)
                    193: {
                    194:        OpenDialog->FileName=AnswerSoundEdit->Text;
                    195:        if(OpenDialog->Execute()==true) {
                    196:        AnswerSoundEdit->Text=OpenDialog->FileName;
                    197:         sndPlaySound(OpenDialog->FileName.c_str(),SND_ASYNC);
                    198:     }
                    199: }
                    200: //---------------------------------------------------------------------------
                    201: 
                    202: void __fastcall TTelnetCfgDlg::HangupSoundButtonClick(TObject *Sender)
                    203: {
                    204:        OpenDialog->FileName=HangupSoundEdit->Text;
                    205:        if(OpenDialog->Execute()==true) {
                    206:        HangupSoundEdit->Text=OpenDialog->FileName;
                    207:         sndPlaySound(OpenDialog->FileName.c_str(),SND_ASYNC);
                    208:        }
                    209: }
                    210: //---------------------------------------------------------------------------
                    211: 
                    212: void __fastcall TTelnetCfgDlg::RLoginEnabledCheckBoxClick(TObject *Sender)
                    213: {
                    214:     RLoginPortEdit->Enabled = RLoginEnabledCheckBox->Checked;
                    215:     RLoginInterfaceEdit->Enabled = RLoginEnabledCheckBox->Checked;
                    216:     RLoginIPallowButton->Enabled = RLoginEnabledCheckBox->Checked;
                    217:     RLogin2ndNameCheckBox->Enabled = RLoginEnabledCheckBox->Checked;
                    218: }
                    219: //---------------------------------------------------------------------------
                    220: 
                    221: void __fastcall TTelnetCfgDlg::RLoginIPallowButtonClick(TObject *Sender)
                    222: {
                    223:        char filename[MAX_PATH];
                    224: 
                    225:     sprintf(filename,"%sRLOGIN.CAN"
                    226:        ,MainForm->cfg.text_dir);
                    227:        Application->CreateForm(__classid(TTextFileEditForm), &TextFileEditForm);
                    228:        TextFileEditForm->Filename=AnsiString(filename);
                    229:     TextFileEditForm->Caption="Allowed IP addresses for RLogin";
                    230:        TextFileEditForm->ShowModal();
                    231:     delete TextFileEditForm;
                    232: }
                    233: //---------------------------------------------------------------------------
                    234: 

unix.superglobalmegacorp.com

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