[Commits] [SCM] claws branch, master, updated. 3.17.4-67-g272ba86bb

miras at claws-mail.org miras at claws-mail.org
Mon Nov 11 22:27:37 CET 2019


The branch, master has been updated
       via  272ba86bbba2f3d864c2d871c56d1d15ec011dd5 (commit)
       via  13f8677c91f5937ed3e30a3bab958ebfe2b09035 (commit)
      from  f139e5f166b17c1c9e708ff943f6c2164e963445 (commit)

Summary of changes:
 src/common/session.c | 94 +++++++++++++++++++++++++++++++++++++++-------------
 src/common/session.h |  5 ++-
 src/inc.c            | 57 +++++++++++++++++++++++--------
 src/inc.h            |  5 +++
 4 files changed, 123 insertions(+), 38 deletions(-)


- Log -----------------------------------------------------------------
commit 272ba86bbba2f3d864c2d871c56d1d15ec011dd5
Merge: 13f8677c9 f139e5f16
Author: Michael Rasmussen <mir at datanom.net>
Date:   Mon Nov 11 23:27:29 2019 +0100

    Merge branch 'master' of ssh+git://git.claws-mail.org/home/git/claws


commit 13f8677c91f5937ed3e30a3bab958ebfe2b09035
Author: Michael Rasmussen <mir at datanom.net>
Date:   Mon Nov 11 23:27:08 2019 +0100

    Fix use of deprecated GTimeVal since glib 2.61.2
    
    Signed-off-by: Michael Rasmussen <mir at datanom.net>

diff --git a/src/common/session.c b/src/common/session.c
index 2da8e16c2..c7a42f084 100644
--- a/src/common/session.c
+++ b/src/common/session.c
@@ -75,7 +75,11 @@ void session_init(Session *session, const void *prefs_account, gboolean is_smtp)
 	session->state = SESSION_READY;
 	session->last_access_time = time(NULL);
 
+#if GLIB_CHECK_VERSION(2,61,2)
+	session->tv_prev = g_date_time_new_now_local();
+#else
 	g_get_current_time(&session->tv_prev);
+#endif
 
 	session->conn_id = 0;
 
@@ -264,7 +268,9 @@ void session_destroy(Session *session)
 #ifdef USE_GNUTLS
 	g_free(session->gnutls_priority);
 #endif
-
+#if GLIB_CHECK_VERSION(2,61,2)
+	g_date_time_unref(session->tv_prev);
+#endif
 	debug_print("session (%p): destroyed\n", session);
 
 	g_free(session);
@@ -500,7 +506,12 @@ gint session_send_data(Session *session, const guchar *data, guint size)
 	session->write_data = data;
 	session->write_data_p = session->write_data;
 	session->write_data_len = size;
-	g_get_current_time(&session->tv_prev);
+#if GLIB_CHECK_VERSION(2,61,2)
+	g_date_time_unref(session->tv_prev);
+        session->tv_prev = g_date_time_new_now_local();
+#else
+        g_get_current_time(&session->tv_prev);
+#endif
 
 	ret = session_write_data_cb(session->sock, G_IO_OUT, session);
 
@@ -522,7 +533,12 @@ gint session_recv_data(Session *session, guint size, const gchar *terminator)
 
 	g_free(session->read_data_terminator);
 	session->read_data_terminator = g_strdup(terminator);
-	g_get_current_time(&session->tv_prev);
+#if GLIB_CHECK_VERSION(2,61,2)
+	g_date_time_unref(session->tv_prev);
+        session->tv_prev = g_date_time_new_now_local();
+#else
+        g_get_current_time(&session->tv_prev);
+#endif
 
 	if (session->read_buf_len > 0)
 		g_idle_add(session_recv_data_idle_cb, session);
