]> err.no Git - sope/blob - sope-mime/NGMail/NGPop3Client.h
minor code cleanups
[sope] / sope-mime / NGMail / NGPop3Client.h
1 /*
2   Copyright (C) 2000-2004 SKYRIX Software AG
3
4   This file is part of OpenGroupware.org.
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_NGPop3Client_H__
24 #define __NGMail_NGPop3Client_H__
25
26 #import <Foundation/NSObject.h>
27 #include <NGStreams/NGStreams.h>
28 #include <NGStreams/NGSocketProtocols.h>
29
30 @class NSString, NSData;
31 @class NGBufferedStream;
32 @class NGMimeMessage;
33
34 typedef enum {
35   NGPop3State_unconnected = 1,
36   NGPop3State_AUTHORIZATION,
37   NGPop3State_TRANSACTION,
38   NGPop3State_UPDATE
39 } NGPop3State;
40
41 @class NGPop3Response, NGPop3MessageInfo;
42
43 @interface NGPop3Client : NSObject
44 {
45 @protected
46   id<NGActiveSocket>       socket;
47   NGBufferedStream         *connection;
48   id<NGExtendedTextStream> text;
49
50   NGPop3State    state;
51   NGPop3Response *lastResponse;
52   BOOL isDebuggingEnabled;
53 }
54
55 + (id)pop3Client;
56 - (id)initWithSocket:(id<NGActiveSocket>)_socket; // designated initializer
57
58 /* accessors */
59
60 - (id<NGActiveSocket>)socket;
61 - (NGPop3State)state;
62 - (NGPop3Response *)lastResponse;
63
64 - (void)setDebuggingEnabled:(BOOL)_flag;
65 - (BOOL)isDebuggingEnabled;
66
67 /* connection */
68
69 - (BOOL)connectToHost:(id)_host;
70 - (BOOL)connectToAddress:(id<NGSocketAddress>)_address;
71 - (void)disconnect;
72
73 /* state */
74
75 - (void)requireState:(NGPop3State)_state;
76 - (void)gotoState:(NGPop3State)_state;
77
78 /* commands */
79
80 - (NGPop3Response *)sendCommand:(NSString *)_command;
81 - (NGPop3Response *)sendCommand:(NSString *)_command argument:(NSString *)arg;
82 - (NGPop3Response *)sendCommand:(NSString *)_command intArgument:(int)_arg;
83
84 /* service commands */
85
86 - (BOOL)login:(NSString *)_user password:(NSString *)_passwd;
87 - (BOOL)quit;
88
89 - (BOOL)statMailDropCount:(int *)_count size:(int *)_size;
90 - (NGPop3MessageInfo *)listMessage:(int)_messageNumber;
91 - (NSEnumerator *)listMessages;
92 - (NSData *)retrieveMessage:(int)_msgNumber;
93 - (BOOL)deleteMessage:(int)_msgNumber;
94 - (BOOL)noop;
95 - (BOOL)reset;
96
97 /* optional service commands */
98
99 - (NSData *)retrieveMessage:(int)_msgNumber bodyLineCount:(int)_numberOfLines;
100 - (NSDictionary *)uniqueIdMappings;
101 - (NSString *)uniqueIdOfMessage:(int)_msgNumber;
102
103 /* MIME support */
104
105 - (NSEnumerator *)messageEnumerator;
106 - (NGMimeMessage *)messageWithNumber:(int)_messageNumber;
107
108 @end
109
110 #endif /* __NGMail_NGPop3Client_H__ */