----- Original Message ----- > On Mon, Feb 03, 2014 at 07:02:34PM +0100, Marc-André Lureau wrote: > > From: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx> > > > > Someday this ought to be GURI.. or SoupUri? > > --- > > gtk/spice-proxy.c | 84 > > ++++++++++++++++++++++++++++++++++++++++++++++++++++- > > gtk/spice-proxy.h | 4 +++ > > gtk/spice-session.c | 2 +- > > 3 files changed, 88 insertions(+), 2 deletions(-) > > > > diff --git a/gtk/spice-proxy.c b/gtk/spice-proxy.c > > index bc4037e..834aa10 100644 > > --- a/gtk/spice-proxy.c > > +++ b/gtk/spice-proxy.c > > @@ -19,6 +19,7 @@ > > #include <stdlib.h> > > #include <string.h> > > > > +#include "glib-compat.h" > > #include "spice-client.h" > > #include "spice-proxy.h" > > > > @@ -26,6 +27,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 +38,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 > > }; > > @@ -74,7 +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); > > > > - gchar **proxyv = g_strsplit(uri, ":", 0); > > + gchar *saveptr, *auth = strtok_r(uri, "@", &saveptr); > > gchar *saveptr; > gchar *auth = strtok_r(uri, "@", &saveprtr); > ok > > + if (saveptr && *saveptr) { > > I don't think anything can be assumed about the value of saveptr. ok > if (auth != NULL) { ... } ? > > > + gchar *saveptr2; > > + 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); > > + g_debug("user: %s pass: %s", user, pass); > > + uri = saveptr; > > Same comment about using the value of saveptr. > > > + } > > + > > + gchar **proxyv = g_strsplit(uri, ":", 2); > > This does not seem to be strictly related to this change. You mean 0 -> 2.. ? ok... > > const gchar *proxy_port = NULL; > > > > if (proxyv[0] == NULL || strlen(proxyv[0]) == 0) { > > @@ -172,6 +188,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; > > @@ -192,6 +214,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; > > @@ -253,6 +281,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 > > @@ -268,3 +314,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); > > This needs to be freed in finalize(). ok > > > + 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); > > That too. > > > > + 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_string(SpiceProxy* self); > > +const gchar* spice_proxy_get_user(SpiceProxy* self); > > +void spice_proxy_set_user(SpiceProxy* self, const gchar* value); > > +const gchar* spice_proxy_get_password(SpiceProxy* self); > > +void spice_proxy_set_password(SpiceProxy* self, const gchar* value); > > > > G_END_DECLS > > > > diff --git a/gtk/spice-session.c b/gtk/spice-session.c > > index bcbba27..ae14a1f 100644 > > --- a/gtk/spice-session.c > > +++ b/gtk/spice-session.c > > @@ -1839,7 +1839,7 @@ GSocketConnection* > > spice_session_channel_open_host(SpiceSession *session, SpiceC > > #endif > > > > if (open_host.error != NULL) { > > - g_warning("%s", open_host.error->message); > > + g_warning("open host: %s", open_host.error->message); > > Unrelated. > ok, I'll push it as trivial seperately > Christophe > > _______________________________________________ > Spice-devel mailing list > Spice-devel@xxxxxxxxxxxxxxxxxxxxx > http://lists.freedesktop.org/mailman/listinfo/spice-devel > _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/spice-devel