NeoMutt  2021-02-05-89-gabe350
Teaching an old dog new tricks
DOXYGEN
private.h File Reference
#include <stdbool.h>
#include <time.h>
#include "mutt/lib.h"
#include "conn/lib.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  PopCache
 POP-specific email cache. More...
 
struct  PopAuth
 POP authentication multiplexor. More...
 

Macros

#define POP_PORT   110
 
#define POP_SSL_PORT   995
 
#define POP_CACHE_LEN   10
 
#define POP_CMD_RESPONSE   512
 
#define pop_query(adata, buf, buflen)   pop_query_d(adata, buf, buflen, NULL)
 

Typedefs

typedef int(* pop_fetch_t) (const char *str, void *data)
 Callback function to handle POP server responses. More...
 

Enumerations

enum  PopStatus { POP_NONE = 0, POP_CONNECTED, POP_DISCONNECTED }
 POP server responses. More...
 
enum  PopAuthRes { POP_A_SUCCESS = 0, POP_A_SOCKET, POP_A_FAILURE, POP_A_UNAVAIL }
 POP authentication responses. More...
 

Functions

bool pop_auth_is_valid (const char *authenticator)
 Check if string is a valid pop authentication method. More...
 
int pop_authenticate (struct PopAccountData *adata)
 Authenticate with a POP server. More...
 
void pop_apop_timestamp (struct PopAccountData *adata, char *buf)
 Get the server timestamp for APOP authentication. More...
 
int pop_parse_path (const char *path, struct ConnAccount *acct)
 Parse a POP mailbox name. More...
 
int pop_connect (struct PopAccountData *adata)
 Open connection. More...
 
int pop_open_connection (struct PopAccountData *adata)
 Open connection and authenticate. More...
 
int pop_query_d (struct PopAccountData *adata, char *buf, size_t buflen, char *msg)
 Send data from buffer and receive answer to the same buffer. More...
 
int pop_fetch_data (struct PopAccountData *adata, const char *query, struct Progress *progress, pop_fetch_t callback, void *data)
 Read Headers with callback function. More...
 
int pop_reconnect (struct Mailbox *m)
 reconnect and verify indexes if connection was lost More...
 
void pop_logout (struct Mailbox *m)
 logout from a POP server More...
 
const char * pop_get_field (enum ConnAccountField field, void *gf_data)
 Get connection login credentials - Implements ConnAccount::get_field() More...
 

Variables

bool C_PopAuthTryAll
 Config: (pop) Try all available authentication methods. More...
 
struct SlistC_PopAuthenticators
 Config: (pop) List of allowed authentication methods. More...
 
short C_PopCheckInterval
 Config: (pop) Interval between checks for new mail. More...
 
unsigned char C_PopDelete
 Config: (pop) After downloading POP messages, delete them on the server. More...
 
char * C_PopHost
 Config: (pop) Url of the POP server. More...
 
bool C_PopLast
 Config: (pop) Use the 'LAST' command to fetch new mail. More...
 
char * C_PopOauthRefreshCommand
 Config: (pop) External command to generate OAUTH refresh token. More...
 
char * C_PopPass
 Config: (pop) Password of the POP server. More...
 
unsigned char C_PopReconnect
 Config: (pop) Reconnect to the server is the connection is lost. More...
 
char * C_PopUser
 Config: (pop) Username of the POP server. More...
 

Detailed Description

POP network mailbox

Authors
  • Vsevolod Volkov
  • 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

◆ POP_PORT

#define POP_PORT   110

Definition at line 37 of file private.h.

◆ POP_SSL_PORT

#define POP_SSL_PORT   995

Definition at line 38 of file private.h.

◆ POP_CACHE_LEN

#define POP_CACHE_LEN   10

Definition at line 41 of file private.h.

◆ POP_CMD_RESPONSE

#define POP_CMD_RESPONSE   512

Definition at line 44 of file private.h.

◆ pop_query

#define pop_query (   adata,
  buf,
  buflen 
)    pop_query_d(adata, buf, buflen, NULL)

Definition at line 119 of file private.h.

Typedef Documentation

◆ pop_fetch_t

typedef int(* pop_fetch_t) (const char *str, void *data)

Callback function to handle POP server responses.

