NeoMutt  2020-11-20
Teaching an old dog new tricks
DOXYGEN
pop.c File Reference

POP network mailbox. More...

#include "config.h"
#include <errno.h>
#include <limits.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "private.h"
#include "mutt/lib.h"
#include "config/lib.h"
#include "email/lib.h"
#include "core/lib.h"
#include "conn/lib.h"
#include "gui/lib.h"
#include "lib.h"
#include "bcache/lib.h"
#include "ncrypt/lib.h"
#include "context.h"
#include "hook.h"
#include "mutt_account.h"
#include "mutt_globals.h"
#include "mutt_header.h"
#include "mutt_logging.h"
#include "mutt_socket.h"
#include "muttlib.h"
#include "mx.h"
#include "progress.h"
#include <libintl.h>
#include "hcache/lib.h"
+ Include dependency graph for pop.c:

Go to the source code of this file.

Macros

#define HC_FNAME   "neomutt" /* filename for hcache as POP lacks paths */
 
#define HC_FEXT   "hcache" /* extension for hcache as POP lacks paths */
 

Functions

static const char * cache_id (const char *id)
 Make a message-cache-compatible id. More...
 
static void pop_adata_free (void **ptr)
 Free the private Account data - Implements Account::adata_free() More...
 
static struct PopAccountDatapop_adata_new (void)
 Create a new PopAccountData object. More...
 
static void pop_edata_free (void **ptr)
 Free the private Email data - Implements Email::edata_free() More...
 
static struct PopEmailDatapop_edata_new (const char *uid)
 Create a new PopEmailData for an email. More...
 
static int fetch_message (const char *line, void *data)
 write line to file - Implements pop_fetch_t More...
 
static int pop_read_header (struct PopAccountData *adata, struct Email *e)
 Read header. More...
 
static int fetch_uidl (const char *line, void *data)
 parse UIDL - Implements pop_fetch_t More...
 
static int msg_cache_check (const char *id, struct BodyCache *bcache, void *data)
 Check the Body Cache for an ID - Implements bcache_list_t. More...
 
static void pop_hcache_namer (const char *path, struct Buffer *dest)
 Create a header cache filename for a POP mailbox - Implements hcache_namer_t. More...
 
static struct HeaderCachepop_hcache_open (struct PopAccountData *adata, const char *path)
 Open the header cache. More...
 
static int pop_fetch_headers (struct Mailbox *m)
 Read headers. More...
 
static void pop_clear_cache (struct PopAccountData *adata)
 delete all cached messages More...
 
void pop_fetch_mail (void)
 Fetch messages and save them in $spoolfile. More...
 
static struct Accountpop_ac_find (struct Account *a, const char *path)
 Find an Account that matches a Mailbox path - Implements MxOps::ac_find() More...
 
static int pop_ac_add (struct Account *a, struct Mailbox *m)
 Add a Mailbox to an Account - Implements MxOps::ac_add() More...
 
static int pop_mbox_open (struct Mailbox *m)
 Open a Mailbox - Implements MxOps::mbox_open() More...
 
static int pop_mbox_check (struct Mailbox *m)
 Check for new mail - Implements MxOps::mbox_check() More...
 
static int pop_mbox_sync (struct Mailbox *m)
 Save changes to the Mailbox - Implements MxOps::mbox_sync() More...
 
static int pop_mbox_close (struct Mailbox *m)
 Close a Mailbox - Implements MxOps::mbox_close() More...
 
static int pop_msg_open (struct Mailbox *m, struct Message *msg, int msgno)
 Open an email message in a Mailbox - Implements MxOps::msg_open() More...
 
static int pop_msg_close (struct Mailbox *m, struct Message *msg)
 Close an email - Implements MxOps::msg_close() More...
 
static int pop_msg_save_hcache (struct Mailbox *m, struct Email *e)
 Save message to the header cache - Implements MxOps::msg_save_hcache() More...
 
enum MailboxType pop_path_probe (const char *path, const struct stat *st)
 Is this a POP Mailbox? - Implements MxOps::path_probe() More...
 
static int pop_path_canon (char *buf, size_t buflen)
 Canonicalise a Mailbox path - Implements MxOps::path_canon() More...
 
static int pop_path_pretty (char *buf, size_t buflen, const char *folder)
 Abbreviate a Mailbox path - Implements MxOps::path_pretty() More...
 
static int pop_path_parent (char *buf, size_t buflen)
 Find the parent of a Mailbox path - Implements MxOps::path_parent() More...
 

Variables

struct MxOps MxPopOps
 POP Mailbox - Implements MxOps. More...
 

Detailed Description

POP network mailbox.

Authors
  • Vsevolod Volkov
  • Rocco Rutte
  • 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 pop.c.

Macro Definition Documentation

◆ HC_FNAME

#define HC_FNAME   "neomutt" /* filename for hcache as POP lacks paths */

Definition at line 69 of file pop.c.

◆ HC_FEXT

#define HC_FEXT   "hcache" /* extension for hcache as POP lacks paths */

Definition at line 70 of file pop.c.

Function Documentation

◆ cache_id()

static const char* cache_id ( const char *  id)
static

Make a message-cache-compatible id.

Parameters
idPOP message id
Return values
ptrSanitised string

The POP message id may contain '/' and other awkward characters.

Note
This function returns a pointer to a static buffer.

Definition at line 81 of file pop.c.

82 {
83  static char clean[128];
84  mutt_str_copy(clean, id, sizeof(clean));
85  mutt_file_sanitize_filename(clean, true);
86  return clean;
87 }
void mutt_file_sanitize_filename(char *path, bool slash)
Replace unsafe characters in a filename.
Definition: file.c:618
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
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pop_adata_free()

static void pop_adata_free ( void **  ptr)
static

Free the private Account data - Implements Account::adata_free()

The PopAccountData struct stores global POP data, such as the connection to the database. This function will close the database, free the resources and the struct itself.

Definition at line 96 of file pop.c.

97 {
98  if (!ptr || !*ptr)
99  return;
100 
101  struct PopAccountData *adata = *ptr;
102  FREE(&adata->auth_list.data);
103  FREE(ptr);
104 }
struct Buffer auth_list
list of auth mechanisms
Definition: private.h:95
void * adata
Private data (for Mailbox backends)
Definition: account.h:43
char * data
Pointer to data.
Definition: buffer.h:35
#define FREE(x)
Definition: memory.h:40
POP-specific Account data -.
Definition: private.h:78
+ Here is the caller graph for this function:

◆ pop_adata_new()

static struct PopAccountData* pop_adata_new ( void  )
static

Create a new PopAccountData object.

Return values
ptrNew PopAccountData struct

Definition at line 110 of file pop.c.

111 {
112  return mutt_mem_calloc(1, sizeof(struct PopAccountData));
113 }
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:50
POP-specific Account data -.
Definition: private.h:78
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pop_edata_free()

static void pop_edata_free ( void **  ptr)
static

Free the private Email data - Implements Email::edata_free()

Each email has an attached PopEmailData, which contains things like the tags (labels).

Definition at line 121 of file pop.c.

122 {
123  if (!ptr || !*ptr)
124  return;
125 
126  struct PopEmailData *edata = *ptr;
127  FREE(&edata->uid);
128  FREE(ptr);
129 }
const char * uid
Definition: private.h:107
POP-specific Email data -.
Definition: private.h:105
void * edata
Driver-specific data.
Definition: email.h:111
#define FREE(x)
Definition: memory.h:40
+ Here is the caller graph for this function:

◆ pop_edata_new()

static struct PopEmailData* pop_edata_new ( const char *  uid)
static

Create a new PopEmailData for an email.

Parameters
uidEmail UID
Return values
ptrNew PopEmailData struct

Definition at line 136 of file pop.c.

137 {
138  struct PopEmailData *edata = mutt_mem_calloc(1, sizeof(struct PopEmailData));
139  edata->uid = mutt_str_dup(uid);
140  return edata;
141 }
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:50
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:370
const char * uid
Definition: private.h:107
POP-specific Email data -.
Definition: private.h:105
void * edata
Driver-specific data.
Definition: email.h:111
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fetch_message()

static int fetch_message ( const char *  line,
void *  data 
)
static

write line to file - Implements pop_fetch_t

Parameters
lineString to write
dataFILE pointer to write to
Return values
0Success
-1Failure

Definition at line 150 of file pop.c.

151 {
152  FILE *fp = data;
153 
154  fputs(line, fp);
155  if (fputc('\n', fp) == EOF)
156  return -1;
157 
158  return 0;
159 }
+ Here is the caller graph for this function:

◆ pop_read_header()

static int pop_read_header ( struct PopAccountData adata,
struct Email e 
)
static

Read header.

Parameters
adataPOP Account data
eEmail
Return values
0Success
-1Connection lost
-2Invalid command or execution error
-3Error writing to tempfile

Definition at line 170 of file pop.c.

