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

Contents of /imapfilter/request.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.58 - (show annotations)
Fri Feb 13 12:17:16 2004 UTC (20 years, 1 month ago) by lefcha
Branch: MAIN
Changes since 1.57: +28 -28 lines
File MIME type: text/plain
Stylistic changes.

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

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26