move url.[hc] into the lib-lib.
[apps/madmutt.git] / imap / imap_private.h
index 0a55409..eecc798 100644 (file)
@@ -1,27 +1,22 @@
 /*
+ * Copyright notice from original mutt:
  * Copyright (C) 1996-9 Brandon Long <blong@fiction.net>
  * Copyright (C) 1999-2001 Brendan Cully <brendan@kublai.com>
- * 
- *     This program is free software; you can redistribute it and/or modify
- *     it under the terms of the GNU General Public License as published by
- *     the Free Software Foundation; either version 2 of the License, or
- *     (at your option) any later version.
- * 
- *     This program is distributed in the hope that it will be useful,
- *     but WITHOUT ANY WARRANTY; without even the implied warranty of
- *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *     GNU General Public License for more details.
- * 
- *     You should have received a copy of the GNU General Public License
- *     along with this program; if not, write to the Free Software
- *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ *
+ * This file is part of mutt-ng, see http://www.muttng.org/.
+ * It's licensed under the GNU General Public License,
+ * please see the file GPL in the top level source directory.
+ */
 
 #ifndef _IMAP_PRIVATE_H
 #define _IMAP_PRIVATE_H 1
 
+#include <inttypes.h>
+
+#include <lib-ui/curses.h>
+
 #include "imap.h"
-#include "mutt_socket.h"
+#include <lib-sys/mutt_socket.h>
 
 /* -- symbols -- */
 #define IMAP_PORT 143
 #define IMAP_CMD_FAIL_OK (1<<0)
 #define IMAP_CMD_PASS    (1<<1)
 
