[Spice-devel] [PATCHv3 spice-gtk 12/14] Make SpiceURI a public API

2014-02-17 Thread Marc-André Lureau
Generalize a little bit SpiceProxy to allow easy URI manipulation by
clients.
---
 doc/reference/Makefile.am|   1 +
 doc/reference/spice-gtk-docs.xml |   1 +
 doc/reference/spice-gtk-sections.txt |  26 ++
 gtk/Makefile.am  |   5 +-
 gtk/map-file |  12 +
 gtk/spice-client.h   |   1 +
 gtk/spice-glib-sym-file  |  12 +
 gtk/spice-proxy.c| 369 
 gtk/spice-proxy.h|  64 -
 gtk/spice-session-priv.h |   3 +-
 gtk/spice-session.c  |  28 +--
 gtk/spice-session.h  |   1 +
 gtk/spice-uri-priv.h |  30 +++
 gtk/spice-uri.c  | 460 +++
 gtk/spice-uri.h  |  52 
 15 files changed, 614 insertions(+), 451 deletions(-)
 delete mode 100644 gtk/spice-proxy.c
 delete mode 100644 gtk/spice-proxy.h
 create mode 100644 gtk/spice-uri-priv.h
 create mode 100644 gtk/spice-uri.c
 create mode 100644 gtk/spice-uri.h

diff --git a/doc/reference/Makefile.am b/doc/reference/Makefile.am
index a0a856c..76c7d34 100644
--- a/doc/reference/Makefile.am
+++ b/doc/reference/Makefile.am
@@ -44,6 +44,7 @@ IGNORE_HFILES=\
spice-marshal.h \
spice-pulse.h   \
spice-session-priv.h\
+   spice-uri-priv.h\
spice-util-priv.h   \
spice-widget-priv.h \
usb-acl-helper.h\
diff --git a/doc/reference/spice-gtk-docs.xml b/doc/reference/spice-gtk-docs.xml
index 4a9a3cf..d2c1a2b 100644
--- a/doc/reference/spice-gtk-docs.xml
+++ b/doc/reference/spice-gtk-docs.xml
@@ -52,6 +52,7 @@
   
   
   
+  
 
 
   
diff --git a/doc/reference/spice-gtk-sections.txt 
b/doc/reference/spice-gtk-sections.txt
index 8d61aa9..411ca0e 100644
--- a/doc/reference/spice-gtk-sections.txt
+++ b/doc/reference/spice-gtk-sections.txt
@@ -429,3 +429,29 @@ SPICE_PORT_CHANNEL_GET_CLASS
 SpicePortChannelPrivate
 
 
+
+spice-uri
+spice_uri_get_scheme
+spice_uri_set_scheme
+spice_uri_get_hostname
+spice_uri_set_hostname
+spice_uri_get_port
+spice_uri_set_port
+spice_uri_get_user
+spice_uri_set_user
+spice_uri_get_password
+spice_uri_set_password
+spice_uri_to_string
+SpiceURIClass
+SpiceURI
+
+SPICE_IS_URI
+SPICE_IS_URI_CLASS
+SPICE_TYPE_URI
+SPICE_URI
+SPICE_URI_CLASS
+SPICE_URI_GET_CLASS
+spice_uri_get_type
+
+SpiceURIPrivate
+
diff --git a/gtk/Makefile.am b/gtk/Makefile.am
index 0740e96..dc09d8c 100644
--- a/gtk/Makefile.am
+++ b/gtk/Makefile.am
@@ -251,8 +251,8 @@ libspice_client_glib_2_0_la_SOURCES =   
\
channel-usbredir-priv.h \
smartcard-manager.c \
smartcard-manager-priv.h\
-   spice-proxy.c   \
-   spice-proxy.h   \
+   spice-uri.c \
+   spice-uri-priv.h\
usb-device-manager.c\
usb-device-manager-priv.h   \
usbutil.c   \
@@ -287,6 +287,7 @@ libspice_client_glibincludedir = 
$(includedir)/spice-client-glib-2.0
 libspice_client_glibinclude_HEADERS =  \
spice-audio.h   \
spice-client.h  \
+   spice-uri.h \
spice-types.h   \
spice-session.h \
spice-channel.h \
diff --git a/gtk/map-file b/gtk/map-file
index b6c184d..82a10eb 100644
--- a/gtk/map-file
+++ b/gtk/map-file
@@ -119,6 +119,18 @@ spice_util_get_version_string;
 spice_util_set_debug;
 spice_uuid_to_string;
 spice_webdav_channel_get_type;
+spice_uri_get_hostname;
+spice_uri_get_password;
+spice_uri_get_port;
+spice_uri_get_scheme;
+spice_uri_get_type;
+spice_uri_get_user;
+spice_uri_set_hostname;
+spice_uri_set_password;
+spice_uri_set_port;
+spice_uri_set_scheme;
+spice_uri_set_user;
+spice_uri_to_string;
 local:
 *;
 };
diff --git a/gtk/spice-client.h b/gtk/spice-client.h
index f5c8aa7..1f80419 100644
--- a/gtk/spice-client.h
+++ b/gtk/spice-client.h
@@ -31,6 +31,7 @@
 #include "spice-session.h"
 #include "spice-channel.h"
 #include "spice-option.h"
+#include "spice-uri.h"
 
 #include "channel-main.h"
 #include "channel-display.h"
diff --git a/gtk/spice-glib-sym-file b/gtk/spice-glib-sym-file
index c9d6b79..3dc709a 100644
--- a/gtk/spice-glib-sym-file
+++ b/gtk/spice-glib-sym-file
@@ -93,3 +93,15 @@ spice_util_get_version_string
 spice_util_set_debug
 spice_uuid_to_string
 spice_webdav_channel_get_type
+spice_uri_get_hostname
+spice_uri_get_password
+spice_uri_get_port
+spice_

[Spice-devel] [PATCHv3 spice-gtk 14/14] session: add spice_session_get_proxy_uri()

2014-02-17 Thread Marc-André Lureau
Learn to return the currently configured proxy, to allow
client to tweak parameters, such as username and password.
---
 doc/reference/spice-gtk-sections.txt |  1 +
 gtk/map-file |  1 +
 gtk/spice-glib-sym-file  |  1 +
 gtk/spice-session.c  | 14 ++
 gtk/spice-session.h  |  1 +
 5 files changed, 18 insertions(+)

diff --git a/doc/reference/spice-gtk-sections.txt 
b/doc/reference/spice-gtk-sections.txt
index 9f0cf67..08b1b4e 100644
--- a/doc/reference/spice-gtk-sections.txt
+++ b/doc/reference/spice-gtk-sections.txt
@@ -28,6 +28,7 @@ spice_session_disconnect
 spice_session_get_channels
 spice_session_get_read_only
 spice_session_has_channel_type
+spice_session_get_proxy_uri
 
 SpiceSessionMigration
 SpiceSessionVerify
diff --git a/gtk/map-file b/gtk/map-file
index 0067960..2a46159 100644
--- a/gtk/map-file
+++ b/gtk/map-file
@@ -90,6 +90,7 @@ spice_session_migration_get_type;
 spice_session_new;
 spice_session_open_fd;
 spice_session_verify_get_type;
+spice_session_get_proxy_uri;
 spice_set_session_option;
 spice_smartcard_channel_get_type;
 spice_smartcard_manager_get;
diff --git a/gtk/spice-glib-sym-file b/gtk/spice-glib-sym-file
index 9d5001a..20f3885 100644
--- a/gtk/spice-glib-sym-file
+++ b/gtk/spice-glib-sym-file
@@ -106,3 +106,4 @@ spice_uri_set_port
 spice_uri_set_scheme
 spice_uri_set_user
 spice_uri_to_string
+spice_session_get_proxy_uri
diff --git a/gtk/spice-session.c b/gtk/spice-session.c
index 5e76b5f..ea32cf7 100644
--- a/gtk/spice-session.c
+++ b/gtk/spice-session.c
@@ -2190,3 +2190,17 @@ guint32 spice_session_get_playback_latency(SpiceSession 
*session)
 return 0;
 }
 }
+
+/**
+ * spice_session_get_proxy_uri:
+ * @session: a #SpiceSession
+ *
+ * Returns: (transfer none): the session proxy #SpiceURI or %NULL.
+ * Since: 0.24
+ **/
+SpiceURI *spice_session_get_proxy_uri(SpiceSession *session)
+{
+SpiceSessionPrivate *s = SPICE_SESSION_GET_PRIVATE(session);
+
+return s->proxy;
+}
diff --git a/gtk/spice-session.h b/gtk/spice-session.h
index 4ea645e..665c609 100644
--- a/gtk/spice-session.h
+++ b/gtk/spice-session.h
@@ -93,6 +93,7 @@ void spice_session_disconnect(SpiceSession *session);
 GList *spice_session_get_channels(SpiceSession *session);
 gboolean spice_session_has_channel_type(SpiceSession *session, gint type);
 gboolean spice_session_get_read_only(SpiceSession *session);
+SpiceURI *spice_session_get_proxy_uri(SpiceSession *session);
 
 G_END_DECLS
 
-- 
1.8.4.2

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCHv3 spice-gtk 13/14] channel: add spice_channel_get_error()

2014-02-17 Thread Marc-André Lureau
Add a function to retrieve the last GError from a channel, this may be
useful to provide additional error details to the client.
---
 doc/reference/spice-gtk-sections.txt |  1 +
 gtk/map-file |  1 +
 gtk/spice-channel-priv.h |  1 +
 gtk/spice-channel.c  | 30 +++---
 gtk/spice-channel.h  |  2 ++
 gtk/spice-glib-sym-file  |  1 +
 gtk/spice-session-priv.h |  2 +-
 gtk/spice-session.c  |  6 +++---
 gtk/spicy.c  |  6 ++
 9 files changed, 43 insertions(+), 7 deletions(-)

diff --git a/doc/reference/spice-gtk-sections.txt 
b/doc/reference/spice-gtk-sections.txt
index 411ca0e..9f0cf67 100644
--- a/doc/reference/spice-gtk-sections.txt
+++ b/doc/reference/spice-gtk-sections.txt
@@ -102,6 +102,7 @@ spice_channel_string_to_type
 spice_channel_set_capability
 spice_channel_flush_async
 spice_channel_flush_finish
+spice_channel_get_error
 
 SPICE_TYPE_CHANNEL_EVENT
 spice_channel_event_get_type
