Exemple #1
0
int mailsmtp_socket_starttls_with_callback(mailsmtp * session,
    void (* callback)(struct mailstream_ssl_context * ssl_context, void * data), void * data)
{
  int r;
  int fd;
  mailstream_low * low;
  mailstream_low * new_low;

  low = mailstream_get_low(session->stream);
  if (low->driver == mailstream_cfstream_driver) {
    // won't use callback
    return mailsmtp_cfsocket_starttls(session);
  }
  
  r = mailesmtp_starttls(session);
  if (r != MAILSMTP_NO_ERROR)
    return r;

  fd = mailstream_low_get_fd(low);
  if (fd == -1)
    return MAILSMTP_ERROR_STREAM;

  new_low = mailstream_low_tls_open_with_callback_timeout(fd, session->smtp_timeout, callback, data);
  if (new_low == NULL)
    return MAILSMTP_ERROR_SSL;

  mailstream_low_free(low);
  mailstream_set_low(session->stream, new_low);

  return MAILSMTP_NO_ERROR;
}
Exemple #2
0
LIBETPAN_EXPORT
int mailpop3_socket_starttls_with_callback(mailpop3 * f,
        void (* callback)(struct mailstream_ssl_context * ssl_context, void * data), void * data)
{
    int r;
    int fd;
    mailstream_low * low;
    mailstream_low * new_low;

    low = mailstream_get_low(f->pop3_stream);
    if (low->driver == mailstream_cfstream_driver) {
        // won't use callback
        return mailpop3_cfsocket_starttls(f);
    }

    r = mailpop3_stls(f);

    switch (r) {
    case MAILPOP3_NO_ERROR:
        break;
    default:
        return r;
    }

    fd = mailstream_low_get_fd(low);
    if (fd == -1)
        return MAILPOP3_ERROR_STREAM;

    new_low = mailstream_low_tls_open_with_callback_timeout(fd,
              f->pop3_timeout, callback, data);
    if (new_low == NULL)
        return MAILPOP3_ERROR_SSL;

    mailstream_low_free(low);
    mailstream_set_low(f->pop3_stream, new_low);

    return MAILPOP3_NO_ERROR;
}
Exemple #3
0
mailstream_low * mailstream_low_tls_open_with_callback(int fd,
    void (* callback)(struct mailstream_ssl_context * ssl_context, void * data), void * data)
{
  return mailstream_low_tls_open_with_callback_timeout(fd, 0, callback, data);
}