Parameters
lineString to parse
dataPrivate data passed to pop_fetch_data()
Return values
0Success
-1Failure

Definition at line 116 of file private.h.

Enumeration Type Documentation

◆ PopStatus

enum PopStatus

POP server responses.

Enumerator
POP_NONE 

No connected to server.

POP_CONNECTED 

Connected to server.

POP_DISCONNECTED 

Disconnected from server.

Definition at line 49 of file private.h.

50 {
51  POP_NONE = 0,
54 };

◆ PopAuthRes

enum PopAuthRes

POP authentication responses.

Enumerator
POP_A_SUCCESS 

Authenticated successfully.

POP_A_SOCKET 

Connection lost.

POP_A_FAILURE 

Authentication failed.

POP_A_UNAVAIL 

No valid authentication method.

Definition at line 59 of file private.h.

60 {
61  POP_A_SUCCESS = 0,
62  POP_A_SOCKET,
65 };

Function Documentation

◆ pop_auth_is_valid()

bool pop_auth_is_valid ( const char *  authenticator)

Check if string is a valid pop authentication method.

Parameters
authenticatorAuthenticator string to check
Return values
boolTrue if argument is a valid auth method

Validate whether an input string is an accepted pop authentication method as defined by pop_authenticators.

Definition at line 404 of file auth.c.