@@ -711,17 +727,31 @@ static gboolean session_read_data_cb(SockInfo *source, GIOCondition condition,
 
 	/* incomplete read */
 	if (!complete) {
+#if GLIB_CHECK_VERSION(2,61,2)
+		GDateTime *tv_cur = g_date_time_new_now_local();
+
+		GTimeSpan ts = g_date_time_difference(tv_cur, session->tv_prev);
+                if (1000 - ts < 0 || ts > UI_REFRESH_INTERVAL) {
+                        session->recv_data_progressive_notify
+                                (session, data_buf->len, 0,
+                                 session->recv_data_progressive_notify_data);
+			g_date_time_unref(session->tv_prev);
+                        session->tv_prev = g_date_time_new_now_local();
+                }
+		g_date_time_unref(tv_cur);
+#else
 		GTimeVal tv_cur;
 
 		g_get_current_time(&tv_cur);
-		if (tv_cur.tv_sec - session->tv_prev.tv_sec > 0 ||
-		    tv_cur.tv_usec - session->tv_prev.tv_usec >
-		    UI_REFRESH_INTERVAL) {
-			session->recv_data_progressive_notify
-				(session, data_buf->len, 0,
-				 session->recv_data_progressive_notify_data);
-			g_get_current_time(&session->tv_prev);
-		}
+                if (tv_cur.tv_sec - session->tv_prev.tv_sec > 0 ||
+                    tv_cur.tv_usec - session->tv_prev.tv_usec >
+                    UI_REFRESH_INTERVAL) {
+                        session->recv_data_progressive_notify
+                                (session, data_buf->len, 0,
+                                 session->recv_data_progressive_notify_data);
+                        g_get_current_time(&session->tv_prev);
+                }
+#endif
 		return TRUE;
 	}
 
@@ -882,20 +912,38 @@ static gboolean session_write_data_cb(SockInfo *source,
 		session->state = SESSION_ERROR;
 		return FALSE;
 	} else if (ret > 0) {
+#if GLIB_CHECK_VERSION(2,61,2)
+                GDateTime *tv_cur = g_date_time_new_now_local();
+
+                GTimeSpan ts = g_date_time_difference(tv_cur, session->tv_prev);
+                if (1000 - ts < 0 || ts > UI_REFRESH_INTERVAL) {
+                        session_set_timeout(session, session->timeout_interval);
+                        session->send_data_progressive_notify
+                                (session,
+                                 session->write_data_p - session->write_data,
+                                 write_data_len,
+                                 session->send_data_progressive_notify_data);
+			g_date_time_unref(session->tv_prev);
+                        session->tv_prev = g_date_time_new_now_local();
+                }
+                g_date_time_unref(tv_cur);
+#else
 		GTimeVal tv_cur;
 
-		g_get_current_time(&tv_cur);
-		if (tv_cur.tv_sec - session->tv_prev.tv_sec > 0 ||
-		    tv_cur.tv_usec - session->tv_prev.tv_usec >
-		    UI_REFRESH_INTERVAL) {
-			session_set_timeout(session, session->timeout_interval);
-			session->send_data_progressive_notify
-				(session,
-				 session->write_data_p - session->write_data,
-				 write_data_len,
-				 session->send_data_progressive_notify_data);
-			g_get_current_time(&session->tv_prev);
-		}
+                g_get_current_time(&tv_cur);
+                if (tv_cur.tv_sec - session->tv_prev.tv_sec > 0 ||
+                    tv_cur.tv_usec - session->tv_prev.tv_usec >
+                    UI_REFRESH_INTERVAL) {
+                        session_set_timeout(session, session->timeout_interval);
+                        session->send_data_progressive_notify
+                                (session,
+                                 session->write_data_p - session->write_data,
+                                 write_data_len,
+                                 session->send_data_progressive_notify_data);
+                        g_get_current_time(&session->tv_prev);
+                }
+
+#endif
 		return TRUE;
 	}
 
diff --git a/src/common/session.h b/src/common/session.h
index 13a56c97e..d24e75030 100644
--- a/src/common/session.h
+++ b/src/common/session.h
@@ -88,8 +88,11 @@ struct _Session
 	SessionState state;
 
 	time_t last_access_time;
+#if GLIB_CHECK_VERSION(2,61,2)
+	GDateTime *tv_prev;
+#else
 	GTimeVal tv_prev;
-
+#endif
 	gint conn_id;
 
 	gint io_tag;
diff --git a/src/inc.c b/src/inc.c
index 5a0bdffcc..48098c614 100644
--- a/src/inc.c
+++ b/src/inc.c
@@ -508,8 +508,13 @@ static IncProgressDialog *inc_progress_dialog_create(gboolean autocheck)
 	}
 
 	dialog->dialog = progress;
+#if GLIB_CHECK_VERSION(2,61,2)
+	dialog->progress_tv = g_date_time_new_now_local();
+	dialog->folder_tv = g_date_time_new_now_local();
+#else
 	g_get_current_time(&dialog->progress_tv);
 	g_get_current_time(&dialog->folder_tv);
