(* @ @ @ @ @ @ @ @ @ @ / C c c * ** (* @ /// Constructor t_news.create (aowner: tcomponent); *) Constructor T_News.create (Aowner: Tcomponent); Begin inherited Create (Aowner); f_nntp: = nil; f_NewsGroups: = TStringList.create; end; (* @ /// 0000000501 *) (* @ /// destructor t_news.destroy; *) deStructor t_news.destroy; begin f_newsgroups.free; inherited destroy; end; (* @ @ @ @ @ @ @ @ @ @ @ @ @ @ 00000030f *)
(* @ /// procedure t_news.SetNewsgroups (Value: TStringList); *) procedure t_news.SetNewsgroups (Value: TStringList); begin if value = NIL then f_newsgroups.clear else f_newsgroups.assign (value); end; (* @ /// 000,0000603 *)
(* @ /// procedure t_news.action; *) procedure t_news.action; var s: string; i: integer; begin if (f_nntp = nil) or (f_newsgroups = nil) OR (f_newsgroups.count = 0) OR F_newsgroups.count> 10) (* no spamming, please *) or (f_from = '') THEN EXIT; S: = 'newsgroups:'; i: = 0; While True Do Begin S: = S F_NewsGroups.Strings [ I]; INC (i); if i
(* @ /// class t_attachment (TObject) *) (* @ /// constructor t_attachment.Create; *) constructor t_attachment.Create; begin inherited create; f_text: = TStringlist.create; f_data: = TMemoryStream.Create; f_encoding : = EC_NONE; END; (* @ /// 0000000617 *) (* @ /// deStructor t_attachment.destroy; *) deStructor t_attachment.destroy; recomgin f_text.free; f_data.free; inherited destroy; end; (* @ /// *) (* @ /// procedure t_attachment.SetText (value: TStringList); *) procedure t_attachment.SetText (value: TStringList); begin if value = NIL then f_text.clear else begin f_text.assign (value) ; f_text.SaveToStream (TMemoryStream (f_data)); end; end; (* @ /// 0000000701 *) (* @ /// procedure t_attachment.SetData (value: TStream); *) procedure t_attachment.SetData (value: TStream Begin if value = nil damorystream (f_data). Clear else begin f_text.clear; tmemorystream (f_data) .loadFromstream (value); end; end; (* @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ / / * ) (* @ /// class t_mime (tcomponent) *) (* @ /// constructor t_mime.create (Aowner: Tcom PONENT); *) Constructor T_Mime.create (Aowner: Tcomponent); Begin inherited Create (Aowner); f_attachment: = tList.create; end; (* @ @ @ @ @ @// destructor t_mime.destroy ; *) deStructor T_Mime.destroy; begin if f_attachment <> nil dam Try RemoveAlattachments; Except end; end; f_attachment.free; inherited destroy; (* @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ 0000000701 *)
(* @ /// function t_mime.AttachFile (const filename: string): integer; *) function t_mime.AttachFile (const filename: string): integer; var t: t_attachment; data: TFileStream; begin t: = t_attachment.Create T. Kind: = 'Application / OCTET-stream'; t.encoding: = EC_BASE64; DATA: = NIL; Try Data: = TFileStream.create (filename, fmopenread); t.data:=data; data.free; Except data.free; t.free; raise; end; t.disposition: = 'attachment; filename = "' filename_of (filename) '"; result: = f_attachment.add (t); end; (* @ /// *) (* @ /// function t_mime.attachtetext (text: tstringlist): integer; *) function t_mime.attachtext (text: tstringlist): integer; var t_attachment; begin T: = t_attachment.create; T.Kind: = 'text / plain'; t.encoding: = EC_QUOTEDPRINTABLE; T.TEXT: = text; t.disposition: = '; result: = f_attachment.add (t); end; (* @ // / 000000060C *) (* @ /// procedure t_mime.RemoveAttachment (index: integer); *) procedure t_mime.RemoveAttachment (index: integer); begin if (index> = 0) and (f_attachment.count> index) then . Begin TObject (f_attachment [index]) free; f_attachment.delete (index); end; end; (* @ /// 0000000301 *) (* @ /// procedure t_mime.RemoveAllAttachments; *) procedure t_mime.RemoveAllAttachments; begin While f_attachment.count> 0 Do Begin Tobject (f_attachment [0]). free; f_attachment.delete (0); end; end; (* @ @ @ @ @ /// function t_mime.getnumberofattachments: integer ; *) function t_mime.getnumberofattachments: integer; begin result: = f_attachment.count; end; (* @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ 0000000317 *)
(* @ /// procedure t_mime.action; *) procedure t_mime.action; var data, encode: TstringList; i, j, p: integer; attach: t_attachment; begin if f_mail = nil dam; boundary: = INTOSTR Round ((NOW-ENCODEDATE (1970, 1, 1)) * 86400)) INTTOHEX (my_ip_address, 8) '=='; DATA: = NIL; P: = - 1; Try Data: = TSTRINGLIST.CREATE f_mail.Header.Add ('mime-version: 1.0'); f_mail.Header.Add ('content-type: multipart / mix; bitchary = "' boundary '); f_mail.header.add (' content- TRANSFER-ENCODING: 7bit '); Data.assign (f_mail.body); if data.count> 0 Then Begin f_mail.body.clear; p: = attachtext (data); end; for i: = 0 to f_attachment.count -1 Do Begin attach: = t_attachment (f_attachment [i]); f_mail.body.add (''); f_mail.body.add ('-' boundary); f_mail.body.add ('content-type: ' attach.kind; if attach.disposition <>' 'TENF_MAIL.BODY.ADD (' content-disposition: ' attach.disposition); case attach.encoding of ec_base64: f_mail.body.add (' Content- TRA nsfer-encoding: base64 '); Ec_quotedprintable: f_mail.body.add (' content-transfer-encoding: quoted-printable '); end; f_mail.body.add (' '); case attach.encoding of (* @ / // ec_base64: *) ec_base64: begin encoded: = encode_base64 (attach.data); f_mail.Body.AddStrings (encoded); encoded.free; end; (* @ /// 0000000201 *) (* @ /// ec_quotedprintable : // Only for text! *) EC_QUOTEDPRINTABLE: Begin for J: = 0 to attach.text.count-1 do f_mail.body.add (Eight2seven_quoteprint (attach.text [j])); end; (* @
/// 0000000315 *) (* @ /// EC_NONE: // only for text! *) EC_NONE: Begin for j: = 0 to attach.text.count-1 do f_mail.body.add (Eight2seven_quoteprint (attach.text [J]); END; (* @ @ @ @ @ @ @ e; f_mail.body.add (''); f_mail.body.add ('-' bousary '-'); f_mail .action; if data.count> 0 THEN F_MAIL.BODY: = DATA; FINALLY DATA.FREE; Removeattachment (P); end; end; (* @ @ @ @ @ @ /// procedure t_mime.setmail (mail: TStringlist); *) procedure t_mime.SetMail (mail: TStringlist); (* @ /// procedure strip_header (const line: string; var field, data: string); *) procedure strip_header (const line: string; Var Field, Data: String; Var H: Integer; Begin H: = POS (':', line); if H> 0 Then Begin Field: = LowerCase (Copy (Line, 1, H-1)); DATA : = TRIM (Copy (Line, H 1, Length (Line)); END ELSE BEGIN Field: = '; DATA: ='; End; End; (* @ @ @ @ @ @ 00 00 00 1 1, J: Integer; S, Field, Data: String; Attach: t_attachment; begin boundary: = '; RemoveAlttachme NTS; (* @ /// PARSE Header Lines and search for mime bitchary *) i: = 0; while (i
(* ignore the empty line *) if i> = mail.count-1 Then Break; while (i
'quoted-printable: = EC_QUOTEDPRINTABLE ELSE ATTACH.Encoding: = EC_NONE; END; (* @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ 00m m .add (attach); end; (* @ /// 0000001b33 *) (* @ /// Function T_mime.Getattachment (index: integer): t_attachment; *) Function T_mime.getatchment (Index: Integer): t_attachment; begin IF index> f_attachment.count-1 Ten Result: = nil else result: = t_attachment (f_attachment [index]); end; (* @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ // / procedure Register; *) procedure Register; begin RegisterComponents ( 'TCP / IP', [t_finger]); RegisterComponents ( 'TCP / IP', [t_fingerD]); RegisterComponents ( 'TCP / IP', [t_http]); RegisterComponents ('TCP / IP', [T_FTP]); RegisterComponents ('TCP / IP', [T_LPR]); RegisterComponents ('TCP / IP', [T_SMTP]); Registercomponents ('TCP / IP', [T_mail]) Registercomponents ('TCP / IP', [T_NNTP]); RegisterComponents ('TCP / IP', [T_News]); Registercomponents ('TCP / IP', [T_TIME]); Registercomponents ('TCP / IP', [T_REXEC ]); Registercomponents ('TCP / IP', [T_RSH]); Registercomponents ('TCP / IP', [T_POP3]); RegisterComponents ('TCP / IP', [T_MIME]); END; (* @ /// *) ( * @ @ /// ositialization * begin lpr_count: = 0; End. (* @ /// *) (* @ @ @ @ 0001000011 *)