2012-11-28 [colin] 3.9.0cvs28
authorColin Leroy <colin@colino.net>
Wed, 28 Nov 2012 11:11:40 +0000 (11:11 +0000)
committerColin Leroy <colin@colino.net>
Wed, 28 Nov 2012 11:11:40 +0000 (11:11 +0000)
* src/mainwindow.c
* src/news.c
* src/news.h
* src/etpan/nntp-thread.c
Disconnect NNTP accounts too when switching offline

ChangeLog
PATCHSETS
configure.ac
src/etpan/nntp-thread.c
src/mainwindow.c
src/news.c
src/news.h

index 45594cb51f74cb18916fa49bb9224f7b82826970..0feec7dc711272e405844c98b0ce39e26c27514f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2012-11-28 [colin]     3.9.0cvs28
+
+       * src/mainwindow.c
+       * src/news.c
+       * src/news.h
+       * src/etpan/nntp-thread.c
+               Disconnect NNTP accounts too when switching offline
+
 2012-11-28 [colin]     3.9.0cvs27
 
        * src/imap.c
index 140d301e85fd4d26e0de0c68bb2b035e434a1978..87307b65bb546cf5e98a0b707956c5846d37b9ab 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.115.2.264 -r 1.115.2.265 src/main.c;  ) > 3.9.0cvs25.patchset
 ( cvs diff -u -r 1.179.2.268 -r 1.179.2.269 src/imap.c;  cvs diff -u -r 1.1.4.126 -r 1.1.4.127 src/etpan/imap-thread.c;  cvs diff -u -r 1.1.4.30 -r 1.1.4.31 src/etpan/imap-thread.h;  ) > 3.9.0cvs26.patchset
 ( cvs diff -u -r 1.179.2.269 -r 1.179.2.270 src/imap.c;  cvs diff -u -r 1.101.2.73 -r 1.101.2.74 src/news.c;  cvs diff -u -r 1.23.2.28 -r 1.23.2.29 src/common/session.c;  cvs diff -u -r 1.8.2.21 -r 1.8.2.22 src/common/session.h;  ) > 3.9.0cvs27.patchset
+( cvs diff -u -r 1.274.2.357 -r 1.274.2.358 src/mainwindow.c;  cvs diff -u -r 1.101.2.74 -r 1.101.2.75 src/news.c;  cvs diff -u -r 1.21.2.11 -r 1.21.2.12 src/news.h;  cvs diff -u -r 1.1.2.23 -r 1.1.2.24 src/etpan/nntp-thread.c;  ) > 3.9.0cvs28.patchset
index bf8822e7abcc8091cc5c7c9c2cd9fdf9bf9c81ee..c2c5798676fd5cc2813005acf63590bcaaaa52f4 100644 (file)
@@ -12,7 +12,7 @@ MINOR_VERSION=9
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=27
+EXTRA_VERSION=28
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index d15dae2f3c8f3f953065dfbcded7209d7149e36b..e380e80df4e4da0316753e82ab30daf3e0be0dbf 100644 (file)
@@ -46,6 +46,8 @@
 #include "ssl_certificate.h"
 #include "socket.h"
 #include "remotefolder.h"
+#include "main.h"
+#include "account.h"
 
 #define DISABLE_LOG_DURING_LOGIN
 
@@ -158,6 +160,7 @@ void nntp_main_init(gboolean skip_ssl_cert_check)
 
 void nntp_main_done(gboolean have_connectivity)
 {
+       nntp_disconnect_all(have_connectivity);
        etpan_thread_manager_stop(thread_manager);
 #if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__)
        return;
@@ -968,6 +971,11 @@ int nntp_threaded_xhdr(Folder * folder, const char *header, guint32 beg, guint32
        return result.error;
 }
 
+void nntp_main_set_timeout(int sec)
+{
+       mailstream_network_delay.tv_sec = sec;
+       mailstream_network_delay.tv_usec = 0;
+}
 
 #else
 
index ac02149bd74a7dea4aa143f6bc702692c8961535..ed944f64e389b6ffa482014c01a78dd6319fb57c 100644 (file)
@@ -85,6 +85,7 @@
 #include "tags.h"
 #include "textview.h"
 #include "imap.h"
+#include "news.h"
 #include "socket.h"
 #include "printing.h"
 #ifdef G_OS_WIN32
@@ -4372,6 +4373,7 @@ static void online_switch_clicked (GtkButton *btn, gpointer data)
                        mainwindow_check_synchronise(mainwin, TRUE);
                prefs_common.work_offline = TRUE;
                imap_disconnect_all(have_connectivity);
+               nntp_disconnect_all(have_connectivity);
                hooks_invoke(OFFLINE_SWITCH_HOOKLIST, NULL);
        } else {
                /*go online */
index 1f0ddc2ed9f9739286a25fff68bf078b72709dc1..e5792c860b2c8e1ae00c510ff3659aa80926c72f 100644 (file)
@@ -1380,6 +1380,48 @@ static gint news_remove_folder(Folder *folder, FolderItem *item)
        return 0;
 }
 
+void nntp_disconnect_all(gboolean have_connectivity)
+{
+       GList *list;
+       gboolean short_timeout;
+#ifdef HAVE_NETWORKMANAGER_SUPPORT
+       GError *error;
+#endif
+
+#ifdef HAVE_NETWORKMANAGER_SUPPORT
+       error = NULL;
+       short_timeout = !networkmanager_is_online(&error);
+       if(error) {
+               short_timeout = TRUE;
+               g_error_free(error);
+       }
+#else
+       short_timeout = TRUE;
+#endif
+
+       if(short_timeout)
+               nntp_main_set_timeout(1);
+
+       for (list = account_get_list(); list != NULL; list = list->next) {
+               PrefsAccount *account = list->data;
+               if (account->protocol == A_NNTP) {
+                       RemoteFolder *folder = (RemoteFolder *)account->folder;
+                       if (folder && folder->session) {
+                               NewsSession *session = (NewsSession *)folder->session;
+                               if (have_connectivity)
+                                       nntp_threaded_disconnect(FOLDER(folder));
+                               SESSION(session)->state = SESSION_DISCONNECTED;
+                               SESSION(session)->sock = NULL;
+                               session_destroy(SESSION(session));
+                               folder->session = NULL;
+                       }
+               }
+       }
+
+       if(short_timeout)
+               nntp_main_set_timeout(prefs_common.io_timeout_secs);
+}
+
 #else
 #include <glib.h>
 #include <glib/gi18n.h>
@@ -1456,5 +1498,8 @@ FolderClass *news_get_class(void)
        return &news_class;
 }
 
+void nntp_disconnect_all(gboolean have_connectivity)
+{
+}
 
 #endif
index 7b3104ed80c39244125727f9b0a99ece3b661a7d..7ec2be35d847520ea4f25784aa02a34137ba745a 100644 (file)
@@ -50,5 +50,6 @@ int news_folder_locked                        (Folder         *folder);
 guint nntp_folder_get_refcnt(Folder *folder);
 void nntp_folder_ref(Folder *folder);
 void nntp_folder_unref(Folder *folder);
+void nntp_disconnect_all(gboolean have_connectivity);
 
 #endif /* __NEWS_H__ */