vinagre r509 - in trunk: . data src



Author: jwendell
Date: Thu Nov 13 23:09:01 2008
New Revision: 509
URL: http://svn.gnome.org/viewvc/vinagre?rev=509&view=rev

Log:
2008-11-13  Jonh Wendell <jwendell gnome org>

	* src/vinagre-connection.[ch],
	* src/vinagre-tab.c,
	* data/vinagre.glade: Allow the username in the authentication schema.
	If an username is required to connect to a host, we ask it in the
	auth dialog, as long as the password. Closes #559526.



Modified:
   trunk/ChangeLog
   trunk/data/vinagre.glade
   trunk/src/vinagre-connection.c
   trunk/src/vinagre-connection.h
   trunk/src/vinagre-tab.c

Modified: trunk/data/vinagre.glade
==============================================================================
--- trunk/data/vinagre.glade	(original)
+++ trunk/data/vinagre.glade	Thu Nov 13 23:09:01 2008
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
 <!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
-<!--Generated with glade3 3.4.5 on Sun Jun  1 09:41:43 2008 -->
+<!--Generated with glade3 3.4.5 on Thu Nov 13 19:51:19 2008 -->
 <glade-interface>
   <widget class="GtkDialog" id="connect_dialog">
     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
@@ -34,37 +34,23 @@
           <widget class="GtkTable" id="table1">
             <property name="visible">True</property>
             <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-            <property name="n_rows">1</property>
             <property name="n_columns">4</property>
             <property name="column_spacing">6</property>
             <property name="row_spacing">6</property>
             <child>
-              <widget class="GtkComboBoxEntry" id="host_entry">
-                <property name="width_request">250</property>
-                <property name="visible">True</property>
-                <property name="tooltip" translatable="yes" comments="Tooltip for host entry in connect dialog">host or host:display or host::port</property>
-                <child internal-child="entry">
-                  <widget class="GtkEntry" id="comboboxentry-entry1">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="activates_default">True</property>
-                  </widget>
-                </child>
-              </widget>
-              <packing>
-                <property name="left_attach">2</property>
-                <property name="right_attach">3</property>
-                <property name="y_options"></property>
-              </packing>
-            </child>
-            <child>
-              <widget class="GtkLabel" id="label2">
+              <widget class="GtkButton" id="find_button">
                 <property name="visible">True</property>
+                <property name="receives_default">True</property>
                 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                <property name="label">  </property>
+                <property name="label">gtk-find</property>
+                <property name="use_stock">True</property>
+                <property name="focus_on_click">False</property>
+                <property name="response_id">0</property>
               </widget>
               <packing>
-                <property name="x_options">GTK_FILL</property>
+                <property name="left_attach">3</property>
+                <property name="right_attach">4</property>
+                <property name="x_options"></property>
                 <property name="y_options"></property>
               </packing>
             </child>
@@ -84,19 +70,32 @@
               </packing>
             </child>
             <child>
-              <widget class="GtkButton" id="find_button">
+              <widget class="GtkLabel" id="label2">
                 <property name="visible">True</property>
-                <property name="receives_default">True</property>
                 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                <property name="label">gtk-find</property>
-                <property name="use_stock">True</property>
-                <property name="focus_on_click">False</property>
-                <property name="response_id">0</property>
+                <property name="label">  </property>
               </widget>
               <packing>
-                <property name="left_attach">3</property>
-                <property name="right_attach">4</property>
-                <property name="x_options"></property>
+                <property name="x_options">GTK_FILL</property>
+                <property name="y_options"></property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkComboBoxEntry" id="host_entry">
+                <property name="width_request">250</property>
+                <property name="visible">True</property>
+                <property name="tooltip" translatable="yes" comments="Tooltip for host entry in connect dialog">host or host:display or host::port</property>
+                <child internal-child="entry">
+                  <widget class="GtkEntry" id="comboboxentry-entry1">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="activates_default">True</property>
+                  </widget>
+                </child>
+              </widget>
+              <packing>
+                <property name="left_attach">2</property>
+                <property name="right_attach">3</property>
                 <property name="y_options"></property>
               </packing>
             </child>
