[Commits] imap.c 1.179.2.269 1.179.2.270 news.c 1.101.2.73 1.101.2.74

colin at claws-mail.org colin at claws-mail.org
Wed Nov 28 12:01:26 CET 2012


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

Modified Files:
      Tag: gtk2
	imap.c news.c 
Log Message:
2012-11-28 [colin]	3.9.0cvs27

	* src/imap.c
	* src/news.c
	* src/common/session.c
	* src/common/session.h
		Add keep-alive pings on IMAP and NNTP

Index: imap.c
===================================================================
RCS file: /home/claws-mail/claws/src/imap.c,v
retrieving revision 1.179.2.269
retrieving revision 1.179.2.270
diff -u -d -r1.179.2.269 -r1.179.2.270
--- imap.c	28 Nov 2012 09:39:37 -0000	1.179.2.269
+++ imap.c	28 Nov 2012 11:01:24 -0000	1.179.2.270
@@ -544,6 +544,24 @@
 	}
 }
 
+static gboolean imap_ping(gpointer data)
+{
+	Session *session = (Session *)data;
+	IMAPSession *imap_session = IMAP_SESSION(session);
+	int r;
+
+	if (session->state != SESSION_READY)
+		return FALSE;
+	if (imap_session->busy || !imap_session->authenticated)
+		return TRUE;
+	
+	lock_session(imap_session);
+	r = imap_cmd_noop(imap_session);
+	unlock_session(imap_session);
+
+	return r == MAILIMAP_NO_ERROR;
+}
+
 static void imap_disc_session_destroy(IMAPSession *session)
 {
 	RemoteFolder *rfolder = NULL;
@@ -752,7 +770,7 @@
 	folder_remote_folder_init((Folder *)folder, name, path);
 	IMAP_FOLDER(folder)->max_set_size = IMAP_SET_MAX_COUNT;
 	IMAP_FOLDER(folder)->search_charset_supported = TRUE;
-	IMAP_FOLDER(folder)->search_charset = "UTF-8";
+	IMAP_FOLDER(folder)->search_charset = conv_get_locale_charset_str_no_utf8();
 }
 
 static FolderItem *imap_folder_item_new(Folder *folder)
@@ -1183,6 +1201,8 @@
 	log_message(LOG_PROTOCOL, "IMAP connection is %s-authenticated\n",
 		    (session->authenticated) ? "pre" : "un");
 	
+	session_register_ping(SESSION(session), imap_ping);
+
 	return session;
 }
 
@@ -2177,9 +2197,9 @@
 	 */
 
 	if (folder->search_charset_supported) {
-		if (folder->search_charset && !strcmp(folder->search_charset, "UTF-8"))
-			folder->search_charset = conv_get_locale_charset_str_no_utf8();
-		else if (folder->search_charset && !strcmp(folder->search_charset, conv_get_locale_charset_str_no_utf8()))
+		if (folder->search_charset && !strcmp(folder->search_charset, conv_get_locale_charset_str_no_utf8()))
+			folder->search_charset = "UTF-8";
+		else if (folder->search_charset && !strcmp(folder->search_charset, "UTF-8"))
 			folder->search_charset = "UTF-7";
 		else {
 			folder->search_charset = NULL;
@@ -3992,8 +4012,6 @@
 		return r;
 	}
 
-	session->folder_content_changed = FALSE;
-
 	if ((exists && exists != session->exists)
 	 || (recent && recent != session->recent)
 	 || (expunge && expunge != session->expunge)

Index: news.c
===================================================================
RCS file: /home/claws-mail/claws/src/news.c,v
retrieving revision 1.101.2.73
retrieving revision 1.101.2.74
diff -u -d -r1.101.2.73 -r1.101.2.74
--- news.c	21 Sep 2012 10:19:42 -0000	1.101.2.73
+++ news.c	28 Nov 2012 11:01:24 -0000	1.101.2.74
@@ -83,7 +83,7 @@
 struct _NewsSession
 {
 	Session session;
-
+	Folder *folder;
 	gchar *group;
 };
 
@@ -282,6 +282,34 @@
 		g_free(news_session->group);
 }
 
+static gboolean nntp_ping(gpointer data)
+{
+	Session *session = (Session *)data;
+	NewsSession *news_session = NEWS_SESSION(session);
+	int r;
+	struct tm lt;
+
+	if (session->state != SESSION_READY || news_folder_locked(news_session->folder))
+		return FALSE;
+	
+	if ((r = nntp_threaded_date(news_session->folder, &lt)) != NEWSNNTP_NO_ERROR) {
+		if (r != NEWSNNTP_ERROR_COMMAND_NOT_SUPPORTED &&
+		    r != NEWSNNTP_ERROR_COMMAND_NOT_UNDERSTOOD) {
+			log_warning(LOG_PROTOCOL, _("NNTP connection to %s:%d has been"
+			      " disconnected.\n"),
+			    news_session->folder->account->nntp_server,
+			    news_session->folder->account->set_nntpport ?
+			    news_session->folder->account->nntpport : NNTP_PORT);
+			REMOTE_FOLDER(news_session->folder)->session = NULL;
+			session_destroy(session);
+			return FALSE;
+		}
+	}
+	session_set_access_time(session);
+	return TRUE;
+}
+
+
 #ifdef USE_GNUTLS
 static Session *news_session_new(Folder *folder, const gchar *server, gushort port,
 				 const gchar *userid, const gchar *passwd,
@@ -320,7 +348,10 @@
 		session_destroy(SESSION(session));
 		return NULL;
 	}
-	
+
+	session->folder = folder;
+
+	session_register_ping(SESSION(session), nntp_ping);
 	return SESSION(session);
 }
 
@@ -437,8 +468,6 @@
 static NewsSession *news_session_get(Folder *folder)
 {
 	RemoteFolder *rfolder = REMOTE_FOLDER(folder);
-	struct tm lt;
-	int r;
 	
 	cm_return_val_if_fail(folder != NULL, NULL);
 	cm_return_val_if_fail(FOLDER_CLASS(folder) == &news_class, NULL);
@@ -469,18 +498,8 @@
 		return NEWS_SESSION(rfolder->session);
 	}
 
-	if ((r = nntp_threaded_date(folder, &lt)) != NEWSNNTP_NO_ERROR) {
-		if (r != NEWSNNTP_ERROR_COMMAND_NOT_SUPPORTED &&
-		    r != NEWSNNTP_ERROR_COMMAND_NOT_UNDERSTOOD) {
-			log_warning(LOG_PROTOCOL, _("NNTP connection to %s:%d has been"
-			      " disconnected. Reconnecting...\n"),
-			    folder->account->nntp_server,
-			    folder->account->set_nntpport ?
-			    folder->account->nntpport : NNTP_PORT);
-			session_destroy(rfolder->session);
-			rfolder->session = news_session_new_for_folder(folder);
-		}
-	}
+	if (!nntp_ping(rfolder->session))
+		rfolder->session = news_session_new_for_folder(folder);
 
 newsession:
 	if (rfolder->session)



More information about the Commits mailing list