talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit 91892f5b2ca33be674a5c393b65bb3f4014fbc3d
parent 94b24847bf5cf842c388a710d59b85d256054e87
Author: Colin Leroy <colin@colino.net>
Date:   Wed, 28 Nov 2012 11:11:40 +0000

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

Diffstat:
MChangeLog | 8++++++++
MPATCHSETS | 1+
Mconfigure.ac | 2+-
Msrc/etpan/nntp-thread.c | 8++++++++
Msrc/mainwindow.c | 2++
Msrc/news.c | 45+++++++++++++++++++++++++++++++++++++++++++++
Msrc/news.h | 1+
7 files changed, 66 insertions(+), 1 deletion(-)

diff --git 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 diff --git a/PATCHSETS b/PATCHSETS @@ -4525,3 +4525,4 @@ ( 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 diff --git a/configure.ac b/configure.ac @@ -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= diff --git a/src/etpan/nntp-thread.c b/src/etpan/nntp-thread.c @@ -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 diff --git a/src/mainwindow.c b/src/mainwindow.c @@ -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 */ diff --git a/src/news.c b/src/news.c @@ -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 diff --git a/src/news.h b/src/news.h @@ -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__ */