[Commits] mainwindow.c 1.274.2.357 1.274.2.358 news.c 1.101.2.74 1.101.2.75 news.h 1.21.2.11 1.21.2.12

colin at claws-mail.org colin at claws-mail.org
Wed Nov 28 12:11:42 CET 2012


Update of /home/claws-mail/claws/src
In directory srv:/tmp/cvs-serv24753/src

Modified Files:
      Tag: gtk2
	mainwindow.c news.c news.h 
Log Message:
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

Index: mainwindow.c
===================================================================
RCS file: /home/claws-mail/claws/src/mainwindow.c,v
retrieving revision 1.274.2.357
retrieving revision 1.274.2.358
diff -u -d -r1.274.2.357 -r1.274.2.358
--- mainwindow.c	27 Nov 2012 10:12:11 -0000	1.274.2.357
+++ mainwindow.c	28 Nov 2012 11:11:40 -0000	1.274.2.358
@@ -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 @@
 			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: news.h
===================================================================
RCS file: /home/claws-mail/claws/src/news.h,v
retrieving revision 1.21.2.11
retrieving revision 1.21.2.12
diff -u -d -r1.21.2.11 -r1.21.2.12
--- news.h	27 May 2012 17:30:52 -0000	1.21.2.11
+++ news.h	28 Nov 2012 11:11:40 -0000	1.21.2.12
@@ -50,5 +50,6 @@
 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__ */

Index: news.c
===================================================================
RCS file: /home/claws-mail/claws/src/news.c,v
retrieving revision 1.101.2.74
retrieving revision 1.101.2.75
diff -u -d -r1.101.2.74 -r1.101.2.75
--- news.c	28 Nov 2012 11:01:24 -0000	1.101.2.74
+++ news.c	28 Nov 2012 11:11:40 -0000	1.101.2.75
@@ -1380,6 +1380,48 @@
 	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 @@
 	return &news_class;
 }
 
+void nntp_disconnect_all(gboolean have_connectivity)
+{
+}
 
 #endif



More information about the Commits mailing list