diff --git a/gtk/map-file b/gtk/map-file
index 82a10eb..0067960 100644
--- a/gtk/map-file
+++ b/gtk/map-file
@@ -7,6 +7,7 @@ spice_channel_connect;
 spice_channel_destroy;
 spice_channel_disconnect;
 spice_channel_event_get_type;
+spice_channel_get_error;
 spice_channel_get_type;
 spice_channel_new;
 spice_channel_open_fd;
diff --git a/gtk/spice-channel-priv.h b/gtk/spice-channel-priv.h
index f38156e..607c0d4 100644
--- a/gtk/spice-channel-priv.h
+++ b/gtk/spice-channel-priv.h
@@ -136,6 +136,7 @@ struct _SpiceChannelPrivate {
 GSList  *flushing;
 
 gbooleandisable_channel_msg;
+GError  *error;
 };
 
 SpiceMsgIn *spice_msg_in_new(SpiceChannel *channel);
diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c
index 1b8ec10..a9c1076 100644
--- a/gtk/spice-channel.c
+++ b/gtk/spice-channel.c
@@ -154,6 +154,8 @@ static void spice_channel_dispose(GObject *gobject)
  c->session = NULL;
 }
 
+g_clear_error(&c->error);
+
 /* Chain up to the parent class */
 if (G_OBJECT_CLASS(spice_channel_parent_class)->dispose)
 G_OBJECT_CLASS(spice_channel_parent_class)->dispose(gobject);
@@ -317,7 +319,9 @@ static void spice_channel_class_init(SpiceChannelClass 
*klass)
  * @event: a #SpiceChannelEvent
  *
  * The #SpiceChannel::channel-event signal is emitted when the
- * state of the connection change.
+ * state of the connection is changed. In case of errors,
+ * spice_channel_get_error() may provide additional informations
+ * on the source of the error.
  **/
 signals[SPICE_CHANNEL_EVENT] =
 g_signal_new("channel-event",
@@ -2220,6 +2224,25 @@ static int spice_channel_load_ca(SpiceChannel *channel)
 return count;
 }
 
+/**
+ * spice_channel_get_error:
+ * @channel:
+ *
+ * Retrieves the #GError currently set on channel, if the #SpiceChannel
+ * is in error state and can provide additional error details.
+ *
+ * Returns: the pointer to the error, or %NULL
+ * Since: 0.24
+ **/
+const GError* spice_channel_get_error(SpiceChannel *self)
+{
+SpiceChannelPrivate *c;
+
+g_return_val_if_fail(SPICE_IS_CHANNEL(self), NULL);
+c = self->priv;
+
+return c->error;
+}
 
 /* coroutine context */
 static void *spice_channel_coroutine(void *data)
@@ -2257,15 +2280,16 @@ static void *spice_channel_coroutine(void *data)
 
 
 reconnect:
-c->conn = spice_session_channel_open_host(c->session, channel, &c->tls);
+c->conn = spice_session_channel_open_host(c->session, channel, &c->tls, 
&c->error);
 if (c->conn == NULL) {
-if (!c->tls) {
+if (!c->error && !c->tls) {
 CHANNEL_DEBUG(channel, "trying with TLS port");
 c->tls = true; /* FIXME: does that really work with provided fd */
 goto reconnect;
 } else {
 CHANNEL_DEBUG(channel, "Connect error");
 emit_main_context(channel, SPICE_CHANNEL_EVENT, 
SPICE_CHANNEL_ERROR_CONNECT);
+g_clear_error(&c->error);
 goto cleanup;
 }
 }
diff --git a/gtk/spice-channel.h b/gtk/spice-channel.h
index 705dddf..1c303b4 100644
--- a/gtk/spice-channel.h
+++ b/gtk/spice-channel.h
@@ -123,6 +123,8 @@ void spice_channel_set_capability(SpiceChannel *channel, 
guint32 cap);
 const gchar* spice_channel_type_to_string(gint type);
 gint spice_channel_string_to_type(const gchar *str);
 
+const GError* spice_channel_get_error(SpiceChannel *channel);
+
 G_END_DECLS
 
 #endif /* __SPICE_CLIENT_CHANNEL_H__ */
diff --git a/gtk/spice-glib-sym-file b/gtk/spice-glib-sym-file
index 3dc709a..9d5001a 100644
--- a/gtk/spice-glib-sym-file
+++ b/gtk/spice-glib-sym-file
@@ -7,6 +7,7 @@ spice_channel_disconnect
 spice_channel_event_get_type
 spice_channel_flush_async
 spice_channel_flush_finish
+spice_channel_get_error
 spice_channel_get_type
 spice_channel_new
 spice_channel_open_fd
diff --git a/gtk/spice-session-p

[Spice-devel] [PATCHv3 spice-gtk 03/14] proxy: add user and pass properties

2014-02-17 Thread Marc-André Lureau
---
 gtk/spice-proxy.c | 72 +++
 gtk/spice-proxy.h |  4 
 2 files changed, 76 insertions(+)

diff --git a/gtk/spice-proxy.c b/gtk/spice-proxy.c
index f338213..7711e83 100644
--- a/gtk/spice-proxy.c
+++ b/gtk/spice-proxy.c
@@ -26,6 +26,8 @@ struct _SpiceProxyPrivate {
 gchar *protocol;
 gchar *hostname;
 guint port;
+gchar *user;
+gchar *password;
 };
 
 #define SPICE_PROXY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), 
SPICE_TYPE_PROXY, SpiceProxyPrivate))
@@ -35,6 +37,8 @@ G_DEFINE_TYPE(SpiceProxy, spice_proxy, G_TYPE_OBJECT);
 enum  {
 SPICE_PROXY_DUMMY_PROPERTY,
 SPICE_PROXY_PROTOCOL,
+SPICE_PROXY_USER,
+SPICE_PROXY_PASSWORD,
 SPICE_PROXY_HOSTNAME,
 SPICE_PROXY_PORT
 };
@@ -173,6 +177,12 @@ static void spice_proxy_get_property(GObject *object, 
guint property_id,
 case SPICE_PROXY_PORT:
 g_value_set_uint(value, spice_proxy_get_port(self));
 break;
+case SPICE_PROXY_USER:
+g_value_set_string(value, spice_proxy_get_user(self));
+break;
+case SPICE_PROXY_PASSWORD:
+g_value_set_string(value, spice_proxy_get_password(self));
+break;
 default:
 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
 break;
@@ -193,6 +203,12 @@ static void spice_proxy_set_property(GObject *object, 
guint property_id,
 case SPICE_PROXY_HOSTNAME:
 spice_proxy_set_hostname(self, g_value_get_string(value));
 break;
+case SPICE_PROXY_USER:
+spice_proxy_set_user(self, g_value_get_string(value));
+break;
+case SPICE_PROXY_PASSWORD:
+spice_proxy_set_password(self, g_value_get_string(value));
+break;
 case SPICE_PROXY_PORT:
 spice_proxy_set_port(self, g_value_get_uint(value));
 break;
@@ -209,6 +225,8 @@ static void spice_proxy_finalize(GObject* obj)
 self = G_TYPE_CHECK_INSTANCE_CAST(obj, SPICE_TYPE_PROXY, SpiceProxy);
 g_free(self->priv->protocol);
 g_free(self->priv->hostname);
+g_free(self->priv->user);
+g_free(self->priv->password);
 
 G_OBJECT_CLASS (spice_proxy_parent_class)->finalize (obj);
 }
@@ -254,6 +272,24 @@ static void spice_proxy_class_init(SpiceProxyClass *klass)
0, G_MAXUINT, 0,
G_PARAM_STATIC_STRINGS |
G_PARAM_READWRITE));
+
+g_object_class_install_property(G_OBJECT_CLASS (klass),
+SPICE_PROXY_USER,
+g_param_spec_string ("user",
+ "user",
+ "user",
+ NULL,
+ 
G_PARAM_STATIC_STRINGS |
+ G_PARAM_READWRITE));
+
+g_object_class_install_property(G_OBJECT_CLASS (klass),
+SPICE_PROXY_PASSWORD,
+g_param_spec_string ("password",
+ "password",
+ "password",
+ NULL,
+ 
G_PARAM_STATIC_STRINGS |
+ G_PARAM_READWRITE));
 }
 
 G_GNUC_INTERNAL
@@ -269,3 +305,39 @@ gchar* spice_proxy_to_string(SpiceProxy* self)
 
 return g_strdup_printf("%s://%s:%u", p->protocol, p->hostname, p->port);
 }
+
+G_GNUC_INTERNAL
+const gchar* spice_proxy_get_user(SpiceProxy *self)
+{
+g_return_val_if_fail(SPICE_IS_PROXY(self), NULL);
+return self->priv->user;
+}
+
+
+G_GNUC_INTERNAL
+void spice_proxy_set_user(SpiceProxy *self, const gchar *value)
+{
+g_return_if_fail(SPICE_IS_PROXY(self));
+
+g_free(self->priv->user);
+self->priv->user = g_strdup(value);
+g_object_notify((GObject *)self, "user");
+}
+
+G_GNUC_INTERNAL
+const gchar* spice_proxy_get_password(SpiceProxy *self)
+{
+g_return_val_if_fail(SPICE_IS_PROXY(self), NULL);
+return self->priv->password;
+}
+
+
+G_GNUC_INTERNAL
+void spice_proxy_set_password(SpiceProxy *self, const gchar *value)
+{
+g_return_if_fail(SPICE_IS_PROXY(self));
+
+g_free(self->priv->password);
+self->priv->password = g_strdup(value);
+g_object_notify((GObject *)self, "password");
+}
diff --git a/gtk/spice-proxy.h b/gtk/spice-proxy.h
index 1e7b6d7..e74053b 100644
--- a/gtk/spice-proxy.h
+++ b/gtk/spice-proxy.h
@@ -54,6 +54,10 @@ void spice_proxy_set_hostname(SpiceProxy* self, const gchar* 
value);
 guint spice_proxy_get_port(SpiceProxy* self);
 void spice_proxy_set_port(SpiceProxy* self, guint port);
 gchar *spice_proxy_to_s

[Spice-devel] [PATCHv3 spice-gtk 10/14] channel: simplify has error code

2014-02-17 Thread Marc-André Lureau
Get rid of a superflous g_socket_condition_check().
---
 gtk/spice-channel.c | 28 +++-
 1 file changed, 11 insertions(+), 17 deletions(-)

diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c
index d47f19f..7bcb0b8 100644
--- a/gtk/spice-channel.c
+++ b/gtk/spice-channel.c
@@ -2099,29 +2099,23 @@ static gboolean wait_migration(gpointer data)
 static gboolean spice_channel_iterate(SpiceChannel *channel)
 {
 SpiceChannelPrivate *c = channel->priv;
-GIOCondition ret;
 
 if (c->state == SPICE_CHANNEL_STATE_MIGRATING &&
 !g_coroutine_condition_wait(&c->coroutine, wait_migration, channel))
 CHANNEL_DEBUG(channel, "migration wait cancelled");
 
-if (c->has_error) {
-CHANNEL_DEBUG(channel, "channel has error, breaking loop");
-return FALSE;
-}
-
 /* flush any pending write and read */
-SPICE_CHANNEL_GET_CLASS(channel)->iterate_write(channel);
-SPICE_CHANNEL_GET_CLASS(channel)->iterate_read(channel);
-
-ret = g_socket_condition_check(c->sock, G_IO_IN | G_IO_ERR | G_IO_HUP);
-if (c->state > SPICE_CHANNEL_STATE_CONNECTING &&
-ret & (G_IO_ERR|G_IO_HUP)) {
-SPICE_DEBUG("got socket error: %d", ret);
-emit_main_context(channel, SPICE_CHANNEL_EVENT,
-  c->state == SPICE_CHANNEL_STATE_READY ?
-  SPICE_CHANNEL_ERROR_IO : SPICE_CHANNEL_ERROR_LINK);
-c->has_error = TRUE;
+if (!c->has_error)
+SPICE_CHANNEL_GET_CLASS(channel)->iterate_write(channel);
+if (!c->has_error)
+SPICE_CHANNEL_GET_CLASS(channel)->iterate_read(channel);
+
+if (c->has_error) {
+CHANNEL_DEBUG(channel, "channel got error");
+if (c->state > SPICE_CHANNEL_STATE_CONNECTING)
+emit_main_context(channel, SPICE_CHANNEL_EVENT,
+  c->state == SPICE_CHANNEL_STATE_READY ?
+  SPICE_CHANNEL_ERROR_IO : 
SPICE_CHANNEL_ERROR_LINK);
 return FALSE;
 }
 
-- 
1.8.4.2

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCHv3 spice-gtk 02/14] proxy: split uri with : in only 2 parts

2014-02-17 Thread Marc-André Lureau
We want just host:port here.
---
 gtk/spice-proxy.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gtk/spice-proxy.c b/gtk/spice-proxy.c
index bc4037e..f338213 100644
--- a/gtk/spice-proxy.c
+++ b/gtk/spice-proxy.c
@@ -74,7 +74,8 @@ gboolean spice_proxy_parse(SpiceProxy *self, const gchar 
*proxyuri, GError **err
 spice_proxy_set_protocol(self, "http");
 spice_proxy_set_port(self, 3128);
 
-gchar **proxyv = g_strsplit(uri, ":", 0);
+/* max 2 parts, host:port */
+gchar **proxyv = g_strsplit(uri, ":", 2);
 const gchar *proxy_port = NULL;
 
 if (proxyv[0] == NULL || strlen(proxyv[0]) == 0) {
-- 
1.8.4.2

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCHv3 spice-gtk 08/14] Fill g_proxy_address_new() with protocol, user and password

2014-02-17 Thread Marc-André Lureau
This way, the call might eventually support more proxy and
authentication.
---
 gtk/spice-session.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/gtk/spice-session.c b/gtk/spice-session.c
index 475306a..975fd7b 100644
--- a/gtk/spice-session.c
+++ b/gtk/spice-session.c
@@ -1724,8 +1724,11 @@ static void proxy_lookup_ready(GObject *source_object, 
GAsyncResult *result,
 
 for (it = addresses; it != NULL; it = it->next) {
 address = g_proxy_address_new(G_INET_ADDRESS(it->data),
-  spice_proxy_get_port(open_host->proxy), 
"http",
-  s->host, open_host->port, NULL, NULL);
+  spice_proxy_get_port(open_host->proxy),
+  
spice_proxy_get_protocol(open_host->proxy),
+  s->host, open_host->port,
+  spice_proxy_get_user(open_host->proxy),
+  
spice_proxy_get_password(open_host->proxy));
 if (address != NULL)
 break;
 }
-- 
1.8.4.2

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCHv3 spice-gtk 04/14] proxy: parse user and pass from uri

2014-02-17 Thread Marc-André Lureau
---
 gtk/spice-proxy.c | 22 +-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/gtk/spice-proxy.c b/gtk/spice-proxy.c
index 7711e83..8613469 100644
--- a/gtk/spice-proxy.c
+++ b/gtk/spice-proxy.c
@@ -19,6 +19,7 @@
 #include 
 #include 
 
+#include "glib-compat.h"
 #include "spice-client.h"
 #include "spice-proxy.h"
 
@@ -78,6 +79,18 @@ gboolean spice_proxy_parse(SpiceProxy *self, const gchar 
*proxyuri, GError **err
 spice_proxy_set_protocol(self, "http");
 spice_proxy_set_port(self, 3128);
 
+/* yes, that parser is bad, we need GUri... */
+if (strstr(uri, "@")) {
+gchar *saveptr, *saveptr2;
+gchar *next = strstr(uri, "@") + 1;
+gchar *auth = strtok_r(uri, "@", &saveptr);
+const gchar *user = strtok_r(auth, ":", &saveptr2);
+const gchar *pass = strtok_r(NULL, ":", &saveptr2);
+spice_proxy_set_user(self, user);
+spice_proxy_set_password(self, pass);
+uri = next;
+}
+
 /* max 2 parts, host:port */
 gchar **proxyv = g_strsplit(uri, ":", 2);
 const gchar *proxy_port = NULL;
@@ -303,7 +316,14 @@ gchar* spice_proxy_to_string(SpiceProxy* self)
 if (p->protocol == NULL || p->hostname == NULL)
 return NULL;
 
-return g_strdup_printf("%s://%s:%u", p->protocol, p->hostname, p->port);
+if (p->user || p->password)
+return g_strdup_printf("%s://%s:%s@%s:%u",
+   p->protocol,
+   p->user, p->password,
+   p->hostname, p->port);
+else
+return g_strdup_printf("%s://%s:%u",
+   p->protocol, p->hostname, p->port);
 }
 
 G_GNUC_INTERNAL
-- 
1.8.4.2

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCHv3 spice-gtk 11/14] channel: talk to giostream instead of gsocket

2014-02-17 Thread Marc-André Lureau
---
 gtk/spice-channel-priv.h |  2 ++
 gtk/spice-channel.c  | 53 +++-
 2 files changed, 41 insertions(+), 14 deletions(-)