@@ -135,10 +134,21 @@
               <placeholder/>
             </child>
             <child>
-              <widget class="GtkCheckButton" id="scaling_check">
+              <widget class="GtkLabel" id="label6">
+                <property name="visible">True</property>
+                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="label">  </property>
+              </widget>
+              <packing>
+                <property name="x_options"></property>
+                <property name="y_options"></property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkCheckButton" id="fullscreen_check">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
-                <property name="label" translatable="yes">_Scaling</property>
+                <property name="label" translatable="yes">_Full screen</property>
                 <property name="use_underline">True</property>
                 <property name="response_id">0</property>
                 <property name="draw_indicator">True</property>
@@ -146,8 +156,6 @@
               <packing>
                 <property name="left_attach">1</property>
                 <property name="right_attach">2</property>
-                <property name="top_attach">2</property>
-                <property name="bottom_attach">3</property>
               </packing>
             </child>
             <child>
@@ -167,10 +175,10 @@
               </packing>
             </child>
             <child>
-              <widget class="GtkCheckButton" id="fullscreen_check">
+              <widget class="GtkCheckButton" id="scaling_check">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
-                <property name="label" translatable="yes">_Full screen</property>
+                <property name="label" translatable="yes">_Scaling</property>
                 <property name="use_underline">True</property>
                 <property name="response_id">0</property>
                 <property name="draw_indicator">True</property>
@@ -178,17 +186,8 @@
               <packing>
                 <property name="left_attach">1</property>
                 <property name="right_attach">2</property>
-              </packing>
-            </child>
-            <child>
-              <widget class="GtkLabel" id="label6">
-                <property name="visible">True</property>
-                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                <property name="label">  </property>
-              </widget>
-              <packing>
-                <property name="x_options"></property>
-                <property name="y_options"></property>
+                <property name="top_attach">2</property>
+                <property name="bottom_attach">3</property>
               </packing>
             </child>
           </widget>
@@ -237,7 +236,7 @@
       </widget>
     </child>
   </widget>
-  <widget class="GtkDialog" id="password_required_dialog">
+  <widget class="GtkDialog" id="auth_required_dialog">
     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
     <property name="border_width">5</property>
     <property name="resizable">False</property>
@@ -261,7 +260,7 @@
                 <property name="visible">True</property>
                 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                 <property name="xalign">0</property>
-                <property name="label" translatable="yes">&lt;b&gt;In order to connect on this machine, a password is required. Please supply it.&lt;/b&gt;</property>
+                <property name="label" translatable="yes">&lt;b&gt;Authentication is required&lt;/b&gt;</property>
                 <property name="use_markup">True</property>
                 <property name="wrap">True</property>
               </widget>
@@ -273,37 +272,89 @@
               <widget class="GtkTable" id="table3">
                 <property name="visible">True</property>
                 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                <property name="n_rows">3</property>
-                <property name="n_columns">2</property>
+                <property name="n_rows">4</property>
+                <property name="n_columns">3</property>
+                <property name="column_spacing">5</property>
                 <property name="row_spacing">5</property>
                 <child>
                   <placeholder/>
                 </child>
                 <child>
-                  <widget class="GtkLabel" id="label19">
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <widget class="GtkLabel" id="label12">
+                    <property name="visible">True</property>
+                    <property name="label">   </property>
+                  </widget>
+                </child>
+                <child>
+                  <widget class="GtkEntry" id="username_entry">
                     <property name="visible">True</property>
+                    <property name="can_focus">True</property>
                     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                    <property name="xalign">0</property>
-                    <property name="label" translatable="yes">Host:</property>
-                    <property name="use_underline">True</property>
-                    <property name="mnemonic_widget">password_entry</property>
+                    <property name="max_length">254</property>
+                    <property name="activates_default">True</property>
                   </widget>
+                  <packing>
+                    <property name="left_attach">2</property>
+                    <property name="right_attach">3</property>
+                    <property name="top_attach">1</property>
+                    <property name="bottom_attach">2</property>
+                  </packing>
                 </child>
                 <child>
