/cpw/tomkiewicz/gg11: b83ccb913c7f: Merge from trunk

Tomasz Wasilczyk tomkiewicz at cpw.pidgin.im
Tue Nov 6 20:46:27 EST 2012


Changeset: b83ccb913c7f913f752bab0e65d95e37b8e7439e
Author:	 Tomasz Wasilczyk <tomkiewicz at cpw.pidgin.im>
Date:	 2012-11-07 02:46 +0100
Branch:	 default
URL: http://hg.pidgin.im/cpw/tomkiewicz/gg11/rev/b83ccb913c7f

Description:

Merge from trunk

diffstat:

 libpurple/http.c    |  66 ++++++++++++++++++++++++++++++++++++++++------------
 pidgin/gtk3compat.h |  10 ++++++++
 pidgin/gtkmedia.c   |  38 ++++++++++++++++++++---------
 pidgin/gtkprefs.c   |  46 ++++++++++++++++++++++++------------
 4 files changed, 118 insertions(+), 42 deletions(-)

diffs (truncated from 344 to 300 lines):

diff --git a/libpurple/http.c b/libpurple/http.c
--- a/libpurple/http.c
+++ b/libpurple/http.c
@@ -111,6 +111,7 @@ struct _PurpleHttpConnection
 	gpointer watcher_user_data;
 	guint watcher_interval_threshold;
 	gint64 watcher_last_call;
+	guint watcher_delayed_handle;
 };
 
 struct _PurpleHttpResponse
