Settings_General.pas
上传用户:dh8233980
上传日期:2014-10-16
资源大小:1015k
文件大小:8k
- unit Settings_General;
- (******************************************************************************)
- (* *)
- (* Hermes General Settings Dialog Box *)
- (* Part of Hermes SMTP/POP3 Server. *)
- (* Copyright(C) 2000 by Alexander J. Fanti, All Rights Reserver Worldwide. *)
- (* *)
- (* Created January 19, 2000 by Alexander J. Fanti. See License.txt *)
- (* *)
- (* Used by: Main *)
- (* Uses: DataU1, UtilU1 *)
- (* *)
- (* Description: This Modal dialog window allows the user to change general *)
- (* server settings *)
- (* *)
- (* Revisions: 1/21/2000 AJF Commented *)
- (* 2/13/2000 AJF Added Startup options *)
- (* 3/11/2000 AJF Added DNS Timeout and Process Queue on Startup *)
- (* *)
- (******************************************************************************)
- interface
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- FileCtrl, ShellAPI, ShlObj, ComObj, StdCtrls, Buttons, Spin, ComCtrls,
- Registry;
- type
- TfrmSettings_General = class(TForm)
- btnOK: TBitBtn;
- btnCancel: TBitBtn;
- SaveDialog1: TSaveDialog;
- PageControl1: TPageControl;
- tsGeneral: TTabSheet;
- tsStartup: TTabSheet;
- tsLog: TTabSheet;
- Label1: TLabel;
- txtServerName: TEdit;
- Label2: TLabel;
- txtMailboxPath: TEdit;
- btnSelectMailbox: TButton;
- btnSelectQueue: TButton;
- txtQueuePath: TEdit;
- Label3: TLabel;
- Label4: TLabel;
- Label6: TLabel;
- txtLogFile: TEdit;
- btnSelectLogFile: TButton;
- lblLogLevel: TLabel;
- lstLogLevel: TComboBox;
- cbxStartMinimized: TCheckBox;
- cbxAutoStart_SmtpServer: TCheckBox;
- cbxAutoStart_SmtpAgent: TCheckBox;
- cbxAutoStart_Pop3Server: TCheckBox;
- speDNSTimeout: TSpinEdit;
- Label5: TLabel;
- cbxStartProcessQueue: TCheckBox;
- cbxSpyMessageContent: TCheckBox;
- lstDNSServerAddress: TComboBox;
- tsBanner: TTabSheet;
- optBanner_NVS: TRadioButton;
- optBanner_NS: TRadioButton;
- optBanner_S: TRadioButton;
- procedure FormShow(Sender: TObject);
- procedure btnSelectMailboxClick(Sender: TObject);
- procedure btnOKClick(Sender: TObject);
- procedure btnSelectQueueClick(Sender: TObject);
- procedure btnSelectLogFileClick(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- frmSettings_General: TfrmSettings_General;
- implementation
- uses DataU1, UtilU1;
- {$R *.DFM}
- procedure TfrmSettings_General.FormCreate(Sender: TObject);
- var
- x : Longint;
- DNSList : TStringList;
- begin
- DNSList := TStringList.Create;
- FetchDNSList(DNSList);
- lstDNSServerAddress.Items.Clear;
- for x := 0 to DNSList.Count -1 do lstDNSServerAddress.Items.Add(DNSList[x]);
- DNSList.Free;
- end;
- procedure TfrmSettings_General.FormShow(Sender: TObject);
- begin
- PageControl1.ActivePage := tsGeneral;
- // Display General settings in dialog
- txtServerName.Text := INI.ServerName;
- cbxStartMinimized.Checked := INI.StartMinimized;
- cbxAutoStart_SmtpServer.Checked := INI.AutoStart_SmtpServer;
- cbxAutoStart_SmtpAgent.Checked := INI.AutoStart_SmtpAgent;
- cbxAutoStart_Pop3Server.Checked := INI.AutoStart_Pop3Server;
- cbxStartProcessQueue.Checked := INI.ProcessQueueOnStartup;
- txtMailboxPath.Text := INI.MailboxPath;
- txtQueuePath.Text := INI.MailQueuePath;
- lstDNSServerAddress.Text := INI.DNSServerAddress;
- speDNSTimeout.Value := INI.DNSServerTimeout;
- txtLogFile.Text := INI.LogFile;
- lstLogLevel.ItemIndex := INI.LogLevel;
- cbxSpyMessageContent.Checked := INI.LogSpyMessageContent;
- case INI.Banner_Level of
- bannerlevel_NameVersionService : optBanner_NVS.Checked := True;
- bannerlevel_NameService : optBanner_NS.Checked := True;
- bannerlevel_Service : optBanner_S.Checked := True;
- else optBanner_NVS.Checked := True;
- end;
- end;
- procedure TfrmSettings_General.btnOKClick(Sender: TObject);
- begin
- // Read General settings from dialog
- INI.ServerName := Trim(txtServerName.Text);
- INI.StartMinimized := cbxStartMinimized.Checked;
- INI.AutoStart_SmtpServer := cbxAutoStart_SmtpServer.Checked;
- INI.AutoStart_SmtpAgent := cbxAutoStart_SmtpAgent.Checked;
- INI.AutoStart_Pop3Server := cbxAutoStart_Pop3Server.Checked;
- INI.ProcessQueueOnStartup := cbxStartProcessQueue.Checked;
- INI.MailboxPath := Trim(txtMailboxPath.Text);
- INI.MailListPath := Trim(txtMailboxPath.Text);
- INI.MailQueuePath := Trim(txtQueuePath.Text);
- INI.DNSServerAddress := '';
- if IsDomainDottedIP(Trim(lstDNSServerAddress.Text)) then
- INI.DNSServerAddress := Trim(lstDNSServerAddress.Text)
- else ShowMessage('DNS Server Address Invalid');
- INI.DNSServerTimeout := speDNSTimeout.Value;
- INI.LogFile := Trim(txtLogFile.Text);
- INI.LogLevel := lstLogLevel.ItemIndex;
- INI.LogSpyMessageContent := cbxSpyMessageContent.Checked;
- INI.Banner_Level := bannerlevel_NameVersionService;
- if optBanner_NVS.Checked then INI.Banner_Level := bannerlevel_NameVersionService;
- if optBanner_NS.Checked then INI.Banner_Level := bannerlevel_NameService;
- if optBanner_S.Checked then INI.Banner_Level := bannerlevel_Service;
- end;
- procedure TfrmSettings_General.btnSelectMailboxClick(Sender: TObject);
- var
- TitleName : string;
- lpItemID : PItemIDList;
- BrowseInfo : TBrowseInfo;
- DisplayName : array[0..MAX_PATH] of char;
- TempPath : array[0..MAX_PATH] of char;
- begin
- // Select a folder for MailBox
- FillChar(BrowseInfo, sizeof(TBrowseInfo), #0);
- BrowseInfo.hwndOwner := Self.Handle;
- BrowseInfo.pidlRoot := nil; // Desktop
- BrowseInfo.pszDisplayName := @DisplayName;
- TitleName := 'Please specify a directory';
- BrowseInfo.lpszTitle := PChar(TitleName);
- BrowseInfo.ulFlags := BIF_RETURNONLYFSDIRS;
- lpItemID := SHBrowseForFolder(BrowseInfo);
- if lpItemId <> nil then begin
- SHGetPathFromIDList(lpItemID, TempPath);
- txtMailboxPath.Text := TempPath;
- GlobalFreePtr(lpItemID);
- end;
- end;
- procedure TfrmSettings_General.btnSelectQueueClick(Sender: TObject);
- var
- TitleName : string;
- lpItemID : PItemIDList;
- BrowseInfo : TBrowseInfo;
- DisplayName : array[0..MAX_PATH] of char;
- TempPath : array[0..MAX_PATH] of char;
- begin
- // Select a folder for Queue Path
- FillChar(BrowseInfo, sizeof(TBrowseInfo), #0);
- BrowseInfo.hwndOwner := Self.Handle;
- BrowseInfo.pidlRoot := nil; // Desktop
- BrowseInfo.pszDisplayName := @DisplayName;
- TitleName := 'Please specify a directory';
- BrowseInfo.lpszTitle := PChar(TitleName);
- BrowseInfo.ulFlags := BIF_RETURNONLYFSDIRS;
- lpItemID := SHBrowseForFolder(BrowseInfo);
- if lpItemId <> nil then begin
- SHGetPathFromIDList(lpItemID, TempPath);
- txtQueuePath.Text := TempPath;
- GlobalFreePtr(lpItemID);
- end;
- end;
- procedure TfrmSettings_General.btnSelectLogFileClick(Sender: TObject);
- begin
- //Choose a Log File
- if SaveDialog1.Execute then txtLogFile.Text := SaveDialog1.Filename;
- end;
- end.