NeoMutt  2021-02-05-89-gabe350
Teaching an old dog new tricks
DOXYGEN
private.h File Reference
#include "config.h"
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <time.h>
#include "mutt/lib.h"
#include "config/lib.h"
#include "mutt.h"
#include "hcache/lib.h"
#include "adata.h"
#include "mdata.h"
+ Include dependency graph for private.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ImapList
 Items in an IMAP browser. More...
 
struct  ImapCommand
 IMAP command structure. More...
 
struct  SeqsetIterator
 UID Sequence Set Iterator. More...
 

Macros

#define IMAP_PORT   143
 Default port for IMAP. More...
 
#define IMAP_SSL_PORT   993
 Port for IMAP over SSL/TLS. More...
 
#define IMAP_LOG_CMD   2
 
#define IMAP_LOG_LTRL   3
 
#define IMAP_LOG_PASS   5
 
#define IMAP_RES_NO   -2
 <tag> NO ... More...
 
#define IMAP_RES_BAD   -1
 <tag> BAD ... More...
 
#define IMAP_RES_OK   0
 <tag> OK ... More...
 
#define IMAP_RES_CONTINUE   1
 * ... More...
 
#define IMAP_RES_RESPOND   2
 + More...
 
#define IMAP_RES_NEW   3
 ImapCommand.state additions. More...
 
#define SEQ_LEN   16
 
#define IMAP_MAX_CMDLEN   1024
 Maximum length of command lines before they must be split (for lazy servers) More...
 
#define IMAP_OPEN_NO_FLAGS   0
 No flags are set. More...
 
#define IMAP_REOPEN_ALLOW   (1 << 0)
 Allow re-opening a folder upon expunge. More...
 
#define IMAP_EXPUNGE_EXPECTED   (1 << 1)
 Messages will be expunged from the server. More...
 
#define IMAP_EXPUNGE_PENDING   (1 << 2)
 Messages on the server have been expunged. More...
 
#define IMAP_NEWMAIL_PENDING   (1 << 3)
 New mail is waiting on the server. More...
 
#define IMAP_FLAGS_PENDING   (1 << 4)
 Flags have changed on the server. More...
 
#define IMAP_CMD_NO_FLAGS   0
 No flags are set. More...
 
#define IMAP_CMD_PASS   (1 << 0)
 Command contains a password. Suppress logging. More...
 
#define IMAP_CMD_QUEUE   (1 << 1)
 Queue a command, do not execute. More...
 
#define IMAP_CMD_POLL   (1 << 2)
 Poll the tcp connection before running the imap command. More...
 
#define IMAP_CMD_SINGLE   (1 << 3)
 Run a single command. More...
 
#define IMAP_DATELEN   27
 
#define IMAP_CAP_NO_FLAGS   0
 No flags are set. More...
 
#define IMAP_CAP_IMAP4   (1 << 0)
 Server supports IMAP4. More...
 
#define IMAP_CAP_IMAP4REV1   (1 << 1)
 Server supports IMAP4rev1. More...
 
#define IMAP_CAP_STATUS   (1 << 2)
 Server supports STATUS command. More...
 
#define IMAP_CAP_ACL   (1 << 3)
 RFC2086: IMAP4 ACL extension. More...
 
#define IMAP_CAP_NAMESPACE   (1 << 4)
 RFC2342: IMAP4 Namespace. More...
 
#define IMAP_CAP_AUTH_CRAM_MD5   (1 << 5)
 RFC2195: CRAM-MD5 authentication. More...
 
#define IMAP_CAP_AUTH_GSSAPI   (1 << 6)
 RFC1731: GSSAPI authentication. More...
 
#define IMAP_CAP_AUTH_ANONYMOUS   (1 << 7)
 AUTH=ANONYMOUS. More...
 
#define IMAP_CAP_AUTH_OAUTHBEARER   (1 << 8)
 RFC7628: AUTH=OAUTHBEARER. More...
 
#define IMAP_CAP_STARTTLS   (1 << 9)
 RFC2595: STARTTLS. More...
 
#define IMAP_CAP_LOGINDISABLED   (1 << 10)
 RFC2595: LOGINDISABLED. More...
 
#define IMAP_CAP_IDLE   (1 << 11)
 RFC2177: IDLE. More...
 
#define IMAP_CAP_SASL_IR   (1 << 12)
 SASL initial response draft. More...
 
#define IMAP_CAP_ENABLE   (1 << 13)
 RFC5161. More...
 
#define IMAP_CAP_CONDSTORE   (1 << 14)
 RFC7162. More...
 
#define IMAP_CAP_QRESYNC   (1 << 15)
 RFC7162. More...
 
#define IMAP_CAP_LIST_EXTENDED   (1 << 16)
 RFC5258: IMAP4 LIST Command Extensions. More...
 
#define IMAP_CAP_COMPRESS   (1 << 17)
 RFC4978: COMPRESS=DEFLATE. More...
 
#define IMAP_CAP_X_GM_EXT_1   (1 << 18)
 https://developers.google.com/gmail/imap/imap-extensions More...
 
#define IMAP_CAP_ALL   ((1 << 19) - 1)
 

Typedefs

typedef uint8_t ImapOpenFlags
 Flags, e.g. MUTT_THREAD_COLLAPSE. More...
 
typedef uint8_t ImapCmdFlags
 Flags for imap_exec(), e.g. IMAP_CMD_PASS. More...
 
typedef uint32_t ImapCapFlags
 Capabilities we are interested in. More...
 

Enumerations

enum  ImapExecResult { IMAP_EXEC_SUCCESS = 0, IMAP_EXEC_ERROR, IMAP_EXEC_FATAL }
 imap_exec return code More...
 
enum  ImapFlags { IMAP_FATAL = 1, IMAP_BYE }
 IMAP server responses. More...
 
enum  ImapState {
  IMAP_DISCONNECTED = 0, IMAP_CONNECTED, IMAP_AUTHENTICATED, IMAP_SELECTED,
  IMAP_IDLE
}
 IMAP connection state. More...
 

Functions

int imap_create_mailbox (struct ImapAccountData *adata, char *mailbox)
 Create a new mailbox. More...
 
int imap_rename_mailbox (struct ImapAccountData *adata, char *oldname, const char *newname)
 Rename a mailbox. More...
 
int imap_exec_msgset (struct Mailbox *m, const char *pre, const char *post, enum MessageType flag, bool changed, bool invert)
 Prepare commands for all messages matching conditions. More...
 
int imap_open_connection (struct ImapAccountData *adata)
 Open an IMAP connection. More...
 
void imap_close_connection (struct ImapAccountData *adata)
 Close an IMAP connection. More...
 
int imap_read_literal (FILE *fp, struct ImapAccountData *adata, unsigned long bytes, struct Progress *pbar)
 Read bytes bytes from server into file. More...
 
void imap_expunge_mailbox (struct Mailbox *m)
 Purge messages from the server. More...
 
int imap_login (struct ImapAccountData *adata)
 Open an IMAP connection. More...
 
int imap_sync_message_for_copy (struct Mailbox *m, struct Email *e, struct Buffer *cmd, enum QuadOption *err_continue)
 Update server to reflect the flags of a single message. More...
 
bool imap_has_flag (struct ListHead *flag_list, const char *flag)
 Does the flag exist in the list. More...
 
int imap_adata_find (const char *path, struct ImapAccountData **adata, struct ImapMboxData **mdata)
 Find the Account data for this path. More...
 
int imap_authenticate (struct ImapAccountData *adata)
 Authenticate to an IMAP server. More...
 
int imap_cmd_start (struct ImapAccountData *adata, const char *cmdstr)
 Given an IMAP command, send it to the server. More...
 
int imap_cmd_step (struct ImapAccountData *adata)
 Reads server responses from an IMAP command. More...
 
void imap_cmd_finish (struct ImapAccountData *adata)
 Attempt to perform cleanup. More...
 
bool imap_code (const char *s)
 Was the command successful. More...
 
const char * imap_cmd_trailer (struct ImapAccountData *adata)
 Extra information after tagged command response if any. More...
 
int imap_exec (struct ImapAccountData *adata, const char *cmdstr, ImapCmdFlags flags)
 Execute a command and wait for the response from the server. More...
 
int imap_cmd_idle (struct ImapAccountData *adata)
 Enter the IDLE state. More...
 
int imap_read_headers (struct Mailbox *m, unsigned int msn_begin, unsigned int msn_end, bool initial_download)
 Read headers from the server. More...
 
char * imap_set_flags (struct Mailbox *m, struct Email *e, char *s, bool *server_changes)
 fill the message header according to the server flags More...
 
int imap_cache_del (struct Mailbox *m, struct Email *e)
 Delete an email from the body cache. More...
 
int imap_cache_clean (struct Mailbox *m)
 Delete all the entries in the message cache. More...
 
int imap_append_message (struct Mailbox *m, struct Message *msg)
 Write an email back to the server. More...
 
bool imap_msg_open (struct Mailbox *m, struct Message *msg, int msgno)
 Open an email message in a Mailbox - Implements MxOps::msg_open() More...
 
int imap_msg_close (struct Mailbox *m, struct Message *msg)
 Close an email - Implements MxOps::msg_close() More...
 
int imap_msg_commit (struct Mailbox *m, struct Message *msg)
 Save changes to an email - Implements MxOps::msg_commit() More...
 
int imap_msg_save_hcache (struct Mailbox *m, struct Email *e)
 Save message to the header cache - Implements MxOps::msg_save_hcache() More...
 
void imap_hcache_open (struct ImapAccountData *adata, struct ImapMboxData *mdata)
 Open a header cache. More...
 
void imap_hcache_close (struct ImapMboxData *mdata)
 Close the header cache. More...
 
struct Emailimap_hcache_get (struct ImapMboxData *mdata, unsigned int uid)
 Get a header cache entry by its UID. More...
 
int imap_hcache_put (struct ImapMboxData *mdata, struct Email *e)
 Add an entry to the header cache. More...
 
int imap_hcache_del (struct ImapMboxData *mdata, unsigned int uid)
 Delete an item from the header cache. More...
 
int imap_hcache_store_uid_seqset (struct ImapMboxData *mdata)
 Store a UID Sequence Set in the header cache. More...
 
int imap_hcache_clear_uid_seqset (struct ImapMboxData *mdata)
 Delete a UID Sequence Set from the header cache. More...
 
char * imap_hcache_get_uid_seqset (struct ImapMboxData *mdata)
 Get a UID Sequence Set from the header cache. More...
 
enum QuadOption imap_continue (const char *msg, const char *resp)
 display a message and ask the user if they want to go on More...
 
void imap_error (const char *where, const char *msg)
 show an error and abort More...
 
void imap_mdata_cache_reset (struct ImapMboxData *mdata)
 Release and clear cache data of ImapMboxData structure. More...
 
char * imap_fix_path (char delim, const char *mailbox, char *path, size_t plen)
 Fix up the imap path. More...
 
void imap_cachepath (char delim, const char *mailbox, struct Buffer *dest)
 Generate a cache path for a mailbox. More...
 
int imap_get_literal_count (const char *buf, unsigned int *bytes)
 write number of bytes in an IMAP literal into bytes More...
 
char * imap_get_qualifier (char *buf)
 Get the qualifier from a tagged response. More...
 
char * imap_next_word (char *s)
 Find where the next IMAP word begins. More...
 
void imap_qualify_path (char *buf, size_t buflen, struct ConnAccount *conn_account, char *path)
 Make an absolute IMAP folder target. More...
 
void imap_quote_string (char *dest, size_t dlen, const char *src, bool quote_backtick)
 quote string according to IMAP rules More...
 
void imap_unquote_string (char *s)
 equally stupid unquoting routine More...
 
void imap_munge_mbox_name (bool unicode, char *dest, size_t dlen, const char *src)
 Quote awkward characters in a mailbox name. More...
 
void imap_unmunge_mbox_name (bool unicode, char *s)
 Remove quoting from a mailbox name. More...
 
struct SeqsetIteratormutt_seqset_iterator_new (const char *seqset)
 Create a new Sequence Set Iterator. More...
 
int mutt_seqset_iterator_next (struct SeqsetIterator *iter, unsigned int *next)
 Get the next UID from a Sequence Set. More...
 
void mutt_seqset_iterator_free (struct SeqsetIterator **ptr)
 Free a Sequence Set Iterator. More...
 
bool imap_account_match (const struct ConnAccount *a1, const struct ConnAccount *a2)
 Compare two Accounts. More...
 
void imap_get_parent (const char *mbox, char delim, char *buf, size_t buflen)
 Get an IMAP folder's parent. More...
 
bool mutt_account_match (const struct ConnAccount *a1, const struct ConnAccount *a2)
 
void imap_utf_encode (bool unicode, char **s)
 Encode email from local charset to UTF-8. More...
 
void imap_utf_decode (bool unicode, char **s)
 Decode email from UTF-8 to local charset. More...
 
void imap_allow_reopen (struct Mailbox *m)
 Allow re-opening a folder upon expunge. More...
 
void imap_disallow_reopen (struct Mailbox *m)
 Disallow re-opening a folder upon expunge. More...
 
void cmd_parse_search (struct ImapAccountData *adata, const char *s)
 store SEARCH response for later use More...
 

Variables

struct SlistC_ImapAuthenticators
 Config: (imap) List of allowed IMAP authentication methods. More...
 
bool C_ImapCheckSubscribed
 Config: (imap) When opening a mailbox, ask the server for a list of subscribed folders. More...
 
bool C_ImapCondstore
 Config: (imap) Enable the CONDSTORE extension. More...
 
bool C_ImapDeflate
 Config: (imap) Compress network traffic. More...
 
char * C_ImapDelimChars
 Config: (imap) Characters that denote separators in IMAP folders. More...
 
long C_ImapFetchChunkSize
 Config: (imap) Download headers in blocks of this size. More...
 
char * C_ImapHeaders
 Config: (imap) Additional email headers to download when getting index. More...
 
bool C_ImapIdle
 Config: (imap) Use the IMAP IDLE extension to check for new mail. More...
 
char * C_ImapLogin
 Config: (imap) Login name for the IMAP server (defaults to $imap_user) More...
 
char * C_ImapOauthRefreshCommand
 Config: (imap) External command to generate OAUTH refresh token. More...
 
char * C_ImapPass
 Config: (imap) Password for the IMAP server. More...
 
short C_ImapPipelineDepth
 Config: (imap) Number of IMAP commands that may be queued up. More...
 
short C_ImapPollTimeout
 Config: (imap) Maximum time to wait for a server response. More...
 
bool C_ImapQresync
 Config: (imap) Enable the QRESYNC extension. More...
 
bool C_ImapRfc5161
 Config: (imap) Use the IMAP ENABLE extension to select capabilities. More...
 
bool C_ImapServerNoise
 Config: (imap) Display server warnings as error messages. More...
 
char * C_ImapUser
 Config: (imap) Username for the IMAP server. More...
 

Detailed Description

Shared constants/structs that are private to IMAP

Authors
  • Brandon Long
  • Brendan Cully
  • Richard Russon

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, see http://www.gnu.org/licenses/.

Definition in file private.h.

Macro Definition Documentation

◆ IMAP_PORT

#define IMAP_PORT   143

Default port for IMAP.

Definition at line 47 of file private.h.

◆ IMAP_SSL_PORT

#define IMAP_SSL_PORT   993

Port for IMAP over SSL/TLS.

Definition at line 48 of file private.h.

◆ IMAP_LOG_CMD

#define IMAP_LOG_CMD   2

Definition at line 51 of file private.h.

◆ IMAP_LOG_LTRL

#define IMAP_LOG_LTRL   3

Definition at line 52 of file private.h.

◆ IMAP_LOG_PASS

#define IMAP_LOG_PASS   5

Definition at line 53 of file private.h.

◆ IMAP_RES_NO

#define IMAP_RES_NO   -2

<tag> NO ...

Definition at line 56 of file private.h.

◆ IMAP_RES_BAD

#define IMAP_RES_BAD   -1

<tag> BAD ...

Definition at line 57 of file private.h.

◆ IMAP_RES_OK

#define IMAP_RES_OK   0

<tag> OK ...

Definition at line 58 of file private.h.

◆ IMAP_RES_CONTINUE

#define IMAP_RES_CONTINUE   1

* ...

Definition at line 59 of file private.h.

◆ IMAP_RES_RESPOND

#define IMAP_RES_RESPOND   2

+

Definition at line 60 of file private.h.

◆ IMAP_RES_NEW

#define IMAP_RES_NEW   3

ImapCommand.state additions.

Definition at line 61 of file private.h.

◆ SEQ_LEN

#define SEQ_LEN   16

Definition at line 63 of file private.h.

◆ IMAP_MAX_CMDLEN

#define IMAP_MAX_CMDLEN   1024

Maximum length of command lines before they must be split (for lazy servers)

Definition at line 64 of file private.h.

◆ IMAP_OPEN_NO_FLAGS

#define IMAP_OPEN_NO_FLAGS   0

No flags are set.

Definition at line 67 of file private.h.

◆ IMAP_REOPEN_ALLOW

#define IMAP_REOPEN_ALLOW   (1 << 0)

Allow re-opening a folder upon expunge.

Definition at line 68 of file private.h.

◆ IMAP_EXPUNGE_EXPECTED

#define IMAP_EXPUNGE_EXPECTED   (1 << 1)

Messages will be expunged from the server.

Definition at line 69 of file private.h.

◆ IMAP_EXPUNGE_PENDING

#define IMAP_EXPUNGE_PENDING   (1 << 2)

Messages on the server have been expunged.

Definition at line 70 of file private.h.

◆ IMAP_NEWMAIL_PENDING

#define IMAP_NEWMAIL_PENDING   (1 << 3)

New mail is waiting on the server.

Definition at line 71 of file private.h.

◆ IMAP_FLAGS_PENDING

#define IMAP_FLAGS_PENDING   (1 << 4)

Flags have changed on the server.

Definition at line 72 of file private.h.

◆ IMAP_CMD_NO_FLAGS

#define IMAP_CMD_NO_FLAGS   0

No flags are set.

Definition at line 75 of file private.h.

◆ IMAP_CMD_PASS

#define IMAP_CMD_PASS   (1 << 0)

Command contains a password. Suppress logging.

Definition at line 76 of file private.h.

◆ IMAP_CMD_QUEUE

#define IMAP_CMD_QUEUE   (1 << 1)

Queue a command, do not execute.

Definition at line 77 of file private.h.

◆ IMAP_CMD_POLL

#define IMAP_CMD_POLL   (1 << 2)

Poll the tcp connection before running the imap command.

Definition at line 78 of file private.h.

◆ IMAP_CMD_SINGLE

#define IMAP_CMD_SINGLE   (1 << 3)

Run a single command.

Definition at line 79 of file private.h.

◆ IMAP_DATELEN

#define IMAP_DATELEN   27

Definition at line 92 of file private.h.

◆ IMAP_CAP_NO_FLAGS

#define IMAP_CAP_NO_FLAGS   0

No flags are set.

Definition at line 124 of file private.h.

◆ IMAP_CAP_IMAP4

#define IMAP_CAP_IMAP4   (1 << 0)

Server supports IMAP4.

Definition at line 125 of file private.h.

◆ IMAP_CAP_IMAP4REV1

#define IMAP_CAP_IMAP4REV1   (1 << 1)

Server supports IMAP4rev1.

Definition at line 126 of file private.h.

◆ IMAP_CAP_STATUS

#define IMAP_CAP_STATUS   (1 << 2)

Server supports STATUS command.

