ufrmEmailBoxProperty.pas
上传用户:yjb1804
上传日期:2021-01-30
资源大小:3105k
文件大小:12k
- unit ufrmEmailBoxProperty;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, RzTabs, cxTextEdit, cxControls, cxContainer, cxEdit, cxLabel,
- cxMaskEdit, cxButtonEdit, Menus, cxLookAndFeelPainters, StdCtrls,
- cxButtons, ExtCtrls, cxListBox, cxRadioGroup, cxCheckBox, cxGraphics,
- cxDropDownEdit, cxImageComboBox, cxSpinEdit, RzShellDialogs, uMyXml,IniFiles,
- ActnList;
- type
- TfrmEmailBoxProperty = class(TForm)
- RzPageControl1: TRzPageControl;
- TabSheet2: TRzTabSheet;
- TabSheet3: TRzTabSheet;
- cxLabel4: TcxLabel;
- pnl1: TPanel;
- btnOk: TcxButton;
- btnCancel: TcxButton;
- lblEmailRecvCount: TLabel;
- btnRecvClear: TcxButton;
- lblBoxName: TLabel;
- rztbshtTabSheet4: TRzTabSheet;
- lstBlack: TcxListBox;
- lstWhite: TcxListBox;
- cxLabel11: TcxLabel;
- cxLabel12: TcxLabel;
- btnAddBlack: TcxButton;
- btnDeleteBlack: TcxButton;
- edtRecvPlaySound: TcxButtonEdit;
- edtRecvRunExe: TcxButtonEdit;
- cxLabel13: TcxLabel;
- cxLabel14: TcxLabel;
- rbAtuoDetect: TcxRadioButton;
- rbMinDetect: TcxRadioButton;
- rbRunDetect: TcxRadioButton;
- rbNeverDetect: TcxRadioButton;
- btnAddWhite: TcxButton;
- btnDeleteWhite: TcxButton;
- btnRuleSet: TcxButton;
- chkReDownload: TcxCheckBox;
- rztbshtTabSheet5: TRzTabSheet;
- cbServerType: TcxImageComboBox;
- cxLabel5: TcxLabel;
- cxLabel8: TcxLabel;
- edtUserName: TcxTextEdit;
- cxLabel9: TcxLabel;
- edtPass: TcxTextEdit;
- edtServerRecv: TcxTextEdit;
- cxlbl1: TcxLabel;
- cxlbl2: TcxLabel;
- edtServerSend: TcxTextEdit;
- cxlbl3: TcxLabel;
- lblEmailSendCount: TcxLabel;
- btnSendClear: TcxButton;
- edtRecvSaveTo: TcxButtonEdit;
- cxlbl5: TcxLabel;
- edtSendSaveTo: TcxButtonEdit;
- chkSendLog: TcxCheckBox;
- chkRecvLog: TcxCheckBox;
- cxlbl6: TcxLabel;
- edtDisplayName: TcxTextEdit;
- lbl1: TcxLabel;
- lbl2: TcxLabel;
- edRecvPort: TcxSpinEdit;
- edSendPort: TcxSpinEdit;
- dlgSave: TRzSaveDialog;
- dlgOpen: TRzOpenDialog;
- lbl3: TcxLabel;
- edt1: TcxButtonEdit;
- actlst1: TActionList;
- actWriteCheckEmailOption: TAction;
- procedure btnRuleSetClick(Sender: TObject);
- procedure btnCancelClick(Sender: TObject);
- procedure edt1PropertiesButtonClick(Sender: TObject;
- AButtonIndex: Integer);
- procedure chkReDownloadClick(Sender: TObject);
- procedure edtRecvPlaySoundPropertiesButtonClick(Sender: TObject;
- AButtonIndex: Integer);
- procedure edtRecvRunExePropertiesButtonClick(Sender: TObject;
- AButtonIndex: Integer);
- procedure btnSendClearClick(Sender: TObject);
- procedure btnRecvClearClick(Sender: TObject);
- procedure btnAddBlackClick(Sender: TObject);
- procedure btnDeleteBlackClick(Sender: TObject);
- procedure btnAddWhiteClick(Sender: TObject);
- procedure btnDeleteWhiteClick(Sender: TObject);
- procedure btnOkClick(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure FormDestroy(Sender: TObject);
- procedure actWriteCheckEmailOptionExecute(Sender: TObject);
- procedure edtRecvSaveToPropertiesButtonClick(Sender: TObject;
- AButtonIndex: Integer);
- private
- { Private declarations }
- FEmailAddr:string;
- FMyxml:TMyXml;
- FAddBlack,
- FDelBlack,
- FAddWhite,
- FDelWhite:TStrings;
- //procedure WriteCheckEmailOption(Option:Integer);
- public
- { Public declarations }
- procedure LoadDefault(EMailAddr:string);
- procedure ShowPage(index:Integer=0);
- end;
- var
- frmEmailBoxProperty: TfrmEmailBoxProperty;
- implementation
- uses ufrmRule, ufrmMain, uCommon, NativeXml,{$WARNINGS OFF} FileCtrl {$WARNINGS ON} ;
- {$R *.dfm}
- procedure TfrmEmailBoxProperty.btnRuleSetClick(Sender: TObject);
- begin
- with TfrmRule.Create(Application) do
- try
- if ShowModal=mrOk then ufrmMain.frmMain.LoadRules;
- finally
- free;
- end;
- end;
- procedure TfrmEmailBoxProperty.LoadDefault(EMailAddr:string);
- var
- MyXml:TMyXml;
- L:TStringList;
- Node:TXmlNode;
- Str:string;
- begin
- FEmailAddr:=EMailAddr;
- myxml:=TMyXml.Create(AppPath+'EmailServers.xml');
- try
- L:=TStringList.Create;
- MyXml.GetAllEmail(FEmailAddr,L,nil,nil);
- lblEmailRecvCount.Caption:=Format('共有%D封邮件',[L.Count]);
- L.Clear;
- MyXml.GetAllSentEmail(FEmailAddr,L);
- lblEmailSendCount.Caption:=Format('共有%D封邮件',[L.Count]);
- L.Free;
-
- Node:=MyXml.FindPop3(FEmailAddr);
- if Node<>nil then
- begin
- chkRecvLog.Checked:=StrToBoolDef(Node.AttributeByName['RecvLog'],True);
- chkSendLog.Checked:=StrToBoolDef(Node.AttributeByName['SendLog'],True);
- chkReDownload.Checked:=StrToBoolDef(Node.AttributeByName['ReDownload'],True);
- case StrToIntDef(Node.AttributeByName['Detect'],0) of
- 0: rbAtuoDetect.Checked:=True;
- 1: rbMinDetect.Checked:=True;
- 2: rbRunDetect.Checked:=True;
- 3: rbNeverDetect.Checked:=True;
- else ;
- end;
- edtRecvPlaySound.Text:=Node.AttributeByName['newemailwav'];
- edtRecvRunExe.Text:=Node.AttributeByName['newemailexe'];
- edtRecvSaveTo.Text:=Node.AttributeByName['SrcEmailSaveTo'];
- edtSendSaveTo.Text:=Node.AttributeByName['SendEmailSaveTo'];
- end;
-
- Str:=Node.ReadString('pop3server','');
- if CompareText('pop',Copy(Str,1,3))=0 then cbServerType.ItemIndex:=0;
- //add more
- edtUserName.Text:=FEmailAddr;
-
- edtServerRecv.Text:=Node.ReadString('pop3server','');
- edtServerSend.Text:=TEMailAddress.SMTPEmailSever(FEmailAddr);
- edtPass.Text:=Node.ReadString('pwd','');
- edtDisplayName.Text:=Node.ReadString('displayname','');
- edRecvPort.Value:=StrToInt(Node.ReadString('popPort','110')) ;
- edSendPort.Value:=StrToInt(Node.ReadString('SMTPPort','25')) ;
- finally
- MyXml.Free;
- end;
- //LoadRules;
- end;
- procedure TfrmEmailBoxProperty.btnCancelClick(Sender: TObject);
- begin
- ModalResult:=mrCancel;
- end;
- procedure TfrmEmailBoxProperty.edt1PropertiesButtonClick(Sender: TObject;
- AButtonIndex: Integer);
- begin
- dlgSave.Filter:='XML文件|*.xml';
- dlgSave.Options:=dlgSave.Options-[osoFilesCanBeFolders];
- if dlgSave.Execute then
- begin
- FMyxml:=TMyXml.Create(AppPath+'EmailServers.xml');
- try
- FMyXml.Root.FindNode('Rules').AttributeByName['RulesSaveTo']:=dlgSave.FileName;
- finally
- FMyxml.Free;
- end;
- frmMain.FRuleSaveTo:=dlgSave.FileName;
- end;
- end;
- procedure TfrmEmailBoxProperty.chkReDownloadClick(Sender: TObject);
- begin
- frmMain.FRetryAgain:=chkReDownload.Checked;
- end;
- procedure TfrmEmailBoxProperty.edtRecvPlaySoundPropertiesButtonClick(
- Sender: TObject; AButtonIndex: Integer);
- var
- FMyXml:TMyXml;
- begin
- dlgOpen.Filter:='声音文件|*.mp3;*.mp4;*.rm;*.rmvb;*.wav;*.avi;|所有文件|*.*';
- if dlgOpen.Execute then
- begin
- FMyxml:=TMyXml.Create(AppPath+'EmailServers.xml');
- try
- if FMyXml.FindPop3(FEmailAddr)<>nil then
- FMyXml.FindPop3(FEmailAddr).AttributeByName['newemailwav'] :=dlgSave.FileName;
- finally
- FMyxml.Free;
- end;
- frmMain.FEmailArrivedPlaySound:=dlgOpen.FileName;
- end;
- end;
- procedure TfrmEmailBoxProperty.edtRecvRunExePropertiesButtonClick(
- Sender: TObject; AButtonIndex: Integer);
- var
- FMyXml:TMyXml;
- begin
- dlgOpen.Filter:='可执行文件|*.exe;*.Bat';
- if dlgOpen.Execute then
- begin
- FMyxml:=TMyXml.Create(AppPath+'EmailServers.xml');
- try
- if FMyXml.FindPop3(FEmailAddr)<>nil then
- FMyXml.FindPop3(FEmailAddr).AttributeByName['newemailexe']:=dlgSave.FileName;
- finally
- FMyxml.Free;
- end;
- frmMain.FEmailArrivedPlaySound:=dlgOpen.FileName;
- end;
- end;
- procedure TfrmEmailBoxProperty.btnSendClearClick(Sender: TObject); //清空发件箱
- var
- L:TStrings;
- I:Integer;
- begin
- FMyxml:=TMyXml.Create(AppPath+'EmailServers.xml');
- try
- L:=TStringList.Create;
- try
- FMyxml.GetAllSentEmail(FEmailAddr,L);
- for i:=0 to L.Count-1 do
- if FileExists(L[I]) then DeleteFile(L[I]);
- FMyxml.DeleteAllSentEmail(FEmailAddr);
- finally
- L.Free;
- end;
- finally
- FMyxml.free;
- end;
- end;
- procedure TfrmEmailBoxProperty.btnRecvClearClick(Sender: TObject); //清空收件箱
- var
- L:TStrings;
- I:Integer;
- begin
- FMyxml:=TMyXml.Create(AppPath+'EmailServers.xml');
- try
- L:=TStringList.Create;
- try
- FMyxml.GetAllEmail(FEmailAddr,L,nil,nil);
- for i:=0 to L.Count-1 do
- if FileExists(L[I]) then DeleteFile(L[I]);
- FMyxml.DeleteAllEmail(FEmailAddr);
- finally
- L.Free;
- end;
- finally
- FMyxml.free;
- end;
- end;
- procedure TfrmEmailBoxProperty.btnAddBlackClick(Sender: TObject);
- var
- account:string;
- begin
- account:=Dialogs.InputBox('添加黑名单','请输入黑名单成员的Email账号:','');
- //if trim(account)='' then Exit;
- if not TEMailAddress.IsEmail(account) then
- begin
- MsgBoxError('Email账号不合法.合法的账号格式是:username@server');
- Exit;
- end;
- lstBlack.Items.Add(Trim(account));
- FAddBlack.Add(account);
- end;
- procedure TfrmEmailBoxProperty.btnDeleteBlackClick(Sender: TObject);
- begin
- FDelBlack.Add(lstBlack.Items[lstBlack.ItemIndex]) ;
- lstBlack.Items.Delete(lstBlack.ItemIndex);
- end;
- procedure TfrmEmailBoxProperty.btnAddWhiteClick(Sender: TObject);
- var
- account:string;
- begin
- account:=Dialogs.InputBox('添加白名单','请输入白名单成员的Email账号:','');
- //if trim(account)='' then Exit;
- if not TEMailAddress.IsEmail(account) then
- begin
- MsgBoxError('Email账号不合法.合法的账号格式是:username@server');
- Exit;
- end;
- lstWhite.Items.Add(Trim(account));
- FAddWhite.Add(account);
- end;
- procedure TfrmEmailBoxProperty.btnDeleteWhiteClick(Sender: TObject);
- begin
- FDelWhite.Add(lstWhite.Items[lstWhite.ItemIndex]);
- lstWhite.Items.Delete(lstWhite.ItemIndex);
- end;
- procedure TfrmEmailBoxProperty.btnOkClick(Sender: TObject);
- var
- MyXml:TMyXml;
- begin
- MyXml:=TMyXml.Create(AppPath+'EmailServers.xml');
- try
- MyXml.AddBlackList(FAddBlack);
- MyXml.AddWhiteList(FAddWhite);
- MyXml.DeleteBlackList(FDelBlack);
- MyXml.DeleteWhiteList(FDelWhite);
- frmMain.FBlackList.Assign(lstBlack.Items);
- frmMain.FWhiteList.Assign(lstWhite.Items);
- finally
- MyXml.Free;
- end;
- ModalResult:=mrOk;
- end;
- procedure TfrmEmailBoxProperty.FormCreate(Sender: TObject);
- var
- MyXml:TMyXml;
- begin
- FAddBlack:=THashedStringList.Create;
- FDelBlack:=THashedStringList.Create;
- FAddWhite:=THashedStringList.Create;
- FDelWhite:=THashedStringList.Create;
- MyXml:=TMyXml.Create(AppPath+'EmailServers.xml');
- try
- MyXml.GetBlackList(lstBlack.Items);
- MyXml.GetWhiteList(lstWhite.Items);
- finally
- MyXml.Free;
- end;
- end;
- procedure TfrmEmailBoxProperty.FormDestroy(Sender: TObject);
- begin
- FAddBlack.Free;
- FDelBlack.Free;
- FAddWhite.Free;
- FDelWhite.Free;
- end;
- procedure TfrmEmailBoxProperty.ShowPage(index: Integer);
- begin
- RzPageControl1.TabIndex:=index;
- end;
- procedure TfrmEmailBoxProperty.actWriteCheckEmailOptionExecute(
- Sender: TObject);
- var
- myXml:TMyXml;
- begin
- MyXml:=TMyXml.Create(AppPath+'EmailServers.xml');
- try
- MyXml.WriteEmailDetect(FEmailAddr,TcxRadioButton(sender).Tag);
- finally
- MyXml.Free;
- end;
- end;
- procedure TfrmEmailBoxProperty.edtRecvSaveToPropertiesButtonClick(
- Sender: TObject; AButtonIndex: Integer);
- var
- Dir:String;
- Xml:TAppXml;
- begin
- if SelectDirectory('',AppPath,Dir) then
- begin
- Xml:=TAppXml.Create;
- try
- Xml.SetEmailSavePath(Dir);
- finally
- Xml.free;
- end;
- end;
- end;
- end.