171 {
172  FILE *fp = mutt_file_mkstemp();
173  if (!fp)
174  {
175  mutt_perror(_("Can't create temporary file"));
176  return -3;
177  }
178 
179  int index = 0;
180  size_t length = 0;
181  char buf[1024];
182 
183  struct PopEmailData *edata = pop_edata_get(e);
184 
185  snprintf(buf, sizeof(buf), "LIST %d\r\n", edata->refno);
186  int rc = pop_query(adata, buf, sizeof(buf));
187  if (rc == 0)
188  {
189  sscanf(buf, "+OK %d %zu", &index, &length);
190 
191  snprintf(buf, sizeof(buf), "TOP %d 0\r\n", edata->refno);
192  rc = pop_fetch_data(adata, buf, NULL, fetch_message, fp);
193 
194  if (adata->cmd_top == 2)
195  {
196  if (rc == 0)
197  {
198  adata->cmd_top = 1;
199 
200  mutt_debug(LL_DEBUG1, "set TOP capability\n");
201  }
202 
203  if (rc == -2)
204  {
205  adata->cmd_top = 0;
206 
207  mutt_debug(LL_DEBUG1, "unset TOP capability\n");
208  snprintf(adata->err_msg, sizeof(adata->err_msg), "%s",
209  _("Command TOP is not supported by server"));
210  }
211  }
212  }
213 
214  switch (rc)
215  {
216  case 0:
217  {
218  rewind(fp);
219  e->env = mutt_rfc822_read_header(fp, e, false, false);
220  e->body->length = length - e->body->offset + 1;
221  rewind(fp);
222  while (!feof(fp))
223  {
224  e->body->length--;
225  fgets(buf, sizeof(buf), fp);
226  }
227  break;
228  }
229  case -2:
230  {
231  mutt_error("%s", adata->err_msg);
232  break;
233  }
234  case -3:
235  {
236  mutt_error(_("Can't write header to temporary file"));
237  break;
238  }
239  }
240 
241  mutt_file_fclose(&fp);
242  return rc;
243 }
#define pop_query(adata, buf, buflen)
Definition: private.h:154
char err_msg[POP_CMD_RESPONSE]
Definition: private.h:98
#define mutt_perror(...)
Definition: logging.h:85
struct Body * body
List of MIME parts.
Definition: email.h:91
struct PopEmailData * pop_edata_get(struct Email *e)
Get the private data for this Email.
Definition: lib.c:269
LOFF_T offset
offset where the actual data begins
Definition: body.h:44
#define _(a)
Definition: message.h:28
int refno
Message number on server.
Definition: private.h:108
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
Definition: file.c:153
struct Envelope * env
Envelope information.
Definition: email.h:90
int pop_fetch_data(struct PopAccountData *adata, const char *query, struct Progress *progress, pop_fetch_t callback, void *data)
Read Headers with callback function.
Definition: lib.c:511
LOFF_T length
length (in bytes) of attachment
Definition: body.h:45
#define mutt_file_mkstemp()
Definition: file.h:106
unsigned int cmd_top
optional command TOP
Definition: private.h:88
POP-specific Email data -.
Definition: private.h:105
Log at debug level 1.
Definition: logging.h:40
void * edata
Driver-specific data.
Definition: email.h:111
#define mutt_error(...)
Definition: logging.h:84
int index
The absolute (unsorted) message number.
Definition: email.h:86
#define mutt_debug(LEVEL,...)
Definition: logging.h:81
struct Envelope * mutt_rfc822_read_header(FILE *fp, struct Email *e, bool user_hdrs, bool weed)
parses an RFC822 header
Definition: parse.c:1111
static int fetch_message(const char *line, void *data)
write line to file - Implements pop_fetch_t
Definition: pop.c:150
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fetch_uidl()

static int fetch_uidl ( const char *  line,
void *  data 
)
static

parse UIDL - Implements pop_fetch_t

Parameters
lineString to parse
dataMailbox
Return values
0Success
-1Failure

Definition at line 252 of file pop.c.

253 {
254  struct Mailbox *m = data;
255  struct PopAccountData *adata = pop_adata_get(m);
256  char *endp = NULL;
257 
258  errno = 0;
259  int index = strtol(line, &endp, 10);
260  if (errno)
261  return -1;
262  while (*endp == ' ')
263  endp++;
264  line = endp;
265 
266  /* uid must be at least be 1 byte */
267  if (strlen(line) == 0)
268  return -1;
269 
270  int i;
271  for (i = 0; i < m->msg_count; i++)
272  {
273  struct PopEmailData *edata = pop_edata_get(m->emails[i]);
274  if (mutt_str_equal(line, edata->uid))
275  break;
276  }
277 
278  if (i == m->msg_count)
279  {
280  mutt_debug(LL_DEBUG1, "new header %d %s\n", index, line);
281 
282  if (i >= m->email_max)
283  mx_alloc_memory(m);
284 
285  m->msg_count++;
286  m->emails[i] = email_new();
287 
288  m->emails[i]->edata = pop_edata_new(line);
290  }
291  else if (m->emails[i]->index != index - 1)
292  adata->clear_cache = true;
293 
294  m->emails[i]->index = index - 1;
295 
296  struct PopEmailData *edata = pop_edata_get(m->emails[i]);
297  edata->refno = index;
298 
299  return 0;
300 }
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:871
struct Email ** emails
Array of Emails.
Definition: mailbox.h:99
int msg_count
Total number of messages.
Definition: mailbox.h:91
struct PopEmailData * pop_edata_get(struct Email *e)
Get the private data for this Email.
Definition: lib.c:269
void mx_alloc_memory(struct Mailbox *m)
Create storage for the emails.
Definition: mx.c:1230
static struct PopEmailData * pop_edata_new(const char *uid)
Create a new PopEmailData for an email.
Definition: pop.c:136
int refno
Message number on server.
Definition: private.h:108
const char * uid
Definition: private.h:107
int email_max
Number of pointers in emails.
Definition: mailbox.h:100
A mailbox.
Definition: mailbox.h:81
void * adata
Private data (for Mailbox backends)
Definition: account.h:43
bool clear_cache
Definition: private.h:91
void(* edata_free)(void **ptr)
Free the private data attached to the Email.
Definition: email.h:117
POP-specific Email data -.
Definition: private.h:105
static void pop_edata_free(void **ptr)
Free the private Email data - Implements Email::edata_free()
Definition: pop.c:121
Log at debug level 1.
Definition: logging.h:40
void * edata
Driver-specific data.
Definition: email.h:111
int index
The absolute (unsorted) message number.
Definition: email.h:86
struct Email * email_new(void)
Create a new Email.
Definition: email.c:72
#define mutt_debug(LEVEL,...)
Definition: logging.h:81
struct PopAccountData * pop_adata_get(struct Mailbox *m)
Get the Account data for this mailbox.
Definition: lib.c:659
POP-specific Account data -.
Definition: private.h:78
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ msg_cache_check()

static int msg_cache_check ( const char *  id,
struct BodyCache bcache,
void *  data 
)
static

Check the Body Cache for an ID - Implements bcache_list_t.

Definition at line 305 of file pop.c.

306 {
307  struct Mailbox *m = data;
308  if (!m)
309  return -1;
310 
311  struct PopAccountData *adata = pop_adata_get(m);
312  if (!adata)
313  return -1;
314 
315 #ifdef USE_HCACHE
316  /* keep hcache file if hcache == bcache */
317  if (strcmp(HC_FNAME "." HC_FEXT, id) == 0)
318  return 0;
319 #endif
320 
321  for (int i = 0; i < m->msg_count; i++)
322  {
323  struct PopEmailData *edata = pop_edata_get(m->emails[i]);
324  /* if the id we get is known for a header: done (i.e. keep in cache) */
325  if (edata->uid && mutt_str_equal(edata->uid, id))
326  return 0;
327  }
328 
329  /* message not found in context -> remove it from cache
330  * return the result of bcache, so we stop upon its first error */
331  return mutt_bcache_del(bcache, cache_id(id));
332 }
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:871
struct Email ** emails
Array of Emails.
Definition: mailbox.h:99
int msg_count
Total number of messages.
Definition: mailbox.h:91
#define HC_FNAME
Definition: pop.c:69
struct PopEmailData * pop_edata_get(struct Email *e)
Get the private data for this Email.
Definition: lib.c:269
static const char * cache_id(const char *id)
Make a message-cache-compatible id.
Definition: pop.c:81
const char * uid
Definition: private.h:107
A mailbox.
Definition: mailbox.h:81
void * adata
Private data (for Mailbox backends)
Definition: account.h:43
int mutt_bcache_del(struct BodyCache *bcache, const char *id)
Delete a file from the Body Cache.
Definition: bcache.c:263
POP-specific Email data -.
Definition: private.h:105
#define HC_FEXT
Definition: pop.c:70
void * edata
Driver-specific data.
Definition: email.h:111
struct PopAccountData * pop_adata_get(struct Mailbox *m)
Get the Account data for this mailbox.
Definition: lib.c:659
POP-specific Account data -.
Definition: private.h:78
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pop_hcache_namer()

static void pop_hcache_namer ( const char *  path,
struct Buffer dest 
)
static

Create a header cache filename for a POP mailbox - Implements hcache_namer_t.

Definition at line 338 of file pop.c.

339 {
340  mutt_buffer_printf(dest, "%s." HC_FEXT, path);
341 }
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:160
#define HC_FEXT
Definition: pop.c:70
char * path
Path of Email (for local Mailboxes)
Definition: email.h:92
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pop_hcache_open()

static struct HeaderCache* pop_hcache_open ( struct PopAccountData adata,
const char *  path 
)
static

Open the header cache.

Parameters
adataPOP Account data
pathPath to the mailbox
Return values
ptrHeader cache

Definition at line 349 of file pop.c.