-                  <widget class="GtkLabel" id="label21">
+                  <widget class="GtkLabel" id="username_label">
                     <property name="visible">True</property>
                     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                     <property name="xalign">0</property>
-                    <property name="label" translatable="yes">_Password:</property>
+                    <property name="label" translatable="yes">_Username:</property>
                     <property name="use_underline">True</property>
-                    <property name="mnemonic_widget">password_entry</property>
+                    <property name="mnemonic_widget">username_entry</property>
                   </widget>
                   <packing>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
                     <property name="top_attach">1</property>
                     <property name="bottom_attach">2</property>
                   </packing>
                 </child>
                 <child>
+                  <widget class="GtkCheckButton" id="save_credential_check">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                    <property name="label" translatable="yes">_Remember this credential</property>
+                    <property name="use_underline">True</property>
+                    <property name="response_id">0</property>
+                    <property name="draw_indicator">True</property>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">2</property>
+                    <property name="right_attach">3</property>
+                    <property name="top_attach">3</property>
+                    <property name="bottom_attach">4</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkLabel" id="host_label">
+                    <property name="visible">True</property>
+                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                    <property name="xalign">0</property>
+                    <property name="use_markup">True</property>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">2</property>
+                    <property name="right_attach">3</property>
+                  </packing>
+                </child>
+                <child>
                   <widget class="GtkEntry" id="password_entry">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
@@ -313,38 +364,40 @@
                     <property name="activates_default">True</property>
                   </widget>
                   <packing>
-                    <property name="left_attach">1</property>
-                    <property name="right_attach">2</property>
-                    <property name="top_attach">1</property>
-                    <property name="bottom_attach">2</property>
+                    <property name="left_attach">2</property>
+                    <property name="right_attach">3</property>
+                    <property name="top_attach">2</property>
+                    <property name="bottom_attach">3</property>
                   </packing>
                 </child>
                 <child>
-                  <widget class="GtkLabel" id="host_label">
+                  <widget class="GtkLabel" id="password_label">
                     <property name="visible">True</property>
                     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                     <property name="xalign">0</property>
+                    <property name="label" translatable="yes">_Password:</property>
+                    <property name="use_underline">True</property>
+                    <property name="mnemonic_widget">password_entry</property>
                   </widget>
                   <packing>
                     <property name="left_attach">1</property>
                     <property name="right_attach">2</property>
+                    <property name="top_attach">2</property>
+                    <property name="bottom_attach">3</property>
                   </packing>
                 </child>
                 <child>
-                  <widget class="GtkCheckButton" id="save_password_check">
+                  <widget class="GtkLabel" id="label19">
                     <property name="visible">True</property>
-                    <property name="can_focus">True</property>
                     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                    <property name="label" translatable="yes">_Remember this password</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes">Host:</property>
                     <property name="use_underline">True</property>
-                    <property name="response_id">0</property>
-                    <property name="draw_indicator">True</property>
+                    <property name="mnemonic_widget">password_entry</property>
                   </widget>
                   <packing>
                     <property name="left_attach">1</property>
                     <property name="right_attach">2</property>
-                    <property name="top_attach">2</property>
-                    <property name="bottom_attach">3</property>
                   </packing>
                 </child>
               </widget>
@@ -561,32 +614,24 @@
               <placeholder/>
             </child>
             <child>
-              <widget class="GtkEntry" id="edit_bookmark_host_entry">
+              <widget class="GtkLabel" id="label16">
                 <property name="visible">True</property>
-                <property name="can_focus">True</property>
                 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                <property name="tooltip" translatable="yes">host or host:display or host::port</property>
-                <property name="activates_default">True</property>
+                <property name="label">  </property>
               </widget>
-              <packing>
-                <property name="left_attach">2</property>
-                <property name="right_attach">3</property>
-                <property name="top_attach">1</property>
-                <property name="bottom_attach">2</property>
-              </packing>
             </child>
             <child>
