sync with 0.9.10cvs6
authorPaul Mangan <paul@claws-mail.org>
Thu, 18 Mar 2004 08:08:04 +0000 (08:08 +0000)
committerPaul Mangan <paul@claws-mail.org>
Thu, 18 Mar 2004 08:08:04 +0000 (08:08 +0000)
ChangeLog
ChangeLog.claws
ChangeLog.jp
configure.ac
src/common/nntp.c
src/news.c

index bebfb2365677171c94a730781f9566e757dd64fe..8b87b07e109d03d9795306304f803325e864ad96 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2004-03-16
+
+       * src/nntp.c: nntp_session_new(): attempt to authenticate at the
+         beginning of a session (thanks to Shiino Yuki and IWAMOTO, Kouichi).
+       * src/news.c
+         src/nntp.c: destroy session when socket error occurred.
+
 2004-03-12
 
        * src/mainwindow.c
 2004-03-12
 
        * src/mainwindow.c
index 50663e753302d5457bb0b19d3be6ccb4d1f7b2fb..c97a11bbc6e84aca308b0198fac259895f5c2be7 100644 (file)
@@ -1,10 +1,15 @@
-2004-02-17 [alfons]    0.9.10claws17
+2004-03-18 [paul]      0.9.10claws18
+
+       * sync with 0.9.10cvs6
+               see ChangeLog 2004-03-16
+
+2004-03-17 [alfons]    0.9.10claws17
 
        * src/gtk/filesel.c
                remove bogus semicolon after if() (sometimes it pays to
                read LKML :)
 
 
        * src/gtk/filesel.c
                remove bogus semicolon after if() (sometimes it pays to
                read LKML :)
 
-2004-02-15 [darko]     0.9.10claws16
+2004-03-15 [darko]     0.9.10claws16
 
        * src/gtk/filesel.c
                support full path in place of a filename
 
        * src/gtk/filesel.c
                support full path in place of a filename
        * src/prefs_common.[hc]
                store directory attachments were last saved to
 
        * src/prefs_common.[hc]
                store directory attachments were last saved to
 
-2004-02-15 [paul]      0.9.10claws15
+2004-03-15 [paul]      0.9.10claws15
 
        * src/folderview.c
                fix bug where unsubscribing a newsgroup would destroy
                (most of the) filtering rules
 
 
        * src/folderview.c
                fix bug where unsubscribing a newsgroup would destroy
                (most of the) filtering rules
 
-2004-02-15 [paul]      0.9.10claws14
+2004-03-15 [paul]      0.9.10claws14
 
        * src/folderview.c
                fix Bug 458, 'Folder View remaining empty after 
 
        * src/folderview.c
                fix Bug 458, 'Folder View remaining empty after 
index 0b51f4ea556ec91c8b77537073b98711bfdd0835..2e873ab77d41afa9116f32279ccae6eee08e46a4 100644 (file)
@@ -1,3 +1,11 @@
+2004-03-16
+
+       * src/nntp.c: nntp_session_new(): ¥»¥Ã¥·¥ç¥ó¤Î³«»Ï»þ¤Ëǧ¾Ú¤ò»î¤ß¤ë
+         ¤è¤¦¤Ë¤·¤¿(Shiino Yuki ¤µ¤ó¡¢ IWAMOTO, Kouichi ¤µ¤ó thanks)¡£
+       * src/news.c
+         src/nntp.c: ¥½¥±¥Ã¥È¥¨¥é¡¼¤¬È¯À¸¤·¤¿¤È¤­¤Ï¥»¥Ã¥·¥ç¥ó¤òÇË´þ¤¹¤ë
+         ¤è¤¦¤Ë¤·¤¿¡£
+
 2004-03-12
 
        * src/mainwindow.c
 2004-03-12
 
        * src/mainwindow.c