350 {
351  if (!adata || !adata->conn)
352  return mutt_hcache_open(C_HeaderCache, path, NULL);
353 
354  struct Url url = { 0 };
355  char p[1024];
356 
357  mutt_account_tourl(&adata->conn->account, &url);
358  url.path = HC_FNAME;
359  url_tostring(&url, p, sizeof(p), U_PATH);
361 }
struct ConnAccount account
Account details: username, password, etc.
Definition: connection.h:36
#define HC_FNAME
Definition: pop.c:69
A parsed URL proto://user:password@host:port/path?a=1&b=2
Definition: url.h:66
char * C_HeaderCache
Config: (hcache) Directory/file for the header cache database.
Definition: config.c:40
struct Connection * conn
Definition: private.h:80
struct HeaderCache * mutt_hcache_open(const char *path, const char *folder, hcache_namer_t namer)
Multiplexor for StoreOps::open.
Definition: hcache.c:320
void mutt_account_tourl(struct ConnAccount *cac, struct Url *url)
Fill URL with info from account.
Definition: mutt_account.c:79
char * path
Path.
Definition: url.h:73
static void pop_hcache_namer(const char *path, struct Buffer *dest)
Create a header cache filename for a POP mailbox - Implements hcache_namer_t.
Definition: pop.c:338
char * path
Path of Email (for local Mailboxes)
Definition: email.h:92
int url_tostring(struct Url *url, char *dest, size_t len, int flags)
Output the URL string for a given Url object.
Definition: url.c:418
#define U_PATH
Definition: url.h:48
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pop_fetch_headers()

static int pop_fetch_headers ( struct Mailbox m)
static

Read headers.

Parameters
mMailbox
Return values
0Success
-1Connection lost
-2Invalid command or execution error
-3Error writing to tempfile

Definition at line 372 of file pop.c.

373 {
374  if (!m)
375  return -1;
376 
377  struct PopAccountData *adata = pop_adata_get(m);
378  struct Progress progress;
379 
380 #ifdef USE_HCACHE
381  struct HeaderCache *hc = pop_hcache_open(adata, mailbox_path(m));
382 #endif
383 
384  adata->check_time = mutt_date_epoch();
385  adata->clear_cache = false;
386 
387  for (int i = 0; i < m->msg_count; i++)
388  {
389  struct PopEmailData *edata = pop_edata_get(m->emails[i]);
390  edata->refno = -1;
391  }
392 
393  const int old_count = m->msg_count;
394  int rc = pop_fetch_data(adata, "UIDL\r\n", NULL, fetch_uidl, m);
395  const int new_count = m->msg_count;
396  m->msg_count = old_count;
397 
398  if (adata->cmd_uidl == 2)
399  {
400  if (rc == 0)
401  {
402  adata->cmd_uidl = 1;
403 
404  mutt_debug(LL_DEBUG1, "set UIDL capability\n");
405  }
406 
407  if ((rc == -2) && (adata->cmd_uidl == 2))
408  {
409  adata->cmd_uidl = 0;
410 
411  mutt_debug(LL_DEBUG1, "unset UIDL capability\n");
412  snprintf(adata->err_msg, sizeof(adata->err_msg), "%s",
413  _("Command UIDL is not supported by server"));
414  }
415  }
416 
417  if (m->verbose)
418  {
419  mutt_progress_init(&progress, _("Fetching message headers..."),
420  MUTT_PROGRESS_READ, new_count - old_count);
421  }
422 
423  if (rc == 0)
424  {
425  int i, deleted;
426  for (i = 0, deleted = 0; i < old_count; i++)
427  {
428  struct PopEmailData *edata = pop_edata_get(m->emails[i]);
429  if (edata->refno == -1)
430  {
431  m->emails[i]->deleted = true;
432  deleted++;
433  }
434  }
435  if (deleted > 0)
436  {
437  mutt_error(
438  ngettext("%d message has been lost. Try reopening the mailbox.",
439  "%d messages have been lost. Try reopening the mailbox.", deleted),
440  deleted);
441  }
442 
443  bool hcached = false;
444  for (i = old_count; i < new_count; i++)
445  {
446  if (m->verbose)
447  mutt_progress_update(&progress, i + 1 - old_count, -1);
448  struct PopEmailData *edata = pop_edata_get(m->emails[i]);
449 #ifdef USE_HCACHE
450  struct HCacheEntry hce = mutt_hcache_fetch(hc, edata->uid, strlen(edata->uid), 0);
451  if (hce.email)
452  {
453  /* Detach the private data */
454  m->emails[i]->edata = NULL;
455 
456  int index = m->emails[i]->index;
457  /* - POP dynamically numbers headers and relies on e->refno
458  * to map messages; so restore header and overwrite restored
459  * refno with current refno, same for index
460  * - e->data needs to a separate pointer as it's driver-specific
461  * data freed separately elsewhere
462  * (the old e->data should point inside a malloc'd block from
463  * hcache so there shouldn't be a memleak here) */
464  email_free(&m->emails[i]);
465  m->emails[i] = hce.email;
466  m->emails[i]->index = index;
467 
468  /* Reattach the private data */
469  m->emails[i]->edata = edata;
471  rc = 0;
472  hcached = true;
473  }
474  else
475 #endif
476  if ((rc = pop_read_header(adata, m->emails[i])) < 0)
477  break;
478 #ifdef USE_HCACHE
479  else
480  {
481  mutt_hcache_store(hc, edata->uid, strlen(edata->uid), m->emails[i], 0);
482  }
483 #endif
484 
485  /* faked support for flags works like this:
486  * - if 'hcached' is true, we have the message in our hcache:
487  * - if we also have a body: read
488  * - if we don't have a body: old
489  * (if $mark_old is set which is maybe wrong as
490  * $mark_old should be considered for syncing the
491  * folder and not when opening it XXX)
492  * - if 'hcached' is false, we don't have the message in our hcache:
493  * - if we also have a body: read
494  * - if we don't have a body: new */
495  const bool bcached =
496  (mutt_bcache_exists(adata->bcache, cache_id(edata->uid)) == 0);
497  m->emails[i]->old = false;
498  m->emails[i]->read = false;
499  if (hcached)
500  {
501  if (bcached)
502  m->emails[i]->read = true;
503  else if (C_MarkOld)
504  m->emails[i]->old = true;
505  }
506  else
507  {
508  if (bcached)
509  m->emails[i]->read = true;
510  }
511 
512  m->msg_count++;
513  }
514  }
515 
516 #ifdef USE_HCACHE
517  mutt_hcache_close(hc);
518 #endif
519 
520  if (rc < 0)
521  {
522  for (int i = m->msg_count; i < new_count; i++)
523  email_free(&m->emails[i]);
524  return rc;
525  }
526 
527  /* after putting the result into our structures,
528  * clean up cache, i.e. wipe messages deleted outside
529  * the availability of our cache */
532 
534  return new_count - old_count;
535 }
struct Email ** emails
Array of Emails.
Definition: mailbox.h:99
time_t mutt_date_epoch(void)
Return the number of seconds since the Unix epoch.
Definition: date.c:416
static const char * mailbox_path(const struct Mailbox *m)
Get the Mailbox&#39;s path string.
Definition: mailbox.h:203
int msg_count
Total number of messages.
Definition: mailbox.h:91
char err_msg[POP_CMD_RESPONSE]
Definition: private.h:98
bool C_MarkOld
Config: Mark new emails as old when leaving the mailbox.
Definition: globals.c:36
bool C_MessageCacheClean
Config: (imap/pop) Clean out obsolete entries from the message cache.
Definition: bcache.c:44
Wrapper for Email retrieved from the header cache.
Definition: lib.h:96
struct BodyCache * bcache
body cache
Definition: private.h:97
header cache structure
Definition: lib.h:85
struct PopEmailData * pop_edata_get(struct Email *e)
Get the private data for this Email.
Definition: lib.c:269
#define _(a)
Definition: message.h:28
static const char * cache_id(const char *id)
Make a message-cache-compatible id.
Definition: pop.c:81
int refno
Message number on server.
Definition: private.h:108
A progress bar.
Definition: progress.h:50
static int msg_cache_check(const char *id, struct BodyCache *bcache, void *data)
Check the Body Cache for an ID - Implements bcache_list_t.
Definition: pop.c:305
int mutt_bcache_list(struct BodyCache *bcache, bcache_list_t want_id, void *data)
Find matching entries in the Body Cache.
Definition: bcache.c:328
static struct HeaderCache * pop_hcache_open(struct PopAccountData *adata, const char *path)
Open the header cache.
Definition: pop.c:349
bool read
Email is read.
Definition: email.h:51
void mutt_progress_update(struct Progress *progress, size_t pos, int percent)
Update the state of the progress bar.
Definition: progress.c:212
bool old
Email is seen, but unread.
Definition: email.h:50
const char * uid
Definition: private.h:107
Progress tracks elements, according to $read_inc
Definition: progress.h:42
int mutt_bcache_exists(struct BodyCache *bcache, const char *id)
Check if a file exists in the Body Cache.
Definition: bcache.c:286
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
Definition: mutt_logging.c:113
int pop_fetch_data(struct PopAccountData *adata, const char *query, struct Progress *progress, pop_fetch_t callback, void *data)
Read Headers with callback function.
Definition: lib.c:511
time_t check_time
Definition: private.h:93
static int fetch_uidl(const char *line, void *data)
parse UIDL - Implements pop_fetch_t
Definition: pop.c:252
void * adata
Private data (for Mailbox backends)
Definition: account.h:43
bool clear_cache
Definition: private.h:91
unsigned int cmd_uidl
optional command UIDL
Definition: private.h:87
void(* edata_free)(void **ptr)
Free the private data attached to the Email.
Definition: email.h:117
static int pop_read_header(struct PopAccountData *adata, struct Email *e)
Read header.
Definition: pop.c:170
bool verbose
Display status messages?
Definition: mailbox.h:118
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:525
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
POP-specific Email data -.
Definition: private.h:105
void mutt_hcache_close(struct HeaderCache *hc)
Multiplexor for StoreOps::close.
Definition: hcache.c:417
static void pop_edata_free(void **ptr)
Free the private Email data - Implements Email::edata_free()
Definition: pop.c:121
Log at debug level 1.
Definition: logging.h:40
bool deleted
Email is deleted.
Definition: email.h:45
void * edata
Driver-specific data.
Definition: email.h:111
#define mutt_error(...)
Definition: logging.h:84
int index
The absolute (unsorted) message number.
Definition: email.h:86
struct HCacheEntry mutt_hcache_fetch(struct HeaderCache *hc, const char *key, size_t keylen, uint32_t uidvalidity)
Multiplexor for StoreOps::fetch.
Definition: hcache.c:436
#define mutt_debug(LEVEL,...)
Definition: logging.h:81
struct PopAccountData * pop_adata_get(struct Mailbox *m)
Get the Account data for this mailbox.
Definition: lib.c:659
struct Email * email
Retrieved email.
Definition: lib.h:100
POP-specific Account data -.
Definition: private.h:78
void email_free(struct Email **ptr)
Free an Email.
Definition: email.c:43
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pop_clear_cache()

