NMUUE.pas
资源名称:FastNet.rar [点击查看]
上传用户:szzdds
上传日期:2013-09-18
资源大小:293k
文件大小:3k
源码类别:
Delphi控件源码
开发平台:
Delphi
- unit NMUUE;
- interface
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, NMConst;
- type
- UUMethods = (uuMime, uuCode);
- TNMUUProcessor = class(TComponent)
- private
- FOnBeginEncode: TNotifyEvent;
- FOnEndEncode: TNotifyEvent;
- FOnBeginDecode: TNotifyEvent;
- FOnEndDecode: TNotifyEvent;
- FInputStream: TStream;
- FOutputStream: TStream;
- protected
- FUUMethod: UUMethods;
- public
- constructor Create(AOwner: TComponent); override;
- procedure Encode;
- procedure Decode;
- property InputStream: TStream read FInputStream write FInputStream;
- property OutputStream: TStream read FOutputStream write FOutputStream;
- published
- property Method: UUMethods read FUUMethod write FUUMethod default uuMime;
- property OnBeginEncode: TNotifyEvent read FOnBeginEncode write FOnBeginEncode;
- property OnEndEncode: TNotifyEvent read FOnEndEncode write FOnEndEncode;
- property OnBeginDecode: TNotifyEvent read FOnBeginDecode write FOnBeginDecode;
- property OnEndDecode: TNotifyEvent read FOnEndDecode write FOnEndDecode;
- end;
- implementation
- uses
- NM64Encode, NM64Decode, NMUUEncode, NMUUDecode;
- {*******************************************************************************
- Create NMUUE and set code method to MIME by default
- *******************************************************************************}
- constructor TNMUUProcessor.Create(AOwner: TComponent);
- begin
- inherited;
- FUUMethod := uuMime;
- end;
- {*******************************************************************************
- Encode
- *******************************************************************************}
- procedure TNMUUProcessor.Encode;
- begin
- FInputStream.Position := 0;
- if Assigned(FOnBeginEncode) then
- FOnBeginEncode(self);
- case Method of
- uuMime: B64Encode(FInputStream, FOutputStream);
- uuCode: UUEEncode(FInputStream, FOutputStream);
- end;
- FInputStream.Position := 0;
- FOutputStream.Position := 0;
- if Assigned(FOnEndEncode) then
- FOnEndEncode(self);
- end;
- {*******************************************************************************************
- Decode
- ********************************************************************************************}
- procedure TNMUUProcessor.Decode;
- begin
- FInputStream.Position := 0;
- if Assigned(FOnBeginDecode) then
- FOnBeginDecode(self);
- case Method of
- uuMime: B64Decode(FInputStream, FOutputStream);
- uuCode: UUEDecode(FInputStream, FOutputStream);
- end;
- FInputStream.Position := 0;
- FOutputStream.Position := 0;
- if Assigned(FOnEndDecode) then
- FOnEndDecode(self);
- end;
- end.