@@ -430,7 +431,9 @@ static gchar * purple_http_headers_dump(
 static void _purple_http_disconnect(PurpleHttpConnection *hc);
 
 static void _purple_http_gen_headers(PurpleHttpConnection *hc);
-static void _purple_http_recv(gpointer _hc, gint fd, PurpleInputCondition cond);
+static gboolean _purple_http_recv_loopbody(PurpleHttpConnection *hc, gint fd);
+static void _purple_http_recv(gpointer _hc, gint fd,
+	PurpleInputCondition cond);
 static void _purple_http_recv_ssl(gpointer _hc,
 	PurpleSslConnection *ssl_connection, PurpleInputCondition cond);
 static void _purple_http_send(gpointer _hc, gint fd, PurpleInputCondition cond);
@@ -794,25 +797,26 @@ static gboolean _purple_http_recv_body(P
 	return _purple_http_recv_body_data(hc, buf, len);
 }
 
-static void _purple_http_recv(gpointer _hc, gint fd, PurpleInputCondition cond)
+static gboolean _purple_http_recv_loopbody(PurpleHttpConnection *hc, gint fd)
 {
-	PurpleHttpConnection *hc = _hc;
 	PurpleHttpSocket *hs = &hc->socket;
 	int len;
 	gchar buf[4096];
+	gboolean got_anything;
 
 	if (hs->is_ssl)
 		len = purple_ssl_read(hs->ssl_connection, buf, sizeof(buf));
 	else
 		len = read(fd, buf, sizeof(buf));
+	got_anything = (len > 0);
 
 	if (len < 0 && errno == EAGAIN)
-		return;
+		return FALSE;
 
 	if (len < 0) {
 		_purple_http_error(hc, _("Error reading from %s: %s"),
 			hc->url->host, g_strerror(errno));
-		return;
+		return FALSE;
 	}
 
 	/* EOF */
@@ -822,7 +826,7 @@ static void _purple_http_recv(gpointer _
 			purple_debug_warning("http", "No more data while reading"
 				" contents\n");
 			_purple_http_error(hc, _("Error parsing HTTP"));
-			return;
+			return FALSE;
 		}
 		if (hc->headers_got)
 			hc->length_expected = hc->length_got;
@@ -830,13 +834,13 @@ static void _purple_http_recv(gpointer _
 			purple_debug_warning("http", "No more data while "
 				"parsing headers\n");
 			_purple_http_error(hc, _("Error parsing HTTP"));
-			return;
+			return FALSE;
 		}
 	}
 
 	if (!hc->headers_got && len > 0) {
 		if (!_purple_http_recv_headers(hc, buf, len))
-			return;
+			return FALSE;
 		len = 0;
 		if (hc->headers_got) {
 			if (!purple_http_headers_get_int(hc->response->headers,
@@ -854,12 +858,12 @@ static void _purple_http_recv(gpointer _
 			_purple_http_recv_body(hc, buffer, buffer_len);
 		}
 		if (!hc->headers_got)
-			return;
+			return got_anything;
 	}
 
 	if (len > 0) {
 		if (!_purple_http_recv_body(hc, buf, len))
-			return;
+			return FALSE;
 	}
 
 	if (hc->is_chunked && hc->chunks_done)
@@ -872,7 +876,7 @@ static void _purple_http_recv(gpointer _
 			hc->response->code = 0;
 			purple_debug_warning("http", "No headers got\n");
 			_purple_http_error(hc, _("Error parsing HTTP"));
-			return;
+			return FALSE;
 		}
 
 		if (purple_debug_is_unsafe() && purple_debug_is_verbose()) {
@@ -898,7 +902,7 @@ static void _purple_http_recv(gpointer _
 
 		if (hc->response->code == 407) {
 			_purple_http_error(hc, _("Invalid proxy credentials"));
-			return;
+			return FALSE;
 		}
 
 		redirect = purple_http_headers_get(hc->response->headers,
@@ -924,13 +928,22 @@ static void _purple_http_recv(gpointer _
 			purple_http_url_free(url);
 
 			_purple_http_reconnect(hc);
-			return;
+			return FALSE;
 		}
 
 		_purple_http_disconnect(hc);
 		purple_http_connection_terminate(hc);
-		return;
+		return FALSE;
 	}
+
+	return got_anything;
+}
+
+static void _purple_http_recv(gpointer _hc, gint fd, PurpleInputCondition cond)
+{
+	PurpleHttpConnection *hc = _hc;
+
+	while (_purple_http_recv_loopbody(hc, fd));
 }
 
 static void _purple_http_recv_ssl(gpointer _hc,
@@ -1281,6 +1294,7 @@ PurpleHttpConnection * purple_http_reque
 /*** HTTP connection API ******************************************************/
 
 static void purple_http_connection_free(PurpleHttpConnection *hc);
+static gboolean purple_http_conn_notify_progress_watcher_timeout(gpointer _hc);
 
 static PurpleHttpConnection * purple_http_connection_new(
 	PurpleHttpRequest *request, PurpleConnection *gc)
@@ -1309,6 +1323,8 @@ static void purple_http_connection_free(
 {
 	if (hc->timeout_handle)
 		purple_timeout_remove(hc->timeout_handle);
+	if (hc->watcher_delayed_handle)
+		purple_timeout_remove(hc->watcher_delayed_handle);
 
 	purple_http_url_free(hc->url);
 	purple_http_request_unref(hc->request);
@@ -1449,12 +1465,32 @@ static void purple_http_conn_notify_prog
 
 	now = g_get_monotonic_time();
 	if (hc->watcher_last_call + hc->watcher_interval_threshold
-		> now && processed != total)
+		> now && processed != total) {
+		if (hc->watcher_delayed_handle)
+			return;
+		hc->watcher_delayed_handle = purple_timeout_add_seconds(
+			1 + hc->watcher_interval_threshold / 1000000,
+			purple_http_conn_notify_progress_watcher_timeout, hc);
 		return;
+	}
+
+	if (hc->watcher_delayed_handle)
+		purple_timeout_remove(hc->watcher_delayed_handle);
+	hc->watcher_delayed_handle = 0;
+
 	hc->watcher_last_call = now;
 	hc->watcher(hc, reading_state, processed, total, hc->watcher_user_data);
 }
 
+static gboolean purple_http_conn_notify_progress_watcher_timeout(gpointer _hc)
+{
+	PurpleHttpConnection *hc = _hc;
+
+	purple_http_conn_notify_progress_watcher(hc);
+
+	return FALSE;
+}
+
 /*** Cookie jar API ***********************************************************/
 
 static PurpleHttpCookie * purple_http_cookie_new(const gchar *value);
diff --git a/pidgin/gtk3compat.h b/pidgin/gtk3compat.h
--- a/pidgin/gtk3compat.h
+++ b/pidgin/gtk3compat.h
@@ -37,6 +37,16 @@
 #define gdk_x11_window_get_xid GDK_WINDOW_XWINDOW
 #define gtk_widget_get_preferred_size(x,y,z) gtk_widget_size_request(x,z)
 
+#ifdef GDK_WINDOWING_X11
+#define GDK_IS_X11_WINDOW(window) TRUE
+#endif
+#ifdef GDK_WINDOWING_WIN32
+#define GDK_IS_WIN32_WINDOW(window) TRUE
+#endif
+#ifdef GDK_WINDOWING_QUARTZ
+#define GDK_IS_QUARTZ_WINDOW(window) TRUE
+#endif
+
 #if !GTK_CHECK_VERSION(2,24,0)
 
 #define gdk_x11_set_sm_client_id gdk_set_sm_client_id
diff --git a/pidgin/gtkmedia.c b/pidgin/gtkmedia.c
--- a/pidgin/gtkmedia.c
+++ b/pidgin/gtkmedia.c
@@ -38,11 +38,13 @@
 #ifdef USE_VV
 #include "media-gst.h"
 
-#ifdef _WIN32
+#ifdef GDK_WINDOWING_WIN32
 #include <gdk/gdkwin32.h>
-#elif defined(GDK_WINDOWING_X11)
+#endif
+#ifdef GDK_WINDOWING_X11
 #include <gdk/gdkx.h>
-#elif defined(GDK_WINDOWING_QUARTZ)
+#endif
+#ifdef GDK_WINDOWING_QUARTZ
 #include <gdk/gdkquartz.h>
 #endif
 
@@ -551,15 +553,27 @@ realize_cb_cb(PidginMediaRealizeData *da
 	}
 
 	if (window) {
-		gulong window_id;
-#ifdef _WIN32
-		window_id = GDK_WINDOW_HWND(window);
-#elif defined(HAVE_X11)
-		window_id = gdk_x11_window_get_xid(window);
-#elif defined(GDK_WINDOWING_QUARTZ)
-		window_id = (gulong) gdk_quartz_window_get_nsview(window);
-#else
-#		error "Unsupported windowing system"
+		gulong window_id = 0;
+#ifdef GDK_WINDOWING_WIN32
+		if (GDK_IS_WIN32_WINDOW(window))
+			window_id = GDK_WINDOW_HWND(window);
+		else
+#endif
+#ifdef GDK_WINDOWING_X11
+		if (GDK_IS_X11_WINDOW(window))
+			window_id = gdk_x11_window_get_xid(window);
+		else
+#endif
+#ifdef GDK_WINDOWING_QUARTZ
+		if (GDK_IS_QUARTZ_WINDOW(window))
+			window_id = (gulong)gdk_quartz_window_get_nsview(window);
+		else
+#endif
+			g_warning("Unsupported GDK backend");
+#if !(defined(GDK_WINDOWING_WIN32) \
+   || defined(GDK_WINDOWING_X11) \
+   || defined(GDK_WINDOWING_QUARTZ))
+#		error "Unsupported GDK windowing system"
 #endif
 
 		purple_media_set_output_window(priv->media, data->session_id,
diff --git a/pidgin/gtkprefs.c b/pidgin/gtkprefs.c
--- a/pidgin/gtkprefs.c
+++ b/pidgin/gtkprefs.c
@@ -66,9 +66,15 @@
 #include <gst/interfaces/xoverlay.h>
 #include <gst/interfaces/propertyprobe.h>
 #endif
-#ifdef HAVE_X11
+#ifdef GDK_WINDOWING_WIN32
+#include <gdk/gdkwin32.h>
+#endif
+#ifdef GDK_WINDOWING_X11
 #include <gdk/gdkx.h>
 #endif
+#ifdef GDK_WINDOWING_QUARTZ
+#include <gdk/gdkquartz.h>
+#endif
 #endif
 
 #include "gtk3compat.h"
@@ -3364,10 +3370,9 @@ toggle_voice_test_cb(GtkToggleButton *te
 }
 
 static void
-scale_value_changed_cb(GtkScaleButton *button, gpointer data)
+volume_changed_cb(GtkScaleButton *button, gpointer data)
 {
-	const char *pref = data;
-	purple_prefs_set_int(pref,
+	purple_prefs_set_int("/purple/media/audio/volume/input",
 	                     gtk_scale_button_get_value(GTK_SCALE_BUTTON(button)) * 100);
 }
 
@@ -3409,8 +3414,7 @@ make_voice_test(GtkWidget *vbox)
 	gtk_scale_button_set_value(GTK_SCALE_BUTTON(volume),
 			purple_prefs_get_int("/purple/media/audio/volume/input") / 100.0);



More information about the Commits mailing list