static void pop_clear_cache ( struct PopAccountData adata)
static

delete all cached messages

Parameters
adataPOP Account data

Definition at line 541 of file pop.c.

542 {
543  if (!adata->clear_cache)
544  return;
545 
546  mutt_debug(LL_DEBUG1, "delete cached messages\n");
547 
548  for (int i = 0; i < POP_CACHE_LEN; i++)
549  {
550  if (adata->cache[i].path)
551  {
552  unlink(adata->cache[i].path);
553  FREE(&adata->cache[i].path);
554  }
555  }
556 }
char * path
Definition: private.h:72
struct PopCache cache[POP_CACHE_LEN]
Definition: private.h:99
#define POP_CACHE_LEN
Definition: private.h:40
bool clear_cache
Definition: private.h:91
Log at debug level 1.
Definition: logging.h:40
#define FREE(x)
Definition: memory.h:40
#define mutt_debug(LEVEL,...)
Definition: logging.h:81
+ Here is the caller graph for this function:

◆ pop_fetch_mail()

void pop_fetch_mail ( void  )

Fetch messages and save them in $spoolfile.

Definition at line 561 of file pop.c.

562 {
563  if (!C_PopHost)
564  {
565  mutt_error(_("POP host is not defined"));
566  return;
567  }
568 
569  char buf[1024];
570  char msgbuf[128];
571  int last = 0, msgs, bytes, rset = 0, ret;
572  struct ConnAccount cac = { { 0 } };
573 
574  char *p = mutt_mem_calloc(strlen(C_PopHost) + 7, sizeof(char));
575  char *url = p;
577  {
578  strcpy(url, "pop://");
579  p = strchr(url, '\0');
580  }
581  strcpy(p, C_PopHost);
582 
583  ret = pop_parse_path(url, &cac);
584  FREE(&url);
585  if (ret)
586  {
587  mutt_error(_("%s is an invalid POP path"), C_PopHost);
588  return;
589  }
590 
591  struct Connection *conn = mutt_conn_find(&cac);
592  if (!conn)
593  return;
594 
595  struct PopAccountData *adata = pop_adata_new();
596  adata->conn = conn;
597 
598  if (pop_open_connection(adata) < 0)
599  {
600  //XXX mutt_socket_free(adata->conn);
601  pop_adata_free((void **) &adata);
602  return;
603  }
604 
605  mutt_message(_("Checking for new messages..."));
606 
607  /* find out how many messages are in the mailbox. */
608  mutt_str_copy(buf, "STAT\r\n", sizeof(buf));
609  ret = pop_query(adata, buf, sizeof(buf));
610  if (ret == -1)
611  goto fail;
612  if (ret == -2)
613  {
614  mutt_error("%s", adata->err_msg);
615  goto finish;
616  }
617 
618  sscanf(buf, "+OK %d %d", &msgs, &bytes);
619 
620  /* only get unread messages */
621  if ((msgs > 0) && C_PopLast)
622  {
623  mutt_str_copy(buf, "LAST\r\n", sizeof(buf));
624  ret = pop_query(adata, buf, sizeof(buf));
625  if (ret == -1)
626  goto fail;
627  if (ret == 0)
628  sscanf(buf, "+OK %d", &last);
629  }
630 
631  if (msgs <= last)
632  {
633  mutt_message(_("No new mail in POP mailbox"));
634  goto finish;
635  }
636 
637  struct Mailbox *m_spool = mx_path_resolve(C_Spoolfile);
638  struct Context *ctx = mx_mbox_open(m_spool, MUTT_OPEN_NO_FLAGS);
639  if (!ctx)
640  {
641  mailbox_free(&m_spool);
642  goto finish;
643  }
644 
645  bool old_append = m_spool->append;
646  m_spool->append = true;
647 
648  enum QuadOption delanswer =
649  query_quadoption(C_PopDelete, _("Delete messages from server?"));
650 
651  snprintf(msgbuf, sizeof(msgbuf),
652  ngettext("Reading new messages (%d byte)...",
653  "Reading new messages (%d bytes)...", bytes),
654  bytes);
655  mutt_message("%s", msgbuf);
656 
657  for (int i = last + 1; i <= msgs; i++)
658  {
659  struct Message *msg = mx_msg_open_new(ctx->mailbox, NULL, MUTT_ADD_FROM);
660  if (msg)
661  {
662  snprintf(buf, sizeof(buf), "RETR %d\r\n", i);
663  ret = pop_fetch_data(adata, buf, NULL, fetch_message, msg->fp);
664  if (ret == -3)
665  rset = 1;
666 
667  if ((ret == 0) && (mx_msg_commit(ctx->mailbox, msg) != 0))
668  {
669  rset = 1;
670  ret = -3;
671  }
672 
673  mx_msg_close(ctx->mailbox, &msg);
674  }
675  else
676  {
677  ret = -3;
678  }
679 
680  if ((ret == 0) && (delanswer == MUTT_YES))
681  {
682  /* delete the message on the server */
683  snprintf(buf, sizeof(buf), "DELE %d\r\n", i);
684  ret = pop_query(adata, buf, sizeof(buf));
685  }
686 
687  if (ret == -1)
688  {
689  m_spool->append = old_append;
690  mx_mbox_close(&ctx);
691  goto fail;
692  }
693  if (ret == -2)
694  {
695  mutt_error("%s", adata->err_msg);
696  break;
697  }
698  if (ret == -3)
699  {
700  mutt_error(_("Error while writing mailbox"));
701  break;
702  }
703 
704  /* L10N: The plural is picked by the second numerical argument, i.e.
705  the %d right before 'messages', i.e. the total number of messages. */
706  mutt_message(ngettext("%s [%d of %d message read]",
707  "%s [%d of %d messages read]", msgs - last),
708  msgbuf, i - last, msgs - last);
709  }
710 
711  m_spool->append = old_append;
712  mx_mbox_close(&ctx);
713 
714  if (rset)
715  {
716  /* make sure no messages get deleted */
717  mutt_str_copy(buf, "RSET\r\n", sizeof(buf));
718  if (pop_query(adata, buf, sizeof(buf)) == -1)
719  goto fail;
720  }
721 
722 finish:
723  /* exit gracefully */
724  mutt_str_copy(buf, "QUIT\r\n", sizeof(buf));
725  if (pop_query(adata, buf, sizeof(buf)) == -1)
726  goto fail;
727  mutt_socket_close(conn);
728  FREE(&conn);
729  pop_adata_free((void **) &adata);
730  return;
731 
732 fail:
733  mutt_error(_("Server closed connection"));
734  mutt_socket_close(conn);
735  pop_adata_free((void **) &adata);
736 }
enum UrlScheme url_check_scheme(const char *str)
Check the protocol of a URL.
Definition: url.c:221
#define MUTT_OPEN_NO_FLAGS
No flags are set.
Definition: mx.h:51
The "current" mailbox.
Definition: context.h:38
#define pop_query(adata, buf, buflen)
Definition: private.h:154
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:50
char err_msg[POP_CMD_RESPONSE]
Definition: private.h:98
int pop_parse_path(const char *path, struct ConnAccount *cac)
Parse a POP mailbox name.
Definition: lib.c:79
int mx_mbox_close(struct Context **ptr)
Save changes and close mailbox.
Definition: mx.c:630
int pop_open_connection(struct PopAccountData *adata)
Open connection and authenticate.
Definition: lib.c:318
#define mutt_message(...)
Definition: logging.h:83
An open network connection (socket)
Definition: connection.h:34
Url wasn&#39;t recognised.
Definition: url.h:34
#define _(a)
Definition: message.h:28
struct Connection * conn
Definition: private.h:80
struct Context * mx_mbox_open(struct Mailbox *m, OpenMailboxFlags flags)
Open a mailbox and parse it.
Definition: mx.c:303
QuadOption
Possible values for a quad-option.
Definition: quad.h:36
char * C_PopHost
Config: (pop) Url of the POP server.
Definition: config.c:41
int mx_msg_close(struct Mailbox *m, struct Message **msg)
Close a message.
Definition: mx.c:1204
struct Message * mx_msg_open_new(struct Mailbox *m, const struct Email *e, MsgOpenFlags flags)
Open a new message.
Definition: mx.c:1072
struct Mailbox * mailbox
Definition: context.h:50
void mailbox_free(struct Mailbox **ptr)
Free a Mailbox.
Definition: mailbox.c:63
struct Connection * mutt_conn_find(const struct ConnAccount *cac)
Find a connection from a list.
Definition: mutt_socket.c:86
int pop_fetch_data(struct PopAccountData *adata, const char *query, struct Progress *progress, pop_fetch_t callback, void *data)
Read Headers with callback function.
Definition: lib.c:511
A local copy of an email.
Definition: mx.h:82
A mailbox.
Definition: mailbox.h:81
void * adata
Private data (for Mailbox backends)
Definition: account.h:43
bool append
Mailbox is opened in append mode.
Definition: mailbox.h:113
static struct PopAccountData * pop_adata_new(void)
Create a new PopAccountData object.
Definition: pop.c:110
unsigned char C_PopDelete
Config: (pop) After downloading POP messages, delete them on the server.
Definition: config.c:40
Login details for a remote server.
Definition: connaccount.h:51
int mutt_socket_close(struct Connection *conn)
Close a socket.
Definition: socket.c:96
bool C_PopLast
Config: (pop) Use the &#39;LAST&#39; command to fetch new mail.
Definition: config.c:42
enum QuadOption query_quadoption(enum QuadOption opt, const char *prompt)
Ask the user a quad-question.
Definition: curs_lib.c:517
WHERE char * C_Spoolfile
Config: Inbox.
Definition: mutt_globals.h:108
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
static void pop_adata_free(void **ptr)
Free the private Account data - Implements Account::adata_free()
Definition: pop.c:96
#define mutt_error(...)
Definition: logging.h:84
int mx_msg_commit(struct Mailbox *m, struct Message *msg)
Commit a message to a folder - Wrapper for MxOps::msg_commit()
Definition: mx.c:1183
FILE * fp
pointer to the message data
Definition: mx.h:84
#define FREE(x)
Definition: memory.h:40
struct Mailbox * mx_path_resolve(const char *path)
Get a Mailbox for a path.
Definition: mx.c:1681
POP-specific Account data -.
Definition: private.h:78
#define MUTT_ADD_FROM
add a From_ line
Definition: mx.h:65
User answered &#39;Yes&#39;, or assume &#39;Yes&#39;.
Definition: quad.h:40
static int fetch_message(const char *line, void *data)
write line to file - Implements pop_fetch_t
Definition: pop.c:150
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pop_ac_find()

