示例#1
0
文件: pop.cpp 项目: badeip/neomutt
/* Check for new messages and fetch headers */
int pop_check_mailbox(CONTEXT *ctx, int *index_hint)
{
    int ret;
    POP_DATA *pop_data = (POP_DATA *)ctx->data;

    if ((pop_data->check_time + PopCheckTimeout) > time(NULL))
        return 0;

    pop_logout(ctx);

    mutt_socket_close(pop_data->conn);

    if (pop_open_connection(pop_data) < 0)
        return -1;

    ctx->size = pop_data->size;

    mutt_message _("Checking for new messages...");

    ret = pop_fetch_headers(ctx);
    pop_clear_cache(pop_data);

    if (ret < 0)
        return -1;

    if (ret > 0)
        return M_NEW_MAIL;

    return 0;
}
示例#2
0
/* reconnect and verify idnexes if connection was lost */
int pop_reconnect (CONTEXT *ctx)
{
  int ret;
  POP_DATA *pop_data = (POP_DATA *)ctx->data;
  progress_t progressbar;

  if (pop_data->status == POP_CONNECTED)
    return 0;
  if (pop_data->status == POP_BYE)
    return -1;

  FOREVER
  {
    mutt_socket_close (pop_data->conn);

    ret = pop_open_connection (pop_data);
    if (ret == 0)
    {
      int i;

      mutt_progress_init (&progressbar, _("Verifying message indexes..."),
			  M_PROGRESS_SIZE, NetInc, 0);

      for (i = 0; i < ctx->msgcount; i++)
	ctx->hdrs[i]->refno = -1;

      ret = pop_fetch_data (pop_data, "UIDL\r\n", &progressbar, check_uidl, ctx);
      if (ret == -2)
      {
        mutt_error ("%s", pop_data->err_msg);
        mutt_sleep (2);
      }
    }
    if (ret == 0)
      return 0;

    pop_logout (ctx);

    if (ret < -1)
      return -1;

    if (query_quadoption (OPT_POPRECONNECT,
		_("Connection lost. Reconnect to POP server?")) != M_YES)
      return -1;
  }
}
示例#3
0
文件: pop.cpp 项目: badeip/neomutt
/* close POP mailbox */
int pop_close_mailbox(CONTEXT *ctx)
{
    POP_DATA *pop_data = (POP_DATA *)ctx->data;

    if (!pop_data)
        return 0;

    pop_logout(ctx);

    if (pop_data->status != POP_NONE)
        mutt_socket_close(pop_data->conn);

    pop_data->status = POP_NONE;

    pop_data->clear_cache = 1;
    pop_clear_cache(pop_data);

    if (!pop_data->conn->data)
        mutt_socket_free(pop_data->conn);

    mutt_bcache_close(&pop_data->bcache);

    return 0;
}