*/
static int msg_cache_check(const char *id, struct BodyCache *bcache, void *data)
{
- struct Context *ctx = data;
- if (!ctx)
+ struct Mailbox *mailbox = data;
+ if (!mailbox)
return -1;
- struct PopData *pop_data = ctx->mailbox->data;
+ struct PopData *pop_data = mailbox->data;
if (!pop_data)
return -1;
return 0;
#endif
- for (int i = 0; i < ctx->mailbox->msg_count; i++)
+ for (int i = 0; i < mailbox->msg_count; i++)
{
/* if the id we get is known for a header: done (i.e. keep in cache) */
- if (ctx->mailbox->hdrs[i]->data &&
- (mutt_str_strcmp(ctx->mailbox->hdrs[i]->data, id) == 0))
+ if (mailbox->hdrs[i]->data && (mutt_str_strcmp(mailbox->hdrs[i]->data, id) == 0))
return 0;
}
* the availability of our cache
*/
if (MessageCacheClean)
- mutt_bcache_list(pop_data->bcache, msg_cache_check, (void *) ctx);
+ mutt_bcache_list(pop_data->bcache, msg_cache_check, ctx->mailbox);
mutt_clear_error();
return new_count - old_count;
while (true)
{
- if (pop_reconnect(ctx) < 0)
+ if (pop_reconnect(ctx->mailbox) < 0)
return -1;
ctx->mailbox->size = pop_data->size;
if (!pop_data)
return 0;
- pop_logout(ctx);
+ pop_logout(ctx->mailbox);
if (pop_data->status != POP_NONE)
mutt_socket_close(pop_data->conn);
while (true)
{
- if (pop_reconnect(ctx) < 0)
+ if (pop_reconnect(ctx->mailbox) < 0)
return -1;
/* verify that massage index is correct */
while (true)
{
- if (pop_reconnect(ctx) < 0)
+ if (pop_reconnect(ctx->mailbox) < 0)
return -1;
mutt_progress_init(&progress, _("Marking messages deleted..."),
if ((pop_data->check_time + PopCheckinterval) > time(NULL))
return 0;
- pop_logout(ctx);
+ pop_logout(ctx->mailbox);
mutt_socket_close(pop_data->conn);
/**
* pop_logout - logout from a POP server
- * @param ctx Context
+ * @param mailbox Mailbox
*/
-void pop_logout(struct Context *ctx)
+void pop_logout(struct Mailbox *mailbox)
{
- struct PopData *pop_data = ctx->mailbox->data;
+ struct PopData *pop_data = mailbox->data;
if (pop_data->status == POP_CONNECTED)
{
char buf[LONG_STRING];
mutt_message(_("Closing connection to POP server..."));
- if (ctx->mailbox->readonly)
+ if (mailbox->readonly)
{
mutt_str_strfcpy(buf, "RSET\r\n", sizeof(buf));
ret = pop_query(pop_data, buf, sizeof(buf));
*/
static int check_uidl(char *line, void *data)
{
- unsigned int index;
- struct Context *ctx = data;
+ if (!line || !data)
+ return -1;
+
char *endp = NULL;
errno = 0;
- index = strtoul(line, &endp, 10);
- if (errno)
+ unsigned int index = strtoul(line, &endp, 10);
+ if (errno != 0)
return -1;
while (*endp == ' ')
endp++;
memmove(line, endp, strlen(endp) + 1);
- for (int i = 0; i < ctx->mailbox->msg_count; i++)
+ struct Mailbox *mailbox = data;
+ for (int i = 0; i < mailbox->msg_count; i++)
{
- if (mutt_str_strcmp(ctx->mailbox->hdrs[i]->data, line) == 0)
+ if (mutt_str_strcmp(mailbox->hdrs[i]->data, line) == 0)
{
- ctx->mailbox->hdrs[i]->refno = index;
+ mailbox->hdrs[i]->refno = index;
break;
}
}
/**
* pop_reconnect - reconnect and verify indexes if connection was lost
- * @param ctx Context
+ * @param mailbox Mailbox
* @retval 0 Success
* @retval -1 Error
*/
-int pop_reconnect(struct Context *ctx)
+int pop_reconnect(struct Mailbox *mailbox)
{
- struct PopData *pop_data = ctx->mailbox->data;
+ struct PopData *pop_data = mailbox->data;
if (pop_data->status == POP_CONNECTED)
return 0;
mutt_progress_init(&progressbar, _("Verifying message indexes..."),
MUTT_PROGRESS_SIZE, NetInc, 0);
- for (int i = 0; i < ctx->mailbox->msg_count; i++)
- ctx->mailbox->hdrs[i]->refno = -1;
+ for (int i = 0; i < mailbox->msg_count; i++)
+ mailbox->hdrs[i]->refno = -1;
- ret = pop_fetch_data(pop_data, "UIDL\r\n", &progressbar, check_uidl, ctx);
+ ret = pop_fetch_data(pop_data, "UIDL\r\n", &progressbar, check_uidl, mailbox);
if (ret == -2)
{
mutt_error("%s", pop_data->err_msg);
if (ret == 0)
return 0;
- pop_logout(ctx);
+ pop_logout(mailbox);
if (ret < -1)
return -1;
struct Account;
struct Context;
+struct Mailbox;
struct Progress;
#define POP_PORT 110
int pop_query_d(struct PopData *pop_data, char *buf, size_t buflen, char *msg);
int pop_fetch_data(struct PopData *pop_data, const char *query, struct Progress *progressbar,
int (*func)(char *, void *), void *data);
-int pop_reconnect(struct Context *ctx);
-void pop_logout(struct Context *ctx);
+int pop_reconnect(struct Mailbox *mailbox);
+void pop_logout(struct Mailbox *mailbox);
#endif /* MUTT_POP_POP_PRIVATE_H */