static struct Account* pop_ac_find ( struct Account a,
const char *  path 
)
static

Find an Account that matches a Mailbox path - Implements MxOps::ac_find()

Definition at line 741 of file pop.c.

742 {
743  struct Url *url = url_parse(path);
744  if (!url)
745  return NULL;
746 
747  struct PopAccountData *adata = a->adata;
748  struct ConnAccount *cac = &adata->conn->account;
749 
750  if (!mutt_istr_equal(url->host, cac->host) || !mutt_istr_equal(url->user, cac->user))
751  {
752  a = NULL;
753  }
754 
755  url_free(&url);
756  return a;
757 }
struct ConnAccount account
Account details: username, password, etc.
Definition: connection.h:36
A parsed URL proto://user:password@host:port/path?a=1&b=2
Definition: url.h:66
char user[128]
Username.
Definition: connaccount.h:55
struct Connection * conn
Definition: private.h:80
void url_free(struct Url **ptr)
Free the contents of a URL.
Definition: url.c:123
char host[128]
Server to login to.
Definition: connaccount.h:53
bool mutt_istr_equal(const char *a, const char *b)
Compare two strings, ignoring case.
Definition: string.c:883
char * user
Username.
Definition: url.h:69
void * adata
Private data (for Mailbox backends)
Definition: account.h:43
char * host
Host.
Definition: url.h:71
Login details for a remote server.
Definition: connaccount.h:51
char * path
Path.
Definition: url.h:73
POP-specific Account data -.
Definition: private.h:78
struct Url * url_parse(const char *src)
Fill in Url.
Definition: url.c:234
+ Here is the call graph for this function:

◆ pop_ac_add()

static int pop_ac_add ( struct Account a,
struct Mailbox m 
)
static

Add a Mailbox to an Account - Implements MxOps::ac_add()

Definition at line 762 of file pop.c.

763 {
764  if (a->adata)
765  return 0;
766 
767  struct ConnAccount cac = { { 0 } };
768  struct PopAccountData *adata = pop_adata_new();
769  a->adata = adata;
771 
772  if (pop_parse_path(mailbox_path(m), &cac))
773  {
774  mutt_error(_("%s is an invalid POP path"), mailbox_path(m));
775  return -1;
776  }
777 
778  adata->conn = mutt_conn_new(&cac);
779  if (!adata->conn)
780  {
781  pop_adata_free((void **) &adata);
782  return -1;
783  }
784 
785  return 0;
786 }
static const char * mailbox_path(const struct Mailbox *m)
Get the Mailbox&#39;s path string.
Definition: mailbox.h:203
int pop_parse_path(const char *path, struct ConnAccount *cac)
Parse a POP mailbox name.
Definition: lib.c:79
#define _(a)
Definition: message.h:28
struct Connection * conn
Definition: private.h:80
void(* adata_free)(void **ptr)
Free the private data attached to the Account.
Definition: account.h:49
struct Connection * mutt_conn_new(const struct ConnAccount *cac)
Create a new Connection.
Definition: mutt_socket.c:46
void * adata
Private data (for Mailbox backends)
Definition: account.h:43
static struct PopAccountData * pop_adata_new(void)
Create a new PopAccountData object.
Definition: pop.c:110
Login details for a remote server.
Definition: connaccount.h:51
static void pop_adata_free(void **ptr)
Free the private Account data - Implements Account::adata_free()
Definition: pop.c:96
#define mutt_error(...)
Definition: logging.h:84
POP-specific Account data -.
Definition: private.h:78
+ Here is the call graph for this function:

◆ pop_mbox_open()

static int pop_mbox_open ( struct Mailbox m)
static

Open a Mailbox - Implements MxOps::mbox_open()

Fetch only headers

Definition at line 793 of file pop.c.

794 {
795  if (!m->account)
796  return -1;
797 
798  char buf[PATH_MAX];
799  struct ConnAccount cac = { { 0 } };
800  struct Url url = { 0 };
801 
802  if (pop_parse_path(mailbox_path(m), &cac))
803  {
804  mutt_error(_("%s is an invalid POP path"), mailbox_path(m));
805  return -1;
806  }
807 
808  mutt_account_tourl(&cac, &url);
809  url.path = NULL;
810  url_tostring(&url, buf, sizeof(buf), 0);
811 
812  mutt_buffer_strcpy(&m->pathbuf, buf);
814 
815  struct PopAccountData *adata = m->account->adata;
816  if (!adata)
817  {
818  adata = pop_adata_new();
819  m->account->adata = adata;
821  }
822 
823  struct Connection *conn = adata->conn;
824  if (!conn)
825  {
826  adata->conn = mutt_conn_new(&cac);
827  conn = adata->conn;
828  if (!conn)
829  return -1;
830  }
831 
832  if (conn->fd < 0)
834 
835  if (pop_open_connection(adata) < 0)
836  return -1;
837 
838  adata->bcache = mutt_bcache_open(&cac, NULL);
839 
840  /* init (hard-coded) ACL rights */
842 #ifdef USE_HCACHE
843  /* flags are managed using header cache, so it only makes sense to
844  * enable them in that case */
845  m->rights |= MUTT_ACL_WRITE;
846 #endif
847 
848  while (true)
849  {
850  if (pop_reconnect(m) < 0)
851  return -1;
852 
853  m->size = adata->size;
854 
855  mutt_message(_("Fetching list of messages..."));
856 
857  const int rc = pop_fetch_headers(m);
858 
859  if (rc >= 0)
860  return 0;
861 
862  if (rc < -1)
863  return -1;
864  }
865 }
static const char * mailbox_path(const struct Mailbox *m)
Get the Mailbox&#39;s path string.
Definition: mailbox.h:203
off_t size
Size of the Mailbox.
Definition: mailbox.h:87
size_t size
Definition: private.h:92
int pop_parse_path(const char *path, struct ConnAccount *cac)
Parse a POP mailbox name.
Definition: lib.c:79
struct BodyCache * mutt_bcache_open(struct ConnAccount *account, const char *mailbox)
Open an Email-Body Cache.
Definition: bcache.c:143
int pop_open_connection(struct PopAccountData *adata)
Open connection and authenticate.
Definition: lib.c:318
#define mutt_message(...)
Definition: logging.h:83
A parsed URL proto://user:password@host:port/path?a=1&b=2
Definition: url.h:66
char * realpath
Used for duplicate detection, context comparison, and the sidebar.
Definition: mailbox.h:84
struct BodyCache * bcache
body cache
Definition: private.h:97
An open network connection (socket)
Definition: connection.h:34
#define _(a)
Definition: message.h:28
struct Connection * conn
Definition: private.h:80
#define MUTT_ACL_DELETE
Delete a message.
Definition: mailbox.h:66
static int pop_fetch_headers(struct Mailbox *m)
Read headers.
Definition: pop.c:372
void mutt_account_tourl(struct ConnAccount *cac, struct Url *url)
Fill URL with info from account.
Definition: mutt_account.c:79
void(* adata_free)(void **ptr)
Free the private data attached to the Account.
Definition: account.h:49
#define MUTT_ACL_WRITE
Write to a message (for flagging or linking threads)
Definition: mailbox.h:74
struct Connection * mutt_conn_new(const struct ConnAccount *cac)
Create a new Connection.
Definition: mutt_socket.c:46
void mutt_account_hook(const char *url)
Perform an account hook.
Definition: hook.c:755
int pop_reconnect(struct Mailbox *m)
reconnect and verify indexes if connection was lost
Definition: lib.c:609
#define PATH_MAX
Definition: mutt.h:44
int fd
Socket file descriptor.
Definition: connection.h:40
void * adata
Private data (for Mailbox backends)
Definition: account.h:43
static struct PopAccountData * pop_adata_new(void)
Create a new PopAccountData object.
Definition: pop.c:110
AclFlags rights
ACL bits, see AclFlags.
Definition: mailbox.h:121
Login details for a remote server.
Definition: connaccount.h:51
size_t mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:312
char * path
Path.
Definition: url.h:73
struct Account * account
Account that owns this Mailbox.
Definition: mailbox.h:131
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
Definition: string.c:446
static void pop_adata_free(void **ptr)
Free the private Account data - Implements Account::adata_free()
Definition: pop.c:96
#define mutt_error(...)
Definition: logging.h:84
int url_tostring(struct Url *url, char *dest, size_t len, int flags)
Output the URL string for a given Url object.
Definition: url.c:418
#define MUTT_ACL_SEEN
Change the &#39;seen&#39; status of a message.
Definition: mailbox.h:73
POP-specific Account data -.
Definition: private.h:78
struct Buffer pathbuf
Definition: mailbox.h:83
+ Here is the call graph for this function:

