pop3-client.c revision f3bb2fbe87425dc89a839908985af496f7f65702
/* Copyright (c) 2002-2009 Dovecot authors, see the included COPYING file */
#include "pop3-common.h"
#include "buffer.h"
#include "ioloop.h"
#include "network.h"
#include "istream.h"
#include "ostream.h"
#include "str.h"
#include "llist.h"
#include "hostpid.h"
#include "var-expand.h"
#include "master-service.h"
#include "mail-storage.h"
#include "mail-storage-service.h"
#include "pop3-commands.h"
#include "mail-search-build.h"
#include "mail-namespace.h"
#include <stdlib.h>
#include <unistd.h>
/* max. length of input command line (spec says 512) */
#define MAX_INBUF_SIZE 2048
/* Stop reading input when output buffer has this many bytes. Once the buffer
size has dropped to half of it, start reading input again. */
#define OUTBUF_THROTTLE_SIZE 4096
/* Disconnect client when it sends too many bad commands in a row */
#define CLIENT_MAX_BAD_COMMANDS 20
/* Disconnect client after idling this many milliseconds */
/* If client starts idling for this many milliseconds, commit the current
transaction. This allows the mailbox to become unlocked. */
struct client *pop3_clients;
unsigned int pop3_client_count;
{
/* Can't commit while commands are running */
return;
}
}
{
"Disconnected for inactivity in reading our output");
} else {
}
}
{
struct mail_search_args *search_args;
struct mailbox_transaction_context *t;
struct mail_search_context *ctx;
struct mailbox_status status;
uint32_t failed_uid = 0;
int i;
for (i = 0; i < 2; i++) {
STATUS_UIDVALIDITY, &status) < 0) {
break;
}
client->total_size = 0;
i_error("Getting size of message "
break;
}
break;
}
}
(void)mailbox_transaction_commit(&t);
break;
}
if (!failed) {
return TRUE;
}
/* well, sync and try again. we might have cached virtual
sizes, make sure they get committed. */
(void)mailbox_transaction_commit(&t);
}
if (expunged) {
"-ERR [IN-USE] Couldn't sync mailbox.");
*error_r = "Can't sync mailbox: Messages keep getting expunged";
} else {
struct mail_storage *storage;
enum mail_error error;
}
return FALSE;
}
{
switch (var_get_key(++format)) {
case 'v':
mask |= UIDL_UIDVALIDITY;
break;
case 'u':
break;
case 'm':
break;
case 'f':
mask |= UIDL_FILE_NAME;
break;
}
}
}
return mask;
}
struct mail_storage_service_user *service_user,
const struct pop3_settings *set)
{
struct mail_namespace *ns;
struct mail_storage *storage;
const char *inbox, *ident;
enum mailbox_flags flags;
const char *errmsg;
enum mail_error error;
/* always use nonblocking I/O */
if (!set->pop3_lock_session) {
}
inbox = "INBOX";
return NULL;
}
if (set->pop3_no_flag_updates)
if (set->pop3_lock_session)
&error));
return NULL;
}
return NULL;
}
if (client->uidl_keymask == 0)
i_fatal("Invalid pop3_uidl_format");
if (ident != NULL) {
}
if (hook_client_created != NULL)
return client;
}
{
static struct var_expand_table static_tab[] = {
};
struct var_expand_table *tab;
}
{
t_strdup_printf("Connection closed: %m");
}
{
if (client->seen_change_count > 0)
if (!client->disconnected) {
}
/* deinitialize command */
}
/* client didn't QUIT, but we still want to save any changes
done in this transaction. especially the cached virtual
message sizes. */
}
if (client->anvil_sent) {
"\n", NULL));
}
i_error("close(client in) failed: %m");
i_error("close(client out) failed: %m");
}
}
{
if (client->disconnected)
return;
}
{
return -1;
T_BEGIN {
} T_END;
if (ret >= 0) {
ret = 1;
} else {
ret = 0;
/* no more input until client has read
our output */
/* If someone happens to flush output,
we want to get our IO handler back in
flush callback */
TRUE);
}
}
}
return (int)ret;
}
{
struct mail_storage *storage;
enum mail_error error;
"state, please relogin.");
return;
}
}
{
int ret;
*args++ = '\0';
T_BEGIN {
} T_END;
if (ret >= 0) {
client->bad_counter = 0;
TRUE);
break;
}
}
}
return FALSE;
}
return TRUE;
}
{
/* we're still processing a command. wait until it's
finished. */
return;
}
case -1:
/* disconnected */
return;
case -2:
/* line too long, kill it */
return;
}
(void)client_handle_input(client);
}
{
int ret;
return 1;
}
}
/* enable input again */
}
}
}
void clients_destroy_all(void)
{
while (pop3_clients != NULL) {
"-ERR Server shutting down.");
}
}
}