#endif
/**
- * imap_check_capabilities - Make sure we can log in to this server
+ * check_capabilities - Make sure we can log in to this server
*/
-static int imap_check_capabilities(struct ImapData *idata)
+static int check_capabilities(struct ImapData *idata)
{
if (imap_exec(idata, "CAPABILITY", 0) != 0)
{
- imap_error("imap_check_capabilities", idata->buf);
+ imap_error("check_capabilities", idata->buf);
return -1;
}
}
/**
- * imap_get_flags - Make a simple list out of a FLAGS response
+ * get_flags - Make a simple list out of a FLAGS response
*
* return stream following FLAGS response
*/
-static char *imap_get_flags(struct ListHead *hflags, char *s)
+static char *get_flags(struct ListHead *hflags, char *s)
{
char *flag_word = NULL;
char ctmp;
/* sanity-check string */
if (mutt_strncasecmp("FLAGS", s, 5) != 0)
{
- mutt_debug(1, "imap_get_flags: not a FLAGS response: %s\n", s);
+ mutt_debug(1, "get_flags: not a FLAGS response: %s\n", s);
return NULL;
}
s += 5;
SKIPWS(s);
if (*s != '(')
{
- mutt_debug(1, "imap_get_flags: bogus FLAGS response: %s\n", s);
+ mutt_debug(1, "get_flags: bogus FLAGS response: %s\n", s);
return NULL;
}
/* note bad flags response */
if (*s != ')')
{
- mutt_debug(1, "imap_get_flags: Unterminated FLAGS response: %s\n", s);
+ mutt_debug(1, "get_flags: Unterminated FLAGS response: %s\n", s);
mutt_list_free(hflags);
return NULL;
}
/**
- * imap_set_flag - append str to flags if we currently have permission
+ * set_flag - append str to flags if we currently have permission
*
* according to aclbit
*/
-static void imap_set_flag(struct ImapData *idata, int aclbit, int flag,
- const char *str, char *flags, size_t flsize)
+static void set_flag(struct ImapData *idata, int aclbit, int flag,
+ const char *str, char *flags, size_t flsize)
{
if (mutt_bit_isset(idata->ctx->rights, aclbit))
if (flag && imap_has_flag(&idata->flags, str))
}
/**
- * imap_make_msg_set - Make a message set
+ * make_msg_set - Make a message set
*
* Note: headers must be in SORT_ORDER. See imap_exec_msgset for args.
* Pos is an opaque pointer a la strtok. It should be 0 at first call.
*/
-static int imap_make_msg_set(struct ImapData *idata, struct Buffer *buf,
- int flag, bool changed, bool invert, int *pos)
+static int make_msg_set(struct ImapData *idata, struct Buffer *buf, int flag,
+ bool changed, bool invert, int *pos)
{
struct Header **hdrs = idata->ctx->hdrs;
int count = 0; /* number of messages in message set */
}
/**
- * imap_get_mailbox - split path into (idata,mailbox name)
+ * get_mailbox - split path into (idata,mailbox name)
*/
-static int imap_get_mailbox(const char *path, struct ImapData **hidata, char *buf, size_t blen)
+static int get_mailbox(const char *path, struct ImapData **hidata, char *buf, size_t blen)
{
struct ImapMbox mx;
if (imap_parse_path(path, &mx))
{
- mutt_debug(1, "imap_get_mailbox: Error parsing %s\n", path);
+ mutt_debug(1, "get_mailbox: Error parsing %s\n", path);
return -1;
}
if (!(*hidata = imap_conn_find(&(mx.account), option(OPT_IMAP_PASSIVE) ? MUTT_IMAP_CONN_NONEW : 0)) ||
}
/**
- * imap_compile_search - Convert NeoMutt pattern to IMAP search
+ * compile_search - Convert NeoMutt pattern to IMAP search
*
* Convert neomutt Pattern to IMAP SEARCH command containing only elements
* that require full-text search (neomutt already has what it needs for most
* match types, and does a better job (eg server doesn't support regexes).
*/
-static int imap_compile_search(struct Context *ctx, const struct Pattern *pat,
- struct Buffer *buf)
+static int compile_search(struct Context *ctx, const struct Pattern *pat, struct Buffer *buf)
{
if (!do_search(pat, 0))
return 0;
mutt_buffer_addstr(buf, "OR ");
clauses--;
- if (imap_compile_search(ctx, clause, buf) < 0)
+ if (compile_search(ctx, clause, buf) < 0)
return -1;
if (clauses)
}
/**
- * imap_complete_hosts - Look for completion matches for mailboxes
+ * complete_hosts - Look for completion matches for mailboxes
*
* look for IMAP URLs to complete from defined mailboxes. Could be extended to
* complete over open connections and account/folder hooks too.
*/
-static int imap_complete_hosts(char *dest, size_t len)
+static int complete_hosts(char *dest, size_t len)
{
struct Buffy *mailbox = NULL;
struct Connection *conn = NULL;
if (mutt_strncasecmp("* OK", idata->buf, 4) == 0)
{
if ((mutt_strncasecmp("* OK [CAPABILITY", idata->buf, 16) != 0) &&
- imap_check_capabilities(idata))
+ check_capabilities(idata))
goto bail;
#ifdef USE_SSL
/* Attempt STARTTLS if available and desired. */
else if (mutt_strncasecmp("* PREAUTH", idata->buf, 9) == 0)
{
idata->state = IMAP_AUTHENTICATED;
- if (imap_check_capabilities(idata) != 0)
+ if (check_capabilities(idata) != 0)
goto bail;
FREE(&idata->capstr);
}
{
cmd->dptr = cmd->data;
mutt_buffer_printf(cmd, "%s ", pre);
- rc = imap_make_msg_set(idata, cmd, flag, changed, invert, &pos);
+ rc = make_msg_set(idata, cmd, flag, changed, invert, &pos);
if (rc > 0)
{
mutt_buffer_printf(cmd, " %s", post);
flags[0] = '\0';
- imap_set_flag(idata, MUTT_ACL_SEEN, hdr->read, "\\Seen ", flags, sizeof(flags));
- imap_set_flag(idata, MUTT_ACL_WRITE, hdr->old, "Old ", flags, sizeof(flags));
- imap_set_flag(idata, MUTT_ACL_WRITE, hdr->flagged, "\\Flagged ", flags, sizeof(flags));
- imap_set_flag(idata, MUTT_ACL_WRITE, hdr->replied, "\\Answered ", flags, sizeof(flags));
- imap_set_flag(idata, MUTT_ACL_DELETE, HEADER_DATA(hdr)->deleted, "\\Deleted ",
- flags, sizeof(flags));
+ set_flag(idata, MUTT_ACL_SEEN, hdr->read, "\\Seen ", flags, sizeof(flags));
+ set_flag(idata, MUTT_ACL_WRITE, hdr->old, "Old ", flags, sizeof(flags));
+ set_flag(idata, MUTT_ACL_WRITE, hdr->flagged, "\\Flagged ", flags, sizeof(flags));
+ set_flag(idata, MUTT_ACL_WRITE, hdr->replied, "\\Answered ", flags, sizeof(flags));
+ set_flag(idata, MUTT_ACL_DELETE, HEADER_DATA(hdr)->deleted, "\\Deleted ",
+ flags, sizeof(flags));
if (mutt_bit_isset(idata->ctx->rights, MUTT_ACL_WRITE))
{
* explicitly revoke all system flags (if we have permission) */
if (!*flags)
{
- imap_set_flag(idata, MUTT_ACL_SEEN, 1, "\\Seen ", flags, sizeof(flags));
- imap_set_flag(idata, MUTT_ACL_WRITE, 1, "Old ", flags, sizeof(flags));
- imap_set_flag(idata, MUTT_ACL_WRITE, 1, "\\Flagged ", flags, sizeof(flags));
- imap_set_flag(idata, MUTT_ACL_WRITE, 1, "\\Answered ", flags, sizeof(flags));
- imap_set_flag(idata, MUTT_ACL_DELETE, !HEADER_DATA(hdr)->deleted,
- "\\Deleted ", flags, sizeof(flags));
+ set_flag(idata, MUTT_ACL_SEEN, 1, "\\Seen ", flags, sizeof(flags));
+ set_flag(idata, MUTT_ACL_WRITE, 1, "Old ", flags, sizeof(flags));
+ set_flag(idata, MUTT_ACL_WRITE, 1, "\\Flagged ", flags, sizeof(flags));
+ set_flag(idata, MUTT_ACL_WRITE, 1, "\\Answered ", flags, sizeof(flags));
+ set_flag(idata, MUTT_ACL_DELETE, !HEADER_DATA(hdr)->deleted, "\\Deleted ",
+ flags, sizeof(flags));
/* erase custom flags */
if (mutt_bit_isset(idata->ctx->rights, MUTT_ACL_WRITE) && HEADER_DATA(hdr)->flags_remote)
if (mailbox->magic != MUTT_IMAP)
continue;
- if (imap_get_mailbox(mailbox->path, &idata, name, sizeof(name)) < 0)
+ if (get_mailbox(mailbox->path, &idata, name, sizeof(name)) < 0)
{
mailbox->new = false;
continue;
char mbox[LONG_STRING];
struct ImapStatus *status = NULL;
- if (imap_get_mailbox(path, &idata, buf, sizeof(buf)) < 0)
+ if (get_mailbox(path, &idata, buf, sizeof(buf)) < 0)
return -1;
/* We are in the folder we're polling - just return the mailbox count.
mutt_buffer_init(&buf);
mutt_buffer_addstr(&buf, "UID SEARCH ");
- if (imap_compile_search(ctx, pat, &buf) < 0)
+ if (compile_search(ctx, pat, &buf) < 0)
{
FREE(&buf.data);
return -1;
if (imap_parse_path(path, &mx))
{
strfcpy(dest, path, dlen);
- return imap_complete_hosts(dest, dlen);
+ return complete_hosts(dest, dlen);
}
/* don't open a new socket just for completion. Instead complete over
{
FREE(&mx.mbox);
strfcpy(dest, path, dlen);
- return imap_complete_hosts(dest, dlen);
+ return complete_hosts(dest, dlen);
}
/* reformat path for IMAP list, and append wildcard */
if (STAILQ_EMPTY(&idata->flags))
{
mutt_debug(3, "Getting mailbox FLAGS\n");
- pc = imap_get_flags(&idata->flags, pc);
+ pc = get_flags(&idata->flags, pc);
if (!pc)
goto fail;
}
mutt_list_free(&idata->flags);
/* skip "OK [PERMANENT" so syntax is the same as FLAGS */
pc += 13;
- pc = imap_get_flags(&(idata->flags), pc);
+ pc = get_flags(&(idata->flags), pc);
if (!pc)
goto fail;
}
#include "hcache/hcache.h"
#endif
-static struct ImapHeaderData *imap_new_header_data(void)
+static struct ImapHeaderData *new_header_data(void)
{
struct ImapHeaderData *d = safe_calloc(1, sizeof(struct ImapHeaderData));
return d;
}
-static void imap_update_context(struct ImapData *idata, int oldmsgcount)
+static void update_context(struct ImapData *idata, int oldmsgcount)
{
struct Context *ctx = NULL;
struct Header *h = NULL;
*len = 0;
}
-static void imap_alloc_msn_index(struct ImapData *idata, unsigned int msn_count)
+static void alloc_msn_index(struct ImapData *idata, unsigned int msn_count)
{
unsigned int new_size;
}
/**
- * imap_generate_seqset - Generate a sequence set
+ * generate_seqset - Generate a sequence set
*
* Generates a more complicated sequence set after using the header cache,
* in case there are missing MSNs in the middle.
* Ideally, we would generate multiple requests if the number of ranges
* is too big, but for now just abort to using the whole range.
*/
-static void imap_generate_seqset(struct Buffer *b, struct ImapData *idata,
- unsigned int msn_begin, unsigned int msn_end)
+static void generate_seqset(struct Buffer *b, struct ImapData *idata,
+ unsigned int msn_begin, unsigned int msn_end)
{
int chunks = 0;
int state = 0; /* 1: single msn, 2: range of msn */
/* Sets server_changes to 1 if a change to a flag is made, or in the
* case of local_changes, if a change to a flag _would_ have been
* made. */
-static void imap_set_changed_flag(struct Context *ctx, struct Header *h,
- int local_changes, int *server_changes, int flag_name,
- int old_hd_flag, int new_hd_flag, int h_flag)
+static void set_changed_flag(struct Context *ctx, struct Header *h,
+ int local_changes, int *server_changes, int flag_name,
+ int old_hd_flag, int new_hd_flag, int h_flag)
{
/* If there are local_changes, we only want to note if the server
* flags have changed, so we can set a reopen flag in
/* make sure context has room to hold the mailbox */
while (msn_end > ctx->hdrmax)
mx_alloc_memory(ctx);
- imap_alloc_msn_index(idata, msn_end);
+ alloc_msn_index(idata, msn_end);
idx = ctx->msgcount;
oldmsgcount = ctx->msgcount;
mutt_progress_update(&progress, msgno, -1);
memset(&h, 0, sizeof(h));
- h.data = imap_new_header_data();
+ h.data = new_header_data();
do
{
rc = imap_cmd_step(idata);
{
/* In case there are holes in the header cache. */
evalhc = false;
- imap_generate_seqset(b, idata, msn_begin, msn_end);
+ generate_seqset(b, idata, msn_begin, msn_end);
}
else
mutt_buffer_printf(b, "%u:%u", msn_begin, msn_end);
rewind(fp);
memset(&h, 0, sizeof(h));
- h.data = imap_new_header_data();
+ h.data = new_header_data();
/* this DO loop does two things:
* 1. handles untagged messages, so we can try again on the same msg
msn_end = idata->new_mail_count;
while (msn_end > ctx->hdrmax)
mx_alloc_memory(ctx);
- imap_alloc_msn_index(idata, msn_end);
+ alloc_msn_index(idata, msn_end);
idata->reopen &= ~IMAP_NEWMAIL_PENDING;
idata->new_mail_count = 0;
}
* yet again. */
mx_alloc_memory(ctx);
mx_update_context(ctx, ctx->msgcount - oldmsgcount);
- imap_update_context(idata, oldmsgcount);
+ update_context(idata, oldmsgcount);
}
idata->reopen |= IMAP_REOPEN_ALLOW;
/* This is redundant with the following two checks. Removing:
* mutt_set_flag (ctx, h, MUTT_NEW, !(hd->read || hd->old));
*/
- imap_set_changed_flag(ctx, h, local_changes, server_changes, MUTT_OLD,
- old_hd.old, hd->old, h->old);
- imap_set_changed_flag(ctx, h, local_changes, server_changes, MUTT_READ,
- old_hd.read, hd->read, h->read);
- imap_set_changed_flag(ctx, h, local_changes, server_changes, MUTT_DELETE,
- old_hd.deleted, hd->deleted, h->deleted);
- imap_set_changed_flag(ctx, h, local_changes, server_changes, MUTT_FLAG,
- old_hd.flagged, hd->flagged, h->flagged);
- imap_set_changed_flag(ctx, h, local_changes, server_changes, MUTT_REPLIED,
- old_hd.replied, hd->replied, h->replied);
+ set_changed_flag(ctx, h, local_changes, server_changes, MUTT_OLD, old_hd.old,
+ hd->old, h->old);
+ set_changed_flag(ctx, h, local_changes, server_changes, MUTT_READ,
+ old_hd.read, hd->read, h->read);
+ set_changed_flag(ctx, h, local_changes, server_changes, MUTT_DELETE,
+ old_hd.deleted, hd->deleted, h->deleted);
+ set_changed_flag(ctx, h, local_changes, server_changes, MUTT_FLAG,
+ old_hd.flagged, hd->flagged, h->flagged);
+ set_changed_flag(ctx, h, local_changes, server_changes, MUTT_REPLIED,
+ old_hd.replied, hd->replied, h->replied);
/* this message is now definitively *not* changed (mutt_set_flag
* marks things changed as a side-effect) */