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

Contents of /imapfilter/request.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.54.2.1 - (show annotations)
Fri Aug 8 00:28:03 2003 UTC (20 years, 7 months ago) by lefcha
Branch: release-0_9-patches
Changes since 1.54: +0 -2 lines
File MIME type: text/plain
Corrected headers includes.

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

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26