+#endif
 	dialog->queue_list = NULL;
 	dialog->cur_row = 0;
 
@@ -553,6 +558,11 @@ static void inc_progress_dialog_destroy(IncProgressDialog *inc_dialog)
 		main_window_progress_off(inc_dialog->mainwin);
 	progress_dialog_destroy(inc_dialog->dialog);
 
+#if GLIB_CHECK_VERSION(2,61,2)
+	g_date_time_unref(inc_dialog->progress_tv);
+	g_date_time_unref(inc_dialog->folder_tv);
+#endif
+
 	g_free(inc_dialog);
 }
 
@@ -1081,25 +1091,44 @@ static void inc_progress_dialog_set_progress(IncProgressDialog *inc_dialog,
 static void inc_progress_dialog_update_periodic(IncProgressDialog *inc_dialog,
 						IncSession *inc_session)
 {
+#if GLIB_CHECK_VERSION(2,61,2)
+	GDateTime *tv_cur = g_date_time_new_now_local();
+	GTimeSpan tv_result;
+
+	tv_result = g_date_time_difference(tv_cur, inc_dialog->progress_tv);
+	g_date_time_unref(tv_cur);
+	if (tv_result < 0) {
+	    tv_result += G_USEC_PER_SEC;
+	}
+
+	if (tv_result > PROGRESS_UPDATE_INTERVAL) {
+                inc_progress_dialog_update(inc_dialog, inc_session);
+		tv_cur = g_date_time_add(inc_dialog->progress_tv, tv_result);
+		g_date_time_unref(inc_dialog->progress_tv);
+                inc_dialog->progress_tv = tv_cur;
+	}
+#else
 	GTimeVal tv_cur;
 	GTimeVal tv_result;
-	gint msec;
 
-	g_get_current_time(&tv_cur);
+        gint msec;
 
-	tv_result.tv_sec = tv_cur.tv_sec - inc_dialog->progress_tv.tv_sec;
-	tv_result.tv_usec = tv_cur.tv_usec - inc_dialog->progress_tv.tv_usec;
-	if (tv_result.tv_usec < 0) {
-		tv_result.tv_sec--;
-		tv_result.tv_usec += G_USEC_PER_SEC;
-	}
+        g_get_current_time(&tv_cur);
 
-	msec = tv_result.tv_sec * 1000 + tv_result.tv_usec / 1000;
-	if (msec > PROGRESS_UPDATE_INTERVAL) {
-		inc_progress_dialog_update(inc_dialog, inc_session);
-		inc_dialog->progress_tv.tv_sec = tv_cur.tv_sec;
-		inc_dialog->progress_tv.tv_usec = tv_cur.tv_usec;
-	}
+        tv_result.tv_sec = tv_cur.tv_sec - inc_dialog->progress_tv.tv_sec;
+        tv_result.tv_usec = tv_cur.tv_usec - inc_dialog->progress_tv.tv_usec;
+        if (tv_result.tv_usec < 0) {
+                tv_result.tv_sec--;
+                tv_result.tv_usec += G_USEC_PER_SEC;
+        }
+
+        msec = tv_result.tv_sec * 1000 + tv_result.tv_usec / 1000;
+        if (msec > PROGRESS_UPDATE_INTERVAL) {
+                inc_progress_dialog_update(inc_dialog, inc_session);
+                inc_dialog->progress_tv.tv_sec = tv_cur.tv_sec;
+                inc_dialog->progress_tv.tv_usec = tv_cur.tv_usec;
+        }
+#endif
 }
 
 static gint inc_recv_data_progressive(Session *session, guint cur_len,
diff --git a/src/inc.h b/src/inc.h
index c440c8f42..c8d38b620 100644
--- a/src/inc.h
+++ b/src/inc.h
@@ -58,8 +58,13 @@ struct _IncProgressDialog
 
 	gboolean show_dialog;
 
+#if GLIB_CHECK_VERSION(2,61,2)
+	GDateTime *progress_tv;
+	GDateTime *folder_tv;
+#else
 	GTimeVal progress_tv;
 	GTimeVal folder_tv;
+#endif
 
 	GList *queue_list;	/* list of IncSession */
 	gint cur_row;

-----------------------------------------------------------------------


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list