405 {
406  for (size_t i = 0; i < mutt_array_size(pop_authenticators); i++)
407  {
408  const struct PopAuth *auth = &pop_authenticators[i];
409  if (auth->method && mutt_istr_equal(auth->method, authenticator))
410  return true;
411  }
412 
413  return false;
414 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pop_authenticate()

int pop_authenticate ( struct PopAccountData adata)

Authenticate with a POP server.

Parameters
adataPOP Account data
Return values
numResult, e.g. POP_A_SUCCESS
0Successful
-1Connection lost
-2Login failed
-3Authentication cancelled

Definition at line 425 of file auth.c.

426 {
427  struct ConnAccount *cac = &adata->conn->account;
428  const struct PopAuth *authenticator = NULL;
429  int attempts = 0;
430  int ret = POP_A_UNAVAIL;
431 
432  if ((mutt_account_getuser(cac) < 0) || (cac->user[0] == '\0'))
433  {
434  return -3;
435  }
436 
438  {
439  /* Try user-specified list of authentication methods */
440  struct ListNode *np = NULL;
441  STAILQ_FOREACH(np, &C_PopAuthenticators->head, entries)
442  {
443  mutt_debug(LL_DEBUG2, "Trying method %s\n", np->data);
444  authenticator = pop_authenticators;
445 
446  while (authenticator->authenticate)
447  {
448  if (!authenticator->method || mutt_istr_equal(authenticator->method, np->data))
449  {
450  ret = authenticator->authenticate(adata, np->data);
451  if (ret == POP_A_SOCKET)
452  {
453  switch (pop_connect(adata))
454  {
455  case 0:
456  {
457  ret = authenticator->authenticate(adata, np->data);
458  break;
459  }
460  case -2:
461  ret = POP_A_FAILURE;
462  }
463  }
464 
465  if (ret != POP_A_UNAVAIL)
466  attempts++;
467  if ((ret == POP_A_SUCCESS) || (ret == POP_A_SOCKET) ||
468  ((ret == POP_A_FAILURE) && !C_PopAuthTryAll))
469  {
470  break;
471  }
472  }
473  authenticator++;
474  }
475  }
476  }
477  else
478  {
479  /* Fall back to default: any authenticator */
480  mutt_debug(LL_DEBUG2, "Using any available method\n");
481  authenticator = pop_authenticators;
482 
483  while (authenticator->authenticate)
484  {
485  ret = authenticator->authenticate(adata, NULL);
486  if (ret == POP_A_SOCKET)
487  {
488  switch (pop_connect(adata))
489  {
490  case 0:
491  {
492  ret = authenticator->authenticate(adata, NULL);
493  break;
494  }
495  case -2:
496  ret = POP_A_FAILURE;
497  }
498  }
499 
500  if (ret != POP_A_UNAVAIL)
501  attempts++;
502  if ((ret == POP_A_SUCCESS) || (ret == POP_A_SOCKET) ||
503  ((ret == POP_A_FAILURE) && !C_PopAuthTryAll))
504  {
505  break;
506  }
507 
508  authenticator++;
509  }
510  }
511 
512  switch (ret)
513  {
514  case POP_A_SUCCESS:
515  return 0;
516  case POP_A_SOCKET:
517  return -1;
518  case POP_A_UNAVAIL:
519  if (attempts == 0)
520  mutt_error(_("No authenticators available"));
521  }
522 
523  return -2;
524 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pop_apop_timestamp()

void pop_apop_timestamp ( struct PopAccountData adata,
char *  buf 
)

Get the server timestamp for APOP authentication.

Parameters
adataPOP Account data
bufTimestamp string

Definition at line 207 of file auth.c.

208 {
209  char *p1 = NULL, *p2 = NULL;
210 
211  FREE(&adata->timestamp);
212 
213  if ((p1 = strchr(buf, '<')) && (p2 = strchr(p1, '>')))
214  {
215  p2[1] = '\0';
216  adata->timestamp = mutt_str_dup(p1);
217  }
218 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pop_parse_path()

int pop_parse_path ( const char *  path,
struct ConnAccount cac 
)

Parse a POP mailbox name.

Parameters
pathPath to parse
cacAccount to store details
Return values
0success
-1error

Split a POP path into host, port, username and password

Definition at line 81 of file lib.c.

82 {
83  /* Defaults */
84  cac->flags = 0;
85  cac->type = MUTT_ACCT_TYPE_POP;
86  cac->port = 0;
87  cac->service = "pop";
88  cac->get_field = pop_get_field;
89 
90  struct Url *url = url_parse(path);
91 
92  if (!url || ((url->scheme != U_POP) && (url->scheme != U_POPS)) ||
93  !url->host || (mutt_account_fromurl(cac, url) < 0))
94  {
95  url_free(&url);
96  mutt_error(_("Invalid POP URL: %s"), path);
97  return -1;
98  }
99 
100  if (url->scheme == U_POPS)
101  cac->flags |= MUTT_ACCT_SSL;
102 
103  struct servent *service =
104  getservbyname((url->scheme == U_POP) ? "pop3" : "pop3s", "tcp");
105  if (cac->port == 0)
106  {
107  if (service)
108  cac->port = ntohs(service->s_port);
109  else
110  cac->port = (url->scheme == U_POP) ? POP_PORT : POP_SSL_PORT;
111  }
112 
113  url_free(&url);
114  return 0;
115 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pop_connect()

int pop_connect ( struct PopAccountData adata)

Open connection.

Parameters
adataPOP Account data
Return values
0Successful
-1Connection lost
-2Invalid response

Definition at line 273 of file lib.c.

274 {
275  char buf[1024];
276 
277  adata->status = POP_NONE;
278  if ((mutt_socket_open(adata->conn) < 0) ||
279  (mutt_socket_readln(buf, sizeof(buf), adata->conn) < 0))
280  {
281  mutt_error(_("Error connecting to server: %s"), adata->conn->account.host);
282  return -1;
283  }
284 
285  adata->status = POP_CONNECTED;
286 
287  if (!mutt_str_startswith(buf, "+OK"))
288  {
289  *adata->err_msg = '\0';
290  pop_error(adata, buf);
291  mutt_error("%s", adata->err_msg);
292  return -2;
293  }
294 
295  pop_apop_timestamp(adata, buf);
296 
297  return 0;
298 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pop_open_connection()

int pop_open_connection ( struct PopAccountData adata)

Open connection and authenticate.

Parameters
adataPOP Account data
Return values
0Successful
-1Connection lost
-2Invalid command or execution error
-3Authentication cancelled

Definition at line 308 of file lib.c.

309 {
310  char buf[1024];
311 
312  int rc = pop_connect(adata);
313  if (rc < 0)
314  return rc;
315 
316  rc = pop_capabilities(adata, 0);
317  if (rc == -1)
318  goto err_conn;
319  if (rc == -2)
320  return -2;
321 
322 #ifdef USE_SSL
323  /* Attempt STLS if available and desired. */
324  if ((adata->conn->ssf == 0) && (adata->cmd_stls || C_SslForceTls))
325  {
326  if (C_SslForceTls)
327  adata->use_stls = 2;
328  if (adata->use_stls == 0)
329  {
330  enum QuadOption ans =
331  query_quadoption(C_SslStarttls, _("Secure connection with TLS?"));
332  if (ans == MUTT_ABORT)
333  return -2;
334  adata->use_stls = 1;
335  if (ans == MUTT_YES)
336  adata->use_stls = 2;
337  }
338  if (adata->use_stls == 2)
339  {
340  mutt_str_copy(buf, "STLS\r\n", sizeof(buf));
341  rc = pop_query(adata, buf, sizeof(buf));
342  // Clear any data after the STLS acknowledgement
343  mutt_socket_empty(adata->conn);
344  if (rc == -1)
345  goto err_conn;
346  if (rc != 0)
347  {
348  mutt_error("%s", adata->err_msg);
349  }
350  else if (mutt_ssl_starttls(adata->conn))
351  {
352  mutt_error(_("Could not negotiate TLS connection"));
353  return -2;
354  }
355  else
356  {
357  /* recheck capabilities after STLS completes */
358  rc = pop_capabilities(adata, 1);
359  if (rc == -1)
360  goto err_conn;
361  if (rc == -2)
362  return -2;
363  }
364  }
365  }
366 
367  if (C_SslForceTls && (adata->conn->ssf == 0))
368  {
369  mutt_error(_("Encrypted connection unavailable"));
370  return -2;
371  }
372 #endif
373 
374  rc = pop_authenticate(adata);
375  if (rc == -1)
376  goto err_conn;
377  if (rc == -3)
379  if (rc != 0)
380  return rc;
381 
382  /* recheck capabilities after authentication */
383  rc = pop_capabilities(adata, 2);
384  if (rc == -1)
385  goto err_conn;
386  if (rc == -2)
387  return -2;
388 
389  /* get total size of mailbox */
390  mutt_str_copy(buf, "STAT\r\n", sizeof(buf));
391  rc = pop_query(adata, buf, sizeof(buf));
392  if (rc == -1)
393  goto err_conn;
394  if (rc == -2)
395  {
396  mutt_error("%s", adata->err_msg);
397  return rc;
398  }
399 
400  unsigned int n = 0, size = 0;
401  sscanf(buf, "+OK %u %u", &n, &size);
402  adata->size = size;
403  return 0;
404 
405 err_conn:
406  adata->status = POP_DISCONNECTED;
407  mutt_error(_("Server closed connection"));
408  return -1;
409 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pop_query_d()

int pop_query_d ( struct PopAccountData adata,
char *  buf,
size_t  buflen,
char *  msg 
)

Send data from buffer and receive answer to the same buffer.

Parameters
adataPOP Account data
bufBuffer to send/store data
buflenBuffer length
msgProgress message
Return values
0Successful
-1Connection lost
-2Invalid command or execution error

Definition at line 456 of file lib.c.

457 {
458  if (adata->status != POP_CONNECTED)
459  return -1;
460 
461  /* print msg instead of real command */
462  if (msg)
463  {
464  mutt_debug(MUTT_SOCK_LOG_CMD, "> %s", msg);
465  }
466 
468 
469  char *c = strpbrk(buf, " \r\n");
470  if (c)
471  *c = '\0';
472  snprintf(adata->err_msg, sizeof(adata->err_msg), "%s: ", buf);
473 
474  if (mutt_socket_readln_d(buf, buflen, adata->conn, MUTT_SOCK_LOG_FULL) < 0)
475  {
476  adata->status = POP_DISCONNECTED;
477  return -1;
478  }
479  if (mutt_str_startswith(buf, "+OK"))
480  return 0;
481 
482  pop_error(adata, buf);
483  return -2;
484 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pop_fetch_data()

int pop_fetch_data ( struct PopAccountData adata,
const char *  query,
struct Progress progress,
pop_fetch_t  callback,
void *  data 
)

Read Headers with callback function.

Parameters
adataPOP Account data
queryPOP query to send to server
progressProgress bar
callbackFunction called for each header read
dataData to pass to the callback
Return values
0Successful
-1Connection lost
-2Invalid command or execution error
-3Error in callback(*line, *data)

This function calls callback(*line, *data) for each received line, callback(NULL, *data) if rewind(*data) needs, exits when fail or done.

Definition at line 501 of file lib.c.

503 {
504  char buf[1024];
505  long pos = 0;
506  size_t lenbuf = 0;
507 
508  mutt_str_copy(buf, query, sizeof(buf));
509  int rc = pop_query(adata, buf, sizeof(buf));
510  if (rc < 0)
511  return rc;
512 
513  char *inbuf = mutt_mem_malloc(sizeof(buf));
514 
515  while (true)
516  {
517  const int chunk =
518  mutt_socket_readln_d(buf, sizeof(buf), adata->conn, MUTT_SOCK_LOG_FULL);
519  if (chunk < 0)
520  {
521  adata->status = POP_DISCONNECTED;
522  rc = -1;
523  break;
524  }
525 
526  char *p = buf;
527  if (!lenbuf && (buf[0] == '.'))
528  {
529  if (buf[1] != '.')
530  break;
531  p++;
532  }
533 
534  mutt_str_copy(inbuf + lenbuf, p, sizeof(buf));
535  pos += chunk;
536 
537  /* cast is safe since we break out of the loop when chunk<=0 */
538  if ((size_t) chunk >= sizeof(buf))
539  {
540  lenbuf += strlen(p);
541  }
542  else
543  {
544  if (progress)
545  mutt_progress_update(progress, pos, -1);
546  if ((rc == 0) && (callback(inbuf, data) < 0))
547  rc = -3;
548  lenbuf = 0;
549  }
550 
551  mutt_mem_realloc(&inbuf, lenbuf + sizeof(buf));
552  }
553 
554  FREE(&inbuf);
555  return rc;
556 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pop_reconnect()

int pop_reconnect ( struct Mailbox m)

reconnect and verify indexes if connection was lost

Parameters
mMailbox
Return values
0Success
-1Error

Definition at line 599 of file lib.c.

600 {
601  struct PopAccountData *adata = pop_adata_get(m);
602 
603  if (adata->status == POP_CONNECTED)
604  return 0;
605 
606  while (true)
607  {
608  mutt_socket_close(adata->conn);
609 
610  int ret = pop_open_connection(adata);
611  if (ret == 0)
612  {
613  struct Progress progress;
614  mutt_progress_init(&progress, _("Verifying message indexes..."), MUTT_PROGRESS_NET, 0);
615 
616  for (int i = 0; i < m->msg_count; i++)
617  {
618  struct PopEmailData *edata = pop_edata_get(m->emails[i]);
619  edata->refno = -1;
620  }
621 
622  ret = pop_fetch_data(adata, "UIDL\r\n", &progress, check_uidl, m);
623  if (ret == -2)
624  {
625  mutt_error("%s", adata->err_msg);
626  }
627  }
628  if (ret == 0)
629  return 0;
630 
631  pop_logout(m);
632 
633  if (ret < -1)
634  return -1;
635 
637  _("Connection lost. Reconnect to POP server?")) != MUTT_YES)
638  {
639  return -1;
640  }
641  }
642 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pop_logout()

void pop_logout ( struct Mailbox m)

logout from a POP server

Parameters
mMailbox

Definition at line 415 of file lib.c.

416 {
417  struct PopAccountData *adata = pop_adata_get(m);
418 
419  if (adata->status == POP_CONNECTED)
420  {
421  int ret = 0;
422  char buf[1024];
423  mutt_message(_("Closing connection to POP server..."));
424 
425  if (m->readonly)
426  {
427  mutt_str_copy(buf, "RSET\r\n", sizeof(buf));
428  ret = pop_query(adata, buf, sizeof(buf));
429  }
430 
431  if (ret != -1)
432  {
433  mutt_str_copy(buf, "QUIT\r\n", sizeof(buf));
434  ret = pop_query(adata, buf, sizeof(buf));
435  }
436 
437  if (ret < 0)
438  mutt_debug(LL_DEBUG1, "Error closing POP connection\n");
439 
441  }
442 
443  adata->status = POP_DISCONNECTED;
444 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pop_get_field()

const char* pop_get_field ( enum ConnAccountField  field,
void *  gf_data 
)

Get connection login credentials - Implements ConnAccount::get_field()

Definition at line 55 of file lib.c.

56 {
57  switch (field)
58  {
59  case MUTT_CA_LOGIN:
60  case MUTT_CA_USER:
61  return C_PopUser;
62  case MUTT_CA_PASS:
63  return C_PopPass;
64  case MUTT_CA_OAUTH_CMD:
66  case MUTT_CA_HOST:
67  default:
68  return NULL;
69  }
70 }
+ Here is the caller graph for this function:

Variable Documentation

◆ C_PopAuthTryAll

bool C_PopAuthTryAll

Config: (pop) Try all available authentication methods.

Definition at line 37 of file config.c.

◆ C_PopAuthenticators

struct Slist* C_PopAuthenticators

Config: (pop) List of allowed authentication methods.

Definition at line 38 of file config.c.

◆ C_PopCheckInterval

short C_PopCheckInterval

Config: (pop) Interval between checks for new mail.

Definition at line 39 of file config.c.

◆ C_PopDelete

unsigned char C_PopDelete

Config: (pop) After downloading POP messages, delete them on the server.

Definition at line 40 of file config.c.

◆ C_PopHost

char* C_PopHost

Config: (pop) Url of the POP server.

Definition at line 41 of file config.c.

◆ C_PopLast

bool C_PopLast

Config: (pop) Use the 'LAST' command to fetch new mail.

Definition at line 42 of file config.c.

◆ C_PopOauthRefreshCommand

char* C_PopOauthRefreshCommand

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

Definition at line 43 of file config.c.

◆ C_PopPass

char* C_PopPass

Config: (pop) Password of the POP server.

Definition at line 44 of file config.c.

◆ C_PopReconnect

unsigned char C_PopReconnect

Config: (pop) Reconnect to the server is the connection is lost.

Definition at line 45 of file config.c.

◆ C_PopUser

char* C_PopUser

Config: (pop) Username of the POP server.

Definition at line 46 of file config.c.

C_SslForceTls
bool C_SslForceTls
Config: (ssl) Require TLS encryption for all connections.
Definition: config.c:46
PopEmailData
POP-specific Email data -.
Definition: edata.h:31
MUTT_PROGRESS_NET
@ MUTT_PROGRESS_NET
Progress tracks bytes, according to $net_inc
Definition: progress.h:44
ConnAccount
Login details for a remote server.
Definition: connaccount.h:51
QuadOption
QuadOption
Possible values for a quad-option.
Definition: quad.h:36
PopAccountData::status
unsigned int status
Definition: adata.h:37
ConnAccount::host
char host[128]
Server to login to.
Definition: connaccount.h:53
mutt_account_fromurl
int mutt_account_fromurl(struct ConnAccount *cac, const struct Url *url)
Fill ConnAccount with information from url.
Definition: mutt_account.c:43
_
#define _(a)
Definition: message.h:28
Mailbox::emails
struct Email ** emails
Array of Emails.
Definition: mailbox.h:99
pop_authenticators
static const struct PopAuth pop_authenticators[]
Accepted authentication methods.
Definition: auth.c:384
ListNode
A List node for strings.
Definition: list.h:34
Connection::account
struct ConnAccount account
Account details: username, password, etc.
Definition: connection.h:36
ConnAccount::get_field
const char *(* get_field)(enum ConnAccountField field, void *gf_data)
Function to get some login credentials.
Definition: connaccount.h:67
C_PopAuthenticators
struct Slist * C_PopAuthenticators
Config: (pop) List of allowed authentication methods.
Definition: config.c:38
mutt_socket_empty
void mutt_socket_empty(struct Connection *conn)
Clear out any queued data.
Definition: socket.c:312
POP_CONNECTED
@ POP_CONNECTED
Connected to server.
Definition: private.h:52
PopAccountData::err_msg
char err_msg[POP_CMD_RESPONSE]
Definition: adata.h:54
C_SslStarttls
unsigned char C_SslStarttls
Config: (ssl) Use STARTTLS on servers advertising the capability.
Definition: config.c:47
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
POP_DISCONNECTED
@ POP_DISCONNECTED
Disconnected from server.
Definition: private.h:53
pop_logout
void pop_logout(struct Mailbox *m)
logout from a POP server
Definition: lib.c:415
Slist::head
struct ListHead head
Definition: slist.h:48
pop_capabilities
static int pop_capabilities(struct PopAccountData *adata, int mode)
Get capabilities from a POP server.
Definition: lib.c:194
mutt_socket_close
int mutt_socket_close(struct Connection *conn)
Close a socket.
Definition: socket.c:96
Url::scheme
enum UrlScheme scheme
Scheme, e.g. U_SMTPS.
Definition: url.h:69
MUTT_YES
@ MUTT_YES
User answered 'Yes', or assume 'Yes'.
Definition: quad.h:40
mutt_str_dup
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:370
POP_A_UNAVAIL
@ POP_A_UNAVAIL
No valid authentication method.
Definition: private.h:64
LL_DEBUG1
@ LL_DEBUG1
Log at debug level 1.
Definition: logging.h:40
FREE
#define FREE(x)
Definition: memory.h:40
C_PopAuthTryAll
bool C_PopAuthTryAll
Config: (pop) Try all available authentication methods.
Definition: config.c:37
pop_open_connection
int pop_open_connection(struct PopAccountData *adata)
Open connection and authenticate.
Definition: lib.c:308
mutt_socket_readln
#define mutt_socket_readln(buf, buflen, conn)
Definition: mutt_socket.h:36
PopAuth
POP authentication multiplexor.
Definition: private.h:79
PopAuth::method
const char * method
Name of authentication method supported, NULL means variable.
Definition: private.h:89
MUTT_ABORT
@ MUTT_ABORT
User aborted the question (with Ctrl-G)
Definition: quad.h:38
pop_edata_get
struct PopEmailData * pop_edata_get(struct Email *e)
Get the private data for this Email.
Definition: edata.c:67
url_parse
struct Url * url_parse(const char *src)
Fill in Url.
Definition: url.c:234
mutt_array_size
#define mutt_array_size(x)
Definition: memory.h:33
STAILQ_FOREACH
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:349
pop_adata_get
struct PopAccountData * pop_adata_get(struct Mailbox *m)
Get the Account data for this mailbox.
Definition: adata.c:64
pop_authenticate
int pop_authenticate(struct PopAccountData *adata)
Authenticate with a POP server.
Definition: auth.c:425
pop_error
static void pop_error(struct PopAccountData *adata, char *msg)
Copy error message to err_msg buffer.
Definition: lib.c:122
mutt_istr_equal
bool mutt_istr_equal(const char *a, const char *b)
Compare two strings, ignoring case.
Definition: string.c:883
POP_SSL_PORT
#define POP_SSL_PORT
Definition: private.h:38
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
query_quadoption
enum QuadOption query_quadoption(enum QuadOption opt, const char *prompt)
Ask the user a quad-question.
Definition: curs_lib.c:518
PopAccountData::use_stls
unsigned int use_stls
Definition: adata.h:39
POP_PORT
#define POP_PORT
Definition: private.h:37
POP_NONE
@ POP_NONE
No connected to server.
Definition: private.h:51
MUTT_CA_PASS
@ MUTT_CA_PASS
Password.
Definition: connaccount.h:36
pop_get_field
const char * pop_get_field(enum ConnAccountField field, void *gf_data)
Get connection login credentials - Implements ConnAccount::get_field()
Definition: lib.c:55
Progress
A progress bar.
Definition: progress.h:50
PopAccountData::conn
struct Connection * conn
Definition: adata.h:36
MUTT_CA_HOST
@ MUTT_CA_HOST
Server name.
Definition: connaccount.h:33
Url
A parsed URL proto://user:password@host:port/path?a=1&b=2
Definition: url.h:67
POP_A_FAILURE
@ POP_A_FAILURE
Authentication failed.
Definition: private.h:63
pop_apop_timestamp
void pop_apop_timestamp(struct PopAccountData *adata, char *buf)
Get the server timestamp for APOP authentication.
Definition: auth.c:207
url_free
void url_free(struct Url **ptr)
Free the contents of a URL.
Definition: url.c:123
Mailbox::msg_count
int msg_count
Total number of messages.
Definition: mailbox.h:91
mutt_clear_error
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
Definition: mutt_logging.c:113
MUTT_ACCT_TYPE_POP
@ MUTT_ACCT_TYPE_POP
Pop Account.
Definition: mutt_account.h:38
PopAccountData::size
size_t size
Definition: adata.h:48
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
mutt_debug
#define mutt_debug(LEVEL,...)
Definition: logging.h:81
C_PopUser
char * C_PopUser
Config: (pop) Username of the POP server.
Definition: config.c:46
ConnAccount::flags
MuttAccountFlags flags
Which fields are initialised, e.g. MUTT_ACCT_USER.
Definition: connaccount.h:59
PopAuth::authenticate
enum PopAuthRes(* authenticate)(struct PopAccountData *adata, const char *method)
Authenticate a POP connection.
Definition: private.h:87
MUTT_CA_LOGIN
@ MUTT_CA_LOGIN
Login name.
Definition: connaccount.h:34
MUTT_ACCT_SSL
#define MUTT_ACCT_SSL
Account uses SSL/TLS.
Definition: connaccount.h:46
Mailbox::readonly
bool readonly
Don't allow changes to the mailbox.
Definition: mailbox.h:119
Slist::count
size_t count
Definition: slist.h:49
mutt_socket_open
int mutt_socket_open(struct Connection *conn)
Simple wrapper.
Definition: socket.c:75
U_POP
@ U_POP
Url is pop://.
Definition: url.h:36
ConnAccount::port
unsigned short port
Port to connect to.
Definition: connaccount.h:57
PopAccountData::cmd_stls
bool cmd_stls
optional command STLS
Definition: adata.h:41
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
POP_A_SUCCESS
@ POP_A_SUCCESS
Authenticated successfully.
Definition: private.h:61
U_POPS
@ U_POPS
Url is pops://.
Definition: url.h:37
C_PopPass
char * C_PopPass
Config: (pop) Password of the POP server.
Definition: config.c:44
pop_query
#define pop_query(adata, buf, buflen)
Definition: private.h:119
Url::host
char * host
Host.
Definition: url.h:72
C_PopOauthRefreshCommand
char * C_PopOauthRefreshCommand
Config: (pop) External command to generate OAUTH refresh token.
Definition: config.c:43
Account::adata
void * adata
Private data (for Mailbox backends)
Definition: account.h:43
ListNode::data
char * data
String.
Definition: list.h:36
pop_fetch_data
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:501
MUTT_SOCK_LOG_CMD
#define MUTT_SOCK_LOG_CMD
Definition: mutt_socket.h:29
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
MUTT_SOCK_LOG_FULL
#define MUTT_SOCK_LOG_FULL
Definition: mutt_socket.h:31
ConnAccount::service
const char * service
Name of the service, e.g. "imap".
Definition: connaccount.h:60
Url::path
char * path
Path.
Definition: url.h:74
check_uidl
static int check_uidl(const char *line, void *data)
find message with this UIDL and set refno - Implements pop_fetch_t
Definition: lib.c:565
MUTT_CA_USER
@ MUTT_CA_USER
User name.
Definition: connaccount.h:35
mutt_ssl_starttls
int mutt_ssl_starttls(struct Connection *conn)
Negotiate TLS over an already opened connection.
Definition: gnutls.c:1136
mutt_account_getuser
int mutt_account_getuser(struct ConnAccount *cac)
Retrieve username into ConnAccount, if necessary.
Definition: connaccount.c:48
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
PopAccountData::timestamp
char * timestamp
Definition: adata.h:52
mutt_message
#define mutt_message(...)
Definition: logging.h:83
PopAccountData
POP-specific Account data -.
Definition: adata.h:34
POP_A_SOCKET
@ POP_A_SOCKET
Connection lost.
Definition: private.h:62
Connection::ssf
unsigned int ssf
Security strength factor, in bits (see below)
Definition: connection.h:37
pop_connect
int pop_connect(struct PopAccountData *adata)
Open connection.
Definition: lib.c:273
ConnAccount::user
char user[128]
Username.
Definition: connaccount.h:55
C_PopReconnect
unsigned char C_PopReconnect
Config: (pop) Reconnect to the server is the connection is lost.
Definition: config.c:45
LL_DEBUG2
@ LL_DEBUG2
Log at debug level 2.
Definition: logging.h:41
MUTT_CA_OAUTH_CMD
@ MUTT_CA_OAUTH_CMD
OAuth refresh command.
Definition: connaccount.h:37
mutt_socket_send_d
#define mutt_socket_send_d(conn, buf, dbg)
Definition: mutt_socket.h:38
mutt_error
#define mutt_error(...)
Definition: logging.h:84
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