]> err.no Git - sope/blob - sope-mime/NGMail/NGSmtpClient.h
minor code cleanups in message generator
[sope] / sope-mime / NGMail / NGSmtpClient.h
1 /*
2   Copyright (C) 2000-2005 SKYRIX Software AG
3
4   This file is part of SOPE.
5
6   SOPE is free software; you can redistribute it and/or modify it under
7   the terms of the GNU Lesser General Public License as published by the
8   Free Software Foundation; either version 2, or (at your option) any
9   later version.
10
11   SOPE is distributed in the hope that it will be useful, but WITHOUT ANY
12   WARRANTY; without even the implied warranty of MERCHANTABILITY or
13   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
14   License for more details.
15
16   You should have received a copy of the GNU Lesser General Public
17   License along with SOPE; see the file COPYING.  If not, write to the
18   Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19   02111-1307, USA.
20 */
21
22 #ifndef __NGMail_NGSmtpClient_H__
23 #define __NGMail_NGSmtpClient_H__
24
25 #import <Foundation/NSObject.h>
26 #import <NGStreams/NGStreams.h>
27 #import <NGStreams/NGSocketProtocols.h>
28
29 @class NSString;
30 @class NGSmtpResponse;
31
32 /*
33   RFC 821 - SMTP
34
35   This class implements the Simple Mail Transfer Protocol as specified in RFC821.
36 */
37
38 typedef enum {
39   NGSmtpState_unconnected = 1,
40   NGSmtpState_connected,
41   NGSmtpState_TRANSACTION
42 } NGSmtpState;
43
44 @interface NGSmtpClient : NSObject
45 {
46 @protected
47   id<NGActiveSocket>       socket;
48   NGBufferedStream         *connection;
49   id<NGExtendedTextStream> text;
50
51   NGSmtpState state;
52   BOOL isDebuggingEnabled;
53
54   struct {
55     BOOL hasExpand:1;
56     BOOL hasSize:1;
57     BOOL hasHelp:1;
58     BOOL hasPipelining;
59   } extensions;
60 }
61
62 + (id)smtpClient;
63 - (id)initWithSocket:(id<NGActiveSocket>)_socket; // designated initializer
64
65 // accessors
66
67 - (id<NGActiveSocket>)socket;
68 - (NGSmtpState)state;
69
70 - (void)setDebuggingEnabled:(BOOL)_flag;
71 - (BOOL)isDebuggingEnabled;
72
73 // connection
74
75 - (BOOL)connectToHost:(id)_host;
76 - (BOOL)connectToAddress:(id<NGSocketAddress>)_address;
77 - (void)disconnect;
78
79 // state
80
81 - (void)requireState:(NGSmtpState)_state;
82 - (void)denyState:(NGSmtpState)_state;
83 - (void)gotoState:(NGSmtpState)_state;
84
85 // replies
86
87 - (NGSmtpResponse *)receiveReply;
88
89 // commands
90
91 - (NGSmtpResponse *)sendCommand:(NSString *)_command;
92 - (NGSmtpResponse *)sendCommand:(NSString *)_command argument:(NSString *)arg;
93
94 // service commands
95
96 - (BOOL)quit;
97 - (BOOL)helloWithHostname:(NSString *)_host;
98 - (BOOL)hello;
99 - (BOOL)noop;
100 - (BOOL)reset;
101
102 - (NSString *)help;
103 - (NSString *)helpForTopic:(NSString *)_topic;
104
105 - (BOOL)verifyAddress:(id)_address;
106
107 // transaction commands
108
109 - (BOOL)mailFrom:(id)_sender;
110 - (BOOL)recipientTo:(id)_receiver;
111 - (BOOL)sendData:(NSData *)_data;
112
113 @end
114
115 #endif /* __NGMail_NGSmtpClient_H__ */