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 45594cb..0feec7d 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 140d301..87307b6 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 bf8822e..c2c5798 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 d15dae2..e380e80 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 ac02149..ed944f6 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 1f0ddc2..e5792c8 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 7b3104e..7ec2be3 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__ */