]> err.no Git - sope/blob - sope-mime/NGImap4/NGImap4Client.h
dcd65245d09c6593789753f1b9871f63326f1120
[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 /* notifications */
100
101 - (void)registerForResponseNotification:(id<NGImap4ResponseReceiver>)_obj;
102 - (void)removeFromResponseNotification:(id<NGImap4ResponseReceiver>)_obj;
103
104 /* connection */
105
106 - (NSDictionary *)openConnection;
107 - (void)closeConnection;
108 - (NSNumber *)isConnected;
109 - (void)reconnect;
110
111 /* commands */
112
113 - (NSDictionary *)login:(NSString *)_login password:(NSString *)_passwd;
114 - (NSDictionary *)logout;
115 - (NSDictionary *)noop;
116   
117 - (NSDictionary *)capability;
118 - (NSDictionary *)list:(NSString *)_folder pattern:(NSString *)_pattern;
119 - (NSDictionary *)lsub:(NSString *)_folder pattern:(NSString *)_pattern;
120 - (NSDictionary *)select:(NSString *)_folder;
121 - (NSDictionary *)status:(NSString *)_folder flags:(NSArray *)_flags;
122 - (NSDictionary *)rename:(NSString *)_folder to:(NSString *)_newName;
123 - (NSDictionary *)delete:(NSString *)_folder;
124 - (NSDictionary *)create:(NSString *)_name;
125 - (NSDictionary *)subscribe:(NSString *)_name;
126 - (NSDictionary *)unsubscribe:(NSString *)_name;
127 - (NSDictionary *)expunge;
128   
129 - (NSDictionary *)sort:(NSArray *)_sortOrderings
130   qualifier:(EOQualifier *)_qual
131   encoding:(NSString *)_encoding;
132 - (NSDictionary *)fetchUids:(NSArray *)_uids parts:(NSArray *)_parts;
133 - (NSDictionary *)fetchUid:(unsigned)_uid    parts:(NSArray *)_parts;
134 - (NSDictionary *)fetchFrom:(unsigned)_from to:(unsigned)_to
135   parts:(NSArray *)_parts;
136 - (NSDictionary *)storeUid:(unsigned)_uid add:(NSNumber *)_add
137   flags:(NSArray *)_flags;
138 - (NSDictionary *)storeFrom:(unsigned)_from to:(unsigned)_to
139   add:(NSNumber *)_add flags:(NSArray *)_flags;
140 - (NSDictionary *)copyUid:(unsigned)_uid toFolder:(NSString *)_folder;
141 - (NSDictionary *)copyFrom:(unsigned)_from to:(unsigned)_to
142   toFolder:(NSString *)_folder;
143 - (NSDictionary *)append:(NSData *)_message toFolder:(NSString *)_folder
144   withFlags:(NSArray *)_flags;
145 - (NSDictionary *)threadBySubject:(BOOL)_bySubject
146   charset:(NSString *)_charSet;
147 - (NSDictionary *)getQuotaRoot:(NSString *)_folder;
148
149 - (NSDictionary *)searchWithQualifier:(EOQualifier *)_qualifier;
150
151 /* context accessors (DEPRECATED) */
152
153 - (void)setContext:(NGImap4Context *)_ctx;
154 - (NGImap4Context *)context;
155
156 /* raw methods */
157
158 - (NSDictionary *)primarySort:(NSString *)_sortString
159   qualifierString:(NSString *)_qualString
160   encoding:(NSString *)_encoding;
161
162 @end
163
164 #endif /* __SOPE_NGImap4_NGImap4Client_H__ */