ManageMailLists.pas
上传用户:dh8233980
上传日期:2014-10-16
资源大小:1015k
文件大小:7k
- unit ManageMailLists;
- (******************************************************************************)
- (* *)
- (* Hermes Manage Mail Lists Dialog Box *)
- (* Part of Hermes SMTP/POP3 Server. *)
- (* Copyright(C) 2000 by Alexander J. Fanti, All Rights Reserver Worldwide. *)
- (* *)
- (* Created January 17, 2000 by Alexander J. Fanti. See License.txt *)
- (* *)
- (* Used by: Main *)
- (* Uses: DataU1, UtilU1, AddEditMailList *)
- (* *)
- (* Description: This Modal dialog window allows the user to Add, Edit, Delete *)
- (* and Rename mailing lists *)
- (* *)
- (* Revisions: 1/21/2000 AJF Commented *)
- (* *)
- (******************************************************************************)
- interface
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- StdCtrls, Buttons, Menus, FileCtrl;
- type
- TfrmManageMailLists = class(TForm)
- lstList: TListBox;
- btnAdd: TBitBtn;
- btnEdit: TBitBtn;
- btnDelete: TBitBtn;
- btnRename: TBitBtn;
- btnImport: TBitBtn;
- btnClose: TBitBtn;
- btnExport: TBitBtn;
- popupMenu: TPopupMenu;
- puAdd: TMenuItem;
- puEdit: TMenuItem;
- puDelete: TMenuItem;
- puRename: TMenuItem;
- N1: TMenuItem;
- puImport: TMenuItem;
- puExport: TMenuItem;
- procedure FormShow(Sender: TObject);
- procedure lstListClick(Sender: TObject);
- procedure popupMenuPopup(Sender: TObject);
- procedure btnAddClick(Sender: TObject);
- procedure btnEditClick(Sender: TObject);
- procedure btnDeleteClick(Sender: TObject);
- procedure btnRenameClick(Sender: TObject);
- procedure btnImportClick(Sender: TObject);
- procedure btnExportClick(Sender: TObject);
- procedure btnCloseClick(Sender: TObject);
- procedure lstListDblClick(Sender: TObject);
- private
- { Private declarations }
- procedure Add; // Add Mail List
- procedure Edit; // Edit Mail List
- procedure Delete; // Delete Mail List
- procedure Rename; // Rename Mail List
- procedure Import; // Import Mail List
- procedure DoExport; // Export Mail List
- procedure EnableUI; // Enable buttons and popum menus based on selections
- public
- { Public declarations }
- end;
- var
- frmManageMailLists: TfrmManageMailLists;
- implementation
- uses DataU1, UtilU1, AddEditMailList;
- {$R *.DFM}
- procedure TfrmManageMailLists.FormShow(Sender: TObject);
- begin
- // Populate list with mailing lists
- INI.List_GetList(lstList.Items);
- // Enable buttons based on list selection
- EnableUI;
- end;
- procedure TfrmManageMailLists.Add;
- begin
- // if they added a mail list through the AddEditMailList Dialog...
- // then refresh the list of mail lists
- if frmAddEditMailList.Add then INI.List_GetList(lstList.Items);
- end;
- procedure TfrmManageMailLists.Edit;
- begin
- // if there's a selected mail list, then let them edit it
- // through the AddEditMailList Dialog...
- // then refresh the list of mail lists
- if lstList.ItemIndex > -1 then
- if frmAddEditMailList.Edit(lstList.Items[lstList.ItemIndex]) then
- INI.List_GetList(lstList.Items);
- end;
- procedure TfrmManageMailLists.Delete;
- var
- x : Integer;
- begin
- // Ask if they really want to delete, cause it can't be un-done
- x := MessageDlg('Deleting list(s) cannot be undone. Proceed?',
- mtConfirmation, [mbYes, mbNo], 0);
- if x = mrYes then begin
- // they really want to do it... for each selected mail list...
- // call the delete function and refresh the list of mail lists
- for x := 0 to lstList.Items.Count -1 do
- if lstList.Selected[x] then INI.List_Delete(lstList.Items[x]);
- INI.List_GetList(lstList.Items);
- end;
- end;
- procedure TfrmManageMailLists.Rename;
- var
- OldListID, NewListID : String;
- begin
- // if there's a mail list selected...
- if lstList.ItemIndex > -1 then
- OldListID := lstList.Items[lstList.ItemIndex];
- NewListID := InputBox('Rename List', 'Enter New List Name', OldListID);
- if LowerCase(NewListID) <> LowerCase(OldListID) then begin
- // and the new mail list isn't the same as the old one...
- // then rename the list and refresh the display
- if not INI.List_Rename(OldListID, NewListID) then
- ShowMessage('Error: Cound not re-name.' + #13 + #10 +
- 'List must have a unique ID.')
- else
- INI.List_GetList(lstList.Items);
- end;
- end;
- procedure TfrmManageMailLists.Import;
- begin // Import Mail Lists
- ShowMessage('Feature not implemented yet...');
- // DEBUG
- // How should I import a mail list ?
- end;
- procedure TfrmManageMailLists.DoExport;
- begin // Export Mail lists
- ShowMessage('Feature not implemented yet...');
- // DEBUG
- // How should I export a mail list ?
- end;
- procedure TfrmManageMailLists.EnableUI;
- begin
- // Enable buttons and menus based on list selection
- btnEdit.Enabled := lstList.SelCount = 1;
- btnDelete.Enabled := lstList.SelCount > 0;
- btnRename.Enabled := lstList.SelCount = 1;
- btnExport.Enabled := lstList.Items.Count > 0;
- puEdit.Enabled := lstList.SelCount = 1;
- puDelete.Enabled := lstList.SelCount > 0;
- puRename.Enabled := lstList.SelCount = 1;
- puExport.Enabled := lstList.Items.Count > 0;
- end;
- // Hook Buttond and menus up with functions for performing actions
- procedure TfrmManageMailLists.btnAddClick(Sender: TObject);
- begin Add; end;
- procedure TfrmManageMailLists.btnEditClick(Sender: TObject);
- begin Edit; end;
- procedure TfrmManageMailLists.btnDeleteClick(Sender: TObject);
- begin Delete; end;
- procedure TfrmManageMailLists.btnRenameClick(Sender: TObject);
- begin Rename; end;
- procedure TfrmManageMailLists.btnImportClick(Sender: TObject);
- begin Import; end;
- procedure TfrmManageMailLists.btnExportClick(Sender: TObject);
- begin DoExport; end;
- procedure TfrmManageMailLists.lstListClick(Sender: TObject);
- begin EnableUI; end;
- procedure TfrmManageMailLists.lstListDblClick(Sender: TObject);
- begin Edit; end;
- procedure TfrmManageMailLists.popupMenuPopup(Sender: TObject);
- begin EnableUI; end;
- procedure TfrmManageMailLists.btnCloseClick(Sender: TObject);
- begin Close; end;
- end.