diff --git a/gtk/spice-channel-priv.h b/gtk/spice-channel-priv.h
index 35704ea..f38156e 100644
--- a/gtk/spice-channel-priv.h
+++ b/gtk/spice-channel-priv.h
@@ -82,6 +82,8 @@ struct _SpiceChannelPrivate {
 SpiceOpenSSLVerify  *sslverify;
 GSocket *sock;
 GSocketConnection   *conn;
+GInputStream*in;
+GOutputStream   *out;
 
 #if HAVE_SASL
 sasl_conn_t *sasl_conn;
diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c
index 7bcb0b8..1b8ec10 100644
--- a/gtk/spice-channel.c
+++ b/gtk/spice-channel.c
@@ -763,7 +763,8 @@ static void spice_channel_flush_wire(SpiceChannel *channel,
 GIOCondition cond;
 
 while (offset < datalen) {
-int ret;
+gssize ret;
+GError *error = NULL;
 
 if (c->has_error) return;
 
@@ -779,9 +780,12 @@ static void spice_channel_flush_wire(SpiceChannel *channel,
 ret = -1;
 }
 } else {
-GError *error = NULL;
-ret = g_socket_send(c->sock, ptr+offset, datalen-offset,
-NULL, &error);
+#if GLIB_CHECK_VERSION(2, 28, 0)
+ret = 
g_pollable_output_stream_write_nonblocking(G_POLLABLE_OUTPUT_STREAM(c->out),
+ ptr+offset, 
datalen-offset, NULL, &error);
+#else
+ret = g_socket_send(c->sock, ptr+offset, datalen-offset, NULL, 
&error);
+#endif
 if (ret < 0) {
 if (g_error_matches(error, G_IO_ERROR, 
G_IO_ERROR_WOULD_BLOCK)) {
 cond = G_IO_OUT;
@@ -794,6 +798,7 @@ static void spice_channel_flush_wire(SpiceChannel *channel,
 }
 if (ret == -1) {
 if (cond != 0) {
+// TODO: should use 
g_pollable_input/output_stream_create_source() in 2.28 ?
 g_coroutine_socket_wait(&c->coroutine, c->sock, cond);
 continue;
 } else {
@@ -888,7 +893,7 @@ static void spice_channel_write_msg(SpiceChannel *channel, 
SpiceMsgOut *out)
 static int spice_channel_read_wire(SpiceChannel *channel, void *data, size_t 
len)
 {
 SpiceChannelPrivate *c = channel->priv;
-int ret;
+gssize ret;
 GIOCondition cond;
 
 reread:
@@ -908,7 +913,13 @@ reread:
 }
 } else {
 GError *error = NULL;
-ret = g_socket_receive(c->sock, data, len, NULL, &error);
+#if GLIB_CHECK_VERSION(2, 28, 0)
+ret = 
g_pollable_input_stream_read_nonblocking(G_POLLABLE_INPUT_STREAM(c->in),
+   data, len, NULL, 
&error);
+#else
+ret = g_socket_receive(c->sock,
+   data, len, NULL, &error);
+#endif
 if (ret < 0) {
 if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK)) {
 cond = G_IO_IN;
@@ -922,6 +933,7 @@ reread:
 
 if (ret == -1) {
 if (cond != 0) {
+// TODO: should use g_pollable_input/output_stream_create_source() 
?
 g_coroutine_socket_wait(&c->coroutine, c->sock, cond);
 goto reread;
 } else {
@@ -2067,9 +2079,12 @@ static void spice_channel_iterate_read(SpiceChannel 
*channel)
 /* treat all incoming data (block on message completion) */
 while (!c->has_error &&
c->state != SPICE_CHANNEL_STATE_MIGRATING &&
-   g_socket_condition_check(c->sock, G_IO_IN) & G_IO_IN) {
-
-do
+#if GLIB_CHECK_VERSION(2, 28, 0)
+   g_pollable_input_stream_is_readable(G_POLLABLE_INPUT_STREAM(c->in))
+#else
+   g_socket_condition_check(c->sock, G_IO_IN) & G_IO_IN
+#endif
+) { do
 spice_channel_recv_msg(channel,

(handler_msg_in)SPICE_CHANNEL_GET_CLASS(channel)->handle_msg, NULL);
 #if HAVE_SASL
@@ -2236,9 +2251,11 @@ static void *spice_channel_coroutine(void *data)
 
 g_socket_set_blocking(c->sock, FALSE);
 g_socket_set_keepalive(c->sock, TRUE);
+c->conn = g_socket_connection_factory_create_connection(c->sock);
 goto connected;
 }
 
+
 reconnect:
 c->conn = spice_session_channel_open_host(c->session, channel, &c->tls);
 if (c->conn == NULL) {
@@ -2299,7 +2316,11 @@ reconnect:
 }
 
 
+#if GLIB_CHECK_VERSION(2, 28, 0)
+BIO *bio = bio_new_giostream(G_IO_STREAM(c->conn));
+#else
 BIO *bio = bio_new_gsocket(c->sock);
+#endif
 SSL_set_bio(c->ssl, bio, bio);
 
 {
@@ -2330,6 +2351,9 @@ ssl_reconnect:
 }
 
 connected:
+c->in = g_io_stream_get_input_stream(G_IO_STREAM(c->conn));
+c->out = g_io_stream_get_output_stream(G_IO_STREAM(c->conn));
+
 rc = setsockopt(g_socket_get_fd(c->sock), IPPROTO_TCP, TCP_NODELAY,
 (const char*)&delay

[Spice-devel] [PATCHv3 spice-gtk 05/14] http-proxy: specify Basic scheme

2014-02-17 Thread Marc-André Lureau
Or Squid will fail with:
WARNING: Unsupported or unconfigured/inactive proxy-auth scheme
---
 gtk/wocky-http-proxy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gtk/wocky-http-proxy.c b/gtk/wocky-http-proxy.c
index d73990b..11f557e 100644
--- a/gtk/wocky-http-proxy.c
+++ b/gtk/wocky-http-proxy.c
@@ -98,7 +98,7 @@ create_request (GProxyAddress *proxy_address, gboolean 
*has_cred)
   base64_cred = g_base64_encode ((guchar *) cred, strlen (cred));
   g_free (cred);
   g_string_append_printf (request,
-  "Proxy-Authorization: %s\r\n",
+  "Proxy-Authorization: Basic %s\r\n",
   base64_cred);
   g_free (base64_cred);
 }
-- 
1.8.4.2

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCHv3 spice-gtk 09/14] openssl: learn to handle a new kind of BIO based on GIOStream

2014-02-17 Thread Marc-André Lureau
Although reusing BIO_new_socket() once again is a hack, it seems
to be the easiest way... The proper solution is certainly to start
using GTls instead, but that will require a glib 2.28 dep bump.
---
 gtk/Makefile.am |   4 +-
 gtk/bio-gio.c   | 135 
 gtk/bio-gio.h   |  34 +
 gtk/bio-gsocket.c   | 111 --
 gtk/bio-gsocket.h   |  30 
 gtk/spice-channel.c |   2 +-
 6 files changed, 172 insertions(+), 144 deletions(-)
 create mode 100644 gtk/bio-gio.c
 create mode 100644 gtk/bio-gio.h
 delete mode 100644 gtk/bio-gsocket.c
 delete mode 100644 gtk/bio-gsocket.h

diff --git a/gtk/Makefile.am b/gtk/Makefile.am
index a1a1e79..0740e96 100644
--- a/gtk/Makefile.am
+++ b/gtk/Makefile.am
@@ -212,8 +212,8 @@ USB_ACL_HELPER_SRCS =
 endif
 
 libspice_client_glib_2_0_la_SOURCES =  \
-   bio-gsocket.c   \
-   bio-gsocket.h   \
+   bio-gio.c   \
+   bio-gio.h   \
glib-compat.c   \
glib-compat.h   \
spice-audio.c   \
diff --git a/gtk/bio-gio.c b/gtk/bio-gio.c
new file mode 100644
index 000..22d58b6
--- /dev/null
+++ b/gtk/bio-gio.c
@@ -0,0 +1,135 @@
+/* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
+/*
+   Copyright (C) 2012 Red Hat, Inc.
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, see .
+*/
+
+#include 
+#include 
+
+#include "spice-util.h"
+#include "bio-gio.h"
+
+typedef struct bio_gsocket_method {
+BIO_METHOD method;
+#if GLIB_CHECK_VERSION(2, 28, 0)
+GIOStream *stream;
+#else
+GSocket *gsocket;
+#endif
+} bio_gsocket_method;
+
+#define BIO_GET_GSOCKET(bio)  (((bio_gsocket_method*)bio->method)->gsocket)
+#define BIO_GET_ISTREAM(bio)  
(g_io_stream_get_input_stream(((bio_gsocket_method*)bio->method)->stream))
+#define BIO_GET_OSTREAM(bio)  
(g_io_stream_get_output_stream(((bio_gsocket_method*)bio->method)->stream))
+
+static int bio_gio_write(BIO *bio, const char *in, int inl)
+{
+gssize ret;
+GError *error = NULL;
+
+#if GLIB_CHECK_VERSION(2, 28, 0)
+ret = 
g_pollable_output_stream_write_nonblocking(G_POLLABLE_OUTPUT_STREAM(BIO_GET_OSTREAM(bio)),
+#else
+ret = g_socket_send(BIO_GET_GSOCKET(bio),
+#endif
+in, inl, NULL, &error);
+BIO_clear_retry_flags(bio);
+
+if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK))
+BIO_set_retry_write(bio);
+if (error != NULL) {
+g_warning("%s", error->message);
+g_clear_error(&error);
+}
+
+return ret;
+}
+
+static int bio_gio_read(BIO *bio, char *out, int outl)
+{
+gssize ret;
+GError *error = NULL;
+
+#if GLIB_CHECK_VERSION(2, 28, 0)
+ret = 
g_pollable_input_stream_read_nonblocking(G_POLLABLE_INPUT_STREAM(BIO_GET_ISTREAM(bio)),
+#else
+ret = g_socket_receive(BIO_GET_GSOCKET(bio),
+#endif
+   out, outl, NULL, &error);
+BIO_clear_retry_flags(bio);
+
+if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK))
+BIO_set_retry_read(bio);
+else if (error != NULL)
+g_warning("%s", error->message);
+
+g_clear_error(&error);
+
+return ret;
+}
+
+static int bio_gio_destroy(BIO *bio)
+{
+if (bio == NULL || bio->method == NULL)
+return 0;
+
+SPICE_DEBUG("bio gsocket destroy");
+g_free(bio->method);
+bio->method = NULL;;
+
+return 1;
+}
+
+static int bio_gio_puts(BIO *bio, const char *str)
+{
+int n, ret;
+
+n = strlen(str);
+ret = bio_gio_write(bio, str, n);
+
+return ret;
+}
+
+G_GNUC_INTERNAL
+#if GLIB_CHECK_VERSION(2, 28, 0)
+BIO* bio_new_giostream(GIOStream *stream)
+{
+// TODO: make an actual new BIO type, or just switch to GTls already...
+BIO *bio = BIO_new_socket(-1, BIO_NOCLOSE);
+#else
+BIO* bio_new_gsocket(GSocket *gsocket)
+{
+BIO *bio = BIO_new_socket(g_socket_get_fd(gsocket), BIO_NOCLOSE);
+#endif
+
+bio_gsocket_method *bio_method = g_new(bio_gsocket_method, 1);
+bio_method->method = *bio->method;
+#if GLIB_CHECK_VERSION(2, 28, 0)
+bio_method->stream = stream;
+#else
+bio_method->gsocket = g

[Spice-devel] [PATCHv3 spice-gtk 07/14] http-proxy: add https proxy

2014-02-17 Thread Marc-André Lureau
This will require glib 2.28 for GTls support, atm
---
 gtk/spice-session.c|   3 +
 gtk/wocky-http-proxy.c | 161 ++---
 gtk/wocky-http-proxy.h |  14 +
 3 files changed, 155 insertions(+), 23 deletions(-)

diff --git a/gtk/spice-session.c b/gtk/spice-session.c
index 5d1c1c1..475306a 100644
--- a/gtk/spice-session.c
+++ b/gtk/spice-session.c
@@ -637,6 +637,9 @@ static void spice_session_class_init(SpiceSessionClass 
*klass)
 #if GLIB_CHECK_VERSION(2, 26, 0)
 _wocky_http_proxy_get_type();
 #endif
+#if GLIB_CHECK_VERSION(2, 28, 0)
+_wocky_https_proxy_get_type();
+#endif
 
 gobject_class->dispose  = spice_session_dispose;
 gobject_class->finalize = spice_session_finalize;
diff --git a/gtk/wocky-http-proxy.c b/gtk/wocky-http-proxy.c
index 11f557e..4226b10 100644
--- a/gtk/wocky-http-proxy.c
+++ b/gtk/wocky-http-proxy.c
@@ -1,7 +1,9 @@
  /* wocky-http-proxy.c: Source for WockyHttpProxy
  *
  * Copyright (C) 2010 Collabora, Ltd.
+ * Copyright (C) 2014 Red Hat, Inc.
  * @author Nicolas Dufresne 
+ * @author Marc-André Lureau 
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -180,9 +182,32 @@ wocky_http_proxy_connect (GProxy *proxy,
 {
   GInputStream *in;
   GOutputStream *out;
-  GDataInputStream *data_in;
-  gchar *buffer;
+  GDataInputStream *data_in = NULL;
+  gchar *buffer = NULL;
   gboolean has_cred;
+  GIOStream *tlsconn = NULL;
+
+#if GLIB_CHECK_VERSION(2, 28, 0)
+  if (WOCKY_IS_HTTPS_PROXY (proxy))
+{
+  tlsconn = g_tls_client_connection_new (io_stream,
+ 
G_SOCKET_CONNECTABLE(proxy_address),
+ error);
+  if (!tlsconn)
+  goto error;
+
+  GTlsCertificateFlags tls_validation_flags = 
G_TLS_CERTIFICATE_VALIDATE_ALL;
+#ifdef DEBUG
+  tls_validation_flags &= ~(G_TLS_CERTIFICATE_UNKNOWN_CA | 
G_TLS_CERTIFICATE_BAD_IDENTITY);
+#endif
+  g_tls_client_connection_set_validation_flags (G_TLS_CLIENT_CONNECTION 
(tlsconn),
+tls_validation_flags);
+  if (!g_tls_connection_handshake (G_TLS_CONNECTION (tlsconn), 
cancellable, error))
+  goto error;
+
+  io_stream = tlsconn;
+}
+#endif
 
   in = g_io_stream_get_input_stream (io_stream);
   out = g_io_stream_get_output_stream (io_stream);
@@ -215,12 +240,14 @@ wocky_http_proxy_connect (GProxy *proxy,
 
   g_free (buffer);
 
-  return g_object_ref (io_stream);
+  g_object_ref (io_stream);
+  g_clear_object (&tlsconn);
 
-error:
-  if (data_in != NULL)
-g_object_unref (data_in);
+  return io_stream;
 
+error:
+  g_clear_object (&tlsconn);
+  g_clear_object (&data_in);
   g_free (buffer);
   return NULL;
 }
@@ -291,6 +318,41 @@ do_write (GAsyncReadyCallback callback, ConnectAsyncData 
*data)
 }
 
 static void
+stream_connected (ConnectAsyncData *data,
+  GIOStream *io_stream)
+{
+  GInputStream *in;
+
+  data->io_stream = g_object_ref (io_stream);
+  in = g_io_stream_get_input_stream (io_stream);
+  data->data_in = g_data_input_stream_new (in);
+  g_filter_input_stream_set_close_base_stream (G_FILTER_INPUT_STREAM 
(data->data_in),
+   FALSE);
+
+  do_write (request_write_cb, data);
+}
+
+#if GLIB_CHECK_VERSION(2, 28, 0)
+static void
+handshake_completed (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+  GTlsConnection *conn = G_TLS_CONNECTION (source_object);
+  ConnectAsyncData *data = user_data;
+  GError *error = NULL;
+
+  if (!g_tls_connection_handshake_finish (conn, res, &error))
+{
+  complete_async_from_error (data, error);
+  return;
+}
+
+  stream_connected (data, G_IO_STREAM (conn));
+}
+#endif
+
+static void
 wocky_http_proxy_connect_async (GProxy *proxy,
 GIOStream *io_stream,
 GProxyAddress *proxy_address,
@@ -300,34 +362,55 @@ wocky_http_proxy_connect_async (GProxy *proxy,
 {
   GSimpleAsyncResult *simple;
   ConnectAsyncData *data;
-  GInputStream *in;
 
   simple = g_simple_async_result_new (G_OBJECT (proxy),
-  callback, user_data,
-  wocky_http_proxy_connect_async);
+  callback, user_data,
+  wocky_http_proxy_connect_async);
 
   data = g_slice_new0 (ConnectAsyncData);
-
-  data->simple = simple;
-  data->io_stream = g_object_ref (io_stream);
-
   if (cancellable != NULL)
 data->cancellable = g_object_ref (cancellable);
-
-  in = g_io_stream_get_input_stream (io_stream);
-
-  data->data_in = g_data_input_stream_new (in);
-  g_filter_input_stream_set_close_base_stream (G_FILTER_INPUT_STREAM 
(data->data_in),
-  FALSE);
-
-  g_simple_async_result_set_op_res_gpointer (simple, data,
-  (GDestroyNotify) free_connect_data);
+  data->simple = simple;
 
   data->buffer = create_

[Spice-devel] [PATCHv3 spice-gtk 06/14] spice-proxy: parse https protocol

2014-02-17 Thread Marc-André Lureau
---
 gtk/spice-proxy.c | 14 ++
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/gtk/spice-proxy.c b/gtk/spice-proxy.c
index 8613469..cf4b6ad 100644
--- a/gtk/spice-proxy.c
+++ b/gtk/spice-proxy.c
@@ -65,9 +65,17 @@ gboolean spice_proxy_parse(SpiceProxy *self, const gchar 
*proxyuri, GError **err
 uri = dup = g_strdup(proxyuri);
 /* FIXME: use GUri when it is ready... only support http atm */
 /* the code is voluntarily not parsing thoroughly the uri */
-if (g_ascii_strncasecmp("http://";, uri, 7) == 0)
+if (g_ascii_strncasecmp("http://";, uri, 7) == 0) {
 uri += 7;
-
+spice_proxy_set_protocol(self, "http");
+spice_proxy_set_port(self, 3128);
+} else if (g_ascii_strncasecmp("https://";, uri, 8) == 0) {
+uri += 8;
+spice_proxy_set_protocol(self, "https");
+spice_proxy_set_port(self, 3129);
+} else {
+return FALSE;
+}
 /* remove trailing slash */
 len = strlen(uri);
 for (; len > 0; len--)
@@ -76,8 +84,6 @@ gboolean spice_proxy_parse(SpiceProxy *self, const gchar 
*proxyuri, GError **err
 else
 break;
 
-spice_proxy_set_protocol(self, "http");
-spice_proxy_set_port(self, 3128);
 
 /* yes, that parser is bad, we need GUri... */
 if (strstr(uri, "@")) {
-- 
1.8.4.2

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCHv3 spice-gtk 01/14] compat: add strtok_r fallback

2014-02-17 Thread Marc-André Lureau
The following Spice proxy URI parsing code makes use of it, but it is
not available on Windows

Origin:
http://git.videolan.org/gitweb.cgi/vlc.git/?p=vlc.git;a=blob;f=compat/strtok_r.c
---
 configure.ac  |  2 +-
 gtk/glib-compat.c | 34 ++
 gtk/glib-compat.h |  8 
 3 files changed, 43 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 4dcd81c..3670863 100644
--- a/configure.ac
+++ b/configure.ac
@@ -235,7 +235,7 @@ else
 EXTERNAL_PNP_IDS="$with_pnp_ids_path"
 fi
 
-AC_CHECK_FUNCS(clearenv)
+AC_CHECK_FUNCS(clearenv strtok_r)
 
 PKG_CHECK_MODULES(GLIB2, glib-2.0 >= 2.22)
 AC_SUBST(GLIB2_CFLAGS)
diff --git a/gtk/glib-compat.c b/gtk/glib-compat.c
index 9ffadbb..5714173 100644
--- a/gtk/glib-compat.c
+++ b/gtk/glib-compat.c
@@ -1,5 +1,8 @@
 /* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
 /*
+   Copyright (C) 2012-2014 Red Hat, Inc.
+   Copyright © 1998-2009 VLC authors and VideoLAN
+
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
@@ -14,6 +17,7 @@
License along with this library; if not, see .
 */
 
+#include 
 #include "glib-compat.h"
 
 #if !GLIB_CHECK_VERSION(2,26,0)
@@ -105,3 +109,33 @@ guint64 g_get_monotonic_time(void)
 return (((gint64) tv.tv_sec) * 100) + tv.tv_usec;
 }
 #endif
+
+#ifndef HAVE_STRTOK_R
+G_GNUC_INTERNAL
+char *strtok_r(char *s, const char *delim, char **save_ptr)
+{
+char *token;
+
+if (s == NULL)
+s = *save_ptr;
+
+/* Scan leading delimiters. */
+s += strspn (s, delim);
+if (*s == '\0')
+return NULL;
+
+/* Find the end of the token. */
+token = s;
+s = strpbrk (token, delim);
+if (s == NULL)
+/* This token finishes the string. */
+*save_ptr = strchr (token, '\0');
+else
+{
+/* Terminate the token and make *SAVE_PTR point past it. */
+*s = '\0';
+*save_ptr = s + 1;
+}
+return token;
+}
+#endif
diff --git a/gtk/glib-compat.h b/gtk/glib-compat.h
index c30a735..62580e2 100644
--- a/gtk/glib-compat.h
+++ b/gtk/glib-compat.h
@@ -1,5 +1,8 @@
 /* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
 /*
+   Copyright (C) 2012-2014 Red Hat, Inc.
+   Copyright © 1998-2009 VLC authors and VideoLAN
+
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
@@ -18,6 +21,7 @@
 
 #include 
 #include 
+#include "config.h"
 
 #if !GLIB_CHECK_VERSION(2,26,0)
 #define G_DEFINE_BOXED_TYPE(TypeName, type_name, copy_func, free_func) 
G_DEFINE_BOXED_TYPE_WITH_CODE (TypeName, type_name, copy_func, free_func, {})
@@ -133,4 +137,8 @@ GType spice_main_context_get_type (void) G_GNUC_CONST;
 guint64 g_get_monotonic_time(void);
 #endif
 
+#ifndef HAVE_STRTOK_R
+char* strtok_r(char *s, const char *delim, char **save_ptr);
+#endif
+
 #endif /* GLIB_COMPAT_H */
-- 
1.8.4.2

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCHv3 spice-gtk 00/14] Add https + basic auth proxy support

2014-02-17 Thread Marc-André Lureau
Hi,

The following series allows to connect to an HTTPS proxy, with Basic
authentication.

It also introduce a get_error() function, currently used to permit
clients to ask for proxy credentials when required. A small patch for
this is ready to be submitted for virt-viewer.

In v3:
 - address last Christophe's comments from v2

Marc-André Lureau (14):
  compat: add strtok_r fallback
  proxy: split uri with : in only 2 parts
  proxy: add user and pass properties
  proxy: parse user and pass from uri
  http-proxy: specify Basic scheme
  spice-proxy: parse https protocol
  http-proxy: add https proxy
  Fill g_proxy_address_new() with protocol, user and password
  openssl: learn to handle a new kind of BIO based on GIOStream
  channel: simplify has error code
  channel: talk to giostream instead of gsocket
  Make SpiceURI a public API
  channel: add spice_channel_get_error()
  session: add spice_session_get_proxy_uri()

 configure.ac |   2 +-
 doc/reference/Makefile.am|   1 +
 doc/reference/spice-gtk-docs.xml |   1 +
 doc/reference/spice-gtk-sections.txt |  28 +++
 gtk/Makefile.am  |   9 +-
 gtk/bio-gio.c| 135 ++
 gtk/bio-gio.h|  34 +++
 gtk/bio-gsocket.c| 111 -
 gtk/bio-gsocket.h|  30 ---
 gtk/glib-compat.c|  34 +++
 gtk/glib-compat.h|   8 +
 gtk/map-file |  14 ++
 gtk/spice-channel-priv.h |   3 +
 gtk/spice-channel.c  | 113 ++---
 gtk/spice-channel.h  |   2 +
 gtk/spice-client.h   |   1 +
 gtk/spice-glib-sym-file  |  14 ++
 gtk/spice-proxy.c| 270 
 gtk/spice-proxy.h|  60 -
 gtk/spice-session-priv.h |   5 +-
 gtk/spice-session.c  |  50 ++--
 gtk/spice-session.h  |   2 +
 gtk/spice-uri-priv.h |  30 +++
 gtk/spice-uri.c  | 460 +++
 gtk/spice-uri.h  |  52 
 gtk/spicy.c  |   6 +
 gtk/wocky-http-proxy.c   | 163 +++--
 gtk/wocky-http-proxy.h   |  14 ++
 28 files changed, 1099 insertions(+), 553 deletions(-)
 create mode 100644 gtk/bio-gio.c
 create mode 100644 gtk/bio-gio.h
 delete mode 100644 gtk/bio-gsocket.c
 delete mode 100644 gtk/bio-gsocket.h
 delete mode 100644 gtk/spice-proxy.c
 delete mode 100644 gtk/spice-proxy.h
 create mode 100644 gtk/spice-uri-priv.h
 create mode 100644 gtk/spice-uri.c
 create mode 100644 gtk/spice-uri.h

-- 
1.8.4.2

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH spice-gtk] Add SpiceVMC GIOStream

2014-02-17 Thread Marc-André Lureau
On Wed, Feb 12, 2014 at 1:57 PM, Christophe Fergeau  wrote:
> On Tue, Feb 11, 2014 at 06:52:49PM +0100, Marc-André Lureau wrote:
>> This allows to use conveniently GIOStream APIs without caring about
>> coroutine and Spice messages details.
>> ---
>>  gtk/Makefile.am |   2 +
>>  gtk/vmcstream.c | 532 
>> 
>>  gtk/vmcstream.h |  81 +
>>  3 files changed, 615 insertions(+)
>>  create mode 100644 gtk/vmcstream.c
>>  create mode 100644 gtk/vmcstream.h
>>
>> diff --git a/gtk/Makefile.am b/gtk/Makefile.am
>> index 62afd36..7ceb22f 100644
>> --- a/gtk/Makefile.am
>> +++ b/gtk/Makefile.am
>> @@ -255,6 +255,8 @@ libspice_client_glib_2_0_la_SOURCES =
>>  \
>>   usbutil.c   \
>>   usbutil.h   \
>>   $(USB_ACL_HELPER_SRCS)  \
>> + vmcstream.c \
>> + vmcstream.h \
>>   \
>>   decode.h\
>>   decode-glz.c\
>> diff --git a/gtk/vmcstream.c b/gtk/vmcstream.c
>> new file mode 100644
>> index 000..f92f8b7
>> --- /dev/null
>> +++ b/gtk/vmcstream.c
>> @@ -0,0 +1,532 @@
>> +/* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
>> +/*
>> +  Copyright (C) 2013 Red Hat, Inc.
>> +
>> +  This library is free software; you can redistribute it and/or
>> +  modify it under the terms of the GNU Lesser General Public
>> +  License as published by the Free Software Foundation; either
>> +  version 2.1 of the License, or (at your option) any later version.
>> +
>> +  This library is distributed in the hope that it will be useful,
>> +  but WITHOUT ANY WARRANTY; without even the implied warranty of
>> +  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
>> +  Lesser General Public License for more details.
>> +
>> +  You should have received a copy of the GNU Lesser General Public
>> +  License along with this library; if not, see 
>> .
>> +*/
>> +#include 
>> +
>> +#include "vmcstream.h"
>> +#include "spice-channel-priv.h"
>> +#include "gio-coroutine.h"
>> +
>> +struct _SpiceVmcInputStream
>> +{
>> +GInputStream parent_instance;
>> +GSimpleAsyncResult *result;
>> +struct coroutine *coroutine;
>> +
>> +SpiceChannel *channel;
>> +gboolean all;
>> +guint8 *buffer;
>> +gsize count;
>> +gsize pos;
>> +
>> +GCancellable *cancellable;
>> +gulong cancel_id;
>> +};
>> +
>> +struct _SpiceVmcInputStreamClass
>> +{
>> +GInputStreamClass parent_class;
>> +};
>> +
>> +static gssize   spice_vmc_input_stream_read(GInputStream
>> *stream,
>> +void
>> *buffer,
>> +gsize
>> count,
>> +GCancellable
>> *cancellable,
>> +GError 
>> **error);
>> +static void spice_vmc_input_stream_read_async  (GInputStream
>> *stream,
>> +void
>> *buffer,
>> +gsize
>> count,
>> +int  
>> io_priority,
>> +GCancellable
>> *cancellable,
>> +GAsyncReadyCallback  
>> callback,
>> +gpointer 
>> user_data);
>> +static gssize   spice_vmc_input_stream_read_finish (GInputStream
>> *stream,
>> +GAsyncResult
>> *result,
>> +GError 
>> **error);
>> +static gssize   spice_vmc_input_stream_skip(GInputStream
>> *stream,
>> +gsize
>> count,
>> +GCancellable
>> *cancellable,
>> +GError 
>> **error);
>> +static gboolean spice_vmc_input_stream_close   (GInputStream
>> *stream,
>> +GCancellable
>> *cancellable,
>> +GError 
>> **error);
>> +
>> +G_DEFINE_TYPE(SpiceVmcInputStream, spice_vmc_input_stream, 
>> G_TYPE_INPUT_STREAM)
>> +
>> +
>> +static void
>> +spice_vmc_input_stream_class_init(SpiceVmcInputStreamClass *klass)
>> +{
>> +GInputStreamClass *istream_class;
>> +
>>

[Spice-devel] Multi-monitor and fullscreen in virt-viewer

2014-02-17 Thread Jonathon Jongsma
Hello all,

Recently I've been trying to improve the multimonitor situation in virt-viewer. 
However, one of the challenges is that the behavior of virt-viewer is not very 
well-specified at the moment.  This means that it's not always easy to 
determine whether certain behavior is intentional or whether it's a bug.  I'm 
attempting to improve that situation little by little.  My first focus is 
specifying the behavior of virt-viewer when it is started in full-screen 
(auto-conf) mode.  I've come up with a set of requirements (see file 
'multimonitor-requirements') for fullscreen / multimonitor mode.  I understand 
that the way I've written these requirements is perhaps a bit formal and 
strange, but I hope that they're understandable at least.  If not, please ask 
for clarification. 

Part of this proposal includes a limited ability to configure what monitors are 
used in fullscreen mode.  I've introduced a simple configuration file format to 
attempt to allow people to be able to specify which monitors to use. For 
example, perhaps they want full-screen mode to use monitors 2 and 3, but leave 
monitor 1 for their local work.  The requirements for this are included in the 
aforementioned file, and in addition, the attached file 
'multimonitor-fullscreen-settings' demonstrates the proposed format of the 
configuration file.  Note that I'm not proposing any UI to manage this 
configuration -- at the moment the configuration must be specified by manually 
editing the settings file.

If anybody has any opinions on any of the above, let me know.

Jonathon


multimonitor-requirements-1
Description: Binary data


multimonitor-fullscreen-settings-1
Description: Binary data
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] How to start with Spice Development?

2014-02-17 Thread Jeremy White

On 02/17/2014 08:44 AM, Alf G. wrote:

Hi,

I am very interested to delve into spice and perhaps do some work on it.
What is the best way to start? Can I use the documents on
spice-space.org/documentation.html
 as base or are they not at
all up to date? Is the spice-project written in pure C or also are there
C++ parts?


That's great, and welcome!

I think the documentation is pretty out of date.  It's certainly a good 
start, and the core concepts in the protocol haven't changed, but the 
web site is well behind the code.


The code is mostly C; there is a (deprecated) client written in C++. 
There is also a Javascript web client.


I'd recommend that your first action is to pick an interesting use case, 
and get it working with code from git.  So either qemu + windows guest, 
or qemu + linux guest, or pure Xspice.


From there, it gets trickier.  I don't think we have a set of 'easy' 
projects to start with.  The links on the devel page don't take you to a 
list of open bugs, but this link should work:


https://bugs.freedesktop.org/buglist.cgi?query_format=specific&order=relevance%20desc&bug_status=__open__&product=Spice

Most Spice developers work for Red Hat, and they have internal bug 
trackers as well that track their priorities.  But I have found them to 
be quite friendly and welcoming.  They're often helpful on the #spice 
channel on irc as well.


Cheers,

Jeremy
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] spice: connection refused

2014-02-17 Thread Sean Darcy

On 02/17/2014 06:37 AM, Marian Krcmarik wrote:



- Original Message -

From: "Sean Darcy" 
To: spice-devel@lists.freedesktop.org
Sent: Monday, February 17, 2014 12:25:36 AM
Subject: Re: [Spice-devel] spice: connection refused

On 02/16/2014 05:11 PM, Marian Krcmarik wrote:



- Original Message -

From: "Sean Darcy" 
To: spice-devel@lists.freedesktop.org
Sent: Sunday, February 16, 2014 8:50:19 PM
Subject: Re: [Spice-devel] spice: connection refused

On 02/16/2014 12:10 PM, Sean Darcy wrote:

I'm trying to connect to a windows guest on an Fedora 19 host from a
Fedora 19 client.

remote-viewer spice://10.10.11.100:5972

(remote-viewer:19994): GSpice-WARNING **: Could not connect to
10.10.11.100: Connection refused

virt-viewer-0.5.6-1.fc19.x86_64

xml for the guest has:



Not sure how you troubleshoot this. I can ssh into the host, and connect
to the guest with vnc.

On the F19 host:

qemu-1.6.1-2.fc19.x86_64
rpm -qa | grep spice | sort
spice-glib-0.20-6.fc19.x86_64
spice-glib-devel-0.20-6.fc19.x86_64
spice-gtk-0.20-6.fc19.x86_64
spice-gtk3-0.20-6.fc19.x86_64
spice-gtk3-devel-0.20-6.fc19.x86_64
spice-gtk-devel-0.20-6.fc19.x86_64
spice-gtk-python-0.20-6.fc19.x86_64
spice-gtk-tools-0.20-6.fc19.x86_64
spice-parent-15-9.fc19.noarch
spice-protocol-0.12.6-1.fc19.noarch
spice-server-0.12.4-3.fc19.x86_64
spice-vdagent-0.14.0-5.fc19.x86_64
spice-xpi-2.8-3.fc19.x86_64

On the Windows 2008R2 guest:

virtio-win-0.1-74.iso
spice guest tools 0.74

Any help appreciated.

sean


On F19 host:
libvirt-1.1.3.2-1.fc19.x86_64


And from the log file on the host:

-spice port=5972,addr=127.0.0.1,disable-ticketing,seamless-migration=on


You specified the spice server to be binded only on localhost:5972 (the
option addr=127.0.0.1) but you are trying to connect to 10.10.11.100:5972,
so If you use only localhost connection (the host and client is the same
machine) try - "remote-viewer spice://localhost:5972" otherwise specify
correct IP address for your spice server to be binded on, try to edit the
domain xml to something like:



and then "remote-viewer spice://10.10.11.100:5972"
You can use address 0.0.0.0 as wildcard for all interfaces.



sean

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel



Hmm. OK, I'll try that. Just to be clear the F19 host is 10.10.11.100.
But to connect remotely, I need to specify the ip address of the host in
the guest xml file? Does this mean I could not connect to the guest from
the host? (which probably doesn't matter to us, but seems odd.)

You could, just use the IP address where the spice server listens, if you 
specify 127.0.0.1 then use 127.0.0.1 which of course will not be accessible 
remotely, or specify 10.10.11.100 and you can connect from your local network 
including localhost. The best for you would be probably to specify wildcard 
0.0.0.0 and spice-server will be listening on all interfaces.


The guest network is bridged, and the guest has an ip address of
10.10.11.70. Would it be better to specify the _guest's_ address? That
way, I assume, I could connect from the host.

Thanks for the prompt reply.

sean

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel



Success! With the address set to 10.10.11.100 I could connect remotely. 
With the address set to 0,0.0.0 I could connect both remotely and locally.


For anybody doing this again though, use this as the graphics xml stanza:


 


Note the lack of a front slash at the end of the first line!

sean

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH win-vdagent] Learn to build spice-vdagent MSI installer

2014-02-17 Thread Marc-André Lureau
---
 Makefile.am  | 23 +++-
 configure.ac | 30 
 spice-vdagent.wxs.in | 78 
 3 files changed, 130 insertions(+), 1 deletion(-)
 create mode 100644 spice-vdagent.wxs.in

diff --git a/Makefile.am b/Makefile.am
index 749ef56..9fa9f14 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,4 +1,5 @@
 NULL =
+EXTRA_DIST =
 MAINTAINERCLEANFILES =
 
 DIST_SUBDIRS = spice-protocol
@@ -61,8 +62,28 @@ vdservice_rc.$(OBJEXT): vdservice/vdservice.rc
 
 MAINTAINERCLEANFILES += vdservice_rc.$(OBJEXT)
 
+deps.txt:
+   $(AM_V_GEN)rpm -qa | grep $(host_os) | sort | unix2dos > $@
 
-EXTRA_DIST =   \
+MANUFACTURER = The Spice Project
+
+EXTRA_DIST += spice-vdagent.wxs.in
+CONFIG_STATUS_DEPENDENCIES = spice-vdagent.wxs.in
+
+spice-vdagent-$(WIXL_ARCH)-$(VERSION)$(BUILDID).msi: spice-vdagent.wxs 
deps.txt all
+   $(AM_V_GEN)DESTDIR=`mktemp -d`&&\
+   make -C $(top_builddir) install DESTDIR=$$DESTDIR >/dev/null && \
+   MANUFACTURER="$(MANUFACTURER)" wixl -D SourceDir=$(prefix)  \
+ -D DESTDIR=$$DESTDIR$(prefix) \
+ --arch $(WIXL_ARCH)  -o $@ $<
+
+msi: spice-vdagent-$(WIXL_ARCH)-$(VERSION)$(BUILDID).msi
+
+CLEANFILES = spice-vdagent-$(WIXL_ARCH)-$(VERSION)$(BUILDID).msi
+
+.PHONY: msi
+
+EXTRA_DIST +=  \
$(top_srcdir)/.version  \
tests/clipboard.py  \
vdagent.sln \
diff --git a/configure.ac b/configure.ac
index 12329b4..7f6511d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -9,11 +9,30 @@ AC_CONFIG_SRCDIR([vdagent])
 AC_CONFIG_HEADERS([config.h])
 AC_CONFIG_MACRO_DIR([m4])
 AC_CONFIG_AUX_DIR([build-aux])
+AC_CANONICAL_HOST
 
 AM_INIT_AUTOMAKE([1.11 foreign subdir-objects no-dist-gzip dist-xz tar-ustar])
 
 AM_SILENT_RULES([yes])
 
+AC_ARG_WITH([buildid],
+AS_HELP_STRING([--with-buildid=id], [Set additional build version details]))
+AC_DEFINE_UNQUOTED([BUILDID], "$with_buildid", [Build version details])
+if test "x$with_buildid" != x; then
+  AC_SUBST([BUILDID], "-$with_buildid")
+fi
+
+major=`echo $PACKAGE_VERSION | cut -d. -f1`
+minor=`echo $PACKAGE_VERSION | cut -d. -f2`
+micro=`echo $PACKAGE_VERSION | cut -d. -f3`
+buildid=`echo $with_buildid | cut -d. -f1`
+if test "x$buildid" = x; then
+  buildid=0
+fi
+build=`expr $micro \* 256 + $buildid`
+WINDOWS_PRODUCTVERSION="$major.$minor.$build"
+AC_SUBST([WINDOWS_PRODUCTVERSION])
+
 # Check for programs
 AC_PROG_CC
 AC_PROG_CXX
@@ -21,6 +40,16 @@ AM_PROG_CC_C_O
 AC_PROG_INSTALL
 AC_CHECK_TOOL(WINDRES, [windres])
 
+case "$host" in
+amd64*|x86_64*)
+  WIXL_ARCH="x64"
+;;
+*)
+  WIXL_ARCH="x86"
+;;
+esac
+AC_SUBST(WIXL_ARCH)
+
 AC_ARG_ENABLE([debug],
 AS_HELP_STRING([--enable-debug], [Enable debugging]))
 
@@ -75,6 +104,7 @@ AC_CONFIG_SUBDIRS([spice-protocol])
 AC_CONFIG_FILES([
 Makefile
 mingw-spice-vdagent.spec
+spice-vdagent.wxs
 ])
 AC_OUTPUT
 
diff --git a/spice-vdagent.wxs.in b/spice-vdagent.wxs.in
new file mode 100644
index 000..060f33d
--- /dev/null
+++ b/spice-vdagent.wxs.in
@@ -0,0 +1,78 @@
+
+
+http://schemas.microsoft.com/wix/2006/wi";>
+
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+
+  
+
+
+
+
+http://www.spice-space.org"/>
+
+
+
+  
+  
+
+NOT 
NEWERVERSIONDETECTED
+
+  
+
+
+
+  
+
+  
+
+  
+
+
+  
+  
+  
+
+  
+  
+
+  
+
+  
+
+
+
+  
+  
+  
+
+
+  
+
-- 
1.8.4.2

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] How to start with Spice Development?

2014-02-17 Thread Alf G.
Hi,

I am very interested to delve into spice and perhaps do some work on it.
What is the best way to start? Can I use the documents on
spice-space.org/documentation.html as base or are they not at all up to
date? Is the spice-project written in pure C or also are there C++ parts?

Thanks
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [patch]spice-gtk: encoding problem when drag a file from client to guest

2014-02-17 Thread Marc-André Lureau


- Original Message -
> On Mon, Feb 17, 2014 at 8:47 PM, Marc-André Lureau 
> wrote:
> > Hi
> >
> > - Original Message -
> >> hi, here's my environment:
> >> client: win7(default encoding is GBK)
> >> guest the same with client
> >> spice-gtk-0.23d
> >>
> >> a file in guest with a name of Chinese
> >> the file name is wrong when drag it to guest desktop
> >> (I think Japanese and Korean have the same problem )
> >>
> >> the following is my patch to " spice-gtk-0.23/gtk/channel-main.c"
> >>
> >> Regards
> >>
> >> --- spice-gtk-0.23/gtk/channel-main.c 2014-02-06 19:08:07.0 +0800
> >> +++ spice-gtk-0.23_modified/gtk/channel-main.c 2014-02-17
> >> 20:12:55.037816310
> >> +0800
> >> @@ -2786,8 +2786,10 @@
> >>
> >> /* File name */
> >> basename = g_file_get_basename(file);
> >> - g_key_file_set_string(keyfile, "vdagent-file-xfer", "name", basename);
> >
> > From glib API reference, I understand basename is a byte string of
> > unspecified encoding.
> >
> unspecified encoding == "utf-8" or unspecified encoding  == locale encoding?
> do you mean locale encoding?

From API doc, 
https://developer.gnome.org/gio/stable/GFile.html#g-file-get-basename :

"
The base name is a byte string (not UTF-8). It has no defined encoding or rules 
other than it may not contain zero bytes. If you want to use filenames in a 
user interface you should use the display name that you can get by requesting 
the G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME attribute with g_file_query_info().
"

> >> + gchar *basename_loc = g_locale_from_utf8(basename, -1, NULL, NULL,
> >> NULL);
> >
> > So this is probably wrong. You should also check for errors.
> 
> yeah, actually, i use g_convert(basename, -1, "gbk", "utf-8", ...) to
> get a right result
> but I don't think it's a general case, so patch it with
> g_locale_from_utf8(...)
> I'll keep testing to Confirm the problem
> 
> > Instead, I think we should use g_file_info_get_display_name()
> thx, I'd try
> >> + g_key_file_set_string(keyfile, "vdagent-file-xfer", "name",
> >> basename_loc);
> >> g_free(basename);
> >> + g_free(basename_loc);
> >> /* File size */
> >> g_key_file_set_uint64(keyfile, "vdagent-file-xfer", "size",
> >> task->file_size);
> >>
> >
> > Can you send patches using git-send-email (inline by default) or as
> > attachments?
> 
> sorry, it's my first time to send a patch in mail list, thank you for Remind
> :)

