[Spice-commits] 9 commits - configure.ac gtk/channel-port.c gtk/desktop-integration.c gtk/spice-session.c gtk/spicy.c tests/util.c
Marc-André Lureau
elmarco at kemper.freedesktop.org
Fri Feb 7 04:59:55 PST 2014
configure.ac | 26 +++++++----
gtk/channel-port.c | 5 +-
gtk/desktop-integration.c | 103 +++++++++++++++++++++++++++++-----------------
gtk/spice-session.c | 3 -
gtk/spicy.c | 8 ---
tests/util.c | 12 ++---
6 files changed, 95 insertions(+), 62 deletions(-)
New commits:
commit 39555c4f69261c2297c99c75885f94c8daae7216
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date: Wed Jan 22 18:37:19 2014 +0100
session: don't track open_host_idle source id
In all cases, when the coroutine is resumed, the idle source has been
running and thus will be removed. Doing it a second time results in the
wrong source being removed or an invalid source warning.
diff --git a/gtk/spice-session.c b/gtk/spice-session.c
index bcbba27..9e6c154 100644
--- a/gtk/spice-session.c
+++ b/gtk/spice-session.c
@@ -1825,10 +1825,9 @@ GSocketConnection* spice_session_channel_open_host(SpiceSession *session, SpiceC
g_timeout_add_seconds(SOCKET_TIMEOUT, connect_timeout, &open_host);
#endif
- guint id = g_idle_add(open_host_idle_cb, &open_host);
+ g_idle_add(open_host_idle_cb, &open_host);
/* switch to main loop and wait for connection */
coroutine_yield(NULL);
- g_source_remove(id);
#if !GLIB_CHECK_VERSION(2,26,0)
if (open_host.timeout_id == 0)
commit 13f8a7b242e82575d307882ec165fb432e3ea638
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date: Sat Jan 11 00:06:06 2014 +0100
spicy: do not flush and disconnect all kind of ports
Some ports may want to live a bit longer, such as following webdav.
diff --git a/gtk/spicy.c b/gtk/spicy.c
index dff9d44..3e280a0 100644
--- a/gtk/spicy.c
+++ b/gtk/spicy.c
@@ -1475,24 +1475,18 @@ static void port_opened(SpiceChannel *channel, GParamSpec *pspec,
/* only send a break event and disconnect */
if (g_strcmp0(name, "org.spice.spicy.break") == 0) {
spice_port_event(port, SPICE_PORT_EVENT_BREAK);
+ spice_channel_flush_async(channel, NULL, port_flushed_cb, conn);
}
/* handle the first spicy port and connect it to stdin/out */
if (g_strcmp0(name, "org.spice.spicy") == 0 && stdin_port == NULL) {
stdin_port = port;
- goto end;
}
-
- if (port == stdin_port)
- goto end;
-
- spice_channel_flush_async(channel, NULL, port_flushed_cb, conn);
} else {
if (port == stdin_port)
stdin_port = NULL;
}
-end:
g_free(name);
}
commit 4277a3d8314155f947dd2ca511e3955a7e0a36eb
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date: Fri Jan 10 13:44:33 2014 +0100
port: send opened a port-event signal on init
If the port is already opened, emit a "opened" port-event on init. This
simplifies user code to only handle port events.
diff --git a/gtk/channel-port.c b/gtk/channel-port.c
index 11948bb..0a8b37f 100644
--- a/gtk/channel-port.c
+++ b/gtk/channel-port.c
@@ -249,9 +249,12 @@ static void port_handle_init(SpiceChannel *channel, SpiceMsgIn *in)
g_return_if_fail(c->name == NULL);
c->name = g_strdup((gchar*)init->name);
- g_object_notify(G_OBJECT(channel), "port-name");
port_set_opened(self, init->opened);
+ if (init->opened)
+ emit_main_context(channel, SPICE_PORT_EVENT, SPICE_PORT_EVENT_OPENED);
+
+ g_object_notify_main_context(G_OBJECT(channel), "port-name");
}
/* coroutine context */
commit 0eaf4920973507d11a347a278b4b7fd90a974805
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date: Thu Jan 30 18:49:23 2014 +0100
test: fix a few compiler warnings
util.c: In function 'test_set_bit':
util.c:131:13: warning: pointer targets in initialization differ in signedness [-Wpointer-sign]
diff --git a/tests/util.c b/tests/util.c
index 922818a..ecd83eb 100644
--- a/tests/util.c
+++ b/tests/util.c
@@ -81,9 +81,9 @@ static void test_unix2dos(void)
static const struct {
unsigned width;
unsigned height;
- guint8 *and;
- guint8 *xor;
- guint8 *dest;
+ gchar *and;
+ gchar *xor;
+ gchar *dest;
} mono[] = {
{
8, 6,
@@ -123,8 +123,8 @@ static void test_set_bit(void)
{
struct {
unsigned len;
- guint8 *src;
- guint8 *dest;
+ gchar *src;
+ gchar *dest;
} tests[] = {
{
4,
@@ -140,7 +140,7 @@ static void test_set_bit(void)
int i, j, bit;
guint8 *dest;
int bytes;
-
+
for (i = 0 ; i < G_N_ELEMENTS(tests); ++i) {
bytes = (tests[i].len + 7) / 8;
dest = g_malloc0(bytes);
commit 7b463a718c4a784b927d474039ada6375615932d
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date: Thu Feb 6 13:40:57 2014 +0100
Add GDBus version of dbus-glib code
diff --git a/gtk/desktop-integration.c b/gtk/desktop-integration.c
index af81b3b..d764e56 100644
--- a/gtk/desktop-integration.c
+++ b/gtk/desktop-integration.c
@@ -43,6 +43,8 @@
struct _SpiceDesktopIntegrationPrivate {
#if defined(USE_DBUS_GLIB)
DBusGProxy *gnome_session_proxy;
+#elif defined(USE_GDBUS)
+ GDBusProxy *gnome_session_proxy;
#else
GObject *gnome_session_proxy; /* dummy */
#endif
@@ -88,6 +90,16 @@ static gboolean gnome_integration_init(SpiceDesktopIntegration *self)
"org.gnome.SessionManager",
&error);
end:
+#elif defined(USE_GDBUS)
+ priv->gnome_session_proxy =
+ g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SESSION,
+ G_DBUS_PROXY_FLAGS_NONE,
+ NULL,
+ "org.gnome.SessionManager",
+ "/org/gnome/SessionManager",
+ "org.gnome.SessionManager",
+ NULL,
+ &error);
#else
success = FALSE;
#endif
@@ -106,6 +118,8 @@ static void gnome_integration_inhibit_automount(SpiceDesktopIntegration *self)
{
SpiceDesktopIntegrationPrivate *priv = self->priv;
GError *error = NULL;
+ G_GNUC_UNUSED const gchar *reason =
+ _("Automounting has been inhibited for USB auto-redirecting");
if (!priv->gnome_session_proxy)
return;
@@ -118,11 +132,24 @@ static void gnome_integration_inhibit_automount(SpiceDesktopIntegration *self)
G_TYPE_STRING, g_get_prgname(),
G_TYPE_UINT, 0,
G_TYPE_STRING,
- _("Automounting has been inhibited for USB auto-redirecting"),
+ reason,
G_TYPE_UINT, GNOME_SESSION_INHIBIT_AUTOMOUNT,
G_TYPE_INVALID,
G_TYPE_UINT, &priv->gnome_automount_inhibit_cookie,
G_TYPE_INVALID);
+#elif defined(USE_GDBUS)
+ GVariant *v = g_dbus_proxy_call_sync(priv->gnome_session_proxy,
+ "Inhibit",
+ g_variant_new("(susu)",
+ g_get_prgname(),
+ 0,
+ reason,
+ GNOME_SESSION_INHIBIT_AUTOMOUNT),
+ G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+ if (v)
+ g_variant_get(v, "(u)", &priv->gnome_automount_inhibit_cookie);
+
+ g_clear_pointer(&v, g_variant_unref);
#endif
if (error)
handle_dbus_call_error("org.gnome.SessionManager.Inhibit", &error);
@@ -146,6 +173,13 @@ static void gnome_integration_uninhibit_automount(SpiceDesktopIntegration *self)
G_TYPE_UINT, priv->gnome_automount_inhibit_cookie,
G_TYPE_INVALID,
G_TYPE_INVALID);
+#elif defined(USE_GDBUS)
+ GVariant *v = g_dbus_proxy_call_sync(priv->gnome_session_proxy,
+ "Uninhibit",
+ g_variant_new("(u)",
+ priv->gnome_automount_inhibit_cookie),
+ G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+ g_clear_pointer(&v, g_variant_unref);
#endif
if (error)
handle_dbus_call_error("org.gnome.SessionManager.Uninhibit", &error);
commit cec756286d449c55c22de3263a746bf7b87bc8a3
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date: Thu Feb 6 13:31:23 2014 +0100
Narrow dbus-glib code, to fit other implementation easily
diff --git a/gtk/desktop-integration.c b/gtk/desktop-integration.c
index 06712d9..af81b3b 100644
--- a/gtk/desktop-integration.c
+++ b/gtk/desktop-integration.c
@@ -22,7 +22,7 @@
#include "config.h"
#include <glib-object.h>
-#ifdef USE_DBUS_GLIB
+#if defined(USE_DBUS_GLIB)
#include <dbus/dbus-glib.h>
#endif
@@ -41,12 +41,12 @@
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), SPICE_TYPE_DESKTOP_INTEGRATION, SpiceDesktopIntegrationPrivate))
struct _SpiceDesktopIntegrationPrivate {
-#ifdef USE_DBUS_GLIB
+#if defined(USE_DBUS_GLIB)
DBusGProxy *gnome_session_proxy;
- guint gnome_automount_inhibit_cookie;
#else
- int dummy;
+ GObject *gnome_session_proxy; /* dummy */
#endif
+ guint gnome_automount_inhibit_cookie;
};
G_DEFINE_TYPE(SpiceDesktopIntegration, spice_desktop_integration, G_TYPE_OBJECT);
@@ -54,27 +54,28 @@ G_DEFINE_TYPE(SpiceDesktopIntegration, spice_desktop_integration, G_TYPE_OBJECT)
/* ------------------------------------------------------------------ */
/* Gnome specific code */
-#ifdef USE_DBUS_GLIB
-
static void handle_dbus_call_error(const char *call, GError **_error)
{
GError *error = *_error;
const char *message = error->message;
+#if defined(USE_DBUS_GLIB)
if (error->domain == DBUS_GERROR &&
error->code == DBUS_GERROR_REMOTE_EXCEPTION)
message = dbus_g_error_get_name(error);
+#endif
g_warning("Error calling '%s': %s", call, message);
g_clear_error(_error);
}
static gboolean gnome_integration_init(SpiceDesktopIntegration *self)
{
- SpiceDesktopIntegrationPrivate *priv = self->priv;
+ G_GNUC_UNUSED SpiceDesktopIntegrationPrivate *priv = self->priv;
GError *error = NULL;
- DBusGConnection *conn;
+ gboolean success = TRUE;
- conn = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
+#if defined(USE_DBUS_GLIB)
+ DBusGConnection *conn = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
if (!conn)
goto end;
@@ -87,14 +88,18 @@ static gboolean gnome_integration_init(SpiceDesktopIntegration *self)
"org.gnome.SessionManager",
&error);
end:
+#else
+ success = FALSE;
+#endif
+
if (error) {
- g_debug("Could not create org.gnome.SessionManager dbus proxy: %s",
- error->message);
+ g_warning("Could not create org.gnome.SessionManager dbus proxy: %s",
+ error->message);
g_clear_error(&error);
return FALSE;
}
- return TRUE;
+ return success;
}
static void gnome_integration_inhibit_automount(SpiceDesktopIntegration *self)
@@ -107,7 +112,8 @@ static void gnome_integration_inhibit_automount(SpiceDesktopIntegration *self)
g_return_if_fail(priv->gnome_automount_inhibit_cookie == 0);
- if (!dbus_g_proxy_call(
+#if defined(USE_DBUS_GLIB)
+ dbus_g_proxy_call(
priv->gnome_session_proxy, "Inhibit", &error,
G_TYPE_STRING, g_get_prgname(),
G_TYPE_UINT, 0,
@@ -116,7 +122,9 @@ static void gnome_integration_inhibit_automount(SpiceDesktopIntegration *self)
G_TYPE_UINT, GNOME_SESSION_INHIBIT_AUTOMOUNT,
G_TYPE_INVALID,
G_TYPE_UINT, &priv->gnome_automount_inhibit_cookie,
- G_TYPE_INVALID))
+ G_TYPE_INVALID);
+#endif
+ if (error)
handle_dbus_call_error("org.gnome.SessionManager.Inhibit", &error);
}
@@ -132,11 +140,14 @@ static void gnome_integration_uninhibit_automount(SpiceDesktopIntegration *self)
if (priv->gnome_automount_inhibit_cookie == 0)
return;
- if (!dbus_g_proxy_call(
+#if defined(USE_DBUS_GLIB)
+ dbus_g_proxy_call(
priv->gnome_session_proxy, "Uninhibit", &error,
G_TYPE_UINT, priv->gnome_automount_inhibit_cookie,
G_TYPE_INVALID,
- G_TYPE_INVALID))
+ G_TYPE_INVALID);
+#endif
+ if (error)
handle_dbus_call_error("org.gnome.SessionManager.Uninhibit", &error);
priv->gnome_automount_inhibit_cookie = 0;
@@ -149,8 +160,6 @@ static void gnome_integration_dispose(SpiceDesktopIntegration *self)
g_clear_object(&priv->gnome_session_proxy);
}
-#endif
-
/* ------------------------------------------------------------------ */
/* gobject glue */
@@ -161,19 +170,15 @@ static void spice_desktop_integration_init(SpiceDesktopIntegration *self)
priv = SPICE_DESKTOP_INTEGRATION_GET_PRIVATE(self);
self->priv = priv;
-#ifdef USE_DBUS_GLIB
if (!gnome_integration_init(self))
-#endif
g_warning("Warning no automount-inhibiting implementation available");
}
static void spice_desktop_integration_dispose(GObject *gobject)
{
-#ifdef USE_DBUS_GLIB
SpiceDesktopIntegration *self = SPICE_DESKTOP_INTEGRATION(gobject);
gnome_integration_dispose(self);
-#endif
/* Chain up to the parent class */
if (G_OBJECT_CLASS(spice_desktop_integration_parent_class)->dispose)
@@ -212,14 +217,10 @@ SpiceDesktopIntegration *spice_desktop_integration_get(SpiceSession *session)
void spice_desktop_integration_inhibit_automount(SpiceDesktopIntegration *self)
{
-#ifdef USE_DBUS_GLIB
gnome_integration_inhibit_automount(self);
-#endif
}
void spice_desktop_integration_uninhibit_automount(SpiceDesktopIntegration *self)
{
-#ifdef USE_DBUS_GLIB
gnome_integration_uninhibit_automount(self);
-#endif
}
commit 0d8e7122d128c8a3c172f3bf49dc482659905153
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date: Thu Feb 6 12:13:06 2014 +0100
dbus: remove priv->dbus_conn
It's only needed once, and it is better to group with rest of dbus-glib
code.
diff --git a/gtk/desktop-integration.c b/gtk/desktop-integration.c
index dd63b17..06712d9 100644
--- a/gtk/desktop-integration.c
+++ b/gtk/desktop-integration.c
@@ -42,7 +42,6 @@
struct _SpiceDesktopIntegrationPrivate {
#ifdef USE_DBUS_GLIB
- DBusGConnection *dbus_conn;
DBusGProxy *gnome_session_proxy;
guint gnome_automount_inhibit_cookie;
#else
@@ -73,18 +72,21 @@ static gboolean gnome_integration_init(SpiceDesktopIntegration *self)
{
SpiceDesktopIntegrationPrivate *priv = self->priv;
GError *error = NULL;
+ DBusGConnection *conn;
- if (!priv->dbus_conn)
- return FALSE;
+ conn = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
+ if (!conn)
+ goto end;
/* We use for_name_owner, to resolve the name now, as we may not be
running under gnome-session manager at all! */
priv->gnome_session_proxy = dbus_g_proxy_new_for_name_owner(
- priv->dbus_conn,
+ conn,
"org.gnome.SessionManager",
"/org/gnome/SessionManager",
"org.gnome.SessionManager",
&error);
+end:
if (error) {
g_debug("Could not create org.gnome.SessionManager dbus proxy: %s",
error->message);
@@ -155,19 +157,11 @@ static void gnome_integration_dispose(SpiceDesktopIntegration *self)
static void spice_desktop_integration_init(SpiceDesktopIntegration *self)
{
SpiceDesktopIntegrationPrivate *priv;
-#ifdef USE_DBUS_GLIB
- GError *error = NULL;
-#endif
priv = SPICE_DESKTOP_INTEGRATION_GET_PRIVATE(self);
self->priv = priv;
#ifdef USE_DBUS_GLIB
- priv->dbus_conn = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
- if (!priv->dbus_conn) {
- g_warning("Error connecting to session dbus: %s", error->message);
- g_clear_error(&error);
- }
if (!gnome_integration_init(self))
#endif
g_warning("Warning no automount-inhibiting implementation available");
commit 6bb31d7a8d05fa2304ec471a6763028495cf8bb6
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date: Thu Feb 6 12:09:22 2014 +0100
build-sys: detect GDBus
diff --git a/configure.ac b/configure.ac
index d6e8489..24416a9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -247,8 +247,8 @@ PKG_CHECK_MODULES(GIO, gio-2.0 >= 2.10.0 $gio_os)
AC_SUBST(GIO_CFLAGS)
AC_SUBST(GIO_LIBS)
-PKG_CHECK_EXISTS([gio-2.0 >= 2.26], [have_gproxy=yes])
-AM_CONDITIONAL([WITH_GPROXY], [test "x$have_gproxy" = "xyes"])
+PKG_CHECK_EXISTS([gio-2.0 >= 2.26], [have_gio26=yes])
+AM_CONDITIONAL([WITH_GPROXY], [test "x$have_gio26" = "xyes"])
PKG_CHECK_MODULES(CAIRO, cairo >= 1.2.0)
AC_SUBST(CAIRO_CFLAGS)
@@ -648,16 +648,20 @@ AC_ARG_ENABLE([dbus],
[],
[enable_dbus="auto"])
+have_dbus=no
if test "x$enable_dbus" != "xno"; then
- PKG_CHECK_MODULES([DBUS_GLIB], [dbus-glib-1],
- [have_dbus=yes],
- [have_dbus=no])
- if test "x$enable_dbus" = "xyes" && test "x$have_dbus" = "xno"; then
- AC_MSG_ERROR([D-Bus support explicitly requested, but some required packages are not available])
+ if test "x$have_gio26" = "xyes"; then
+ AC_DEFINE(USE_GDBUS, [1], [Define if supporting gdbus])
+ have_dbus=gdbus
+ else
+ PKG_CHECK_EXISTS([DBUS_GLIB], [dbus-glib-1], [
+ AC_DEFINE(USE_DBUS_GLIB, [1], [Define if supporting dbus-glib])
+ have_dbus=dbus-glib
+ ])
fi
- if test "x$have_dbus" = "xyes"; then
- AC_DEFINE(USE_DBUS_GLIB, [1], [Define if supporting dbus])
+ if test "x$enable_dbus" = "xyes" && test "x$have_dbus" = "xno"; then
+ AC_MSG_ERROR([D-Bus support explicitly requested, but some required packages are not available])
fi
fi
@@ -726,7 +730,11 @@ AC_MSG_NOTICE([
Smartcard support: ${have_smartcard}
USB redirection support: ${have_usbredir} ${with_usbredir_hotplug}
Gtk: $GTK_API_VERSION
+ DBus: ${have_dbus}
Now type 'make' to build $PACKAGE
])
+if test "x$have_dbus" = "xno"; then
+ AC_MSG_WARN([No D-Bus support, desktop integration and USB redirection may not work properly])
+fi
commit 629189cce101f13703315f4022479c8875113b09
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date: Thu Feb 6 12:08:30 2014 +0100
misc: sed -i -e 's/USE_DBUS/USE_DBUS_GLIB/g'
diff --git a/configure.ac b/configure.ac
index dccc231..d6e8489 100644
--- a/configure.ac
+++ b/configure.ac
@@ -657,7 +657,7 @@ if test "x$enable_dbus" != "xno"; then
fi
if test "x$have_dbus" = "xyes"; then
- AC_DEFINE(USE_DBUS, [1], [Define if supporting dbus])
+ AC_DEFINE(USE_DBUS_GLIB, [1], [Define if supporting dbus])
fi
fi
diff --git a/gtk/desktop-integration.c b/gtk/desktop-integration.c
index 044e0d3..dd63b17 100644
--- a/gtk/desktop-integration.c
+++ b/gtk/desktop-integration.c
@@ -22,7 +22,7 @@
#include "config.h"
#include <glib-object.h>
-#ifdef USE_DBUS
+#ifdef USE_DBUS_GLIB
#include <dbus/dbus-glib.h>
#endif
@@ -41,7 +41,7 @@
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), SPICE_TYPE_DESKTOP_INTEGRATION, SpiceDesktopIntegrationPrivate))
struct _SpiceDesktopIntegrationPrivate {
-#ifdef USE_DBUS
+#ifdef USE_DBUS_GLIB
DBusGConnection *dbus_conn;
DBusGProxy *gnome_session_proxy;
guint gnome_automount_inhibit_cookie;
@@ -55,7 +55,7 @@ G_DEFINE_TYPE(SpiceDesktopIntegration, spice_desktop_integration, G_TYPE_OBJECT)
/* ------------------------------------------------------------------ */
/* Gnome specific code */
-#ifdef USE_DBUS
+#ifdef USE_DBUS_GLIB
static void handle_dbus_call_error(const char *call, GError **_error)
{
@@ -155,14 +155,14 @@ static void gnome_integration_dispose(SpiceDesktopIntegration *self)
static void spice_desktop_integration_init(SpiceDesktopIntegration *self)
{
SpiceDesktopIntegrationPrivate *priv;
-#ifdef USE_DBUS
+#ifdef USE_DBUS_GLIB
GError *error = NULL;
#endif
priv = SPICE_DESKTOP_INTEGRATION_GET_PRIVATE(self);
self->priv = priv;
-#ifdef USE_DBUS
+#ifdef USE_DBUS_GLIB
priv->dbus_conn = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
if (!priv->dbus_conn) {
g_warning("Error connecting to session dbus: %s", error->message);
@@ -175,7 +175,7 @@ static void spice_desktop_integration_init(SpiceDesktopIntegration *self)
static void spice_desktop_integration_dispose(GObject *gobject)
{
-#ifdef USE_DBUS
+#ifdef USE_DBUS_GLIB
SpiceDesktopIntegration *self = SPICE_DESKTOP_INTEGRATION(gobject);
gnome_integration_dispose(self);
@@ -218,14 +218,14 @@ SpiceDesktopIntegration *spice_desktop_integration_get(SpiceSession *session)
void spice_desktop_integration_inhibit_automount(SpiceDesktopIntegration *self)
{
-#ifdef USE_DBUS
+#ifdef USE_DBUS_GLIB
gnome_integration_inhibit_automount(self);
#endif
}
void spice_desktop_integration_uninhibit_automount(SpiceDesktopIntegration *self)
{
-#ifdef USE_DBUS
+#ifdef USE_DBUS_GLIB
gnome_integration_uninhibit_automount(self);
#endif
}
More information about the Spice-commits
mailing list