]> err.no Git - sope/blob - sope-mime/NGImap4/NGImap4Client.h
fixed OGo bug #1587 (qp decoding in IMAP4 envelopes)
[sope] / sope-mime / NGImap4 / NGImap4Client.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 __SOPE_NGImap4_NGImap4Client_H__
23 #define __SOPE_NGImap4_NGImap4Client_H__
24
25 #import <Foundation/NSObject.h>
26 #include <NGStreams/NGStreams.h>
27 #include <NGStreams/NGSocketProtocols.h>
28 #include <NGImap4/NGImap4Support.h>
29
30 /*
31   NGImap4Client
32   
33   An IMAP4 client object. This object is a thin wrapper around the TCP/IP
34   socket (id<NGActiveSocket> object) connecting to the IMAP4 server.
35   
36   While it is pretty near to the IMAP4 raw protocol, it already does some
37   normalization of responses. We might want to have something which is even
38   lower level in the future.
39   
40   Responses are send to all registered response receivers.
41   TODO: explain notification system.
42 */
43
44 @class NSMutableArray, NSString, NSNumber, NSDictionary, NSArray, NSURL;
45 @class EOGlobalID, EOQualifier;
46 @class NGHashMap;
47 @class NGImap4ResponseParser, NGImap4Client, NGImap4ResponseNormalizer;
48
49 typedef enum {
50   UnConnected_NGImap4State = 1,
51   NonAuthenticated_NGImap4State,
52   Authenticated_NGImap4State,
53   Selected_NGImap4State,
54 } NGImap4State;
55
56 @interface NGImap4Client : NSObject
57 {
58   id<NGActiveSocket>        socket;
59   id<NGExtendedTextStream>  text;
60   id<NGSocketAddress>       address;
61   NGImap4ResponseParser     *parser;
62   NGImap4ResponseNormalizer *normer;
63   NSMutableArray            *responseReceiver;  
64
65   BOOL     isLogin;
66   unsigned tagId;
67
68   NSString *delimiter;
69   NSString *selectedFolder;
70   NSString *login;
71   NSString *password;
72
73   BOOL debug;
74   BOOL useSSL;
75
76   NGImap4Context *context; /* not retained, used to store exceptions */
77   EOGlobalID *serverGID;
78 }
79
80 + (id)clientWithURL:(NSURL *)_url;
81 + (id)clientWithAddress:(id<NGSocketAddress>)_address;
82 + (id)clientWithHost:(id)_host;
83
84 - (id)initWithURL:(NSURL *)_url;
85 - (id)initWithHost:(id)_host;
86 - (id)initWithAddress:(id<NGSocketAddress>)_address;
87
88 /* equality */
89
90 - (BOOL)isEqualToClient:(NGImap4Client *)_obj;
91
92 /* accessors */
93
94 - (id<NGActiveSocket>)socket;
95 - (id<NGSocketAddress>)address;
96 - (NSString *)delimiter;
97 - (EOGlobalID *)serverGlobalID;
98
99 - (NSString *)selectedFolderName;
100
101 /* notifications */
102
103 - (void)registerForResponseNotification:(id<NGImap4ResponseReceiver>)_obj;
104 - (void)removeFromResponseNotification:(id<NGImap4ResponseReceiver>)_obj;
105
106 /* connection */
107
108 - (NSDictionary *)openConnection;
109 - (void)closeConnection;
110 - (NSNumber *)isConnected;
111 - (void)reconnect;
112
113 /* commands */
114
115 - (NSDictionary *)login:(NSString *)_login password:(NSString *)_passwd;
116 - (NSDictionary *)logout;
117 - (NSDictionary *)noop;
118   
119 - (NSDictionary *)capability;
120 - (NSDictionary *)list:(NSString *)_folder pattern:(NSString *)_pattern;
121 - (NSDictionary *)lsub:(NSString *)_folder pattern:(NSString *)_pattern;
122 - (NSDictionary *)select:(NSString *)_folder;
123 - (NSDictionary *)status:(NSString *)_folder flags:(NSArray *)_flags;
124 - (NSDictionary *)rename:(NSString *)_folder to:(NSString *)_newName;
125 - (NSDictionary *)delete:(NSString *)_folder;
126 - (NSDictionary *)create:(NSString *)_name;
127 - (NSDictionary *)subscribe:(NSString *)_name;
128 - (NSDictionary *)unsubscribe:(NSString *)_name;
129 - (NSDictionary *)expunge;
130   
131 - (NSDictionary *)sort:(id)_sortOrderings qualifier:(EOQualifier *)_qual
132   encoding:(NSString *)_encoding;
133 - (NSDictionary *)fetchUids:(NSArray *)_uids parts:(NSArray *)_parts;
134 - (NSDictionary *)fetchUid:(unsigned)_uid    parts:(NSArray *)_parts;
135 - (NSDictionary *)fetchFrom:(unsigned)_from to:(unsigned)_to
136   parts:(NSArray *)_parts;
137 - (NSDictionary *)storeUid:(unsigned)_uid add:(NSNumber *)_add
138   flags:(NSArray *)_flags;
139 - (NSDictionary *)storeFrom:(unsigned)_from to:(unsigned)_to
140   add:(NSNumber *)_add flags:(NSArray *)_flags;
141 - (NSDictionary *)storeFlags:(NSArray *)_flags forMSNs:(id)_msns
142   addOrRemove:(BOOL)_flag;
143
144 - (NSDictionary *)copyUid:(unsigned)_uid    toFolder:(NSString *)_folder;
145 - (NSDictionary *)copyUids:(NSArray *)_uids toFolder:(NSString *)_folder;
146 - (NSDictionary *)copyFrom:(unsigned)_from to:(unsigned)_to
147   toFolder:(NSString *)_folder;
148
149 - (NSDictionary *)append:(NSData *)_message toFolder:(NSString *)_folder
150   withFlags:(NSArray *)_flags;
151 - (NSDictionary *)threadBySubject:(BOOL)_bySubject
152   charset:(NSString *)_charSet;
153 - (NSDictionary *)getQuotaRoot:(NSString *)_folder;
154
155 - (NSDictionary *)searchWithQualifier:(EOQualifier *)_qualifier;
156
157 /* ACLs */
158
159 - (NSDictionary *)getACL:(NSString *)_folder;
160 - (NSDictionary *)setACL:(NSString *)_folder rights:(NSString *)_r
161   uid:(NSString *)_uid;
162 - (NSDictionary *)deleteACL:(NSString *)_folder uid:(NSString *)_uid;
163 - (NSDictionary *)listRights:(NSString *)_folder uid:(NSString *)_uid;
164 - (NSDictionary *)myRights:(NSString *)_folder;
165
166 /* context accessors (DEPRECATED) */
167
168 - (void)setContext:(NGImap4Context *)_ctx;
169 - (NGImap4Context *)context;
170
171 /* raw methods */
172
173 - (NSDictionary *)primarySort:(NSString *)_sortString
174   qualifierString:(NSString *)_qualString
175   encoding:(NSString *)_encoding;
176
177 @end
178
179 #endif /* __SOPE_NGImap4_NGImap4Client_H__ */