Settings_General.pas
上传用户:dh8233980
上传日期:2014-10-16
资源大小:1015k
文件大小:8k
源码类别:

Email服务器

开发平台:

Delphi

  1. unit Settings_General;
  2. (******************************************************************************)
  3. (*                                                                            *)
  4. (* Hermes General Settings Dialog Box                                         *)
  5. (* Part of Hermes SMTP/POP3 Server.                                           *)
  6. (* Copyright(C) 2000 by Alexander J. Fanti, All Rights Reserver Worldwide.    *)
  7. (*                                                                            *)
  8. (* Created January 19, 2000 by Alexander J. Fanti.  See License.txt           *)
  9. (*                                                                            *)
  10. (* Used by: Main                                                              *)
  11. (* Uses: DataU1, UtilU1                                                       *)
  12. (*                                                                            *)
  13. (* Description: This Modal dialog window allows the user to change general    *)
  14. (*              server settings                                               *)
  15. (*                                                                            *)
  16. (* Revisions: 1/21/2000  AJF  Commented                                       *)
  17. (*            2/13/2000  AJF  Added Startup options                           *)
  18. (*            3/11/2000  AJF  Added DNS Timeout and Process Queue on Startup  *)
  19. (*                                                                            *)
  20. (******************************************************************************)
  21. interface
  22. uses
  23.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  24.   FileCtrl, ShellAPI, ShlObj, ComObj, StdCtrls, Buttons, Spin, ComCtrls,
  25.   Registry;
  26. type
  27.   TfrmSettings_General = class(TForm)
  28.     btnOK: TBitBtn;
  29.     btnCancel: TBitBtn;
  30.     SaveDialog1: TSaveDialog;
  31.     PageControl1: TPageControl;
  32.     tsGeneral: TTabSheet;
  33.     tsStartup: TTabSheet;
  34.     tsLog: TTabSheet;
  35.     Label1: TLabel;
  36.     txtServerName: TEdit;
  37.     Label2: TLabel;
  38.     txtMailboxPath: TEdit;
  39.     btnSelectMailbox: TButton;
  40.     btnSelectQueue: TButton;
  41.     txtQueuePath: TEdit;
  42.     Label3: TLabel;
  43.     Label4: TLabel;
  44.     Label6: TLabel;
  45.     txtLogFile: TEdit;
  46.     btnSelectLogFile: TButton;
  47.     lblLogLevel: TLabel;
  48.     lstLogLevel: TComboBox;
  49.     cbxStartMinimized: TCheckBox;
  50.     cbxAutoStart_SmtpServer: TCheckBox;
  51.     cbxAutoStart_SmtpAgent: TCheckBox;
  52.     cbxAutoStart_Pop3Server: TCheckBox;
  53.     speDNSTimeout: TSpinEdit;
  54.     Label5: TLabel;
  55.     cbxStartProcessQueue: TCheckBox;
  56.     cbxSpyMessageContent: TCheckBox;
  57.     lstDNSServerAddress: TComboBox;
  58.     tsBanner: TTabSheet;
  59.     optBanner_NVS: TRadioButton;
  60.     optBanner_NS: TRadioButton;
  61.     optBanner_S: TRadioButton;
  62.     procedure FormShow(Sender: TObject);
  63.     procedure btnSelectMailboxClick(Sender: TObject);
  64.     procedure btnOKClick(Sender: TObject);
  65.     procedure btnSelectQueueClick(Sender: TObject);
  66.     procedure btnSelectLogFileClick(Sender: TObject);
  67.     procedure FormCreate(Sender: TObject);
  68.   private
  69.     { Private declarations }
  70.   public
  71.     { Public declarations }
  72.   end;
  73. var
  74.   frmSettings_General: TfrmSettings_General;
  75. implementation
  76. uses DataU1, UtilU1;
  77. {$R *.DFM}
  78. procedure TfrmSettings_General.FormCreate(Sender: TObject);
  79. var
  80.   x : Longint;
  81.   DNSList : TStringList;
  82. begin
  83.   DNSList := TStringList.Create;
  84.   FetchDNSList(DNSList);
  85.   lstDNSServerAddress.Items.Clear;
  86.   for x := 0 to DNSList.Count -1 do lstDNSServerAddress.Items.Add(DNSList[x]);
  87.   DNSList.Free;
  88. end;
  89. procedure TfrmSettings_General.FormShow(Sender: TObject);
  90. begin
  91.   PageControl1.ActivePage := tsGeneral;
  92.   // Display General settings in dialog
  93.   txtServerName.Text := INI.ServerName;
  94.   cbxStartMinimized.Checked := INI.StartMinimized;
  95.   cbxAutoStart_SmtpServer.Checked := INI.AutoStart_SmtpServer;
  96.   cbxAutoStart_SmtpAgent.Checked := INI.AutoStart_SmtpAgent;
  97.   cbxAutoStart_Pop3Server.Checked := INI.AutoStart_Pop3Server;
  98.   cbxStartProcessQueue.Checked := INI.ProcessQueueOnStartup;
  99.   txtMailboxPath.Text := INI.MailboxPath;
  100.   txtQueuePath.Text := INI.MailQueuePath;
  101.   lstDNSServerAddress.Text := INI.DNSServerAddress;
  102.   speDNSTimeout.Value := INI.DNSServerTimeout;
  103.   txtLogFile.Text := INI.LogFile;
  104.   lstLogLevel.ItemIndex := INI.LogLevel;
  105.   cbxSpyMessageContent.Checked := INI.LogSpyMessageContent;
  106.   case INI.Banner_Level of
  107.     bannerlevel_NameVersionService : optBanner_NVS.Checked := True;
  108.     bannerlevel_NameService        : optBanner_NS.Checked := True;
  109.     bannerlevel_Service            : optBanner_S.Checked := True;
  110.     else optBanner_NVS.Checked := True;
  111.   end;
  112. end;
  113. procedure TfrmSettings_General.btnOKClick(Sender: TObject);
  114. begin
  115.   // Read General settings from dialog
  116.   INI.ServerName := Trim(txtServerName.Text);
  117.   INI.StartMinimized := cbxStartMinimized.Checked;
  118.   INI.AutoStart_SmtpServer := cbxAutoStart_SmtpServer.Checked;
  119.   INI.AutoStart_SmtpAgent := cbxAutoStart_SmtpAgent.Checked;
  120.   INI.AutoStart_Pop3Server := cbxAutoStart_Pop3Server.Checked;
  121.   INI.ProcessQueueOnStartup := cbxStartProcessQueue.Checked;
  122.   INI.MailboxPath := Trim(txtMailboxPath.Text);
  123.   INI.MailListPath := Trim(txtMailboxPath.Text);
  124.   INI.MailQueuePath := Trim(txtQueuePath.Text);
  125.   INI.DNSServerAddress := '';
  126.   if IsDomainDottedIP(Trim(lstDNSServerAddress.Text)) then
  127.     INI.DNSServerAddress := Trim(lstDNSServerAddress.Text)
  128.     else ShowMessage('DNS Server Address Invalid');
  129.   INI.DNSServerTimeout := speDNSTimeout.Value;
  130.   INI.LogFile := Trim(txtLogFile.Text);
  131.   INI.LogLevel := lstLogLevel.ItemIndex;
  132.   INI.LogSpyMessageContent := cbxSpyMessageContent.Checked;
  133.   INI.Banner_Level := bannerlevel_NameVersionService;
  134.   if optBanner_NVS.Checked then INI.Banner_Level := bannerlevel_NameVersionService;
  135.   if optBanner_NS.Checked then INI.Banner_Level  := bannerlevel_NameService;
  136.   if optBanner_S.Checked then INI.Banner_Level   := bannerlevel_Service;
  137. end;
  138. procedure TfrmSettings_General.btnSelectMailboxClick(Sender: TObject);
  139. var
  140.   TitleName : string;
  141.   lpItemID : PItemIDList;
  142.   BrowseInfo : TBrowseInfo;
  143.   DisplayName : array[0..MAX_PATH] of char;
  144.   TempPath : array[0..MAX_PATH] of char;
  145. begin
  146.   // Select a folder for MailBox
  147.   FillChar(BrowseInfo, sizeof(TBrowseInfo), #0);
  148.   BrowseInfo.hwndOwner := Self.Handle;
  149.   BrowseInfo.pidlRoot := nil;  // Desktop
  150.   BrowseInfo.pszDisplayName := @DisplayName;
  151.   TitleName := 'Please specify a directory';
  152.   BrowseInfo.lpszTitle := PChar(TitleName);
  153.   BrowseInfo.ulFlags := BIF_RETURNONLYFSDIRS;
  154.   lpItemID := SHBrowseForFolder(BrowseInfo);
  155.   if lpItemId <> nil then begin
  156.     SHGetPathFromIDList(lpItemID, TempPath);
  157.     txtMailboxPath.Text := TempPath;
  158.     GlobalFreePtr(lpItemID);
  159.   end;
  160. end;
  161. procedure TfrmSettings_General.btnSelectQueueClick(Sender: TObject);
  162. var
  163.   TitleName : string;
  164.   lpItemID : PItemIDList;
  165.   BrowseInfo : TBrowseInfo;
  166.   DisplayName : array[0..MAX_PATH] of char;
  167.   TempPath : array[0..MAX_PATH] of char;
  168. begin
  169.   // Select a folder for Queue Path
  170.   FillChar(BrowseInfo, sizeof(TBrowseInfo), #0);
  171.   BrowseInfo.hwndOwner := Self.Handle;
  172.   BrowseInfo.pidlRoot := nil;  // Desktop
  173.   BrowseInfo.pszDisplayName := @DisplayName;
  174.   TitleName := 'Please specify a directory';
  175.   BrowseInfo.lpszTitle := PChar(TitleName);
  176.   BrowseInfo.ulFlags := BIF_RETURNONLYFSDIRS;
  177.   lpItemID := SHBrowseForFolder(BrowseInfo);
  178.   if lpItemId <> nil then begin
  179.     SHGetPathFromIDList(lpItemID, TempPath);
  180.     txtQueuePath.Text := TempPath;
  181.     GlobalFreePtr(lpItemID);
  182.   end;
  183. end;
  184. procedure TfrmSettings_General.btnSelectLogFileClick(Sender: TObject);
  185. begin
  186.   //Choose a Log File
  187.   if SaveDialog1.Execute then txtLogFile.Text := SaveDialog1.Filename;
  188. end;
  189. end.