-              <widget class="GtkEntry" id="edit_bookmark_name_entry">
-                <property name="width_request">250</property>
+              <widget class="GtkLabel" id="label14">
                 <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="is_focus">True</property>
                 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                <property name="activates_default">True</property>
+                <property name="xalign">0</property>
+                <property name="label" translatable="yes">_Bookmark name:</property>
+                <property name="use_underline">True</property>
+                <property name="mnemonic_widget">edit_bookmark_name_entry</property>
               </widget>
               <packing>
-                <property name="left_attach">2</property>
-                <property name="right_attach">3</property>
+                <property name="left_attach">1</property>
+                <property name="right_attach">2</property>
               </packing>
             </child>
             <child>
@@ -606,25 +651,33 @@
               </packing>
             </child>
             <child>
-              <widget class="GtkLabel" id="label14">
+              <widget class="GtkEntry" id="edit_bookmark_name_entry">
+                <property name="width_request">250</property>
                 <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="is_focus">True</property>
                 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                <property name="xalign">0</property>
-                <property name="label" translatable="yes">_Bookmark name:</property>
-                <property name="use_underline">True</property>
-                <property name="mnemonic_widget">edit_bookmark_name_entry</property>
+                <property name="activates_default">True</property>
               </widget>
               <packing>
-                <property name="left_attach">1</property>
-                <property name="right_attach">2</property>
+                <property name="left_attach">2</property>
+                <property name="right_attach">3</property>
               </packing>
             </child>
             <child>
-              <widget class="GtkLabel" id="label16">
+              <widget class="GtkEntry" id="edit_bookmark_host_entry">
                 <property name="visible">True</property>
+                <property name="can_focus">True</property>
                 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                <property name="label">  </property>
+                <property name="tooltip" translatable="yes">host or host:display or host::port</property>
+                <property name="activates_default">True</property>
               </widget>
+              <packing>
+                <property name="left_attach">2</property>
+                <property name="right_attach">3</property>
+                <property name="top_attach">1</property>
+                <property name="bottom_attach">2</property>
+              </packing>
             </child>
           </widget>
           <packing>
@@ -660,10 +713,21 @@
               <placeholder/>
             </child>
             <child>
-              <widget class="GtkCheckButton" id="edit_scaling_check">
+              <widget class="GtkLabel" id="label11">
+                <property name="visible">True</property>
+                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="label">  </property>
+              </widget>
+              <packing>
+                <property name="x_options"></property>
+                <property name="y_options"></property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkCheckButton" id="edit_fullscreen_check">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
-                <property name="label" translatable="yes">_Scaling</property>
+                <property name="label" translatable="yes">_Full screen</property>
                 <property name="use_underline">True</property>
                 <property name="response_id">0</property>
                 <property name="draw_indicator">True</property>
@@ -671,8 +735,6 @@
               <packing>
                 <property name="left_attach">1</property>
                 <property name="right_attach">2</property>
-                <property name="top_attach">2</property>
-                <property name="bottom_attach">3</property>
               </packing>
             </child>
             <child>
@@ -692,10 +754,10 @@
               </packing>
             </child>
             <child>
-              <widget class="GtkCheckButton" id="edit_fullscreen_check">
+              <widget class="GtkCheckButton" id="edit_scaling_check">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
-                <property name="label" translatable="yes">_Full screen</property>
+                <property name="label" translatable="yes">_Scaling</property>
                 <property name="use_underline">True</property>
                 <property name="response_id">0</property>
                 <property name="draw_indicator">True</property>
@@ -703,17 +765,8 @@
               <packing>
                 <property name="left_attach">1</property>
                 <property name="right_attach">2</property>
-              </packing>
-            </child>
-            <child>
-              <widget class="GtkLabel" id="label11">
-                <property name="visible">True</property>
-                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                <property name="label">  </property>
-              </widget>
-              <packing>
-                <property name="x_options"></property>
-                <property name="y_options"></property>
+                <property name="top_attach">2</property>
+                <property name="bottom_attach">3</property>
               </packing>
             </child>
           </widget>

Modified: trunk/src/vinagre-connection.c
==============================================================================
--- trunk/src/vinagre-connection.c	(original)
+++ trunk/src/vinagre-connection.c	Thu Nov 13 23:09:01 2008
@@ -33,6 +33,7 @@
   gchar *host;
   gint   port;
   gchar *name;
+  gchar *username;
   gchar *password;
   gchar *desktop_name;
   gboolean view_only;
@@ -47,6 +48,7 @@
   PROP_HOST,
   PROP_PORT,
   PROP_NAME,
+  PROP_USERNAME,
   PROP_PASSWORD,
   PROP_DESKTOP_NAME,
   PROP_BEST_NAME,
@@ -71,6 +73,7 @@
   conn->priv->host = NULL;
   conn->priv->port = 0;
   conn->priv->password = NULL;
+  conn->priv->username = NULL;
   conn->priv->name = NULL;
   conn->priv->desktop_name = NULL;
   conn->priv->view_only = FALSE;
@@ -83,20 +86,19 @@
 {
   VinagreConnection *conn = VINAGRE_CONNECTION (object);
 
-  if (conn->priv->host)
-    g_free (conn->priv->host);
+  g_free (conn->priv->host);
   conn->priv->host = NULL;
 
-  if (conn->priv->password)
-    g_free (conn->priv->password);
+  g_free (conn->priv->username);
+  conn->priv->username = NULL;
+
+  g_free (conn->priv->password);
   conn->priv->password = NULL;
 
-  if (conn->priv->name)
-    g_free (conn->priv->name);
+  g_free (conn->priv->name);
   conn->priv->name = NULL;
 
-  if (conn->priv->desktop_name)
-    g_free (conn->priv->desktop_name);
+  g_free (conn->priv->desktop_name);
   conn->priv->desktop_name = NULL;
 
   G_OBJECT_CLASS (vinagre_connection_parent_class)->finalize (object);
@@ -125,6 +127,10 @@
 	vinagre_connection_set_port (conn, g_value_get_int (value));
 	break;
 
+      case PROP_USERNAME:
+	vinagre_connection_set_username (conn, g_value_get_string (value));
+	break;
+
       case PROP_PASSWORD:
 	vinagre_connection_set_password (conn, g_value_get_string (value));
 	break;
@@ -179,6 +185,10 @@
 	g_value_set_int (value, conn->priv->port);
 	break;
 
+      case PROP_USERNAME:
+	g_value_set_string (value, conn->priv->username);
+	break;
+
       case PROP_PASSWORD:
 	g_value_set_string (value, conn->priv->password);
 	break;
@@ -269,6 +279,18 @@
                                                       G_PARAM_STATIC_BLURB));
 
   g_object_class_install_property (object_class,
+                                   PROP_NAME,
+                                   g_param_spec_string ("username",
+                                                        "username",
+	                                                "username (if any) necessary for complete this connection",
+                                                        NULL,
+	                                                G_PARAM_READWRITE |
+                                                        G_PARAM_CONSTRUCT |
+                                                        G_PARAM_STATIC_NICK |
+                                                        G_PARAM_STATIC_NAME |
+                                                        G_PARAM_STATIC_BLURB));
+
+  g_object_class_install_property (object_class,
                                    PROP_PASSWORD,
                                    g_param_spec_string ("password",
                                                         "password",
@@ -419,13 +441,29 @@
 }
 
 void
+vinagre_connection_set_username (VinagreConnection *conn,
+			     const gchar *username)
+{
+  g_return_if_fail (VINAGRE_IS_CONNECTION (conn));
+
+  g_free (conn->priv->username);
+  conn->priv->username = g_strdup (username);
+}
+const gchar *
+vinagre_connection_get_username (VinagreConnection *conn)
+{
+  g_return_val_if_fail (VINAGRE_IS_CONNECTION (conn), NULL);
+
+  return conn->priv->username;
+}
+
+void
 vinagre_connection_set_password (VinagreConnection *conn,
 			         const gchar *password)
 {
   g_return_if_fail (VINAGRE_IS_CONNECTION (conn));
 
-  if (conn->priv->password)
-    g_free (conn->priv->password);
+  g_free (conn->priv->password);
   conn->priv->password = g_strdup (password);
 }
 const gchar *
@@ -442,8 +480,7 @@
 {
   g_return_if_fail (VINAGRE_IS_CONNECTION (conn));
 
-  if (conn->priv->name)
-    g_free (conn->priv->name);
+  g_free (conn->priv->name);
   conn->priv->name = g_strdup (name);
 }
 const gchar *
@@ -460,8 +497,7 @@
 {
   g_return_if_fail (VINAGRE_IS_CONNECTION (conn));
 
-  if (conn->priv->desktop_name)
-    g_free (conn->priv->desktop_name);
+  g_free (conn->priv->desktop_name);
   conn->priv->desktop_name = g_strdup (desktop_name);
 }
 const gchar *
@@ -498,6 +534,7 @@
 
   vinagre_connection_set_host (new_conn, vinagre_connection_get_host (conn));
   vinagre_connection_set_port (new_conn, vinagre_connection_get_port (conn));
+  vinagre_connection_set_username (new_conn, vinagre_connection_get_username (conn));
   vinagre_connection_set_password (new_conn, vinagre_connection_get_password (conn));
   vinagre_connection_set_name (new_conn, vinagre_connection_get_name (conn));
   vinagre_connection_set_desktop_name (new_conn, vinagre_connection_get_desktop_name (conn));

Modified: trunk/src/vinagre-connection.h
==============================================================================
--- trunk/src/vinagre-connection.h	(original)
+++ trunk/src/vinagre-connection.h	Thu Nov 13 23:09:01 2008
@@ -71,6 +71,10 @@
 void		    vinagre_connection_set_port		(VinagreConnection *conn,
 							 gint port);
 
+const gchar*	    vinagre_connection_get_username	(VinagreConnection *conn);
+void		    vinagre_connection_set_username	(VinagreConnection *conn,
+							 const gchar *username);
+
 const gchar*	    vinagre_connection_get_password	(VinagreConnection *conn);
 void		    vinagre_connection_set_password	(VinagreConnection *conn,
 							 const gchar *password);

Modified: trunk/src/vinagre-tab.c
==============================================================================
--- trunk/src/vinagre-tab.c	(original)
+++ trunk/src/vinagre-tab.c	Thu Nov 13 23:09:01 2008
@@ -43,7 +43,7 @@
   VinagreConnection *conn;
   VinagreNotebook   *nb;
   VinagreWindow     *window;
-  gboolean           save_password;
+  gboolean           save_credential;
   guint32            keyring_item_id;
   VinagreTabState    state;
   gchar             *clipboard_str;
@@ -450,41 +450,42 @@
 }
 
 static void
-vinagre_tab_save_password (VinagreTab *tab)
+vinagre_tab_save_credential (VinagreTab *tab)
 {
   GnomeKeyringResult result;
 
-  if (!tab->priv->save_password)
+  if (!tab->priv->save_credential)
     return;
 
   result = gnome_keyring_set_network_password_sync (
-                NULL,           /* default keyring */
-                NULL,           /* user            */
-                NULL,           /* domain          */
-                vinagre_connection_get_host (tab->priv->conn),   /* server          */
-                NULL,           /* object          */
-                "rfb",          /* protocol        */
-                "vnc-password", /* authtype        */
-                vinagre_connection_get_port (tab->priv->conn),           /* port            */
-                vinagre_connection_get_password (tab->priv->conn),       /* password        */
+                NULL,                                              /* default keyring */
+                vinagre_connection_get_username (tab->priv->conn), /* user            */
+                NULL,                                              /* domain          */
+                vinagre_connection_get_host (tab->priv->conn),     /* server          */
+                NULL,                                              /* object          */
+                "rfb",                                             /* protocol        */
+                "vnc-password",                                    /* authtype        */
+                vinagre_connection_get_port (tab->priv->conn),     /* port            */
+                vinagre_connection_get_password (tab->priv->conn), /* password        */
                 &tab->priv->keyring_item_id);
 
   if (result != GNOME_KEYRING_RESULT_OK)
-    vinagre_utils_show_error (_("Error saving the password on the keyring."),
+    vinagre_utils_show_error (_("Error saving the credential on the keyring."),
 			      GTK_WINDOW (tab->priv->window));
 
-  tab->priv->save_password = FALSE;
+  tab->priv->save_credential = FALSE;
 }
 
-static gchar *
-vinagre_tab_find_password (VinagreTab *tab)
+static gboolean
+vinagre_tab_find_credentials (VinagreTab *tab, gchar **username, gchar **password)
 {
   GnomeKeyringNetworkPasswordData *found_item;
   GnomeKeyringResult               result;
   GList                           *matches;
-  gchar                           *password;
   
-  matches = NULL;
+  matches   = NULL;
+  *username = NULL;
+  *password = NULL;
 
   result = gnome_keyring_find_network_password_sync (
                 NULL,           /* user     */
@@ -493,20 +494,22 @@
 		NULL,           /* object   */
 		"rfb",          /* protocol */
 		"vnc-password", /* authtype */
-		vinagre_connection_get_port (tab->priv->conn),           /* port     */
+		vinagre_connection_get_port (tab->priv->conn),   /* port     */
 		&matches);
 
   if (result != GNOME_KEYRING_RESULT_OK || matches == NULL || matches->data == NULL)
-    return NULL;
+    return FALSE;
 
   found_item = (GnomeKeyringNetworkPasswordData *) matches->data;
 
-  password = g_strdup (found_item->password);
+  *username = g_strdup (found_item->user);
+  *password = g_strdup (found_item->password);
+  
   tab->priv->keyring_item_id = found_item->item_id;
 
   gnome_keyring_network_password_list_free (matches);
 
-  return password;
+  return TRUE;
 }
 
 static void
@@ -541,7 +544,7 @@
   g_free (name);
 
   vinagre_window_set_title (tab->priv->window);
-  vinagre_tab_save_password (tab);
+  vinagre_tab_save_credential (tab);
   vinagre_tab_add_recent_used (tab);
 
   tab->priv->state = VINAGRE_TAB_STATE_CONNECTED;
@@ -553,76 +556,126 @@
 		 0);
 }
 
-static gchar *
-ask_password(VinagreTab *tab)
+static gboolean
+ask_credential (VinagreTab *tab,
+		gboolean    need_username,
+		gboolean    need_password,
+		gchar     **username,
+		gchar     **password)
 {
   GladeXML   *xml;
   const char *glade_file;
-  GtkWidget  *password_dialog, *password_entry, *host_label, *save_password_check;
-  gchar      *password = NULL, *name;
+  GtkWidget  *password_dialog, *password_entry, *host_label, *save_credential_check;
+  GtkWidget  *password_label, *username_label, *username_entry;
+  gchar      *name, *label;
   int         result;
 
+  *username = NULL;
+  *password = NULL;
+
   glade_file = vinagre_utils_get_glade_filename ();
   xml = glade_xml_new (glade_file, NULL, NULL);
 
-  password_dialog = glade_xml_get_widget (xml, "password_required_dialog");
+  password_dialog = glade_xml_get_widget (xml, "auth_required_dialog");
   gtk_window_set_transient_for (GTK_WINDOW(password_dialog), GTK_WINDOW(tab->priv->window));
 
   host_label = glade_xml_get_widget (xml, "host_label");
   name = vinagre_connection_get_best_name (tab->priv->conn);
-  gtk_label_set_text (GTK_LABEL (host_label), name);
+  label = g_strdup_printf ("<i>%s</i>", name);
+  gtk_label_set_markup (GTK_LABEL (host_label), label);
   g_free (name);
+  g_free (label);
+
+  password_entry = glade_xml_get_widget (xml, "password_entry");
+  username_entry = glade_xml_get_widget (xml, "username_entry");
+  password_label = glade_xml_get_widget (xml, "password_label");
+  username_label = glade_xml_get_widget (xml, "username_label");
+  save_credential_check = glade_xml_get_widget (xml, "save_credential_check");
+
+  if (!need_username)
+    {
+      gtk_widget_hide (username_label);
+      gtk_widget_hide (username_entry);
+    }
+
+  if (!need_password)
+    {
+      gtk_widget_hide (password_label);
+      gtk_widget_hide (password_entry);
+    }
 
   result = gtk_dialog_run (GTK_DIALOG (password_dialog));
   if (result == -5)
     {
-      password_entry = glade_xml_get_widget (xml, "password_entry");
-      password = g_strdup (gtk_entry_get_text (GTK_ENTRY (password_entry)));
-
-      save_password_check = glade_xml_get_widget (xml, "save_password_check");
-      tab->priv->save_password = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (save_password_check));
+      *username = g_strdup (gtk_entry_get_text (GTK_ENTRY (username_entry)));
+      *password = g_strdup (gtk_entry_get_text (GTK_ENTRY (password_entry)));
+      tab->priv->save_credential = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (save_credential_check));
     }
 
   gtk_widget_destroy (GTK_WIDGET (password_dialog));
   g_object_unref (xml);
 
