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

Diff of /imapfilter/request.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

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

Legend:
Removed from v.1.54.2.1  
changed lines
  Added in v.1.63

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26