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

Email服务器

开发平台:

Delphi

  1. unit ManageMailLists;
  2. (******************************************************************************)
  3. (*                                                                            *)
  4. (* Hermes Manage Mail Lists 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 17, 2000 by Alexander J. Fanti.  See License.txt           *)
  9. (*                                                                            *)
  10. (* Used by: Main                                                              *)
  11. (* Uses: DataU1, UtilU1, AddEditMailList                                      *)
  12. (*                                                                            *)
  13. (* Description: This Modal dialog window allows the user to Add, Edit, Delete *)
  14. (*              and Rename mailing lists                                      *)
  15. (*                                                                            *)
  16. (* Revisions: 1/21/2000  AJF  Commented                                       *)
  17. (*                                                                            *)
  18. (******************************************************************************)
  19. interface
  20. uses
  21.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  22.   StdCtrls, Buttons, Menus, FileCtrl;
  23. type
  24.   TfrmManageMailLists = class(TForm)
  25.     lstList: TListBox;
  26.     btnAdd: TBitBtn;
  27.     btnEdit: TBitBtn;
  28.     btnDelete: TBitBtn;
  29.     btnRename: TBitBtn;
  30.     btnImport: TBitBtn;
  31.     btnClose: TBitBtn;
  32.     btnExport: TBitBtn;
  33.     popupMenu: TPopupMenu;
  34.     puAdd: TMenuItem;
  35.     puEdit: TMenuItem;
  36.     puDelete: TMenuItem;
  37.     puRename: TMenuItem;
  38.     N1: TMenuItem;
  39.     puImport: TMenuItem;
  40.     puExport: TMenuItem;
  41.     procedure FormShow(Sender: TObject);
  42.     procedure lstListClick(Sender: TObject);
  43.     procedure popupMenuPopup(Sender: TObject);
  44.     procedure btnAddClick(Sender: TObject);
  45.     procedure btnEditClick(Sender: TObject);
  46.     procedure btnDeleteClick(Sender: TObject);
  47.     procedure btnRenameClick(Sender: TObject);
  48.     procedure btnImportClick(Sender: TObject);
  49.     procedure btnExportClick(Sender: TObject);
  50.     procedure btnCloseClick(Sender: TObject);
  51.     procedure lstListDblClick(Sender: TObject);
  52.   private
  53.     { Private declarations }
  54.     procedure Add;      // Add Mail List
  55.     procedure Edit;     // Edit Mail List
  56.     procedure Delete;   // Delete Mail List
  57.     procedure Rename;   // Rename Mail List
  58.     procedure Import;   // Import Mail List
  59.     procedure DoExport; // Export Mail List
  60.     procedure EnableUI; // Enable buttons and popum menus based on selections
  61.   public
  62.     { Public declarations }
  63.   end;
  64. var
  65.   frmManageMailLists: TfrmManageMailLists;
  66. implementation
  67. uses DataU1, UtilU1, AddEditMailList;
  68. {$R *.DFM}
  69. procedure TfrmManageMailLists.FormShow(Sender: TObject);
  70. begin
  71.   // Populate list with mailing lists
  72.   INI.List_GetList(lstList.Items);
  73.   // Enable buttons based on list selection
  74.   EnableUI;
  75. end;
  76. procedure TfrmManageMailLists.Add;
  77. begin
  78.   // if they added a mail list through the AddEditMailList Dialog...
  79.   // then refresh the list of mail lists
  80.   if frmAddEditMailList.Add then INI.List_GetList(lstList.Items);
  81. end;
  82. procedure TfrmManageMailLists.Edit;
  83. begin
  84.   // if there's a selected mail list, then let them edit it
  85.   // through the AddEditMailList Dialog...
  86.   // then refresh the list of mail lists
  87.   if lstList.ItemIndex > -1 then
  88.     if frmAddEditMailList.Edit(lstList.Items[lstList.ItemIndex]) then
  89.       INI.List_GetList(lstList.Items);
  90. end;
  91. procedure TfrmManageMailLists.Delete;
  92. var
  93.   x : Integer;
  94. begin
  95.   // Ask if they really want to delete, cause it can't be un-done
  96.   x := MessageDlg('Deleting list(s) cannot be undone.  Proceed?',
  97.                   mtConfirmation, [mbYes, mbNo], 0);
  98.   if x = mrYes then begin
  99.     // they really want to do it... for each selected mail list...
  100.     // call the delete function and refresh the list of mail lists
  101.     for x := 0 to lstList.Items.Count -1 do
  102.       if lstList.Selected[x] then INI.List_Delete(lstList.Items[x]);
  103.     INI.List_GetList(lstList.Items);
  104.   end;
  105. end;
  106. procedure TfrmManageMailLists.Rename;
  107. var
  108.   OldListID, NewListID : String;
  109. begin
  110.   // if there's a mail list selected...
  111.   if lstList.ItemIndex > -1 then
  112.     OldListID := lstList.Items[lstList.ItemIndex];
  113.   NewListID := InputBox('Rename List', 'Enter New List Name', OldListID);
  114.   if LowerCase(NewListID) <> LowerCase(OldListID) then begin
  115.     // and the new mail list isn't the same as the old one...
  116.     // then rename the list and refresh the display
  117.     if not INI.List_Rename(OldListID, NewListID) then
  118.       ShowMessage('Error: Cound not re-name.' + #13 + #10 +
  119.                   'List must have a unique ID.')
  120.     else
  121.       INI.List_GetList(lstList.Items);
  122.   end;
  123. end;
  124. procedure TfrmManageMailLists.Import;
  125. begin // Import Mail Lists
  126.   ShowMessage('Feature not implemented yet...');
  127.   // DEBUG
  128.   // How should I import a mail list ?
  129. end;
  130. procedure TfrmManageMailLists.DoExport;
  131. begin // Export Mail lists
  132.   ShowMessage('Feature not implemented yet...');
  133.   // DEBUG
  134.   // How should I export a mail list ?
  135. end;
  136. procedure TfrmManageMailLists.EnableUI;
  137. begin
  138.   // Enable buttons and menus based on list selection
  139.   btnEdit.Enabled   := lstList.SelCount = 1;
  140.   btnDelete.Enabled := lstList.SelCount > 0;
  141.   btnRename.Enabled := lstList.SelCount = 1;
  142.   btnExport.Enabled := lstList.Items.Count > 0;
  143.   puEdit.Enabled   := lstList.SelCount = 1;
  144.   puDelete.Enabled := lstList.SelCount > 0;
  145.   puRename.Enabled := lstList.SelCount = 1;
  146.   puExport.Enabled := lstList.Items.Count > 0;
  147. end;
  148. // Hook Buttond and menus up with functions for performing actions
  149. procedure TfrmManageMailLists.btnAddClick(Sender: TObject);
  150. begin  Add;                                    end;
  151. procedure TfrmManageMailLists.btnEditClick(Sender: TObject);
  152. begin  Edit;                                   end;
  153. procedure TfrmManageMailLists.btnDeleteClick(Sender: TObject);
  154. begin  Delete;                                 end;
  155. procedure TfrmManageMailLists.btnRenameClick(Sender: TObject);
  156. begin  Rename;                                 end;
  157. procedure TfrmManageMailLists.btnImportClick(Sender: TObject);
  158. begin  Import;                                 end;
  159. procedure TfrmManageMailLists.btnExportClick(Sender: TObject);
  160. begin  DoExport;                               end;
  161. procedure TfrmManageMailLists.lstListClick(Sender: TObject);
  162. begin  EnableUI;                               end;
  163. procedure TfrmManageMailLists.lstListDblClick(Sender: TObject);
  164. begin  Edit;                                   end;
  165. procedure TfrmManageMailLists.popupMenuPopup(Sender: TObject);
  166. begin  EnableUI;                               end;
  167. procedure TfrmManageMailLists.btnCloseClick(Sender: TObject);
  168. begin  Close;                                  end;
  169. end.