-  return password;
+  return result == -5;
 }
 
 static void
 vnc_authentication_cb (VncDisplay *vnc, GValueArray *credList, VinagreTab *tab)
 {
-  gchar *password;
+  gchar *username, *password;
+  gboolean need_password, need_username;
   int i;
 
   if (credList == NULL)
     return;
 
+  need_password = FALSE;
+  need_username = FALSE;
+  username = NULL;
+  password = NULL;
+
   for (i = 0; i < credList->n_values; i++) {
     switch (g_value_get_enum (&credList->values[i]))
       {
-        case VNC_DISPLAY_CREDENTIAL_PASSWORD:
-          password = vinagre_tab_find_password (tab);
-          if (!password)
-            {
-              password = ask_password (tab);
-              if (!password) {
-                vinagre_notebook_remove_tab (tab->priv->nb, tab);
-                return;
-              }
-            }
-
-          vinagre_connection_set_password (tab->priv->conn, password);
-          vnc_display_set_credential (vnc, VNC_DISPLAY_CREDENTIAL_PASSWORD, password);
-
-          g_free (password);
-          break;
+	case VNC_DISPLAY_CREDENTIAL_USERNAME:
+	  need_username= TRUE;
+	  break;
+
+	case VNC_DISPLAY_CREDENTIAL_PASSWORD:
+	  need_password = TRUE;
+	  break;
 
         case VNC_DISPLAY_CREDENTIAL_CLIENTNAME:
           vnc_display_set_credential (vnc, VNC_DISPLAY_CREDENTIAL_CLIENTNAME, "vinagre");
           break;
       }
   }
+
+  if (need_password || need_username)
+    {
+      if (!vinagre_tab_find_credentials (tab, &username, &password))
+	{
+	  if (!ask_credential (tab, need_username, need_password, &username, &password))
+	    {
+	      vinagre_notebook_remove_tab (tab->priv->nb, tab);
+	      return;
+	    }
+	}
+
+      if (need_username && username)
+	{
+	  vinagre_connection_set_username (tab->priv->conn, username);
+	  vnc_display_set_credential (vnc, VNC_DISPLAY_CREDENTIAL_USERNAME, username);
+	}
+
+      if (need_password && password)
+	{
+	  vinagre_connection_set_password (tab->priv->conn, password);
+	  vnc_display_set_credential (vnc, VNC_DISPLAY_CREDENTIAL_PASSWORD, password);
+	}
+
+      g_free (username);
+      g_free (password);
+    }
 }
 
 static void
@@ -790,7 +843,7 @@
   gboolean       shared;
 
   tab->priv = VINAGRE_TAB_GET_PRIVATE (tab);
-  tab->priv->save_password = FALSE;
+  tab->priv->save_credential = FALSE;
   tab->priv->keyring_item_id = 0;
   tab->priv->state = VINAGRE_TAB_STATE_INITIALIZING;
   tab->priv->clipboard_str = NULL;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]