index db782055be9ab09979d4700b29bd6cf7c5070979..b053b3e7582564b7a6a73e52c59140442b575e66 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=10
 INTERFACE_AGE=0
 BINARY_AGE=0
 MICRO_VERSION=10
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=17
+EXTRA_VERSION=18
 if test $EXTRA_VERSION -eq 0; then
     VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}claws
 else
 if test $EXTRA_VERSION -eq 0; then
     VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}claws
 else
index bd0023c46b18e51f2108a627e88bab87f2bf91c0..6bcc83ecaea3b7f3f4ecc1b3d583643991b76ab1 100644 (file)
@@ -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-2003 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2004 Hiroyuki Yamamoto
  *
  * 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
  *
  * 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
@@ -41,7 +41,7 @@ static void nntp_session_destroy(Session      *session);
 static gint nntp_ok            (SockInfo       *sock,
                                 gchar          *argbuf);
 
 static gint nntp_ok            (SockInfo       *sock,
                                 gchar          *argbuf);
 
-static void nntp_gen_send      (SockInfo       *sock,
+static gint nntp_gen_send      (SockInfo       *sock,
                                 const gchar    *format,
                                 ...);
 static gint nntp_gen_recv      (SockInfo       *sock,
                                 const gchar    *format,
                                 ...);
 static gint nntp_gen_recv      (SockInfo       *sock,
@@ -97,8 +97,32 @@ Session *nntp_session_new(const gchar *server, gushort port, gchar *buf,
        session->group = NULL;
 
        if (userid && passwd) {
        session->group = NULL;
 
        if (userid && passwd) {
+               gint ok;
+
                session->userid = g_strdup(userid);
                session->passwd = g_strdup(passwd);
                session->userid = g_strdup(userid);
                session->passwd = g_strdup(passwd);
+
+               ok = nntp_gen_send(sock, "AUTHINFO USER %s", session->userid);
+               if (ok != NN_SUCCESS) {
+                       session_destroy(SESSION(session));
+                       return NULL;
+               }
+               ok = nntp_ok(sock, NULL);
+               if (ok == NN_AUTHCONT) {
+                       ok = nntp_gen_send(sock, "AUTHINFO PASS %s",
+                                          session->passwd);
+                       if (ok != NN_SUCCESS) {
+                               session_destroy(SESSION(session));
+                               return NULL;
+                       }
+                       ok = nntp_ok(sock, NULL);
+                       if (ok != NN_SUCCESS)
+                               session->auth_failed = TRUE;
+               }
+               if (ok == NN_SOCKET) {
+                       session_destroy(SESSION(session));
+                       return NULL;
+               }
        }
 
        return SESSION(session);
        }
 
        return SESSION(session);
@@ -134,7 +158,7 @@ gint nntp_group(NNTPSession *session, const gchar *group,
 
        ok = nntp_gen_command(session, buf, "GROUP %s", group);
 
 
        ok = nntp_gen_command(session, buf, "GROUP %s", group);
 
-       if (ok != NN_SUCCESS) {
+       if (ok != NN_SUCCESS && ok != NN_SOCKET && ok != NN_AUTHREQ) {
                ok = nntp_mode(session, FALSE);
                if (ok == NN_SUCCESS)
                        ok = nntp_gen_command(session, buf, "GROUP %s", group);
                ok = nntp_mode(session, FALSE);
                if (ok == NN_SUCCESS)
                        ok = nntp_gen_command(session, buf, "GROUP %s", group);
@@ -291,9 +315,6 @@ gint nntp_mode(NNTPSession *session, gboolean stream)
 {
        gint ok;
 
 {
        gint ok;
 
-       if (session->auth_failed)
-               return NN_AUTHREQ;
-
        ok = nntp_gen_command(session, NULL, "MODE %s",
                              stream ? "STREAM" : "READER");
 
        ok = nntp_gen_command(session, NULL, "MODE %s",
                              stream ? "STREAM" : "READER");
 
@@ -327,7 +348,7 @@ static gint nntp_ok(SockInfo *sock, gchar *argbuf)
        return ok;
 }
 
        return ok;
 }
 
-static void nntp_gen_send(SockInfo *sock, const gchar *format, ...)
+static gint nntp_gen_send(SockInfo *sock, const gchar *format, ...)
 {
        gchar buf[NNTPBUFSIZE];
        va_list args;
 {
        gchar buf[NNTPBUFSIZE];
        va_list args;
@@ -344,7 +365,12 @@ static void nntp_gen_send(SockInfo *sock, const gchar *format, ...)
        }
 
        strcat(buf, "\r\n");
        }
 
        strcat(buf, "\r\n");
-       sock_write_all(sock, buf, strlen(buf));
+       if (sock_write_all(sock, buf, strlen(buf)) < 0) {
+               log_warning(_("Error occurred while sending command\n"));
+               return NN_SOCKET;
+       }
+
+       return NN_SUCCESS;
 }
 
 static gint nntp_gen_recv(SockInfo *sock, gchar *buf, gint size)
 }
 
 static gint nntp_gen_recv(SockInfo *sock, gchar *buf, gint size)
@@ -373,7 +399,9 @@ static gint nntp_gen_command(NNTPSession *session, gchar *argbuf,
        va_end(args);
 
        sock = SESSION(session)->sock;
        va_end(args);
 
        sock = SESSION(session)->sock;
-       nntp_gen_send(sock, "%s", buf);
+       ok = nntp_gen_send(sock, "%s", buf);
+       if (ok != NN_SUCCESS)
+               return ok;
        ok = nntp_ok(sock, argbuf);
        if (ok == NN_AUTHREQ) {
                if (!session->userid || !session->passwd) {
        ok = nntp_ok(sock, argbuf);
        if (ok == NN_AUTHREQ) {
                if (!session->userid || !session->passwd) {
@@ -381,11 +409,15 @@ static gint nntp_gen_command(NNTPSession *session, gchar *argbuf,
                        return ok;
                }
 
                        return ok;
                }
 
-               nntp_gen_send(sock, "AUTHINFO USER %s", session->userid);
+               ok = nntp_gen_send(sock, "AUTHINFO USER %s", session->userid);
+               if (ok != NN_SUCCESS)
+                       return ok;
                ok = nntp_ok(sock, NULL);
                if (ok == NN_AUTHCONT) {
                ok = nntp_ok(sock, NULL);
                if (ok == NN_AUTHCONT) {
-                       nntp_gen_send(sock, "AUTHINFO PASS %s",
-                                     session->passwd);
+                       ok = nntp_gen_send(sock, "AUTHINFO PASS %s",
+                                          session->passwd);
+                       if (ok != NN_SUCCESS)
+                               return ok;
                        ok = nntp_ok(sock, NULL);
                }
                if (ok != NN_SUCCESS) {
                        ok = nntp_ok(sock, NULL);
                }
                if (ok != NN_SUCCESS) {
@@ -393,18 +425,20 @@ static gint nntp_gen_command(NNTPSession *session, gchar *argbuf,
                        return ok;
                }
 
                        return ok;
                }
 
-               nntp_gen_send(sock, "%s", buf);
+               ok = nntp_gen_send(sock, "%s", buf);
+               if (ok != NN_SUCCESS)
+                       return ok;
                ok = nntp_ok(sock, argbuf);
 
        } else if (ok == NN_AUTHCONT) {
                ok = nntp_ok(sock, argbuf);
 
        } else if (ok == NN_AUTHCONT) {
-                nntp_gen_send(sock, "AUTHINFO PASS %s", session->passwd);
-                ok = nntp_ok(sock, NULL);
-
-                if (ok != NN_SUCCESS) {
+                ok = nntp_gen_send(sock, "AUTHINFO PASS %s",
+                                  session->passwd);
+               if (ok != NN_SUCCESS)  {
                        session->auth_failed = TRUE;
                        session->auth_failed = TRUE;
-                        return ok;
-                }
-        }
+                       return ok;
+               }
+                ok = nntp_ok(sock, NULL);
+       }
 
        return ok;
 }
 
        return ok;
 }
index 7a4eceba2afc8183a6287099db70bc9c2071ab19..88f835803cf70e2a8be8ac08f775d9c2677554a2 100644 (file)
@@ -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-2003 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2004 Hiroyuki Yamamoto
  *
  * 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
  *
  * 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
@@ -315,7 +315,10 @@ static gchar *news_fetch_msg(Folder *folder, FolderItem *item, gint num)
 
        ok = news_select_group(session, item->path, NULL, NULL, NULL);
        if (ok != NN_SUCCESS) {
 
        ok = news_select_group(session, item->path, NULL, NULL, NULL);
        if (ok != NN_SUCCESS) {
-               g_warning("can't select group %s\n", item->path);
+               if (ok == NN_SOCKET) {
+                       session_destroy(SESSION(session));
+                       REMOTE_FOLDER(folder)->session = NULL;
+               }
                g_free(filename);
                return NULL;
        }
                g_free(filename);
                return NULL;
        }
@@ -323,10 +326,12 @@ static gchar *news_fetch_msg(Folder *folder, FolderItem *item, gint num)
        debug_print("getting article %d...\n", num);
        ok = news_get_article(NNTP_SESSION(REMOTE_FOLDER(folder)->session),
                              num, filename);
        debug_print("getting article %d...\n", num);
        ok = news_get_article(NNTP_SESSION(REMOTE_FOLDER(folder)->session),
                              num, filename);
-       if (ok < 0) {
+       if (ok != NN_SUCCESS) {
                g_warning("can't read article %d\n", num);
                g_warning("can't read article %d\n", num);
-               session_destroy(SESSION(session));
-               REMOTE_FOLDER(folder)->session = NULL;
+               if (ok == NN_SOCKET) {
+                       session_destroy(SESSION(session));
+                       REMOTE_FOLDER(folder)->session = NULL;
+               }
                g_free(filename);
                return NULL;
        }
                g_free(filename);
                return NULL;
        }
@@ -379,6 +384,7 @@ GSList *news_get_group_list(Folder *folder)
 
        if ((fp = fopen(filename, "rb")) == NULL) {
                NNTPSession *session;
 
        if ((fp = fopen(filename, "rb")) == NULL) {
                NNTPSession *session;
+               gint ok;
 
                session = news_session_get(folder);
                if (!session) {
 
                session = news_session_get(folder);
                if (!session) {
@@ -386,7 +392,12 @@ GSList *news_get_group_list(Folder *folder)
                        return NULL;
                }
 
                        return NULL;
                }
 
-               if (nntp_list(session) != NN_SUCCESS) {
+               ok = nntp_list(session);
+               if (ok != NN_SUCCESS) {
+                       if (ok == NN_SOCKET) {
+                               session_destroy(SESSION(session));
+                               REMOTE_FOLDER(folder)->session = NULL;
+                       }
                        g_free(filename);
                        return NULL;
                }
                        g_free(filename);
                        return NULL;
                }
@@ -505,6 +516,10 @@ gint news_post_stream(Folder *folder, FILE *fp)
        ok = nntp_post(session, fp);
        if (ok != NN_SUCCESS) {
                log_warning("can't post article.\n");
        ok = nntp_post(session, fp);
        if (ok != NN_SUCCESS) {
                log_warning("can't post article.\n");
+               if (ok == NN_SOCKET) {
+                       session_destroy(SESSION(session));
+                       REMOTE_FOLDER(folder)->session = NULL;
+               }
                return -1;
        }
 
                return -1;
        }
 
@@ -515,20 +530,25 @@ static gint news_get_article_cmd(NNTPSession *session, const gchar *cmd,
                                 gint num, gchar *filename)
 {
        gchar *msgid;
                                 gint num, gchar *filename)
 {
        gchar *msgid;
+       gint ok;
 
 
-       if (nntp_get_article(session, cmd, num, &msgid)
-           != NN_SUCCESS)
-               return -1;
+       ok = nntp_get_article(session, cmd, num, &msgid);
+       if (ok != NN_SUCCESS)
+               return ok;
 
        debug_print("Message-Id = %s, num = %d\n", msgid, num);
        g_free(msgid);
 
 
        debug_print("Message-Id = %s, num = %d\n", msgid, num);
        g_free(msgid);
 
-       if (recv_write_to_file(SESSION(session)->sock, filename) < 0) {
-               log_warning("can't retrieve article %d\n", num);
-               return -1;
+       ok = recv_write_to_file(SESSION(session)->sock, filename);
+       if (ok < 0) {
+               log_warning(_("can't retrieve article %d\n"), num);
+               if (ok == -2)
+                       return NN_SOCKET;
+               else
+                       return NN_IOERR;
        }
 
        }
 
-       return 0;
+       return NN_SUCCESS;
 }
 
 static gint news_get_article(NNTPSession *session, gint num, gchar *filename)
 }
 
 static gint news_get_article(NNTPSession *session, gint num, gchar *filename)
@@ -569,6 +589,8 @@ static gint news_select_group(NNTPSession *session, const gchar *group,
        ok = nntp_group(session, group, num, first, last);
        if (ok == NN_SUCCESS)
                session->group = g_strdup(group);
        ok = nntp_group(session, group, num, first, last);
        if (ok == NN_SUCCESS)
                session->group = g_strdup(group);
+       else
+               log_warning(_("can't select group: %s\n"), group);
 
        return ok;
 }
 
        return ok;
 }
@@ -819,6 +841,7 @@ MsgInfo *news_get_msginfo(Folder *folder, FolderItem *item, gint num)
        NNTPSession *session;
        MsgInfo *msginfo = NULL;
        gchar buf[NNTPBUFSIZE];
        NNTPSession *session;
        MsgInfo *msginfo = NULL;
        gchar buf[NNTPBUFSIZE];
+       gint ok;
 
        session = news_session_get(folder);
        g_return_val_if_fail(session != NULL, NULL);
 
        session = news_session_get(folder);
        g_return_val_if_fail(session != NULL, NULL);
@@ -828,8 +851,13 @@ MsgInfo *news_get_msginfo(Folder *folder, FolderItem *item, gint num)
 
        log_message(_("getting xover %d in %s...\n"),
                    num, item->path);
 
        log_message(_("getting xover %d in %s...\n"),
                    num, item->path);
-       if (nntp_xover(session, num, num) != NN_SUCCESS) {
+       ok = nntp_xover(session, num, num);
+       if (ok != NN_SUCCESS) {
                log_warning(_("can't get xover\n"));
                log_warning(_("can't get xover\n"));
+               if (ok == NN_SOCKET) {
+                       session_destroy(SESSION(session));
+                       REMOTE_FOLDER(item->folder)->session = NULL;
+               }
                return NULL;
        }
        
                return NULL;
        }
        
@@ -853,8 +881,13 @@ MsgInfo *news_get_msginfo(Folder *folder, FolderItem *item, gint num)
        msginfo->flags.tmp_flags = MSG_NEWS;
        msginfo->newsgroups = g_strdup(item->path);
 
        msginfo->flags.tmp_flags = MSG_NEWS;
        msginfo->newsgroups = g_strdup(item->path);
 
-       if (nntp_xhdr(session, "to", num, num) != NN_SUCCESS) {
+       ok = nntp_xhdr(session, "to", num, num);
+       if (ok != NN_SUCCESS) {
                log_warning(_("can't get xhdr\n"));
                log_warning(_("can't get xhdr\n"));
+               if (ok == NN_SOCKET) {
+                       session_destroy(SESSION(session));
+                       REMOTE_FOLDER(item->folder)->session = NULL;
+               }
                return msginfo;
        }
 
                return msginfo;
        }
 
@@ -867,8 +900,13 @@ MsgInfo *news_get_msginfo(Folder *folder, FolderItem *item, gint num)
 
        READ_TO_LISTEND("xhdr (to)");
 
 
        READ_TO_LISTEND("xhdr (to)");
 
-       if (nntp_xhdr(session, "cc", num, num) != NN_SUCCESS) {
+       ok = nntp_xhdr(session, "cc", num, num);
+       if (ok != NN_SUCCESS) {
                log_warning(_("can't get xhdr\n"));
                log_warning(_("can't get xhdr\n"));
+               if (ok == NN_SOCKET) {
+                       session_destroy(SESSION(session));
+                       REMOTE_FOLDER(item->folder)->session = NULL;
+               }
                return msginfo;
        }
 
                return msginfo;
        }
 
@@ -891,14 +929,20 @@ static GSList *news_get_msginfos_for_range(NNTPSession *session, FolderItem *ite
        GSList *llast = NULL;
        MsgInfo *msginfo;
        guint count = 0, lines = (end - begin + 2) * 3;
        GSList *llast = NULL;
        MsgInfo *msginfo;
        guint count = 0, lines = (end - begin + 2) * 3;
+       gint ok;
 
        g_return_val_if_fail(session != NULL, NULL);
        g_return_val_if_fail(item != NULL, NULL);
 
        log_message(_("getting xover %d - %d in %s...\n"),
                    begin, end, item->path);
 
        g_return_val_if_fail(session != NULL, NULL);
        g_return_val_if_fail(item != NULL, NULL);
 
        log_message(_("getting xover %d - %d in %s...\n"),
                    begin, end, item->path);
-       if (nntp_xover(session, begin, end) != NN_SUCCESS) {
+       ok = nntp_xover(session, begin, end);
+       if (ok != NN_SUCCESS) {
                log_warning(_("can't get xover\n"));
                log_warning(_("can't get xover\n"));
+               if (ok == NN_SOCKET) {
+                       session_destroy(SESSION(session));
+                       REMOTE_FOLDER(item->folder)->session = NULL;
+               }
                return NULL;
        }
 
                return NULL;
        }
 
@@ -934,8 +978,13 @@ static GSList *news_get_msginfos_for_range(NNTPSession *session, FolderItem *ite
                }
        }
 
                }
        }
 
-       if (nntp_xhdr(session, "to", begin, end) != NN_SUCCESS) {
+       ok = nntp_xhdr(session, "to", begin, end);
+       if (ok != NN_SUCCESS) {
                log_warning(_("can't get xhdr\n"));
                log_warning(_("can't get xhdr\n"));
+               if (ok == NN_SOCKET) {
+                       session_destroy(SESSION(session));
+                       REMOTE_FOLDER(item->folder)->session = NULL;
+               }
                return newlist;
        }
 
                return newlist;
        }
 
@@ -964,8 +1013,13 @@ static GSList *news_get_msginfos_for_range(NNTPSession *session, FolderItem *ite
                llast = llast->next;
        }
 
                llast = llast->next;
        }
 
-       if (nntp_xhdr(session, "cc", begin, end) != NN_SUCCESS) {
+       ok = nntp_xhdr(session, "cc", begin, end);
+       if (ok != NN_SUCCESS) {
                log_warning(_("can't get xhdr\n"));
                log_warning(_("can't get xhdr\n"));
+               if (ok == NN_SOCKET) {
+                       session_destroy(SESSION(session));
+                       REMOTE_FOLDER(item->folder)->session = NULL;
+               }
                return newlist;
        }
 
                return newlist;
        }