Great! Welcome! Feel free to join and ask questions on spice irc channel if you 
need further help. 

> > thanks
> ___
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
> 
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [patch]spice-gtk: encoding problem when drag a file from client to guest

2014-02-17 Thread Cody Chan
On Mon, Feb 17, 2014 at 8:47 PM, Marc-André Lureau  wrote:
> Hi
>
> - Original Message -
>> hi, here's my environment:
>> client: win7(default encoding is GBK)
>> guest the same with client
>> spice-gtk-0.23d
>>
>> a file in guest with a name of Chinese
>> the file name is wrong when drag it to guest desktop
>> (I think Japanese and Korean have the same problem )
>>
>> the following is my patch to " spice-gtk-0.23/gtk/channel-main.c"
>>
>> Regards
>>
>> --- spice-gtk-0.23/gtk/channel-main.c 2014-02-06 19:08:07.0 +0800
>> +++ spice-gtk-0.23_modified/gtk/channel-main.c 2014-02-17 20:12:55.037816310
>> +0800
>> @@ -2786,8 +2786,10 @@
>>
>> /* File name */
>> basename = g_file_get_basename(file);
>> - g_key_file_set_string(keyfile, "vdagent-file-xfer", "name", basename);
>
> From glib API reference, I understand basename is a byte string of 
> unspecified encoding.
>
unspecified encoding == "utf-8" or unspecified encoding  == locale encoding?
do you mean locale encoding?
>> + gchar *basename_loc = g_locale_from_utf8(basename, -1, NULL, NULL, NULL);
>
> So this is probably wrong. You should also check for errors.