Definition at line 127 of file private.h.

◆ IMAP_CAP_ACL

#define IMAP_CAP_ACL   (1 << 3)

RFC2086: IMAP4 ACL extension.

Definition at line 128 of file private.h.

◆ IMAP_CAP_NAMESPACE

#define IMAP_CAP_NAMESPACE   (1 << 4)

RFC2342: IMAP4 Namespace.

Definition at line 129 of file private.h.

◆ IMAP_CAP_AUTH_CRAM_MD5

#define IMAP_CAP_AUTH_CRAM_MD5   (1 << 5)

RFC2195: CRAM-MD5 authentication.

Definition at line 130 of file private.h.

◆ IMAP_CAP_AUTH_GSSAPI

#define IMAP_CAP_AUTH_GSSAPI   (1 << 6)

RFC1731: GSSAPI authentication.

Definition at line 131 of file private.h.

◆ IMAP_CAP_AUTH_ANONYMOUS

#define IMAP_CAP_AUTH_ANONYMOUS   (1 << 7)

AUTH=ANONYMOUS.

Definition at line 132 of file private.h.

◆ IMAP_CAP_AUTH_OAUTHBEARER

#define IMAP_CAP_AUTH_OAUTHBEARER   (1 << 8)

RFC7628: AUTH=OAUTHBEARER.

Definition at line 133 of file private.h.

◆ IMAP_CAP_STARTTLS

#define IMAP_CAP_STARTTLS   (1 << 9)

RFC2595: STARTTLS.

Definition at line 134 of file private.h.

◆ IMAP_CAP_LOGINDISABLED

#define IMAP_CAP_LOGINDISABLED   (1 << 10)

RFC2595: LOGINDISABLED.

Definition at line 135 of file private.h.

◆ IMAP_CAP_IDLE

#define IMAP_CAP_IDLE   (1 << 11)

RFC2177: IDLE.

Definition at line 136 of file private.h.

◆ IMAP_CAP_SASL_IR

#define IMAP_CAP_SASL_IR   (1 << 12)

SASL initial response draft.

Definition at line 137 of file private.h.

◆ IMAP_CAP_ENABLE

#define IMAP_CAP_ENABLE   (1 << 13)

RFC5161.

Definition at line 138 of file private.h.

◆ IMAP_CAP_CONDSTORE

#define IMAP_CAP_CONDSTORE   (1 << 14)

RFC7162.

Definition at line 139 of file private.h.

◆ IMAP_CAP_QRESYNC

#define IMAP_CAP_QRESYNC   (1 << 15)

RFC7162.

Definition at line 140 of file private.h.

◆ IMAP_CAP_LIST_EXTENDED

#define IMAP_CAP_LIST_EXTENDED   (1 << 16)

RFC5258: IMAP4 LIST Command Extensions.

Definition at line 141 of file private.h.

◆ IMAP_CAP_COMPRESS

#define IMAP_CAP_COMPRESS   (1 << 17)

RFC4978: COMPRESS=DEFLATE.

Definition at line 142 of file private.h.

◆ IMAP_CAP_X_GM_EXT_1

#define IMAP_CAP_X_GM_EXT_1   (1 << 18)

◆ IMAP_CAP_ALL

#define IMAP_CAP_ALL   ((1 << 19) - 1)

Definition at line 145 of file private.h.

Typedef Documentation

◆ ImapOpenFlags

typedef uint8_t ImapOpenFlags

Flags, e.g. MUTT_THREAD_COLLAPSE.

Definition at line 66 of file private.h.

◆ ImapCmdFlags

typedef uint8_t ImapCmdFlags

Flags for imap_exec(), e.g. IMAP_CMD_PASS.

Definition at line 74 of file private.h.

◆ ImapCapFlags

typedef uint32_t ImapCapFlags

Capabilities we are interested in.

Note
This must be kept in the same order as Capabilities. Flags, e.g. IMAP_CAP_IMAP4

Definition at line 123 of file private.h.

Enumeration Type Documentation

◆ ImapExecResult

imap_exec return code

Enumerator
IMAP_EXEC_SUCCESS 

Imap command executed or queued successfully.

IMAP_EXEC_ERROR 

Imap command failure.

IMAP_EXEC_FATAL 

Imap connection failure.

Definition at line 84 of file private.h.

85 {
86  IMAP_EXEC_SUCCESS = 0,
89 };

◆ ImapFlags

enum ImapFlags

IMAP server responses.

Enumerator
IMAP_FATAL 

Unrecoverable error occurred.

IMAP_BYE 

Logged out from server.

Definition at line 97 of file private.h.

98 {
99  IMAP_FATAL = 1,
100  IMAP_BYE,
101 };

◆ ImapState

enum ImapState

IMAP connection state.

Enumerator
IMAP_DISCONNECTED 

Disconnected from server.

IMAP_CONNECTED 

Connected to server.

IMAP_AUTHENTICATED 

Connection is authenticated.

IMAP_SELECTED 

Mailbox is selected.

IMAP_IDLE 

Connection is idle.

Definition at line 106 of file private.h.

107 {
108  /* States */
109  IMAP_DISCONNECTED = 0,
112  IMAP_SELECTED,
113 
114  /* and pseudo-states */
115  IMAP_IDLE,
116 };

Function Documentation

◆ imap_create_mailbox()

int imap_create_mailbox ( struct ImapAccountData adata,
char *  mailbox 
)

Create a new mailbox.

Parameters
adataImap Account data
mailboxMailbox to create
Return values
0Success
-1Failure

Definition at line 447 of file imap.c.

