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 bebfb23..8b87b07 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
index 50663e7..c97a11b 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 :)
 
-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/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
 
-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 
index 0b51f4e..2e873ab 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
index db78205..b053b3e 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 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
index bd0023c..6bcc83e 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * 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
@@ -41,7 +41,7 @@ static void nntp_session_destroy(Session      *session);
 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,
@@ -97,8 +97,32 @@ Session *nntp_session_new(const gchar *server, gushort port, gchar *buf,
        session->group = NULL;
 
        if (userid && passwd) {
+               gint ok;
+
                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);
@@ -134,7 +158,7 @@ gint nntp_group(NNTPSession *session, const gchar *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);
@@ -291,9 +315,6 @@ gint nntp_mode(NNTPSession *session, gboolean stream)
 {
        gint ok;
 
-       if (session->auth_failed)
-               return NN_AUTHREQ;
-
        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;
 }
 
-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;
@@ -344,7 +365,12 @@ static void nntp_gen_send(SockInfo *sock, const gchar *format, ...)
        }
 
        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)
@@ -373,7 +399,9 @@ static gint nntp_gen_command(NNTPSession *session, gchar *argbuf,
        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) {
@@ -381,11 +409,15 @@ static gint nntp_gen_command(NNTPSession *session, gchar *argbuf,
                        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) {
-                       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) {
@@ -393,18 +425,20 @@ static gint nntp_gen_command(NNTPSession *session, gchar *argbuf,
                        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) {
-                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;
-                        return ok;
-                }
-        }
+                       return ok;
+               }
+                ok = nntp_ok(sock, NULL);
+       }
 
        return ok;
 }
index 7a4eceb..88f8358 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * 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
@@ -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) {
-               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;
        }
@@ -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);
-       if (ok < 0) {
+       if (ok != NN_SUCCESS) {
                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;
        }
@@ -379,6 +384,7 @@ GSList *news_get_group_list(Folder *folder)
 
        if ((fp = fopen(filename, "rb")) == NULL) {
                NNTPSession *session;
+               gint ok;
 
                session = news_session_get(folder);
                if (!session) {
@@ -386,7 +392,12 @@ GSList *news_get_group_list(Folder *folder)
                        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;
                }
@@ -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");
+               if (ok == NN_SOCKET) {
+                       session_destroy(SESSION(session));
+                       REMOTE_FOLDER(folder)->session = NULL;
+               }
                return -1;
        }
 
@@ -515,20 +530,25 @@ static gint news_get_article_cmd(NNTPSession *session, const gchar *cmd,
                                 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);
 
-       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)
@@ -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);
+       else
+               log_warning(_("can't select group: %s\n"), group);
 
        return ok;
 }
@@ -819,6 +841,7 @@ MsgInfo *news_get_msginfo(Folder *folder, FolderItem *item, gint num)
        NNTPSession *session;
        MsgInfo *msginfo = NULL;
        gchar buf[NNTPBUFSIZE];
+       gint ok;
 
        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);
-       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"));
+               if (ok == NN_SOCKET) {
+                       session_destroy(SESSION(session));
+                       REMOTE_FOLDER(item->folder)->session = 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);
 
-       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"));
+               if (ok == NN_SOCKET) {
+                       session_destroy(SESSION(session));
+                       REMOTE_FOLDER(item->folder)->session = NULL;
+               }
                return msginfo;
        }
 
@@ -867,8 +900,13 @@ MsgInfo *news_get_msginfo(Folder *folder, FolderItem *item, gint num)
 
        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"));
+               if (ok == NN_SOCKET) {
+                       session_destroy(SESSION(session));
+                       REMOTE_FOLDER(item->folder)->session = NULL;
+               }
                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;
+       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);
-       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"));
+               if (ok == NN_SOCKET) {
+                       session_destroy(SESSION(session));
+                       REMOTE_FOLDER(item->folder)->session = 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"));
+               if (ok == NN_SOCKET) {
+                       session_destroy(SESSION(session));
+                       REMOTE_FOLDER(item->folder)->session = NULL;
+               }
                return newlist;
        }
 
@@ -964,8 +1013,13 @@ static GSList *news_get_msginfos_for_range(NNTPSession *session, FolderItem *ite
                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"));
+               if (ok == NN_SOCKET) {
+                       session_destroy(SESSION(session));
+                       REMOTE_FOLDER(item->folder)->session = NULL;
+               }
                return newlist;
        }