◆ pop_mbox_check()

static int pop_mbox_check ( struct Mailbox m)
static

Check for new mail - Implements MxOps::mbox_check()

Definition at line 870 of file pop.c.

871 {
872  struct PopAccountData *adata = pop_adata_get(m);
873 
874  if ((adata->check_time + C_PopCheckinterval) > mutt_date_epoch())
875  return 0;
876 
877  pop_logout(m);
878 
879  mutt_socket_close(adata->conn);
880 
881  if (pop_open_connection(adata) < 0)
882  return -1;
883 
884  m->size = adata->size;
885 
886  mutt_message(_("Checking for new messages..."));
887 
888  int old_msg_count = m->msg_count;
889  int rc = pop_fetch_headers(m);
890  pop_clear_cache(adata);
891  if (m->msg_count > old_msg_count)
893 
894  if (rc < 0)
895  return -1;
896 
897  if (rc > 0)
898  return MUTT_NEW_MAIL;
899 
900  return 0;
901 }
time_t mutt_date_epoch(void)
Return the number of seconds since the Unix epoch.
Definition: date.c:416
int msg_count
Total number of messages.
Definition: mailbox.h:91
off_t size
Size of the Mailbox.
Definition: mailbox.h:87
size_t size
Definition: private.h:92
int pop_open_connection(struct PopAccountData *adata)
Open connection and authenticate.
Definition: lib.c:318
#define mutt_message(...)
Definition: logging.h:83
#define _(a)
Definition: message.h:28
struct Connection * conn
Definition: private.h:80
Email list was changed.
Definition: mailbox.h:173
static int pop_fetch_headers(struct Mailbox *m)
Read headers.
Definition: pop.c:372
static void pop_clear_cache(struct PopAccountData *adata)
delete all cached messages
Definition: pop.c:541
short C_PopCheckinterval
Config: (pop) Interval between checks for new mail.
Definition: config.c:39
time_t check_time
Definition: private.h:93
void * adata
Private data (for Mailbox backends)
Definition: account.h:43
int mutt_socket_close(struct Connection *conn)
Close a socket.
Definition: socket.c:96
struct PopAccountData * pop_adata_get(struct Mailbox *m)
Get the Account data for this mailbox.
Definition: lib.c:659
New mail received in Mailbox.
Definition: mx.h:73
POP-specific Account data -.
Definition: private.h:78
void mailbox_changed(struct Mailbox *m, enum NotifyMailbox action)
Notify observers of a change to a Mailbox.
Definition: mailbox.c:177
void pop_logout(struct Mailbox *m)
logout from a POP server
Definition: lib.c:425
+ Here is the call graph for this function:

◆ pop_mbox_sync()

static int pop_mbox_sync ( struct Mailbox m)
static

Save changes to the Mailbox - Implements MxOps::mbox_sync()

Update POP mailbox, delete messages from server

Definition at line 908 of file pop.c.

909 {
910  int i, j, rc = 0;
911  char buf[1024];
912  struct PopAccountData *adata = pop_adata_get(m);
913  struct Progress progress;
914 #ifdef USE_HCACHE
915  struct HeaderCache *hc = NULL;
916 #endif
917 
918  adata->check_time = 0;
919 
920  int num_deleted = 0;
921  for (i = 0; i < m->msg_count; i++)
922  {
923  if (m->emails[i]->deleted)
924  num_deleted++;
925  }
926 
927  while (true)
928  {
929  if (pop_reconnect(m) < 0)
930  return -1;
931 
932  mutt_progress_init(&progress, _("Marking messages deleted..."),
933  MUTT_PROGRESS_WRITE, num_deleted);
934 
935 #ifdef USE_HCACHE
936  hc = pop_hcache_open(adata, mailbox_path(m));
937 #endif
938 
939  for (i = 0, j = 0, rc = 0; (rc == 0) && (i < m->msg_count); i++)
940  {
941  struct PopEmailData *edata = pop_edata_get(m->emails[i]);
942  if (m->emails[i]->deleted && (edata->refno != -1))
943  {
944  j++;
945  if (m->verbose)
946  mutt_progress_update(&progress, j, -1);
947  snprintf(buf, sizeof(buf), "DELE %d\r\n", edata->refno);
948  rc = pop_query(adata, buf, sizeof(buf));
949  if (rc == 0)
950  {
951  mutt_bcache_del(adata->bcache, cache_id(edata->uid));
952 #ifdef USE_HCACHE
953  mutt_hcache_delete_record(hc, edata->uid, strlen(edata->uid));
954 #endif
955  }
956  }
957 
958 #ifdef USE_HCACHE
959  if (m->emails[i]->changed)
960  {
961  mutt_hcache_store(hc, edata->uid, strlen(edata->uid), m->emails[i], 0);
962  }
963 #endif
964  }
965 
966 #ifdef USE_HCACHE
967  mutt_hcache_close(hc);
968 #endif
969 
970  if (rc == 0)
971  {
972  mutt_str_copy(buf, "QUIT\r\n", sizeof(buf));
973  rc = pop_query(adata, buf, sizeof(buf));
974  }
975 
976  if (rc == 0)
977  {
978  adata->clear_cache = true;
979  pop_clear_cache(adata);
980  adata->status = POP_DISCONNECTED;
981  return 0;
982  }
983 
984  if (rc == -2)
985  {
986  mutt_error("%s", adata->err_msg);
987  return -1;
988  }
989  }
990 }
struct Email ** emails
Array of Emails.
Definition: mailbox.h:99
static const char * mailbox_path(const struct Mailbox *m)
Get the Mailbox&#39;s path string.
Definition: mailbox.h:203
#define pop_query(adata, buf, buflen)
Definition: private.h:154
int msg_count
Total number of messages.
Definition: mailbox.h:91
char err_msg[POP_CMD_RESPONSE]
Definition: private.h:98
Progress tracks elements, according to $write_inc
Definition: progress.h:43
struct BodyCache * bcache
body cache
Definition: private.h:97
header cache structure
Definition: lib.h:85
struct PopEmailData * pop_edata_get(struct Email *e)
Get the private data for this Email.
Definition: lib.c:269
#define _(a)
Definition: message.h:28
bool changed
Email has been edited.
Definition: email.h:48
static const char * cache_id(const char *id)
Make a message-cache-compatible id.
Definition: pop.c:81
int refno
Message number on server.
Definition: private.h:108
Disconnected from server.
Definition: private.h:52
A progress bar.
Definition: progress.h:50
static void pop_clear_cache(struct PopAccountData *adata)
delete all cached messages
Definition: pop.c:541
static struct HeaderCache * pop_hcache_open(struct PopAccountData *adata, const char *path)
Open the header cache.
Definition: pop.c:349
void mutt_progress_update(struct Progress *progress, size_t pos, int percent)
Update the state of the progress bar.
Definition: progress.c:212
const char * uid
Definition: private.h:107
time_t check_time
Definition: private.h:93
int pop_reconnect(struct Mailbox *m)
reconnect and verify indexes if connection was lost
Definition: lib.c:609
void * adata
Private data (for Mailbox backends)
Definition: account.h:43
bool clear_cache
Definition: private.h:91
int mutt_hcache_delete_record(struct HeaderCache *hc, const char *key, size_t keylen)
Multiplexor for StoreOps::delete_record.
Definition: hcache.c:602
bool verbose
Display status messages?
Definition: mailbox.h:118
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:525
int mutt_bcache_del(struct BodyCache *bcache, const char *id)
Delete a file from the Body Cache.
Definition: bcache.c:263
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
unsigned int status
Definition: private.h:81
POP-specific Email data -.
Definition: private.h:105
void mutt_hcache_close(struct HeaderCache *hc)
Multiplexor for StoreOps::close.
Definition: hcache.c:417
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
bool deleted
Email is deleted.
Definition: email.h:45
void * edata
Driver-specific data.
Definition: email.h:111
#define mutt_error(...)
Definition: logging.h:84
struct PopAccountData * pop_adata_get(struct Mailbox *m)
Get the Account data for this mailbox.
Definition: lib.c:659
POP-specific Account data -.
Definition: private.h:78
+ Here is the call graph for this function:

◆ pop_mbox_close()

static int pop_mbox_close ( struct Mailbox m)
static

Close a Mailbox - Implements MxOps::mbox_close()

Definition at line 995 of file pop.c.

996 {
997  struct PopAccountData *adata = pop_adata_get(m);
998  if (!adata)
999  return 0;
1000 
1001  pop_logout(m);
1002 
1003  if (adata->status != POP_NONE)
1004  {
1005  mutt_socket_close(adata->conn);
1006  // FREE(&adata->conn);
1007  }
1008 
1009  adata->status = POP_NONE;
1010 
1011  adata->clear_cache = true;
1012  pop_clear_cache(adata);
1013 
1014  mutt_bcache_close(&adata->bcache);
1015 
1016  return 0;
1017 }
struct BodyCache * bcache
body cache
Definition: private.h:97
struct Connection * conn
Definition: private.h:80
static void pop_clear_cache(struct PopAccountData *adata)
delete all cached messages
Definition: pop.c:541
No connected to server.
Definition: private.h:50
void * adata
Private data (for Mailbox backends)
Definition: account.h:43
bool clear_cache
Definition: private.h:91
unsigned int status
Definition: private.h:81
int mutt_socket_close(struct Connection *conn)
Close a socket.
Definition: socket.c:96
struct PopAccountData * pop_adata_get(struct Mailbox *m)
Get the Account data for this mailbox.
Definition: lib.c:659
POP-specific Account data -.
Definition: private.h:78
void mutt_bcache_close(struct BodyCache **bcache)
Close an Email-Body Cache.
Definition: bcache.c:164
void pop_logout(struct Mailbox *m)
logout from a POP server
Definition: lib.c:425
+ Here is the call graph for this function:

◆ pop_msg_open()

static int pop_msg_open ( struct Mailbox m,
struct Message msg,
int  msgno 
)
static

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

Definition at line 1022 of file pop.c.

1023 {
1024  char buf[1024];
1025  struct Progress progress;
1026  struct PopAccountData *adata = pop_adata_get(m);
1027  struct Email *e = m->emails[msgno];
1028  struct PopEmailData *edata = pop_edata_get(e);
1029  bool bcache = true;
1030  int rc = -1;
1031  struct Buffer *path = NULL;
1032 
1033  /* see if we already have the message in body cache */
1034  msg->fp = mutt_bcache_get(adata->bcache, cache_id(edata->uid));
1035  if (msg->fp)
1036  return 0;
1037 
1038  /* see if we already have the message in our cache in
1039  * case $message_cachedir is unset */
1040  struct PopCache *cache = &adata->cache[e->index % POP_CACHE_LEN];
1041 
1042  if (cache->path)
1043  {
1044  if (cache->index == e->index)
1045  {
1046  /* yes, so just return a pointer to the message */
1047  msg->fp = fopen(cache->path, "r");
1048  if (msg->fp)
1049  return 0;
1050 
1051  mutt_perror(cache->path);
1052  return -1;
1053  }
1054  else
1055  {
1056  /* clear the previous entry */
1057  unlink(cache->path);
1058  FREE(&cache->path);
1059  }
1060  }
1061 
1062  path = mutt_buffer_pool_get();
1063 
1064  while (true)
1065  {
1066  if (pop_reconnect(m) < 0)
1067  goto cleanup;
1068 
1069  /* verify that massage index is correct */
1070  if (edata->refno < 0)
1071  {
1072  mutt_error(
1073  _("The message index is incorrect. Try reopening the mailbox."));
1074  goto cleanup;
1075  }
1076 
1077  mutt_progress_init(&progress, _("Fetching message..."), MUTT_PROGRESS_NET,
1078  e->body->length + e->body->offset - 1);
1079 
1080  /* see if we can put in body cache; use our cache as fallback */
1081  msg->fp = mutt_bcache_put(adata->bcache, cache_id(edata->uid));
1082  if (!msg->fp)
1083  {
1084  /* no */
1085  bcache = false;
1086  mutt_buffer_mktemp(path);
1087  msg->fp = mutt_file_fopen(mutt_b2s(path), "w+");
1088  if (!msg->fp)
1089  {
1090  mutt_perror(mutt_b2s(path));
1091  goto cleanup;
1092  }
1093  }
1094 
1095  snprintf(buf, sizeof(buf), "RETR %d\r\n", edata->refno);
1096 
1097  const int ret = pop_fetch_data(adata, buf, &progress, fetch_message, msg->fp);
1098  if (ret == 0)
1099  break;
1100 
1101  mutt_file_fclose(&msg->fp);
1102 
1103  /* if RETR failed (e.g. connection closed), be sure to remove either
1104  * the file in bcache or from POP's own cache since the next iteration
1105  * of the loop will re-attempt to put() the message */
1106  if (!bcache)
1107  unlink(mutt_b2s(path));
1108 
1109  if (ret == -2)
1110  {
1111  mutt_error("%s", adata->err_msg);
1112  goto cleanup;
1113  }
1114 
1115  if (ret == -3)
1116  {
1117  mutt_error(_("Can't write message to temporary file"));
1118  goto cleanup;
1119  }
1120  }
1121 
1122  /* Update the header information. Previously, we only downloaded a
1123  * portion of the headers, those required for the main display. */
1124  if (bcache)
1125  mutt_bcache_commit(adata->bcache, cache_id(edata->uid));
1126  else
1127  {
1128  cache->index = e->index;
1129  cache->path = mutt_buffer_strdup(path);
1130  }
1131  rewind(msg->fp);
1132 
1133  /* Detach the private data */
1134  e->edata = NULL;
1135 
1136  /* we replace envelope, key in subj_hash has to be updated as well */
1137  if (m->subj_hash && e->env->real_subj)
1139  mutt_label_hash_remove(m, e);
1140  mutt_env_free(&e->env);
1141  e->env = mutt_rfc822_read_header(msg->fp, e, false, false);
1142  if (m->subj_hash && e->env->real_subj)
1144  mutt_label_hash_add(m, e);
1145 
1146  /* Reattach the private data */
1147  e->edata = edata;
1149 
1150  e->lines = 0;
1151  fgets(buf, sizeof(buf), msg->fp);
1152  while (!feof(msg->fp))
1153  {
1154  m->emails[msgno]->lines++;
1155  fgets(buf, sizeof(buf), msg->fp);
1156  }
1157 
1158  e->body->length = ftello(msg->fp) - e->body->offset;
1159 
1160  /* This needs to be done in case this is a multipart message */
1161  if (!WithCrypto)
1162  e->security = crypt_query(e->body);
1163 
1164  mutt_clear_error();
1165  rewind(msg->fp);
1166 
1167  rc = 0;
1168 
1169 cleanup:
1170  mutt_buffer_pool_release(&path);
1171  return rc;
1172 }
struct Email ** emails
Array of Emails.
Definition: mailbox.h:99
Progress tracks bytes, according to $net_inc
Definition: progress.h:44
struct HashElem * mutt_hash_insert(struct HashTable *table, const char *strkey, void *data)
Add a new element to the Hash Table (with string keys)
Definition: hash.c:327
char * path
Definition: private.h:72
#define mutt_buffer_mktemp(buf)
Definition: muttlib.h:77
int lines
How many lines in the body of this message?
Definition: email.h:85
char err_msg[POP_CMD_RESPONSE]
Definition: private.h:98
#define WithCrypto
Definition: lib.h:123
The envelope/body of an email.
Definition: email.h:37
struct Buffer * mutt_buffer_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:101
#define mutt_perror(...)
Definition: logging.h:85
struct Body * body
List of MIME parts.
Definition: email.h:91
char * mutt_buffer_strdup(const struct Buffer *buf)
Copy a Buffer&#39;s string.
Definition: buffer.c:432
struct PopCache cache[POP_CACHE_LEN]
Definition: private.h:99
int mutt_bcache_commit(struct BodyCache *bcache, const char *id)
Move a temporary file into the Body Cache.
Definition: bcache.c:246
void mutt_buffer_pool_release(struct Buffer **pbuf)
Free a Buffer from the pool.
Definition: pool.c:112
struct BodyCache * bcache
body cache
Definition: private.h:97
String manipulation buffer.
Definition: buffer.h:33
struct PopEmailData * pop_edata_get(struct Email *e)
Get the private data for this Email.
Definition: lib.c:269
LOFF_T offset
offset where the actual data begins
Definition: body.h:44
#define _(a)
Definition: message.h:28
char * real_subj
Offset of the real subject.
Definition: envelope.h:67
void mutt_label_hash_add(struct Mailbox *m, struct Email *e)
Add a message&#39;s labels to the Hash Table.
Definition: mutt_header.c:377
static const char * cache_id(const char *id)
Make a message-cache-compatible id.
Definition: pop.c:81
void mutt_label_hash_remove(struct Mailbox *m, struct Email *e)
Remove a message&#39;s labels from the Hash Table.
Definition: mutt_header.c:390
int refno
Message number on server.
Definition: private.h:108
A progress bar.
Definition: progress.h:50
FILE * mutt_bcache_get(struct BodyCache *bcache, const char *id)
Open a file in the Body Cache.
Definition: bcache.c:179
#define POP_CACHE_LEN
Definition: private.h:40
const char * uid
Definition: private.h:107
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
Definition: file.c:153
struct Envelope * env
Envelope information.
Definition: email.h:90
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
Definition: mutt_logging.c:113
struct HashTable * subj_hash
Hash Table by subject.
Definition: mailbox.h:128
int pop_fetch_data(struct PopAccountData *adata, const char *query, struct Progress *progress, pop_fetch_t callback, void *data)
Read Headers with callback function.
Definition: lib.c:511
FILE * mutt_bcache_put(struct BodyCache *bcache, const char *id)
Create a file in the Body Cache.
Definition: bcache.c:206
#define mutt_b2s(buf)
Definition: buffer.h:41
LOFF_T length
length (in bytes) of attachment
Definition: body.h:45
int pop_reconnect(struct Mailbox *m)
reconnect and verify indexes if connection was lost
Definition: lib.c:609
void * adata
Private data (for Mailbox backends)
Definition: account.h:43
void mutt_env_free(struct Envelope **ptr)
Free an Envelope.
Definition: envelope.c:96
void(* edata_free)(void **ptr)
Free the private data attached to the Email.
Definition: email.h:117
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
SecurityFlags security
bit 0-10: flags, bit 11,12: application, bit 13: traditional pgp See: ncrypt/lib.h pgplib...
Definition: email.h:39
POP-specific Email data -.
Definition: private.h:105
static void pop_edata_free(void **ptr)
Free the private Email data - Implements Email::edata_free()
Definition: pop.c:121
void * edata
Driver-specific data.
Definition: email.h:111
#define mutt_error(...)
Definition: logging.h:84
unsigned int index
Definition: private.h:71
FILE * fp
pointer to the message data
Definition: mx.h:84
int index
The absolute (unsorted) message number.
Definition: email.h:86
#define FREE(x)
Definition: memory.h:40
void mutt_hash_delete(struct HashTable *table, const char *strkey, const void *data)
Remove an element from a Hash Table.
Definition: hash.c:419
POP-specific email cache.
Definition: private.h:69
struct PopAccountData * pop_adata_get(struct Mailbox *m)
Get the Account data for this mailbox.
Definition: lib.c:659
POP-specific Account data -.
Definition: private.h:78
FILE * mutt_file_fopen(const char *path, const char *mode)
Call fopen() safely.
Definition: file.c:588
struct Envelope * mutt_rfc822_read_header(FILE *fp, struct Email *e, bool user_hdrs, bool weed)
parses an RFC822 header
Definition: parse.c:1111
SecurityFlags crypt_query(struct Body *m)
Check out the type of encryption used.
Definition: crypt.c:685
int msgno
Number displayed to the user.
Definition: email.h:87
static int fetch_message(const char *line, void *data)
write line to file - Implements pop_fetch_t
Definition: pop.c:150
+ Here is the call graph for this function:

◆ pop_msg_close()

static int pop_msg_close ( struct Mailbox m,
struct Message msg 
)
static

Close an email - Implements MxOps::msg_close()

Return values
0Success
EOFError, see errno

Definition at line 1179 of file pop.c.

1180 {
1181  return mutt_file_fclose(&msg->fp);
1182 }
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
Definition: file.c:153
FILE * fp
pointer to the message data
Definition: mx.h:84
+ Here is the call graph for this function:

◆ pop_msg_save_hcache()

static int pop_msg_save_hcache ( struct Mailbox m,
struct Email e 
)
static

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

Definition at line 1187 of file pop.c.

1188 {
1189  int rc = 0;
1190 #ifdef USE_HCACHE
1191  struct PopAccountData *adata = pop_adata_get(m);
1192  struct PopEmailData *edata = e->edata;
1193  struct HeaderCache *hc = pop_hcache_open(adata, mailbox_path(m));
1194  rc = mutt_hcache_store(hc, edata->uid, strlen(edata->uid), e, 0);
1195  mutt_hcache_close(hc);
1196 #endif
1197 
1198  return rc;
1199 }
static const char * mailbox_path(const struct Mailbox *m)
Get the Mailbox&#39;s path string.
Definition: mailbox.h:203
header cache structure
Definition: lib.h:85
static struct HeaderCache * pop_hcache_open(struct PopAccountData *adata, const char *path)
Open the header cache.
Definition: pop.c:349
const char * uid
Definition: private.h:107
void * adata
Private data (for Mailbox backends)
Definition: account.h:43
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:525
POP-specific Email data -.
Definition: private.h:105
void mutt_hcache_close(struct HeaderCache *hc)
Multiplexor for StoreOps::close.
Definition: hcache.c:417
void * edata
Driver-specific data.
Definition: email.h:111
struct PopAccountData * pop_adata_get(struct Mailbox *m)
Get the Account data for this mailbox.
Definition: lib.c:659
POP-specific Account data -.
Definition: private.h:78
+ Here is the call graph for this function:

◆ pop_path_probe()

enum MailboxType pop_path_probe ( const char *  path,
const struct stat *  st 
)

Is this a POP Mailbox? - Implements MxOps::path_probe()

Definition at line 1204 of file pop.c.

1205 {
1206  if (mutt_istr_startswith(path, "pop://"))
1207  return MUTT_POP;
1208 
1209  if (mutt_istr_startswith(path, "pops://"))
1210  return MUTT_POP;
1211 
1212  return MUTT_UNKNOWN;
1213 }
Mailbox wasn&#39;t recognised.
Definition: mailbox.h:47
&#39;POP3&#39; Mailbox type
Definition: mailbox.h:55
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
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pop_path_canon()

static int pop_path_canon ( char *  buf,
size_t  buflen 
)
static

Canonicalise a Mailbox path - Implements MxOps::path_canon()

Definition at line 1218 of file pop.c.

1219 {
1220  return 0;
1221 }

◆ pop_path_pretty()

static int pop_path_pretty ( char *  buf,
size_t  buflen,
const char *  folder 
)
static

Abbreviate a Mailbox path - Implements MxOps::path_pretty()

Definition at line 1226 of file pop.c.

1227 {
1228  /* Succeed, but don't do anything, for now */
1229  return 0;
1230 }

◆ pop_path_parent()

static int pop_path_parent ( char *  buf,
size_t  buflen 
)
static

Find the parent of a Mailbox path - Implements MxOps::path_parent()

Definition at line 1235 of file pop.c.

1236 {
1237  /* Succeed, but don't do anything, for now */
1238  return 0;
1239 }

Variable Documentation

◆ MxPopOps

struct MxOps MxPopOps
Initial value:
= {
.type = MUTT_POP,
.name = "pop",
.is_local = false,
.ac_find = pop_ac_find,
.ac_add = pop_ac_add,
.mbox_open = pop_mbox_open,
.mbox_open_append = NULL,
.mbox_check = pop_mbox_check,
.mbox_check_stats = NULL,
.mbox_sync = pop_mbox_sync,
.mbox_close = pop_mbox_close,
.msg_open = pop_msg_open,
.msg_open_new = NULL,
.msg_commit = NULL,
.msg_close = pop_msg_close,
.msg_padding_size = NULL,
.msg_save_hcache = pop_msg_save_hcache,
.tags_edit = NULL,
.tags_commit = NULL,
.path_probe = pop_path_probe,
.path_canon = pop_path_canon,
.path_pretty = pop_path_pretty,
.path_parent = pop_path_parent,
.path_is_empty = NULL,
}
static int pop_path_pretty(char *buf, size_t buflen, const char *folder)
Abbreviate a Mailbox path - Implements MxOps::path_pretty()
Definition: pop.c:1226
static int pop_msg_open(struct Mailbox *m, struct Message *msg, int msgno)
Open an email message in a Mailbox - Implements MxOps::msg_open()
Definition: pop.c:1022
static int pop_path_parent(char *buf, size_t buflen)
Find the parent of a Mailbox path - Implements MxOps::path_parent()
Definition: pop.c:1235
static struct Account * pop_ac_find(struct Account *a, const char *path)
Find an Account that matches a Mailbox path - Implements MxOps::ac_find()
Definition: pop.c:741
static int pop_mbox_close(struct Mailbox *m)
Close a Mailbox - Implements MxOps::mbox_close()
Definition: pop.c:995
&#39;POP3&#39; Mailbox type
Definition: mailbox.h:55
static int pop_mbox_open(struct Mailbox *m)
Open a Mailbox - Implements MxOps::mbox_open()
Definition: pop.c:793
static int pop_mbox_sync(struct Mailbox *m)
Save changes to the Mailbox - Implements MxOps::mbox_sync()
Definition: pop.c:908
static int pop_path_canon(char *buf, size_t buflen)
Canonicalise a Mailbox path - Implements MxOps::path_canon()
Definition: pop.c:1218
enum MailboxType pop_path_probe(const char *path, const struct stat *st)
Is this a POP Mailbox? - Implements MxOps::path_probe()
Definition: pop.c:1204
static int pop_msg_close(struct Mailbox *m, struct Message *msg)
Close an email - Implements MxOps::msg_close()
Definition: pop.c:1179
static int pop_mbox_check(struct Mailbox *m)
Check for new mail - Implements MxOps::mbox_check()
Definition: pop.c:870
static int pop_msg_save_hcache(struct Mailbox *m, struct Email *e)
Save message to the header cache - Implements MxOps::msg_save_hcache()
Definition: pop.c:1187
static int pop_ac_add(struct Account *a, struct Mailbox *m)
Add a Mailbox to an Account - Implements MxOps::ac_add()
Definition: pop.c:762

POP Mailbox - Implements MxOps.

Definition at line 1245 of file pop.c.