]> err.no Git - sope/blob - sope-mime/NGMail/NGSmtpClient.h
minor code cleanups
[sope] / sope-mime / NGMail / NGSmtpClient.h
1 /*
2   Copyright (C) 2000-2003 SKYRIX Software AG
3
4   This file is part of OGo
5
6   OGo 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   OGo 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 OGo; 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 // $Id$
22
23 #ifndef __NGMail_NGSmtpClient_H__
24 #define __NGMail_NGSmtpClient_H__
25
26 #import <Foundation/NSObject.h>
27 #import <NGStreams/NGStreams.h>
28 #import <NGStreams/NGSocketProtocols.h>
29
30 @class NSString;
31 @class NGSmtpResponse;
32
33 /*
34   RFC 821 - SMTP
35
36   This class implements the Simple Mail Transfer Protocol as specified in RFC821.
37 */
38
39 typedef enum {
40   NGSmtpState_unconnected = 1,
41   NGSmtpState_connected,
42   NGSmtpState_TRANSACTION
43 } NGSmtpState;
44
45 @interface NGSmtpClient : NSObject
46 {
47 @protected
48   id<NGActiveSocket>       socket;
49   NGBufferedStream         *connection;
50   id<NGExtendedTextStream> text;
51
52   NGSmtpState state;
53   BOOL isDebuggingEnabled;
54
55   struct {
56     BOOL hasExpand:1;
57     BOOL hasSize:1;
58     BOOL hasHelp:1;
59     BOOL hasPipelining;
60   } extensions;
61 }
62
63 + (id)smtpClient;
64 - (id)initWithSocket:(id<NGActiveSocket>)_socket; // designated initializer
65
66 // accessors
67
68 - (id<NGActiveSocket>)socket;
69 - (NGSmtpState)state;
70
71 - (void)setDebuggingEnabled:(BOOL)_flag;
72 - (BOOL)isDebuggingEnabled;
73
74 // connection
75
76 - (BOOL)connectToHost:(id)_host;
77 - (BOOL)connectToAddress:(id<NGSocketAddress>)_address;
78 - (void)disconnect;
79
80 // state
81
82 - (void)requireState:(NGSmtpState)_state;
83 - (void)denyState:(NGSmtpState)_state;
84 - (void)gotoState:(NGSmtpState)_state;
85
86 // replies
87
88 - (NGSmtpResponse *)receiveReply;
89
90 // commands
91
92 - (NGSmtpResponse *)sendCommand:(NSString *)_command;
93 - (NGSmtpResponse *)sendCommand:(NSString *)_command argument:(NSString *)arg;
94
95 // service commands
96
97 - (BOOL)quit;
98 - (BOOL)helloWithHostname:(NSString *)_host;
99 - (BOOL)hello;
100 - (BOOL)noop;
101 - (BOOL)reset;
102
103 - (NSString *)help;
104 - (NSString *)helpForTopic:(NSString *)_topic;
105
106 - (BOOL)verifyAddress:(id)_address;
107
108 // transaction commands
109
110 - (BOOL)mailFrom:(id)_sender;
111 - (BOOL)recipientTo:(id)_receiver;
112 - (BOOL)sendData:(NSData *)_data;
113
114 @end
115
116 #endif /* __NGMail_NGSmtpClient_H__ */