448 {
449  char buf[2048], mbox[1024];
450 
451  imap_munge_mbox_name(adata->unicode, mbox, sizeof(mbox), mailbox);
452  snprintf(buf, sizeof(buf), "CREATE %s", mbox);
453 
454  if (imap_exec(adata, buf, IMAP_CMD_NO_FLAGS) != IMAP_EXEC_SUCCESS)
455  {
456  mutt_error(_("CREATE failed: %s"), imap_cmd_trailer(adata));
457  return -1;
458  }
459 
460  return 0;
461 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ imap_rename_mailbox()

int imap_rename_mailbox ( struct ImapAccountData adata,
char *  oldname,
const char *  newname 
)

Rename a mailbox.

Parameters
adataImap Account data
oldnameExisting mailbox
newnameNew name for mailbox
Return values
0Success
-1Failure

Definition at line 488 of file imap.c.

489 {
490  char oldmbox[1024];
491  char newmbox[1024];
492  int rc = 0;
493 
494  imap_munge_mbox_name(adata->unicode, oldmbox, sizeof(oldmbox), oldname);
495  imap_munge_mbox_name(adata->unicode, newmbox, sizeof(newmbox), newname);
496 
497  struct Buffer *buf = mutt_buffer_pool_get();
498  mutt_buffer_printf(buf, "RENAME %s %s", oldmbox, newmbox);
499 
501  rc = -1;
502 
504 
505  return rc;
506 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ imap_exec_msgset()

int imap_exec_msgset ( struct Mailbox m,
const char *  pre,
const char *  post,
enum MessageType  flag,
bool  changed,
bool  invert 
)

Prepare commands for all messages matching conditions.

Parameters
mSelected Imap Mailbox
preprefix commands
postpostfix commands
flagflag type on which to filter, e.g. MUTT_REPLIED
changedinclude only changed messages in message set
invertinvert sense of flag, eg MUTT_READ matches unread messages
Return values
numMatched messages
-1Failure

pre/post: commands are of the form "%s %s %s %s", tag, pre, message set, post Prepares commands for all messages matching conditions (must be flushed with imap_exec)

Definition at line 917 of file imap.c.

919 {
920  struct ImapAccountData *adata = imap_adata_get(m);
921  if (!adata || (adata->mailbox != m))
922  return -1;
923 
924  struct Email **emails = NULL;
925  short oldsort;
926  int pos;
927  int rc;
928  int count = 0;
929 
930  struct Buffer cmd = mutt_buffer_make(0);
931 
932  /* We make a copy of the headers just in case resorting doesn't give
933  exactly the original order (duplicate messages?), because other parts of
934  the ctx are tied to the header order. This may be overkill. */
935  oldsort = C_Sort;
936  if (C_Sort != SORT_ORDER)
937  {
938  emails = m->emails;
939  // We overcommit here, just in case new mail arrives whilst we're sync-ing
940  m->emails = mutt_mem_malloc(m->email_max * sizeof(struct Email *));
941  memcpy(m->emails, emails, m->email_max * sizeof(struct Email *));
942 
943  C_Sort = SORT_ORDER;
944  qsort(m->emails, m->msg_count, sizeof(struct Email *), compare_uid);
945  }
946 
947  pos = 0;
948 
949  do
950  {
951  mutt_buffer_reset(&cmd);
952  mutt_buffer_add_printf(&cmd, "%s ", pre);
953  rc = make_msg_set(m, &cmd, flag, changed, invert, &pos);
954  if (rc > 0)
955  {
956  mutt_buffer_add_printf(&cmd, " %s", post);
957  if (imap_exec(adata, cmd.data, IMAP_CMD_QUEUE) != IMAP_EXEC_SUCCESS)
958  {
959  rc = -1;
960  goto out;
961  }
962  count += rc;
963  }
964  } while (rc > 0);
965 
966  rc = count;
967 
968 out:
969  mutt_buffer_dealloc(&cmd);
970  if (oldsort != C_Sort)
971  {
972  C_Sort = oldsort;
973  FREE(&m->emails);
974  m->emails = emails;
975  }
976 
977  return rc;
978 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ imap_open_connection()

int imap_open_connection ( struct ImapAccountData adata)

Open an IMAP connection.

Parameters
adataImap Account data
Return values
0Success
-1Failure

Definition at line 740 of file imap.c.

741 {
742  if (mutt_socket_open(adata->conn) < 0)
743  return -1;
744 
745  adata->state = IMAP_CONNECTED;
746 
747  if (imap_cmd_step(adata) != IMAP_RES_OK)
748  {
749  imap_close_connection(adata);
750  return -1;
751  }
752 
753  if (mutt_istr_startswith(adata->buf, "* OK"))
754  {
755  if (!mutt_istr_startswith(adata->buf, "* OK [CAPABILITY") && check_capabilities(adata))
756  {
757  goto bail;
758  }
759 #ifdef USE_SSL
760  /* Attempt STARTTLS if available and desired. */
761  if ((adata->conn->ssf == 0) && (C_SslForceTls || (adata->capabilities & IMAP_CAP_STARTTLS)))
762  {
763  enum QuadOption ans;
764 
765  if (C_SslForceTls)
766  ans = MUTT_YES;
767  else if ((ans = query_quadoption(C_SslStarttls,
768  _("Secure connection with TLS?"))) == MUTT_ABORT)
769  {
770  goto bail;
771  }
772  if (ans == MUTT_YES)
773  {
774  enum ImapExecResult rc = imap_exec(adata, "STARTTLS", IMAP_CMD_SINGLE);
775  // Clear any data after the STARTTLS acknowledgement
776  mutt_socket_empty(adata->conn);
777 
778  if (rc == IMAP_EXEC_FATAL)
779  goto bail;
780  if (rc != IMAP_EXEC_ERROR)
781  {
782  if (mutt_ssl_starttls(adata->conn))
783  {
784  mutt_error(_("Could not negotiate TLS connection"));
785  goto bail;
786  }
787  else
788  {
789  /* RFC2595 demands we recheck CAPABILITY after TLS completes. */
790  if (imap_exec(adata, "CAPABILITY", IMAP_CMD_NO_FLAGS))
791  goto bail;
792  }
793  }
794  }
795  }
796 
797  if (C_SslForceTls && (adata->conn->ssf == 0))
798  {
799  mutt_error(_("Encrypted connection unavailable"));
800  goto bail;
801  }
802 #endif
803  }
804  else if (mutt_istr_startswith(adata->buf, "* PREAUTH"))
805  {
806 #ifdef USE_SSL
807  /* Unless using a secure $tunnel, an unencrypted PREAUTH response may be a
808  * MITM attack. The only way to stop "STARTTLS" MITM attacks is via
809  * $ssl_force_tls: an attacker can easily spoof "* OK" and strip the
810  * STARTTLS capability. So consult $ssl_force_tls, not $ssl_starttls, to
811  * decide whether to abort. Note that if using $tunnel and
812  * $tunnel_is_secure, adata->conn->ssf will be set to 1. */
813  if ((adata->conn->ssf == 0) && C_SslForceTls)
814  {
815  mutt_error(_("Encrypted connection unavailable"));
816  goto bail;
817  }
818 #endif
819 
820  adata->state = IMAP_AUTHENTICATED;
821  if (check_capabilities(adata) != 0)
822  goto bail;
823  FREE(&adata->capstr);
824  }
825  else
826  {
827  imap_error("imap_open_connection()", adata->buf);
828  goto bail;
829  }
830 
831  return 0;
832 
833 bail:
834  imap_close_connection(adata);
835  FREE(&adata->capstr);
836  return -1;
837 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ imap_close_connection()

void imap_close_connection ( struct ImapAccountData adata)

Close an IMAP connection.

Parameters
adataImap Account data

Definition at line 843 of file imap.c.

844 {
845  if (adata->state != IMAP_DISCONNECTED)
846  {
847  mutt_socket_close(adata->conn);
848  adata->state = IMAP_DISCONNECTED;
849  }
850  adata->seqno = 0;
851  adata->nextcmd = 0;
852  adata->lastcmd = 0;
853  adata->status = 0;
854  memset(adata->cmds, 0, sizeof(struct ImapCommand) * adata->cmdslots);
855 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ imap_read_literal()

int imap_read_literal ( FILE *  fp,
struct ImapAccountData adata,
unsigned long  bytes,
struct Progress pbar 
)

Read bytes bytes from server into file.

Parameters
fpFile handle for email file
adataImap Account data
bytesNumber of bytes to read
pbarProgress bar
Return values
0Success
-1Failure

Not explicitly buffered, relies on FILE buffering.

Note
Strips \r from \r\n. Apparently even literals use \r\n-terminated strings ?!

Definition at line 596 of file imap.c.

598 {
599  char c;
600  bool r = false;
601  struct Buffer buf = { 0 }; // Do not allocate, maybe it won't be used
602 
604  mutt_buffer_alloc(&buf, bytes + 10);
605 
606  mutt_debug(LL_DEBUG2, "reading %ld bytes\n", bytes);
607 
608  for (unsigned long pos = 0; pos < bytes; pos++)
609  {
610  if (mutt_socket_readchar(adata->conn, &c) != 1)
611  {
612  mutt_debug(LL_DEBUG1, "error during read, %ld bytes read\n", pos);
613  adata->status = IMAP_FATAL;
614 
615  mutt_buffer_dealloc(&buf);
616  return -1;
617  }
618 
619  if (r && (c != '\n'))
620  fputc('\r', fp);
621 
622  if (c == '\r')
623  {
624  r = true;
625  continue;
626  }
627  else
628  r = false;
629 
630  fputc(c, fp);
631 
632  if (pbar && !(pos % 1024))
633  mutt_progress_update(pbar, pos, -1);
635  mutt_buffer_addch(&buf, c);
636  }
637 
639  {
640  mutt_debug(IMAP_LOG_LTRL, "\n%s", buf.data);
641  mutt_buffer_dealloc(&buf);
642  }
643  return 0;
644 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ imap_expunge_mailbox()

void imap_expunge_mailbox ( struct Mailbox m)

Purge messages from the server.

Parameters
mMailbox

Purge IMAP portion of expunged messages from the context. Must not be done while something has a handle on any headers (eg inside pager or editor). That is, check IMAP_REOPEN_ALLOW.

Definition at line 671 of file imap.c.

672 {
673  struct ImapAccountData *adata = imap_adata_get(m);
674  struct ImapMboxData *mdata = imap_mdata_get(m);
675  if (!adata || !mdata)
676  return;
677 
678  struct Email *e = NULL;
679 
680 #ifdef USE_HCACHE
681  imap_hcache_open(adata, mdata);
682 #endif
683 
684  for (int i = 0; i < m->msg_count; i++)
685  {
686  e = m->emails[i];
687  if (!e)
688  break;
689 
690  if (e->index == INT_MAX)
691  {
692  mutt_debug(LL_DEBUG2, "Expunging message UID %u\n", imap_edata_get(e)->uid);
693 
694  e->deleted = true;
695 
696  imap_cache_del(m, e);
697 #ifdef USE_HCACHE
698  imap_hcache_del(mdata, imap_edata_get(e)->uid);
699 #endif
700 
701  mutt_hash_int_delete(mdata->uid_hash, imap_edata_get(e)->uid, e);
702 
703  imap_edata_free((void **) &e->edata);
704  }
705  else
706  {
707  /* NeoMutt has several places where it turns off e->active as a
708  * hack. For example to avoid FLAG updates, or to exclude from
709  * imap_exec_msgset.
710  *
711  * Unfortunately, when a reopen is allowed and the IMAP_EXPUNGE_PENDING
712  * flag becomes set (e.g. a flag update to a modified header),
713  * this function will be called by imap_cmd_finish().
714  *
715  * The ctx_update_tables() will free and remove these "inactive" headers,
716  * despite that an EXPUNGE was not received for them.
717  * This would result in memory leaks and segfaults due to dangling
718  * pointers in the msn_index and uid_hash.
719  *
720  * So this is another hack to work around the hacks. We don't want to
721  * remove the messages, so make sure active is on. */
722  e->active = true;
723  }
724  }
725 
726 #ifdef USE_HCACHE
727  imap_hcache_close(mdata);
728 #endif
729 
732 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ imap_login()

int imap_login ( struct ImapAccountData adata)

Open an IMAP connection.

Parameters
adataImap Account data
Return values
0Success
-1Failure

Ensure ImapAccountData is connected and logged into the imap server.

Definition at line 1827 of file imap.c.

1828 {
1829  if (!adata)
1830  return -1;
1831 
1832  if (adata->state == IMAP_DISCONNECTED)
1833  {
1834  mutt_buffer_reset(&adata->cmdbuf); // purge outstanding queued commands
1835  imap_open_connection(adata);
1836  }
1837  if (adata->state == IMAP_CONNECTED)
1838  {
1839  if (imap_authenticate(adata) == IMAP_AUTH_SUCCESS)
1840  {
1841  adata->state = IMAP_AUTHENTICATED;
1842  FREE(&adata->capstr);
1843  if (adata->conn->ssf != 0)
1844  {
1845  mutt_debug(LL_DEBUG2, "Communication encrypted at %d bits\n",
1846  adata->conn->ssf);
1847  }
1848  }
1849  else
1851  }
1852  if (adata->state == IMAP_AUTHENTICATED)
1853  {
1854  /* capabilities may have changed */
1855  imap_exec(adata, "CAPABILITY", IMAP_CMD_PASS);
1856 
1857 #ifdef USE_ZLIB
1858  /* RFC4978 */
1859  if ((adata->capabilities & IMAP_CAP_COMPRESS) && C_ImapDeflate &&
1860  (imap_exec(adata, "COMPRESS DEFLATE", IMAP_CMD_PASS) == IMAP_EXEC_SUCCESS))
1861  {
1862  mutt_debug(LL_DEBUG2, "IMAP compression is enabled on connection to %s\n",
1863  adata->conn->account.host);
1864  mutt_zstrm_wrap_conn(adata->conn);
1865  }
1866 #endif
1867 
1868  /* enable RFC6855, if the server supports that */
1869  if (C_ImapRfc5161 && (adata->capabilities & IMAP_CAP_ENABLE))
1870  imap_exec(adata, "ENABLE UTF8=ACCEPT", IMAP_CMD_QUEUE);
1871 
1872  /* enable QRESYNC. Advertising QRESYNC also means CONDSTORE
1873  * is supported (even if not advertised), so flip that bit. */
1874  if (adata->capabilities & IMAP_CAP_QRESYNC)
1875  {
1876  adata->capabilities |= IMAP_CAP_CONDSTORE;
1878  imap_exec(adata, "ENABLE QRESYNC", IMAP_CMD_QUEUE);
1879  }
1880 
1881  /* get root delimiter, '/' as default */
1882  adata->delim = '/';
1883  imap_exec(adata, "LIST \"\" \"\"", IMAP_CMD_QUEUE);
1884 
1885  /* we may need the root delimiter before we open a mailbox */
1886  imap_exec(adata, NULL, IMAP_CMD_NO_FLAGS);
1887 
1888  /* select the mailbox that used to be open before disconnect */
1889  if (adata->mailbox)
1890  {
1891  imap_mbox_select(adata->mailbox);
1892  }
1893  }
1894 
1895  if (adata->state < IMAP_AUTHENTICATED)
1896  return -1;
1897 
1898  return 0;
1899 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ imap_sync_message_for_copy()

int imap_sync_message_for_copy ( struct Mailbox m,
struct Email e,
struct Buffer cmd,
enum QuadOption err_continue 
)

Update server to reflect the flags of a single message.

Parameters
[in]mMailbox
[in]eEmail
[in]cmdBuffer for the command string
[out]err_continueDid the user force a continue?
Return values
0Success
-1Failure

Update the IMAP server to reflect the flags for a single message before performing a "UID COPY".

Note
This does not sync the "deleted" flag state, because it is not desirable to propagate that flag into the copy.

Definition at line 995 of file imap.c.

997 {
998  struct ImapAccountData *adata = imap_adata_get(m);
999  if (!adata || (adata->mailbox != m))
1000  return -1;
1001 
1002  char flags[1024];
1003  char *tags = NULL;
1004  char uid[11];
1005 
1006  if (!compare_flags_for_copy(e))
1007  {
1008  if (e->deleted == imap_edata_get(e)->deleted)
1009  e->changed = false;
1010  return 0;
1011  }
1012 
1013  snprintf(uid, sizeof(uid), "%u", imap_edata_get(e)->uid);
1014  mutt_buffer_reset(cmd);
1015  mutt_buffer_addstr(cmd, "UID STORE ");
1016  mutt_buffer_addstr(cmd, uid);
1017 
1018  flags[0] = '\0';
1019 
1020  set_flag(m, MUTT_ACL_SEEN, e->read, "\\Seen ", flags, sizeof(flags));
1021  set_flag(m, MUTT_ACL_WRITE, e->old, "Old ", flags, sizeof(flags));
1022  set_flag(m, MUTT_ACL_WRITE, e->flagged, "\\Flagged ", flags, sizeof(flags));
1023  set_flag(m, MUTT_ACL_WRITE, e->replied, "\\Answered ", flags, sizeof(flags));
1024  set_flag(m, MUTT_ACL_DELETE, imap_edata_get(e)->deleted, "\\Deleted ", flags,
1025  sizeof(flags));
1026 
1027  if (m->rights & MUTT_ACL_WRITE)
1028  {
1029  /* restore system flags */
1030  if (imap_edata_get(e)->flags_system)
1031  mutt_str_cat(flags, sizeof(flags), imap_edata_get(e)->flags_system);
1032  /* set custom flags */
1033  tags = driver_tags_get_with_hidden(&e->tags);
1034  if (tags)
1035  {
1036  mutt_str_cat(flags, sizeof(flags), tags);
1037  FREE(&tags);
1038  }
1039  }
1040 
1042 
1043  /* UW-IMAP is OK with null flags, Cyrus isn't. The only solution is to
1044  * explicitly revoke all system flags (if we have permission) */
1045  if (*flags == '\0')
1046  {
1047  set_flag(m, MUTT_ACL_SEEN, true, "\\Seen ", flags, sizeof(flags));
1048  set_flag(m, MUTT_ACL_WRITE, true, "Old ", flags, sizeof(flags));
1049  set_flag(m, MUTT_ACL_WRITE, true, "\\Flagged ", flags, sizeof(flags));
1050  set_flag(m, MUTT_ACL_WRITE, true, "\\Answered ", flags, sizeof(flags));
1051  set_flag(m, MUTT_ACL_DELETE, !imap_edata_get(e)->deleted, "\\Deleted ",
1052  flags, sizeof(flags));
1053 
1054  /* erase custom flags */
1055  if ((m->rights & MUTT_ACL_WRITE) && imap_edata_get(e)->flags_remote)
1056  mutt_str_cat(flags, sizeof(flags), imap_edata_get(e)->flags_remote);
1057 
1059 
1060  mutt_buffer_addstr(cmd, " -FLAGS.SILENT (");
1061  }
1062  else
1063  mutt_buffer_addstr(cmd, " FLAGS.SILENT (");
1064 
1065  mutt_buffer_addstr(cmd, flags);
1066  mutt_buffer_addstr(cmd, ")");
1067 
1068  /* after all this it's still possible to have no flags, if you
1069  * have no ACL rights */
1070  if (*flags && (imap_exec(adata, cmd->data, IMAP_CMD_NO_FLAGS) != IMAP_EXEC_SUCCESS) &&
1071  err_continue && (*err_continue != MUTT_YES))
1072  {
1073  *err_continue = imap_continue("imap_sync_message: STORE failed", adata->buf);
1074  if (*err_continue != MUTT_YES)
1075  return -1;
1076  }
1077 
1078  /* server have now the updated flags */
1079  FREE(&imap_edata_get(e)->flags_remote);
1081 
1082  if (e->deleted == imap_edata_get(e)->deleted)
1083  e->changed = false;
1084 
1085  return 0;
1086 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ imap_has_flag()

bool imap_has_flag ( struct ListHead *  flag_list,
const char *  flag 
)

Does the flag exist in the list.

Parameters
flag_listList of server flags
flagFlag to find
Return values
trueFlag exists

Do a caseless comparison of the flag against a flag list, return true if found or flag list has '*'. Note that "flag" might contain additional whitespace at the end, so we really need to compare up to the length of each element in "flag_list".

Definition at line 868 of file imap.c.

869 {
870  if (STAILQ_EMPTY(flag_list))
871  return false;
872 
873  const size_t flaglen = mutt_str_len(flag);
874  struct ListNode *np = NULL;
875  STAILQ_FOREACH(np, flag_list, entries)
876  {
877  const size_t nplen = strlen(np->data);
878  if ((flaglen >= nplen) && ((flag[nplen] == '\0') || (flag[nplen] == ' ')) &&
879  mutt_istrn_equal(np->data, flag, nplen))
880  {
881  return true;
882  }
883 
884  if (mutt_str_equal(np->data, "\\*"))
885  return true;
886  }
887 
888  return false;
889 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ imap_adata_find()

int imap_adata_find ( const char *  path,
struct ImapAccountData **  adata,
struct ImapMboxData **  mdata 
)

Find the Account data for this path.

Parameters
pathPath to search for
adataImap Account data
mdataImap Mailbox data
Return values
0Success
-1Failure

Definition at line 74 of file util.c.

76 {
77  struct ConnAccount cac = { { 0 } };
78  struct ImapAccountData *tmp_adata = NULL;
79  char tmp[1024];
80 
81  if (imap_parse_path(path, &cac, tmp, sizeof(tmp)) < 0)
82  return -1;
83 
84  struct Account *np = NULL;
85  TAILQ_FOREACH(np, &NeoMutt->accounts, entries)
86  {
87  if (np->type != MUTT_IMAP)
88  continue;
89 
90  tmp_adata = np->adata;
91  if (!tmp_adata)
92  continue;
93  if (imap_account_match(&tmp_adata->conn->account, &cac))
94  {
95  *mdata = imap_mdata_new(tmp_adata, tmp);
96  *adata = tmp_adata;
97  return 0;
98  }
99  }
100  mutt_debug(LL_DEBUG3, "no ImapAccountData found\n");
101  return -1;
102 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ imap_authenticate()

int imap_authenticate ( struct ImapAccountData adata)

Authenticate to an IMAP server.

Parameters
adataImap Account data
Return values
numResult, e.g. IMAP_AUTH_SUCCESS

Attempt to authenticate using either user-specified authentication method if specified, or any.

Definition at line 105 of file auth.c.

106 {
107  int rc = IMAP_AUTH_FAILURE;
108 
110  {
111  mutt_debug(LL_DEBUG2, "Trying user-defined imap_authenticators\n");
112 
113  /* Try user-specified list of authentication methods */
114  struct ListNode *np = NULL;
116  {
117  mutt_debug(LL_DEBUG2, "Trying method %s\n", np->data);
118 
119  for (size_t i = 0; i < mutt_array_size(imap_authenticators); i++)
120  {
121  const struct ImapAuth *auth = &imap_authenticators[i];
122  if (!auth->method || mutt_istr_equal(auth->method, np->data))
123  {
124  rc = auth->authenticate(adata, np->data);
125  if (rc == IMAP_AUTH_SUCCESS)
126  {
127  return rc;
128  }
129  }
130  }
131  }
132  }
133  else
134  {
135  /* Fall back to default: any authenticator */
136  mutt_debug(LL_DEBUG2, "Trying pre-defined imap_authenticators\n");
137 
138  for (size_t i = 0; i < mutt_array_size(imap_authenticators); i++)
139  {
140  rc = imap_authenticators[i].authenticate(adata, NULL);
141  if (rc == IMAP_AUTH_SUCCESS)
142  return rc;
143  }
144  }
145 
146  mutt_error(_("No authenticators available or wrong credentials"));
147  return rc;
148 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ imap_cmd_start()

int imap_cmd_start ( struct ImapAccountData adata,
const char *  cmdstr 
)

Given an IMAP command, send it to the server.

Parameters
adataImap Account data
cmdstrCommand string to send
Return values
0Success
<0Failure, e.g. IMAP_RES_BAD

If cmdstr is NULL, sends queued commands.

Definition at line 1060 of file command.c.

1061 {
1062  return cmd_start(adata, cmdstr, IMAP_CMD_NO_FLAGS);
1063 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ imap_cmd_step()

int imap_cmd_step ( struct ImapAccountData adata)

Reads server responses from an IMAP command.

Parameters
adataImap Account data
Return values
0Success
<0Failure, e.g. IMAP_RES_BAD

detects tagged completion response, handles untagged messages, can read arbitrarily large strings (using malloc, so don't make it too large!).

Definition at line 1074 of file command.c.

1075 {
1076  if (!adata)
1077  return -1;
1078 
1079  size_t len = 0;
1080  int c;
1081  int rc;
1082  int stillrunning = 0;
1083  struct ImapCommand *cmd = NULL;
1084 
1085  if (adata->status == IMAP_FATAL)
1086  {
1087  cmd_handle_fatal(adata);
1088  return IMAP_RES_BAD;
1089  }
1090 
1091  /* read into buffer, expanding buffer as necessary until we have a full
1092  * line */
1093  do
1094  {
1095  if (len == adata->blen)
1096  {
1097  mutt_mem_realloc(&adata->buf, adata->blen + IMAP_CMD_BUFSIZE);
1098  adata->blen = adata->blen + IMAP_CMD_BUFSIZE;
1099  mutt_debug(LL_DEBUG3, "grew buffer to %lu bytes\n", adata->blen);
1100  }
1101 
1102  /* back up over '\0' */
1103  if (len)
1104  len--;
1105  c = mutt_socket_readln_d(adata->buf + len, adata->blen - len, adata->conn, MUTT_SOCK_LOG_FULL);
1106  if (c <= 0)
1107  {
1108  mutt_debug(LL_DEBUG1, "Error reading server response\n");
1109  cmd_handle_fatal(adata);
1110  return IMAP_RES_BAD;
1111  }
1112 
1113  len += c;
1114  }
1115  /* if we've read all the way to the end of the buffer, we haven't read a
1116  * full line (mutt_socket_readln strips the \r, so we always have at least
1117  * one character free when we've read a full line) */
1118  while (len == adata->blen);
1119 
1120  /* don't let one large string make cmd->buf hog memory forever */
1121  if ((adata->blen > IMAP_CMD_BUFSIZE) && (len <= IMAP_CMD_BUFSIZE))
1122  {
1124  adata->blen = IMAP_CMD_BUFSIZE;
1125  mutt_debug(LL_DEBUG3, "shrank buffer to %lu bytes\n", adata->blen);
1126  }
1127 
1128  adata->lastread = mutt_date_epoch();
1129 
1130  /* handle untagged messages. The caller still gets its shot afterwards. */
1131  if ((mutt_str_startswith(adata->buf, "* ") ||
1132  mutt_str_startswith(imap_next_word(adata->buf), "OK [")) &&
1133  cmd_handle_untagged(adata))
1134  {
1135  return IMAP_RES_BAD;
1136  }
1137 
1138  /* server demands a continuation response from us */
1139  if (adata->buf[0] == '+')
1140  return IMAP_RES_RESPOND;
1141 
1142  /* Look for tagged command completions.
1143  *
1144  * Some response handlers can end up recursively calling
1145  * imap_cmd_step() and end up handling all tagged command
1146  * completions.
1147  * (e.g. FETCH->set_flag->set_header_color->~h pattern match.)
1148  *
1149  * Other callers don't even create an adata->cmds entry.
1150  *
1151  * For both these cases, we default to returning OK */
1152  rc = IMAP_RES_OK;
1153  c = adata->lastcmd;
1154  do
1155  {
1156  cmd = &adata->cmds[c];
1157  if (cmd->state == IMAP_RES_NEW)
1158  {
1159  if (mutt_str_startswith(adata->buf, cmd->seq))
1160  {
1161  if (!stillrunning)
1162  {
1163  /* first command in queue has finished - move queue pointer up */
1164  adata->lastcmd = (adata->lastcmd + 1) % adata->cmdslots;
1165  }
1166  cmd->state = cmd_status(adata->buf);
1167  rc = cmd->state;
1168  if (cmd->state == IMAP_RES_NO || cmd->state == IMAP_RES_BAD)
1169  {
1170  mutt_message(_("IMAP command failed: %s"), adata->buf);
1171  }
1172  }
1173  else
1174  stillrunning++;
1175  }
1176 
1177  c = (c + 1) % adata->cmdslots;
1178  } while (c != adata->nextcmd);
1179 
1180  if (stillrunning)
1181  rc = IMAP_RES_CONTINUE;
1182  else
1183  {
1184  mutt_debug(LL_DEBUG3, "IMAP queue drained\n");
1185  imap_cmd_finish(adata);
1186  }
1187 
1188  return rc;
1189 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ imap_cmd_finish()

void imap_cmd_finish ( struct ImapAccountData adata)

Attempt to perform cleanup.

Parameters
adataImap Account data

If a reopen is allowed, it attempts to perform cleanup (eg fetch new mail if detected, do expunge). Called automatically by imap_cmd_step(), but may be called at any time.

mdata->check_status is set and will be used later by imap_check_mailbox().

Definition at line 1309 of file command.c.

1310 {
1311  if (!adata)
1312  return;
1313 
1314  if (adata->status == IMAP_FATAL)
1315  {
1316  adata->closing = false;
1317  cmd_handle_fatal(adata);
1318  return;
1319  }
1320 
1321  if (!(adata->state >= IMAP_SELECTED) || (adata->mailbox && adata->closing))
1322  {
1323  adata->closing = false;
1324  return;
1325  }
1326 
1327  adata->closing = false;
1328 
1329  struct ImapMboxData *mdata = imap_mdata_get(adata->mailbox);
1330 
1331  if (mdata && mdata->reopen & IMAP_REOPEN_ALLOW)
1332  {
1333  // First remove expunged emails from the msn_index
1334  if (mdata->reopen & IMAP_EXPUNGE_PENDING)
1335  {
1336  mutt_debug(LL_DEBUG2, "Expunging mailbox\n");
1337  imap_expunge_mailbox(adata->mailbox);
1338  /* Detect whether we've gotten unexpected EXPUNGE messages */
1339  if (!(mdata->reopen & IMAP_EXPUNGE_EXPECTED))
1340  mdata->check_status |= IMAP_EXPUNGE_PENDING;
1342  }
1343 
1344  // Then add new emails to it
1345  if (mdata->reopen & IMAP_NEWMAIL_PENDING)
1346  {
1347  const size_t max_msn = imap_msn_highest(&mdata->msn);
1348  if (mdata->new_mail_count > max_msn)
1349  {
1350  if (!(mdata->reopen & IMAP_EXPUNGE_PENDING))
1351  mdata->check_status |= IMAP_NEWMAIL_PENDING;
1352 
1353  mutt_debug(LL_DEBUG2, "Fetching new mails from %d to %d\n", max_msn + 1,
1354  mdata->new_mail_count);
1355  imap_read_headers(adata->mailbox, max_msn + 1, mdata->new_mail_count, false);
1356  }
1357  }
1358 
1359  // And to finish inform about MUTT_REOPEN if needed
1360  if (mdata->reopen & IMAP_EXPUNGE_PENDING && !(mdata->reopen & IMAP_EXPUNGE_EXPECTED))
1361  mdata->check_status |= IMAP_EXPUNGE_PENDING;
1362 
1363  if (mdata->reopen & IMAP_EXPUNGE_PENDING)
1365  }
1366 
1367  adata->status = 0;
1368 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ imap_code()

bool imap_code ( const char *  s)

Was the command successful.

Parameters
sIMAP command status
Return values
1Command result was OK
0If NO or BAD

Definition at line 1197 of file command.c.

1198 {
1199  return cmd_status(s) == IMAP_RES_OK;
1200 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ imap_cmd_trailer()

const char* imap_cmd_trailer ( struct ImapAccountData adata)

Extra information after tagged command response if any.

Parameters
adataImap Account data
Return values
ptrExtra command information (pointer into adata->buf)
""Error (static string)

Definition at line 1208 of file command.c.

1209 {
1210  static const char *notrailer = "";
1211  const char *s = adata->buf;
1212 
1213  if (!s)
1214  {
1215  mutt_debug(LL_DEBUG2, "not a tagged response\n");
1216  return notrailer;
1217  }
1218 
1219  s = imap_next_word((char *) s);
1220  if (!s || (!mutt_istr_startswith(s, "OK") && !mutt_istr_startswith(s, "NO") &&
1221  !mutt_istr_startswith(s, "BAD")))
1222  {
1223  mutt_debug(LL_DEBUG2, "not a command completion: %s\n", adata->buf);
1224  return notrailer;
1225  }
1226 
1227  s = imap_next_word((char *) s);
1228  if (!s)
1229  return notrailer;
1230 
1231  return s;
1232 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ imap_exec()

int imap_exec ( struct ImapAccountData adata,
const char *  cmdstr,
ImapCmdFlags  flags 
)

Execute a command and wait for the response from the server.

Parameters
adataImap Account data
cmdstrCommand to execute
flagsFlags, see ImapCmdFlags
Return values
IMAP_EXEC_SUCCESSCommand successful or queued
IMAP_EXEC_ERRORCommand returned an error
IMAP_EXEC_FATALImap connection failure

Also, handle untagged responses.

Definition at line 1245 of file command.c.

1246 {
1247  int rc;
1248 
1249  if (flags & IMAP_CMD_SINGLE)
1250  {
1251  // Process any existing commands
1252  if (adata->nextcmd != adata->lastcmd)
1253  imap_exec(adata, NULL, IMAP_CMD_POLL);
1254  }
1255 
1256  rc = cmd_start(adata, cmdstr, flags);
1257  if (rc < 0)
1258  {
1259  cmd_handle_fatal(adata);
1260  return IMAP_EXEC_FATAL;
1261  }
1262 
1263  if (flags & IMAP_CMD_QUEUE)
1264  return IMAP_EXEC_SUCCESS;
1265 
1266  if ((flags & IMAP_CMD_POLL) && (C_ImapPollTimeout > 0) &&
1267  ((mutt_socket_poll(adata->conn, C_ImapPollTimeout)) == 0))
1268  {
1269  mutt_error(_("Connection to %s timed out"), adata->conn->account.host);
1270  cmd_handle_fatal(adata);
1271  return IMAP_EXEC_FATAL;
1272  }
1273 
1274  /* Allow interruptions, particularly useful if there are network problems. */
1276  do
1277  {
1278  rc = imap_cmd_step(adata);
1279  // The queue is empty, so the single command has been processed
1280  if ((flags & IMAP_CMD_SINGLE) && (adata->nextcmd == adata->lastcmd))
1281  break;
1282  } while (rc == IMAP_RES_CONTINUE);
1283  mutt_sig_allow_interrupt(false);
1284 
1285  if (rc == IMAP_RES_NO)
1286  return IMAP_EXEC_ERROR;
1287  if (rc != IMAP_RES_OK)
1288  {
1289  if (adata->status != IMAP_FATAL)
1290  return IMAP_EXEC_ERROR;
1291 
1292  mutt_debug(LL_DEBUG1, "command failed: %s\n", adata->buf);
1293  return IMAP_EXEC_FATAL;
1294  }
1295 
1296  return IMAP_EXEC_SUCCESS;
1297 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ imap_cmd_idle()

int imap_cmd_idle ( struct ImapAccountData adata)

Enter the IDLE state.

Parameters
adataImap Account data
Return values
0Success
<0Failure, e.g. IMAP_RES_BAD

Definition at line 1376 of file command.c.

1377 {
1378  int rc;
1379 
1380  if (cmd_start(adata, "IDLE", IMAP_CMD_POLL) < 0)
1381  {
1382  cmd_handle_fatal(adata);
1383  return -1;
1384  }
1385 
1386  if ((C_ImapPollTimeout > 0) && ((mutt_socket_poll(adata->conn, C_ImapPollTimeout)) == 0))
1387  {
1388  mutt_error(_("Connection to %s timed out"), adata->conn->account.host);
1389  cmd_handle_fatal(adata);
1390  return -1;
1391  }
1392 
1393  do
1394  {
1395  rc = imap_cmd_step(adata);
1396  } while (rc == IMAP_RES_CONTINUE);
1397 
1398  if (rc == IMAP_RES_RESPOND)
1399  {
1400  /* successfully entered IDLE state */
1401  adata->state = IMAP_IDLE;
1402  /* queue automatic exit when next command is issued */
1403  mutt_buffer_addstr(&adata->cmdbuf, "DONE\r\n");
1404  rc = IMAP_RES_OK;
1405  }
1406  if (rc != IMAP_RES_OK)
1407  {
1408  mutt_debug(LL_DEBUG1, "error starting IDLE\n");
1409  return -1;
1410  }
1411 
1412  return 0;
1413 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ imap_read_headers()

int imap_read_headers ( struct Mailbox m,
unsigned int  msn_begin,
unsigned int  msn_end,
bool  initial_download 
)

Read headers from the server.

Parameters
mImap Selected Mailbox
msn_beginFirst Message Sequence Number
msn_endLast Message Sequence Number
initial_downloadtrue, if this is the first opening of the mailbox
Return values
numLast MSN
-1Failure

Changed to read many headers instead of just one. It will return the msn of the last message read. It will return a value other than msn_end if mail comes in while downloading headers (in theory).

Definition at line 1283 of file message.c.

1285 {
1286  int oldmsgcount;
1287  unsigned int maxuid = 0;
1288  int retval = -1;
1289  bool evalhc = false;
1290 
1291 #ifdef USE_HCACHE
1292  void *uidvalidity = NULL;
1293  void *puid_next = NULL;
1294  unsigned int uid_next = 0;
1295  bool has_condstore = false;
1296  bool has_qresync = false;
1297  bool eval_condstore = false;
1298  bool eval_qresync = false;
1299  unsigned long long *pmodseq = NULL;
1300  unsigned long long hc_modseq = 0;
1301  char *uid_seqset = NULL;
1302 #endif /* USE_HCACHE */
1303 
1304  struct ImapAccountData *adata = imap_adata_get(m);
1305  struct ImapMboxData *mdata = imap_mdata_get(m);
1306  if (!adata || (adata->mailbox != m))
1307  return -1;
1308 
1309 #ifdef USE_HCACHE
1310 retry:
1311 #endif /* USE_HCACHE */
1312 
1313  /* make sure context has room to hold the mailbox */
1314  while (msn_end > m->email_max)
1315  mx_alloc_memory(m);
1316  imap_msn_reserve(&mdata->msn, msn_end);
1317  imap_alloc_uid_hash(adata, msn_end);
1318 
1319  oldmsgcount = m->msg_count;
1321  mdata->new_mail_count = 0;
1322 
1323 #ifdef USE_HCACHE
1324  imap_hcache_open(adata, mdata);
1325 
1326  if (mdata->hcache && initial_download)
1327  {
1328  size_t dlen = 0;
1329  uidvalidity = mutt_hcache_fetch_raw(mdata->hcache, "/UIDVALIDITY", 12, &dlen);
1330  puid_next = mutt_hcache_fetch_raw(mdata->hcache, "/UIDNEXT", 8, &dlen);
1331  if (puid_next)
1332  {
1333  uid_next = *(unsigned int *) puid_next;
1334  mutt_hcache_free_raw(mdata->hcache, &puid_next);
1335  }
1336 
1337  if (mdata->modseq)
1338  {
1340  has_condstore = true;
1341 
1342  /* If IMAP_CAP_QRESYNC and ImapQResync then NeoMutt sends ENABLE QRESYNC.
1343  * If we receive an ENABLED response back, then adata->qresync is set. */
1344  if (adata->qresync)
1345  has_qresync = true;
1346  }
1347 
1348  if (uidvalidity && uid_next && (*(uint32_t *) uidvalidity == mdata->uidvalidity))
1349  {
1350  size_t dlen2 = 0;
1351  evalhc = true;
1352  pmodseq = mutt_hcache_fetch_raw(mdata->hcache, "/MODSEQ", 7, &dlen2);
1353  if (pmodseq)
1354  {
1355  hc_modseq = *pmodseq;
1356  mutt_hcache_free_raw(mdata->hcache, (void **) &pmodseq);
1357  }
1358  if (hc_modseq)
1359  {
1360  if (has_qresync)
1361  {
1362  uid_seqset = imap_hcache_get_uid_seqset(mdata);
1363  if (uid_seqset)
1364  eval_qresync = true;
1365  }
1366 
1367  if (!eval_qresync && has_condstore)
1368  eval_condstore = true;
1369  }
1370  }
1372  }
1373  if (evalhc)
1374  {
1375  if (eval_qresync)
1376  {
1377  if (read_headers_qresync_eval_cache(adata, uid_seqset) < 0)
1378  goto bail;
1379  }
1380  else
1381  {
1382  if (read_headers_normal_eval_cache(adata, msn_end, uid_next, has_condstore || has_qresync,
1383  eval_condstore) < 0)
1384  goto bail;
1385  }
1386 
1387  if ((eval_condstore || eval_qresync) && (hc_modseq != mdata->modseq))
1388  {
1390  hc_modseq, eval_qresync) < 0)
1391  {
1392  goto bail;
1393  }
1394  }
1395 
1396  /* Look for the first empty MSN and start there */
1397  while (msn_begin <= msn_end)
1398  {
1399  if (!imap_msn_get(&mdata->msn, msn_begin - 1))
1400  break;
1401  msn_begin++;
1402  }
1403  }
1404 #endif /* USE_HCACHE */
1405 
1406  if (read_headers_fetch_new(m, msn_begin, msn_end, evalhc, &maxuid, initial_download) < 0)
1407  goto bail;
1408 
1409 #ifdef USE_HCACHE
1410  if (eval_qresync && initial_download)
1411  {
1412  if (imap_verify_qresync(m) != 0)
1413  {
1414  eval_qresync = false;
1415  eval_condstore = false;
1416  evalhc = false;
1417  hc_modseq = 0;
1418  maxuid = 0;
1419  FREE(&uid_seqset);
1420  uidvalidity = NULL;
1421  uid_next = 0;
1422 
1423  goto retry;
1424  }
1425  }
1426 #endif /* USE_HCACHE */
1427 
1428  if (maxuid && (mdata->uid_next < maxuid + 1))
1429  mdata->uid_next = maxuid + 1;
1430 
1431 #ifdef USE_HCACHE
1432  mutt_hcache_store_raw(mdata->hcache, "/UIDVALIDITY", 12, &mdata->uidvalidity,
1433  sizeof(mdata->uidvalidity));
1434  if (maxuid && (mdata->uid_next < maxuid + 1))
1435  {
1436  mutt_debug(LL_DEBUG2, "Overriding UIDNEXT: %u -> %u\n", mdata->uid_next, maxuid + 1);
1437  mdata->uid_next = maxuid + 1;
1438  }
1439  if (mdata->uid_next > 1)
1440  {
1441  mutt_hcache_store_raw(mdata->hcache, "/UIDNEXT", 8, &mdata->uid_next,
1442  sizeof(mdata->uid_next));
1443  }
1444 
1445  /* We currently only sync CONDSTORE and QRESYNC on the initial download.
1446  * To do it more often, we'll need to deal with flag updates combined with
1447  * unsync'ed local flag changes. We'll also need to properly sync flags to
1448  * the header cache on close. I'm not sure it's worth the added complexity. */
1449  if (initial_download)
1450  {
1451  if (has_condstore || has_qresync)
1452  {
1453  mutt_hcache_store_raw(mdata->hcache, "/MODSEQ", 7, &mdata->modseq,
1454  sizeof(mdata->modseq));
1455  }
1456  else
1457  mutt_hcache_delete_record(mdata->hcache, "/MODSEQ", 7);
1458 
1459  if (has_qresync)
1461  else
1463  }
1464 #endif /* USE_HCACHE */
1465 
1466  if (m->msg_count > oldmsgcount)
1467  {
1468  /* TODO: it's not clear to me why we are calling mx_alloc_memory
1469  * yet again. */
1470  mx_alloc_memory(m);
1471  }
1472 
1473  mdata->reopen |= IMAP_REOPEN_ALLOW;
1474 
1475  retval = msn_end;
1476 
1477 bail:
1478 #ifdef USE_HCACHE
1480  FREE(&uid_seqset);
1481 #endif /* USE_HCACHE */
1482 
1483  return retval;
1484 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ imap_set_flags()

char* imap_set_flags ( struct Mailbox m,
struct Email e,
char *  s,
bool *  server_changes 
)

fill the message header according to the server flags

Parameters
[in]mImap Selected Mailbox
[in]eEmail
[in]sCommand string
[out]server_changesSet to true if the flags have changed
Return values
ptrThe end of flags string
NULLFailure

Expects a flags line of the form "FLAGS (flag flag ...)"

imap_set_flags: fill out the message header according to the flags from the server. Expects a flags line of the form "FLAGS (flag flag ...)"

Sets server_changes to 1 if a change to a flag is made, or in the case of e->changed, if a change to a flag would have been made.

Definition at line 1847 of file message.c.

1848 {
1849  struct ImapAccountData *adata = imap_adata_get(m);
1850  if (!adata || (adata->mailbox != m))
1851  return NULL;
1852 
1853  struct ImapHeader newh = { 0 };
1854  struct ImapEmailData old_edata = { 0 };
1855  int local_changes = e->changed;
1856 
1857  struct ImapEmailData *edata = e->edata;
1858  newh.edata = edata;
1859 
1860  mutt_debug(LL_DEBUG2, "parsing FLAGS\n");
1861  s = msg_parse_flags(&newh, s);
1862  if (!s)
1863  return NULL;
1864 
1865  /* Update tags system */
1866  /* We take a copy of the tags so we can split the string */
1867  char *tags_copy = mutt_str_dup(edata->flags_remote);
1868  driver_tags_replace(&e->tags, tags_copy);
1869  FREE(&tags_copy);
1870 
1871  /* YAUH (yet another ugly hack): temporarily set context to
1872  * read-write even if it's read-only, so *server* updates of
1873  * flags can be processed by mutt_set_flag. mailbox->changed must
1874  * be restored afterwards */
1875  bool readonly = m->readonly;
1876  m->readonly = false;
1877 
1878  /* This is redundant with the following two checks. Removing:
1879  * mutt_set_flag (m, e, MUTT_NEW, !(edata->read || edata->old)); */
1880  set_changed_flag(m, e, local_changes, server_changes, MUTT_OLD, old_edata.old,
1881  edata->old, e->old);
1882  set_changed_flag(m, e, local_changes, server_changes, MUTT_READ,
1883  old_edata.read, edata->read, e->read);
1884  set_changed_flag(m, e, local_changes, server_changes, MUTT_DELETE,
1885  old_edata.deleted, edata->deleted, e->deleted);
1886  set_changed_flag(m, e, local_changes, server_changes, MUTT_FLAG,
1887  old_edata.flagged, edata->flagged, e->flagged);
1888  set_changed_flag(m, e, local_changes, server_changes, MUTT_REPLIED,
1889  old_edata.replied, edata->replied, e->replied);
1890 
1891  /* this message is now definitively *not* changed (mutt_set_flag
1892  * marks things changed as a side-effect) */
1893  if (local_changes == 0)
1894  e->changed = false;
1895  m->changed &= !readonly;
1896  m->readonly = readonly;
1897 
1898  return s;
1899 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ imap_cache_del()

int imap_cache_del ( struct Mailbox m,
struct Email e 
)

Delete an email from the body cache.

Parameters
mSelected Imap Mailbox
eEmail
Return values
0Success
-1Failure

Definition at line 1796 of file message.c.

1797 {
1798  struct ImapAccountData *adata = imap_adata_get(m);
1799  struct ImapMboxData *mdata = imap_mdata_get(m);
1800 
1801  if (!e || !adata || (adata->mailbox != m))
1802  return -1;
1803 
1804  mdata->bcache = msg_cache_open(m);
1805  char id[64];
1806  snprintf(id, sizeof(id), "%u-%u", mdata->uidvalidity, imap_edata_get(e)->uid);
1807  return mutt_bcache_del(mdata->bcache, id);
1808 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ imap_cache_clean()

int imap_cache_clean ( struct Mailbox m)

Delete all the entries in the message cache.

Parameters
mSelectedImap Mailbox
Return values
0Always

Definition at line 1815 of file message.c.

1816 {
1817  struct ImapAccountData *adata = imap_adata_get(m);
1818  struct ImapMboxData *mdata = imap_mdata_get(m);
1819 
1820  if (!adata || (adata->mailbox != m))
1821  return -1;
1822 
1823  mdata->bcache = msg_cache_open(m);
1825 
1826  return 0;
1827 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ imap_append_message()

int imap_append_message ( struct Mailbox m,
struct Message msg 
)

Write an email back to the server.

Parameters
mMailbox
msgMessage to save
Return values
0Success
-1Failure

Definition at line 1493 of file message.c.

1494 {
1495  if (!m || !msg)
1496  return -1;
1497 
1498  FILE *fp = NULL;
1499  char buf[1024 * 2];
1500  char internaldate[IMAP_DATELEN];
1501  char imap_flags[128];
1502  size_t len;
1503  struct Progress progress;
1504  size_t sent;
1505  int c, last;
1506  int rc;
1507 
1508  struct ImapAccountData *adata = imap_adata_get(m);
1509  struct ImapMboxData *mdata = imap_mdata_get(m);
1510 
1511  fp = fopen(msg->path, "r");
1512  if (!fp)
1513  {
1514  mutt_perror(msg->path);
1515  goto fail;
1516  }
1517 
1518  /* currently we set the \Seen flag on all messages, but probably we
1519  * should scan the message Status header for flag info. Since we're
1520  * already rereading the whole file for length it isn't any more
1521  * expensive (it'd be nice if we had the file size passed in already
1522  * by the code that writes the file, but that's a lot of changes.
1523  * Ideally we'd have an Email structure with flag info here... */
1524  for (last = EOF, len = 0; (c = fgetc(fp)) != EOF; last = c)
1525  {
1526  if ((c == '\n') && (last != '\r'))
1527  len++;
1528 
1529  len++;
1530  }
1531  rewind(fp);
1532 
1533  if (m->verbose)
1534  mutt_progress_init(&progress, _("Uploading message..."), MUTT_PROGRESS_NET, len);
1535 
1536  mutt_date_make_imap(internaldate, sizeof(internaldate), msg->received);
1537 
1538  imap_flags[0] = '\0';
1539  imap_flags[1] = '\0';
1540 
1541  if (msg->flags.read)
1542  mutt_str_cat(imap_flags, sizeof(imap_flags), " \\Seen");
1543  if (msg->flags.replied)
1544  mutt_str_cat(imap_flags, sizeof(imap_flags), " \\Answered");
1545  if (msg->flags.flagged)
1546  mutt_str_cat(imap_flags, sizeof(imap_flags), " \\Flagged");
1547  if (msg->flags.draft)
1548  mutt_str_cat(imap_flags, sizeof(imap_flags), " \\Draft");
1549 
1550  snprintf(buf, sizeof(buf), "APPEND %s (%s) \"%s\" {%lu}", mdata->munge_name,
1551  imap_flags + 1, internaldate, (unsigned long) len);
1552 
1553  imap_cmd_start(adata, buf);
1554 
1555  do
1556  {
1557  rc = imap_cmd_step(adata);
1558  } while (rc == IMAP_RES_CONTINUE);
1559 
1560  if (rc != IMAP_RES_RESPOND)
1561  goto cmd_step_fail;
1562 
1563  for (last = EOF, sent = len = 0; (c = fgetc(fp)) != EOF; last = c)
1564  {
1565  if ((c == '\n') && (last != '\r'))
1566  buf[len++] = '\r';
1567 
1568  buf[len++] = c;
1569 
1570  if (len > sizeof(buf) - 3)
1571  {
1572  sent += len;
1573  if (flush_buffer(buf, &len, adata->conn) < 0)
1574  goto fail;
1575  if (m->verbose)
1576  mutt_progress_update(&progress, sent, -1);
1577  }
1578  }
1579 
1580  if (len)
1581  if (flush_buffer(buf, &len, adata->conn) < 0)
1582  goto fail;
1583 
1584  if (mutt_socket_send(adata->conn, "\r\n") < 0)
1585  goto fail;
1586  mutt_file_fclose(&fp);
1587 
1588  do
1589  {
1590  rc = imap_cmd_step(adata);
1591  } while (rc == IMAP_RES_CONTINUE);
1592 
1593  if (rc != IMAP_RES_OK)
1594  goto cmd_step_fail;
1595 
1596  return 0;
1597 
1598 cmd_step_fail:
1599  mutt_debug(LL_DEBUG1, "command failed: %s\n", adata->buf);
1600  if (rc != IMAP_RES_BAD)
1601  {
1602  char *pc = imap_next_word(adata->buf); /* skip sequence number or token */
1603  pc = imap_next_word(pc); /* skip response code */
1604  if (*pc != '\0')
1605  mutt_error("%s", pc);
1606  }
1607 
1608 fail:
1609  mutt_file_fclose(&fp);
1610  return -1;
1611 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ imap_msg_open()

bool imap_msg_open ( struct Mailbox m,
struct Message msg,
int  msgno 
)

Open an email message in a Mailbox - Implements MxOps::msg_open()

Definition at line 1904 of file message.c.

1905 {
1906  struct Envelope *newenv = NULL;
1907  char buf[1024];
1908  char *pc = NULL;
1909  unsigned int bytes;
1910  struct Progress progress;
1911  unsigned int uid;
1912  bool retried = false;
1913  bool read;
1914  int rc;
1915 
1916  /* Sam's weird courier server returns an OK response even when FETCH
1917  * fails. Thanks Sam. */
1918  bool fetched = false;
1919 
1920  struct ImapAccountData *adata = imap_adata_get(m);
1921 
1922  if (!adata || (adata->mailbox != m))
1923  return false;
1924 
1925  struct Email *e = m->emails[msgno];
1926  if (!e)
1927  return false;
1928 
1929  msg->fp = msg_cache_get(m, e);
1930  if (msg->fp)
1931  {
1932  if (imap_edata_get(e)->parsed)
1933  return true;
1934  goto parsemsg;
1935  }
1936 
1937  /* This function is called in a few places after endwin()
1938  * e.g. mutt_pipe_message(). */
1939  bool output_progress = !isendwin() && m->verbose;
1940  if (output_progress)
1941  mutt_message(_("Fetching message..."));
1942 
1943  msg->fp = msg_cache_put(m, e);
1944  if (!msg->fp)
1945  {
1946  struct Buffer *path = mutt_buffer_pool_get();
1947  mutt_buffer_mktemp(path);
1948  msg->fp = mutt_file_fopen(mutt_buffer_string(path), "w+");
1949  unlink(mutt_buffer_string(path));
1950  mutt_buffer_pool_release(&path);
1951 
1952  if (!msg->fp)
1953  return false;
1954  }
1955 
1956  /* mark this header as currently inactive so the command handler won't
1957  * also try to update it. HACK until all this code can be moved into the
1958  * command handler */
1959  e->active = false;
1960 
1961  snprintf(buf, sizeof(buf), "UID FETCH %u %s", imap_edata_get(e)->uid,
1962  ((adata->capabilities & IMAP_CAP_IMAP4REV1) ?
1963  (C_ImapPeek ? "BODY.PEEK[]" : "BODY[]") :
1964  "RFC822"));
1965 
1966  imap_cmd_start(adata, buf);
1967  do
1968  {
1969  rc = imap_cmd_step(adata);
1970  if (rc != IMAP_RES_CONTINUE)
1971  break;
1972 
1973  pc = adata->buf;
1974  pc = imap_next_word(pc);
1975  pc = imap_next_word(pc);
1976 
1977  if (mutt_istr_startswith(pc, "FETCH"))
1978  {
1979  while (*pc)
1980  {
1981  pc = imap_next_word(pc);
1982  if (pc[0] == '(')
1983  pc++;
1984  if (mutt_istr_startswith(pc, "UID"))
1985  {
1986  pc = imap_next_word(pc);
1987  if (mutt_str_atoui(pc, &uid) < 0)
1988  goto bail;
1989  if (uid != imap_edata_get(e)->uid)
1990  {
1991  mutt_error(_(
1992  "The message index is incorrect. Try reopening the mailbox."));
1993  }
1994  }
1995  else if (mutt_istr_startswith(pc, "RFC822") || mutt_istr_startswith(pc, "BODY[]"))
1996  {
1997  pc = imap_next_word(pc);
1998  if (imap_get_literal_count(pc, &bytes) < 0)
1999  {
2000  imap_error("imap_msg_open()", buf);
2001  goto bail;
2002  }
2003  if (output_progress)
2004  {
2005  mutt_progress_init(&progress, _("Fetching message..."), MUTT_PROGRESS_NET, bytes);
2006  }
2007  if (imap_read_literal(msg->fp, adata, bytes, output_progress ? &progress : NULL) < 0)
2008  {
2009  goto bail;
2010  }
2011  /* pick up trailing line */
2012  rc = imap_cmd_step(adata);
2013  if (rc != IMAP_RES_CONTINUE)
2014  goto bail;
2015  pc = adata->buf;
2016 
2017  fetched = true;
2018  }
2019  /* UW-IMAP will provide a FLAGS update here if the FETCH causes a
2020  * change (eg from \Unseen to \Seen).
2021  * Uncommitted changes in neomutt take precedence. If we decide to
2022  * incrementally update flags later, this won't stop us syncing */
2023  else if (!e->changed && mutt_istr_startswith(pc, "FLAGS"))
2024  {
2025  pc = imap_set_flags(m, e, pc, NULL);
2026  if (!pc)
2027  goto bail;
2028  }
2029  }
2030  }
2031  } while (rc == IMAP_RES_CONTINUE);
2032 
2033  /* see comment before command start. */
2034  e->active = true;
2035 
2036  fflush(msg->fp);
2037  if (ferror(msg->fp))
2038  goto bail;
2039 
2040  if (rc != IMAP_RES_OK)
2041  goto bail;
2042 
2043  if (!fetched || !imap_code(adata->buf))
2044  goto bail;
2045 
2046  msg_cache_commit(m, e);
2047 
2048 parsemsg:
2049  /* Update the header information. Previously, we only downloaded a
2050  * portion of the headers, those required for the main display. */
2051  rewind(msg->fp);
2052  /* It may be that the Status header indicates a message is read, but the
2053  * IMAP server doesn't know the message has been \Seen. So we capture
2054  * the server's notion of 'read' and if it differs from the message info
2055  * picked up in mutt_rfc822_read_header, we mark the message (and context
2056  * changed). Another possibility: ignore Status on IMAP? */
2057  read = e->read;
2058  newenv = mutt_rfc822_read_header(msg->fp, e, false, false);
2059  mutt_env_merge(e->env, &newenv);
2060 
2061  /* see above. We want the new status in e->read, so we unset it manually
2062  * and let mutt_set_flag set it correctly, updating context. */
2063  if (read != e->read)
2064  {
2065  e->read = read;
2066  mutt_set_flag(m, e, MUTT_NEW, read);
2067  }
2068 
2069  e->lines = 0;
2070  fgets(buf, sizeof(buf), msg->fp);
2071  while (!feof(msg->fp))
2072  {
2073  e->lines++;
2074  fgets(buf, sizeof(buf), msg->fp);
2075  }
2076 
2077  e->body->length = ftell(msg->fp) - e->body->offset;
2078 
2079  mutt_clear_error();
2080  rewind(msg->fp);
2081  imap_edata_get(e)->parsed = true;
2082 
2083  /* retry message parse if cached message is empty */
2084  if (!retried && ((e->lines == 0) || (e->body->length == 0)))
2085  {
2086  imap_cache_del(m, e);
2087  retried = true;
2088  goto parsemsg;
2089  }
2090 
2091  return true;
2092 
2093 bail:
2094  e->active = true;
2095  mutt_file_fclose(&msg->fp);
2096  imap_cache_del(m, e);
2097  return false;
2098 }
+ Here is the call graph for this function:

◆ imap_msg_close()

int imap_msg_close ( struct Mailbox m,
struct Message msg 
)

Close an email - Implements MxOps::msg_close()

Note
May also return EOF Failure, see errno

Definition at line 2119 of file message.c.

2120 {
2121  return mutt_file_fclose(&msg->fp);
2122 }
+ Here is the call graph for this function:

◆ imap_msg_commit()

int imap_msg_commit ( struct Mailbox m,
struct Message msg 
)

Save changes to an email - Implements MxOps::msg_commit()

Note
May also return EOF Failure, see errno

Definition at line 2105 of file message.c.

2106 {
2107  int rc = mutt_file_fclose(&msg->fp);
2108  if (rc != 0)
2109  return rc;
2110 
2111  return imap_append_message(m, msg);
2112 }
+ Here is the call graph for this function:

◆ imap_msg_save_hcache()

int imap_msg_save_hcache ( struct Mailbox m,
struct Email e 
)

Save message to the header cache - Implements MxOps::msg_save_hcache()

Definition at line 2127 of file message.c.

2128 {
2129  int rc = 0;
2130 #ifdef USE_HCACHE
2131  bool close_hc = true;
2132  struct ImapAccountData *adata = imap_adata_get(m);
2133  struct ImapMboxData *mdata = imap_mdata_get(m);
2134  if (!mdata || !adata)
2135  return -1;
2136  if (mdata->hcache)
2137  close_hc = false;
2138  else
2139  imap_hcache_open(adata, mdata);
2140  rc = imap_hcache_put(mdata, e);
2141  if (close_hc)
2143 #endif
2144  return rc;
2145 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ imap_hcache_open()

void imap_hcache_open ( struct ImapAccountData adata,
struct ImapMboxData mdata 
)

Open a header cache.

Parameters
adataImap Account data
mdataImap Mailbox data

Definition at line 299 of file util.c.

300 {
301  if (!adata || !mdata)
302  return;
303 
304  if (mdata->hcache)
305  return;
306 
307  struct HeaderCache *hc = NULL;
308  struct Buffer *mbox = mutt_buffer_pool_get();
309  struct Buffer *cachepath = mutt_buffer_pool_get();
310 
311  imap_cachepath(adata->delim, mdata->name, mbox);
312 
313  if (strstr(mutt_buffer_string(mbox), "/../") ||
314  mutt_str_equal(mutt_buffer_string(mbox), "..") ||
315  mutt_strn_equal(mutt_buffer_string(mbox), "../", 3))
316  {
317  goto cleanup;
318  }
319  size_t len = mutt_buffer_len(mbox);
320  if ((len > 3) && (strcmp(mutt_buffer_string(mbox) + len - 3, "/..") == 0))
321  goto cleanup;
322 
323  struct Url url = { 0 };
324  mutt_account_tourl(&adata->conn->account, &url);
325  url.path = mbox->data;
326  url_tobuffer(&url, cachepath, U_PATH);
327 
329 
330 cleanup:
332  mutt_buffer_pool_release(&cachepath);
333  mdata->hcache = hc;
334 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ imap_hcache_close()

void imap_hcache_close ( struct ImapMboxData mdata)

Close the header cache.

Parameters
mdataImap Mailbox data

Definition at line 340 of file util.c.

341 {
342  if (!mdata->hcache)
343  return;
344 
345  mutt_hcache_close(mdata->hcache);
346  mdata->hcache = NULL;
347 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ imap_hcache_get()

struct Email* imap_hcache_get ( struct ImapMboxData mdata,
unsigned int  uid 
)

Get a header cache entry by its UID.

Parameters
mdataImap Mailbox data
uidUID to find
Return values
ptrEmail
NULLFailure

Definition at line 356 of file util.c.

357 {
358  if (!mdata->hcache)
359  return NULL;
360 
361  char key[16];
362 
363  sprintf(key, "/%u", uid);
364  struct HCacheEntry hce =
365  mutt_hcache_fetch(mdata->hcache, key, mutt_str_len(key), mdata->uidvalidity);
366  if (!hce.email && hce.uidvalidity)
367  {
368  mutt_debug(LL_DEBUG3, "hcache uidvalidity mismatch: %u\n", hce.uidvalidity);
369  }
370 
371  return hce.email;
372 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ imap_hcache_put()

int imap_hcache_put ( struct ImapMboxData mdata,
struct Email e 
)

Add an entry to the header cache.

Parameters
mdataImap Mailbox data
eEmail
Return values
0Success
-1Failure

Definition at line 381 of file util.c.

382 {
383  if (!mdata->hcache)
384  return -1;
385 
386  char key[16];
387 
388  sprintf(key, "/%u", imap_edata_get(e)->uid);
389  return mutt_hcache_store(mdata->hcache, key, mutt_str_len(key), e, mdata->uidvalidity);
390 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ imap_hcache_del()

int imap_hcache_del ( struct ImapMboxData mdata,
unsigned int  uid 
)

Delete an item from the header cache.

Parameters
mdataImap Mailbox data
uidUID of entry to delete
Return values
0Success
-1Failure

Definition at line 399 of file util.c.

400 {
401  if (!mdata->hcache)
402  return -1;
403 
404  char key[16];
405 
406  sprintf(key, "/%u", uid);
407  return mutt_hcache_delete_record(mdata->hcache, key, mutt_str_len(key));
408 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ imap_hcache_store_uid_seqset()

int imap_hcache_store_uid_seqset ( struct ImapMboxData mdata)

Store a UID Sequence Set in the header cache.

Parameters
mdataImap Mailbox data
Return values
0Success
-1Error

Definition at line 416 of file util.c.

417 {
418  if (!mdata->hcache)
419  return -1;
420 
421  /* The seqset is likely large. Preallocate to reduce reallocs */
422  struct Buffer buf = mutt_buffer_make(8192);
423  imap_msn_index_to_uid_seqset(&buf, mdata);
424 
425  int rc = mutt_hcache_store_raw(mdata->hcache, "/UIDSEQSET", 10, buf.data,
426  mutt_buffer_len(&buf) + 1);
427  mutt_debug(LL_DEBUG3, "Stored /UIDSEQSET %s\n", buf.data);
428  mutt_buffer_dealloc(&buf);
429  return rc;
430 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ imap_hcache_clear_uid_seqset()

int imap_hcache_clear_uid_seqset ( struct ImapMboxData mdata)

Delete a UID Sequence Set from the header cache.

Parameters
mdataImap Mailbox data
Return values
0Success
-1Error

Definition at line 438 of file util.c.

439 {
440  if (!mdata->hcache)
441  return -1;
442 
443  return mutt_hcache_delete_record(mdata->hcache, "/UIDSEQSET", 10);
444 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ imap_hcache_get_uid_seqset()

char* imap_hcache_get_uid_seqset ( struct ImapMboxData mdata)

Get a UID Sequence Set from the header cache.

Parameters
mdataImap Mailbox data
Return values
ptrUID Sequence Set
NULLError

Definition at line 452 of file util.c.

453 {
454  if (!mdata->hcache)
455  return NULL;
456 
457  char *seqset = NULL;
458  size_t dlen = 0;
459  char *hc_seqset = mutt_hcache_fetch_raw(mdata->hcache, "/UIDSEQSET", 10, &dlen);
460  if (hc_seqset)
461  {
462  seqset = mutt_strn_dup(hc_seqset, dlen);
463  mutt_hcache_free_raw(mdata->hcache, (void **) &hc_seqset);
464  }
465  mutt_debug(LL_DEBUG3, "Retrieved /UIDSEQSET %s\n", NONULL(seqset));
466 
467  return seqset;
468 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ imap_continue()

enum QuadOption imap_continue ( const char *  msg,
const char *  resp 
)

display a message and ask the user if they want to go on

Parameters
msgLocation of the error
respMessage for user
Return values
QuadOptionResult, e.g. MUTT_NO

Definition at line 652 of file util.c.

653 {
654  imap_error(msg, resp);
655  return mutt_yesorno(_("Continue?"), MUTT_NO);
656 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ imap_error()

void imap_error ( const char *  where,
const char *  msg 
)

show an error and abort

Parameters
whereLocation of the error
msgMessage for user

Definition at line 663 of file util.c.

664 {
665  mutt_error("%s [%s]", where, msg);
666 }
+ Here is the caller graph for this function:

◆ imap_mdata_cache_reset()

void imap_mdata_cache_reset ( struct ImapMboxData mdata)

Release and clear cache data of ImapMboxData structure.

Parameters
mdataImap Mailbox data

Definition at line 108 of file util.c.

109 {
110  mutt_hash_free(&mdata->uid_hash);
111  imap_msn_free(&mdata->msn);
112  mutt_bcache_close(&mdata->bcache);
113 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ imap_fix_path()

char* imap_fix_path ( char  delim,
const char *  mailbox,
char *  path,
size_t  plen 
)

Fix up the imap path.

Parameters
delimDelimiter specified by the server, '\0' for $imap_delim_chars
mailboxMailbox path
pathBuffer for the result
plenLength of buffer
Return values
ptrFixed-up path
Note
if delim is '\0', the first character in mailbox matching any of the characters in $imap_delim_chars is used as a delimiter.

This is necessary because the rest of neomutt assumes a hierarchy delimiter of '/', which is not necessarily true in IMAP. Additionally, the filesystem converts multiple hierarchy delimiters into a single one, ie "///" is equal to "/". IMAP servers are not required to do this. Moreover, IMAP servers may dislike the path ending with the delimiter.

Definition at line 685 of file util.c.

686 {
687  int i = 0;
688  for (; mailbox && *mailbox && (i < plen - 1); i++)
689  {
690  if (*mailbox == delim || (!delim && strchr(NONULL(C_ImapDelimChars), *mailbox)))
691  {
692  delim = *mailbox;
693  /* Skip multiple occurrences of delim */
694  while (*mailbox && *(mailbox + 1) == delim)
695  mailbox++;
696  }
697  path[i] = *mailbox++;
698  }
699 
700  /* Do not terminate with a delimiter */
701  if (i && path[i - 1] == delim)
702  i--;
703 
704  /* Ensure null termination */
705  path[i] = '\0';
706  return path;
707 }
+ Here is the caller graph for this function:

◆ imap_cachepath()

void imap_cachepath ( char  delim,
const char *  mailbox,
struct Buffer dest 
)

Generate a cache path for a mailbox.

Parameters
delimImap server delimiter
mailboxMailbox name
destBuffer to store cache path

Definition at line 715 of file util.c.

716 {
717  const char *p = mailbox;
718  mutt_buffer_reset(dest);
719  if (!p)
720  return;
721 
722  while (*p)
723  {
724  if (p[0] == delim)
725  {
726  mutt_buffer_addch(dest, '/');
727  /* simple way to avoid collisions with UIDs */
728  if ((p[1] >= '0') && (p[1] <= '9'))
729  mutt_buffer_addch(dest, '_');
730  }
731  else
732  mutt_buffer_addch(dest, *p);
733  p++;
734  }
735 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ imap_get_literal_count()

int imap_get_literal_count ( const char *  buf,
unsigned int *  bytes 
)

write number of bytes in an IMAP literal into bytes

Parameters
[in]bufNumber as a string
[out]bytesResulting number
Return values
0Success
-1Failure

Definition at line 744 of file util.c.

745 {
746  char *pc = NULL;
747  char *pn = NULL;
748 
749  if (!buf || !(pc = strchr(buf, '{')))
750  return -1;
751 
752  pc++;
753  pn = pc;
754  while (isdigit((unsigned char) *pc))
755  pc++;
756  *pc = '\0';
757  if (mutt_str_atoui(pn, bytes) < 0)
758  return -1;
759 
760  return 0;
761 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ imap_get_qualifier()

char* imap_get_qualifier ( char *  buf)

Get the qualifier from a tagged response.

Parameters
bufCommand string to process
Return values
ptrStart of the qualifier

In a tagged response, skip tag and status for the qualifier message. Used by imap_copy_message for TRYCREATE

Definition at line 771 of file util.c.

772 {
773  char *s = buf;
774 
775  /* skip tag */
776  s = imap_next_word(s);
777  /* skip OK/NO/BAD response */
778  s = imap_next_word(s);
779 
780  return s;
781 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ imap_next_word()

char* imap_next_word ( char *  s)

Find where the next IMAP word begins.

Parameters
sCommand string to process
Return values
ptrNext IMAP word

Definition at line 788 of file util.c.

789 {
790  bool quoted = false;
791 
792  while (*s)
793  {
794  if (*s == '\\')
795  {
796  s++;
797  if (*s)
798  s++;
799  continue;
800  }
801  if (*s == '\"')
802  quoted = !quoted;
803  if (!quoted && IS_SPACE(*s))
804  break;
805  s++;
806  }
807 
808  SKIPWS(s);
809  return s;
810 }
+ Here is the caller graph for this function:

◆ imap_qualify_path()

void imap_qualify_path ( char *  buf,
size_t  buflen,
struct ConnAccount cac,
char *  path 
)

Make an absolute IMAP folder target.

Parameters
bufBuffer for the result
buflenLength of buffer
cacConnAccount of the account
pathPath relative to the mailbox

Definition at line 819 of file util.c.

820 {
821  struct Url url = { 0 };
822  mutt_account_tourl(cac, &url);
823  url.path = path;
824  url_tostring(&url, buf, buflen, U_NO_FLAGS);
825 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ imap_quote_string()

void imap_quote_string ( char *  dest,
size_t  dlen,
const char *  src,
bool  quote_backtick 
)

quote string according to IMAP rules

Parameters
destBuffer for the result
dlenLength of the buffer
srcString to be quoted
quote_backtickIf true, quote backticks too

Surround string with quotes, escape " and \ with backslash

Definition at line 836 of file util.c.

837 {
838  const char *quote = "`\"\\";
839  if (!quote_backtick)
840  quote++;
841 
842  char *pt = dest;
843  const char *s = src;
844 
845  *pt++ = '"';
846  /* save room for quote-chars */
847  dlen -= 3;
848 
849  for (; *s && dlen; s++)
850  {
851  if (strchr(quote, *s))
852  {
853  if (dlen < 2)
854  break;
855  dlen -= 2;
856  *pt++ = '\\';
857  *pt++ = *s;
858  }
859  else
860  {
861  *pt++ = *s;
862  dlen--;
863  }
864  }
865  *pt++ = '"';
866  *pt = '\0';
867 }
+ Here is the caller graph for this function:

◆ imap_unquote_string()

void imap_unquote_string ( char *  s)

equally stupid unquoting routine

Parameters
sString to be unquoted

Definition at line 873 of file util.c.

874 {
875  char *d = s;
876 
877  if (*s == '\"')
878  s++;
879  else
880  return;
881 
882  while (*s)
883  {
884  if (*s == '\"')
885  {
886  *d = '\0';
887  return;
888  }
889  if (*s == '\\')
890  {
891  s++;
892  }
893  if (*s)
894  {
895  *d = *s;
896  d++;
897  s++;
898  }
899  }
900  *d = '\0';
901 }
+ Here is the caller graph for this function:

◆ imap_munge_mbox_name()

void imap_munge_mbox_name ( bool  unicode,
char *  dest,
size_t  dlen,
const char *  src 
)

Quote awkward characters in a mailbox name.

Parameters
unicodetrue if Unicode is allowed
destBuffer to store safe mailbox name
dlenLength of buffer
srcMailbox name

Definition at line 910 of file util.c.

911 {
912  char *buf = mutt_str_dup(src);
913  imap_utf_encode(unicode, &buf);
914 
915  imap_quote_string(dest, dlen, buf, false);
916 
917  FREE(&buf);
918 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ imap_unmunge_mbox_name()

void imap_unmunge_mbox_name ( bool  unicode,
char *  s 
)

Remove quoting from a mailbox name.

Parameters
unicodetrue if Unicode is allowed
sMailbox name

The string will be altered in-place.

Definition at line 927 of file util.c.

928 {
930 
931  char *buf = mutt_str_dup(s);
932  if (buf)
933  {
934  imap_utf_decode(unicode, &buf);
935  strncpy(s, buf, strlen(s));
936  }
937 
938  FREE(&buf);
939 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_seqset_iterator_new()

struct SeqsetIterator* mutt_seqset_iterator_new ( const char *  seqset)

Create a new Sequence Set Iterator.

Parameters
seqsetSource Sequence Set
Return values
ptrNewly allocated Sequence Set Iterator

Definition at line 1074 of file util.c.

1075 {
1076  if (!seqset || (*seqset == '\0'))
1077  return NULL;
1078 
1079  struct SeqsetIterator *iter = mutt_mem_calloc(1, sizeof(struct SeqsetIterator));
1080  iter->full_seqset = mutt_str_dup(seqset);
1081  iter->eostr = strchr(iter->full_seqset, '\0');
1082  iter->substr_cur = iter->substr_end = iter->full_seqset;
1083 
1084  return iter;
1085 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_seqset_iterator_next()

int mutt_seqset_iterator_next ( struct SeqsetIterator iter,
unsigned int *  next 
)

Get the next UID from a Sequence Set.

Parameters
[in]iterSequence Set Iterator
[out]nextNext UID in set
Return values
0Next sequence is generated
1Iterator is finished
-1error

Definition at line 1095 of file util.c.

1096 {
1097  if (!iter || !next)
1098  return -1;
1099 
1100  if (iter->in_range)
1101  {
1102  if ((iter->down && (iter->range_cur == (iter->range_end - 1))) ||
1103  (!iter->down && (iter->range_cur == (iter->range_end + 1))))
1104  {
1105  iter->in_range = 0;
1106  }
1107  }
1108 
1109  if (!iter->in_range)
1110  {
1111  iter->substr_cur = iter->substr_end;
1112  if (iter->substr_cur == iter->eostr)
1113  return 1;
1114 
1115  while (!*(iter->substr_cur))
1116  iter->substr_cur++;
1117  iter->substr_end = strchr(iter->substr_cur, ',');
1118  if (!iter->substr_end)
1119  iter->substr_end = iter->eostr;
1120  else
1121  *(iter->substr_end) = '\0';
1122 
1123  char *range_sep = strchr(iter->substr_cur, ':');
1124  if (range_sep)
1125  *range_sep++ = '\0';
1126 
1127  if (mutt_str_atoui(iter->substr_cur, &iter->range_cur) != 0)
1128  return -1;
1129  if (range_sep)
1130  {
1131  if (mutt_str_atoui(range_sep, &iter->range_end) != 0)
1132  return -1;
1133  }
1134  else
1135  iter->range_end = iter->range_cur;
1136 
1137  iter->down = (iter->range_end < iter->range_cur);
1138  iter->in_range = 1;
1139  }
1140 
1141  *next = iter->range_cur;
1142  if (iter->down)
1143  iter->range_cur--;
1144  else
1145  iter->range_cur++;
1146 
1147  return 0;
1148 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_seqset_iterator_free()

void mutt_seqset_iterator_free ( struct SeqsetIterator **  ptr)

Free a Sequence Set Iterator.

Parameters
[out]ptrIterator to free

Definition at line 1154 of file util.c.

1155 {
1156  if (!ptr || !*ptr)
1157  return;
1158 
1159  struct SeqsetIterator *iter = *ptr;
1160  FREE(&iter->full_seqset);
1161  FREE(ptr);
1162 }
+ Here is the caller graph for this function:

◆ imap_account_match()

bool imap_account_match ( const struct ConnAccount a1,
const struct ConnAccount a2 
)

Compare two Accounts.

Parameters
a1First ConnAccount
a2Second ConnAccount
Return values
trueAccounts match

Definition at line 1043 of file util.c.

1044 {
1045  if (!a1 || !a2)
1046  return false;
1047  if (a1->type != a2->type)
1048  return false;
1049  if (!mutt_istr_equal(a1->host, a2->host))
1050  return false;
1051  if ((a1->port != 0) && (a2->port != 0) && (a1->port != a2->port))
1052  return false;
1053  if (a1->flags & a2->flags & MUTT_ACCT_USER)
1054  return strcmp(a1->user, a2->user) == 0;
1055 
1056  const char *user = NONULL(Username);
1057 
1058  if ((a1->type == MUTT_ACCT_TYPE_IMAP) && C_ImapUser)
1059  user = C_ImapUser;
1060 
1061  if (a1->flags & MUTT_ACCT_USER)
1062  return strcmp(a1->user, user) == 0;
1063  if (a2->flags & MUTT_ACCT_USER)
1064  return strcmp(a2->user, user) == 0;
1065 
1066  return true;
1067 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ imap_get_parent()

void imap_get_parent ( const char *  mbox,
char  delim,
char *  buf,
size_t  buflen 
)

Get an IMAP folder's parent.

Parameters
mboxMailbox whose parent is to be determined
delimPath delimiter
bufBuffer for the result
buflenLength of the buffer

Definition at line 122 of file util.c.

123 {
124  /* Make a copy of the mailbox name, but only if the pointers are different */
125  if (mbox != buf)
126  mutt_str_copy(buf, mbox, buflen);
127 
128  int n = mutt_str_len(buf);
129 
130  /* Let's go backwards until the next delimiter
131  *
132  * If buf[n] is a '/', the first n-- will allow us
133  * to ignore it. If it isn't, then buf looks like
134  * "/aaaaa/bbbb". There is at least one "b", so we can't skip
135  * the "/" after the 'a's.
136  *
137  * If buf == '/', then n-- => n == 0, so the loop ends
138  * immediately */
139  for (n--; (n >= 0) && (buf[n] != delim); n--)
140  ; // do nothing
141 
142  /* We stopped before the beginning. There is a trailing slash. */
143  if (n > 0)
144  {
145  /* Strip the trailing delimiter. */
146  buf[n] = '\0';
147  }
148  else
149  {
150  buf[0] = (n == 0) ? delim : '\0';
151  }
152 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_account_match()

bool mutt_account_match ( const struct ConnAccount a1,
const struct ConnAccount a2 
)

◆ imap_utf_encode()

void imap_utf_encode ( bool  unicode,
char **  s 
)

Encode email from local charset to UTF-8.

Parameters
[in]unicodetrue if Unicode is allowed
[out]sEmail to convert

Definition at line 316 of file utf7.c.

317 {
318  if (!C_Charset || !s || !*s)
319  return;
320 
321  if (unicode && mutt_ch_is_utf8(C_Charset))
322  {
323  return;
324  }
325 
327  {
328  FREE(s);
329  return;
330  }
331 
332  if (!unicode)
333  {
334  char *utf7 = utf8_to_utf7(*s, strlen(*s), NULL, 0);
335  FREE(s);
336  *s = utf7;
337  }
338 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ imap_utf_decode()

void imap_utf_decode ( bool  unicode,
char **  s 
)

Decode email from UTF-8 to local charset.

Parameters
[in]unicodetrue if Unicode is allowed
[out]sEmail to convert

Definition at line 345 of file utf7.c.

346 {
347  if (!C_Charset || !s || !*s)
348  return;
349 
350  if (unicode && mutt_ch_is_utf8(C_Charset))
351  {
352  return;
353  }
354 
355  if (!unicode)
356  {
357  char *utf8 = utf7_to_utf8(*s, strlen(*s), 0, 0);
358  FREE(s);
359  *s = utf8;
360  }
361 
363  {
364  FREE(s);
365  }
366 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ imap_allow_reopen()

void imap_allow_reopen ( struct Mailbox m)

Allow re-opening a folder upon expunge.

Parameters
mMailbox

Definition at line 1015 of file util.c.

1016 {
1017  struct ImapAccountData *adata = imap_adata_get(m);
1018  struct ImapMboxData *mdata = imap_mdata_get(m);
1019  if (!adata || !adata->mailbox || (adata->mailbox != m) || !mdata)
1020  return;
1021  mdata->reopen |= IMAP_REOPEN_ALLOW;
1022 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ imap_disallow_reopen()

void imap_disallow_reopen ( struct Mailbox m)

Disallow re-opening a folder upon expunge.

Parameters
mMailbox

Definition at line 1028 of file util.c.

1029 {
1030  struct ImapAccountData *adata = imap_adata_get(m);
1031  struct ImapMboxData *mdata = imap_mdata_get(m);
1032  if (!adata || !adata->mailbox || (adata->mailbox != m) || !mdata)
1033  return;
1034  mdata->reopen &= ~IMAP_REOPEN_ALLOW;
1035 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cmd_parse_search()

void cmd_parse_search ( struct ImapAccountData adata,
const char *  s 
)

store SEARCH response for later use

Parameters
adataImap Account data
sCommand string with search results

Definition at line 258 of file search.c.

259 {
260  unsigned int uid;
261  struct Email *e = NULL;
262  struct ImapMboxData *mdata = adata->mailbox->mdata;
263 
264  mutt_debug(LL_DEBUG2, "Handling SEARCH\n");
265 
266  while ((s = imap_next_word((char *) s)) && (*s != '\0'))
267  {
268  if (mutt_str_atoui(s, &uid) < 0)
269  continue;
270  e = mutt_hash_int_find(mdata->uid_hash, uid);
271  if (e)
272  e->matched = true;
273  }
274 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ C_ImapAuthenticators

struct Slist* C_ImapAuthenticators

Config: (imap) List of allowed IMAP authentication methods.

Definition at line 39 of file config.c.

◆ C_ImapCheckSubscribed

bool C_ImapCheckSubscribed

Config: (imap) When opening a mailbox, ask the server for a list of subscribed folders.

Definition at line 40 of file config.c.

◆ C_ImapCondstore

bool C_ImapCondstore

Config: (imap) Enable the CONDSTORE extension.

Definition at line 41 of file config.c.

◆ C_ImapDeflate

bool C_ImapDeflate

Config: (imap) Compress network traffic.

Definition at line 43 of file config.c.

◆ C_ImapDelimChars

char* C_ImapDelimChars

Config: (imap) Characters that denote separators in IMAP folders.

Definition at line 45 of file config.c.

◆ C_ImapFetchChunkSize

long C_ImapFetchChunkSize

Config: (imap) Download headers in blocks of this size.

Definition at line 46 of file config.c.

◆ C_ImapHeaders

char* C_ImapHeaders

Config: (imap) Additional email headers to download when getting index.

Definition at line 47 of file config.c.

◆ C_ImapIdle

bool C_ImapIdle

Config: (imap) Use the IMAP IDLE extension to check for new mail.

Definition at line 48 of file config.c.

◆ C_ImapLogin

char* C_ImapLogin

Config: (imap) Login name for the IMAP server (defaults to $imap_user)

Definition at line 51 of file config.c.

◆ C_ImapOauthRefreshCommand

char* C_ImapOauthRefreshCommand

Config: (imap) External command to generate OAUTH refresh token.

Definition at line 52 of file config.c.

◆ C_ImapPass

char* C_ImapPass

Config: (imap) Password for the IMAP server.

Definition at line 53 of file config.c.

◆ C_ImapPipelineDepth

short C_ImapPipelineDepth

Config: (imap) Number of IMAP commands that may be queued up.

Definition at line 56 of file config.c.

◆ C_ImapPollTimeout

short C_ImapPollTimeout

Config: (imap) Maximum time to wait for a server response.

Definition at line 57 of file config.c.

◆ C_ImapQresync

bool C_ImapQresync

Config: (imap) Enable the QRESYNC extension.

Definition at line 58 of file config.c.

◆ C_ImapRfc5161

bool C_ImapRfc5161

Config: (imap) Use the IMAP ENABLE extension to select capabilities.

Definition at line 59 of file config.c.

◆ C_ImapServerNoise

bool C_ImapServerNoise

Config: (imap) Display server warnings as error messages.

Definition at line 60 of file config.c.

◆ C_ImapUser

char* C_ImapUser

Config: (imap) Username for the IMAP server.

Definition at line 61 of file config.c.

Url::src
char * src
Raw URL string.
Definition: url.h:76
ImapMboxData::hcache
struct HeaderCache * hcache
Definition: mdata.h:62
Envelope
The header of an Email.
Definition: envelope.h:54
C_SslForceTls
bool C_SslForceTls
Config: (ssl) Require TLS encryption for all connections.
Definition: config.c:46
IMAP_RES_OK
#define IMAP_RES_OK
<tag> OK ...
Definition: private.h:58
C_ImapDeflate
bool C_ImapDeflate
Config: (imap) Compress network traffic.
Definition: config.c:43
read_headers_normal_eval_cache
static int read_headers_normal_eval_cache(struct ImapAccountData *adata, unsigned int msn_end, unsigned int uid_next, bool store_flag_updates, bool eval_condstore)
Retrieve data from the header cache.
Definition: message.c:658
msg_cache_commit
static int msg_cache_commit(struct Mailbox *m, struct Email *e)
Add to the message cache.
Definition: message.c:149
IMAP_RES_RESPOND
#define IMAP_RES_RESPOND
+
Definition: private.h:60
SeqsetIterator::range_cur
unsigned int range_cur
Definition: private.h:176
imap_cache_del
int imap_cache_del(struct Mailbox *m, struct Email *e)
Delete an email from the body cache.
Definition: message.c:1796
Message::flags
struct Message::@1 flags
Email::msgno
int msgno
Number displayed to the user.
Definition: email.h:87
imap_hcache_store_uid_seqset
int imap_hcache_store_uid_seqset(struct ImapMboxData *mdata)
Store a UID Sequence Set in the header cache.
Definition: util.c:416
imap_utf_decode
void imap_utf_decode(bool unicode, char **s)
Decode email from UTF-8 to local charset.
Definition: utf7.c:345
MUTT_PROGRESS_NET
@ MUTT_PROGRESS_NET
Progress tracks bytes, according to $net_inc
Definition: progress.h:44
SeqsetIterator::range_end
unsigned int range_end
Definition: private.h:177
C_ImapDelimChars
char * C_ImapDelimChars
Config: (imap) Characters that denote separators in IMAP folders.
Definition: config.c:45
ConnAccount
Login details for a remote server.
Definition: connaccount.h:51
IMAP_LOG_LTRL
#define IMAP_LOG_LTRL
Definition: private.h:52
Mailbox::rights
AclFlags rights
ACL bits, see AclFlags.
Definition: mailbox.h:121
mutt_hcache_open
struct HeaderCache * mutt_hcache_open(const char *path, const char *folder, hcache_namer_t namer)
Multiplexor for StoreOps::open.
Definition: hcache.c:322
msg_cache_get
static FILE * msg_cache_get(struct Mailbox *m, struct Email *e)
Get the message cache entry for an email.
Definition: message.c:107
MUTT_FLAG
@ MUTT_FLAG
Flagged messages.
Definition: mutt.h:102
imap_hcache_open
void imap_hcache_open(struct ImapAccountData *adata, struct ImapMboxData *mdata)
Open a header cache.
Definition: util.c:299
QuadOption
QuadOption
Possible values for a quad-option.
Definition: quad.h:36
imap_hcache_put
int imap_hcache_put(struct ImapMboxData *mdata, struct Email *e)
Add an entry to the header cache.
Definition: util.c:381
ImapMboxData::uid_next
unsigned int uid_next
Definition: mdata.h:51
ConnAccount::host
char host[128]
Server to login to.
Definition: connaccount.h:53
ImapExecResult
ImapExecResult
imap_exec return code
Definition: private.h:84
mutt_mem_calloc
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:50
NeoMutt::accounts
struct AccountList accounts
List of all Accounts.
Definition: neomutt.h:40
ImapMboxData::flags
struct ListHead flags
Definition: mdata.h:49
ImapEmailData::replied
bool replied
Definition: edata.h:40
_
#define _(a)
Definition: message.h:28
NONULL
#define NONULL(x)
Definition: string2.h:37
Email::lines
int lines
How many lines in the body of this message?
Definition: email.h:85
IMAP_EXPUNGE_PENDING
#define IMAP_EXPUNGE_PENDING
Messages on the server have been expunged.
Definition: private.h:70
Mailbox::emails
struct Email ** emails
Array of Emails.
Definition: mailbox.h:99
mutt_hcache_store_raw
int mutt_hcache_store_raw(struct HeaderCache *hc, const char *key, size_t keylen, void *data, size_t dlen)
store a key / data pair
Definition: hcache.c:584
mutt_strn_equal
bool mutt_strn_equal(const char *a, const char *b, size_t num)
Check for equality of two strings (to a maximum), safely.
Definition: string.c:593
IMAP_FATAL
@ IMAP_FATAL
Unrecoverable error occurred.
Definition: private.h:99
ImapMboxData::uid_hash
struct HashTable * uid_hash
Definition: mdata.h:58
Email::matched
bool matched
Search matches this Email.
Definition: email.h:68
IMAP_EXEC_SUCCESS
@ IMAP_EXEC_SUCCESS
Imap command executed or queued successfully.
Definition: private.h:86
ListNode
A List node for strings.
Definition: list.h:34
Buffer
String manipulation buffer.
Definition: buffer.h:33
IMAP_BYE
@ IMAP_BYE
Logged out from server.
Definition: private.h:100
Account::type
enum MailboxType type
Type of Mailboxes this Account contains.
Definition: account.h:38
ImapAccountData::closing
bool closing
If true, we are waiting for CLOSE completion.
Definition: adata.h:40
LL_DEBUG3
@ LL_DEBUG3
Log at debug level 3.
Definition: logging.h:42
Connection::account
struct ConnAccount account
Account details: username, password, etc.
Definition: connection.h:36
Body::offset
LOFF_T offset
offset where the actual data begins
Definition: body.h:44
IMAP_DISCONNECTED
@ IMAP_DISCONNECTED
Disconnected from server.
Definition: private.h:109
IMAP_IDLE
@ IMAP_IDLE
Connection is idle.
Definition: private.h:115
driver_tags_replace
bool driver_tags_replace(struct TagList *head, char *tags)
Replace all tags.
Definition: tags.c:185
mutt_file_fclose
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
Definition: file.c:153
cmd_status
static int cmd_status(const char *s)
parse response line for tagged OK/NO/BAD
Definition: command.c:238
mutt_socket_empty
void mutt_socket_empty(struct Connection *conn)
Clear out any queued data.
Definition: socket.c:312
MUTT_ACL_DELETE
#define MUTT_ACL_DELETE
Delete a message.
Definition: mailbox.h:66
mutt_buffer_dealloc
void mutt_buffer_dealloc(struct Buffer *buf)
Release the memory allocated by a buffer.
Definition: buffer.c:294
imap_msn_index_to_uid_seqset
static void imap_msn_index_to_uid_seqset(struct Buffer *buf, struct ImapMboxData *mdata)
Convert MSN index of UIDs to Seqset.
Definition: util.c:233
imap_authenticate
int imap_authenticate(struct ImapAccountData *adata)
Authenticate to an IMAP server.
Definition: auth.c:105
C_ImapQresync
bool C_ImapQresync
Config: (imap) Enable the QRESYNC extension.
Definition: config.c:58
C_SslStarttls
unsigned char C_SslStarttls
Config: (ssl) Use STARTTLS on servers advertising the capability.
Definition: config.c:47
ImapHeader::edata
struct ImapEmailData * edata
Definition: message.h:35
mutt_socket_readln_d
int mutt_socket_readln_d(char *buf, size_t buflen, struct Connection *conn, int dbg)
Read a line from a socket.
Definition: socket.c:245
IMAP_RES_NEW
#define IMAP_RES_NEW
ImapCommand.state additions.
Definition: private.h:61
mutt_buffer_add_printf
int mutt_buffer_add_printf(struct Buffer *buf, const char *fmt,...)
Format a string appending a Buffer.
Definition: buffer.c:203
MUTT_ICONV_NO_FLAGS
#define MUTT_ICONV_NO_FLAGS
No flags are set.
Definition: charset.h:73
mutt_account_tourl
void mutt_account_tourl(struct ConnAccount *cac, struct Url *url)
Fill URL with info from account.
Definition: mutt_account.c:79
ImapEmailData::flags_remote
char * flags_remote
Definition: edata.h:48
ImapEmailData::old
bool old
Definition: edata.h:37
imap_munge_mbox_name
void imap_munge_mbox_name(bool unicode, char *dest, size_t dlen, const char *src)
Quote awkward characters in a mailbox name.
Definition: util.c:910
make_msg_set
static int make_msg_set(struct Mailbox *m, struct Buffer *buf, enum MessageType flag, bool changed, bool invert, int *pos)
Make a message set.
Definition: imap.c:196
imap_mdata_new
struct ImapMboxData * imap_mdata_new(struct ImapAccountData *adata, const char *name)
Allocate and initialise a new ImapMboxData structure.
Definition: mdata.c:68
msg_cache_clean_cb
static int msg_cache_clean_cb(const char *id, struct BodyCache *bcache, void *data)
Delete an entry from the message cache - Implements bcache_list_t.
Definition: message.c:168
U_NO_FLAGS
#define U_NO_FLAGS
Definition: url.h:48
Slist::head
struct ListHead head
Definition: slist.h:48
imap_code
bool imap_code(const char *s)
Was the command successful.
Definition: command.c:1197
IMAP_CAP_ENABLE
#define IMAP_CAP_ENABLE
RFC5161.
Definition: private.h:138
mutt_buffer_mktemp
#define mutt_buffer_mktemp(buf)
Definition: muttlib.h:77
ImapAccountData::buf
char * buf
Definition: adata.h:56
ImapAccountData::capabilities
ImapCapFlags capabilities
Definition: adata.h:52
mutt_socket_readchar
int mutt_socket_readchar(struct Connection *conn, char *c)
simple read buffering to speed things up
Definition: socket.c:209
TAILQ_FOREACH
#define TAILQ_FOREACH(var, head, field)
Definition: queue.h:718
ImapAccountData::status
unsigned char status
ImapFlags, e.g. IMAP_FATAL.
Definition: adata.h:42
imap_cmd_step
int imap_cmd_step(struct ImapAccountData *adata)
Reads server responses from an IMAP command.
Definition: command.c:1074
ImapAccountData::cmdslots
int cmdslots
Definition: adata.h:67
mutt_socket_close
int mutt_socket_close(struct Connection *conn)
Close a socket.
Definition: socket.c:96
MUTT_YES
@ MUTT_YES
User answered 'Yes', or assume 'Yes'.
Definition: quad.h:40
imap_msn_reserve
void imap_msn_reserve(struct MSN *msn, size_t num)
Create / reallocate the cache.
Definition: msn.c:41
check_capabilities
static int check_capabilities(struct ImapAccountData *adata)
Make sure we can log in to this server.
Definition: imap.c:93
ImapEmailData::deleted
bool deleted
Definition: edata.h:38
mutt_str_dup
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:370
Message::received
time_t received
the time at which this message was received
Definition: mx.h:107
set_changed_flag
static void set_changed_flag(struct Mailbox *m, struct Email *e, int local_changes, bool *server_changes, enum MessageType flag_name, bool old_hd_flag, bool new_hd_flag, bool h_flag)
Have the flags of an email changed.
Definition: message.c:618
mutt_file_fopen
FILE * mutt_file_fopen(const char *path, const char *mode)
Call fopen() safely.
Definition: file.c:589
LL_DEBUG1
@ LL_DEBUG1
Log at debug level 1.
Definition: logging.h:40
IMAP_CMD_POLL
#define IMAP_CMD_POLL
Poll the tcp connection before running the imap command.
Definition: private.h:78
FREE
#define FREE(x)
Definition: memory.h:40
imap_next_word
char * imap_next_word(char *s)
Find where the next IMAP word begins.
Definition: util.c:788
SeqsetIterator::substr_cur
char * substr_cur
Definition: private.h:178
mutt_perror
#define mutt_perror(...)
Definition: logging.h:85
imap_alloc_uid_hash
static void imap_alloc_uid_hash(struct ImapAccountData *adata, unsigned int msn_count)
Create a Hash Table for the UIDs.
Definition: message.c:509
imap_hcache_del
int imap_hcache_del(struct ImapMboxData *mdata, unsigned int uid)
Delete an item from the header cache.
Definition: util.c:399
mutt_ch_convert_string
int mutt_ch_convert_string(char **ps, const char *from, const char *to, uint8_t flags)
Convert a string between encodings.
Definition: charset.c:754
MUTT_ABORT
@ MUTT_ABORT
User aborted the question (with Ctrl-G)
Definition: quad.h:38
ImapAccountData::lastread
time_t lastread
last time we read a command for the server
Definition: adata.h:55
mutt_buffer_reset
void mutt_buffer_reset(struct Buffer *buf)
Reset an existing Buffer.
Definition: buffer.c:79
mutt_socket_poll
int mutt_socket_poll(struct Connection *conn, time_t wait_secs)
Checks whether reads would block.
Definition: socket.c:191
mutt_buffer_pool_release
void mutt_buffer_pool_release(struct Buffer **pbuf)
Free a Buffer from the pool.
Definition: pool.c:112
STAILQ_EMPTY
#define STAILQ_EMPTY(head)
Definition: queue.h:345
msg_cache_put
static FILE * msg_cache_put(struct Mailbox *m, struct Email *e)
Put an email into the message cache.
Definition: message.c:128
Username
WHERE char * Username
User's login name.
Definition: mutt_globals.h:52
imap_adata_get
struct ImapAccountData * imap_adata_get(struct Mailbox *m)
Get the Account data for this mailbox.
Definition: adata.c:86
mutt_date_make_imap
int mutt_date_make_imap(char *buf, size_t buflen, time_t timestamp)
Format date in IMAP style: DD-MMM-YYYY HH:MM:SS +ZZzz.
Definition: date.c:546
mutt_array_size
#define mutt_array_size(x)
Definition: memory.h:33
STAILQ_FOREACH
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:349
ImapAccountData::conn
struct Connection * conn
Definition: adata.h:38
mutt_buffer_alloc
void mutt_buffer_alloc(struct Buffer *buf, size_t new_size)
Make sure a buffer can store at least new_size bytes.
Definition: buffer.c:265
imap_authenticators
static const struct ImapAuth imap_authenticators[]
Accepted authentication methods.
Definition: auth.c:57
imap_cmd_finish
void imap_cmd_finish(struct ImapAccountData *adata)
Attempt to perform cleanup.
Definition: command.c:1309
imap_open_connection
int imap_open_connection(struct ImapAccountData *adata)
Open an IMAP connection.
Definition: imap.c:740
SeqsetIterator::in_range
int in_range
Definition: private.h:174
MUTT_READ
@ MUTT_READ
Messages that have been read.
Definition: mutt.h:96
SKIPWS
#define SKIPWS(ch)
Definition: string2.h:46
mutt_istr_equal
bool mutt_istr_equal(const char *a, const char *b)
Compare two strings, ignoring case.
Definition: string.c:883
mutt_hash_int_find
void * mutt_hash_int_find(const struct HashTable *table, unsigned int intkey)
Find the HashElem data in a Hash Table element using a key.
Definition: hash.c:384
ImapCommand::seq
char seq[SEQ_LEN+1]
Command tag, e.g. 'a0001'.
Definition: private.h:163
mutt_str_equal
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:871
IMAP_CAP_IMAP4REV1
#define IMAP_CAP_IMAP4REV1
Server supports IMAP4rev1.
Definition: private.h:126
SeqsetIterator::full_seqset
char * full_seqset
Definition: private.h:172
Email::old
bool old
Email is seen, but unread.
Definition: email.h:50
mutt_progress_init
void mutt_progress_init(struct Progress *progress, const char *msg, enum ProgressType type, size_t size)
Set up a progress bar.
Definition: progress.c:153
cmd_handle_fatal
static void cmd_handle_fatal(struct ImapAccountData *adata)
When ImapAccountData is in fatal state, do what we can.
Definition: command.c:166
Email::active
bool active
Message is not to be removed.
Definition: email.h:59
SeqsetIterator::down
int down
Definition: private.h:175
query_quadoption
enum QuadOption query_quadoption(enum QuadOption opt, const char *prompt)
Ask the user a quad-question.
Definition: curs_lib.c:518
mx_alloc_memory
void mx_alloc_memory(struct Mailbox *m)
Create storage for the emails.
Definition: mx.c:1230
mutt_buffer_addch
size_t mutt_buffer_addch(struct Buffer *buf, char c)
Add a single character to a Buffer.
Definition: buffer.c:240
imap_hcache_get_uid_seqset
char * imap_hcache_get_uid_seqset(struct ImapMboxData *mdata)
Get a UID Sequence Set from the header cache.
Definition: util.c:452
mutt_buffer_pool_get
struct Buffer * mutt_buffer_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:101
mutt_account_unsetpass
void mutt_account_unsetpass(struct ConnAccount *cac)
Unset ConnAccount's password.
Definition: connaccount.c:141
imap_hcache_close
void imap_hcache_close(struct ImapMboxData *mdata)
Close the header cache.
Definition: util.c:340
utf7_to_utf8
static char * utf7_to_utf8(const char *u7, size_t u7len, char **u8, size_t *u8len)
Convert data from RFC2060's UTF-7 to UTF-8.
Definition: utf7.c:83
IMAP_CAP_STARTTLS
#define IMAP_CAP_STARTTLS
RFC2595: STARTTLS.
Definition: private.h:134
Mailbox::mdata
void * mdata
Driver specific data.
Definition: mailbox.h:136
url_tostring
int url_tostring(struct Url *url, char *dest, size_t len, uint8_t flags)
Output the URL string for a given Url object.
Definition: url.c:418
NT_MAILBOX_UPDATE
@ NT_MAILBOX_UPDATE
Update internal tables.
Definition: mailbox.h:176
U_PATH
#define U_PATH
Definition: url.h:49
imap_msn_get
struct Email * imap_msn_get(const struct MSN *msn, size_t idx)
Return the Email associated with an msn.
Definition: msn.c:80
imap_utf_encode
void imap_utf_encode(bool unicode, char **s)
Encode email from local charset to UTF-8.
Definition: utf7.c:316
MUTT_NEW
@ MUTT_NEW
New messages.
Definition: mutt.h:93
Account
A group of associated Mailboxes.
Definition: account.h:36
imap_error
void imap_error(const char *where, const char *msg)
show an error and abort
Definition: util.c:663
imap_read_headers
int imap_read_headers(struct Mailbox *m, unsigned int msn_begin, unsigned int msn_end, bool initial_download)
Read headers from the server.
Definition: message.c:1283
Message::path
char * path
path to temp file
Definition: mx.h:97
Progress
A progress bar.
Definition: progress.h:50
ImapAccountData::cmds
struct ImapCommand * cmds
Definition: adata.h:66
Body::length
LOFF_T length
length (in bytes) of attachment
Definition: body.h:45
Mailbox::changed
bool changed
Mailbox has been modified.
Definition: mailbox.h:114
Url
A parsed URL proto://user:password@host:port/path?a=1&b=2
Definition: url.h:67
mutt_sig_allow_interrupt
void mutt_sig_allow_interrupt(bool allow)
Allow/disallow Ctrl-C (SIGINT)
Definition: signal.c:238
Message::draft
bool draft
Definition: mx.h:105
ImapCommand::state
int state
Command state, e.g. IMAP_RES_NEW.
Definition: private.h:164
ImapEmailData
IMAP-specific Email data -.
Definition: edata.h:33
MUTT_ACCT_TYPE_IMAP
@ MUTT_ACCT_TYPE_IMAP
Imap Account.
Definition: mutt_account.h:37
Mailbox::msg_count
int msg_count
Total number of messages.
Definition: mailbox.h:91
Message::read
bool read
Definition: mx.h:102
mutt_clear_error
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
Definition: mutt_logging.c:113
imap_next_word
char * imap_next_word(char *s)
Find where the next IMAP word begins.
Definition: util.c:788
ImapAccountData::unicode
bool unicode
If true, we can send UTF-8, and the server will use UTF8 rather than mUTF7.
Definition: adata.h:59
ImapMboxData::bcache
struct BodyCache * bcache
Definition: mdata.h:60
mutt_hash_int_delete
void mutt_hash_int_delete(struct HashTable *table, unsigned int intkey, const void *data)
Remove an element from a Hash Table.
Definition: hash.c:434
cmd_start
static int cmd_start(struct ImapAccountData *adata, const char *cmdstr, ImapCmdFlags flags)
Start a new IMAP command.
Definition: command.c:202
IMAP_RES_NO
#define IMAP_RES_NO
<tag> NO ...
Definition: private.h:56
imap_cmd_start
int imap_cmd_start(struct ImapAccountData *adata, const char *cmdstr)
Given an IMAP command, send it to the server.
Definition: command.c:1060
mutt_zstrm_wrap_conn
void mutt_zstrm_wrap_conn(struct Connection *conn)
Wrap a compression layer around a Connection.
Definition: zstrm.c:288
mutt_hcache_free_raw
void mutt_hcache_free_raw(struct HeaderCache *hc, void **data)
Multiplexor for StoreOps::free.
Definition: hcache.c:514
MUTT_IMAP
@ MUTT_IMAP
'IMAP' Mailbox type
Definition: mailbox.h:53
cmd_handle_untagged
static int cmd_handle_untagged(struct ImapAccountData *adata)
fallback parser for otherwise unhandled messages
Definition: command.c:984
flush_buffer
static int flush_buffer(char *buf, size_t *len, struct Connection *conn)
Write data to a connection.
Definition: message.c:469
url_tobuffer
int url_tobuffer(struct Url *url, struct Buffer *buf, uint8_t flags)
Output the URL string for a given Url object.
Definition: url.c:353
mutt_socket_send
#define mutt_socket_send(conn, buf)
Definition: mutt_socket.h:37
C_ImapRfc5161
bool C_ImapRfc5161
Config: (imap) Use the IMAP ENABLE extension to select capabilities.
Definition: config.c:59
SeqsetIterator::eostr
char * eostr
Definition: private.h:173
HCacheEntry::email
struct Email * email
Retrieved email.
Definition: lib.h:100
imap_error
void imap_error(const char *where, const char *msg)
show an error and abort
Definition: util.c:663
mutt_mem_realloc
void mutt_mem_realloc(void *ptr, size_t size)
Resize a block of memory on the heap.
Definition: memory.c:114
ConnAccount::type
unsigned char type
Connection type, e.g. MUTT_ACCT_TYPE_IMAP.
Definition: connaccount.h:58
Email::env
struct Envelope * env
Envelope information.
Definition: email.h:90
mutt_debug
#define mutt_debug(LEVEL,...)
Definition: logging.h:81
mutt_bcache_close
void mutt_bcache_close(struct BodyCache **bcache)
Close an Email-Body Cache.
Definition: bcache.c:165
Mailbox::email_max
int email_max
Number of pointers in emails.
Definition: mailbox.h:100
MUTT_REPLIED
@ MUTT_REPLIED
Messages that have been replied to.
Definition: mutt.h:95
MUTT_NO
@ MUTT_NO
User answered 'No', or assume 'No'.
Definition: quad.h:39
imap_msn_free
void imap_msn_free(struct MSN *msn)
Free the cache.
Definition: msn.c:59
mutt_bcache_list
int mutt_bcache_list(struct BodyCache *bcache, bcache_list_t want_id, void *data)
Find matching entries in the Body Cache.
Definition: bcache.c:330
imap_read_literal
int imap_read_literal(FILE *fp, struct ImapAccountData *adata, unsigned long bytes, struct Progress *pbar)
Read bytes bytes from server into file.
Definition: imap.c:596
ImapAccountData::seqno
unsigned int seqno
tag sequence number, e.g. '{seqid}0001'
Definition: adata.h:54
Message::replied
bool replied
Definition: mx.h:104
HCacheEntry
Wrapper for Email retrieved from the header cache.
Definition: lib.h:96
Message::fp
FILE * fp
pointer to the message data
Definition: mx.h:96
read_headers_fetch_new
static int read_headers_fetch_new(struct Mailbox *m, unsigned int msn_begin, unsigned int msn_end, bool evalhc, unsigned int *maxuid, bool initial_download)
Retrieve new messages from the server.
Definition: message.c:1037
Email::flagged
bool flagged
Marked important?
Definition: email.h:43
mutt_str_len
size_t mutt_str_len(const char *a)
Calculate the length of a string, safely.
Definition: string.c:631
MUTT_ACCT_USER
#define MUTT_ACCT_USER
User field has been set.
Definition: connaccount.h:43
mutt_buffer_string
static const char * mutt_buffer_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:77
Mailbox::verbose
bool verbose
Display status messages?
Definition: mailbox.h:118
ConnAccount::flags
MuttAccountFlags flags
Which fields are initialised, e.g. MUTT_ACCT_USER.
Definition: connaccount.h:59
C_ImapUser
char * C_ImapUser
Config: (imap) Username for the IMAP server.
Definition: config.c:61
ImapAccountData::lastcmd
int lastcmd
Definition: adata.h:69
mutt_date_epoch
time_t mutt_date_epoch(void)
Return the number of seconds since the Unix epoch.
Definition: date.c:416
SORT_ORDER
@ SORT_ORDER
Sort by the order the messages appear in the mailbox.
Definition: sort2.h:50
ImapAccountData
IMAP-specific Account data -.
Definition: adata.h:36
imap_close_connection
void imap_close_connection(struct ImapAccountData *adata)
Close an IMAP connection.
Definition: imap.c:843
read_headers_qresync_eval_cache
static int read_headers_qresync_eval_cache(struct ImapAccountData *adata, char *uid_seqset)
Retrieve data from the header cache.
Definition: message.c:800
MUTT_ACL_WRITE
#define MUTT_ACL_WRITE
Write to a message (for flagging or linking threads)
Definition: mailbox.h:74
ImapMboxData
IMAP-specific Mailbox data -.
Definition: mdata.h:38
IMAP_CONNECTED
@ IMAP_CONNECTED
Connected to server.
Definition: private.h:110
MUTT_OLD
@ MUTT_OLD
Old messages.
Definition: mutt.h:94
imap_edata_free
void imap_edata_free(void **ptr)
Free the private Email data - Implements Email::edata_free()
Definition: edata.c:37
ImapAuth::method
const char * method
Name of authentication method supported, NULL means variable.
Definition: auth.c:50
Message::flagged
bool flagged
Definition: mx.h:103
mutt_hcache_store
int mutt_hcache_store(struct HeaderCache *hc, const char *key, size_t keylen, struct Email *e, uint32_t uidvalidity)
Multiplexor for StoreOps::store.
Definition: hcache.c:527
Email::deleted
bool deleted
Email is deleted.
Definition: email.h:45
imap_msn_highest
size_t imap_msn_highest(const struct MSN *msn)
Return the highest MSN in use.
Definition: msn.c:69
mutt_bcache_del
int mutt_bcache_del(struct BodyCache *bcache, const char *id)
Delete a file from the Body Cache.
Definition: bcache.c:265
IMAP_AUTH_FAILURE
@ IMAP_AUTH_FAILURE
Authentication failed.
Definition: auth.h:39
Mailbox::readonly
bool readonly
Don't allow changes to the mailbox.
Definition: mailbox.h:119
mutt_str_cat
char * mutt_str_cat(char *buf, size_t buflen, const char *s)
Concatenate two strings.
Definition: string.c:385
HeaderCache
header cache structure
Definition: lib.h:85
read_headers_condstore_qresync_updates
static int read_headers_condstore_qresync_updates(struct ImapAccountData *adata, unsigned int msn_end, unsigned int uid_next, unsigned long long hc_modseq, bool eval_qresync)
Retrieve updates from the server.
Definition: message.c:869
imap_hcache_clear_uid_seqset
int imap_hcache_clear_uid_seqset(struct ImapMboxData *mdata)
Delete a UID Sequence Set from the header cache.
Definition: util.c:438
IMAP_CAP_CONDSTORE
#define IMAP_CAP_CONDSTORE
RFC7162.
Definition: private.h:139
IMAP_AUTH_SUCCESS
@ IMAP_AUTH_SUCCESS
Authentication successful.
Definition: auth.h:38
Slist::count
size_t count
Definition: slist.h:49
MUTT_DELETE
@ MUTT_DELETE
Messages to be deleted.
Definition: mutt.h:98
mutt_socket_open
int mutt_socket_open(struct Connection *conn)
Simple wrapper.
Definition: socket.c:75
C_DebugLevel
short C_DebugLevel
Config: Logging level for debug logs.
Definition: mutt_logging.c:48
ConnAccount::port
unsigned short port
Port to connect to.
Definition: connaccount.h:57
IMAP_CMD_PASS
#define IMAP_CMD_PASS
Command contains a password. Suppress logging.
Definition: private.h:76
C_Sort
WHERE short C_Sort
Config: Sort method for the index.
Definition: sort.h:60
Email::edata
void * edata
Driver-specific data.
Definition: email.h:111
mutt_mem_malloc
void * mutt_mem_malloc(size_t size)
Allocate memory on the heap.
Definition: memory.c:90
ImapAccountData::state
unsigned char state
ImapState, e.g. IMAP_AUTHENTICATED.
Definition: adata.h:41
Email::tags
struct TagList tags
For drivers that support server tagging.
Definition: email.h:109
imap_exec
int imap_exec(struct ImapAccountData *adata, const char *cmdstr, ImapCmdFlags flags)
Execute a command and wait for the response from the server.
Definition: command.c:1245
IMAP_DATELEN
#define IMAP_DATELEN
Definition: private.h:92
IMAP_RES_CONTINUE
#define IMAP_RES_CONTINUE
* ...
Definition: private.h:59
ImapAccountData::blen
size_t blen
Definition: adata.h:57
mutt_ch_is_utf8
#define mutt_ch_is_utf8(str)
Definition: charset.h:97
compare_uid
static int compare_uid(const void *a, const void *b)
Compare two Emails by UID - Implements sort_t.
Definition: imap.c:894
mutt_strn_dup
char * mutt_strn_dup(const char *begin, size_t len)
Duplicate a sub-string.
Definition: string.c:548
imap_quote_string
void imap_quote_string(char *dest, size_t dlen, const char *src, bool quote_backtick)
quote string according to IMAP rules
Definition: util.c:836
mutt_str_remove_trailing_ws
void mutt_str_remove_trailing_ws(char *s)
Trim trailing whitespace from a string.
Definition: string.c:700
NeoMutt
Container for Accounts, Notifications.
Definition: neomutt.h:36
utf8_to_utf7
static char * utf8_to_utf7(const char *u8, size_t u8len, char **u7, size_t *u7len)
Convert data from UTF-8 to RFC2060's UTF-7.
Definition: utf7.c:193
mutt_hcache_delete_record
int mutt_hcache_delete_record(struct HeaderCache *hc, const char *key, size_t keylen)
Multiplexor for StoreOps::delete_record.
Definition: hcache.c:604
IMAP_EXPUNGE_EXPECTED
#define IMAP_EXPUNGE_EXPECTED
Messages will be expunged from the server.
Definition: private.h:69
ImapAccountData::mailbox
struct Mailbox * mailbox
Current selected mailbox.
Definition: adata.h:73
mutt_istr_startswith
size_t mutt_istr_startswith(const char *str, const char *prefix)
Check whether a string starts with a prefix, ignoring case.
Definition: string.c:172
imap_unquote_string
void imap_unquote_string(char *s)
equally stupid unquoting routine
Definition: util.c:873
ImapEmailData::flagged
bool flagged
Definition: edata.h:39
imap_append_message
int imap_append_message(struct Mailbox *m, struct Message *msg)
Write an email back to the server.
Definition: message.c:1493
msg_cache_open
static struct BodyCache * msg_cache_open(struct Mailbox *m)
Open a message cache.
Definition: message.c:79
ImapAccountData::cmdbuf
struct Buffer cmdbuf
Definition: adata.h:70
IMAP_EXEC_ERROR
@ IMAP_EXEC_ERROR
Imap command failure.
Definition: private.h:87
imap_cachepath
void imap_cachepath(char delim, const char *mailbox, struct Buffer *dest)
Generate a cache path for a mailbox.
Definition: util.c:715
C_HeaderCache
char * C_HeaderCache
Config: (hcache) Directory/file for the header cache database.
Definition: config.c:40
C_ImapPeek
bool C_ImapPeek
Config: (imap) Don't mark messages as read when fetching them from the server.
Definition: config.c:55
imap_get_literal_count
int imap_get_literal_count(const char *buf, unsigned int *bytes)
write number of bytes in an IMAP literal into bytes
Definition: util.c:744
mailbox_changed
void mailbox_changed(struct Mailbox *m, enum NotifyMailbox action)
Notify observers of a change to a Mailbox.
Definition: mailbox.c:186
imap_mdata_get
struct ImapMboxData * imap_mdata_get(struct Mailbox *m)
Get the Mailbox data for this mailbox.
Definition: mdata.c:55
mutt_buffer_len
size_t mutt_buffer_len(const struct Buffer *buf)
Calculate the length of a Buffer.
Definition: buffer.c:356
IMAP_CMD_QUEUE
#define IMAP_CMD_QUEUE
Queue a command, do not execute.
Definition: private.h:77
ImapEmailData::read
bool read
Definition: edata.h:36
Account::adata
void * adata
Private data (for Mailbox backends)
Definition: account.h:43
ListNode::data
char * data
String.
Definition: list.h:36
imap_account_match
bool imap_account_match(const struct ConnAccount *a1, const struct ConnAccount *a2)
Compare two Accounts.
Definition: util.c:1043
Email::index
int index
The absolute (unsorted) message number.
Definition: email.h:86
mutt_rfc822_read_header
struct Envelope * mutt_rfc822_read_header(FILE *fp, struct Email *e, bool user_hdrs, bool weed)
parses an RFC822 header
Definition: parse.c:1112
set_flag
static void set_flag(struct Mailbox *m, AclFlags aclflag, bool flag, const char *str, char *flags, size_t flsize)
append str to flags if we currently have permission according to aclflag
Definition: imap.c:175
mutt_progress_update
void mutt_progress_update(struct Progress *progress, size_t pos, int percent)
Update the state of the progress bar.
Definition: progress.c:212
plen
static size_t plen
Length of cached packet.
Definition: pgppacket.c:39
mutt_buffer_addstr
size_t mutt_buffer_addstr(struct Buffer *buf, const char *s)
Add a string to a Buffer.
Definition: buffer.c:225
IMAP_AUTHENTICATED
@ IMAP_AUTHENTICATED
Connection is authenticated.
Definition: private.h:111
SeqsetIterator::substr_end
char * substr_end
Definition: private.h:179
IMAP_EXEC_FATAL
@ IMAP_EXEC_FATAL
Imap connection failure.
Definition: private.h:88
MUTT_SOCK_LOG_FULL
#define MUTT_SOCK_LOG_FULL
Definition: mutt_socket.h:31
mutt_istrn_equal
bool mutt_istrn_equal(const char *a, const char *b, size_t num)
Check for equality of two strings ignoring case (to a maximum), safely.
Definition: string.c:621
IMAP_CMD_NO_FLAGS
#define IMAP_CMD_NO_FLAGS
No flags are set.
Definition: private.h:75
IMAP_RES_BAD
#define IMAP_RES_BAD
<tag> BAD ...
Definition: private.h:57
IMAP_NEWMAIL_PENDING
#define IMAP_NEWMAIL_PENDING
New mail is waiting on the server.
Definition: private.h:71
Url::path
char * path
Path.
Definition: url.h:74
mutt_hcache_fetch_raw
void * mutt_hcache_fetch_raw(struct HeaderCache *hc, const char *key, size_t keylen, size_t *dlen)
Fetch a message's header from the cache.
Definition: hcache.c:496
HCacheEntry::uidvalidity
uint32_t uidvalidity
IMAP-specific UIDVALIDITY.
Definition: lib.h:98
C_ImapPollTimeout
short C_ImapPollTimeout
Config: (imap) Maximum time to wait for a server response.
Definition: config.c:57
mutt_str_atoui
int mutt_str_atoui(const char *str, unsigned int *dst)
Convert ASCII string to an unsigned integer.
Definition: string.c:282
mutt_hcache_close
void mutt_hcache_close(struct HeaderCache *hc)
Multiplexor for StoreOps::close.
Definition: hcache.c:419
C_Charset
char * C_Charset
Config: Default character set for displaying text on screen.
Definition: charset.c:53
imap_set_flags
char * imap_set_flags(struct Mailbox *m, struct Email *e, char *s, bool *server_changes)
fill the message header according to the server flags
Definition: message.c:1847
Email::replied
bool replied
Email has been replied to.
Definition: email.h:54
mutt_yesorno
enum QuadOption mutt_yesorno(const char *msg, enum QuadOption def)
Ask the user a Yes/No question.
Definition: curs_lib.c:380
Buffer::data
char * data
Pointer to data.
Definition: buffer.h:35
IS_SPACE
#define IS_SPACE(ch)
Definition: string2.h:38
ImapAccountData::capstr
char * capstr
Definition: adata.h:51
Email
The envelope/body of an email.
Definition: email.h:37
mutt_ssl_starttls
int mutt_ssl_starttls(struct Connection *conn)
Negotiate TLS over an already opened connection.
Definition: gnutls.c:1136
SeqsetIterator
UID Sequence Set Iterator.
Definition: private.h:170
ImapAuth
IMAP authentication multiplexor.
Definition: auth.c:40
MUTT_ACL_SEEN
#define MUTT_ACL_SEEN
Change the 'seen' status of a message.
Definition: mailbox.h:73
compare_flags_for_copy
static bool compare_flags_for_copy(struct Email *e)
Compare local flags against the server.
Definition: imap.c:298
IMAP_CMD_BUFSIZE
#define IMAP_CMD_BUFSIZE
Definition: command.c:59
mutt_env_merge
void mutt_env_merge(struct Envelope *base, struct Envelope **extra)
Merge the headers of two Envelopes.
Definition: envelope.c:151
imap_expunge_mailbox
void imap_expunge_mailbox(struct Mailbox *m)
Purge messages from the server.
Definition: imap.c:671
mutt_str_startswith
size_t mutt_str_startswith(const char *str, const char *prefix)
Check whether a string starts with a prefix.
Definition: string.c:160
mutt_message
#define mutt_message(...)
Definition: logging.h:83
mutt_set_flag
#define mutt_set_flag(m, e, flag, bf)
Definition: protos.h:67
IMAP_SELECTED
@ IMAP_SELECTED
Mailbox is selected.
Definition: private.h:112
mutt_buffer_printf
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:160
imap_edata_get
struct ImapEmailData * imap_edata_get(struct Email *e)
Get the private data for this Email.
Definition: edata.c:63
imap_hcache_namer
static void imap_hcache_namer(const char *path, struct Buffer *dest)
Generate a filename for the header cache - Implements hcache_namer_t.
Definition: util.c:289
msg_parse_flags
static char * msg_parse_flags(struct ImapHeader *h, char *s)
read a FLAGS token into an ImapHeader
Definition: message.c:191
mutt_buffer_make
struct Buffer mutt_buffer_make(size_t size)
Make a new buffer on the stack.
Definition: buffer.c:61
ImapAccountData::nextcmd
int nextcmd
Definition: adata.h:68
NT_MAILBOX_RESORT
@ NT_MAILBOX_RESORT
Email list needs resorting.
Definition: mailbox.h:174
Email::read
bool read
Email is read.
Definition: email.h:51
IMAP_CMD_SINGLE
#define IMAP_CMD_SINGLE
Run a single command.
Definition: private.h:79
IMAP_CAP_QRESYNC
#define IMAP_CAP_QRESYNC
RFC7162.
Definition: private.h:140
ImapEmailData::parsed
bool parsed
Definition: edata.h:42
ImapAuth::authenticate
enum ImapAuthRes(* authenticate)(struct ImapAccountData *adata, const char *method)
Authenticate an IMAP connection.
Definition: auth.c:48
Connection::ssf
unsigned int ssf
Security strength factor, in bits (see below)
Definition: connection.h:37
ConnAccount::user
char user[128]
Username.
Definition: connaccount.h:55
C_ImapCondstore
bool C_ImapCondstore
Config: (imap) Enable the CONDSTORE extension.
Definition: config.c:41
LL_DEBUG2
@ LL_DEBUG2
Log at debug level 2.
Definition: logging.h:41
imap_continue
enum QuadOption imap_continue(const char *msg, const char *resp)
display a message and ask the user if they want to go on
Definition: util.c:652
imap_verify_qresync
static int imap_verify_qresync(struct Mailbox *m)
Check to see if QRESYNC got jumbled.
Definition: message.c:965
mutt_hash_free
void mutt_hash_free(struct HashTable **ptr)
Free a hash table.
Definition: hash.c:447
ImapMboxData::uidvalidity
uint32_t uidvalidity
Definition: mdata.h:50
IMAP_CAP_COMPRESS
#define IMAP_CAP_COMPRESS
RFC4978: COMPRESS=DEFLATE.
Definition: private.h:142
ImapAccountData::qresync
bool qresync
true, if QRESYNC is successfully ENABLE'd
Definition: adata.h:60
Email::changed
bool changed
Email has been edited.
Definition: email.h:48
ImapCommand
IMAP command structure.
Definition: private.h:161
imap_cmd_trailer
const char * imap_cmd_trailer(struct ImapAccountData *adata)
Extra information after tagged command response if any.
Definition: command.c:1208
ImapMboxData::name
char * name
Mailbox name.
Definition: mdata.h:40
C_ImapAuthenticators
struct Slist * C_ImapAuthenticators
Config: (imap) List of allowed IMAP authentication methods.
Definition: config.c:39
ImapHeader
IMAP-specific header.
Definition: message.h:33
imap_parse_path
int imap_parse_path(const char *path, struct ConnAccount *cac, char *mailbox, size_t mailboxlen)
Parse an IMAP mailbox name into ConnAccount, name.
Definition: util.c:483
driver_tags_get_with_hidden
char * driver_tags_get_with_hidden(struct TagList *list)
Get tags with hiddens.
Definition: tags.c:157
Email::body
struct Body * body
List of MIME parts.
Definition: email.h:91
IMAP_REOPEN_ALLOW
#define IMAP_REOPEN_ALLOW
Allow re-opening a folder upon expunge.
Definition: private.h:68
ImapAccountData::delim
char delim
Definition: adata.h:72
mutt_error
#define mutt_error(...)
Definition: logging.h:84
imap_mbox_select
static void imap_mbox_select(struct Mailbox *m)
Select a Mailbox.
Definition: imap.c:1795
mutt_hcache_fetch
struct HCacheEntry mutt_hcache_fetch(struct HeaderCache *hc, const char *key, size_t keylen, uint32_t uidvalidity)
Multiplexor for StoreOps::fetch.
Definition: hcache.c:438
mutt_str_copy
size_t mutt_str_copy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:716