|
|
1.1 root 1: /* Synchronet Control Panel (GUI Borland C++ Builder Project for Win32) */
2:
1.1.1.2 ! root 3: /* $Id: MainFormUnit.cpp,v 1.143 2004/12/31 22:26:54 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 2004 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>
1.1.1.2 ! root 38: #include <vcl/Registry.hpp> /* TRegistry */
1.1 root 39: #pragma hdrstop
40: #include <winsock.h> // IPPORT_TELNET, INADDR_ANY
41: #include <process.h> // _beginthread()
42: #include <io.h>
43: #include <stdio.h>
1.1.1.2 ! root 44: #include <sys/stat.h>
! 45: #include <sys/locking.h>
1.1 root 46: #include <fcntl.h>
47: #include <share.h>
48:
49: #include "MainFormUnit.h"
50: #include "TelnetFormUnit.h"
1.1.1.2 ! root 51: #include "EventsFormUnit.h"
! 52: #include "ServicesFormUnit.h"
1.1 root 53: #include "FtpFormUnit.h"
1.1.1.2 ! root 54: #include "WebFormUnit.h"
1.1 root 55: #include "MailFormUnit.h"
56: #include "NodeFormUnit.h"
1.1.1.2 ! root 57:
1.1 root 58: #include "StatsFormUnit.h"
59: #include "ClientFormUnit.h"
60: #include "CtrlPathDialogUnit.h"
61: #include "TelnetCfgDlgUnit.h"
62: #include "MailCfgDlgUnit.h"
63: #include "FtpCfgDlgUnit.h"
1.1.1.2 ! root 64: #include "WebCfgDlgUnit.h"
! 65: #include "ServicesCfgDlgUnit.h"
1.1 root 66: #include "AboutBoxFormUnit.h"
67: #include "CodeInputFormUnit.h"
68: #include "TextFileEditUnit.h"
69: #include "UserListFormUnit.h"
1.1.1.2 ! root 70: #include "PropertiesDlgUnit.h"
! 71: #include "ConfigWizardUnit.h"
! 72: #include "PreviewFormUnit.h"
1.1 root 73:
74: #include "sbbs.h" // unixtodstr()
1.1.1.2 ! root 75: #include "sbbs_ini.h" // sbbs_read_ini()
1.1 root 76: #include "userdat.h" // lastuser()
1.1.1.2 ! root 77: #include "ntsvcs.h" // NTSVC_NAME_*
1.1 root 78:
79: //---------------------------------------------------------------------------
80: #pragma package(smart_init)
1.1.1.2 ! root 81: #pragma link "trayicon"
! 82: #pragma link "Trayicon"
1.1 root 83: #pragma resource "*.dfm"
84: TMainForm *MainForm;
85:
86: #define LOG_TIME_FMT " m/d hh:mm:ssa/p"
87:
1.1.1.2 ! root 88: /* Service functions are NT-only, must call dynamically :-( */
! 89: typedef WINADVAPI SC_HANDLE (WINAPI *OpenSCManager_t)(LPCTSTR,LPCTSTR,DWORD);
! 90: typedef WINADVAPI SC_HANDLE (WINAPI *OpenService_t)(SC_HANDLE,LPCTSTR,DWORD);
! 91: typedef WINADVAPI BOOL (WINAPI *StartService_t)(SC_HANDLE,DWORD,LPCTSTR*);
! 92: typedef WINADVAPI BOOL (WINAPI *ControlService_t)(SC_HANDLE,DWORD,LPSERVICE_STATUS);
! 93: typedef WINADVAPI BOOL (WINAPI *QueryServiceStatus_t)(SC_HANDLE,LPSERVICE_STATUS);
! 94: typedef WINADVAPI BOOL (WINAPI *QueryServiceConfig_t)(SC_HANDLE,LPQUERY_SERVICE_CONFIG,DWORD,LPDWORD);
! 95: typedef WINADVAPI BOOL (WINAPI *CloseServiceHandle_t)(SC_HANDLE);
! 96:
! 97: OpenSCManager_t openSCManager;
! 98: OpenService_t openService;
! 99: StartService_t startService;
! 100: ControlService_t controlService;
! 101: QueryServiceStatus_t queryServiceStatus;
! 102: QueryServiceConfig_t queryServiceConfig;
! 103: CloseServiceHandle_t closeServiceHandle;
! 104:
! 105: SC_HANDLE hSCManager;
! 106: SC_HANDLE bbs_svc;
! 107: SC_HANDLE ftp_svc;
! 108: SC_HANDLE web_svc;
! 109: SC_HANDLE mail_svc;
! 110: SC_HANDLE services_svc;
! 111: SERVICE_STATUS bbs_svc_status;
! 112: SERVICE_STATUS ftp_svc_status;
! 113: SERVICE_STATUS web_svc_status;
! 114: SERVICE_STATUS mail_svc_status;
! 115: SERVICE_STATUS services_svc_status;
! 116: QUERY_SERVICE_CONFIG* bbs_svc_config;
! 117: DWORD bbs_svc_config_size;
! 118: QUERY_SERVICE_CONFIG* ftp_svc_config;
! 119: DWORD ftp_svc_config_size;
! 120: QUERY_SERVICE_CONFIG* web_svc_config;
! 121: DWORD web_svc_config_size;
! 122: QUERY_SERVICE_CONFIG* mail_svc_config;
! 123: DWORD mail_svc_config_size;
! 124: QUERY_SERVICE_CONFIG* services_svc_config;
! 125: DWORD services_svc_config_size;
1.1 root 126:
1.1.1.2 ! root 127: DWORD MaxLogLen=20000;
! 128: int threads=1;
! 129:
! 130: static void thread_up(void* p, BOOL up, BOOL setuid)
1.1 root 131: {
132: char str[128];
133: static HANDLE mutex;
134:
135: if(!mutex)
136: mutex=CreateMutex(NULL,false,NULL);
137: WaitForSingleObject(mutex,INFINITE);
138: if(up)
139: threads++;
140: else if(threads>0)
141: threads--;
142: sprintf(str,"Threads: %d",threads);
143: AnsiString Str=AnsiString(str);
144: if(MainForm->StatusBar->Panels->Items[0]->Text!=Str)
145: MainForm->StatusBar->Panels->Items[0]->Text=Str;
146: ReleaseMutex(mutex);
147: }
148:
149: int sockets=0;
150:
1.1.1.2 ! root 151: void socket_open(void* p, BOOL open)
1.1 root 152: {
153: char str[128];
154: static HANDLE mutex;
155:
156: if(!mutex)
157: mutex=CreateMutex(NULL,false,NULL);
158: WaitForSingleObject(mutex,INFINITE);
159: if(open)
160: sockets++;
161: else if(sockets>0)
162: sockets--;
163: sprintf(str,"Sockets: %d",sockets);
164: AnsiString Str=AnsiString(str);
165: if(MainForm->StatusBar->Panels->Items[1]->Text!=Str)
166: MainForm->StatusBar->Panels->Items[1]->Text=Str;
167: ReleaseMutex(mutex);
168: }
169:
170: int clients=0;
171: int total_clients=0;
172:
1.1.1.2 ! root 173: static void client_add(void* p, BOOL add)
1.1 root 174: {
175: char str[128];
176:
177: if(add) {
178: clients++;
179: total_clients++;
180: } else if(clients>0)
181: clients--;
182: sprintf(str,"Clients: %d",clients);
183: AnsiString Str=AnsiString(str);
184: if(MainForm->StatusBar->Panels->Items[2]->Text!=Str)
185: MainForm->StatusBar->Panels->Items[2]->Text=Str;
186:
187: sprintf(str,"Served: %d",total_clients);
188: Str=AnsiString(str);
189: if(MainForm->StatusBar->Panels->Items[3]->Text!=Str)
190: MainForm->StatusBar->Panels->Items[3]->Text=Str;
191: }
192:
1.1.1.2 ! root 193: static void client_on(void* p, BOOL on, int sock, client_t* client, BOOL update)
1.1 root 194: {
195: char str[128];
196: int i,j;
197: time_t t;
198: static HANDLE mutex;
199: TListItem* Item;
200:
201: if(!mutex)
202: mutex=CreateMutex(NULL,false,NULL);
203: WaitForSingleObject(mutex,INFINITE);
204: WaitForSingleObject(ClientForm->ListMutex,INFINITE);
205:
206: /* Search for exising entry for this socket */
207: for(i=0;i<ClientForm->ListView->Items->Count;i++) {
208: if(ClientForm->ListView->Items->Item[i]->Caption.ToIntDef(0)==sock)
209: break;
210: }
1.1.1.2 ! root 211: if(i>=ClientForm->ListView->Items->Count) {
! 212: if(update) { /* Can't update a non-existing entry */
! 213: ReleaseMutex(mutex);
! 214: ReleaseMutex(ClientForm->ListMutex);
! 215: return;
! 216: }
1.1 root 217: i=-1;
1.1.1.2 ! root 218: }
1.1 root 219:
1.1.1.2 ! root 220: if(on) {
! 221: if(!update)
! 222: client_add(NULL, TRUE);
! 223: } else { // Off
! 224: client_add(NULL, FALSE);
1.1 root 225: if(i>=0)
226: ClientForm->ListView->Items->Delete(i);
227: ReleaseMutex(mutex);
228: ReleaseMutex(ClientForm->ListMutex);
229: return;
230: }
231: if(client!=NULL && client->size==sizeof(client_t)) {
232: if(i>=0) {
233: Item=ClientForm->ListView->Items->Item[i];
234: } else {
235: Item=ClientForm->ListView->Items->Add();
236: Item->Data=(void*)client->time;
237: Item->Caption=sock;
238: }
239: Item->SubItems->Clear();
240: Item->SubItems->Add(client->protocol);
241: Item->SubItems->Add(client->user);
242: Item->SubItems->Add(client->addr);
243: Item->SubItems->Add(client->host);
244: Item->SubItems->Add(client->port);
245: t=time(NULL)-(time_t)Item->Data;
246: sprintf(str,"%d:%02d",t/60,t%60);
247: Item->SubItems->Add(str);
248: }
249: ReleaseMutex(mutex);
250: ReleaseMutex(ClientForm->ListMutex);
251: }
252:
1.1.1.2 ! root 253: static int bbs_lputs(void* p, int level, char *str)
1.1 root 254: {
255: static HANDLE mutex;
256:
257: if(!mutex)
258: mutex=CreateMutex(NULL,false,NULL);
259: WaitForSingleObject(mutex,INFINITE);
260:
1.1.1.2 ! root 261: while(MaxLogLen && TelnetForm->Log->Text.Length()>=MaxLogLen)
1.1 root 262: TelnetForm->Log->Lines->Delete(0);
263:
264: AnsiString Line=Now().FormatString(LOG_TIME_FMT)+" ";
265: Line+=AnsiString(str).Trim();
266: TelnetForm->Log->Lines->Add(Line);
267: ReleaseMutex(mutex);
268: return(Line.Length());
269: }
270:
1.1.1.2 ! root 271: static void bbs_status(void* p, char *str)
1.1 root 272: {
273: static HANDLE mutex;
274:
275: if(!mutex)
276: mutex=CreateMutex(NULL,false,NULL);
277: WaitForSingleObject(mutex,INFINITE);
278:
279: TelnetForm->Status->Caption=AnsiString(str);
280:
281: ReleaseMutex(mutex);
282: }
283:
1.1.1.2 ! root 284: static void bbs_clients(void* p, int clients)
1.1 root 285: {
286: static HANDLE mutex;
287: static save_clients;
288:
289: save_clients=clients;
290:
291: if(!mutex)
292: mutex=CreateMutex(NULL,false,NULL);
293: WaitForSingleObject(mutex,INFINITE);
294:
295: TelnetForm->ProgressBar->Max
296: =(MainForm->bbs_startup.last_node
297: -MainForm->bbs_startup.first_node)+1;
298: TelnetForm->ProgressBar->Position=clients;
299:
300: ReleaseMutex(mutex);
301: }
302:
1.1.1.2 ! root 303: static void bbs_terminated(void* p, int code)
1.1 root 304: {
305: Screen->Cursor=crDefault;
306: MainForm->TelnetStart->Enabled=true;
307: MainForm->TelnetStop->Enabled=false;
1.1.1.2 ! root 308: MainForm->TelnetRecycle->Enabled=false;
! 309: Application->ProcessMessages();
1.1 root 310: }
1.1.1.2 ! root 311: static void bbs_started(void* p)
1.1 root 312: {
313: Screen->Cursor=crDefault;
314: MainForm->TelnetStart->Enabled=false;
315: MainForm->TelnetStop->Enabled=true;
1.1.1.2 ! root 316: MainForm->TelnetRecycle->Enabled=true;
! 317: Application->ProcessMessages();
1.1 root 318: }
319: static void bbs_start(void)
320: {
321: Screen->Cursor=crAppStart;
1.1.1.2 ! root 322: bbs_status(NULL,"Starting");
! 323: SAFECOPY(MainForm->bbs_startup.ctrl_dir
! 324: ,MainForm->global.ctrl_dir);
! 325: SAFECOPY(MainForm->bbs_startup.temp_dir
! 326: ,MainForm->global.temp_dir);
! 327: SAFECOPY(MainForm->bbs_startup.host_name
! 328: ,MainForm->global.host_name);
! 329: MainForm->bbs_startup.sem_chk_freq=MainForm->global.sem_chk_freq;
! 330:
! 331: /* JavaScript operational parameters */
! 332: MainForm->bbs_startup.js_max_bytes=MainForm->global.js.max_bytes;
! 333: MainForm->bbs_startup.js_cx_stack=MainForm->global.js.cx_stack;
! 334: MainForm->bbs_startup.js_branch_limit=MainForm->global.js.branch_limit;
! 335: MainForm->bbs_startup.js_gc_interval=MainForm->global.js.gc_interval;
! 336: MainForm->bbs_startup.js_yield_interval=MainForm->global.js.yield_interval;
! 337:
1.1 root 338: _beginthread((void(*)(void*))bbs_thread,0,&MainForm->bbs_startup);
1.1.1.2 ! root 339: Application->ProcessMessages();
! 340: }
! 341:
! 342: static int event_lputs(int level, char *str)
! 343: {
! 344: static HANDLE mutex;
! 345:
! 346: if(!mutex)
! 347: mutex=CreateMutex(NULL,false,NULL);
! 348: WaitForSingleObject(mutex,INFINITE);
! 349:
! 350: while(MaxLogLen && EventsForm->Log->Text.Length()>=MaxLogLen)
! 351: EventsForm->Log->Lines->Delete(0);
! 352:
! 353: AnsiString Line=Now().FormatString(LOG_TIME_FMT)+" ";
! 354: Line+=AnsiString(str).Trim();
! 355: EventsForm->Log->Lines->Add(Line);
! 356: ReleaseMutex(mutex);
! 357: return(Line.Length());
! 358: }
! 359:
! 360: static int service_lputs(void* p, int level, char *str)
! 361: {
! 362: static HANDLE mutex;
! 363:
! 364: if(!mutex)
! 365: mutex=CreateMutex(NULL,false,NULL);
! 366: WaitForSingleObject(mutex,INFINITE);
! 367:
! 368: while(MaxLogLen && ServicesForm->Log->Text.Length()>=MaxLogLen)
! 369: ServicesForm->Log->Lines->Delete(0);
! 370:
! 371: AnsiString Line=Now().FormatString(LOG_TIME_FMT)+" ";
! 372: Line+=AnsiString(str).Trim();
! 373: ServicesForm->Log->Lines->Add(Line);
! 374: ReleaseMutex(mutex);
! 375: return(Line.Length());
! 376: }
! 377:
! 378: static void services_status(void* p, char *str)
! 379: {
! 380: static HANDLE mutex;
! 381:
! 382: if(!mutex)
! 383: mutex=CreateMutex(NULL,false,NULL);
! 384: WaitForSingleObject(mutex,INFINITE);
! 385:
! 386: ServicesForm->Status->Caption=AnsiString(str);
! 387:
! 388: ReleaseMutex(mutex);
! 389: }
! 390:
! 391: static void services_terminated(void* p, int code)
! 392: {
! 393: Screen->Cursor=crDefault;
! 394: MainForm->ServicesStart->Enabled=true;
! 395: MainForm->ServicesStop->Enabled=false;
! 396: MainForm->ServicesRecycle->Enabled=false;
! 397: Application->ProcessMessages();
! 398: }
! 399: static void services_started(void* p)
! 400: {
! 401: Screen->Cursor=crDefault;
! 402: MainForm->ServicesStart->Enabled=false;
! 403: MainForm->ServicesStop->Enabled=true;
! 404: MainForm->ServicesRecycle->Enabled=true;
! 405: Application->ProcessMessages();
1.1 root 406: }
407:
1.1.1.2 ! root 408: static void services_clients(void* p, int clients)
! 409: {
! 410: }
! 411:
! 412: static int mail_lputs(void* p, int level, char *str)
1.1 root 413: {
414: static HANDLE mutex;
415: static FILE* LogStream;
416:
417: if(!mutex)
418: mutex=CreateMutex(NULL,false,NULL);
419: WaitForSingleObject(mutex,INFINITE);
420:
421: if(str==NULL) {
422: if(LogStream!=NULL)
423: fclose(LogStream);
424: LogStream=NULL;
425: ReleaseMutex(mutex);
426: return(0);
427: }
428:
1.1.1.2 ! root 429: while(MaxLogLen && MailForm->Log->Text.Length()>=MaxLogLen)
1.1 root 430: MailForm->Log->Lines->Delete(0);
431:
432: AnsiString Line=Now().FormatString(LOG_TIME_FMT)+" ";
433: Line+=AnsiString(str).Trim();
434: MailForm->Log->Lines->Add(Line);
435:
436: if(MainForm->MailLogFile && MainForm->MailStop->Enabled) {
437: AnsiString LogFileName
438: =AnsiString(MainForm->cfg.data_dir)
439: +"LOGS\\MS"
440: +Now().FormatString("mmddyy")
441: +".LOG";
442:
443: if(!FileExists(LogFileName)) {
444: if(LogStream!=NULL) {
445: fclose(LogStream);
446: LogStream=NULL;
447: }
448: }
449: if(LogStream==NULL)
1.1.1.2 ! root 450: LogStream=_fsopen(LogFileName.c_str(),"a",SH_DENYNONE);
1.1 root 451:
452: if(LogStream!=NULL) {
453: Line=Now().FormatString("hh:mm:ss")+" ";
454: Line+=AnsiString(str).Trim();
455: Line+="\n";
456: fwrite(AnsiString(Line).c_str(),1,Line.Length(),LogStream);
457: }
458: }
459:
460: ReleaseMutex(mutex);
461: return(Line.Length());
462: }
463:
1.1.1.2 ! root 464: static void mail_status(void* p, char *str)
1.1 root 465: {
466: static HANDLE mutex;
467:
468: if(!mutex)
469: mutex=CreateMutex(NULL,false,NULL);
470: WaitForSingleObject(mutex,INFINITE);
471:
472: MailForm->Status->Caption=AnsiString(str);
473:
474: ReleaseMutex(mutex);
475: }
476:
1.1.1.2 ! root 477: static void mail_clients(void* p, int clients)
1.1 root 478: {
479: static HANDLE mutex;
480:
481: if(!mutex)
482: mutex=CreateMutex(NULL,false,NULL);
483: WaitForSingleObject(mutex,INFINITE);
484:
485: MailForm->ProgressBar->Max=MainForm->mail_startup.max_clients;
486: MailForm->ProgressBar->Position=clients;
487:
488: ReleaseMutex(mutex);
489: }
490:
1.1.1.2 ! root 491: static void mail_terminated(void* p, int code)
1.1 root 492: {
493: Screen->Cursor=crDefault;
494: MainForm->MailStart->Enabled=true;
495: MainForm->MailStop->Enabled=false;
1.1.1.2 ! root 496: MainForm->MailRecycle->Enabled=false;
! 497: Application->ProcessMessages();
1.1 root 498: }
1.1.1.2 ! root 499: static void mail_started(void* p)
1.1 root 500: {
501: Screen->Cursor=crDefault;
502: MainForm->MailStart->Enabled=false;
503: MainForm->MailStop->Enabled=true;
1.1.1.2 ! root 504: MainForm->MailRecycle->Enabled=true;
! 505: Application->ProcessMessages();
1.1 root 506: }
507: static void mail_start(void)
508: {
509: Screen->Cursor=crAppStart;
1.1.1.2 ! root 510: mail_status(NULL, "Starting");
! 511: SAFECOPY(MainForm->mail_startup.ctrl_dir
! 512: ,MainForm->global.ctrl_dir);
! 513: SAFECOPY(MainForm->mail_startup.host_name
! 514: ,MainForm->global.host_name);
! 515: MainForm->mail_startup.sem_chk_freq=MainForm->global.sem_chk_freq;
1.1 root 516: _beginthread((void(*)(void*))mail_server,0,&MainForm->mail_startup);
1.1.1.2 ! root 517: Application->ProcessMessages();
1.1 root 518: }
519:
1.1.1.2 ! root 520: static int ftp_lputs(void* p, int level, char *str)
1.1 root 521: {
522: static HANDLE mutex;
523: static FILE* LogStream;
524:
525: if(!mutex)
526: mutex=CreateMutex(NULL,false,NULL);
527: WaitForSingleObject(mutex,INFINITE);
528:
529: if(str==NULL) {
530: if(LogStream!=NULL)
531: fclose(LogStream);
532: LogStream=NULL;
533: ReleaseMutex(mutex);
534: return(0);
535: }
536:
1.1.1.2 ! root 537: while(MaxLogLen && FtpForm->Log->Text.Length()>=MaxLogLen)
1.1 root 538: FtpForm->Log->Lines->Delete(0);
539:
540: AnsiString Line=Now().FormatString(LOG_TIME_FMT)+" ";
541: Line+=AnsiString(str).Trim();
542: FtpForm->Log->Lines->Add(Line);
543:
544: if(MainForm->FtpLogFile && MainForm->FtpStop->Enabled) {
545: AnsiString LogFileName
546: =AnsiString(MainForm->cfg.data_dir)
547: +"LOGS\\FS"
548: +Now().FormatString("mmddyy")
549: +".LOG";
550:
551: if(!FileExists(LogFileName)) {
552: FileClose(FileCreate(LogFileName));
553: if(LogStream!=NULL) {
554: fclose(LogStream);
555: LogStream=NULL;
556: }
557: }
558: if(LogStream==NULL)
1.1.1.2 ! root 559: LogStream=_fsopen(LogFileName.c_str(),"a",SH_DENYNONE);
1.1 root 560:
561: if(LogStream!=NULL) {
562: Line=Now().FormatString("hh:mm:ss")+" ";
563: Line+=AnsiString(str).Trim();
564: Line+="\n";
565: fwrite(AnsiString(Line).c_str(),1,Line.Length(),LogStream);
566: }
567: }
568:
569: ReleaseMutex(mutex);
570: return(Line.Length());
571: }
572:
1.1.1.2 ! root 573: static void ftp_status(void* p, char *str)
1.1 root 574: {
575: static HANDLE mutex;
576:
577: if(!mutex)
578: mutex=CreateMutex(NULL,false,NULL);
579: WaitForSingleObject(mutex,INFINITE);
580:
581: FtpForm->Status->Caption=AnsiString(str);
582:
583: ReleaseMutex(mutex);
584: }
585:
1.1.1.2 ! root 586: static void ftp_clients(void* p, int clients)
1.1 root 587: {
588: static HANDLE mutex;
589:
590: if(!mutex)
591: mutex=CreateMutex(NULL,false,NULL);
592: WaitForSingleObject(mutex,INFINITE);
593:
594: FtpForm->ProgressBar->Max=MainForm->ftp_startup.max_clients;
595: FtpForm->ProgressBar->Position=clients;
596:
597: ReleaseMutex(mutex);
598: }
599:
1.1.1.2 ! root 600: static void ftp_terminated(void* p, int code)
1.1 root 601: {
602: Screen->Cursor=crDefault;
603: MainForm->FtpStart->Enabled=true;
604: MainForm->FtpStop->Enabled=false;
1.1.1.2 ! root 605: MainForm->FtpRecycle->Enabled=false;
! 606: Application->ProcessMessages();
1.1 root 607: }
1.1.1.2 ! root 608: static void ftp_started(void* p)
1.1 root 609: {
610: Screen->Cursor=crDefault;
611: MainForm->FtpStart->Enabled=false;
612: MainForm->FtpStop->Enabled=true;
1.1.1.2 ! root 613: MainForm->FtpRecycle->Enabled=true;
! 614: Application->ProcessMessages();
1.1 root 615: }
616: static void ftp_start(void)
617: {
618: Screen->Cursor=crAppStart;
1.1.1.2 ! root 619: ftp_status(NULL, "Starting");
! 620: SAFECOPY(MainForm->ftp_startup.ctrl_dir
! 621: ,MainForm->global.ctrl_dir);
! 622: SAFECOPY(MainForm->ftp_startup.temp_dir
! 623: ,MainForm->global.temp_dir);
! 624: SAFECOPY(MainForm->ftp_startup.host_name
! 625: ,MainForm->global.host_name);
! 626: MainForm->ftp_startup.sem_chk_freq=MainForm->global.sem_chk_freq;
! 627:
! 628: /* JavaScript operational parameters */
! 629: MainForm->ftp_startup.js_max_bytes=MainForm->global.js.max_bytes;
! 630: MainForm->ftp_startup.js_cx_stack=MainForm->global.js.cx_stack;
! 631:
1.1 root 632: _beginthread((void(*)(void*))ftp_server,0,&MainForm->ftp_startup);
1.1.1.2 ! root 633: Application->ProcessMessages();
1.1 root 634: }
635: //---------------------------------------------------------------------------
1.1.1.2 ! root 636: static int web_lputs(void* p, int level, char *str)
! 637: {
! 638: static HANDLE mutex;
! 639: static FILE* LogStream;
! 640:
! 641: if(!mutex)
! 642: mutex=CreateMutex(NULL,false,NULL);
! 643: WaitForSingleObject(mutex,INFINITE);
! 644:
! 645: if(str==NULL) {
! 646: if(LogStream!=NULL)
! 647: fclose(LogStream);
! 648: LogStream=NULL;
! 649: ReleaseMutex(mutex);
! 650: return(0);
! 651: }
! 652:
! 653: while(MaxLogLen && WebForm->Log->Text.Length()>=MaxLogLen)
! 654: WebForm->Log->Lines->Delete(0);
! 655:
! 656: AnsiString Line=Now().FormatString(LOG_TIME_FMT)+" ";
! 657: Line+=AnsiString(str).Trim();
! 658: WebForm->Log->Lines->Add(Line);
! 659: #if 0
! 660: if(MainForm->WebLogFile && MainForm->WebStop->Enabled) {
! 661: AnsiString LogFileName
! 662: =AnsiString(MainForm->cfg.data_dir)
! 663: +"LOGS\\FS"
! 664: +Now().FormatString("mmddyy")
! 665: +".LOG";
! 666:
! 667: if(!FileExists(LogFileName)) {
! 668: FileClose(FileCreate(LogFileName));
! 669: if(LogStream!=NULL) {
! 670: fclose(LogStream);
! 671: LogStream=NULL;
! 672: }
! 673: }
! 674: if(LogStream==NULL)
! 675: LogStream=_fsopen(LogFileName.c_str(),"a",SH_DENYNONE);
! 676:
! 677: if(LogStream!=NULL) {
! 678: Line=Now().FormatString("hh:mm:ss")+" ";
! 679: Line+=AnsiString(str).Trim();
! 680: Line+="\n";
! 681: fwrite(AnsiString(Line).c_str(),1,Line.Length(),LogStream);
! 682: }
! 683: }
! 684: #endif
! 685: ReleaseMutex(mutex);
! 686: return(Line.Length());
! 687: }
! 688:
! 689: static void web_status(void* p, char *str)
! 690: {
! 691: static HANDLE mutex;
! 692:
! 693: if(!mutex)
! 694: mutex=CreateMutex(NULL,false,NULL);
! 695: WaitForSingleObject(mutex,INFINITE);
! 696:
! 697: WebForm->Status->Caption=AnsiString(str);
! 698:
! 699: ReleaseMutex(mutex);
! 700: }
! 701:
! 702: static void web_clients(void* p, int clients)
! 703: {
! 704: static HANDLE mutex;
! 705:
! 706: if(!mutex)
! 707: mutex=CreateMutex(NULL,false,NULL);
! 708: WaitForSingleObject(mutex,INFINITE);
1.1 root 709:
1.1.1.2 ! root 710: WebForm->ProgressBar->Max=MainForm->ftp_startup.max_clients;
! 711: WebForm->ProgressBar->Position=clients;
! 712:
! 713: ReleaseMutex(mutex);
! 714: }
1.1 root 715:
1.1.1.2 ! root 716: static void web_terminated(void* p, int code)
! 717: {
! 718: Screen->Cursor=crDefault;
! 719: MainForm->WebStart->Enabled=true;
! 720: MainForm->WebStop->Enabled=false;
! 721: MainForm->WebRecycle->Enabled=false;
! 722: Application->ProcessMessages();
! 723: }
! 724: static void web_started(void* p)
! 725: {
! 726: Screen->Cursor=crDefault;
! 727: MainForm->WebStart->Enabled=false;
! 728: MainForm->WebStop->Enabled=true;
! 729: MainForm->WebRecycle->Enabled=true;
! 730: Application->ProcessMessages();
! 731: }
! 732: static void web_start(void)
! 733: {
! 734: Screen->Cursor=crAppStart;
! 735: web_status(NULL, "Starting");
! 736: SAFECOPY(MainForm->web_startup.ctrl_dir
! 737: ,MainForm->global.ctrl_dir);
! 738: SAFECOPY(MainForm->web_startup.host_name
! 739: ,MainForm->global.host_name);
! 740: MainForm->web_startup.sem_chk_freq=MainForm->global.sem_chk_freq;
! 741:
! 742: /* JavaScript operational parameters */
! 743: MainForm->web_startup.js_max_bytes=MainForm->global.js.max_bytes;
! 744: MainForm->web_startup.js_cx_stack=MainForm->global.js.cx_stack;
! 745:
! 746: _beginthread((void(*)(void*))web_server,0,&MainForm->web_startup);
! 747: Application->ProcessMessages();
! 748: }
! 749: //---------------------------------------------------------------------------
! 750: /* Server recycle callback (read relevant startup .ini file section) */
! 751: static void recycle(void* cbdata)
! 752: {
! 753: char str[MAX_PATH*2];
! 754: FILE* fp=NULL;
! 755: bbs_startup_t* bbs=NULL;
! 756: ftp_startup_t* ftp=NULL;
! 757: web_startup_t* web=NULL;
! 758: mail_startup_t* mail=NULL;
! 759: services_startup_t* services=NULL;
! 760:
! 761: SAFEPRINTF(str,"Reading %s",MainForm->ini_file);
! 762: if(cbdata==(void*)&MainForm->bbs_startup) {
! 763: bbs=&MainForm->bbs_startup;
! 764: bbs_lputs(cbdata,LOG_INFO,str);
! 765: } else if(cbdata==(void*)&MainForm->ftp_startup) {
! 766: ftp=&MainForm->ftp_startup;
! 767: ftp_lputs(cbdata,LOG_INFO,str);
! 768: } else if(cbdata==(void*)&MainForm->web_startup) {
! 769: web=&MainForm->web_startup;
! 770: web_lputs(cbdata,LOG_INFO,str);
! 771: } else if(cbdata==(void*)&MainForm->mail_startup) {
! 772: mail=&MainForm->mail_startup;
! 773: mail_lputs(cbdata,LOG_INFO,str);
! 774: } else if(cbdata==(void*)&MainForm->services_startup) {
! 775: services=&MainForm->services_startup;
! 776: service_lputs(cbdata,LOG_INFO,str);
! 777: }
! 778:
! 779: fp=fopen(MainForm->ini_file,"r");
! 780: sbbs_read_ini(fp
! 781: ,&MainForm->global
! 782: ,NULL ,bbs
! 783: ,NULL ,ftp
! 784: ,NULL ,web
! 785: ,NULL ,mail
! 786: ,NULL ,services
! 787: );
! 788: if(fp!=NULL)
! 789: fclose(fp);
! 790: }
1.1 root 791: //---------------------------------------------------------------------------
792: __fastcall TMainForm::TMainForm(TComponent* Owner)
793: : TForm(Owner)
794: {
1.1.1.2 ! root 795: /* Defaults */
! 796: SAFECOPY(global.ctrl_dir,"c:\\sbbs\\ctrl\\");
! 797: global.js.max_bytes=JAVASCRIPT_MAX_BYTES;
! 798: global.js.cx_stack=JAVASCRIPT_CONTEXT_STACK;
! 799: global.js.branch_limit=JAVASCRIPT_BRANCH_LIMIT;
! 800: global.js.gc_interval=JAVASCRIPT_GC_INTERVAL;
! 801: global.js.yield_interval=JAVASCRIPT_YIELD_INTERVAL;
! 802: global.sem_chk_freq=5; /* seconds */
! 803:
! 804: /* These are SBBSCTRL-specific */
! 805: LoginCommand="telnet://localhost";
! 806: ConfigCommand="%sscfg.exe %s -l25";
! 807: MinimizeToSysTray=false;
! 808: UndockableForms=false;
! 809: UseFileAssociations=true;
! 810: Initialized=false;
! 811:
! 812: char* p;
! 813: if((p=getenv("SBBSCTRL"))!=NULL)
! 814: SAFECOPY(global.ctrl_dir,p);
! 815: p=lastchar(global.ctrl_dir);
! 816: if(*p!='/' && *p!='\\')
! 817: strcat(global.ctrl_dir,"\\");
! 818:
1.1 root 819: memset(&bbs_startup,0,sizeof(bbs_startup));
820: bbs_startup.size=sizeof(bbs_startup);
1.1.1.2 ! root 821: bbs_startup.cbdata=&bbs_startup;
1.1 root 822: bbs_startup.first_node=1;
823: bbs_startup.last_node=4;
1.1.1.2 ! root 824: bbs_startup.options=BBS_OPT_XTRN_MINIMIZED|BBS_OPT_SYSOP_AVAILABLE;
! 825: bbs_startup.telnet_port=IPPORT_TELNET;
1.1 root 826: bbs_startup.telnet_interface=INADDR_ANY;
827: bbs_startup.rlogin_port=513;
828: bbs_startup.rlogin_interface=INADDR_ANY;
829: bbs_startup.lputs=bbs_lputs;
830: bbs_startup.status=bbs_status;
831: bbs_startup.clients=bbs_clients;
832: bbs_startup.started=bbs_started;
1.1.1.2 ! root 833: bbs_startup.recycle=recycle;
1.1 root 834: bbs_startup.terminated=bbs_terminated;
835: bbs_startup.thread_up=thread_up;
836: bbs_startup.client_on=client_on;
837: bbs_startup.socket_open=socket_open;
1.1.1.2 ! root 838: bbs_startup.event_lputs=event_lputs;
1.1 root 839:
840: memset(&mail_startup,0,sizeof(mail_startup));
841: mail_startup.size=sizeof(mail_startup);
1.1.1.2 ! root 842: mail_startup.cbdata=&mail_startup;
1.1 root 843: mail_startup.smtp_port=IPPORT_SMTP;
844: mail_startup.relay_port=IPPORT_SMTP;
845: mail_startup.pop3_port=110;
846: mail_startup.interface_addr=INADDR_ANY;
847: mail_startup.lputs=mail_lputs;
848: mail_startup.status=mail_status;
849: mail_startup.clients=mail_clients;
850: mail_startup.started=mail_started;
1.1.1.2 ! root 851: mail_startup.recycle=recycle;
1.1 root 852: mail_startup.terminated=mail_terminated;
853: mail_startup.options=MAIL_OPT_ALLOW_POP3;
854: mail_startup.thread_up=thread_up;
855: mail_startup.client_on=client_on;
856: mail_startup.socket_open=socket_open;
1.1.1.2 ! root 857: mail_startup.max_delivery_attempts=50;
! 858: mail_startup.rescan_frequency=3600; /* 60 minutes */
! 859: mail_startup.lines_per_yield=10;
! 860: mail_startup.max_clients=10;
! 861: mail_startup.max_msg_size=10*1024*1024;
1.1 root 862:
863: memset(&ftp_startup,0,sizeof(ftp_startup));
864: ftp_startup.size=sizeof(ftp_startup);
1.1.1.2 ! root 865: ftp_startup.cbdata=&ftp_startup;
1.1 root 866: ftp_startup.port=IPPORT_FTP;
867: ftp_startup.interface_addr=INADDR_ANY;
868: ftp_startup.lputs=ftp_lputs;
869: ftp_startup.status=ftp_status;
870: ftp_startup.clients=ftp_clients;
871: ftp_startup.started=ftp_started;
1.1.1.2 ! root 872: ftp_startup.recycle=recycle;
1.1 root 873: ftp_startup.terminated=ftp_terminated;
874: ftp_startup.thread_up=thread_up;
875: ftp_startup.client_on=client_on;
876: ftp_startup.socket_open=socket_open;
1.1.1.2 ! root 877: ftp_startup.options
! 878: =FTP_OPT_INDEX_FILE|FTP_OPT_HTML_INDEX_FILE|FTP_OPT_ALLOW_QWK;
! 879: ftp_startup.max_clients=10;
1.1 root 880: strcpy(ftp_startup.index_file_name,"00index");
1.1.1.2 ! root 881: strcpy(ftp_startup.html_index_file,"00index.html");
! 882: strcpy(ftp_startup.html_index_script,"ftp-html.js");
! 883:
! 884: memset(&web_startup,0,sizeof(web_startup));
! 885: web_startup.size=sizeof(web_startup);
! 886: web_startup.cbdata=&web_startup;
! 887: web_startup.lputs=web_lputs;
! 888: web_startup.status=web_status;
! 889: web_startup.clients=web_clients;
! 890: web_startup.started=web_started;
! 891: web_startup.recycle=recycle;
! 892: web_startup.terminated=web_terminated;
! 893: web_startup.thread_up=thread_up;
! 894: web_startup.client_on=client_on;
! 895: web_startup.socket_open=socket_open;
! 896:
! 897: memset(&services_startup,0,sizeof(services_startup));
! 898: services_startup.size=sizeof(services_startup);
! 899: services_startup.cbdata=&services_startup;
! 900: services_startup.interface_addr=INADDR_ANY;
! 901: services_startup.lputs=service_lputs;
! 902: services_startup.status=services_status;
! 903: services_startup.clients=services_clients;
! 904: services_startup.started=services_started;
! 905: services_startup.recycle=recycle;
! 906: services_startup.terminated=services_terminated;
! 907: services_startup.thread_up=thread_up;
! 908: services_startup.client_on=client_on;
! 909: services_startup.socket_open=socket_open;
! 910:
! 911: bbs_log=INVALID_HANDLE_VALUE;
! 912: event_log=INVALID_HANDLE_VALUE;
! 913: ftp_log=INVALID_HANDLE_VALUE;
! 914: web_log=INVALID_HANDLE_VALUE;
! 915: mail_log=INVALID_HANDLE_VALUE;
! 916: services_log=INVALID_HANDLE_VALUE;
1.1 root 917:
918: /* Default local "Spy Terminal" settings */
919: SpyTerminalFont=new TFont;
920: SpyTerminalFont->Name="Terminal";
921: SpyTerminalFont->Size=9;
922: SpyTerminalFont->Pitch=fpFixed;
923: SpyTerminalWidth=434;
924: SpyTerminalHeight=365;
925: SpyTerminalKeyboardActive=true;
1.1.1.2 ! root 926:
! 927: Application->OnMinimize=FormMinimize;
! 928:
! 929: /* Get pointers to NT Service functions */
! 930: HANDLE hSCMlib = LoadLibrary("ADVAPI32.DLL");
! 931: if(hSCMlib!=NULL) {
! 932: openSCManager=(OpenSCManager_t)GetProcAddress(hSCMlib, "OpenSCManagerA");
! 933: openService=(OpenService_t)GetProcAddress(hSCMlib,"OpenServiceA");
! 934: startService=(StartService_t)GetProcAddress(hSCMlib,"StartServiceA");
! 935: controlService=(ControlService_t)GetProcAddress(hSCMlib,"ControlService");
! 936: queryServiceStatus=(QueryServiceStatus_t)GetProcAddress(hSCMlib,"QueryServiceStatus");
! 937: queryServiceConfig=(QueryServiceConfig_t)GetProcAddress(hSCMlib,"QueryServiceConfigA");
! 938: closeServiceHandle=(CloseServiceHandle_t)GetProcAddress(hSCMlib,"CloseServiceHandle");
! 939: FreeLibrary(hSCMlib);
! 940: }
! 941:
! 942: /* Open Service Manager */
! 943: if(openSCManager!=NULL)
! 944: hSCManager = openSCManager(
! 945: NULL, // machine (NULL == local)
! 946: NULL, // database (NULL == default)
! 947: SC_MANAGER_ALL_ACCESS // access required
! 948: );
! 949:
! 950: /* Open Synchronet Services */
! 951: if(hSCManager!=NULL) {
! 952: bbs_svc = openService(hSCManager, NTSVC_NAME_BBS, SERVICE_ALL_ACCESS);
! 953: ftp_svc = openService(hSCManager, NTSVC_NAME_FTP, SERVICE_ALL_ACCESS);
! 954: web_svc = openService(hSCManager, NTSVC_NAME_WEB, SERVICE_ALL_ACCESS);
! 955: mail_svc = openService(hSCManager, NTSVC_NAME_MAIL, SERVICE_ALL_ACCESS);
! 956: services_svc = openService(hSCManager, NTSVC_NAME_SERVICES, SERVICE_ALL_ACCESS);
! 957: }
1.1 root 958: }
959: //---------------------------------------------------------------------------
960: void __fastcall TMainForm::FileExitMenuItemClick(TObject *Sender)
961: {
962: Close();
963: }
964: void __fastcall TMainForm::FormCreate(TObject *Sender)
965: {
966: Height=400; // Just incase we mess it up in the IDE
967: Width=700;
968:
1.1.1.2 ! root 969: // Verify SBBS.DLL version
! 970: long bbs_ver = bbs_ver_num();
! 971: if(bbs_ver < (0x31200 | 'A'-'A') || bbs_ver > (0x399<<8)) {
! 972: char str[128];
! 973: sprintf(str,"Incorrect SBBS.DLL Version (%lX)",bbs_ver);
! 974: Application->MessageBox(str,"ERROR",MB_OK|MB_ICONEXCLAMATION);
1.1 root 975: Application->Terminate();
976: }
977:
978: // Read Registry keys
979: TRegistry* Registry=new TRegistry;
980: if(!Registry->OpenKey(REG_KEY,true)) {
981: Application->MessageBox("Error opening registry key"
982: ,REG_KEY,MB_OK|MB_ICONEXCLAMATION);
983: Application->Terminate();
1.1.1.2 ! root 984: return;
1.1 root 985: }
986: if(Registry->ValueExists("MainFormTop"))
987: Top=Registry->ReadInteger("MainFormTop");
988: if(Registry->ValueExists("MainFormLeft"))
989: Left=Registry->ReadInteger("MainFormLeft");
990: if(Registry->ValueExists("MainFormHeight"))
991: Height=Registry->ReadInteger("MainFormHeight");
992: if(Registry->ValueExists("MainFormWidth"))
993: Width=Registry->ReadInteger("MainFormWidth");
994: else
995: WindowState=wsMaximized; // Default to fullscreen
996: if(Registry->ValueExists("SpyTerminalWidth"))
997: SpyTerminalWidth=Registry->ReadInteger("SpyTerminalWidth");
998: if(Registry->ValueExists("SpyTerminalHeight"))
999: SpyTerminalHeight=Registry->ReadInteger("SpyTerminalHeight");
1000: if(Registry->ValueExists("SpyTerminalFontName"))
1001: SpyTerminalFont->Name=Registry->ReadString("SpyTerminalFontName");
1002: if(Registry->ValueExists("SpyTerminalFontSize"))
1003: SpyTerminalFont->Size=Registry->ReadInteger("SpyTerminalFontSize");
1004: if(Registry->ValueExists("SpyTerminalKeyboardActive"))
1005: SpyTerminalKeyboardActive
1006: =Registry->ReadBool("SpyTerminalKeyboardActive");
1007:
1008: Registry->CloseKey();
1009: delete Registry;
1010: }
1011: //---------------------------------------------------------------------------
1012: void __fastcall TMainForm::FormShow(TObject *Sender)
1013: {
1014: StartupTimer->Enabled=true;
1015: }
1016: //---------------------------------------------------------------------------
1017:
1018: void __fastcall TMainForm::ViewToolbarMenuItemClick(TObject *Sender)
1019: {
1.1.1.2 ! root 1020: Toolbar->Visible=ViewToolbarMenuItem->Checked;
1.1 root 1021: }
1022: //---------------------------------------------------------------------------
1023: void __fastcall TMainForm::FormClose(TObject *Sender, TCloseAction &Action)
1024: {
1.1.1.2 ! root 1025: UpTimer->Enabled=false; /* Stop updating the status bar */
1.1 root 1026:
1.1.1.2 ! root 1027: if(TrayIcon->Visible) /* minimized to tray? */
! 1028: TrayIcon->Visible=false; /* restore to avoid crash */
! 1029:
! 1030: /* This is necessary to save form sizes/positions */
! 1031: if(Initialized) /* Don't overwrite registry settings with defaults */
! 1032: SaveRegistrySettings(Sender);
! 1033:
! 1034: StatusBar->Panels->Items[4]->Text="Closing...";
! 1035: time_t start=time(NULL);
! 1036: while( (bbs_svc==NULL && TelnetStop->Enabled)
! 1037: || (mail_svc==NULL && MailStop->Enabled)
! 1038: || (ftp_svc==NULL && FtpStop->Enabled)
! 1039: || (web_svc==NULL && WebStop->Enabled)
! 1040: || (services_svc==NULL && ServicesStop->Enabled)) {
! 1041: if(time(NULL)-start>30)
! 1042: break;
! 1043: Application->ProcessMessages();
! 1044: YIELD();
! 1045: }
! 1046: /* Extra time for callbacks to be called by child threads */
! 1047: start=time(NULL);
! 1048: while(time(NULL)<start+2) {
! 1049: Application->ProcessMessages();
! 1050: YIELD();
! 1051: }
! 1052: #if 0
! 1053: if(hSCManager!=NULL)
! 1054: closeServiceHandle(hSCManager);
! 1055: #endif
1.1 root 1056: }
1057: //---------------------------------------------------------------------------
1058:
1059: void __fastcall TMainForm::FormCloseQuery(TObject *Sender, bool &CanClose)
1060: {
1.1.1.2 ! root 1061: CanClose=false;
1.1 root 1062:
1.1.1.2 ! root 1063: if(TelnetStop->Enabled && bbs_svc==NULL) {
1.1 root 1064: if(TelnetForm->ProgressBar->Position
1065: && Application->MessageBox("Shut down the Telnet Server?"
1066: ,"Telnet Server In Use", MB_OKCANCEL)!=IDOK)
1067: return;
1068: TelnetStopExecute(Sender);
1069: }
1070:
1.1.1.2 ! root 1071: if(MailStop->Enabled && mail_svc==NULL) {
1.1 root 1072: if(MailForm->ProgressBar->Position
1073: && Application->MessageBox("Shut down the Mail Server?"
1074: ,"Mail Server In Use", MB_OKCANCEL)!=IDOK)
1075: return;
1076: MailStopExecute(Sender);
1077: }
1078:
1.1.1.2 ! root 1079: if(FtpStop->Enabled && ftp_svc==NULL) {
1.1 root 1080: if(FtpForm->ProgressBar->Position
1081: && Application->MessageBox("Shut down the FTP Server?"
1082: ,"FTP Server In Use", MB_OKCANCEL)!=IDOK)
1083: return;
1084: FtpStopExecute(Sender);
1085: }
1086:
1.1.1.2 ! root 1087: if(WebStop->Enabled && web_svc==NULL) {
! 1088: if(WebForm->ProgressBar->Position
! 1089: && Application->MessageBox("Shut down the Web Server?"
! 1090: ,"Web Server In Use", MB_OKCANCEL)!=IDOK)
! 1091: return;
! 1092: WebStopExecute(Sender);
! 1093: }
! 1094:
! 1095: if(ServicesStop->Enabled && services_svc==NULL)
! 1096: ServicesStopExecute(Sender);
! 1097:
! 1098: CanClose=true;
! 1099: }
! 1100: //---------------------------------------------------------------------------
! 1101: BOOL StartNTsvc(SC_HANDLE svc, SERVICE_STATUS* status, QUERY_SERVICE_CONFIG* config, DWORD config_size)
! 1102: {
! 1103: if(svc==NULL || startService==NULL || queryServiceStatus==NULL || config==NULL)
! 1104: return(FALSE);
! 1105:
! 1106: DWORD ret;
! 1107: if(!queryServiceConfig(svc,config,config_size,&ret))
! 1108: return(FALSE);
! 1109: if(config->dwStartType==SERVICE_DISABLED)
! 1110: return(FALSE);
! 1111: if(!queryServiceStatus(svc,status))
! 1112: return(FALSE);
! 1113: if(status->dwCurrentState!=SERVICE_STOPPED)
! 1114: return(TRUE);
! 1115: if(!startService(svc,0,NULL))
! 1116: Application->MessageBox(AnsiString("ERROR " + IntToStr(GetLastError()) +
! 1117: " starting " + config->lpDisplayName).c_str()
! 1118: ,"ERROR"
! 1119: ,MB_OK|MB_ICONEXCLAMATION);
! 1120: return(TRUE);
1.1 root 1121: }
1122: //---------------------------------------------------------------------------
1123: void __fastcall TMainForm::TelnetStartExecute(TObject *Sender)
1124: {
1.1.1.2 ! root 1125: if(!StartNTsvc(bbs_svc,&bbs_svc_status,bbs_svc_config,bbs_svc_config_size))
! 1126: bbs_start();
! 1127: }
! 1128: //---------------------------------------------------------------------------
! 1129: void __fastcall TMainForm::ServicesStartExecute(TObject *Sender)
! 1130: {
! 1131: if(StartNTsvc(services_svc,&services_svc_status,services_svc_config,services_svc_config_size))
! 1132: return;
! 1133: Screen->Cursor=crAppStart;
! 1134: services_status(NULL, "Starting");
! 1135:
! 1136: SAFECOPY(MainForm->services_startup.ctrl_dir
! 1137: ,MainForm->global.ctrl_dir);
! 1138: SAFECOPY(MainForm->services_startup.host_name
! 1139: ,MainForm->global.host_name);
! 1140: MainForm->services_startup.sem_chk_freq=global.sem_chk_freq;
! 1141:
! 1142: /* JavaScript operational parameters */
! 1143: MainForm->services_startup.js_max_bytes=MainForm->global.js.max_bytes;
! 1144: MainForm->services_startup.js_cx_stack=MainForm->global.js.cx_stack;
! 1145: MainForm->services_startup.js_branch_limit=MainForm->global.js.branch_limit;
! 1146: MainForm->services_startup.js_gc_interval=MainForm->global.js.gc_interval;
! 1147: MainForm->services_startup.js_yield_interval=MainForm->global.js.yield_interval;
! 1148:
! 1149: _beginthread((void(*)(void*))services_thread,0,&MainForm->services_startup);
! 1150: Application->ProcessMessages();
! 1151: }
! 1152:
! 1153: //---------------------------------------------------------------------------
! 1154: BOOL StopNTsvc(SC_HANDLE svc, SERVICE_STATUS* status)
! 1155: {
! 1156: if(svc==NULL || controlService==NULL)
! 1157: return(FALSE);
! 1158:
! 1159: return controlService(svc,SERVICE_CONTROL_STOP,status);
! 1160: }
! 1161:
! 1162: //---------------------------------------------------------------------------
! 1163:
! 1164: void __fastcall TMainForm::ServicesStopExecute(TObject *Sender)
! 1165: {
! 1166: if(StopNTsvc(services_svc,&services_svc_status))
! 1167: return;
! 1168: Screen->Cursor=crAppStart;
! 1169: services_status(NULL, "Terminating");
! 1170: services_terminate();
! 1171: Application->ProcessMessages();
1.1 root 1172: }
1173: //---------------------------------------------------------------------------
1174:
1175: void __fastcall TMainForm::TelnetStopExecute(TObject *Sender)
1176: {
1.1.1.2 ! root 1177: if(StopNTsvc(bbs_svc,&bbs_svc_status))
! 1178: return;
! 1179: Screen->Cursor=crAppStart;
! 1180: bbs_status(NULL, "Terminating");
! 1181: bbs_terminate();
! 1182: Application->ProcessMessages();
1.1 root 1183: }
1184: //---------------------------------------------------------------------------
1185:
1186: void __fastcall TMainForm::TelnetConfigureExecute(TObject *Sender)
1187: {
1.1.1.2 ! root 1188: static inside;
! 1189: if(inside) return;
! 1190: inside=true;
! 1191:
1.1 root 1192: Application->CreateForm(__classid(TTelnetCfgDlg), &TelnetCfgDlg);
1193: TelnetCfgDlg->ShowModal();
1194: delete TelnetCfgDlg;
1.1.1.2 ! root 1195:
! 1196: inside=false;
1.1 root 1197: }
1198: //---------------------------------------------------------------------------
1199:
1200:
1201: void __fastcall TMainForm::NodeListStartExecute(TObject *Sender)
1202: {
1203: NodeForm->Timer->Enabled=true;
1204: NodeListStart->Enabled=false;
1205: NodeListStop->Enabled=true;
1206: }
1207: //---------------------------------------------------------------------------
1208:
1209: void __fastcall TMainForm::NodeListStopExecute(TObject *Sender)
1210: {
1211: NodeForm->Timer->Enabled=false;
1212: NodeListStart->Enabled=true;
1213: NodeListStop->Enabled=false;
1214: }
1215: //---------------------------------------------------------------------------
1216:
1217:
1218: void __fastcall TMainForm::MailConfigureExecute(TObject *Sender)
1219: {
1.1.1.2 ! root 1220: static inside;
! 1221: if(inside) return;
! 1222: inside=true;
! 1223:
1.1 root 1224: Application->CreateForm(__classid(TMailCfgDlg), &MailCfgDlg);
1225: MailCfgDlg->ShowModal();
1226: delete MailCfgDlg;
1.1.1.2 ! root 1227:
! 1228: inside=false;
1.1 root 1229: }
1230: //---------------------------------------------------------------------------
1231:
1232: void __fastcall TMainForm::MailStartExecute(TObject *Sender)
1233: {
1.1.1.2 ! root 1234: if(!StartNTsvc(mail_svc,&mail_svc_status,mail_svc_config,mail_svc_config_size))
! 1235: mail_start();
1.1 root 1236: }
1237: //---------------------------------------------------------------------------
1238:
1239: void __fastcall TMainForm::MailStopExecute(TObject *Sender)
1240: {
1.1.1.2 ! root 1241: if(StopNTsvc(mail_svc,&mail_svc_status))
! 1242: return;
! 1243: Screen->Cursor=crAppStart;
! 1244: mail_status(NULL, "Terminating");
! 1245: mail_terminate();
! 1246: Application->ProcessMessages();
1.1 root 1247: }
1248: //---------------------------------------------------------------------------
1249: void __fastcall TMainForm::ViewTelnetExecute(TObject *Sender)
1250: {
1.1.1.2 ! root 1251: TelnetForm->Visible=ViewTelnet->Checked;
! 1252: }
! 1253: //---------------------------------------------------------------------------
! 1254: void __fastcall TMainForm::ViewEventsExecute(TObject *Sender)
! 1255: {
! 1256: EventsForm->Visible=ViewEvents->Checked;
1.1 root 1257: }
1258: //---------------------------------------------------------------------------
1259:
1260: void __fastcall TMainForm::ViewNodesExecute(TObject *Sender)
1261: {
1.1.1.2 ! root 1262: NodeForm->Visible=ViewNodes->Checked;
1.1 root 1263: }
1264: //---------------------------------------------------------------------------
1265:
1266: void __fastcall TMainForm::ViewMailServerExecute(TObject *Sender)
1267: {
1.1.1.2 ! root 1268: MailForm->Visible=ViewMailServer->Checked;
1.1 root 1269: }
1270: //---------------------------------------------------------------------------
1271:
1272: void __fastcall TMainForm::ViewFtpServerExecute(TObject *Sender)
1273: {
1.1.1.2 ! root 1274: FtpForm->Visible=ViewFtpServer->Checked;
! 1275: }
! 1276: //---------------------------------------------------------------------------
! 1277: void __fastcall TMainForm::ViewWebServerExecute(TObject *Sender)
! 1278: {
! 1279: WebForm->Visible=ViewWebServer->Checked;
! 1280: }
! 1281: //---------------------------------------------------------------------------
! 1282: void __fastcall TMainForm::ViewServicesExecute(TObject *Sender)
! 1283: {
! 1284: ServicesForm->Visible=ViewServices->Checked;
! 1285: }
! 1286: //---------------------------------------------------------------------------
! 1287: void __fastcall TMainForm::ViewStatsExecute(TObject *Sender)
! 1288: {
! 1289: StatsForm->Visible=ViewStats->Checked;
! 1290: }
! 1291: //---------------------------------------------------------------------------
! 1292: void __fastcall TMainForm::ViewClientsExecute(TObject *Sender)
! 1293: {
! 1294: ClientForm->Visible=ViewClients->Checked;
1.1 root 1295: }
1296: //---------------------------------------------------------------------------
1297: void __fastcall TMainForm::FtpStartExecute(TObject *Sender)
1298: {
1.1.1.2 ! root 1299: if(!StartNTsvc(ftp_svc,&ftp_svc_status,ftp_svc_config,ftp_svc_config_size))
! 1300: ftp_start();
1.1 root 1301: }
1302: //---------------------------------------------------------------------------
1303:
1304: void __fastcall TMainForm::FtpStopExecute(TObject *Sender)
1305: {
1.1.1.2 ! root 1306: if(StopNTsvc(ftp_svc,&ftp_svc_status))
! 1307: return;
! 1308: Screen->Cursor=crAppStart;
! 1309: ftp_status(NULL, "Terminating");
! 1310: ftp_terminate();
! 1311: Application->ProcessMessages();
1.1 root 1312: }
1313: //---------------------------------------------------------------------------
1314:
1315: void __fastcall TMainForm::FtpConfigureExecute(TObject *Sender)
1316: {
1.1.1.2 ! root 1317: static inside;
! 1318: if(inside) return;
! 1319: inside=true;
! 1320:
1.1 root 1321: Application->CreateForm(__classid(TFtpCfgDlg), &FtpCfgDlg);
1322: FtpCfgDlg->ShowModal();
1323: delete FtpCfgDlg;
1.1.1.2 ! root 1324:
! 1325: inside=false;
1.1 root 1326: }
1327: //---------------------------------------------------------------------------
1.1.1.2 ! root 1328: void __fastcall TMainForm::WebStartExecute(TObject *Sender)
! 1329: {
! 1330: if(!StartNTsvc(web_svc,&web_svc_status,web_svc_config,web_svc_config_size))
! 1331: web_start();
! 1332: }
! 1333: //---------------------------------------------------------------------------
! 1334: void __fastcall TMainForm::WebStopExecute(TObject *Sender)
1.1 root 1335: {
1.1.1.2 ! root 1336: if(StopNTsvc(web_svc,&web_svc_status))
! 1337: return;
! 1338: Screen->Cursor=crAppStart;
! 1339: web_status(NULL, "Terminating");
! 1340: web_terminate();
! 1341: Application->ProcessMessages();
1.1 root 1342: }
1343: //---------------------------------------------------------------------------
1.1.1.2 ! root 1344: void __fastcall TMainForm::WebConfigureExecute(TObject *Sender)
! 1345: {
! 1346: static inside;
! 1347: if(inside) return;
! 1348: inside=true;
! 1349:
! 1350: Application->CreateForm(__classid(TWebCfgDlg), &WebCfgDlg);
! 1351: WebCfgDlg->ShowModal();
! 1352: delete WebCfgDlg;
1.1 root 1353:
1.1.1.2 ! root 1354: inside=false;
! 1355: }
! 1356: //---------------------------------------------------------------------------
1.1 root 1357: void __fastcall TMainForm::BBSConfigureMenuItemClick(TObject *Sender)
1358: {
1359: char str[256];
1360:
1361: sprintf(str,ConfigCommand.c_str()
1362: ,cfg.exec_dir, cfg.ctrl_dir);
1363: STARTUPINFO startup_info={0};
1364: PROCESS_INFORMATION process_info;
1365: startup_info.cb=sizeof(startup_info);
1.1.1.2 ! root 1366: startup_info.lpTitle="Synchronet Configuration Utility";
1.1 root 1367: CreateProcess(
1368: NULL, // pointer to name of executable module
1369: str, // pointer to command line string
1370: NULL, // process security attributes
1371: NULL, // thread security attributes
1.1.1.2 ! root 1372: FALSE, // handle inheritance flag
1.1 root 1373: CREATE_NEW_CONSOLE|CREATE_SEPARATE_WOW_VDM, // creation flags
1374: NULL, // pointer to new environment block
1375: cfg.ctrl_dir, // pointer to current directory name
1376: &startup_info, // pointer to STARTUPINFO
1377: &process_info // pointer to PROCESS_INFORMATION
1378: );
1.1.1.2 ! root 1379: // Resource leak if you don't close these:
! 1380: CloseHandle(process_info.hThread);
! 1381: CloseHandle(process_info.hProcess);
1.1 root 1382: }
1383: //---------------------------------------------------------------------------
1384:
1385:
1386:
1387:
1388: void __fastcall TMainForm::NodeCloseButtonClick(TObject *Sender)
1389: {
1390: ViewNodesExecute(Sender);
1391: }
1392: //---------------------------------------------------------------------------
1393:
1394: void __fastcall TMainForm::TelnetCloseButtonClick(TObject *Sender)
1395: {
1396: ViewTelnetExecute(Sender);
1397: }
1398: //---------------------------------------------------------------------------
1399:
1400: void __fastcall TMainForm::MailCloseButtonClick(TObject *Sender)
1401: {
1402: ViewMailServerExecute(Sender);
1403: }
1404: //---------------------------------------------------------------------------
1405:
1406: void __fastcall TMainForm::FtpCloseButtonClick(TObject *Sender)
1407: {
1408: ViewFtpServerExecute(Sender);
1409: }
1410: //---------------------------------------------------------------------------
1411: void __fastcall TMainForm::StatsTimerTick(TObject *Sender)
1412: {
1413: char str[128];
1414: int i;
1415: static stats_t stats;
1.1.1.2 ! root 1416: static users;
! 1417: static newusers;
! 1418: static counter;
1.1 root 1419:
1.1.1.2 ! root 1420: if(!StatsForm->Visible)
! 1421: return;
1.1 root 1422:
1.1.1.2 ! root 1423: getstats(&cfg,0,&stats);
1.1 root 1424:
1425: StatsForm->TotalLogons->Caption=AnsiString(stats.logons);
1426: StatsForm->LogonsToday->Caption=AnsiString(stats.ltoday);
1427: StatsForm->TotalTimeOn->Caption=AnsiString(stats.timeon);
1428: StatsForm->TimeToday->Caption=AnsiString(stats.ttoday);
1429: StatsForm->TotalEMail->Caption=AnsiString(getmail(&cfg,0,0));
1430: StatsForm->EMailToday->Caption=AnsiString(stats.etoday);
1431: StatsForm->TotalFeedback->Caption=AnsiString(getmail(&cfg,1,0));
1432: StatsForm->FeedbackToday->Caption=AnsiString(stats.ftoday);
1.1.1.2 ! root 1433: /* Don't scan a large user database more often than necessary */
! 1434: if(!counter || users<100 || (counter%(users/100))==0 || stats.nusers!=newusers)
! 1435: users=total_users(&cfg);
! 1436: StatsForm->TotalUsers->Caption=AnsiString(users);
! 1437: StatsForm->NewUsersToday->Caption=AnsiString(newusers=stats.nusers);
1.1 root 1438: StatsForm->PostsToday->Caption=AnsiString(stats.ptoday);
1439: StatsForm->UploadedFiles->Caption=AnsiString(stats.uls);
1440: if(stats.ulb>=1024*1024)
1441: sprintf(str,"%.1fM",stats.ulb/(1024.0*1024.0));
1442: else if(stats.ulb>=1024)
1443: sprintf(str,"%luK",stats.ulb/1024);
1444: else
1445: sprintf(str,"%lu",stats.ulb);
1446: StatsForm->UploadedBytes->Caption=AnsiString(str);
1447: StatsForm->DownloadedFiles->Caption=AnsiString(stats.dls);
1448: if(stats.dlb>=1024*1024)
1449: sprintf(str,"%.1fM",stats.dlb/(1024.0*1024.0));
1450: else if(stats.dlb>=1024)
1451: sprintf(str,"%luK",stats.dlb/1024);
1452: else
1453: sprintf(str,"%lu",stats.dlb);
1454: StatsForm->DownloadedBytes->Caption=AnsiString(str);
1455:
1.1.1.2 ! root 1456: counter++;
1.1 root 1457: }
1458: //---------------------------------------------------------------------------
1459: void __fastcall TMainForm::StatsCloseButtonClick(TObject *Sender)
1460: {
1461: ViewStatsExecute(Sender);
1462: }
1463: //---------------------------------------------------------------------------
1464: enum {
1465: PAGE_UPPERLEFT
1466: ,PAGE_UPPERRIGHT
1467: ,PAGE_LOWERRIGHT
1468: ,PAGE_LOWERLEFT
1469: };
1470: TPageControl* __fastcall TMainForm::PageControl(int num)
1471: {
1472: switch(num)
1473: {
1474: case PAGE_UPPERLEFT:
1475: return(UpperLeftPageControl);
1476: case PAGE_UPPERRIGHT:
1477: return(UpperRightPageControl);
1478: case PAGE_LOWERRIGHT:
1479: return(LowerRightPageControl);
1480: case PAGE_LOWERLEFT:
1481: return(LowerLeftPageControl);
1482: }
1483: return(NULL);
1484: }
1485: int __fastcall TMainForm::PageNum(TPageControl* obj)
1486: {
1487: if(obj==UpperLeftPageControl)
1488: return(PAGE_UPPERLEFT);
1489: if(obj==UpperRightPageControl)
1490: return(PAGE_UPPERRIGHT);
1491: if(obj==LowerRightPageControl)
1492: return(PAGE_LOWERRIGHT);
1493: if(obj==LowerLeftPageControl)
1494: return(PAGE_LOWERLEFT);
1495: return(PAGE_LOWERRIGHT);
1496: }
1.1.1.2 ! root 1497: TColor __fastcall TMainForm::ReadColor(TRegistry* Registry
! 1498: ,AnsiString name)
! 1499: {
! 1500: if(Registry->ValueExists(name + "Color"))
! 1501: return(StringToColor(Registry->ReadString(name + "Color")));
! 1502:
! 1503: return(clWindow); // Default
! 1504: }
! 1505: void __fastcall TMainForm::WriteColor(TRegistry* Registry
! 1506: ,AnsiString name, TColor color)
! 1507: {
! 1508: Registry->WriteString(name + "Color", ColorToString(color));
! 1509: }
! 1510:
! 1511: int FontStyleToInt(TFont* Font)
! 1512: {
! 1513: int style=0;
! 1514: for(int i=fsBold;i<=fsStrikeOut;i++)
! 1515: if(Font->Style.Contains((TFontStyle)i))
! 1516: style|=(1<<i);
! 1517: return(style);
! 1518: }
! 1519:
! 1520: void IntToFontStyle(int style, TFont* Font)
! 1521: {
! 1522: Font->Style=Font->Style.Clear();
! 1523: for(int i=fsBold;i<=fsStrikeOut;i++)
! 1524: if(style&(1<<i))
! 1525: Font->Style=Font->Style<<(TFontStyle)i;
! 1526: }
! 1527:
! 1528: void __fastcall TMainForm::ReadFont(AnsiString subkey, TFont* Font)
! 1529: {
! 1530: // Read Registry keys
! 1531: TRegistry* Registry=new TRegistry;
! 1532: AnsiString key = REG_KEY + subkey + "Font";
! 1533: if(!Registry->OpenKey(key,true)) {
! 1534: Application->MessageBox("Error opening registry key"
! 1535: ,key.c_str(),MB_OK|MB_ICONEXCLAMATION);
! 1536: Application->Terminate();
! 1537: return;
! 1538: }
! 1539: if(Registry->ValueExists("Name"))
! 1540: Font->Name=Registry->ReadString("Name");
! 1541: if(Registry->ValueExists("Color"))
! 1542: Font->Color=StringToColor(Registry->ReadString("Color"));
! 1543: if(Registry->ValueExists("Height"))
! 1544: Font->Height=Registry->ReadInteger("Height");
! 1545: if(Registry->ValueExists("Size"))
! 1546: Font->Size=Registry->ReadInteger("Size");
! 1547:
! 1548: if(Registry->ValueExists("Style"))
! 1549: IntToFontStyle(Registry->ReadInteger("Style"),Font);
! 1550:
! 1551: Registry->CloseKey();
! 1552: delete Registry;
! 1553: }
! 1554: void __fastcall TMainForm::WriteFont(AnsiString subkey, TFont* Font)
! 1555: {
! 1556: // Read Registry keys
! 1557: TRegistry* Registry=new TRegistry;
! 1558: AnsiString key = REG_KEY + subkey + "Font";
! 1559: if(!Registry->OpenKey(key,true)) {
! 1560: Application->MessageBox("Error opening registry key"
! 1561: ,key.c_str(),MB_OK|MB_ICONEXCLAMATION);
! 1562: Application->Terminate();
! 1563: return;
! 1564: }
! 1565: Registry->WriteString("Name",Font->Name);
! 1566: Registry->WriteString("Color",ColorToString(Font->Color));
! 1567: Registry->WriteInteger("Height",Font->Height);
! 1568: Registry->WriteInteger("Size",Font->Size);
! 1569: Registry->WriteInteger("Style",FontStyleToInt(Font));
! 1570:
! 1571: Registry->CloseKey();
! 1572: delete Registry;
! 1573: }
1.1 root 1574: void __fastcall TMainForm::StartupTimerTick(TObject *Sender)
1575: {
1576: bool TelnetFormFloating=false;
1.1.1.2 ! root 1577: bool EventsFormFloating=false;
! 1578: bool ServicesFormFloating=false;
1.1 root 1579: bool NodeFormFloating=false;
1580: bool StatsFormFloating=false;
1581: bool ClientFormFloating=false;
1582: bool MailFormFloating=false;
1583: bool FtpFormFloating=false;
1.1.1.2 ! root 1584: bool WebFormFloating=false;
1.1 root 1585: int NodeFormPage=PAGE_UPPERLEFT;
1586: int StatsFormPage=PAGE_UPPERLEFT;
1587: int ClientFormPage=PAGE_UPPERLEFT;
1588: int TelnetFormPage=PAGE_LOWERLEFT;
1.1.1.2 ! root 1589: int EventsFormPage=PAGE_LOWERLEFT;
1.1 root 1590: int MailFormPage=PAGE_UPPERRIGHT;
1591: int FtpFormPage=PAGE_LOWERRIGHT;
1.1.1.2 ! root 1592: int WebFormPage=PAGE_LOWERRIGHT;
! 1593: int ServicesFormPage=PAGE_LOWERRIGHT;
! 1594: #if 0 /* not yet working */
! 1595: bool TelnetFormVisible=true;
! 1596: bool EventsFormVisible=true;
! 1597: bool ServicesFormVisible=true;
! 1598: bool NodeFormVisible=true;
! 1599: bool StatsFormVisible=true;
! 1600: bool ClientFormVisible=true;
! 1601: bool MailFormVisible=true;
! 1602: bool FtpFormVisible=true;
! 1603: bool WebFormVisible=true;
! 1604: #endif
1.1 root 1605:
1606: AnsiString Str;
1607:
1608: delete StartupTimer;
1609:
1610: // Read Registry keys
1611: TRegistry* Registry=new TRegistry;
1612: if(!Registry->OpenKey(REG_KEY,true)) {
1613: Application->MessageBox("Error opening registry key"
1614: ,REG_KEY,MB_OK|MB_ICONEXCLAMATION);
1615: Application->Terminate();
1.1.1.2 ! root 1616: return;
1.1 root 1617: }
1618:
1619: TopPanel->Height=Height/3;
1620: UpperLeftPageControl->Width=Width/2;
1621: LowerLeftPageControl->Width=Width/2;
1622:
1623: if(Registry->ValueExists("TopPanelHeight"))
1624: TopPanel->Height=Registry->ReadInteger("TopPanelHeight");
1625: if(Registry->ValueExists("UpperLeftPageControlWidth"))
1626: UpperLeftPageControl->Width
1627: =Registry->ReadInteger("UpperLeftPageControlWidth");
1628: if(Registry->ValueExists("LowerLeftPageControlWidth"))
1629: LowerLeftPageControl->Width
1630: =Registry->ReadInteger("LowerLeftPageControlWidth");
1.1.1.2 ! root 1631: if(Registry->ValueExists("UndockableForms"))
! 1632: UndockableForms=Registry->ReadBool("UndockableForms");
1.1 root 1633:
1.1.1.2 ! root 1634: if(UndockableForms) {
! 1635: if(Registry->ValueExists("TelnetFormFloating"))
! 1636: TelnetFormFloating=Registry->ReadBool("TelnetFormFloating");
! 1637: if(Registry->ValueExists("EventsFormFloating"))
! 1638: EventsFormFloating=Registry->ReadBool("EventsFormFloating");
! 1639: if(Registry->ValueExists("ServicesFormFloating"))
! 1640: ServicesFormFloating=Registry->ReadBool("ServicesFormFloating");
! 1641: if(Registry->ValueExists("NodeFormFloating"))
! 1642: NodeFormFloating=Registry->ReadBool("NodeFormFloating");
! 1643: if(Registry->ValueExists("StatsFormFloating"))
! 1644: StatsFormFloating=Registry->ReadBool("StatsFormFloating");
! 1645: if(Registry->ValueExists("ClientFormFloating"))
! 1646: ClientFormFloating=Registry->ReadBool("ClientFormFloating");
! 1647: if(Registry->ValueExists("MailFormFloating"))
! 1648: MailFormFloating=Registry->ReadBool("MailFormFloating");
! 1649: if(Registry->ValueExists("FtpFormFloating"))
! 1650: FtpFormFloating=Registry->ReadBool("FtpFormFloating");
! 1651: if(Registry->ValueExists("WebFormFloating"))
! 1652: WebFormFloating=Registry->ReadBool("WebFormFloating");
! 1653: }
! 1654: #if 0
! 1655: if(Registry->ValueExists("TelnetFormVisible"))
! 1656: TelnetFormVisible=Registry->ReadBool("TelnetFormVisible");
! 1657: if(Registry->ValueExists("EventsFormVisible"))
! 1658: EventsFormVisible=Registry->ReadBool("EventsFormVisible");
! 1659: if(Registry->ValueExists("ServicesFormVisible"))
! 1660: ServicesFormVisible=Registry->ReadBool("ServicesFormVisible");
! 1661: if(Registry->ValueExists("NodeFormVisible"))
! 1662: NodeFormVisible=Registry->ReadBool("NodeFormVisible");
! 1663: if(Registry->ValueExists("StatsFormVisible"))
! 1664: StatsFormVisible=Registry->ReadBool("StatsFormVisible");
! 1665: if(Registry->ValueExists("ClientFormVisible"))
! 1666: ClientFormVisible=Registry->ReadBool("ClientFormVisible");
! 1667: if(Registry->ValueExists("MailFormVisible"))
! 1668: MailFormVisible=Registry->ReadBool("MailFormVisible");
! 1669: if(Registry->ValueExists("FtpFormVisible"))
! 1670: FtpFormVisible=Registry->ReadBool("FtpFormVisible");
! 1671: if(Registry->ValueExists("WebFormVisible"))
! 1672: WebFormVisible=Registry->ReadBool("WebFormVisible");
! 1673: #endif
1.1 root 1674: if(Registry->ValueExists("TelnetFormPage"))
1675: TelnetFormPage=Registry->ReadInteger("TelnetFormPage");
1.1.1.2 ! root 1676: if(Registry->ValueExists("EventsFormPage"))
! 1677: EventsFormPage=Registry->ReadInteger("EventsFormPage");
! 1678: if(Registry->ValueExists("ServicesFormPage"))
! 1679: ServicesFormPage=Registry->ReadInteger("ServicesFormPage");
1.1 root 1680: if(Registry->ValueExists("NodeFormPage"))
1681: NodeFormPage=Registry->ReadInteger("NodeFormPage");
1682: if(Registry->ValueExists("StatsFormPage"))
1683: StatsFormPage=Registry->ReadInteger("StatsFormPage");
1684: if(Registry->ValueExists("ClientFormPage"))
1685: ClientFormPage=Registry->ReadInteger("ClientFormPage");
1686: if(Registry->ValueExists("MailFormPage"))
1687: MailFormPage=Registry->ReadInteger("MailFormPage");
1688: if(Registry->ValueExists("FtpFormPage"))
1689: FtpFormPage=Registry->ReadInteger("FtpFormPage");
1.1.1.2 ! root 1690: if(Registry->ValueExists("WebFormPage"))
! 1691: WebFormPage=Registry->ReadInteger("WebFormPage");
! 1692:
! 1693: TelnetForm->Log->Color=ReadColor(Registry,"TelnetLog");
! 1694: ReadFont("TelnetLog",TelnetForm->Log->Font);
! 1695: EventsForm->Log->Color=ReadColor(Registry,"EventsLog");
! 1696: ReadFont("EventsLog",EventsForm->Log->Font);
! 1697: ServicesForm->Log->Color=ReadColor(Registry,"ServicesLog");
! 1698: ReadFont("ServicesLog",ServicesForm->Log->Font);
! 1699: MailForm->Log->Color=ReadColor(Registry,"MailLog");
! 1700: ReadFont("MailLog",MailForm->Log->Font);
! 1701: FtpForm->Log->Color=ReadColor(Registry,"FtpLog");
! 1702: ReadFont("FtpLog",FtpForm->Log->Font);
! 1703: WebForm->Log->Color=ReadColor(Registry,"WebLog");
! 1704: ReadFont("WebLog",WebForm->Log->Font);
! 1705: NodeForm->ListBox->Color=ReadColor(Registry,"NodeList");
! 1706: ReadFont("NodeList",NodeForm->ListBox->Font);
! 1707: ClientForm->ListView->Color=ReadColor(Registry,"ClientList");
! 1708: ReadFont("ClientList",ClientForm->ListView->Font);
1.1 root 1709:
1710: if(Registry->ValueExists("TelnetFormTop"))
1711: TelnetForm->Top=Registry->ReadInteger("TelnetFormTop");
1712: if(Registry->ValueExists("TelnetFormLeft"))
1713: TelnetForm->Left=Registry->ReadInteger("TelnetFormLeft");
1714: if(Registry->ValueExists("TelnetFormWidth"))
1715: TelnetForm->Width=Registry->ReadInteger("TelnetFormWidth");
1716: if(Registry->ValueExists("TelnetFormHeight"))
1717: TelnetForm->Height=Registry->ReadInteger("TelnetFormHeight");
1718:
1.1.1.2 ! root 1719: if(Registry->ValueExists("EventsFormTop"))
! 1720: EventsForm->Top=Registry->ReadInteger("EventsFormTop");
! 1721: if(Registry->ValueExists("EventsFormLeft"))
! 1722: EventsForm->Left=Registry->ReadInteger("EventsFormLeft");
! 1723: if(Registry->ValueExists("EventsFormWidth"))
! 1724: EventsForm->Width=Registry->ReadInteger("EventsFormWidth");
! 1725: if(Registry->ValueExists("EventsFormHeight"))
! 1726: EventsForm->Height=Registry->ReadInteger("EventsFormHeight");
! 1727:
! 1728: if(Registry->ValueExists("ServicesFormTop"))
! 1729: ServicesForm->Top=Registry->ReadInteger("ServicesFormTop");
! 1730: if(Registry->ValueExists("ServicesFormLeft"))
! 1731: ServicesForm->Left=Registry->ReadInteger("ServicesFormLeft");
! 1732: if(Registry->ValueExists("ServicesFormWidth"))
! 1733: ServicesForm->Width=Registry->ReadInteger("ServicesFormWidth");
! 1734: if(Registry->ValueExists("ServicesFormHeight"))
! 1735: ServicesForm->Height=Registry->ReadInteger("ServicesFormHeight");
! 1736:
1.1 root 1737: if(Registry->ValueExists("FtpFormTop"))
1738: FtpForm->Top=Registry->ReadInteger("FtpFormTop");
1739: if(Registry->ValueExists("FtpFormLeft"))
1740: FtpForm->Left=Registry->ReadInteger("FtpFormLeft");
1741: if(Registry->ValueExists("FtpFormWidth"))
1742: FtpForm->Width=Registry->ReadInteger("FtpFormWidth");
1743: if(Registry->ValueExists("FtpFormHeight"))
1744: FtpForm->Height=Registry->ReadInteger("FtpFormHeight");
1745:
1.1.1.2 ! root 1746: if(Registry->ValueExists("WebFormTop"))
! 1747: WebForm->Top=Registry->ReadInteger("WebFormTop");
! 1748: if(Registry->ValueExists("WebFormLeft"))
! 1749: WebForm->Left=Registry->ReadInteger("WebFormLeft");
! 1750: if(Registry->ValueExists("WebFormWidth"))
! 1751: WebForm->Width=Registry->ReadInteger("WebFormWidth");
! 1752: if(Registry->ValueExists("WebFormHeight"))
! 1753: WebForm->Height=Registry->ReadInteger("WebFormHeight");
! 1754:
1.1 root 1755: if(Registry->ValueExists("MailFormTop"))
1756: MailForm->Top=Registry->ReadInteger("MailFormTop");
1757: if(Registry->ValueExists("MailFormLeft"))
1758: MailForm->Left=Registry->ReadInteger("MailFormLeft");
1759: if(Registry->ValueExists("MailFormWidth"))
1760: MailForm->Width=Registry->ReadInteger("MailFormWidth");
1761: if(Registry->ValueExists("MailFormHeight"))
1762: MailForm->Height=Registry->ReadInteger("MailFormHeight");
1763:
1764: if(Registry->ValueExists("NodeFormTop"))
1765: NodeForm->Top=Registry->ReadInteger("NodeFormTop");
1766: if(Registry->ValueExists("NodeFormLeft"))
1767: NodeForm->Left=Registry->ReadInteger("NodeFormLeft");
1768: if(Registry->ValueExists("NodeFormWidth"))
1769: NodeForm->Width=Registry->ReadInteger("NodeFormWidth");
1770: if(Registry->ValueExists("NodeFormHeight"))
1771: NodeForm->Height=Registry->ReadInteger("NodeFormHeight");
1772:
1773: if(Registry->ValueExists("StatsFormTop"))
1774: StatsForm->Top=Registry->ReadInteger("StatsFormTop");
1775: if(Registry->ValueExists("StatsFormLeft"))
1776: StatsForm->Left=Registry->ReadInteger("StatsFormLeft");
1777: if(Registry->ValueExists("StatsFormWidth"))
1778: StatsForm->Width=Registry->ReadInteger("StatsFormWidth");
1779: if(Registry->ValueExists("StatsFormHeight"))
1780: StatsForm->Height=Registry->ReadInteger("StatsFormHeight");
1781:
1782: if(Registry->ValueExists("ClientFormTop"))
1783: ClientForm->Top=Registry->ReadInteger("ClientFormTop");
1784: if(Registry->ValueExists("ClientFormLeft"))
1785: ClientForm->Left=Registry->ReadInteger("ClientFormLeft");
1786: if(Registry->ValueExists("ClientFormWidth"))
1787: ClientForm->Width=Registry->ReadInteger("ClientFormWidth");
1788: if(Registry->ValueExists("ClientFormHeight"))
1789: ClientForm->Height=Registry->ReadInteger("ClientFormHeight");
1790:
1.1.1.2 ! root 1791: for(int i=0;i<ClientForm->ListView->Columns->Count;i++) {
! 1792: char str[128];
! 1793: sprintf(str,"ClientListColumn%dWidth",i);
! 1794: if(Registry->ValueExists(str))
! 1795: ClientForm->ListView->Columns->Items[i]->Width
! 1796: =Registry->ReadInteger(str);
! 1797: }
! 1798:
1.1 root 1799: if(Registry->ValueExists("ToolbarVisible"))
1800: Toolbar->Visible=Registry->ReadBool("ToolbarVisible");
1801:
1802: ViewToolbarMenuItem->Checked=Toolbar->Visible;
1803: ViewStatusBarMenuItem->Checked=StatusBar->Visible;
1804:
1.1.1.2 ! root 1805: if(Registry->ValueExists("MaxLogLen"))
! 1806: MaxLogLen=Registry->ReadInteger("MaxLogLen");
! 1807:
1.1 root 1808: if(Registry->ValueExists("LoginCommand"))
1809: LoginCommand=Registry->ReadString("LoginCommand");
1810: if(Registry->ValueExists("ConfigCommand"))
1811: ConfigCommand=Registry->ReadString("ConfigCommand");
1.1.1.2 ! root 1812: if(Registry->ValueExists("Password"))
! 1813: Password=Registry->ReadString("Password");
! 1814: if(Registry->ValueExists("MinimizeToSysTray"))
! 1815: MinimizeToSysTray=Registry->ReadBool("MinimizeToSysTray");
! 1816: if(Registry->ValueExists("UseFileAssociations"))
! 1817: UseFileAssociations=Registry->ReadBool("UseFileAssociations");
! 1818: if(Registry->ValueExists("NodeDisplayInterval"))
! 1819: NodeForm->Timer->Interval=Registry->ReadInteger("NodeDisplayInterval")*1000;
! 1820: if(Registry->ValueExists("ClientDisplayInterval"))
! 1821: ClientForm->Timer->Interval=Registry->ReadInteger("ClientDisplayInterval")*1000;
1.1 root 1822:
1823: if(Registry->ValueExists("MailLogFile"))
1824: MailLogFile=Registry->ReadInteger("MailLogFile");
1825: else
1826: MailLogFile=true;
1827:
1828: if(Registry->ValueExists("FtpLogFile"))
1829: FtpLogFile=Registry->ReadInteger("FtpLogFile");
1830: else
1831: FtpLogFile=true;
1832:
1.1.1.2 ! root 1833: FILE* fp;
! 1834: if((!Registry->ValueExists("SysAutoStart")
! 1835: || (Registry->ValueExists("Imported") && Registry->ReadBool("Imported")))
! 1836: && ini_file[0]) {
! 1837: if((fp=fopen(ini_file,"r"))==NULL) {
! 1838: char err[MAX_PATH*2];
! 1839: sprintf(err,"Error %d opening initialization file: %s",errno,ini_file);
! 1840: Application->MessageBox(err,"ERROR",MB_OK|MB_ICONEXCLAMATION);
! 1841: Application->Terminate();
! 1842: return;
! 1843: }
! 1844: sbbs_read_ini(fp
! 1845: ,&global
! 1846: ,&SysAutoStart ,&bbs_startup
! 1847: ,&FtpAutoStart ,&ftp_startup
! 1848: ,&WebAutoStart ,&web_startup
! 1849: ,&MailAutoStart ,&mail_startup
! 1850: ,&ServicesAutoStart ,&services_startup
! 1851: );
! 1852: StatusBar->Panels->Items[4]->Text="Read " + AnsiString(ini_file);
! 1853: fclose(fp);
! 1854:
! 1855: } else { /* Legacy (v3.10-3.11) */
! 1856:
! 1857: if(Registry->ValueExists("SysAutoStart"))
! 1858: SysAutoStart=Registry->ReadInteger("SysAutoStart");
! 1859: else
! 1860: SysAutoStart=true;
! 1861:
! 1862: if(Registry->ValueExists("MailAutoStart"))
! 1863: MailAutoStart=Registry->ReadInteger("MailAutoStart");
! 1864: else
! 1865: MailAutoStart=true;
! 1866:
! 1867: if(Registry->ValueExists("FtpAutoStart"))
! 1868: FtpAutoStart=Registry->ReadInteger("FtpAutoStart");
! 1869: else
! 1870: FtpAutoStart=true;
! 1871:
! 1872: if(Registry->ValueExists("WebAutoStart"))
! 1873: WebAutoStart=Registry->ReadInteger("WebAutoStart");
! 1874: else
! 1875: WebAutoStart=true;
! 1876:
! 1877: if(Registry->ValueExists("ServicesAutoStart"))
! 1878: ServicesAutoStart=Registry->ReadInteger("ServicesAutoStart");
! 1879: else
! 1880: ServicesAutoStart=true;
! 1881:
! 1882: if(Registry->ValueExists("Hostname"))
! 1883: SAFECOPY(global.host_name,Registry->ReadString("Hostname"));
! 1884: if(Registry->ValueExists("CtrlDirectory"))
! 1885: SAFECOPY(global.ctrl_dir,Registry->ReadString("CtrlDirectory"));
! 1886: if(Registry->ValueExists("TempDirectory"))
! 1887: SAFECOPY(global.temp_dir,Registry->ReadString("TempDirectory"));
! 1888:
! 1889: if(Registry->ValueExists("SemFileCheckFrequency"))
! 1890: global.sem_chk_freq=Registry->ReadInteger("SemFileCheckFrequency");
! 1891:
! 1892: /* JavaScript Operating Parameters */
! 1893: if(Registry->ValueExists("JS_MaxBytes"))
! 1894: global.js.max_bytes=Registry->ReadInteger("JS_MaxBytes");
! 1895: if(global.js.max_bytes==0)
! 1896: global.js.max_bytes=JAVASCRIPT_MAX_BYTES;
! 1897: if(Registry->ValueExists("JS_ContextStack"))
! 1898: global.js.cx_stack=Registry->ReadInteger("JS_ContextStack");
! 1899: if(global.js.cx_stack==0)
! 1900: global.js.cx_stack=JAVASCRIPT_CONTEXT_STACK;
! 1901: if(Registry->ValueExists("JS_BranchLimit"))
! 1902: global.js.branch_limit=Registry->ReadInteger("JS_BranchLimit");
! 1903: if(Registry->ValueExists("JS_GcInterval"))
! 1904: global.js.gc_interval=Registry->ReadInteger("JS_GcInterval");
! 1905: if(Registry->ValueExists("JS_YieldInterval"))
! 1906: global.js.yield_interval=Registry->ReadInteger("JS_YieldInterval");
! 1907:
! 1908: if(Registry->ValueExists("TelnetInterface"))
! 1909: bbs_startup.telnet_interface=Registry->ReadInteger("TelnetInterface");
! 1910: if(Registry->ValueExists("RLoginInterface"))
! 1911: bbs_startup.rlogin_interface=Registry->ReadInteger("RLoginInterface");
! 1912:
! 1913: if(Registry->ValueExists("TelnetPort"))
! 1914: bbs_startup.telnet_port=Registry->ReadInteger("TelnetPort");
! 1915: if(Registry->ValueExists("RLoginPort"))
! 1916: bbs_startup.rlogin_port=Registry->ReadInteger("RLoginPort");
! 1917:
! 1918: if(Registry->ValueExists("FirstNode"))
! 1919: bbs_startup.first_node=Registry->ReadInteger("FirstNode");
! 1920:
! 1921: if(Registry->ValueExists("LastNode"))
! 1922: bbs_startup.last_node=Registry->ReadInteger("LastNode");
! 1923:
! 1924: if(Registry->ValueExists("ExternalYield"))
! 1925: bbs_startup.xtrn_polls_before_yield=Registry->ReadInteger("ExternalYield");
! 1926:
! 1927: if(Registry->ValueExists("OutbufHighwaterMark"))
! 1928: bbs_startup.outbuf_highwater_mark=Registry->ReadInteger("OutbufHighwaterMark");
! 1929: else
! 1930: bbs_startup.outbuf_highwater_mark=1024;
! 1931: if(Registry->ValueExists("OutbufDrainTimeout"))
! 1932: bbs_startup.outbuf_drain_timeout=Registry->ReadInteger("OutbufDrainTimeout");
! 1933: else
! 1934: bbs_startup.outbuf_drain_timeout=10;
! 1935:
! 1936: if(Registry->ValueExists("AnswerSound"))
! 1937: SAFECOPY(bbs_startup.answer_sound
! 1938: ,Registry->ReadString("AnswerSound").c_str());
! 1939:
! 1940: if(Registry->ValueExists("HangupSound"))
! 1941: SAFECOPY(bbs_startup.hangup_sound
! 1942: ,Registry->ReadString("HangupSound").c_str());
! 1943:
! 1944: if(Registry->ValueExists("StartupOptions"))
! 1945: bbs_startup.options=Registry->ReadInteger("StartupOptions");
! 1946:
! 1947: if(Registry->ValueExists("MailMaxClients"))
! 1948: mail_startup.max_clients=Registry->ReadInteger("MailMaxClients");
! 1949:
! 1950: if(Registry->ValueExists("MailMaxInactivity"))
! 1951: mail_startup.max_inactivity=Registry->ReadInteger("MailMaxInactivity");
! 1952:
! 1953: if(Registry->ValueExists("MailInterface"))
! 1954: mail_startup.interface_addr=Registry->ReadInteger("MailInterface");
! 1955:
! 1956: if(Registry->ValueExists("MailMaxDeliveryAttempts"))
! 1957: mail_startup.max_delivery_attempts
! 1958: =Registry->ReadInteger("MailMaxDeliveryAttempts");
! 1959:
! 1960: if(Registry->ValueExists("MailRescanFrequency"))
! 1961: mail_startup.rescan_frequency
! 1962: =Registry->ReadInteger("MailRescanFrequency");
! 1963:
! 1964: if(Registry->ValueExists("MailLinesPerYield"))
! 1965: mail_startup.lines_per_yield
! 1966: =Registry->ReadInteger("MailLinesPerYield");
! 1967:
! 1968: if(Registry->ValueExists("MailMaxRecipients"))
! 1969: mail_startup.max_recipients
! 1970: =Registry->ReadInteger("MailMaxRecipients");
! 1971:
! 1972: if(Registry->ValueExists("MailMaxMsgSize"))
! 1973: mail_startup.max_msg_size
! 1974: =Registry->ReadInteger("MailMaxMsgSize");
! 1975:
! 1976: if(Registry->ValueExists("MailSMTPPort"))
! 1977: mail_startup.smtp_port=Registry->ReadInteger("MailSMTPPort");
! 1978:
! 1979: if(Registry->ValueExists("MailPOP3Port"))
! 1980: mail_startup.pop3_port=Registry->ReadInteger("MailPOP3Port");
! 1981:
! 1982: if(Registry->ValueExists("MailRelayServer"))
! 1983: SAFECOPY(mail_startup.relay_server
! 1984: ,Registry->ReadString("MailRelayServer").c_str());
! 1985:
! 1986: if(Registry->ValueExists("MailRelayPort"))
! 1987: mail_startup.relay_port=Registry->ReadInteger("MailRelayPort");
! 1988:
! 1989: if(Registry->ValueExists("MailDefaultUser"))
! 1990: SAFECOPY(mail_startup.default_user
! 1991: ,Registry->ReadString("MailDefaultUser").c_str());
! 1992:
! 1993: if(Registry->ValueExists("MailDNSBlacklistSubject"))
! 1994: SAFECOPY(mail_startup.dnsbl_tag
! 1995: ,Registry->ReadString("MailDNSBlacklistSubject").c_str());
! 1996: else
! 1997: SAFECOPY(mail_startup.dnsbl_tag,"SPAM");
! 1998:
! 1999: if(Registry->ValueExists("MailDNSBlacklistHeader"))
! 2000: SAFECOPY(mail_startup.dnsbl_hdr
! 2001: ,Registry->ReadString("MailDNSBlacklistHeader").c_str());
! 2002: else
! 2003: SAFECOPY(mail_startup.dnsbl_hdr,"X-DNSBL");
! 2004:
! 2005: if(Registry->ValueExists("MailDNSServer"))
! 2006: SAFECOPY(mail_startup.dns_server
! 2007: ,Registry->ReadString("MailDNSServer").c_str());
! 2008:
! 2009: if(Registry->ValueExists("MailInboundSound"))
! 2010: SAFECOPY(mail_startup.inbound_sound
! 2011: ,Registry->ReadString("MailInboundSound").c_str());
! 2012:
! 2013: if(Registry->ValueExists("MailOutboundSound"))
! 2014: SAFECOPY(mail_startup.outbound_sound
! 2015: ,Registry->ReadString("MailOutboundSound").c_str());
! 2016:
! 2017: if(Registry->ValueExists("MailPOP3Sound"))
! 2018: SAFECOPY(mail_startup.pop3_sound
! 2019: ,Registry->ReadString("MailPOP3Sound").c_str());
! 2020:
! 2021: if(Registry->ValueExists("MailOptions"))
! 2022: mail_startup.options=Registry->ReadInteger("MailOptions");
! 2023:
! 2024: if(Registry->ValueExists("FtpMaxClients"))
! 2025: ftp_startup.max_clients=Registry->ReadInteger("FtpMaxClients");
! 2026:
! 2027: if(Registry->ValueExists("FtpMaxInactivity"))
! 2028: ftp_startup.max_inactivity=Registry->ReadInteger("FtpMaxInactivity");
! 2029:
! 2030: if(Registry->ValueExists("FtpQwkTimeout"))
! 2031: ftp_startup.qwk_timeout=Registry->ReadInteger("FtpQwkTimeout");
! 2032:
! 2033: if(Registry->ValueExists("FtpInterface"))
! 2034: ftp_startup.interface_addr=Registry->ReadInteger("FtpInterface");
! 2035:
! 2036: if(Registry->ValueExists("FtpPort"))
! 2037: ftp_startup.port=Registry->ReadInteger("FtpPort");
! 2038:
! 2039: if(Registry->ValueExists("FtpAnswerSound"))
! 2040: SAFECOPY(ftp_startup.answer_sound
! 2041: ,Registry->ReadString("FtpAnswerSound").c_str());
! 2042:
! 2043: if(Registry->ValueExists("FtpHangupSound"))
! 2044: SAFECOPY(ftp_startup.hangup_sound
! 2045: ,Registry->ReadString("FtpHangupSound").c_str());
! 2046:
! 2047: if(Registry->ValueExists("FtpHackAttemptSound"))
! 2048: SAFECOPY(ftp_startup.hack_sound
! 2049: ,Registry->ReadString("FtpHackAttemptSound").c_str());
! 2050:
! 2051: if(Registry->ValueExists("FtpIndexFileName"))
! 2052: SAFECOPY(ftp_startup.index_file_name
! 2053: ,Registry->ReadString("FtpIndexFileName").c_str());
! 2054:
! 2055: if(Registry->ValueExists("FtpHtmlIndexFile"))
! 2056: SAFECOPY(ftp_startup.html_index_file
! 2057: ,Registry->ReadString("FtpHtmlIndexFile").c_str());
! 2058:
! 2059: if(Registry->ValueExists("FtpHtmlIndexScript"))
! 2060: SAFECOPY(ftp_startup.html_index_script
! 2061: ,Registry->ReadString("FtpHtmlIndexScript").c_str());
! 2062:
! 2063: if(Registry->ValueExists("FtpOptions"))
! 2064: ftp_startup.options=Registry->ReadInteger("FtpOptions");
! 2065:
! 2066: if(Registry->ValueExists("ServicesInterface"))
! 2067: services_startup.interface_addr
! 2068: =Registry->ReadInteger("ServicesInterface");
! 2069:
! 2070: if(Registry->ValueExists("ServicesAnswerSound"))
! 2071: SAFECOPY(services_startup.answer_sound
! 2072: ,Registry->ReadString("ServicesAnswerSound").c_str());
! 2073:
! 2074: if(Registry->ValueExists("ServicesHangupSound"))
! 2075: SAFECOPY(services_startup.hangup_sound
! 2076: ,Registry->ReadString("ServicesHangupSound").c_str());
! 2077:
! 2078: if(Registry->ValueExists("ServicesOptions"))
! 2079: services_startup.options=Registry->ReadInteger("ServicesOptions");
1.1 root 2080:
1.1.1.2 ! root 2081: if(SaveIniSettings(Sender))
! 2082: Registry->WriteBool("Imported",true); /* Use the .ini file for these settings from now on */
! 2083: }
1.1 root 2084:
2085: Registry->CloseKey();
2086: delete Registry;
2087:
1.1.1.2 ! root 2088: AnsiString CtrlDirectory = AnsiString(global.ctrl_dir);
1.1 root 2089: if(!FileExists(CtrlDirectory+"MAIN.CNF")) {
2090: Application->CreateForm(__classid(TCtrlPathDialog), &CtrlPathDialog);
2091: if(CtrlPathDialog->ShowModal()!=mrOk) {
2092: Application->Terminate();
2093: return;
2094: }
2095: CtrlDirectory=CtrlPathDialog->Edit->Text;
2096: delete CtrlPathDialog;
2097: }
2098: if(CtrlDirectory.UpperCase().AnsiPos("MAIN.CNF"))
2099: CtrlDirectory.SetLength(CtrlDirectory.Length()-8);
1.1.1.2 ! root 2100: SAFECOPY(global.ctrl_dir,CtrlDirectory.c_str());
! 2101: memset(&cfg,0,sizeof(cfg));
! 2102: SAFECOPY(cfg.ctrl_dir,global.ctrl_dir);
! 2103: cfg.size=sizeof(cfg);
! 2104: cfg.node_num=bbs_startup.first_node;
! 2105: char error[256];
! 2106: SAFECOPY(error,UNKNOWN_LOAD_ERROR);
! 2107: if(!load_cfg(&cfg, NULL, TRUE, error)) {
! 2108: Application->MessageBox(error,"ERROR Loading Configuration"
1.1 root 2109: ,MB_OK|MB_ICONEXCLAMATION);
2110: Application->Terminate();
2111: return;
2112: }
2113:
1.1.1.2 ! root 2114: if(!(cfg.sys_misc&SM_LOCAL_TZ)) {
! 2115: if(putenv("TZ=UTC0")) {
! 2116: Application->MessageBox("Error setting timezone"
! 2117: ,"ERROR",MB_OK|MB_ICONEXCLAMATION);
! 2118: Application->Terminate();
! 2119: }
! 2120: tzset();
! 2121: }
! 2122:
! 2123: if(cfg.new_install) {
! 2124: Application->BringToFront();
! 2125: for(int i=0;i<10;i++) {
! 2126: Application->ProcessMessages();
! 2127: Sleep(300); // Let 'em see the logo for a bit
! 2128: }
! 2129: BBSConfigWizardMenuItemClick(Sender);
! 2130: }
! 2131:
1.1 root 2132: if(bbs_startup.options&BBS_OPT_MUTE)
2133: SoundToggle->Checked=false;
2134: else
2135: SoundToggle->Checked=true;
2136:
2137: if(bbs_startup.options&BBS_OPT_SYSOP_AVAILABLE)
2138: ChatToggle->Checked=true;
2139: else
2140: ChatToggle->Checked=false;
2141:
2142: if(!NodeFormFloating)
2143: NodeForm->ManualDock(PageControl(NodeFormPage),NULL,alClient);
2144: if(!ClientFormFloating)
2145: ClientForm->ManualDock(PageControl(ClientFormPage),NULL,alClient);
2146: if(!StatsFormFloating)
2147: StatsForm->ManualDock(PageControl(StatsFormPage),NULL,alClient);
2148: if(!MailFormFloating)
2149: MailForm->ManualDock(PageControl(MailFormPage),NULL,alClient);
2150: if(!TelnetFormFloating)
2151: TelnetForm->ManualDock(PageControl(TelnetFormPage),NULL,alClient);
1.1.1.2 ! root 2152: if(!EventsFormFloating)
! 2153: EventsForm->ManualDock(PageControl(EventsFormPage),NULL,alClient);
! 2154: if(!ServicesFormFloating)
! 2155: ServicesForm->ManualDock(PageControl(ServicesFormPage),NULL,alClient);
1.1 root 2156: if(!FtpFormFloating)
2157: FtpForm->ManualDock(PageControl(FtpFormPage),NULL,alClient);
1.1.1.2 ! root 2158: if(!WebFormFloating)
! 2159: WebForm->ManualDock(PageControl(WebFormPage),NULL,alClient);
1.1 root 2160:
2161: NodeForm->Show();
1.1.1.2 ! root 2162: // ViewNodes->Checked=NodeFormVisible, ViewNodesExecute(Sender);
1.1 root 2163: ClientForm->Show();
1.1.1.2 ! root 2164: // ViewClients->Checked=ClientFormVisible, ViewClientsExecute(Sender);
1.1 root 2165: StatsForm->Show();
1.1.1.2 ! root 2166: // ViewStats->Checked=StatsFormVisible, ViewStatsExecute(Sender);
1.1 root 2167: TelnetForm->Show();
1.1.1.2 ! root 2168: // ViewTelnet->Checked=TelnetFormVisible, ViewTelnetExecute(Sender);
! 2169: EventsForm->Show();
! 2170: // ViewEvents->Checked=EventsFormVisible, ViewEventsExecute(Sender);
1.1 root 2171: FtpForm->Show();
1.1.1.2 ! root 2172: // ViewFtpServer->Checked=FtpFormVisible, ViewFtpServerExecute(Sender);
! 2173: WebForm->Show();
! 2174: // ViewWebServer->Checked=WebFormVisible;
! 2175: // WebForm->Visible=ViewWebServer->Checked;
1.1 root 2176: MailForm->Show();
1.1.1.2 ! root 2177: // ViewMailServer->Checked=MailFormVisible,ViewMailServerExecute(Sender);
! 2178: ServicesForm->Show();
! 2179: // ViewServices->Checked=ServicesFormVisible,ViewServicesExecute(Sender);
1.1 root 2180:
2181: UpperLeftPageControl->Visible=true;
2182: UpperRightPageControl->Visible=true;
2183: LowerLeftPageControl->Visible=true;
2184: LowerRightPageControl->Visible=true;
2185: HorizontalSplitter->Visible=true;
2186: BottomPanel->Visible=true;
2187: TopPanel->Visible=true;
2188:
2189: // Work-around for CB5 PageControl anomaly
2190: int i;
2191:
2192: for(i=1;i<UpperLeftPageControl->PageCount;i++)
2193: UpperLeftPageControl->ActivePageIndex=i;
2194: UpperLeftPageControl->ActivePageIndex=0;
2195:
2196: for(i=1;i<UpperRightPageControl->PageCount;i++)
2197: UpperRightPageControl->ActivePageIndex=i;
2198: UpperRightPageControl->ActivePageIndex=0;
2199:
2200: for(i=1;i<LowerRightPageControl->PageCount;i++)
2201: LowerRightPageControl->ActivePageIndex=i;
2202: LowerRightPageControl->ActivePageIndex=0;
2203:
2204: for(i=1;i<LowerLeftPageControl->PageCount;i++)
2205: LowerLeftPageControl->ActivePageIndex=i;
2206: LowerLeftPageControl->ActivePageIndex=0;
2207:
1.1.1.2 ! root 2208: LogTimerTick(Sender); /* Open Log Mailslots */
! 2209: ServiceStatusTimerTick(Sender); /* Query service config lengths */
! 2210:
! 2211: if(SysAutoStart)
! 2212: TelnetStartExecute(Sender);
! 2213: if(MailAutoStart)
! 2214: MailStartExecute(Sender);
! 2215: if(FtpAutoStart)
! 2216: FtpStartExecute(Sender);
! 2217: if(WebAutoStart)
! 2218: WebStartExecute(Sender);
! 2219: if(ServicesAutoStart)
! 2220: ServicesStartExecute(Sender);
! 2221:
1.1 root 2222: NodeForm->Timer->Enabled=true;
1.1.1.2 ! root 2223: ClientForm->Timer->Enabled=true;
! 2224:
! 2225: StatsTimer->Interval=cfg.node_stat_check*1000;
1.1 root 2226: StatsTimer->Enabled=true;
1.1.1.2 ! root 2227: Initialized=true;
1.1 root 2228:
1.1.1.2 ! root 2229: UpTimer->Enabled=true; /* Start updating the status bar */
! 2230:
! 2231: if(!Application->Active) /* Starting up minimized? */
! 2232: FormMinimize(Sender); /* Put icon in systray */
1.1 root 2233: }
2234: //---------------------------------------------------------------------------
1.1.1.2 ! root 2235: void __fastcall TMainForm::SaveRegistrySettings(TObject* Sender)
! 2236: {
! 2237: StatusBar->Panels->Items[4]->Text="Saving Registry Settings...";
1.1 root 2238:
1.1.1.2 ! root 2239: // Write Registry keys
! 2240: TRegistry* Registry=new TRegistry;
! 2241: if(!Registry->OpenKey(REG_KEY,true)) {
! 2242: Application->MessageBox("Error creating registry key"
! 2243: ,REG_KEY,MB_OK|MB_ICONEXCLAMATION);
! 2244: Application->Terminate();
! 2245: return;
! 2246: }
! 2247: Registry->WriteInteger("MainFormTop",Top);
! 2248: Registry->WriteInteger("MainFormLeft",Left);
! 2249: Registry->WriteInteger("MainFormHeight",Height);
! 2250: Registry->WriteInteger("MainFormWidth",Width);
1.1 root 2251:
1.1.1.2 ! root 2252: Registry->WriteInteger("NodeFormTop",NodeForm->Top);
! 2253: Registry->WriteInteger("NodeFormLeft",NodeForm->Left);
! 2254: Registry->WriteInteger("NodeFormHeight",NodeForm->Height);
! 2255: Registry->WriteInteger("NodeFormWidth",NodeForm->Width);
1.1 root 2256:
1.1.1.2 ! root 2257: Registry->WriteInteger("StatsFormTop",StatsForm->Top);
! 2258: Registry->WriteInteger("StatsFormLeft",StatsForm->Left);
! 2259: Registry->WriteInteger("StatsFormHeight",StatsForm->Height);
! 2260: Registry->WriteInteger("StatsFormWidth",StatsForm->Width);
1.1 root 2261:
1.1.1.2 ! root 2262: Registry->WriteInteger("ClientFormTop",ClientForm->Top);
! 2263: Registry->WriteInteger("ClientFormLeft",ClientForm->Left);
! 2264: Registry->WriteInteger("ClientFormHeight",ClientForm->Height);
! 2265: Registry->WriteInteger("ClientFormWidth",ClientForm->Width);
1.1 root 2266:
1.1.1.2 ! root 2267: for(int i=0;i<ClientForm->ListView->Columns->Count;i++) {
! 2268: char str[128];
! 2269: sprintf(str,"ClientListColumn%dWidth",i);
! 2270: Registry->WriteInteger(str
! 2271: ,ClientForm->ListView->Columns->Items[i]->Width);
1.1 root 2272: }
1.1.1.2 ! root 2273:
! 2274: Registry->WriteInteger("TelnetFormTop",TelnetForm->Top);
! 2275: Registry->WriteInteger("TelnetFormLeft",TelnetForm->Left);
! 2276: Registry->WriteInteger("TelnetFormHeight",TelnetForm->Height);
! 2277: Registry->WriteInteger("TelnetFormWidth",TelnetForm->Width);
1.1 root 2278:
1.1.1.2 ! root 2279: Registry->WriteInteger("EventsFormTop",EventsForm->Top);
! 2280: Registry->WriteInteger("EventsFormLeft",EventsForm->Left);
! 2281: Registry->WriteInteger("EventsFormHeight",EventsForm->Height);
! 2282: Registry->WriteInteger("EventsFormWidth",EventsForm->Width);
! 2283:
! 2284: Registry->WriteInteger("ServicesFormTop",ServicesForm->Top);
! 2285: Registry->WriteInteger("ServicesFormLeft",ServicesForm->Left);
! 2286: Registry->WriteInteger("ServicesFormHeight",ServicesForm->Height);
! 2287: Registry->WriteInteger("ServicesFormWidth",ServicesForm->Width);
1.1 root 2288:
1.1.1.2 ! root 2289: Registry->WriteInteger("FtpFormTop",FtpForm->Top);
! 2290: Registry->WriteInteger("FtpFormLeft",FtpForm->Left);
! 2291: Registry->WriteInteger("FtpFormHeight",FtpForm->Height);
! 2292: Registry->WriteInteger("FtpFormWidth",FtpForm->Width);
1.1 root 2293:
1.1.1.2 ! root 2294: Registry->WriteInteger("WebFormTop",WebForm->Top);
! 2295: Registry->WriteInteger("WebFormLeft",WebForm->Left);
! 2296: Registry->WriteInteger("WebFormHeight",WebForm->Height);
! 2297: Registry->WriteInteger("WebFormWidth",WebForm->Width);
1.1 root 2298:
1.1.1.2 ! root 2299: Registry->WriteInteger("MailFormTop",MailForm->Top);
! 2300: Registry->WriteInteger("MailFormLeft",MailForm->Left);
! 2301: Registry->WriteInteger("MailFormHeight",MailForm->Height);
! 2302: Registry->WriteInteger("MailFormWidth",MailForm->Width);
1.1 root 2303:
1.1.1.2 ! root 2304: Registry->WriteInteger("TopPanelHeight",TopPanel->Height);
! 2305: Registry->WriteInteger("UpperLeftPageControlWidth"
! 2306: ,UpperLeftPageControl->Width);
! 2307: Registry->WriteInteger("LowerLeftPageControlWidth"
! 2308: ,LowerLeftPageControl->Width);
1.1 root 2309:
1.1.1.2 ! root 2310: Registry->WriteBool("UndockableForms",UndockableForms);
1.1 root 2311:
1.1.1.2 ! root 2312: Registry->WriteBool("TelnetFormFloating",TelnetForm->Floating);
! 2313: Registry->WriteBool("EventsFormFloating",EventsForm->Floating);
! 2314: Registry->WriteBool("ServicesFormFloating",ServicesForm->Floating);
! 2315: Registry->WriteBool("NodeFormFloating",NodeForm->Floating);
! 2316: Registry->WriteBool("StatsFormFloating",StatsForm->Floating);
! 2317: Registry->WriteBool("ClientFormFloating",ClientForm->Floating);
! 2318: Registry->WriteBool("FtpFormFloating",FtpForm->Floating);
! 2319: Registry->WriteBool("WebFormFloating",WebForm->Floating);
! 2320: Registry->WriteBool("MailFormFloating",MailForm->Floating);
! 2321:
! 2322: Registry->WriteBool("TelnetFormVisible",TelnetForm->Visible);
! 2323: Registry->WriteBool("EventsFormVisible",EventsForm->Visible);
! 2324: Registry->WriteBool("ServicesFormVisible",ServicesForm->Visible);
! 2325: Registry->WriteBool("NodeFormVisible",NodeForm->Visible);
! 2326: Registry->WriteBool("StatsFormVisible",StatsForm->Visible);
! 2327: Registry->WriteBool("ClientFormVisible",ClientForm->Visible);
! 2328: Registry->WriteBool("FtpFormVisible",FtpForm->Visible);
! 2329: Registry->WriteBool("WebFormVisible",WebForm->Visible);
! 2330: Registry->WriteBool("MailFormVisible",MailForm->Visible);
! 2331:
! 2332: Registry->WriteInteger("TelnetFormPage"
! 2333: ,PageNum((TPageControl*)TelnetForm->HostDockSite));
! 2334: Registry->WriteInteger("EventsFormPage"
! 2335: ,PageNum((TPageControl*)EventsForm->HostDockSite));
! 2336: Registry->WriteInteger("ServicesFormPage"
! 2337: ,PageNum((TPageControl*)ServicesForm->HostDockSite));
! 2338: Registry->WriteInteger("NodeFormPage"
! 2339: ,PageNum((TPageControl*)NodeForm->HostDockSite));
! 2340: Registry->WriteInteger("MailFormPage"
! 2341: ,PageNum((TPageControl*)MailForm->HostDockSite));
! 2342: Registry->WriteInteger("FtpFormPage"
! 2343: ,PageNum((TPageControl*)FtpForm->HostDockSite));
! 2344: Registry->WriteInteger("WebFormPage"
! 2345: ,PageNum((TPageControl*)WebForm->HostDockSite));
! 2346: Registry->WriteInteger("StatsFormPage"
! 2347: ,PageNum((TPageControl*)StatsForm->HostDockSite));
! 2348: Registry->WriteInteger("ClientFormPage"
! 2349: ,PageNum((TPageControl*)ClientForm->HostDockSite));
! 2350:
! 2351: WriteColor(Registry,"TelnetLog",TelnetForm->Log->Color);
! 2352: WriteFont("TelnetLog",TelnetForm->Log->Font);
! 2353: WriteColor(Registry,"EventsLog",EventsForm->Log->Color);
! 2354: WriteFont("EventsLog",EventsForm->Log->Font);
! 2355: WriteColor(Registry,"ServicesLog",ServicesForm->Log->Color);
! 2356: WriteFont("ServicesLog",ServicesForm->Log->Font);
! 2357: WriteColor(Registry,"MailLog",MailForm->Log->Color);
! 2358: WriteFont("MailLog",MailForm->Log->Font);
! 2359: WriteColor(Registry,"FtpLog",FtpForm->Log->Color);
! 2360: WriteFont("FtpLog",FtpForm->Log->Font);
! 2361: WriteColor(Registry,"WebLog",WebForm->Log->Color);
! 2362: WriteFont("WebLog",WebForm->Log->Font);
! 2363: WriteColor(Registry,"NodeList",NodeForm->ListBox->Color);
! 2364: WriteFont("NodeList",NodeForm->ListBox->Font);
! 2365: WriteColor(Registry,"ClientList",ClientForm->ListView->Color);
! 2366: WriteFont("ClientList",ClientForm->ListView->Font);
! 2367:
! 2368: Registry->WriteBool("ToolBarVisible",Toolbar->Visible);
! 2369: Registry->WriteBool("StatusBarVisible",StatusBar->Visible);
! 2370:
! 2371: Registry->WriteInteger("MaxLogLen",MaxLogLen);
! 2372:
! 2373: Registry->WriteString("LoginCommand",LoginCommand);
! 2374: Registry->WriteString("ConfigCommand",ConfigCommand);
! 2375: Registry->WriteString("Password",Password);
! 2376: Registry->WriteBool("MinimizeToSysTray",MinimizeToSysTray);
! 2377: Registry->WriteBool("UseFileAssociations",UseFileAssociations);
! 2378: Registry->WriteInteger("NodeDisplayInterval",NodeForm->Timer->Interval/1000);
! 2379: Registry->WriteInteger("ClientDisplayInterval",ClientForm->Timer->Interval/1000);
! 2380:
! 2381: Registry->WriteInteger( "SpyTerminalWidth"
! 2382: ,SpyTerminalWidth);
! 2383: Registry->WriteInteger( "SpyTerminalHeight"
! 2384: ,SpyTerminalHeight);
! 2385: Registry->WriteString( "SpyTerminalFontName"
! 2386: ,SpyTerminalFont->Name);
! 2387: Registry->WriteInteger( "SpyTerminalFontSize"
! 2388: ,SpyTerminalFont->Size);
! 2389: Registry->WriteBool( "SpyTerminalKeyboardActive"
! 2390: ,SpyTerminalKeyboardActive);
! 2391:
! 2392: Registry->CloseKey();
! 2393: delete Registry;
! 2394: }
! 2395: //---------------------------------------------------------------------------
! 2396: void __fastcall TMainForm::SaveSettings(TObject* Sender)
! 2397: {
! 2398: SaveIniSettings(Sender);
! 2399: SaveRegistrySettings(Sender);
! 2400: }
! 2401: //---------------------------------------------------------------------------
! 2402: bool __fastcall TMainForm::SaveIniSettings(TObject* Sender)
! 2403: {
! 2404: FILE* fp=NULL;
! 2405: if(ini_file[0]==0)
! 2406: return(false);
! 2407:
! 2408: if((fp=fopen(ini_file,"r+"))==NULL) {
! 2409: char err[MAX_PATH*2];
! 2410: SAFEPRINTF2(err,"Error %d opening initialization file: %s",errno,ini_file);
! 2411: Application->MessageBox(err,"ERROR",MB_OK|MB_ICONEXCLAMATION);
! 2412: return(false);
! 2413: }
! 2414:
! 2415: StatusBar->Panels->Items[4]->Text="Saving Settings to " + AnsiString(ini_file) + " ...";
! 2416:
! 2417: bool success = sbbs_write_ini(fp
! 2418: ,&cfg
! 2419: ,&global
! 2420: ,SysAutoStart ,&bbs_startup
! 2421: ,FtpAutoStart ,&ftp_startup
! 2422: ,WebAutoStart ,&web_startup
! 2423: ,MailAutoStart ,&mail_startup
! 2424: ,ServicesAutoStart ,&services_startup
! 2425: );
! 2426: fclose(fp);
! 2427:
! 2428: return(success);
! 2429: }
! 2430:
! 2431: //---------------------------------------------------------------------------
! 2432: void __fastcall TMainForm::ImportFormSettings(TMemIniFile* IniFile, const char* section, TForm* Form)
! 2433: {
! 2434: Form->Top=IniFile->ReadInteger(section,"Top",Form->Top);
! 2435: Form->Left=IniFile->ReadInteger(section,"Left",Form->Left);
! 2436: Form->Width=IniFile->ReadInteger(section,"Width",Form->Width);
! 2437: Form->Height=IniFile->ReadInteger(section,"Height",Form->Height);
! 2438: }
! 2439: //---------------------------------------------------------------------------
! 2440: void __fastcall TMainForm::ExportFormSettings(TMemIniFile* IniFile, const char* section, TForm* Form)
! 2441: {
! 2442: IniFile->WriteInteger(section,"Top",Form->Top);
! 2443: IniFile->WriteInteger(section,"Left",Form->Left);
! 2444: IniFile->WriteInteger(section,"Width",Form->Width);
! 2445: IniFile->WriteInteger(section,"Height",Form->Height);
! 2446: IniFile->WriteInteger(section,"Page",PageNum((TPageControl*)Form->HostDockSite));
! 2447: IniFile->WriteBool(section,"Floating",Form->Floating);
! 2448: }
! 2449: //---------------------------------------------------------------------------
! 2450: void __fastcall TMainForm::ImportFont(TMemIniFile* IniFile, const char* section, AnsiString prefix, TFont* Font)
! 2451: {
! 2452: Font->Name=IniFile->ReadString(section,prefix + "Name",Font->Name);
! 2453: Font->Color=StringToColor(IniFile->ReadString(section,prefix + "Color",ColorToString(Font->Color)));
! 2454: Font->Height=IniFile->ReadInteger(section,prefix + "Height",Font->Height);
! 2455: Font->Size=IniFile->ReadInteger(section,prefix + "Size", Font->Size);
! 2456: IntToFontStyle(IniFile->ReadInteger(section,prefix + "Style",FontStyleToInt(Font)),Font);
! 2457: }
! 2458: //---------------------------------------------------------------------------
! 2459: void __fastcall TMainForm::ExportFont(TMemIniFile* IniFile, const char* section, AnsiString prefix, TFont* Font)
! 2460: {
! 2461: IniFile->WriteString(section,prefix+"Name",Font->Name);
! 2462: IniFile->WriteString(section,prefix+"Color",ColorToString(Font->Color));
! 2463: IniFile->WriteInteger(section,prefix+"Height",Font->Height);
! 2464: IniFile->WriteInteger(section,prefix+"Size",Font->Size);
! 2465: IniFile->WriteInteger(section,prefix+"Style",FontStyleToInt(Font));
! 2466: }
! 2467: //---------------------------------------------------------------------------
! 2468: void __fastcall TMainForm::ImportSettings(TObject* Sender)
! 2469: {
! 2470: OpenDialog->Filter="Settings files (*.ini)|*.ini|All files|*.*";
! 2471: OpenDialog->FileName=AnsiString(global.ctrl_dir)+"sbbsctrl.ini";
! 2472: if(!OpenDialog->Execute())
! 2473: return;
! 2474:
! 2475: StatusBar->Panels->Items[4]->Text="Importing Settings...";
! 2476:
! 2477: TMemIniFile* IniFile=new TMemIniFile(OpenDialog->FileName);
! 2478:
! 2479: const char* section = "Properties";
! 2480:
! 2481: LoginCommand=IniFile->ReadString(section,"LoginCommand",LoginCommand);
! 2482: ConfigCommand=IniFile->ReadString(section,"ConfigCommand",ConfigCommand);
! 2483: Password=IniFile->ReadString(section,"Password",Password);
! 2484: MinimizeToSysTray=IniFile->ReadBool(section,"MinimizeToSysTray",MinimizeToSysTray);
! 2485: UseFileAssociations=IniFile->ReadBool(section,"UseFileAssociations" ,UseFileAssociations);
! 2486: UndockableForms=IniFile->ReadBool(section,"UndockableForms",UndockableForms);
! 2487:
! 2488: ImportFormSettings(IniFile,section="MainForm",MainForm);
! 2489: TopPanel->Height=IniFile->ReadInteger(section,"TopPanelHeight",TopPanel->Height);
! 2490: UpperLeftPageControl->Width=IniFile->ReadInteger(section,"UpperLeftPageControlWidth",UpperLeftPageControl->Width);
! 2491: LowerLeftPageControl->Width=IniFile->ReadInteger(section,"LowerLeftPageControlWidth",LowerLeftPageControl->Width);
! 2492: Toolbar->Visible=IniFile->ReadBool(section,"ToolBarVisible",Toolbar->Visible);
! 2493: StatusBar->Visible=IniFile->ReadBool(section,"StatusBarVisible",StatusBar->Visible);
! 2494:
! 2495: ImportFormSettings(IniFile,section="TelnetForm",TelnetForm);
! 2496: ImportFont(IniFile,section,"LogFont",TelnetForm->Log->Font);
! 2497: TelnetForm->Log->Color=StringToColor(IniFile->ReadString(section,"LogColor",clWindow));
! 2498:
! 2499: ImportFormSettings(IniFile,section="EventsForm",EventsForm);
! 2500: ImportFont(IniFile,section,"LogFont",EventsForm->Log->Font);
! 2501: EventsForm->Log->Color=StringToColor(IniFile->ReadString(section,"LogColor",clWindow));
! 2502:
! 2503: ImportFormSettings(IniFile,section="ServicesForm",ServicesForm);
! 2504: ImportFont(IniFile,section,"LogFont",ServicesForm->Log->Font);
! 2505: ServicesForm->Log->Color=StringToColor(IniFile->ReadString(section,"LogColor",clWindow));
! 2506:
! 2507: ImportFormSettings(IniFile,section="FtpForm",FtpForm);
! 2508: ImportFont(IniFile,section,"LogFont",FtpForm->Log->Font);
! 2509: FtpLogFile=IniFile->ReadInteger(section,"LogFile",true);
! 2510: FtpForm->Log->Color=StringToColor(IniFile->ReadString(section,"LogColor",clWindow));
! 2511:
! 2512: ImportFormSettings(IniFile,section="WebForm",WebForm);
! 2513: ImportFont(IniFile,section,"LogFont",WebForm->Log->Font);
! 2514: WebForm->Log->Color=StringToColor(IniFile->ReadString(section,"LogColor",clWindow));
! 2515:
! 2516: ImportFormSettings(IniFile,section="MailForm",MailForm);
! 2517: ImportFont(IniFile,section,"LogFont",MailForm->Log->Font);
! 2518: MailLogFile=IniFile->ReadInteger(section,"LogFile",true);
! 2519: MailForm->Log->Color=StringToColor(IniFile->ReadString(section,"LogColor",clWindow));
! 2520:
! 2521: ImportFormSettings(IniFile,section="NodeForm",NodeForm);
! 2522: ImportFont(IniFile,section,"ListFont",NodeForm->ListBox->Font);
! 2523: NodeForm->Timer->Interval=IniFile->ReadInteger(section,"DisplayInterval"
! 2524: ,NodeForm->Timer->Interval/1000)*1000;
! 2525: NodeForm->ListBox->Color=StringToColor(IniFile->ReadString(section,"ListColor",clWindow));
! 2526:
! 2527: ImportFormSettings(IniFile,section="StatsForm",StatsForm);
! 2528:
! 2529: ImportFormSettings(IniFile,section="ClientForm",ClientForm);
! 2530: ImportFont(IniFile,section,"ListFont",ClientForm->ListView->Font);
! 2531: ClientForm->ListView->Color=StringToColor(IniFile->ReadString(section,"ListColor",clWindow));
! 2532: ClientForm->Timer->Interval=IniFile->ReadInteger(section,"DisplayInterval"
! 2533: ,ClientForm->Timer->Interval/1000)*1000;
! 2534: for(int i=0;i<ClientForm->ListView->Columns->Count;i++) {
! 2535: char str[128];
! 2536: sprintf(str,"Column%dWidth",i);
! 2537: if(IniFile->ValueExists(section,str))
! 2538: ClientForm->ListView->Columns->Items[i]->Width
! 2539: =IniFile->ReadInteger(section,str,0);
! 2540: }
! 2541:
! 2542: section = "SpyTerminal";
! 2543: SpyTerminalWidth=IniFile->ReadInteger(section, "Width", SpyTerminalWidth);
! 2544: SpyTerminalHeight=IniFile->ReadInteger(section, "Height", SpyTerminalHeight);
! 2545: SpyTerminalFont->Name=IniFile->ReadString(section, "FontName", SpyTerminalFont->Name);
! 2546: SpyTerminalFont->Size=IniFile->ReadInteger(section, "FontSize", SpyTerminalFont->Size);
! 2547: SpyTerminalKeyboardActive=IniFile->ReadBool(section, "KeyboardActive", SpyTerminalKeyboardActive);
! 2548:
! 2549: delete IniFile;
! 2550:
! 2551: Application->MessageBox(AnsiString("Successfully imported SBBSCTRL settings from "
! 2552: + OpenDialog->FileName).c_str(),"Successful Import",MB_OK);
! 2553: }
! 2554: //---------------------------------------------------------------------------
! 2555: void __fastcall TMainForm::ExportSettings(TObject* Sender)
! 2556: {
! 2557: char str[128];
! 2558:
! 2559: SaveDialog->Filter="Settings files (*.ini)|*.ini|All files|*.*";
! 2560: SaveDialog->FileName=AnsiString(global.ctrl_dir)+"sbbsctrl.ini";
! 2561: if(!SaveDialog->Execute())
! 2562: return;
! 2563:
! 2564: TMemIniFile* IniFile=new TMemIniFile(SaveDialog->FileName);
! 2565:
! 2566: StatusBar->Panels->Items[4]->Text="Exporting Settings...";
! 2567:
! 2568: const char* section = "Properties";
! 2569:
! 2570: IniFile->WriteString(section,"LoginCommand",LoginCommand);
! 2571: IniFile->WriteString(section,"ConfigCommand",ConfigCommand);
! 2572: IniFile->WriteString(section,"Password",Password);
! 2573: IniFile->WriteBool(section,"MinimizeToSysTray",MinimizeToSysTray);
! 2574: IniFile->WriteBool(section,"UseFileAssociations",UseFileAssociations);
! 2575: IniFile->WriteBool(section,"UndockableForms",UndockableForms);
! 2576:
! 2577: ExportFormSettings(IniFile,section="MainForm",MainForm);
! 2578: IniFile->WriteInteger(section,"TopPanelHeight",TopPanel->Height);
! 2579: IniFile->WriteInteger(section,"UpperLeftPageControlWidth",UpperLeftPageControl->Width);
! 2580: IniFile->WriteInteger(section,"LowerLeftPageControlWidth",LowerLeftPageControl->Width);
! 2581: IniFile->WriteBool(section,"ToolBarVisible",Toolbar->Visible);
! 2582: IniFile->WriteBool(section,"StatusBarVisible",StatusBar->Visible);
! 2583:
! 2584: ExportFormSettings(IniFile,section = "NodeForm",NodeForm);
! 2585: ExportFont(IniFile,section,"ListFont",NodeForm->ListBox->Font);
! 2586: IniFile->WriteString(section,"ListColor",ColorToString(NodeForm->ListBox->Color));
! 2587: IniFile->WriteInteger(section,"DisplayInterval",NodeForm->Timer->Interval/1000);
! 2588:
! 2589: ExportFormSettings(IniFile,section = "StatsForm",StatsForm);
! 2590:
! 2591: ExportFormSettings(IniFile,section = "ClientForm",ClientForm);
! 2592: ExportFont(IniFile,section,"ListFont",ClientForm->ListView->Font);
! 2593: IniFile->WriteString(section,"ListColor",ColorToString(ClientForm->ListView->Color));
! 2594: IniFile->WriteInteger(section,"DisplayInterval",ClientForm->Timer->Interval/1000);
! 2595: for(int i=0;i<ClientForm->ListView->Columns->Count;i++) {
! 2596: char str[128];
! 2597: sprintf(str,"Column%dWidth",i);
! 2598: IniFile->WriteInteger(section,str
! 2599: ,ClientForm->ListView->Columns->Items[i]->Width);
! 2600: }
! 2601:
! 2602: ExportFormSettings(IniFile,section = "TelnetForm",TelnetForm);
! 2603: ExportFont(IniFile,section,"LogFont",TelnetForm->Log->Font);
! 2604:
! 2605: ExportFormSettings(IniFile,section = "EventsForm",EventsForm);
! 2606: ExportFont(IniFile,section,"LogFont",EventsForm->Log->Font);
! 2607:
! 2608: ExportFormSettings(IniFile,section = "ServicesForm",ServicesForm);
! 2609: ExportFont(IniFile,section,"LogFont",ServicesForm->Log->Font);
! 2610:
! 2611: ExportFormSettings(IniFile,section = "FtpForm",FtpForm);
! 2612: ExportFont(IniFile,section,"LogFont",FtpForm->Log->Font);
! 2613:
! 2614: ExportFormSettings(IniFile,section = "MailForm",MailForm);
! 2615: ExportFont(IniFile,section,"LogFont",MailForm->Log->Font);
! 2616:
! 2617: section = "SpyTerminal";
! 2618: IniFile->WriteInteger(section, "Width"
! 2619: ,SpyTerminalWidth);
! 2620: IniFile->WriteInteger(section, "Height"
! 2621: ,SpyTerminalHeight);
! 2622: IniFile->WriteString(section, "FontName"
! 2623: ,SpyTerminalFont->Name);
! 2624: IniFile->WriteInteger(section, "FontSize"
! 2625: ,SpyTerminalFont->Size);
! 2626: IniFile->WriteBool(section, "KeyboardActive"
! 2627: ,SpyTerminalKeyboardActive);
! 2628:
! 2629: IniFile->UpdateFile();
! 2630:
! 2631: delete IniFile;
! 2632:
! 2633: Application->MessageBox(AnsiString("Successfully exported SBBSCTRL settings to "
! 2634: + SaveDialog->FileName).c_str(),"Successful Export",MB_OK);
! 2635: }
! 2636: //---------------------------------------------------------------------------
! 2637:
! 2638: void __fastcall TMainForm::ViewStatusBarMenuItemClick(TObject *Sender)
! 2639: {
! 2640: StatusBar->Visible=!StatusBar->Visible;
! 2641: ViewStatusBarMenuItem->Checked=StatusBar->Visible;
! 2642: }
! 2643: //---------------------------------------------------------------------------
! 2644: void __fastcall TMainForm::HelpAboutMenuItemClick(TObject *Sender)
! 2645: {
! 2646: Application->CreateForm(__classid(TAboutBoxForm), &AboutBoxForm);
! 2647: AboutBoxForm->ShowModal();
! 2648: delete AboutBoxForm;
! 2649: }
! 2650: //---------------------------------------------------------------------------
! 2651: BOOL MuteService(SC_HANDLE svc, SERVICE_STATUS* status, BOOL mute)
! 2652: {
! 2653: if(svc==NULL || controlService==NULL)
! 2654: return(FALSE);
! 2655:
! 2656: return controlService(svc
! 2657: ,mute ? SERVICE_CONTROL_MUTE:SERVICE_CONTROL_UNMUTE, status);
! 2658: }
! 2659: //---------------------------------------------------------------------------
! 2660: void __fastcall TMainForm::SoundToggleExecute(TObject *Sender)
! 2661: {
! 2662: SoundToggle->Checked=!SoundToggle->Checked;
! 2663:
! 2664: if(!SoundToggle->Checked) {
! 2665: bbs_startup.options|=BBS_OPT_MUTE;
! 2666: ftp_startup.options|=FTP_OPT_MUTE;
! 2667: web_startup.options|=FTP_OPT_MUTE;
! 2668: mail_startup.options|=MAIL_OPT_MUTE;
! 2669: services_startup.options|=MAIL_OPT_MUTE;
! 2670: } else {
! 2671: bbs_startup.options&=~BBS_OPT_MUTE;
! 2672: ftp_startup.options&=~FTP_OPT_MUTE;
! 2673: web_startup.options&=~FTP_OPT_MUTE;
! 2674: mail_startup.options&=~MAIL_OPT_MUTE;
! 2675: services_startup.options&=~MAIL_OPT_MUTE;
! 2676: }
! 2677: MuteService(bbs_svc,&bbs_svc_status,!SoundToggle->Checked);
! 2678: MuteService(ftp_svc,&ftp_svc_status,!SoundToggle->Checked);
! 2679: MuteService(web_svc,&web_svc_status,!SoundToggle->Checked);
! 2680: MuteService(mail_svc,&mail_svc_status,!SoundToggle->Checked);
! 2681: MuteService(services_svc,&services_svc_status,!SoundToggle->Checked);
! 2682: }
! 2683: //---------------------------------------------------------------------------
! 2684: void __fastcall TMainForm::BBSStatisticsLogMenuItemClick(TObject *Sender)
! 2685: {
! 2686: StatsForm->LogButtonClick(Sender);
! 2687: }
! 2688: //---------------------------------------------------------------------------
! 2689:
! 2690: void __fastcall TMainForm::ForceTimedEventMenuItemClick(TObject *Sender)
! 2691: {
! 2692: int i,file;
! 2693: char str[MAX_PATH+1];
! 2694:
! 2695: Application->CreateForm(__classid(TCodeInputForm), &CodeInputForm);
! 2696: CodeInputForm->Label->Caption="Event Internal Code";
! 2697: CodeInputForm->ComboBox->Items->Clear();
! 2698: for(i=0;i<cfg.total_events;i++)
! 2699: CodeInputForm->ComboBox->Items->Add(
! 2700: AnsiString(cfg.event[i]->code).UpperCase());
! 2701: CodeInputForm->ComboBox->ItemIndex=0;
! 2702: if(CodeInputForm->ShowModal()==mrOk
! 2703: && CodeInputForm->ComboBox->Text.Length()) {
! 2704: for(i=0;i<cfg.total_events;i++) {
! 2705: if(!stricmp(CodeInputForm->ComboBox->Text.c_str(),cfg.event[i]->code)) {
! 2706: sprintf(str,"%s%s.now",cfg.data_dir,cfg.event[i]->code);
! 2707: if((file=_sopen(str,O_CREAT|O_TRUNC|O_WRONLY
! 2708: ,SH_DENYRW,S_IREAD|S_IWRITE))!=-1)
! 2709: close(file);
! 2710: break;
! 2711: }
! 2712: }
! 2713: if(i>=cfg.total_events)
! 2714: Application->MessageBox(CodeInputForm->ComboBox->Text.c_str()
! 2715: ,"Event Code Not Found",MB_OK|MB_ICONEXCLAMATION);
! 2716: }
! 2717: delete CodeInputForm;
! 2718: }
! 2719: //---------------------------------------------------------------------------
! 2720:
! 2721: void __fastcall TMainForm::ForceNetworkCalloutMenuItemClick(
! 2722: TObject *Sender)
! 2723: {
! 2724: int i,file;
! 2725: char str[MAX_PATH+1];
! 2726:
! 2727: Application->CreateForm(__classid(TCodeInputForm), &CodeInputForm);
! 2728: CodeInputForm->Label->Caption="Hub QWK-ID";
! 2729: CodeInputForm->ComboBox->Items->Clear();
! 2730: for(i=0;i<cfg.total_qhubs;i++)
! 2731: CodeInputForm->ComboBox->Items->Add(
! 2732: AnsiString(cfg.qhub[i]->id).UpperCase());
! 2733: CodeInputForm->ComboBox->ItemIndex=0;
! 2734: if(CodeInputForm->ShowModal()==mrOk
! 2735: && CodeInputForm->ComboBox->Text.Length()) {
! 2736: for(i=0;i<cfg.total_qhubs;i++) {
! 2737: if(!stricmp(CodeInputForm->ComboBox->Text.c_str(),cfg.qhub[i]->id)) {
! 2738: sprintf(str,"%sqnet/%s.now",cfg.data_dir,cfg.qhub[i]->id);
! 2739: if((file=_sopen(str,O_CREAT|O_TRUNC|O_WRONLY
! 2740: ,SH_DENYRW,S_IREAD|S_IWRITE))!=-1)
! 2741: close(file);
! 2742: break;
! 2743: }
! 2744: }
1.1 root 2745: if(i>=cfg.total_qhubs)
1.1.1.2 ! root 2746: Application->MessageBox(CodeInputForm->ComboBox->Text.c_str()
! 2747: ,"QWKnet Hub ID Not Found",MB_OK|MB_ICONEXCLAMATION);
1.1 root 2748: }
2749: delete CodeInputForm;
2750: }
2751: //---------------------------------------------------------------------------
2752:
2753: void __fastcall TMainForm::TextMenuItemEditClick(TObject *Sender)
2754: {
2755: char filename[MAX_PATH+1];
2756:
2757: sprintf(filename,"%s%s"
2758: ,MainForm->cfg.text_dir
2759: ,((TMenuItem*)Sender)->Hint.c_str());
1.1.1.2 ! root 2760: EditFile(filename,((TMenuItem*)Sender)->Caption);
1.1 root 2761: }
2762:
1.1.1.2 ! root 2763: //---------------------------------------------------------------------------
1.1 root 2764: void __fastcall TMainForm::CtrlMenuItemEditClick(TObject *Sender)
2765: {
2766: char filename[MAX_PATH+1];
2767:
1.1.1.2 ! root 2768: iniFileName(filename,sizeof(filename)
1.1 root 2769: ,MainForm->cfg.ctrl_dir
2770: ,((TMenuItem*)Sender)->Hint.c_str());
1.1.1.2 ! root 2771: EditFile(filename,((TMenuItem*)Sender)->Caption);
! 2772: }
! 2773: void __fastcall TMainForm::DataMenuItemClick(TObject *Sender)
! 2774: {
! 2775: char filename[MAX_PATH+1];
1.1 root 2776:
1.1.1.2 ! root 2777: sprintf(filename,"%s%s"
! 2778: ,MainForm->cfg.data_dir
! 2779: ,((TMenuItem*)Sender)->Hint.c_str());
! 2780: EditFile(filename,((TMenuItem*)Sender)->Caption);
1.1 root 2781: }
1.1.1.2 ! root 2782: //---------------------------------------------------------------------------
1.1 root 2783:
2784: //---------------------------------------------------------------------------
2785:
2786: void __fastcall TMainForm::UpTimerTick(TObject *Sender)
2787: {
2788: char str[128];
2789: char days[64];
2790: static time_t start;
2791: ulong up;
2792:
2793: if(!start)
2794: start=time(NULL);
2795: up=time(NULL)-start;
2796:
2797: days[0]=0;
2798: if((up/(24*60*60))>=2) {
2799: sprintf(days,"%u days ",up/(24*60*60));
2800: up%=(24*60*60);
2801: }
2802: sprintf(str,"Up: %s%u:%02u"
2803: ,days
2804: ,up/(60*60)
2805: ,(up/60)%60
2806: );
2807: AnsiString Str=AnsiString(str);
2808: if(MainForm->StatusBar->Panels->Items[4]->Text!=Str)
2809: MainForm->StatusBar->Panels->Items[4]->Text=Str;
1.1.1.2 ! root 2810: #if 0
! 2811: THeapStatus hp=GetHeapStatus();
! 2812: sprintf(str,"Mem Used: %lu bytes",hp.TotalAllocated);
! 2813: Str=AnsiString(str);
! 2814: if(MainForm->StatusBar->Panels->Items[5]->Text!=Str)
! 2815: MainForm->StatusBar->Panels->Items[5]->Text=Str;
! 2816: #endif
! 2817: if(TrayIcon->Visible) {
! 2818: /* Animate TrayIcon when in use */
! 2819: AnsiString NumClients;
! 2820: try {
! 2821: if(clients) {
! 2822: TrayIcon->IconIndex=(TrayIcon->IconIndex==4) ? 59 : 4;
! 2823: NumClients=" ("+AnsiString(clients)+" client";
! 2824: if(clients>1)
! 2825: NumClients+="s";
! 2826: NumClients+=")";
! 2827: } else if(TrayIcon->IconIndex!=4)
! 2828: TrayIcon->IconIndex=4;
! 2829: TrayIcon->Hint=AnsiString(APP_TITLE)+NumClients;
! 2830: } catch(...) { /* ignore exceptions here */ };
! 2831: }
1.1 root 2832: }
2833: //---------------------------------------------------------------------------
2834:
2835: void __fastcall TMainForm::BBSViewErrorLogMenuItemClick(TObject *Sender)
2836: {
2837: char filename[MAX_PATH+1];
2838:
2839: sprintf(filename,"%sERROR.LOG"
1.1.1.2 ! root 2840: ,MainForm->cfg.logs_dir);
! 2841: ViewFile(filename,"Error Log");
1.1 root 2842: }
2843: //---------------------------------------------------------------------------
2844:
2845: void __fastcall TMainForm::ChatToggleExecute(TObject *Sender)
2846: {
2847: ChatToggle->Checked=!ChatToggle->Checked;
2848: if(ChatToggle->Checked)
2849: bbs_startup.options|=BBS_OPT_SYSOP_AVAILABLE;
2850: else
2851: bbs_startup.options&=~BBS_OPT_SYSOP_AVAILABLE;
2852:
1.1.1.2 ! root 2853: if(bbs_svc!=NULL && controlService!=NULL)
! 2854: controlService(bbs_svc
! 2855: ,ChatToggle->Checked ? SERVICE_CONTROL_SYSOP_AVAILABLE : SERVICE_CONTROL_SYSOP_UNAVAILABLE
! 2856: ,&bbs_svc_status);
1.1 root 2857: }
2858: //---------------------------------------------------------------------------
2859: void __fastcall TMainForm::UserEditExecute(TObject *Sender)
2860: {
2861: char str[256];
2862:
2863: sprintf(str,"%sUSEREDIT %s",cfg.exec_dir,cfg.data_dir);
2864: WinExec(str,SW_SHOWNORMAL);
2865: }
2866: //---------------------------------------------------------------------------
2867:
1.1.1.2 ! root 2868: void __fastcall TMainForm::BBSPreviewMenuItemClick(TObject *Sender)
1.1 root 2869: {
2870: TOpenDialog* dlg=new TOpenDialog((TComponent*)Sender);
2871:
1.1.1.2 ! root 2872: dlg->Options << ofNoChangeDir;
! 2873: dlg->Filter = "ANSI/Ctrl-A files (*.asc; *.msg; *.ans)|*.ASC;*.MSG;*.ANS"
1.1 root 2874: "|All files|*.*";
2875: dlg->InitialDir=cfg.text_dir;
2876: if(dlg->Execute()==true) {
1.1.1.2 ! root 2877: Application->CreateForm(__classid(TPreviewForm), &PreviewForm);
! 2878: PreviewForm->Filename=AnsiString(dlg->FileName);
! 2879: PreviewForm->ShowModal();
! 2880: delete PreviewForm;
1.1 root 2881: }
2882: delete dlg;
2883: }
2884: //---------------------------------------------------------------------------
2885: void __fastcall TMainForm::BBSLoginMenuItemClick(TObject *Sender)
2886: {
1.1.1.2 ! root 2887: if(!strnicmp(LoginCommand.c_str(),"start ",6)) /* Doesn't work on NT */
! 2888: ShellExecute(Handle, "open", LoginCommand.c_str()+6,
! 2889: NULL,NULL,SW_SHOWDEFAULT);
! 2890: else if(!strnicmp(LoginCommand.c_str(),"telnet:",7))
! 2891: ShellExecute(Handle, "open", LoginCommand.c_str(),
! 2892: NULL,NULL,SW_SHOWDEFAULT);
1.1 root 2893: else
2894: WinExec(LoginCommand.c_str(),SW_SHOWNORMAL);
2895: }
2896: //---------------------------------------------------------------------------
2897: void __fastcall TMainForm::ViewLogClick(TObject *Sender)
2898: {
2899: char str[128];
2900: char filename[MAX_PATH+1];
2901: struct tm* tm;
2902: time_t t;
2903: TModalResult mr;
2904:
2905: if(((TMenuItem*)Sender)->Tag==-1) {
2906: Application->CreateForm(__classid(TCodeInputForm), &CodeInputForm);
2907: CodeInputForm->Label->Caption="Date";
1.1.1.2 ! root 2908: CodeInputForm->ComboBox->Items->Clear();
! 2909: CodeInputForm->ComboBox->Text=AnsiString(unixtodstr(&cfg,time(NULL),str));
1.1 root 2910: mr=CodeInputForm->ShowModal();
1.1.1.2 ! root 2911: t=dstrtounix(&cfg,CodeInputForm->ComboBox->Text.c_str());
1.1 root 2912: delete CodeInputForm;
2913: if(mr!=mrOk)
2914: return;
2915: } else {
2916: t=time(NULL);
2917: t-=((TMenuItem*)Sender)->Tag*24*60*60;
2918: }
1.1.1.2 ! root 2919: tm=localtime(&t);
1.1 root 2920: if(tm==NULL)
2921: return;
2922:
2923: /* Close Mail/FTP logs */
1.1.1.2 ! root 2924: mail_lputs(NULL,0,NULL);
! 2925: ftp_lputs(NULL,0,NULL);
1.1 root 2926:
2927: sprintf(filename,"%sLOGS\\%s%02d%02d%02d.LOG"
1.1.1.2 ! root 2928: ,MainForm->cfg.logs_dir
1.1 root 2929: ,((TMenuItem*)Sender)->Hint.c_str()
2930: ,tm->tm_mon+1
2931: ,tm->tm_mday
2932: ,tm->tm_year%100
2933: );
1.1.1.2 ! root 2934: ViewFile(filename,((TMenuItem*)Sender)->Caption);
1.1 root 2935: }
2936: //---------------------------------------------------------------------------
2937: void __fastcall TMainForm::UserListExecute(TObject *Sender)
2938: {
2939: UserListForm->Show();
2940: }
2941: //---------------------------------------------------------------------------
2942:
1.1.1.2 ! root 2943: void __fastcall TMainForm::WebPageMenuItemClick(TObject *Sender)
! 2944: {
! 2945: ShellExecute(Handle, "open", ((TMenuItem*)Sender)->Hint.c_str(),
! 2946: NULL,NULL,SW_SHOWDEFAULT);
! 2947: }
! 2948: //---------------------------------------------------------------------------
! 2949: void __fastcall TMainForm::FormMinimize(TObject *Sender)
! 2950: {
! 2951: if(MinimizeToSysTray) {
! 2952: if(Password.Length()) {
! 2953: TrayIcon->RestoreOn=imNone;
! 2954: CloseTrayMenuItem->Enabled=false;
! 2955: ConfigureTrayMenuItem->Enabled=false;
! 2956: UserEditTrayMenuItem->Enabled=false;
! 2957: } else {
! 2958: TrayIcon->RestoreOn=imLeftClickUp;
! 2959: CloseTrayMenuItem->Enabled=true;
! 2960: ConfigureTrayMenuItem->Enabled=true;
! 2961: UserEditTrayMenuItem->Enabled=true;
! 2962: }
! 2963: if(!TrayIcon->Visible)
! 2964: TrayIcon->Visible=true;
! 2965: TrayIcon->Minimize();
! 2966: }
! 2967: }
! 2968:
! 2969: void __fastcall TMainForm::TrayIconRestore(TObject *Sender)
! 2970: {
! 2971: TrayIcon->Visible=false;
! 2972: }
! 2973:
! 2974: //---------------------------------------------------------------------------
! 2975:
! 2976: void __fastcall TMainForm::PropertiesExecute(TObject *Sender)
! 2977: {
! 2978: static inside;
! 2979: if(inside) return;
! 2980: inside=true;
! 2981:
! 2982: Application->CreateForm(__classid(TPropertiesDlg), &PropertiesDlg);
! 2983: PropertiesDlg->LoginCmdEdit->Text=LoginCommand;
! 2984: PropertiesDlg->ConfigCmdEdit->Text=ConfigCommand;
! 2985: PropertiesDlg->HostnameEdit->Text=global.host_name;
! 2986: PropertiesDlg->CtrlDirEdit->Text=global.ctrl_dir;
! 2987: PropertiesDlg->TempDirEdit->Text=global.temp_dir;
! 2988: PropertiesDlg->NodeIntUpDown->Position=NodeForm->Timer->Interval/1000;
! 2989: PropertiesDlg->ClientIntUpDown->Position=ClientForm->Timer->Interval/1000;
! 2990: PropertiesDlg->SemFreqUpDown->Position=global.sem_chk_freq;
! 2991: PropertiesDlg->TrayIconCheckBox->Checked=MinimizeToSysTray;
! 2992: PropertiesDlg->UndockableCheckBox->Checked=UndockableForms;
! 2993: PropertiesDlg->FileAssociationsCheckBox->Checked=UseFileAssociations;
! 2994: PropertiesDlg->PasswordEdit->Text=Password;
! 2995: PropertiesDlg->JS_MaxBytesEdit->Text=IntToStr(global.js.max_bytes);
! 2996: PropertiesDlg->JS_ContextStackEdit->Text=IntToStr(global.js.cx_stack);
! 2997: PropertiesDlg->JS_BranchLimitEdit->Text=IntToStr(global.js.branch_limit);
! 2998: PropertiesDlg->JS_GcIntervalEdit->Text=IntToStr(global.js.gc_interval);
! 2999: PropertiesDlg->JS_YieldIntervalEdit->Text=IntToStr(global.js.yield_interval);
! 3000:
! 3001: if(MaxLogLen==0)
! 3002: PropertiesDlg->MaxLogLenEdit->Text="<unlimited>";
! 3003: else
! 3004: PropertiesDlg->MaxLogLenEdit->Text=IntToStr(MaxLogLen);
! 3005: if(PropertiesDlg->ShowModal()==mrOk) {
! 3006: LoginCommand=PropertiesDlg->LoginCmdEdit->Text;
! 3007: ConfigCommand=PropertiesDlg->ConfigCmdEdit->Text;
! 3008: SAFECOPY(global.host_name,PropertiesDlg->HostnameEdit->Text.c_str());
! 3009: SAFECOPY(global.ctrl_dir,PropertiesDlg->CtrlDirEdit->Text.c_str());
! 3010: SAFECOPY(global.temp_dir,PropertiesDlg->TempDirEdit->Text.c_str());
! 3011: Password=PropertiesDlg->PasswordEdit->Text;
! 3012: NodeForm->Timer->Interval=PropertiesDlg->NodeIntUpDown->Position*1000;
! 3013: ClientForm->Timer->Interval=PropertiesDlg->ClientIntUpDown->Position*1000;
! 3014: global.sem_chk_freq=PropertiesDlg->SemFreqUpDown->Position;
! 3015: MinimizeToSysTray=PropertiesDlg->TrayIconCheckBox->Checked;
! 3016: UndockableForms=PropertiesDlg->UndockableCheckBox->Checked;
! 3017: UseFileAssociations=PropertiesDlg->FileAssociationsCheckBox->Checked;
! 3018: global.js.max_bytes
! 3019: =PropertiesDlg->JS_MaxBytesEdit->Text.ToIntDef(JAVASCRIPT_MAX_BYTES);
! 3020: global.js.cx_stack
! 3021: =PropertiesDlg->JS_ContextStackEdit->Text.ToIntDef(JAVASCRIPT_CONTEXT_STACK);
! 3022: global.js.branch_limit
! 3023: =PropertiesDlg->JS_BranchLimitEdit->Text.ToIntDef(JAVASCRIPT_BRANCH_LIMIT);
! 3024: global.js.gc_interval
! 3025: =PropertiesDlg->JS_GcIntervalEdit->Text.ToIntDef(JAVASCRIPT_GC_INTERVAL);
! 3026: global.js.yield_interval
! 3027: =PropertiesDlg->JS_YieldIntervalEdit->Text.ToIntDef(JAVASCRIPT_YIELD_INTERVAL);
! 3028:
! 3029: MaxLogLen
! 3030: =PropertiesDlg->MaxLogLenEdit->Text.ToIntDef(0);
! 3031: SaveSettings(Sender);
! 3032: }
! 3033: delete PropertiesDlg;
! 3034:
! 3035: inside=false;
! 3036: }
! 3037: //---------------------------------------------------------------------------
! 3038:
! 3039: void __fastcall TMainForm::CloseTrayMenuItemClick(TObject *Sender)
! 3040: {
! 3041: Close();
! 3042: }
! 3043: //---------------------------------------------------------------------------
! 3044:
! 3045: void __fastcall TMainForm::RestoreTrayMenuItemClick(TObject *Sender)
! 3046: {
! 3047: #if 0
! 3048: TrayIcon->Visible=false;
! 3049: Application->Restore();
! 3050: #else
! 3051: static inside;
! 3052: if(inside)
! 3053: return;
! 3054: inside=true;
! 3055:
! 3056: if(Password.Length()) {
! 3057: Application->CreateForm(__classid(TCodeInputForm), &CodeInputForm);
! 3058: CodeInputForm->Label->Caption="Password";
! 3059: CodeInputForm->Edit->Visible=true;
! 3060: CodeInputForm->Edit->PasswordChar='*';
! 3061: if(CodeInputForm->ShowModal()==mrOk
! 3062: && CodeInputForm->Edit->Text.AnsiCompareIC(Password)==0)
! 3063: TrayIcon->Restore();
! 3064: delete CodeInputForm;
! 3065: } else
! 3066: TrayIcon->Restore();
! 3067:
! 3068: inside=false;
! 3069: #endif
! 3070: }
! 3071: //---------------------------------------------------------------------------
! 3072: void __fastcall TMainForm::BBSConfigWizardMenuItemClick(TObject *Sender)
! 3073: {
! 3074: TConfigWizard* ConfigWizard;
! 3075: static inside;
! 3076: if(inside) return;
! 3077: inside=true;
! 3078:
! 3079: Application->CreateForm(__classid(TConfigWizard), &ConfigWizard);
! 3080: if(ConfigWizard->ShowModal()==mrOk) {
! 3081: SaveSettings(Sender);
! 3082: ReloadConfigExecute(Sender);
! 3083: }
! 3084: delete ConfigWizard;
! 3085:
! 3086: inside=false;
! 3087: }
! 3088: //---------------------------------------------------------------------------
! 3089:
! 3090: void __fastcall TMainForm::PageControlUnDock(TObject *Sender,
! 3091: TControl *Client, TWinControl *NewTarget, bool &Allow)
! 3092: {
! 3093: if(NewTarget==NULL) /* Desktop */
! 3094: Allow=UndockableForms;
! 3095: }
! 3096: //---------------------------------------------------------------------------
! 3097:
! 3098: void __fastcall TMainForm::ReloadConfigExecute(TObject *Sender)
! 3099: {
! 3100: FtpRecycleExecute(Sender);
! 3101: WebRecycleExecute(Sender);
! 3102: MailRecycleExecute(Sender);
! 3103: ServicesRecycleExecute(Sender);
! 3104:
! 3105: char error[256];
! 3106: SAFECOPY(error,UNKNOWN_LOAD_ERROR);
! 3107: if(!load_cfg(&cfg, NULL, TRUE, error)) {
! 3108: Application->MessageBox(error,"ERROR Re-loading Configuration"
! 3109: ,MB_OK|MB_ICONEXCLAMATION);
! 3110: Application->Terminate();
! 3111: }
! 3112:
! 3113: node_t node;
! 3114: for(int i=0;i<cfg.sys_nodes;i++) {
! 3115: int file;
! 3116: if(NodeForm->getnodedat(i+1,&node,&file))
! 3117: break;
! 3118: node.misc|=NODE_RRUN;
! 3119: if(NodeForm->putnodedat(i+1,&node,file))
! 3120: break;
! 3121: }
! 3122: }
! 3123:
! 3124: //---------------------------------------------------------------------------
! 3125:
! 3126:
! 3127: void __fastcall TMainForm::ServicesConfigureExecute(TObject *Sender)
! 3128: {
! 3129: static inside;
! 3130: if(inside) return;
! 3131: inside=true;
! 3132:
! 3133: Application->CreateForm(__classid(TServicesCfgDlg), &ServicesCfgDlg);
! 3134: ServicesCfgDlg->ShowModal();
! 3135: delete ServicesCfgDlg;
! 3136:
! 3137: inside=false;
! 3138: }
! 3139: //---------------------------------------------------------------------------
! 3140:
! 3141: void __fastcall TMainForm::UserTruncateMenuItemClick(TObject *Sender)
! 3142: {
! 3143: int usernumber;
! 3144: int deleted=0;
! 3145: user_t user;
! 3146:
! 3147: Screen->Cursor=crHourGlass;
! 3148: while((user.number=lastuser(&cfg))!=0) {
! 3149: if(getuserdat(&cfg,&user)!=0)
! 3150: break;
! 3151: if(!(user.misc&DELETED))
! 3152: break;
! 3153: if(!del_lastuser(&cfg))
! 3154: break;
! 3155: deleted++;
! 3156: }
! 3157: Screen->Cursor=crDefault;
! 3158: char str[128];
! 3159: sprintf(str,"%u Deleted User Records Removed",deleted);
! 3160: Application->MessageBox(str,"Users Truncated",MB_OK);
! 3161: }
! 3162:
! 3163: BOOL RecycleService(SC_HANDLE svc, SERVICE_STATUS* status)
! 3164: {
! 3165: if(svc==NULL || controlService==NULL)
! 3166: return(FALSE);
! 3167:
! 3168: return controlService(svc, SERVICE_CONTROL_RECYCLE, status);
! 3169: }
! 3170:
! 3171: //---------------------------------------------------------------------------
! 3172: void __fastcall TMainForm::MailRecycleExecute(TObject *Sender)
! 3173: {
! 3174: if(!RecycleService(mail_svc,&mail_svc_status)) {
! 3175: mail_startup.recycle_now=true;
! 3176: MailRecycle->Enabled=false;
! 3177: }
! 3178: }
! 3179: //---------------------------------------------------------------------------
! 3180: void __fastcall TMainForm::FtpRecycleExecute(TObject *Sender)
! 3181: {
! 3182: if(!RecycleService(ftp_svc,&ftp_svc_status)) {
! 3183: ftp_startup.recycle_now=true;
! 3184: FtpRecycle->Enabled=false;
! 3185: }
! 3186: }
! 3187: //---------------------------------------------------------------------------
! 3188: void __fastcall TMainForm::WebRecycleExecute(TObject *Sender)
! 3189: {
! 3190: if(!RecycleService(web_svc,&web_svc_status)) {
! 3191: web_startup.recycle_now=true;
! 3192: WebRecycle->Enabled=false;
! 3193: }
! 3194: }
! 3195: //---------------------------------------------------------------------------
! 3196: void __fastcall TMainForm::ServicesRecycleExecute(TObject *Sender)
! 3197: {
! 3198: if(!RecycleService(services_svc,&services_svc_status)) {
! 3199: services_startup.recycle_now=true;
! 3200: ServicesRecycle->Enabled=false;
! 3201: }
! 3202: }
! 3203: //---------------------------------------------------------------------------
! 3204:
! 3205: void __fastcall TMainForm::TelnetRecycleExecute(TObject *Sender)
! 3206: {
! 3207: if(!RecycleService(bbs_svc,&bbs_svc_status)) {
! 3208: bbs_startup.recycle_now=true;
! 3209: TelnetRecycle->Enabled=false;
! 3210: }
! 3211: }
! 3212: //---------------------------------------------------------------------------
! 3213:
! 3214: void __fastcall TMainForm::FileEditTextFilesClick(TObject *Sender)
! 3215: {
! 3216: TOpenDialog* dlg=new TOpenDialog((TComponent*)Sender);
! 3217:
! 3218: dlg->Options << ofNoChangeDir;
! 3219: dlg->Filter = "Text files (*.txt)|*.TXT"
! 3220: "|All files|*.*";
! 3221: dlg->InitialDir=cfg.text_dir;
! 3222: if(dlg->Execute()==true)
! 3223: EditFile(dlg->FileName.c_str());
! 3224: delete dlg;
! 3225: }
! 3226: //---------------------------------------------------------------------------
! 3227:
! 3228: void __fastcall TMainForm::BBSEditBajaMenuItemClick(TObject *Sender)
! 3229: {
! 3230: TOpenDialog* dlg=new TOpenDialog((TComponent*)Sender);
! 3231:
! 3232: dlg->Options << ofNoChangeDir;
! 3233: dlg->Filter = "Baja Source Code (*.src)|*.SRC";
! 3234: dlg->InitialDir=cfg.exec_dir;
! 3235: if(dlg->Execute()==true) {
! 3236: Application->CreateForm(__classid(TTextFileEditForm), &TextFileEditForm);
! 3237: TextFileEditForm->Filename=AnsiString(dlg->FileName);
! 3238: TextFileEditForm->Caption="Edit";
! 3239: if(TextFileEditForm->ShowModal()==mrOk) {
! 3240: /* Compile Baja Source File (requires Baja v2.33+) */
! 3241: char cmdline[512];
! 3242: sprintf(cmdline,"%sbaja -p %s",cfg.exec_dir,dlg->FileName);
! 3243: WinExec(cmdline,SW_SHOW);
! 3244: }
! 3245: delete TextFileEditForm;
! 3246: }
! 3247: delete dlg;
! 3248: }
! 3249: //---------------------------------------------------------------------------
! 3250:
! 3251: void __fastcall TMainForm::FileEditJavaScriptClick(TObject *Sender)
! 3252: {
! 3253: TOpenDialog* dlg=new TOpenDialog((TComponent*)Sender);
! 3254:
! 3255: dlg->Options << ofNoChangeDir;
! 3256: dlg->Filter = "JavaScript Files (*.js)|*.JS";
! 3257: dlg->InitialDir=cfg.exec_dir;
! 3258: if(dlg->Execute()==true)
! 3259: EditFile(dlg->FileName.c_str());
! 3260: delete dlg;
! 3261: }
! 3262: //---------------------------------------------------------------------------
! 3263:
! 3264: void __fastcall TMainForm::FileEditConfigFilesClick(TObject *Sender)
! 3265: {
! 3266: TOpenDialog* dlg=new TOpenDialog((TComponent*)Sender);
! 3267:
! 3268: dlg->Options << ofNoChangeDir;
! 3269: dlg->Filter = "Configuration Files (*.cfg; *.ini; *.conf)|*.cfg;*.ini;*.conf";
! 3270: dlg->InitialDir=cfg.ctrl_dir;
! 3271: if(dlg->Execute()==true)
! 3272: EditFile(dlg->FileName.c_str());
! 3273: delete dlg;
! 3274: }
! 3275:
! 3276: void __fastcall TMainForm::BBSEditFileClick(TObject *Sender)
! 3277: {
! 3278: TOpenDialog* dlg=new TOpenDialog((TComponent*)Sender);
! 3279:
! 3280: dlg->Options << ofNoChangeDir;
! 3281: dlg->Filter = "ANSI/Ctrl-A files (*.asc; *.msg; *.ans)|*.ASC;*.MSG;*.ANS"
! 3282: "|All files|*.*";
! 3283: dlg->InitialDir=cfg.text_dir;
! 3284: if(dlg->Execute()==true) {
! 3285: Application->CreateForm(__classid(TTextFileEditForm), &TextFileEditForm);
! 3286: TextFileEditForm->Filename=AnsiString(dlg->FileName);
! 3287: TextFileEditForm->Caption="Edit";
! 3288: if(TextFileEditForm->ShowModal()==mrOk) {
! 3289: Application->CreateForm(__classid(TPreviewForm), &PreviewForm);
! 3290: PreviewForm->Filename=AnsiString(dlg->FileName);
! 3291: PreviewForm->ShowModal();
! 3292: delete PreviewForm;
! 3293: }
! 3294: delete TextFileEditForm;
! 3295: }
! 3296: delete dlg;
! 3297: }
! 3298: //---------------------------------------------------------------------------
! 3299: bool GetServerLogLine(HANDLE& log, const char* name, char* line, size_t len)
! 3300: {
! 3301: char fname[256];
! 3302:
! 3303: if(log==INVALID_HANDLE_VALUE) {
! 3304: sprintf(fname,"\\\\.\\mailslot\\%s.log",name);
! 3305: log = CreateMailslot(
! 3306: fname, // pointer to string for mailslot name
! 3307: 0, // maximum message size
! 3308: 0, // milliseconds before read time-out
! 3309: NULL); // pointer to security structure
! 3310: if(log==INVALID_HANDLE_VALUE)
! 3311: return(false);
! 3312: }
! 3313: DWORD msgs=0;
! 3314: if(!GetMailslotInfo(
! 3315: log, // mailslot handle
! 3316: NULL, // address of maximum message size
! 3317: NULL, // address of size of next message
! 3318: &msgs, // address of number of messages
! 3319: NULL // address of read time-out
! 3320: ) || !msgs)
! 3321: return(false);
! 3322:
! 3323: DWORD rd=0;
! 3324: if(!ReadFile(
! 3325: log, // handle of file to read
! 3326: line, // pointer to buffer that receives data
! 3327: len-1, // number of bytes to read
! 3328: &rd, // pointer to number of bytes read
! 3329: NULL // pointer to structure for data
! 3330: ) || !rd)
! 3331: return(false);
! 3332:
! 3333: line[rd]=0; /* 0-terminate */
! 3334:
! 3335: return(true);
! 3336: }
! 3337: //---------------------------------------------------------------------------
! 3338:
! 3339: void __fastcall TMainForm::LogTimerTick(TObject *Sender)
! 3340: {
! 3341: char line[1024];
! 3342:
! 3343: while(GetServerLogLine(bbs_log,NTSVC_NAME_BBS,line,sizeof(line)))
! 3344: bbs_lputs(NULL,LOG_INFO,line);
! 3345:
! 3346: while(GetServerLogLine(event_log,NTSVC_NAME_EVENT,line,sizeof(line)))
! 3347: event_lputs(LOG_INFO,line);
! 3348:
! 3349: while(GetServerLogLine(ftp_log,NTSVC_NAME_FTP,line,sizeof(line)))
! 3350: ftp_lputs(NULL,LOG_INFO,line);
! 3351:
! 3352: while(GetServerLogLine(web_log,NTSVC_NAME_WEB,line,sizeof(line)))
! 3353: web_lputs(NULL,LOG_INFO,line);
! 3354:
! 3355: while(GetServerLogLine(mail_log,NTSVC_NAME_MAIL,line,sizeof(line)))
! 3356: mail_lputs(NULL,LOG_INFO,line);
! 3357:
! 3358: while(GetServerLogLine(services_log,NTSVC_NAME_SERVICES,line,sizeof(line)))
! 3359: service_lputs(NULL,LOG_INFO,line);
! 3360:
! 3361: }
! 3362:
! 3363: //---------------------------------------------------------------------------
! 3364: void CheckServiceStatus(
! 3365: SC_HANDLE svc
! 3366: ,SERVICE_STATUS* status
! 3367: ,QUERY_SERVICE_CONFIG* &config
! 3368: ,DWORD &config_size
! 3369: ,TStaticText* text
! 3370: ,TAction* start
! 3371: ,TAction* stop
! 3372: ,TAction* recycle
! 3373: ,TProgressBar* bar
! 3374: )
! 3375: {
! 3376: if(svc==NULL)
! 3377: return;
! 3378:
! 3379: DWORD ret;
! 3380:
! 3381: if(!queryServiceConfig(svc,config,config_size,&ret)) {
! 3382: if(GetLastError()==ERROR_INSUFFICIENT_BUFFER) {
! 3383: config_size=ret;
! 3384: if(config!=NULL)
! 3385: free(config);
! 3386: config = (QUERY_SERVICE_CONFIG*)malloc(config_size);
! 3387: }
! 3388: return;
! 3389: }
! 3390:
! 3391: if(config->dwStartType==SERVICE_DISABLED)
! 3392: return;
! 3393:
! 3394: if(!queryServiceStatus(svc,status)) {
! 3395: text->Caption="QueryServiceStatus Error "; // + GetLastError());
! 3396: return;
! 3397: }
! 3398:
! 3399: bool running=false;
! 3400:
! 3401: switch(status->dwCurrentState) {
! 3402: case SERVICE_STOPPED:
! 3403: text->Caption="Stopped NT Service";
! 3404: break;
! 3405: case SERVICE_STOP_PENDING:
! 3406: text->Caption="Stopping NT Service";
! 3407: break;
! 3408: case SERVICE_RUNNING:
! 3409: text->Caption="Running NT Service";
! 3410: running=true;
! 3411: break;
! 3412: case SERVICE_START_PENDING:
! 3413: text->Caption="Starting NT Service";
! 3414: running=true;
! 3415: break;
! 3416: default:
! 3417: text->Caption="!UNKNOWN: " + status->dwCurrentState;
! 3418: break;
! 3419: }
! 3420:
! 3421: start->Enabled=!running;
! 3422: stop->Enabled=running;
! 3423: recycle->Enabled=running;
! 3424: }
! 3425: //---------------------------------------------------------------------------
! 3426:
! 3427: void __fastcall TMainForm::ServiceStatusTimerTick(TObject *Sender)
! 3428: {
! 3429: if(queryServiceStatus==NULL || queryServiceConfig==NULL
! 3430: || (bbs_svc==NULL
! 3431: && ftp_svc==NULL
! 3432: && web_svc==NULL
! 3433: && mail_svc==NULL
! 3434: && services_svc==NULL)) {
! 3435: ServiceStatusTimer->Enabled=false;
! 3436: return;
! 3437: }
! 3438:
! 3439: CheckServiceStatus(
! 3440: bbs_svc
! 3441: ,&bbs_svc_status
! 3442: ,bbs_svc_config
! 3443: ,bbs_svc_config_size
! 3444: ,TelnetForm->Status
! 3445: ,TelnetStart
! 3446: ,TelnetStop
! 3447: ,TelnetRecycle
! 3448: ,TelnetForm->ProgressBar
! 3449: );
! 3450: CheckServiceStatus(
! 3451: ftp_svc
! 3452: ,&ftp_svc_status
! 3453: ,ftp_svc_config
! 3454: ,ftp_svc_config_size
! 3455: ,FtpForm->Status
! 3456: ,FtpStart
! 3457: ,FtpStop
! 3458: ,FtpRecycle
! 3459: ,FtpForm->ProgressBar
! 3460: );
! 3461: CheckServiceStatus(
! 3462: web_svc
! 3463: ,&web_svc_status
! 3464: ,web_svc_config
! 3465: ,web_svc_config_size
! 3466: ,WebForm->Status
! 3467: ,WebStart
! 3468: ,WebStop
! 3469: ,WebRecycle
! 3470: ,WebForm->ProgressBar
! 3471: );
! 3472: CheckServiceStatus(
! 3473: mail_svc
! 3474: ,&mail_svc_status
! 3475: ,mail_svc_config
! 3476: ,mail_svc_config_size
! 3477: ,MailForm->Status
! 3478: ,MailStart
! 3479: ,MailStop
! 3480: ,MailRecycle
! 3481: ,MailForm->ProgressBar
! 3482: );
! 3483: CheckServiceStatus(
! 3484: services_svc
! 3485: ,&services_svc_status
! 3486: ,services_svc_config
! 3487: ,services_svc_config_size
! 3488: ,ServicesForm->Status
! 3489: ,ServicesStart
! 3490: ,ServicesStop
! 3491: ,ServicesRecycle
! 3492: ,NULL
! 3493: );
! 3494:
! 3495: }
! 3496: //---------------------------------------------------------------------------
! 3497: void __fastcall TMainForm::EditFile(AnsiString filename, AnsiString Caption)
! 3498: {
! 3499: if(!UseFileAssociations
! 3500: || (int)ShellExecute(Handle, "edit", filename.c_str(), NULL,NULL,SW_SHOWDEFAULT)<=32) {
! 3501: Application->CreateForm(__classid(TTextFileEditForm), &TextFileEditForm);
! 3502: TextFileEditForm->Filename=filename;
! 3503: TextFileEditForm->Caption=Caption;
! 3504: TextFileEditForm->ShowModal();
! 3505: delete TextFileEditForm;
! 3506: }
! 3507: }
! 3508: //---------------------------------------------------------------------------
! 3509: void __fastcall TMainForm::ViewFile(AnsiString filename, AnsiString Caption)
! 3510: {
! 3511: if(!UseFileAssociations
! 3512: || (int)ShellExecute(Handle, "open", filename.c_str(), NULL,NULL,SW_SHOWDEFAULT)<=32) {
! 3513: Application->CreateForm(__classid(TTextFileEditForm), &TextFileEditForm);
! 3514: TextFileEditForm->Filename=filename;
! 3515: TextFileEditForm->Caption=Caption;
! 3516: TextFileEditForm->Memo->ReadOnly=true;
! 3517: TextFileEditForm->ShowModal();
! 3518: delete TextFileEditForm;
! 3519: }
! 3520: }
! 3521: //---------------------------------------------------------------------------
! 3522:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.