/[imapfilter]/imapfilter/request.c
ViewVC logotype

Contents of /imapfilter/request.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.63 - (show annotations)
Sun Feb 15 15:31:54 2004 UTC (20 years, 1 month ago) by lefcha
Branch: MAIN
CVS Tags: HEAD
Changes since 1.62: +2 -2 lines
File MIME type: text/plain
Renamed variable.

1 #include "config.h"
2 #include "imapfilter.h"
3
4
5 extern connection_t connpri, connaux;
6 extern options_t opts;
7
8
9 /*
10 * Test/ping server.
11 */
12 int
13 test(connection_t * conn)
14 {
15
16 return response_generic(conn, imap_noop(conn));
17 }
18
19
20 /*
21 * Check server's capabilities.
22 */
23 int
24 check_capabilities(connection_t * conn)
25 {
26
27 conn->proto = PROTOCOL_NONE;
28 conn->caps = CAPABILITY_NONE;
29
30 return response_capability(conn, imap_capability(conn));
31 }
32
33
34 /*
35 * Get namespace of mail server's mailboxes.
36 */
37 int
38 check_namespace(connection_t * conn)
39 {
40
41 conn->ns.prefix[0] = conn->ns.delim = '\0';
42
43 if (!opts.namespace || !(conn->caps & CAPABILITY_NAMESPACE))
44 return 0;
45 else
46 return response_namespace(conn, imap_namespace(conn));
47 }
48
49
50 #ifdef SSL_TLS
51 /*
52 * Begin TLS negotiation (STARTTLS).
53 */
54 int
55 negotiate_tls(connection_t * conn)
56 {
57 int r;
58
59 r = response_generic(conn, imap_starttls(conn));
60 init_secure_connection(conn, SSL_TLS_V1);
61
62 return r;
63 }
64 #endif
65
66
67 /*
68 * Login to server.
69 */
70 int
71 login(connection_t * conn, char *user, char *pass)
72 {
73
74 return response_generic(conn, imap_login(conn, user, pass));
75 }
76
77
78
79 /*
80 * Check if a mailbox exists.
81 */
82 int
83 check_mailbox(connection_t * conn, char *mbox)
84 {
85
86 return response_generic(conn, imap_examine(conn, mbox));
87 }
88
89
90 /*
91 * Open mailbox in read-write mode.
92 */
93 int
94 select_mailbox(connection_t * conn, char *mbox)
95 {
96 int r;
97
98 if (mailbox_status(conn, mbox) == -2)
99 return -2; /* No messages exist. No filters need to be
100 * applied. */
101
102 r = response_select(conn, imap_select(conn,
103 apply_namespace(mbox, conn->ns.prefix, conn->ns.delim)));
104
105 log_info(LOG_MBOX, mbox);
106
107 return r;
108 }
109
110
111 /*
112 * Get mailbox's status.
113 */
114 int
115 mailbox_status(connection_t * conn, char *mbox)
116 {
117 if (conn->proto == PROTOCOL_IMAP4REV1)
118 return response_status(conn, imap_status(conn,
119 apply_namespace(mbox, conn->ns.prefix, conn->ns.delim),
120 "MESSAGES RECENT UNSEEN"), mbox);
121 else
122 return response_examine(conn, imap_examine(conn,
123 apply_namespace(mbox, conn->ns.prefix, conn->ns.delim)),
124 mbox);
125 }
126
127
128 /*
129 * Close examined/selected mailbox.
130 */
131 int
132 close_mailbox(connection_t * conn)
133 {
134
135 return response_generic(conn, imap_close(conn));
136 }
137
138
139 /*
140 * Logout from server.
141 */
142 int
143 logout(connection_t * conn)
144 {
145
146 return response_logout(conn, imap_logout(conn));
147 }

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26