yeah, actually, i use g_convert(basename, -1, "gbk", "utf-8", ...) to
get a right result
but I don't think it's a general case, so patch it with g_locale_from_utf8(...)
I'll keep testing to Confirm the problem

> Instead, I think we should use g_file_info_get_display_name()
thx, I'd try
>> + g_key_file_set_string(keyfile, "vdagent-file-xfer", "name", basename_loc);
>> g_free(basename);
>> + g_free(basename_loc);
>> /* File size */
>> g_key_file_set_uint64(keyfile, "vdagent-file-xfer", "size", task->file_size);
>>
>
> Can you send patches using git-send-email (inline by default) or as 
> attachments?

sorry, it's my first time to send a patch in mail list, thank you for Remind :)
> thanks
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [patch]spice-gtk: encoding problem when drag a file from client to guest

2014-02-17 Thread Marc-André Lureau
Hi

- Original Message -
> hi, here's my environment:
> client: win7(default encoding is GBK)
> guest the same with client
> spice-gtk-0.23d
> 
> a file in guest with a name of Chinese
> the file name is wrong when drag it to guest desktop
> (I think Japanese and Korean have the same problem )
> 
> the following is my patch to " spice-gtk-0.23/gtk/channel-main.c"
> 
> Regards
> 
> --- spice-gtk-0.23/gtk/channel-main.c 2014-02-06 19:08:07.0 +0800
> +++ spice-gtk-0.23_modified/gtk/channel-main.c 2014-02-17 20:12:55.037816310
> +0800
> @@ -2786,8 +2786,10 @@
> 
> /* File name */
> basename = g_file_get_basename(file);
> - g_key_file_set_string(keyfile, "vdagent-file-xfer", "name", basename);

