Fix FSF address (Tobias Mueller, #470445)
[platform/upstream/evolution-data-server.git] / camel / providers / imap / camel-imap-store.h
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /* camel-imap-store.h : class for an imap store */
3
4 /* 
5  * Authors: Jeffrey Stedfast <fejj@ximian.com>
6  *
7  * Copyright (C) 2000 Ximian, Inc.
8  *
9  * This program is free software; you can redistribute it and/or 
10  * modify it under the terms of version 2 of the GNU Lesser General Public 
11  * License as published by the Free Software Foundation.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
21  * USA
22  */
23
24
25 #ifndef CAMEL_IMAP_STORE_H
26 #define CAMEL_IMAP_STORE_H 1
27
28 #include "camel-imap-types.h"
29 #include <camel/camel-disco-store.h>
30 #include <sys/time.h>
31
32 #ifdef ENABLE_THREADS
33 #include <libedataserver/e-msgport.h>
34
35 G_BEGIN_DECLS
36
37 typedef struct _CamelImapMsg CamelImapMsg;
38
39 struct _CamelImapMsg {
40         EMsg msg;
41
42         void (*receive)(CamelImapStore *store, struct _CamelImapMsg *m);
43         void (*free)(CamelImapStore *store, struct _CamelImapMsg *m);
44 };
45
46 CamelImapMsg *camel_imap_msg_new(void (*receive)(CamelImapStore *store, struct _CamelImapMsg *m),
47                                  void (*free)(CamelImapStore *store, struct _CamelImapMsg *m),
48                                  size_t size);
49 void camel_imap_msg_queue(CamelImapStore *store, CamelImapMsg *msg);
50
51 G_END_DECLS
52
53 #endif
54
55 #define CAMEL_IMAP_STORE_TYPE     (camel_imap_store_get_type ())
56 #define CAMEL_IMAP_STORE(obj)     (CAMEL_CHECK_CAST((obj), CAMEL_IMAP_STORE_TYPE, CamelImapStore))
57 #define CAMEL_IMAP_STORE_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_IMAP_STORE_TYPE, CamelImapStoreClass))
58 #define CAMEL_IS_IMAP_STORE(o)    (CAMEL_CHECK_TYPE((o), CAMEL_IMAP_STORE_TYPE))
59
60 G_BEGIN_DECLS
61
62 enum {
63         CAMEL_IMAP_STORE_ARG_FIRST  = CAMEL_DISCO_STORE_ARG_FIRST + 100,
64         CAMEL_IMAP_STORE_ARG_NAMESPACE,
65         CAMEL_IMAP_STORE_ARG_OVERRIDE_NAMESPACE,
66         CAMEL_IMAP_STORE_ARG_CHECK_ALL,
67         CAMEL_IMAP_STORE_ARG_FILTER_INBOX,
68         CAMEL_IMAP_STORE_ARG_FILTER_JUNK,
69         CAMEL_IMAP_STORE_ARG_FILTER_JUNK_INBOX,
70 };
71
72 #define CAMEL_IMAP_STORE_NAMESPACE           (CAMEL_IMAP_STORE_ARG_NAMESPACE | CAMEL_ARG_STR)
73 #define CAMEL_IMAP_STORE_OVERRIDE_NAMESPACE  (CAMEL_IMAP_STORE_ARG_OVERRIDE_NAMESPACE | CAMEL_ARG_INT)
74 #define CAMEL_IMAP_STORE_CHECK_ALL           (CAMEL_IMAP_STORE_ARG_CHECK_ALL | CAMEL_ARG_INT)
75 #define CAMEL_IMAP_STORE_FILTER_INBOX        (CAMEL_IMAP_STORE_ARG_FILTER_INBOX | CAMEL_ARG_INT)
76 #define CAMEL_IMAP_STORE_FILTER_JUNK         (CAMEL_IMAP_STORE_ARG_FILTER_JUNK | CAMEL_ARG_BOO)
77 #define CAMEL_IMAP_STORE_FILTER_JUNK_INBOX   (CAMEL_IMAP_STORE_ARG_FILTER_JUNK_INBOX | CAMEL_ARG_BOO)
78
79 /* CamelFolderInfo flags */
80 #define CAMEL_IMAP_FOLDER_MARKED             (1<<16)
81 #define CAMEL_IMAP_FOLDER_UNMARKED           (1<<17)
82
83 typedef enum {
84         IMAP_LEVEL_UNKNOWN,
85         IMAP_LEVEL_IMAP4,
86         IMAP_LEVEL_IMAP4REV1
87 } CamelImapServerLevel;
88
89 #define IMAP_CAPABILITY_IMAP4                   (1 << 0)
90 #define IMAP_CAPABILITY_IMAP4REV1               (1 << 1)
91 #define IMAP_CAPABILITY_STATUS                  (1 << 2)
92 #define IMAP_CAPABILITY_NAMESPACE               (1 << 3)
93 #define IMAP_CAPABILITY_UIDPLUS                 (1 << 4)
94 #define IMAP_CAPABILITY_LITERALPLUS             (1 << 5)
95 #define IMAP_CAPABILITY_STARTTLS                (1 << 6)
96 #define IMAP_CAPABILITY_useful_lsub             (1 << 7)
97 #define IMAP_CAPABILITY_utf8_search             (1 << 8)
98 #define IMAP_CAPABILITY_XGWEXTENSIONS           (1 << 9)
99 #define IMAP_CAPABILITY_XGWMOVE                 (1 << 10)
100 #define IMAP_CAPABILITY_LOGINDISABLED           (1 << 11)
101
102 #define IMAP_PARAM_OVERRIDE_NAMESPACE           (1 << 0)
103 #define IMAP_PARAM_CHECK_ALL                    (1 << 1)
104 #define IMAP_PARAM_FILTER_INBOX                 (1 << 2)
105 #define IMAP_PARAM_FILTER_JUNK                  (1 << 3)
106 #define IMAP_PARAM_FILTER_JUNK_INBOX            (1 << 4)
107 #define IMAP_PARAM_SUBSCRIPTIONS                (1 << 5)
108
109 #define IMAP_FETCH_ALL_HEADERS 1
110 #define IMAP_FETCH_MAILING_LIST_HEADERS 2 /* Fetches Minimal and Mailing List Headers. Default behavior */
111 #define IMAP_FETCH_MINIMAL_HEADERS 3
112
113 struct _CamelImapStore {
114         CamelDiscoStore parent_object;  
115         
116         CamelStream *istream;
117         CamelStream *ostream;
118
119         struct _CamelImapStoreSummary *summary;
120         
121         /* Information about the command channel / connection status */
122         guint connected:1;
123         guint preauthed:1;
124
125         /* broken server - don't use BODY, dont use partial fetches for message retrival */
126         guint braindamaged:1;
127         guint renaming:1;
128         /* broken server - wont let us append with custom flags even if the folder allows them */
129         guint nocustomappend:1;
130
131         char tag_prefix;
132         guint32 command;
133         CamelFolder *current_folder;
134         
135         /* Information about the server */
136         CamelImapServerLevel server_level;
137         guint32 capabilities, parameters;
138         /* NB: namespace should be handled by summary->namespace */
139         char *namespace, dir_sep, *base_url, *storage_path;
140         GHashTable *authtypes;
141         
142         time_t refresh_stamp;
143
144         guint32 headers;
145         char *custom_headers;
146 };
147
148 typedef struct {
149         CamelDiscoStoreClass parent_class;
150
151 } CamelImapStoreClass;
152
153
154 /* Standard Camel function */
155 CamelType camel_imap_store_get_type (void);
156
157
158 gboolean camel_imap_store_connected (CamelImapStore *store, CamelException *ex);
159
160 ssize_t camel_imap_store_readline (CamelImapStore *store, char **dest, CamelException *ex);
161
162 G_END_DECLS
163
164 #endif /* CAMEL_IMAP_STORE_H */