|
|
22448f |
From 503a7925fcd71e7826322d32d4af6d1a36e2f03c Mon Sep 17 00:00:00 2001
|
|
|
22448f |
From: Marek Kasik <mkasik@redhat.com>
|
|
|
22448f |
Date: Fri, 20 Nov 2015 17:32:58 +0100
|
|
|
22448f |
Subject: [PATCH 1/2] Handle domain when looking for credentials
|
|
|
22448f |
|
|
|
22448f |
Add domain property to VinagreConnection and use it when looking for
|
|
|
22448f |
credentials if needed.
|
|
|
22448f |
Show default values for 'username' and 'domain' in authentication dialog
|
|
|
22448f |
if given.
|
|
|
22448f |
|
|
|
22448f |
https://bugzilla.gnome.org/show_bug.cgi?id=753355
|
|
|
22448f |
---
|
|
|
22448f |
data/vinagre.ui | 6 +--
|
|
|
22448f |
plugins/spice/vinagre-spice-tab.c | 4 ++
|
|
|
22448f |
plugins/vnc/vinagre-vnc-tab.c | 6 +--
|
|
|
22448f |
vinagre/vinagre-connection.c | 44 +++++++++++++++++
|
|
|
22448f |
vinagre/vinagre-connection.h | 4 ++
|
|
|
22448f |
vinagre/vinagre-ssh.c | 4 +-
|
|
|
22448f |
vinagre/vinagre-tab.c | 100 ++++++++++++++++++++++++++++----------
|
|
|
22448f |
vinagre/vinagre-tab.h | 1 +
|
|
|
22448f |
vinagre/vinagre-utils.vala | 34 +++++++++++++
|
|
|
22448f |
9 files changed, 169 insertions(+), 34 deletions(-)
|
|
|
22448f |
|
|
|
22448f |
diff --git a/data/vinagre.ui b/data/vinagre.ui
|
|
|
22448f |
index 8b3e7f3..3135336 100644
|
|
|
22448f |
--- a/data/vinagre.ui
|
|
|
22448f |
+++ b/data/vinagre.ui
|
|
|
22448f |
@@ -207,7 +207,7 @@ Jonh Wendell <jwendell@gnome.org></property>
|
|
|
22448f |
</child>
|
|
|
22448f |
<child>
|
|
|
22448f |
<object class="GtkLabel" id="domain_label">
|
|
|
22448f |
- <property name="visible">False</property>
|
|
|
22448f |
+ <property name="visible">True</property>
|
|
|
22448f |
<property name="can_focus">False</property>
|
|
|
22448f |
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
|
|
22448f |
<property name="margin_left">12</property>
|
|
|
22448f |
@@ -240,7 +240,7 @@ Jonh Wendell <jwendell@gnome.org></property>
|
|
|
22448f |
</object>
|
|
|
22448f |
<packing>
|
|
|
22448f |
<property name="left_attach">1</property>
|
|
|
22448f |
- <property name="top_attach">3</property>
|
|
|
22448f |
+ <property name="top_attach">4</property>
|
|
|
22448f |
<property name="width">1</property>
|
|
|
22448f |
<property name="height">1</property>
|
|
|
22448f |
</packing>
|
|
|
22448f |
@@ -281,7 +281,7 @@ Jonh Wendell <jwendell@gnome.org></property>
|
|
|
22448f |
</child>
|
|
|
22448f |
<child>
|
|
|
22448f |
<object class="GtkEntry" id="domain_entry">
|
|
|
22448f |
- <property name="visible">False</property>
|
|
|
22448f |
+ <property name="visible">True</property>
|
|
|
22448f |
<property name="can_focus">True</property>
|
|
|
22448f |
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
|
|
22448f |
<property name="max_length">254</property>
|
|
|
22448f |
diff --git a/plugins/spice/vinagre-spice-tab.c b/plugins/spice/vinagre-spice-tab.c
|
|
|
22448f |
index 0a26a00..2c20477 100644
|
|
|
22448f |
--- a/plugins/spice/vinagre-spice-tab.c
|
|
|
22448f |
+++ b/plugins/spice/vinagre-spice-tab.c
|
|
|
22448f |
@@ -297,10 +297,14 @@ spice_main_channel_event_cb(SpiceChannel *channel, SpiceChannelEvent event,
|
|
|
22448f |
if (!vinagre_utils_request_credential (window,
|
|
|
22448f |
"SPICE",
|
|
|
22448f |
name,
|
|
|
22448f |
+ NULL,
|
|
|
22448f |
+ NULL,
|
|
|
22448f |
+ FALSE,
|
|
|
22448f |
FALSE,
|
|
|
22448f |
TRUE,
|
|
|
22448f |
SPICE_MAX_PASSWORD_LENGTH,
|
|
|
22448f |
NULL,
|
|
|
22448f |
+ NULL,
|
|
|
22448f |
&password,
|
|
|
22448f |
&save_in_keyring))
|
|
|
22448f |
{
|
|
|
22448f |
diff --git a/plugins/vnc/vinagre-vnc-tab.c b/plugins/vnc/vinagre-vnc-tab.c
|
|
|
22448f |
index cf675a5..a3bc467 100644
|
|
|
22448f |
--- a/plugins/vnc/vinagre-vnc-tab.c
|
|
|
22448f |
+++ b/plugins/vnc/vinagre-vnc-tab.c
|
|
|
22448f |
@@ -502,13 +502,13 @@ vnc_authentication_cb (VncDisplay *vnc, GValueArray *credList, VinagreVncTab *vn
|
|
|
22448f |
|
|
|
22448f |
if (need_password || need_username)
|
|
|
22448f |
{
|
|
|
22448f |
- vinagre_tab_find_credentials_in_keyring (tab, &username, &password);
|
|
|
22448f |
+ vinagre_tab_find_credentials_in_keyring (tab, NULL, &username, &password);
|
|
|
22448f |
|
|
|
22448f |
if ( (need_username && !username) || (need_password && !password) )
|
|
|
22448f |
{
|
|
|
22448f |
host = vinagre_connection_get_best_name (conn);
|
|
|
22448f |
- if (!vinagre_utils_request_credential (window, "VNC", host,
|
|
|
22448f |
- need_username, need_password, 8, &username, &password,
|
|
|
22448f |
+ if (!vinagre_utils_request_credential (window, "VNC", host, NULL, NULL,
|
|
|
22448f |
+ FALSE, need_username, need_password, 8, NULL, &username, &password,
|
|
|
22448f |
&save_in_keyring))
|
|
|
22448f |
{
|
|
|
22448f |
vinagre_tab_remove_from_notebook (tab);
|
|
|
22448f |
diff --git a/vinagre/vinagre-connection.c b/vinagre/vinagre-connection.c
|
|
|
22448f |
index 3a3b9ac..23c21c2 100644
|
|
|
22448f |
--- a/vinagre/vinagre-connection.c
|
|
|
22448f |
+++ b/vinagre/vinagre-connection.c
|
|
|
22448f |
@@ -39,6 +39,7 @@ struct _VinagreConnectionPrivate
|
|
|
22448f |
gchar *protocol;
|
|
|
22448f |
gchar *host;
|
|
|
22448f |
gint port;
|
|
|
22448f |
+ gchar *domain;
|
|
|
22448f |
gchar *username;
|
|
|
22448f |
gchar *password;
|
|
|
22448f |
gchar *name;
|
|
|
22448f |
@@ -53,6 +54,7 @@ enum
|
|
|
22448f |
PROP_PROTOCOL,
|
|
|
22448f |
PROP_HOST,
|
|
|
22448f |
PROP_PORT,
|
|
|
22448f |
+ PROP_DOMAIN,
|
|
|
22448f |
PROP_USERNAME,
|
|
|
22448f |
PROP_PASSWORD,
|
|
|
22448f |
PROP_NAME,
|
|
|
22448f |
@@ -75,6 +77,7 @@ vinagre_connection_init (VinagreConnection *conn)
|
|
|
22448f |
conn->priv->port = 0;
|
|
|
22448f |
conn->priv->password = NULL;
|
|
|
22448f |
conn->priv->username = NULL;
|
|
|
22448f |
+ conn->priv->domain = NULL;
|
|
|
22448f |
conn->priv->name = NULL;
|
|
|
22448f |
conn->priv->fullscreen = FALSE;
|
|
|
22448f |
conn->priv->width = DEFAULT_WIDTH;
|
|
|
22448f |
@@ -88,6 +91,7 @@ vinagre_connection_finalize (GObject *object)
|
|
|
22448f |
|
|
|
22448f |
g_free (conn->priv->protocol);
|
|
|
22448f |
g_free (conn->priv->host);
|
|
|
22448f |
+ g_free (conn->priv->domain);
|
|
|
22448f |
g_free (conn->priv->username);
|
|
|
22448f |
g_free (conn->priv->password);
|
|
|
22448f |
g_free (conn->priv->name);
|
|
|
22448f |
@@ -118,6 +122,10 @@ vinagre_connection_set_property (GObject *object, guint prop_id, const GValue *v
|
|
|
22448f |
vinagre_connection_set_port (conn, g_value_get_int (value));
|
|
|
22448f |
break;
|
|
|
22448f |
|
|
|
22448f |
+ case PROP_DOMAIN:
|
|
|
22448f |
+ vinagre_connection_set_domain (conn, g_value_get_string (value));
|
|
|
22448f |
+ break;
|
|
|
22448f |
+
|
|
|
22448f |
case PROP_USERNAME:
|
|
|
22448f |
vinagre_connection_set_username (conn, g_value_get_string (value));
|
|
|
22448f |
break;
|
|
|
22448f |
@@ -172,6 +180,10 @@ vinagre_connection_get_property (GObject *object, guint prop_id, GValue *value,
|
|
|
22448f |
g_value_set_int (value, conn->priv->port);
|
|
|
22448f |
break;
|
|
|
22448f |
|
|
|
22448f |
+ case PROP_DOMAIN:
|
|
|
22448f |
+ g_value_set_string (value, conn->priv->domain);
|
|
|
22448f |
+ break;
|
|
|
22448f |
+
|
|
|
22448f |
case PROP_USERNAME:
|
|
|
22448f |
g_value_set_string (value, conn->priv->username);
|
|
|
22448f |
break;
|
|
|
22448f |
@@ -214,6 +226,7 @@ default_fill_writer (VinagreConnection *conn, xmlTextWriter *writer)
|
|
|
22448f |
xmlTextWriterWriteElement (writer, BAD_CAST "name", BAD_CAST conn->priv->name);
|
|
|
22448f |
xmlTextWriterWriteElement (writer, BAD_CAST "host", BAD_CAST conn->priv->host);
|
|
|
22448f |
xmlTextWriterWriteElement (writer, BAD_CAST "username", BAD_CAST (conn->priv->username ? conn->priv->username : ""));
|
|
|
22448f |
+ xmlTextWriterWriteElement (writer, BAD_CAST "domain", BAD_CAST (conn->priv->domain ? conn->priv->domain : ""));
|
|
|
22448f |
xmlTextWriterWriteFormatElement (writer, BAD_CAST "port", "%d", conn->priv->port);
|
|
|
22448f |
xmlTextWriterWriteFormatElement (writer, BAD_CAST "fullscreen", "%d", conn->priv->fullscreen);
|
|
|
22448f |
xmlTextWriterWriteFormatElement (writer, BAD_CAST "width", "%d", conn->priv->width);
|
|
|
22448f |
@@ -236,6 +249,8 @@ default_parse_item (VinagreConnection *conn, xmlNode *root)
|
|
|
22448f |
vinagre_connection_set_name (conn, (const gchar *)s_value);
|
|
|
22448f |
else if (!xmlStrcmp(curr->name, BAD_CAST "username"))
|
|
|
22448f |
vinagre_connection_set_username (conn, (const gchar *)s_value);
|
|
|
22448f |
+ else if (!xmlStrcmp(curr->name, BAD_CAST "domain"))
|
|
|
22448f |
+ vinagre_connection_set_domain (conn, (const gchar *)s_value);
|
|
|
22448f |
else if (!xmlStrcmp(curr->name, BAD_CAST "port"))
|
|
|
22448f |
vinagre_connection_set_port (conn, atoi ((const char *)s_value));
|
|
|
22448f |
else if (!xmlStrcmp(curr->name, BAD_CAST "fullscreen"))
|
|
|
22448f |
@@ -322,6 +337,18 @@ vinagre_connection_class_init (VinagreConnectionClass *klass)
|
|
|
22448f |
G_PARAM_STATIC_BLURB));
|
|
|
22448f |
|
|
|
22448f |
g_object_class_install_property (object_class,
|
|
|
22448f |
+ PROP_DOMAIN,
|
|
|
22448f |
+ g_param_spec_string ("domain",
|
|
|
22448f |
+ "domain",
|
|
|
22448f |
+ "domain (if any) necessary for complete this connection",
|
|
|
22448f |
+ NULL,
|
|
|
22448f |
+ G_PARAM_READWRITE |
|
|
|
22448f |
+ G_PARAM_CONSTRUCT |
|
|
|
22448f |
+ G_PARAM_STATIC_NICK |
|
|
|
22448f |
+ G_PARAM_STATIC_NAME |
|
|
|
22448f |
+ G_PARAM_STATIC_BLURB));
|
|
|
22448f |
+
|
|
|
22448f |
+ g_object_class_install_property (object_class,
|
|
|
22448f |
PROP_USERNAME,
|
|
|
22448f |
g_param_spec_string ("username",
|
|
|
22448f |
"username",
|
|
|
22448f |
@@ -460,6 +487,23 @@ vinagre_connection_get_port (VinagreConnection *conn)
|
|
|
22448f |
}
|
|
|
22448f |
|
|
|
22448f |
void
|
|
|
22448f |
+vinagre_connection_set_domain (VinagreConnection *conn,
|
|
|
22448f |
+ const gchar *domain)
|
|
|
22448f |
+{
|
|
|
22448f |
+ g_return_if_fail (VINAGRE_IS_CONNECTION (conn));
|
|
|
22448f |
+
|
|
|
22448f |
+ g_free (conn->priv->domain);
|
|
|
22448f |
+ conn->priv->domain = g_strdup (domain);
|
|
|
22448f |
+}
|
|
|
22448f |
+const gchar *
|
|
|
22448f |
+vinagre_connection_get_domain (VinagreConnection *conn)
|
|
|
22448f |
+{
|
|
|
22448f |
+ g_return_val_if_fail (VINAGRE_IS_CONNECTION (conn), NULL);
|
|
|
22448f |
+
|
|
|
22448f |
+ return conn->priv->domain;
|
|
|
22448f |
+}
|
|
|
22448f |
+
|
|
|
22448f |
+void
|
|
|
22448f |
vinagre_connection_set_username (VinagreConnection *conn,
|
|
|
22448f |
const gchar *username)
|
|
|
22448f |
{
|
|
|
22448f |
diff --git a/vinagre/vinagre-connection.h b/vinagre/vinagre-connection.h
|
|
|
22448f |
index 7fc130c..a717208 100644
|
|
|
22448f |
--- a/vinagre/vinagre-connection.h
|
|
|
22448f |
+++ b/vinagre/vinagre-connection.h
|
|
|
22448f |
@@ -72,6 +72,10 @@ gint vinagre_connection_get_port (VinagreConnection *conn);
|
|
|
22448f |
void vinagre_connection_set_port (VinagreConnection *conn,
|
|
|
22448f |
gint port);
|
|
|
22448f |
|
|
|
22448f |
+const gchar* vinagre_connection_get_domain (VinagreConnection *conn);
|
|
|
22448f |
+void vinagre_connection_set_domain (VinagreConnection *conn,
|
|
|
22448f |
+ const gchar *domain);
|
|
|
22448f |
+
|
|
|
22448f |
const gchar* vinagre_connection_get_username (VinagreConnection *conn);
|
|
|
22448f |
void vinagre_connection_set_username (VinagreConnection *conn,
|
|
|
22448f |
const gchar *username);
|
|
|
22448f |
diff --git a/vinagre/vinagre-ssh.c b/vinagre/vinagre-ssh.c
|
|
|
22448f |
index 432563b..7db228f 100644
|
|
|
22448f |
--- a/vinagre/vinagre-ssh.c
|
|
|
22448f |
+++ b/vinagre/vinagre-ssh.c
|
|
|
22448f |
@@ -502,8 +502,8 @@ handle_login (GtkWindow *parent,
|
|
|
22448f |
gboolean res;
|
|
|
22448f |
|
|
|
22448f |
full_host = g_strjoin ("@", user, host, NULL);
|
|
|
22448f |
- res = vinagre_utils_request_credential (parent, "SSH", full_host,
|
|
|
22448f |
- FALSE, TRUE, 0, NULL, &password, &save_in_keyring);
|
|
|
22448f |
+ res = vinagre_utils_request_credential (parent, "SSH", full_host, NULL, NULL,
|
|
|
22448f |
+ FALSE, FALSE, TRUE, 0, NULL, NULL, &password, &save_in_keyring);
|
|
|
22448f |
g_free (full_host);
|
|
|
22448f |
if (!res)
|
|
|
22448f |
{
|
|
|
22448f |
diff --git a/vinagre/vinagre-tab.c b/vinagre/vinagre-tab.c
|
|
|
22448f |
index f19bfe5..1ac123a 100644
|
|
|
22448f |
--- a/vinagre/vinagre-tab.c
|
|
|
22448f |
+++ b/vinagre/vinagre-tab.c
|
|
|
22448f |
@@ -758,24 +758,71 @@ vinagre_tab_get_from_connection (VinagreConnection *conn)
|
|
|
22448f |
return (res != NULL) ? VINAGRE_TAB (res) : NULL;
|
|
|
22448f |
}
|
|
|
22448f |
|
|
|
22448f |
+static GHashTable *
|
|
|
22448f |
+secret_attributes_create (VinagreConnection *connection)
|
|
|
22448f |
+{
|
|
|
22448f |
+ const gchar *conn_user = vinagre_connection_get_username (connection);
|
|
|
22448f |
+ const gchar *conn_domain = vinagre_connection_get_domain (connection);
|
|
|
22448f |
+ GHashTable *attributes;
|
|
|
22448f |
+
|
|
|
22448f |
+ attributes = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
|
|
|
22448f |
+
|
|
|
22448f |
+ g_hash_table_insert (attributes,
|
|
|
22448f |
+ g_strdup ("server"),
|
|
|
22448f |
+ g_strdup (vinagre_connection_get_host (connection)));
|
|
|
22448f |
+
|
|
|
22448f |
+ g_hash_table_insert (attributes,
|
|
|
22448f |
+ g_strdup ("protocol"),
|
|
|
22448f |
+ g_strdup (vinagre_connection_get_protocol (connection)));
|
|
|
22448f |
+
|
|
|
22448f |
+ g_hash_table_insert (attributes,
|
|
|
22448f |
+ g_strdup ("port"),
|
|
|
22448f |
+ g_strdup_printf ("%d", vinagre_connection_get_port (connection)));
|
|
|
22448f |
+
|
|
|
22448f |
+ if (conn_user != NULL)
|
|
|
22448f |
+ {
|
|
|
22448f |
+ g_hash_table_insert (attributes,
|
|
|
22448f |
+ g_strdup ("user"),
|
|
|
22448f |
+ g_strdup (conn_user));
|
|
|
22448f |
+ }
|
|
|
22448f |
+
|
|
|
22448f |
+ if (conn_domain != NULL)
|
|
|
22448f |
+ {
|
|
|
22448f |
+ g_hash_table_insert (attributes,
|
|
|
22448f |
+ g_strdup ("domain"),
|
|
|
22448f |
+ g_strdup (conn_domain));
|
|
|
22448f |
+ }
|
|
|
22448f |
+
|
|
|
22448f |
+ return attributes;
|
|
|
22448f |
+}
|
|
|
22448f |
+
|
|
|
22448f |
gboolean
|
|
|
22448f |
-vinagre_tab_find_credentials_in_keyring (VinagreTab *tab, gchar **username, gchar **password)
|
|
|
22448f |
+vinagre_tab_find_credentials_in_keyring (VinagreTab *tab, gchar **domain, gchar **username, gchar **password)
|
|
|
22448f |
{
|
|
|
22448f |
const gchar *conn_user = vinagre_connection_get_username (tab->priv->conn);
|
|
|
22448f |
+ const gchar *conn_domain = vinagre_connection_get_domain (tab->priv->conn);
|
|
|
22448f |
+ GHashTable *attributes;
|
|
|
22448f |
+
|
|
|
22448f |
*username = NULL;
|
|
|
22448f |
|
|
|
22448f |
- /* "user" goes last, to terminate the attribute list if conn_user is NULL. */
|
|
|
22448f |
- *password = secret_password_lookup_sync (SECRET_SCHEMA_COMPAT_NETWORK, NULL, NULL,
|
|
|
22448f |
- "server", vinagre_connection_get_host (tab->priv->conn),
|
|
|
22448f |
- "protocol", vinagre_connection_get_protocol (tab->priv->conn),
|
|
|
22448f |
- "port", vinagre_connection_get_port (tab->priv->conn),
|
|
|
22448f |
- conn_user ? "user" : NULL, conn_user,
|
|
|
22448f |
- NULL);
|
|
|
22448f |
+ if (domain != NULL)
|
|
|
22448f |
+ *domain = NULL;
|
|
|
22448f |
+
|
|
|
22448f |
+ attributes = secret_attributes_create (tab->priv->conn);
|
|
|
22448f |
+
|
|
|
22448f |
+ *password = secret_password_lookupv_sync (SECRET_SCHEMA_COMPAT_NETWORK,
|
|
|
22448f |
+ attributes, NULL, NULL);
|
|
|
22448f |
+
|
|
|
22448f |
+ g_hash_table_destroy (attributes);
|
|
|
22448f |
|
|
|
22448f |
if (*password == NULL)
|
|
|
22448f |
return FALSE;
|
|
|
22448f |
|
|
|
22448f |
*username = g_strdup (conn_user);
|
|
|
22448f |
+
|
|
|
22448f |
+ if (domain != NULL)
|
|
|
22448f |
+ *domain = g_strdup (conn_domain);
|
|
|
22448f |
+
|
|
|
22448f |
return TRUE;
|
|
|
22448f |
}
|
|
|
22448f |
|
|
|
22448f |
@@ -787,25 +834,24 @@ void vinagre_tab_set_save_credentials (VinagreTab *tab, gboolean value)
|
|
|
22448f |
void
|
|
|
22448f |
vinagre_tab_save_credentials_in_keyring (VinagreTab *tab)
|
|
|
22448f |
{
|
|
|
22448f |
+ GHashTable *attributes;
|
|
|
22448f |
GError *error = NULL;
|
|
|
22448f |
gchar *label;
|
|
|
22448f |
- const gchar *conn_user = vinagre_connection_get_username (tab->priv->conn);
|
|
|
22448f |
|
|
|
22448f |
if (!tab->priv->save_credentials)
|
|
|
22448f |
return;
|
|
|
22448f |
|
|
|
22448f |
label = g_strdup_printf (_("Remote desktop password for %s"),
|
|
|
22448f |
vinagre_connection_get_host (tab->priv->conn));
|
|
|
22448f |
- /* "user" goes last, to terminate the attribute list if conn_user is NULL. */
|
|
|
22448f |
- secret_password_store_sync (SECRET_SCHEMA_COMPAT_NETWORK, NULL,
|
|
|
22448f |
- label, vinagre_connection_get_password (tab->priv->conn),
|
|
|
22448f |
- NULL, &error,
|
|
|
22448f |
- "server", vinagre_connection_get_host (tab->priv->conn),
|
|
|
22448f |
- "protocol", vinagre_connection_get_protocol (tab->priv->conn),
|
|
|
22448f |
- "port", vinagre_connection_get_port (tab->priv->conn),
|
|
|
22448f |
- conn_user ? "user" : NULL, conn_user,
|
|
|
22448f |
- NULL);
|
|
|
22448f |
+
|
|
|
22448f |
+ attributes = secret_attributes_create (tab->priv->conn);
|
|
|
22448f |
+
|
|
|
22448f |
+ secret_password_storev_sync (SECRET_SCHEMA_COMPAT_NETWORK, attributes, NULL,
|
|
|
22448f |
+ label, vinagre_connection_get_password (tab->priv->conn),
|
|
|
22448f |
+ NULL, &error);
|
|
|
22448f |
+
|
|
|
22448f |
g_free (label);
|
|
|
22448f |
+ g_hash_table_destroy (attributes);
|
|
|
22448f |
|
|
|
22448f |
if (error == NULL) {
|
|
|
22448f |
tab->priv->saved_credentials = TRUE;
|
|
|
22448f |
@@ -824,17 +870,19 @@ void vinagre_tab_remove_credentials_from_keyring (VinagreTab *tab)
|
|
|
22448f |
{
|
|
|
22448f |
if (tab->priv->saved_credentials)
|
|
|
22448f |
{
|
|
|
22448f |
- /* Put "user" last, to terminate the attributes if conn_user is NULL. */
|
|
|
22448f |
- const gchar *conn_user = vinagre_connection_get_username (tab->priv->conn);
|
|
|
22448f |
- secret_password_clear_sync (SECRET_SCHEMA_COMPAT_NETWORK, NULL, NULL,
|
|
|
22448f |
- "server", vinagre_connection_get_host (tab->priv->conn),
|
|
|
22448f |
- "protocol", vinagre_connection_get_protocol (tab->priv->conn),
|
|
|
22448f |
- "port", vinagre_connection_get_port (tab->priv->conn),
|
|
|
22448f |
- conn_user ? "user" : NULL, conn_user,
|
|
|
22448f |
- NULL);
|
|
|
22448f |
+ GHashTable *attributes;
|
|
|
22448f |
+
|
|
|
22448f |
+ attributes = secret_attributes_create (tab->priv->conn);
|
|
|
22448f |
+
|
|
|
22448f |
+ secret_password_clearv_sync (SECRET_SCHEMA_COMPAT_NETWORK,
|
|
|
22448f |
+ attributes, NULL, NULL);
|
|
|
22448f |
+
|
|
|
22448f |
tab->priv->saved_credentials = FALSE;
|
|
|
22448f |
+
|
|
|
22448f |
+ g_hash_table_destroy (attributes);
|
|
|
22448f |
}
|
|
|
22448f |
|
|
|
22448f |
+ vinagre_connection_set_domain (tab->priv->conn, NULL);
|
|
|
22448f |
vinagre_connection_set_username (tab->priv->conn, NULL);
|
|
|
22448f |
vinagre_connection_set_password (tab->priv->conn, NULL);
|
|
|
22448f |
}
|
|
|
22448f |
diff --git a/vinagre/vinagre-tab.h b/vinagre/vinagre-tab.h
|
|
|
22448f |
index 01bd36b..58f7275 100644
|
|
|
22448f |
--- a/vinagre/vinagre-tab.h
|
|
|
22448f |
+++ b/vinagre/vinagre-tab.h
|
|
|
22448f |
@@ -127,6 +127,7 @@ const gchar *vinagre_tab_get_icon_name (VinagreTab *tab);
|
|
|
22448f |
void vinagre_tab_set_save_credentials (VinagreTab *tab, gboolean value);
|
|
|
22448f |
void vinagre_tab_save_credentials_in_keyring (VinagreTab *tab);
|
|
|
22448f |
gboolean vinagre_tab_find_credentials_in_keyring (VinagreTab *tab,
|
|
|
22448f |
+ gchar **domain,
|
|
|
22448f |
gchar **username,
|
|
|
22448f |
gchar **password);
|
|
|
22448f |
void vinagre_tab_remove_credentials_from_keyring (VinagreTab *tab);
|
|
|
22448f |
diff --git a/vinagre/vinagre-utils.vala b/vinagre/vinagre-utils.vala
|
|
|
22448f |
index 15969f4..2d90cb4 100644
|
|
|
22448f |
--- a/vinagre/vinagre-utils.vala
|
|
|
22448f |
+++ b/vinagre/vinagre-utils.vala
|
|
|
22448f |
@@ -95,9 +95,13 @@ namespace Vinagre.Utils {
|
|
|
22448f |
public bool request_credential (Window parent,
|
|
|
22448f |
string protocol,
|
|
|
22448f |
string host,
|
|
|
22448f |
+ string? default_domain,
|
|
|
22448f |
+ string? default_username,
|
|
|
22448f |
+ bool need_domain,
|
|
|
22448f |
bool need_username,
|
|
|
22448f |
bool need_password,
|
|
|
22448f |
int password_limit,
|
|
|
22448f |
+ out string domain,
|
|
|
22448f |
out string username,
|
|
|
22448f |
out string password,
|
|
|
22448f |
out bool save_in_keyring)
|
|
|
22448f |
@@ -116,6 +120,7 @@ namespace Vinagre.Utils {
|
|
|
22448f |
|
|
|
22448f |
var password_label = xml.get_object ("password_label") as Label;
|
|
|
22448f |
var username_label = xml.get_object ("username_label") as Label;
|
|
|
22448f |
+ var domain_label = xml.get_object ("domain_label") as Label;
|
|
|
22448f |
var save_credential_check = xml.get_object ("save_credential_check")
|
|
|
22448f |
as CheckButton;
|
|
|
22448f |
|
|
|
22448f |
@@ -124,9 +129,30 @@ namespace Vinagre.Utils {
|
|
|
22448f |
IconSize.BUTTON);
|
|
|
22448f |
ok_button.image = image;
|
|
|
22448f |
|
|
|
22448f |
+ var domain_entry = xml.get_object ("domain_entry") as Entry;
|
|
|
22448f |
var username_entry = xml.get_object ("username_entry") as Entry;
|
|
|
22448f |
var password_entry = xml.get_object ("password_entry") as Entry;
|
|
|
22448f |
|
|
|
22448f |
+ domain_entry.changed.connect (() => {
|
|
|
22448f |
+ var enabled = true;
|
|
|
22448f |
+
|
|
|
22448f |
+ if (username_entry.visible)
|
|
|
22448f |
+ enabled = enabled && username_entry.text_length > 0;
|
|
|
22448f |
+
|
|
|
22448f |
+ if (password_entry.visible)
|
|
|
22448f |
+ enabled = enabled && password_entry.text_length > 0;
|
|
|
22448f |
+
|
|
|
22448f |
+ ok_button.sensitive = enabled;
|
|
|
22448f |
+ });
|
|
|
22448f |
+
|
|
|
22448f |
+ if (!need_domain) {
|
|
|
22448f |
+ domain_label.hide ();
|
|
|
22448f |
+ domain_entry.hide ();
|
|
|
22448f |
+ } else {
|
|
|
22448f |
+ if (default_domain != null)
|
|
|
22448f |
+ domain_entry.set_text (default_domain);
|
|
|
22448f |
+ }
|
|
|
22448f |
+
|
|
|
22448f |
username_entry.changed.connect (() => {
|
|
|
22448f |
var enabled = true;
|
|
|
22448f |
|
|
|
22448f |
@@ -142,6 +168,11 @@ namespace Vinagre.Utils {
|
|
|
22448f |
if (!need_username) {
|
|
|
22448f |
username_label.hide ();
|
|
|
22448f |
username_entry.hide ();
|
|
|
22448f |
+ } else {
|
|
|
22448f |
+ if (default_username != null) {
|
|
|
22448f |
+ username_entry.set_text (default_username);
|
|
|
22448f |
+ password_entry.grab_focus ();
|
|
|
22448f |
+ }
|
|
|
22448f |
}
|
|
|
22448f |
|
|
|
22448f |
password_entry.changed.connect (() => {
|
|
|
22448f |
@@ -165,6 +196,9 @@ namespace Vinagre.Utils {
|
|
|
22448f |
|
|
|
22448f |
var result = password_dialog.run ();
|
|
|
22448f |
if (result == ResponseType.OK) {
|
|
|
22448f |
+ if (domain_entry.text_length > 0)
|
|
|
22448f |
+ domain = domain_entry.text;
|
|
|
22448f |
+
|
|
|
22448f |
if (username_entry.text_length > 0)
|
|
|
22448f |
username = username_entry.text;
|
|
|
22448f |
|
|
|
22448f |
--
|
|
|
22448f |
2.5.0
|
|
|
22448f |
|