>From glib API reference, I understand basename is a byte string of unspecified 
>encoding.

> + gchar *basename_loc = g_locale_from_utf8(basename, -1, NULL, NULL, NULL);

So this is probably wrong. You should also check for errors.

Instead, I think we should use g_file_info_get_display_name()

> + g_key_file_set_string(keyfile, "vdagent-file-xfer", "name", basename_loc);
> g_free(basename);
> + g_free(basename_loc);
> /* File size */
> g_key_file_set_uint64(keyfile, "vdagent-file-xfer", "size", task->file_size);
> 

Can you send patches using git-send-email (inline by default) or as attachments?

thanks
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [patch]spice-gtk: encoding problem when drag a file from client to guest

2014-02-17 Thread Cody Chan
hi, here's my environment:
client: win7(default encoding is GBK)
guest the same with client
spice-gtk-0.23d

a file in guest with a name of Chinese
the file name is wrong when drag it to guest desktop
(I think Japanese and Korean have the same problem)

the following is my patch to "spice-gtk-0.23/gtk/channel-main.c"

Regards

--- spice-gtk-0.23/gtk/channel-main.c   2014-02-06 19:08:07.0 +0800
+++ spice-gtk-0.23_modified/gtk/channel-main.c  2014-02-17
20:12:55.037816310 +0800
@@ -2786,8 +2786,10 @@

 /* File name */
 basename = g_file_get_basename(file);