-enum
-{
+enum {
   IMAP_FATAL = 1,
   IMAP_BYE,
   IMAP_REOPENED
 };
 
-enum
-{
+enum {
   /* States */
   IMAP_DISCONNECTED = 0,
   IMAP_CONNECTED,
@@ -75,43 +68,27 @@ enum
   IMAP_SELECTED
 };
 
-enum
-{
+enum {
   /* Namespace types */
   IMAP_NS_PERSONAL = 0,
   IMAP_NS_OTHER,
   IMAP_NS_SHARED
 };
 
-/* ACL Rights */
-enum
-{
-  IMAP_ACL_LOOKUP = 0,
-  IMAP_ACL_READ,
-  IMAP_ACL_SEEN,
-  IMAP_ACL_WRITE,
-  IMAP_ACL_INSERT,
-  IMAP_ACL_POST,
-  IMAP_ACL_CREATE,
-  IMAP_ACL_DELETE,
-  IMAP_ACL_ADMIN,
-
-  RIGHTSMAX
-};
+/* ACL Rights are moved to ../mx.h */
 
 /* Capabilities we are interested in */
-enum
-{
+enum {
   IMAP4 = 0,
   IMAP4REV1,
   STATUS,
-  ACL,                         /* RFC 2086: IMAP4 ACL extension */
-  NAMESPACE,                           /* RFC 2342: IMAP4 Namespace */
-  ACRAM_MD5,                   /* RFC 2195: CRAM-MD5 authentication */
-  AGSSAPI,                     /* RFC 1731: GSSAPI authentication */
-  AUTH_ANON,                   /* AUTH=ANONYMOUS */
-  STARTTLS,                    /* RFC 2595: STARTTLS */
-  LOGINDISABLED,               /*           LOGINDISABLED */
+  ACL,                          /* RFC 2086: IMAP4 ACL extension */
+  NAMESPACE,                    /* RFC 2342: IMAP4 Namespace */
+  ACRAM_MD5,                    /* RFC 2195: CRAM-MD5 authentication */
+  AGSSAPI,                      /* RFC 1731: GSSAPI authentication */
+  AUTH_ANON,                    /* AUTH=ANONYMOUS */
+  STARTTLS,                     /* RFC 2595: STARTTLS */
+  LOGINDISABLED,                /*           LOGINDISABLED */
 
   CAPMAX
 };
@@ -121,35 +98,31 @@ enum
 #define M_IMAP_CONN_NOSELECT (1<<1)
 
 /* -- data structures -- */
-typedef struct
-{
+typedef struct {
   unsigned int uid;
-  charpath;
+  char *path;
 } IMAP_CACHE;
 
-typedef struct 
-{
+typedef struct {
   int type;
   int listable;
   char *prefix;
   char delim;
   int home_namespace;
   /* We get these when we check if namespace exists - cache them */
-  int noselect;                        
+  int noselect;
   int noinferiors;
 } IMAP_NAMESPACE_INFO;
 
 /* IMAP command structure */
-typedef struct
-{
-  char seq[SEQLEN+1];
-  char* buf;
+typedef struct {
+  char seq[SEQLEN + 1];
+  char *buf;
   unsigned int blen;
   int state;
 } IMAP_COMMAND;
 
-typedef struct
-{
+typedef struct {
   /* This data is specific to a CONNECTION to an IMAP server */
   CONNECTION *conn;
   unsigned char state;
@@ -162,10 +135,10 @@ typedef struct
    * I've chosen (3) for now. (2) might not be too bad, but it involves
    * tracking all possible capabilities. bah. (1) I don't like because
    * it's just no fun to get the same information twice */
-  charcapstr;
-  unsigned char capabilities[(CAPMAX + 7)/8];
+  char *capstr;
+  unsigned char capabilities[(CAPMAX + 7) / 8];
   unsigned int seqno;
-  time_t lastread; /* last time we read a command for the server */
+  time_t lastread;              /* last time we read a command for the server */
   /* who knows, one day we may run multiple commands in parallel */
   IMAP_COMMAND cmd;
 
@@ -175,14 +148,17 @@ typedef struct
   char *mailbox;
   unsigned short check_status;
   unsigned char reopen;
-  unsigned char rights[(RIGHTSMAX + 7)/8];
+  unsigned char rights[(RIGHTSMAX + 7) / 8];
   unsigned int newMailCount;
   IMAP_CACHE cache[IMAP_CACHE_LEN];
-  int noclose : 1;
-  
+#ifdef USE_HCACHE
+  unsigned long uid_validity;
+#endif
+
   /* all folder flags - system flags AND keywords */
   LIST *flags;
 } IMAP_DATA;
+
 /* I wish that were called IMAP_CONTEXT :( */
 
 /* -- macros -- */
@@ -190,49 +166,55 @@ typedef struct
 
 /* -- private IMAP functions -- */
 /* imap.c */
-int imap_create_mailbox (IMAP_DATA* idata, char* mailbox);
-int imap_make_msg_set (IMAP_DATA* idata, BUFFER* buf, int flag, int changed);
-int imap_open_connection (IMAP_DATA* idata);
-IMAP_DATA* imap_conn_find (const ACCOUNT* account, int flags);
-int imap_parse_list_response(IMAP_DATA* idata, char** name, int* noselect,
-  int* noinferiors, char* delim);
-int imap_read_literal (FILE* fp, IMAP_DATA* idata, long bytes);
-void imap_expunge_mailbox (IMAP_DATA* idata);
-void imap_logout (IMAP_DATA* idata);
+int imap_create_mailbox (IMAP_DATA * idata, char *mailbox);
+int imap_rename_mailbox (IMAP_DATA * idata, IMAP_MBOX * mx,
+                         const char *newname);
+int imap_make_msg_set (IMAP_DATA * idata, BUFFER * buf, int flag,
+                       int changed);
+int imap_open_connection (IMAP_DATA * idata);
+IMAP_DATA *imap_conn_find (const ACCOUNT * account, int flags);
+int imap_parse_list_response (IMAP_DATA * idata, char **name, int *noselect,
+                              int *noinferiors, char *delim);
+int imap_read_literal (FILE * fp, IMAP_DATA * idata, long bytes, progress_t*);
+void imap_expunge_mailbox (IMAP_DATA * idata);
+int imap_reconnect (CONTEXT * ctx);
+void imap_logout (IMAP_DATA * idata);
+int imap_sync_message (IMAP_DATA*, HEADER*, BUFFER*, int*);
 
 /* auth.c */
-int imap_authenticate (IMAP_DATA* idata);
+int imap_authenticate (IMAP_DATA * idata);
 
 /* command.c */
-int imap_cmd_start (IMAP_DATA* idata, const char* cmd);
-int imap_cmd_step (IMAP_DATA* idata);
-void imap_cmd_finish (IMAP_DATA* idata);
-int imap_code (const chars);
-int imap_exec (IMAP_DATA* idata, const char* cmd, int flags);
+int imap_cmd_start (IMAP_DATA * idata, const char *cmd);
+int imap_cmd_step (IMAP_DATA * idata);
+void imap_cmd_finish (IMAP_DATA * idata);
+int imap_code (const char *s);
+int imap_exec (IMAP_DATA * idata, const char *cmd, int flags);
 
 /* message.c */
-void imap_add_keywords (char* s, HEADER* keywords, LIST* mailbox_flags, size_t slen);
-void imap_free_header_data (void** data);
-int imap_read_headers (IMAP_DATA* idata, int msgbegin, int msgend);
-char* imap_set_flags (IMAP_DATA* idata, HEADER* h, char* s);
+void imap_add_keywords (char *s, HEADER * keywords, LIST * mailbox_flags,
+                        size_t slen);
+void imap_free_header_data (void **data);
+int imap_read_headers (IMAP_DATA * idata, int msgbegin, int msgend);
+char *imap_set_flags (IMAP_DATA * idata, HEADER * h, char *s);
 
 /* util.c */
-int imap_continue (const char* msg, const char* resp);
-void imap_error (const char* where, const char* msg);
-IMAP_DATAimap_new_idata (void);
-void imap_free_idata (IMAP_DATA** idata);
-char* imap_fix_path (IMAP_DATA* idata, char* mailbox, char* path, 
-  size_t plen);
-int imap_get_literal_count (const char* buf, long* bytes);
-char* imap_get_qualifier (char* buf);
-char* imap_next_word (char* s);
-time_t imap_parse_date (chars);
-void imap_qualify_path (char *dest, size_t len, IMAP_MBOX *mx, char* path);
-void imap_quote_string (char* dest, size_t slen, const char* src);
-void imap_unquote_string (chars);
+int imap_continue (const char *msg, const char *resp);
+void imap_error (const char *where, const char *msg);
+IMAP_DATA *imap_new_idata (void);
+void imap_free_idata (IMAP_DATA ** idata);
+char *imap_fix_path (IMAP_DATA * idata, char *mailbox, char *path,
+                     size_t plen);
+int imap_get_literal_count (const char *buf, long *bytes);
+char *imap_get_qualifier (char *buf);
+char *imap_next_word (char *s);
+time_t imap_parse_date (char *s);
+void imap_qualify_path (char *dest, size_t len, IMAP_MBOX * mx, char *path);
+void imap_quote_string (char *dest, size_t slen, const char *src);
+void imap_unquote_string (char *s);
 void imap_munge_mbox_name (char *dest, size_t dlen, const char *src);
 void imap_unmunge_mbox_name (char *s);
-int imap_wordcasecmp(const char *a, const char *b);
+int imap_wordcasecmp (const char *a, const char *b);
 
 /* utf7.c */
 void imap_utf7_encode (char **s);