sync with 0.8.11cvs14
This commit is contained in:
parent
11cc4f70d3
commit
a36de28be1
|
@ -1,3 +1,9 @@
|
||||||
|
2003-03-27
|
||||||
|
|
||||||
|
* src/nntp.[ch]
|
||||||
|
src/news.[ch]: refactored. Remove NNTPSockInfo and use NNTPSession
|
||||||
|
in nntp.c.
|
||||||
|
|
||||||
2003-03-27
|
2003-03-27
|
||||||
|
|
||||||
* src/inc.c: inc_pop3_session_do(): retrun appropriate error if
|
* src/inc.c: inc_pop3_session_do(): retrun appropriate error if
|
||||||
|
|
|
@ -1,3 +1,11 @@
|
||||||
|
2003-03-27 [paul] 0.8.11claws59
|
||||||
|
|
||||||
|
* sync with 0.8.11cvs14
|
||||||
|
see ChangeLog 2003-03-27
|
||||||
|
|
||||||
|
* src/selective_download.[ch] ** REMOVED **
|
||||||
|
really removed
|
||||||
|
|
||||||
2003-03-27 [christoph] 0.8.11claws58
|
2003-03-27 [christoph] 0.8.11claws58
|
||||||
|
|
||||||
* src/folder.c
|
* src/folder.c
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
2003-03-27
|
||||||
|
|
||||||
|
* src/nntp.[ch]
|
||||||
|
src/news.[ch]: リファクタリング。 NNTPSockInfo を削除し、 nntp.c
|
||||||
|
で NNTPSession を使用するようにした。
|
||||||
|
|
||||||
2003-03-27
|
2003-03-27
|
||||||
|
|
||||||
* src/inc.c: inc_pop3_session_do(): Session::state == SESSION_ERROR
|
* src/inc.c: inc_pop3_session_do(): Session::state == SESSION_ERROR
|
||||||
|
|
|
@ -11,7 +11,7 @@ MINOR_VERSION=8
|
||||||
MICRO_VERSION=11
|
MICRO_VERSION=11
|
||||||
INTERFACE_AGE=0
|
INTERFACE_AGE=0
|
||||||
BINARY_AGE=0
|
BINARY_AGE=0
|
||||||
EXTRA_VERSION=claws58
|
EXTRA_VERSION=claws59
|
||||||
VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
|
VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
|
||||||
|
|
||||||
dnl set $target
|
dnl set $target
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
|
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
|
||||||
* Copyright (C) 1999-2002 Hiroyuki Yamamoto
|
* Copyright (C) 1999-2003 Hiroyuki Yamamoto
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -36,26 +36,33 @@
|
||||||
|
|
||||||
static gint verbose = 1;
|
static gint verbose = 1;
|
||||||
|
|
||||||
static void nntp_gen_send (NNTPSockInfo *sock,
|
static void nntp_session_destroy(Session *session);
|
||||||
|
|
||||||
|
static gint nntp_ok (SockInfo *sock,
|
||||||
|
gchar *argbuf);
|
||||||
|
|
||||||
|
static void nntp_gen_send (SockInfo *sock,
|
||||||
const gchar *format,
|
const gchar *format,
|
||||||
...);
|
...);
|
||||||
static gint nntp_gen_recv (NNTPSockInfo *sock,
|
static gint nntp_gen_recv (SockInfo *sock,
|
||||||
gchar *buf,
|
gchar *buf,
|
||||||
gint size);
|
gint size);
|
||||||
static gint nntp_gen_command (NNTPSockInfo *sock,
|
static gint nntp_gen_command (NNTPSession *session,
|
||||||
gchar *argbuf,
|
gchar *argbuf,
|
||||||
const gchar *format,
|
const gchar *format,
|
||||||
...);
|
...);
|
||||||
|
|
||||||
#if USE_OPENSSL
|
#if USE_OPENSSL
|
||||||
NNTPSockInfo *nntp_open(const gchar *server, gushort port, gchar *buf,
|
Session *nntp_session_new(const gchar *server, gushort port, gchar *buf,
|
||||||
SSLType ssl_type)
|
const gchar *userid, const gchar *passwd,
|
||||||
|
SSLType ssl_type)
|
||||||
#else
|
#else
|
||||||
NNTPSockInfo *nntp_open(const gchar *server, gushort port, gchar *buf)
|
Session *nntp_session_new(const gchar *server, gushort port, gchar *buf,
|
||||||
|
const gchar *userid, const gchar *passwd)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
NNTPSession *session;
|
||||||
SockInfo *sock;
|
SockInfo *sock;
|
||||||
NNTPSockInfo *nntp_sock;
|
|
||||||
|
|
||||||
if ((sock = sock_connect(server, port)) == NULL) {
|
if ((sock = sock_connect(server, port)) == NULL) {
|
||||||
log_warning(_("Can't connect to NNTP server: %s:%d\n"),
|
log_warning(_("Can't connect to NNTP server: %s:%d\n"),
|
||||||
|
@ -70,75 +77,64 @@ NNTPSockInfo *nntp_open(const gchar *server, gushort port, gchar *buf)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
nntp_sock = g_new0(NNTPSockInfo, 1);
|
if (nntp_ok(sock, buf) != NN_SUCCESS) {
|
||||||
nntp_sock->sock = sock;
|
|
||||||
|
|
||||||
if (nntp_ok(nntp_sock, buf) == NN_SUCCESS)
|
|
||||||
return nntp_sock;
|
|
||||||
else {
|
|
||||||
sock_close(sock);
|
sock_close(sock);
|
||||||
g_free(nntp_sock);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
session = g_new0(NNTPSession, 1);
|
||||||
|
SESSION(session)->type = SESSION_NEWS;
|
||||||
|
SESSION(session)->server = g_strdup(server);
|
||||||
|
SESSION(session)->sock = sock;
|
||||||
|
SESSION(session)->last_access_time = time(NULL);
|
||||||
|
SESSION(session)->data = NULL;
|
||||||
|
|
||||||
|
SESSION(session)->destroy = nntp_session_destroy;
|
||||||
|
|
||||||
|
session->group = NULL;
|
||||||
|
|
||||||
|
if (userid && passwd) {
|
||||||
|
session->userid = g_strdup(userid);
|
||||||
|
session->passwd = g_strdup(passwd);
|
||||||
|
}
|
||||||
|
|
||||||
|
return SESSION(session);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if USE_OPENSSL
|
void nntp_forceauth(NNTPSession *session, gchar *buf, const gchar *userid, const gchar *passwd)
|
||||||
NNTPSockInfo *nntp_open_auth(const gchar *server, gushort port, gchar *buf,
|
|
||||||
const gchar *userid, const gchar *passwd,
|
|
||||||
SSLType ssl_type)
|
|
||||||
#else
|
|
||||||
NNTPSockInfo *nntp_open_auth(const gchar *server, gushort port, gchar *buf,
|
|
||||||
const gchar *userid, const gchar *passwd)
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
NNTPSockInfo *sock;
|
|
||||||
|
|
||||||
#if USE_OPENSSL
|
|
||||||
sock = nntp_open(server, port, buf, ssl_type);
|
|
||||||
#else
|
|
||||||
sock = nntp_open(server, port, buf);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!sock) return NULL;
|
|
||||||
|
|
||||||
sock->userid = g_strdup(userid);
|
|
||||||
sock->passwd = g_strdup(passwd);
|
|
||||||
|
|
||||||
return sock;
|
|
||||||
}
|
|
||||||
|
|
||||||
void nntp_close(NNTPSockInfo *sock)
|
|
||||||
{
|
|
||||||
if (!sock) return;
|
|
||||||
|
|
||||||
sock_close(sock->sock);
|
|
||||||
g_free(sock->userid);
|
|
||||||
g_free(sock->passwd);
|
|
||||||
g_free(sock);
|
|
||||||
}
|
|
||||||
|
|
||||||
void nntp_forceauth(NNTPSockInfo *sock, gchar *buf, const gchar *userid, const gchar *passwd)
|
|
||||||
|
|
||||||
{
|
{
|
||||||
if (!sock) return;
|
if (!session) return;
|
||||||
|
|
||||||
nntp_gen_command(sock, buf , "AUTHINFO USER %s", userid);
|
nntp_gen_command(session, buf , "AUTHINFO USER %s", userid);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
gint nntp_group(NNTPSockInfo *sock, const gchar *group,
|
|
||||||
|
static void nntp_session_destroy(Session *session)
|
||||||
|
{
|
||||||
|
NNTPSession *nntp_session = NNTP_SESSION(session);
|
||||||
|
|
||||||
|
g_return_if_fail(session != NULL);
|
||||||
|
|
||||||
|
g_free(nntp_session->group);
|
||||||
|
g_free(nntp_session->userid);
|
||||||
|
g_free(nntp_session->passwd);
|
||||||
|
}
|
||||||
|
|
||||||
|
gint nntp_group(NNTPSession *session, const gchar *group,
|
||||||
gint *num, gint *first, gint *last)
|
gint *num, gint *first, gint *last)
|
||||||
{
|
{
|
||||||
gint ok;
|
gint ok;
|
||||||
gint resp;
|
gint resp;
|
||||||
gchar buf[NNTPBUFSIZE];
|
gchar buf[NNTPBUFSIZE];
|
||||||
|
|
||||||
ok = nntp_gen_command(sock, buf, "GROUP %s", group);
|
ok = nntp_gen_command(session, buf, "GROUP %s", group);
|
||||||
|
|
||||||
if (ok != NN_SUCCESS) {
|
if (ok != NN_SUCCESS) {
|
||||||
ok = nntp_mode(sock, FALSE);
|
ok = nntp_mode(session, FALSE);
|
||||||
if (ok == NN_SUCCESS)
|
if (ok == NN_SUCCESS)
|
||||||
ok = nntp_gen_command(sock, buf, "GROUP %s", group);
|
ok = nntp_gen_command(session, buf, "GROUP %s", group);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ok != NN_SUCCESS)
|
if (ok != NN_SUCCESS)
|
||||||
|
@ -153,16 +149,16 @@ gint nntp_group(NNTPSockInfo *sock, const gchar *group,
|
||||||
return NN_SUCCESS;
|
return NN_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
gint nntp_get_article(NNTPSockInfo *sock, const gchar *cmd, gint num,
|
gint nntp_get_article(NNTPSession *session, const gchar *cmd, gint num,
|
||||||
gchar **msgid)
|
gchar **msgid)
|
||||||
{
|
{
|
||||||
gint ok;
|
gint ok;
|
||||||
gchar buf[NNTPBUFSIZE];
|
gchar buf[NNTPBUFSIZE];
|
||||||
|
|
||||||
if (num > 0)
|
if (num > 0)
|
||||||
ok = nntp_gen_command(sock, buf, "%s %d", cmd, num);
|
ok = nntp_gen_command(session, buf, "%s %d", cmd, num);
|
||||||
else
|
else
|
||||||
ok = nntp_gen_command(sock, buf, cmd);
|
ok = nntp_gen_command(session, buf, cmd);
|
||||||
|
|
||||||
if (ok != NN_SUCCESS)
|
if (ok != NN_SUCCESS)
|
||||||
return ok;
|
return ok;
|
||||||
|
@ -177,33 +173,33 @@ gint nntp_get_article(NNTPSockInfo *sock, const gchar *cmd, gint num,
|
||||||
return NN_SUCCESS;
|
return NN_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
gint nntp_article(NNTPSockInfo *sock, gint num, gchar **msgid)
|
gint nntp_article(NNTPSession *session, gint num, gchar **msgid)
|
||||||
{
|
{
|
||||||
return nntp_get_article(sock, "ARTICLE", num, msgid);
|
return nntp_get_article(session, "ARTICLE", num, msgid);
|
||||||
}
|
}
|
||||||
|
|
||||||
gint nntp_body(NNTPSockInfo *sock, gint num, gchar **msgid)
|
gint nntp_body(NNTPSession *session, gint num, gchar **msgid)
|
||||||
{
|
{
|
||||||
return nntp_get_article(sock, "BODY", num, msgid);
|
return nntp_get_article(session, "BODY", num, msgid);
|
||||||
}
|
}
|
||||||
|
|
||||||
gint nntp_head(NNTPSockInfo *sock, gint num, gchar **msgid)
|
gint nntp_head(NNTPSession *session, gint num, gchar **msgid)
|
||||||
{
|
{
|
||||||
return nntp_get_article(sock, "HEAD", num, msgid);
|
return nntp_get_article(session, "HEAD", num, msgid);
|
||||||
}
|
}
|
||||||
|
|
||||||
gint nntp_stat(NNTPSockInfo *sock, gint num, gchar **msgid)
|
gint nntp_stat(NNTPSession *session, gint num, gchar **msgid)
|
||||||
{
|
{
|
||||||
return nntp_get_article(sock, "STAT", num, msgid);
|
return nntp_get_article(session, "STAT", num, msgid);
|
||||||
}
|
}
|
||||||
|
|
||||||
gint nntp_next(NNTPSockInfo *sock, gint *num, gchar **msgid)
|
gint nntp_next(NNTPSession *session, gint *num, gchar **msgid)
|
||||||
{
|
{
|
||||||
gint ok;
|
gint ok;
|
||||||
gint resp;
|
gint resp;
|
||||||
gchar buf[NNTPBUFSIZE];
|
gchar buf[NNTPBUFSIZE];
|
||||||
|
|
||||||
ok = nntp_gen_command(sock, buf, "NEXT");
|
ok = nntp_gen_command(session, buf, "NEXT");
|
||||||
|
|
||||||
if (ok != NN_SUCCESS)
|
if (ok != NN_SUCCESS)
|
||||||
return ok;
|
return ok;
|
||||||
|
@ -223,84 +219,85 @@ gint nntp_next(NNTPSockInfo *sock, gint *num, gchar **msgid)
|
||||||
return NN_SUCCESS;
|
return NN_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
gint nntp_xover(NNTPSockInfo *sock, gint first, gint last)
|
gint nntp_xover(NNTPSession *session, gint first, gint last)
|
||||||
{
|
{
|
||||||
gint ok;
|
gint ok;
|
||||||
gchar buf[NNTPBUFSIZE];
|
gchar buf[NNTPBUFSIZE];
|
||||||
|
|
||||||
ok = nntp_gen_command(sock, buf, "XOVER %d-%d", first, last);
|
ok = nntp_gen_command(session, buf, "XOVER %d-%d", first, last);
|
||||||
if (ok != NN_SUCCESS)
|
if (ok != NN_SUCCESS)
|
||||||
return ok;
|
return ok;
|
||||||
|
|
||||||
return NN_SUCCESS;
|
return NN_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
gint nntp_xhdr(NNTPSockInfo *sock, const gchar *header, gint first, gint last)
|
gint nntp_xhdr(NNTPSession *session, const gchar *header, gint first, gint last)
|
||||||
{
|
{
|
||||||
gint ok;
|
gint ok;
|
||||||
gchar buf[NNTPBUFSIZE];
|
gchar buf[NNTPBUFSIZE];
|
||||||
|
|
||||||
ok = nntp_gen_command(sock, buf, "XHDR %s %d-%d", header, first, last);
|
ok = nntp_gen_command(session, buf, "XHDR %s %d-%d",
|
||||||
|
header, first, last);
|
||||||
if (ok != NN_SUCCESS)
|
if (ok != NN_SUCCESS)
|
||||||
return ok;
|
return ok;
|
||||||
|
|
||||||
return NN_SUCCESS;
|
return NN_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
gint nntp_list(NNTPSockInfo *sock)
|
gint nntp_list(NNTPSession *session)
|
||||||
{
|
{
|
||||||
return nntp_gen_command(sock, NULL, "LIST");
|
return nntp_gen_command(session, NULL, "LIST");
|
||||||
}
|
}
|
||||||
|
|
||||||
gint nntp_post(NNTPSockInfo *sock, FILE *fp)
|
gint nntp_post(NNTPSession *session, FILE *fp)
|
||||||
{
|
{
|
||||||
gint ok;
|
gint ok;
|
||||||
gchar buf[NNTPBUFSIZE];
|
gchar buf[NNTPBUFSIZE];
|
||||||
gchar *msg;
|
gchar *msg;
|
||||||
|
|
||||||
ok = nntp_gen_command(sock, buf, "POST");
|
ok = nntp_gen_command(session, buf, "POST");
|
||||||
if (ok != NN_SUCCESS)
|
if (ok != NN_SUCCESS)
|
||||||
return ok;
|
return ok;
|
||||||
|
|
||||||
msg = get_outgoing_rfc2822_str(fp);
|
msg = get_outgoing_rfc2822_str(fp);
|
||||||
if (sock_write_all(sock->sock, msg, strlen(msg)) < 0) {
|
if (sock_write_all(SESSION(session)->sock, msg, strlen(msg)) < 0) {
|
||||||
log_warning(_("Error occurred while posting\n"));
|
log_warning(_("Error occurred while posting\n"));
|
||||||
g_free(msg);
|
g_free(msg);
|
||||||
return NN_SOCKET;
|
return NN_SOCKET;
|
||||||
}
|
}
|
||||||
g_free(msg);
|
g_free(msg);
|
||||||
|
|
||||||
sock_write_all(sock->sock, ".\r\n", 3);
|
sock_write_all(SESSION(session)->sock, ".\r\n", 3);
|
||||||
if ((ok = nntp_ok(sock, buf)) != NN_SUCCESS)
|
if ((ok = nntp_ok(SESSION(session)->sock, buf)) != NN_SUCCESS)
|
||||||
return ok;
|
return ok;
|
||||||
|
|
||||||
return NN_SUCCESS;
|
return NN_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
gint nntp_newgroups(NNTPSockInfo *sock)
|
gint nntp_newgroups(NNTPSession *session)
|
||||||
{
|
{
|
||||||
return NN_SUCCESS;
|
return NN_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
gint nntp_newnews(NNTPSockInfo *sock)
|
gint nntp_newnews(NNTPSession *session)
|
||||||
{
|
{
|
||||||
return NN_SUCCESS;
|
return NN_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
gint nntp_mode(NNTPSockInfo *sock, gboolean stream)
|
gint nntp_mode(NNTPSession *session, gboolean stream)
|
||||||
{
|
{
|
||||||
gint ok;
|
gint ok;
|
||||||
|
|
||||||
if (sock->auth_failed)
|
if (session->auth_failed)
|
||||||
return NN_AUTHREQ;
|
return NN_AUTHREQ;
|
||||||
|
|
||||||
ok = nntp_gen_command(sock, NULL, "MODE %s",
|
ok = nntp_gen_command(session, NULL, "MODE %s",
|
||||||
stream ? "STREAM" : "READER");
|
stream ? "STREAM" : "READER");
|
||||||
|
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
gint nntp_ok(NNTPSockInfo *sock, gchar *argbuf)
|
static gint nntp_ok(SockInfo *sock, gchar *argbuf)
|
||||||
{
|
{
|
||||||
gint ok;
|
gint ok;
|
||||||
gchar buf[NNTPBUFSIZE];
|
gchar buf[NNTPBUFSIZE];
|
||||||
|
@ -327,7 +324,7 @@ gint nntp_ok(NNTPSockInfo *sock, gchar *argbuf)
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nntp_gen_send(NNTPSockInfo *sock, const gchar *format, ...)
|
static void nntp_gen_send(SockInfo *sock, const gchar *format, ...)
|
||||||
{
|
{
|
||||||
gchar buf[NNTPBUFSIZE];
|
gchar buf[NNTPBUFSIZE];
|
||||||
va_list args;
|
va_list args;
|
||||||
|
@ -344,12 +341,12 @@ static void nntp_gen_send(NNTPSockInfo *sock, const gchar *format, ...)
|
||||||
}
|
}
|
||||||
|
|
||||||
strcat(buf, "\r\n");
|
strcat(buf, "\r\n");
|
||||||
sock_write_all(sock->sock, buf, strlen(buf));
|
sock_write_all(sock, buf, strlen(buf));
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint nntp_gen_recv(NNTPSockInfo *sock, gchar *buf, gint size)
|
static gint nntp_gen_recv(SockInfo *sock, gchar *buf, gint size)
|
||||||
{
|
{
|
||||||
if (sock_gets(sock->sock, buf, size) == -1)
|
if (sock_gets(sock, buf, size) == -1)
|
||||||
return NN_SOCKET;
|
return NN_SOCKET;
|
||||||
|
|
||||||
strretchomp(buf);
|
strretchomp(buf);
|
||||||
|
@ -360,33 +357,36 @@ static gint nntp_gen_recv(NNTPSockInfo *sock, gchar *buf, gint size)
|
||||||
return NN_SUCCESS;
|
return NN_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint nntp_gen_command(NNTPSockInfo *sock, gchar *argbuf,
|
static gint nntp_gen_command(NNTPSession *session, gchar *argbuf,
|
||||||
const gchar *format, ...)
|
const gchar *format, ...)
|
||||||
{
|
{
|
||||||
gchar buf[NNTPBUFSIZE];
|
gchar buf[NNTPBUFSIZE];
|
||||||
va_list args;
|
va_list args;
|
||||||
gint ok;
|
gint ok;
|
||||||
|
SockInfo *sock;
|
||||||
|
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
g_vsnprintf(buf, sizeof(buf), format, args);
|
g_vsnprintf(buf, sizeof(buf), format, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
|
sock = SESSION(session)->sock;
|
||||||
nntp_gen_send(sock, "%s", buf);
|
nntp_gen_send(sock, "%s", buf);
|
||||||
ok = nntp_ok(sock, argbuf);
|
ok = nntp_ok(sock, argbuf);
|
||||||
if (ok == NN_AUTHREQ) {
|
if (ok == NN_AUTHREQ) {
|
||||||
if (!sock->userid || !sock->passwd) {
|
if (!session->userid || !session->passwd) {
|
||||||
sock->auth_failed = TRUE;
|
session->auth_failed = TRUE;
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
nntp_gen_send(sock, "AUTHINFO USER %s", sock->userid);
|
nntp_gen_send(sock, "AUTHINFO USER %s", session->userid);
|
||||||
ok = nntp_ok(sock, NULL);
|
ok = nntp_ok(sock, NULL);
|
||||||
if (ok == NN_AUTHCONT) {
|
if (ok == NN_AUTHCONT) {
|
||||||
nntp_gen_send(sock, "AUTHINFO PASS %s", sock->passwd);
|
nntp_gen_send(sock, "AUTHINFO PASS %s",
|
||||||
|
session->passwd);
|
||||||
ok = nntp_ok(sock, NULL);
|
ok = nntp_ok(sock, NULL);
|
||||||
}
|
}
|
||||||
if (ok != NN_SUCCESS) {
|
if (ok != NN_SUCCESS) {
|
||||||
sock->auth_failed = TRUE;
|
session->auth_failed = TRUE;
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -394,11 +394,11 @@ static gint nntp_gen_command(NNTPSockInfo *sock, gchar *argbuf,
|
||||||
ok = nntp_ok(sock, argbuf);
|
ok = nntp_ok(sock, argbuf);
|
||||||
|
|
||||||
} else if (ok == NN_AUTHCONT) {
|
} else if (ok == NN_AUTHCONT) {
|
||||||
nntp_gen_send(sock, "AUTHINFO PASS %s", sock->passwd);
|
nntp_gen_send(sock, "AUTHINFO PASS %s", session->passwd);
|
||||||
ok = nntp_ok(sock, NULL);
|
ok = nntp_ok(sock, NULL);
|
||||||
|
|
||||||
if (ok != NN_SUCCESS) {
|
if (ok != NN_SUCCESS) {
|
||||||
sock->auth_failed = TRUE;
|
session->auth_failed = TRUE;
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
82
src/news.c
82
src/news.c
|
@ -190,50 +190,19 @@ static Session *news_session_new(const gchar *server, gushort port,
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
gchar buf[NNTPBUFSIZE];
|
gchar buf[NNTPBUFSIZE];
|
||||||
NNTPSession *session;
|
Session *session;
|
||||||
NNTPSockInfo *nntp_sock;
|
|
||||||
|
|
||||||
g_return_val_if_fail(server != NULL, NULL);
|
g_return_val_if_fail(server != NULL, NULL);
|
||||||
|
|
||||||
log_message(_("creating NNTP connection to %s:%d ...\n"), server, port);
|
log_message(_("creating NNTP connection to %s:%d ...\n"), server, port);
|
||||||
|
|
||||||
#if USE_OPENSSL
|
#if USE_OPENSSL
|
||||||
if (userid && passwd)
|
session = nntp_session_new(server, port, buf, userid, passwd, ssl_type);
|
||||||
nntp_sock = nntp_open_auth(server, port, buf, userid, passwd,
|
|
||||||
ssl_type);
|
|
||||||
else
|
|
||||||
nntp_sock = nntp_open(server, port, buf, ssl_type);
|
|
||||||
#else
|
#else
|
||||||
if (userid && passwd)
|
session = nntp_session_new(server, port, buf, userid, passwd);
|
||||||
nntp_sock = nntp_open_auth(server, port, buf, userid, passwd);
|
|
||||||
else
|
|
||||||
nntp_sock = nntp_open(server, port, buf);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (nntp_sock == NULL)
|
return session;
|
||||||
return NULL;
|
|
||||||
|
|
||||||
session = g_new0(NNTPSession, 1);
|
|
||||||
session_init(SESSION(session));
|
|
||||||
SESSION(session)->type = SESSION_NEWS;
|
|
||||||
SESSION(session)->server = g_strdup(server);
|
|
||||||
SESSION(session)->sock = NULL;
|
|
||||||
SESSION(session)->data = NULL;
|
|
||||||
|
|
||||||
SESSION(session)->destroy = news_session_destroy;
|
|
||||||
|
|
||||||
session->nntp_sock = nntp_sock;
|
|
||||||
session->group = NULL;
|
|
||||||
|
|
||||||
return SESSION(session);
|
|
||||||
}
|
|
||||||
|
|
||||||
void news_session_destroy(Session *session)
|
|
||||||
{
|
|
||||||
nntp_close(NNTP_SESSION(session)->nntp_sock);
|
|
||||||
NNTP_SESSION(session)->nntp_sock = NULL;
|
|
||||||
|
|
||||||
g_free(NNTP_SESSION(session)->group);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Session *news_session_new_for_folder(Folder *folder)
|
static Session *news_session_new_for_folder(Folder *folder)
|
||||||
|
@ -268,7 +237,7 @@ static Session *news_session_new_for_folder(Folder *folder)
|
||||||
session = news_session_new(ac->nntp_server, port, userid, passwd);
|
session = news_session_new(ac->nntp_server, port, userid, passwd);
|
||||||
#endif
|
#endif
|
||||||
if ((session != NULL) && ac->use_nntp_auth && ac->use_nntp_auth_onconnect)
|
if ((session != NULL) && ac->use_nntp_auth && ac->use_nntp_auth_onconnect)
|
||||||
nntp_forceauth(NNTP_SESSION(session)->nntp_sock, buf, userid, passwd);
|
nntp_forceauth(NNTP_SESSION(session), buf, userid, passwd);
|
||||||
|
|
||||||
g_free(passwd);
|
g_free(passwd);
|
||||||
|
|
||||||
|
@ -293,7 +262,7 @@ NNTPSession *news_session_get(Folder *folder)
|
||||||
return NNTP_SESSION(rfolder->session);
|
return NNTP_SESSION(rfolder->session);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nntp_mode(NNTP_SESSION(rfolder->session)->nntp_sock, FALSE)
|
if (nntp_mode(NNTP_SESSION(rfolder->session), FALSE)
|
||||||
!= NN_SUCCESS) {
|
!= NN_SUCCESS) {
|
||||||
log_warning("NNTP connection to %s:%d has been"
|
log_warning("NNTP connection to %s:%d has been"
|
||||||
" disconnected. Reconnecting...\n",
|
" disconnected. Reconnecting...\n",
|
||||||
|
@ -464,12 +433,11 @@ GSList *news_get_group_list(Folder *folder)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nntp_list(session->nntp_sock) != NN_SUCCESS) {
|
if (nntp_list(session) != NN_SUCCESS) {
|
||||||
g_free(filename);
|
g_free(filename);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (recv_write_to_file
|
if (recv_write_to_file(SESSION(session)->sock, filename) < 0) {
|
||||||
(session->nntp_sock->sock, filename) < 0) {
|
|
||||||
log_warning("can't retrieve newsgroup list\n");
|
log_warning("can't retrieve newsgroup list\n");
|
||||||
session_destroy(SESSION(session));
|
session_destroy(SESSION(session));
|
||||||
REMOTE_FOLDER(folder)->session = NULL;
|
REMOTE_FOLDER(folder)->session = NULL;
|
||||||
|
@ -581,7 +549,7 @@ gint news_post_stream(Folder *folder, FILE *fp)
|
||||||
session = news_session_get(folder);
|
session = news_session_get(folder);
|
||||||
if (!session) return -1;
|
if (!session) return -1;
|
||||||
|
|
||||||
ok = nntp_post(session->nntp_sock, fp);
|
ok = nntp_post(session, fp);
|
||||||
if (ok != NN_SUCCESS) {
|
if (ok != NN_SUCCESS) {
|
||||||
log_warning("can't post article.\n");
|
log_warning("can't post article.\n");
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -595,14 +563,14 @@ static gint news_get_article_cmd(NNTPSession *session, const gchar *cmd,
|
||||||
{
|
{
|
||||||
gchar *msgid;
|
gchar *msgid;
|
||||||
|
|
||||||
if (nntp_get_article(session->nntp_sock, cmd, num, &msgid)
|
if (nntp_get_article(session, cmd, num, &msgid)
|
||||||
!= NN_SUCCESS)
|
!= NN_SUCCESS)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
debug_print("Message-Id = %s, num = %d\n", msgid, num);
|
debug_print("Message-Id = %s, num = %d\n", msgid, num);
|
||||||
g_free(msgid);
|
g_free(msgid);
|
||||||
|
|
||||||
if (recv_write_to_file(session->nntp_sock->sock, filename) < 0) {
|
if (recv_write_to_file(SESSION(session)->sock, filename) < 0) {
|
||||||
log_warning("can't retrieve article %d\n", num);
|
log_warning("can't retrieve article %d\n", num);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -658,7 +626,7 @@ static gint news_select_group(NNTPSession *session, const gchar *group,
|
||||||
g_free(session->group);
|
g_free(session->group);
|
||||||
session->group = NULL;
|
session->group = NULL;
|
||||||
|
|
||||||
ok = nntp_group(session->nntp_sock, group, num, first, last);
|
ok = nntp_group(session, group, num, first, last);
|
||||||
if (ok == NN_SUCCESS)
|
if (ok == NN_SUCCESS)
|
||||||
session->group = g_strdup(group);
|
session->group = g_strdup(group);
|
||||||
|
|
||||||
|
@ -846,7 +814,7 @@ gint news_get_num_list(Folder *folder, FolderItem *item, GSList **msgnum_list)
|
||||||
|
|
||||||
#define READ_TO_LISTEND(hdr) \
|
#define READ_TO_LISTEND(hdr) \
|
||||||
while (!(buf[0] == '.' && buf[1] == '\r')) { \
|
while (!(buf[0] == '.' && buf[1] == '\r')) { \
|
||||||
if (sock_gets(session->nntp_sock->sock, buf, sizeof(buf)) < 0) { \
|
if (sock_gets(SESSION(session)->sock, buf, sizeof(buf)) < 0) { \
|
||||||
log_warning(_("error occurred while getting %s.\n"), hdr); \
|
log_warning(_("error occurred while getting %s.\n"), hdr); \
|
||||||
return msginfo; \
|
return msginfo; \
|
||||||
} \
|
} \
|
||||||
|
@ -866,12 +834,12 @@ MsgInfo *news_get_msginfo(Folder *folder, FolderItem *item, gint num)
|
||||||
|
|
||||||
log_message(_("getting xover %d in %s...\n"),
|
log_message(_("getting xover %d in %s...\n"),
|
||||||
num, item->path);
|
num, item->path);
|
||||||
if (nntp_xover(session->nntp_sock, num, num) != NN_SUCCESS) {
|
if (nntp_xover(session, num, num) != NN_SUCCESS) {
|
||||||
log_warning(_("can't get xover\n"));
|
log_warning(_("can't get xover\n"));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sock_gets(session->nntp_sock->sock, buf, sizeof(buf)) < 0) {
|
if (sock_gets(SESSION(session)->sock, buf, sizeof(buf)) < 0) {
|
||||||
log_warning(_("error occurred while getting xover.\n"));
|
log_warning(_("error occurred while getting xover.\n"));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -891,12 +859,12 @@ MsgInfo *news_get_msginfo(Folder *folder, FolderItem *item, gint num)
|
||||||
msginfo->flags.tmp_flags = MSG_NEWS;
|
msginfo->flags.tmp_flags = MSG_NEWS;
|
||||||
msginfo->newsgroups = g_strdup(item->path);
|
msginfo->newsgroups = g_strdup(item->path);
|
||||||
|
|
||||||
if (nntp_xhdr(session->nntp_sock, "to", num, num) != NN_SUCCESS) {
|
if (nntp_xhdr(session, "to", num, num) != NN_SUCCESS) {
|
||||||
log_warning(_("can't get xhdr\n"));
|
log_warning(_("can't get xhdr\n"));
|
||||||
return msginfo;
|
return msginfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sock_gets(session->nntp_sock->sock, buf, sizeof(buf)) < 0) {
|
if (sock_gets(SESSION(session)->sock, buf, sizeof(buf)) < 0) {
|
||||||
log_warning(_("error occurred while getting xhdr.\n"));
|
log_warning(_("error occurred while getting xhdr.\n"));
|
||||||
return msginfo;
|
return msginfo;
|
||||||
}
|
}
|
||||||
|
@ -905,12 +873,12 @@ MsgInfo *news_get_msginfo(Folder *folder, FolderItem *item, gint num)
|
||||||
|
|
||||||
READ_TO_LISTEND("xhdr (to)");
|
READ_TO_LISTEND("xhdr (to)");
|
||||||
|
|
||||||
if (nntp_xhdr(session->nntp_sock, "cc", num, num) != NN_SUCCESS) {
|
if (nntp_xhdr(session, "cc", num, num) != NN_SUCCESS) {
|
||||||
log_warning(_("can't get xhdr\n"));
|
log_warning(_("can't get xhdr\n"));
|
||||||
return msginfo;
|
return msginfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sock_gets(session->nntp_sock->sock, buf, sizeof(buf)) < 0) {
|
if (sock_gets(SESSION(session)->sock, buf, sizeof(buf)) < 0) {
|
||||||
log_warning(_("error occurred while getting xhdr.\n"));
|
log_warning(_("error occurred while getting xhdr.\n"));
|
||||||
return msginfo;
|
return msginfo;
|
||||||
}
|
}
|
||||||
|
@ -935,13 +903,13 @@ static GSList *news_get_msginfos_for_range(NNTPSession *session, FolderItem *ite
|
||||||
|
|
||||||
log_message(_("getting xover %d - %d in %s...\n"),
|
log_message(_("getting xover %d - %d in %s...\n"),
|
||||||
begin, end, item->path);
|
begin, end, item->path);
|
||||||
if (nntp_xover(session->nntp_sock, begin, end) != NN_SUCCESS) {
|
if (nntp_xover(session, begin, end) != NN_SUCCESS) {
|
||||||
log_warning(_("can't get xover\n"));
|
log_warning(_("can't get xover\n"));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (sock_gets(session->nntp_sock->sock, buf, sizeof(buf)) < 0) {
|
if (sock_gets(SESSION(session)->sock, buf, sizeof(buf)) < 0) {
|
||||||
log_warning(_("error occurred while getting xover.\n"));
|
log_warning(_("error occurred while getting xover.\n"));
|
||||||
return newlist;
|
return newlist;
|
||||||
}
|
}
|
||||||
|
@ -972,7 +940,7 @@ static GSList *news_get_msginfos_for_range(NNTPSession *session, FolderItem *ite
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nntp_xhdr(session->nntp_sock, "to", begin, end) != NN_SUCCESS) {
|
if (nntp_xhdr(session, "to", begin, end) != NN_SUCCESS) {
|
||||||
log_warning(_("can't get xhdr\n"));
|
log_warning(_("can't get xhdr\n"));
|
||||||
return newlist;
|
return newlist;
|
||||||
}
|
}
|
||||||
|
@ -980,7 +948,7 @@ static GSList *news_get_msginfos_for_range(NNTPSession *session, FolderItem *ite
|
||||||
llast = newlist;
|
llast = newlist;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (sock_gets(session->nntp_sock->sock, buf, sizeof(buf)) < 0) {
|
if (sock_gets(SESSION(session)->sock, buf, sizeof(buf)) < 0) {
|
||||||
log_warning(_("error occurred while getting xhdr.\n"));
|
log_warning(_("error occurred while getting xhdr.\n"));
|
||||||
return newlist;
|
return newlist;
|
||||||
}
|
}
|
||||||
|
@ -1002,7 +970,7 @@ static GSList *news_get_msginfos_for_range(NNTPSession *session, FolderItem *ite
|
||||||
llast = llast->next;
|
llast = llast->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nntp_xhdr(session->nntp_sock, "cc", begin, end) != NN_SUCCESS) {
|
if (nntp_xhdr(session, "cc", begin, end) != NN_SUCCESS) {
|
||||||
log_warning(_("can't get xhdr\n"));
|
log_warning(_("can't get xhdr\n"));
|
||||||
return newlist;
|
return newlist;
|
||||||
}
|
}
|
||||||
|
@ -1010,7 +978,7 @@ static GSList *news_get_msginfos_for_range(NNTPSession *session, FolderItem *ite
|
||||||
llast = newlist;
|
llast = newlist;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (sock_gets(session->nntp_sock->sock, buf, sizeof(buf)) < 0) {
|
if (sock_gets(SESSION(session)->sock, buf, sizeof(buf)) < 0) {
|
||||||
log_warning(_("error occurred while getting xhdr.\n"));
|
log_warning(_("error occurred while getting xhdr.\n"));
|
||||||
return newlist;
|
return newlist;
|
||||||
}
|
}
|
||||||
|
|
19
src/news.h
19
src/news.h
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
|
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
|
||||||
* Copyright (C) 1999-2002 Hiroyuki Yamamoto
|
* Copyright (C) 1999-2003 Hiroyuki Yamamoto
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -24,15 +24,11 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "folder.h"
|
#include "folder.h"
|
||||||
#include "session.h"
|
|
||||||
#include "nntp.h"
|
|
||||||
|
|
||||||
typedef struct _NewsFolder NewsFolder;
|
typedef struct _NewsFolder NewsFolder;
|
||||||
typedef struct _NNTPSession NNTPSession;
|
|
||||||
typedef struct _NewsGroupInfo NewsGroupInfo;
|
typedef struct _NewsGroupInfo NewsGroupInfo;
|
||||||
|
|
||||||
#define NEWS_FOLDER(obj) ((NewsFolder *)obj)
|
#define NEWS_FOLDER(obj) ((NewsFolder *)obj)
|
||||||
#define NNTP_SESSION(obj) ((NNTPSession *)obj)
|
|
||||||
|
|
||||||
struct _NewsFolder
|
struct _NewsFolder
|
||||||
{
|
{
|
||||||
|
@ -41,16 +37,6 @@ struct _NewsFolder
|
||||||
gboolean use_auth;
|
gboolean use_auth;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _NNTPSession
|
|
||||||
{
|
|
||||||
Session session;
|
|
||||||
|
|
||||||
NNTPSockInfo *nntp_sock;
|
|
||||||
gchar *group;
|
|
||||||
gfloat fetch_base_percentage;
|
|
||||||
gfloat fetch_total_percentage;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _NewsGroupInfo
|
struct _NewsGroupInfo
|
||||||
{
|
{
|
||||||
gchar *name;
|
gchar *name;
|
||||||
|
@ -64,9 +50,6 @@ Folder *news_folder_new (const gchar *name,
|
||||||
const gchar *folder);
|
const gchar *folder);
|
||||||
void news_folder_destroy (Folder *folder);
|
void news_folder_destroy (Folder *folder);
|
||||||
|
|
||||||
void news_session_destroy (Session *session);
|
|
||||||
NNTPSession *news_session_get (Folder *folder);
|
|
||||||
|
|
||||||
GSList *news_get_article_list (Folder *folder,
|
GSList *news_get_article_list (Folder *folder,
|
||||||
FolderItem *item,
|
FolderItem *item,
|
||||||
gboolean use_cache);
|
gboolean use_cache);
|
||||||
|
|
Loading…
Reference in a new issue