-g_key_file_set_string(keyfile, "vdagent-file-xfer", "name", basename);
+gchar *basename_loc = g_locale_from_utf8(basename, -1, NULL, NULL,
NULL);
+g_key_file_set_string(keyfile, "vdagent-file-xfer", "name",
basename_loc);
 g_free(basename);
+g_free(basename_loc);
 /* File size */
 g_key_file_set_uint64(keyfile, "vdagent-file-xfer", "size",
task->file_size);
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [spice-gtk] build-sys: Don't build tests when not building static libs

2014-02-17 Thread Marc-André Lureau
ack

- Original Message -
> The tests rely on static linking in order to get access to symbols which
> are not exported in spice-gtk shared libraries. When build of static
> libraries is disabled with --disable-static, we should not attempt to build
> the tests as this will result in link errors.
> ---
>  Makefile.am  | 6 +-
>  configure.ac | 2 ++
>  2 files changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/Makefile.am b/Makefile.am
> index ab10f5f..8add19f 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -1,7 +1,11 @@
>  ACLOCAL_AMFLAGS = -I m4
>  NULL =
>  
> -SUBDIRS = spice-common gtk po doc data tests
> +SUBDIRS = spice-common gtk po doc data
> +
> +if BUILD_TESTS
> +SUBDIRS += tests
> +endif
>  
>  if HAVE_INTROSPECTION
>  if WITH_VALA
> diff --git a/configure.ac b/configure.ac
> index 24416a9..e2dd742 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -696,6 +696,8 @@ AC_SUBST(SPICE_GTK_REQUIRES)
>  
>  m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
>  
> +AM_CONDITIONAL([BUILD_TESTS], [test x"$enable_static" = xyes])
> +
>  AC_OUTPUT([
>  Makefile
>  spice-client-glib-2.0.pc
> --
> 1.8.5.3
> 
> ___
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
> 
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] spice: connection refused

2014-02-17 Thread Marian Krcmarik


- Original Message -
> From: "Sean Darcy" 
> To: spice-devel@lists.freedesktop.org
> Sent: Monday, February 17, 2014 12:25:36 AM
> Subject: Re: [Spice-devel] spice: connection refused
> 
> On 02/16/2014 05:11 PM, Marian Krcmarik wrote:
> >
> >
> > - Original Message -
> >> From: "Sean Darcy" 
> >> To: spice-devel@lists.freedesktop.org
> >> Sent: Sunday, February 16, 2014 8:50:19 PM
> >> Subject: Re: [Spice-devel] spice: connection refused
> >>
> >> On 02/16/2014 12:10 PM, Sean Darcy wrote:
> >>> I'm trying to connect to a windows guest on an Fedora 19 host from a
> >>> Fedora 19 client.
> >>>
> >>> remote-viewer spice://10.10.11.100:5972
> >>>
> >>> (remote-viewer:19994): GSpice-WARNING **: Could not connect to
> >>> 10.10.11.100: Connection refused
> >>>
> >>> virt-viewer-0.5.6-1.fc19.x86_64
> >>>
> >>> xml for the guest has:
> >>>
> >>> 
> >>>
> >>> Not sure how you troubleshoot this. I can ssh into the host, and connect
> >>> to the guest with vnc.
> >>>
> >>> On the F19 host:
> >>>
> >>> qemu-1.6.1-2.fc19.x86_64
> >>> rpm -qa | grep spice | sort
> >>> spice-glib-0.20-6.fc19.x86_64
> >>> spice-glib-devel-0.20-6.fc19.x86_64
> >>> spice-gtk-0.20-6.fc19.x86_64
> >>> spice-gtk3-0.20-6.fc19.x86_64
> >>> spice-gtk3-devel-0.20-6.fc19.x86_64
> >>> spice-gtk-devel-0.20-6.fc19.x86_64
> >>> spice-gtk-python-0.20-6.fc19.x86_64
> >>> spice-gtk-tools-0.20-6.fc19.x86_64
> >>> spice-parent-15-9.fc19.noarch
> >>> spice-protocol-0.12.6-1.fc19.noarch
> >>> spice-server-0.12.4-3.fc19.x86_64
> >>> spice-vdagent-0.14.0-5.fc19.x86_64
> >>> spice-xpi-2.8-3.fc19.x86_64
> >>>
> >>> On the Windows 2008R2 guest:
> >>>
> >>> virtio-win-0.1-74.iso
> >>> spice guest tools 0.74
> >>>
> >>> Any help appreciated.
> >>>
> >>> sean
> >>>
> >> On F19 host:
> >> libvirt-1.1.3.2-1.fc19.x86_64
> >>
> >>
> >> And from the log file on the host:
> >>
> >> -spice port=5972,addr=127.0.0.1,disable-ticketing,seamless-migration=on
> >
> > You specified the spice server to be binded only on localhost:5972 (the
> > option addr=127.0.0.1) but you are trying to connect to 10.10.11.100:5972,
> > so If you use only localhost connection (the host and client is the same
> > machine) try - "remote-viewer spice://localhost:5972" otherwise specify
> > correct IP address for your spice server to be binded on, try to edit the
> > domain xml to something like:
> > 
> >
> > 
> > and then "remote-viewer spice://10.10.11.100:5972"
> > You can use address 0.0.0.0 as wildcard for all interfaces.
> >
> >>
> >> sean
> >>
> >> ___
> >> Spice-devel mailing list
> >> Spice-devel@lists.freedesktop.org
> >> http://lists.freedesktop.org/mailman/listinfo/spice-devel
> >>
> 
> Hmm. OK, I'll try that. Just to be clear the F19 host is 10.10.11.100.
> But to connect remotely, I need to specify the ip address of the host in
> the guest xml file? Does this mean I could not connect to the guest from
> the host? (which probably doesn't matter to us, but seems odd.)
You could, just use the IP address where the spice server listens, if you 
specify 127.0.0.1 then use 127.0.0.1 which of course will not be accessible 
remotely, or specify 10.10.11.100 and you can connect from your local network 
including localhost. The best for you would be probably to specify wildcard 
0.0.0.0 and spice-server will be listening on all interfaces.
> 
> The guest network is bridged, and the guest has an ip address of
> 10.10.11.70. Would it be better to specify the _guest's_ address? That
> way, I assume, I could connect from the host.
> 
> Thanks for the prompt reply.
> 
> sean
> 
> ___
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
> 
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel