A note is added to the peap and ttls panes to remind the user of
the use of the server hash. The subject entry also shows a string
to notify the user the subject will be probed later.
---
 src/wireless-security/eap-method-peap.c  |   75 ++++++++++++++++++++++++++++-
 src/wireless-security/eap-method-peap.ui |   33 +++++++++----
 src/wireless-security/eap-method-ttls.c  |   75 ++++++++++++++++++++++++++++-
 src/wireless-security/eap-method-ttls.ui |   25 +++++++---
 4 files changed, 184 insertions(+), 24 deletions(-)

diff --git a/src/wireless-security/eap-method-peap.c 
b/src/wireless-security/eap-method-peap.c
index e379e93..028a77e 100644
--- a/src/wireless-security/eap-method-peap.c
+++ b/src/wireless-security/eap-method-peap.c
@@ -35,6 +35,8 @@
 #define I_NAME_COLUMN   0
 #define I_METHOD_COLUMN 1
 
+#define SUBJECT_NOTE _("<will be filled automatically>")
+
 struct _EAPMethodPEAP {
        EAPMethod parent;
 
@@ -93,6 +95,10 @@ add_to_size_group (EAPMethod *parent, GtkSizeGroup *group)
        g_assert (widget);
        gtk_size_group_add_widget (group, widget);
 
+       widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, 
"eap_peap_subject_label"));
+       g_assert (widget);
+       gtk_size_group_add_widget (group, widget);
+
        widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, 
"eap_peap_ca_cert_label"));
        g_assert (widget);
        gtk_size_group_add_widget (group, widget);
@@ -144,7 +150,7 @@ fill_connection (EAPMethod *parent, NMConnection 
*connection)
        widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, 
"eap_peap_subject_entry"));
        g_assert (widget);
        text = gtk_entry_get_text (GTK_ENTRY (widget));
-       if (text && strlen (text))
+       if (text && strlen (text)  && g_strcmp0 (text, SUBJECT_NOTE) != 0)
                g_object_set (s_8021x, NM_SETTING_802_1X_SUBJECT_MATCH, text, 
NULL);
 
        widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, 
"eap_peap_ca_cert_button"));
@@ -314,6 +320,37 @@ update_secrets (EAPMethod *parent, NMConnection 
*connection)
                                                 I_METHOD_COLUMN);
 }
 
+static gboolean
+subject_entry_focus_in_cb (GtkWidget *widget,
+                           GdkEvent  *event,
+                           gpointer user_data)
+{
+       const char *text = gtk_entry_get_text (GTK_ENTRY (widget));
+       if (g_strcmp0 (text, SUBJECT_NOTE) == 0) {
+               gtk_entry_set_text (GTK_ENTRY (widget), "");
+               gtk_widget_override_color (widget, GTK_STATE_FLAG_NORMAL, NULL);
+       }
+       return FALSE;
+}
+
+static gboolean
+subject_entry_focus_out_cb (GtkWidget *widget,
+                            GdkEvent  *event,
+                            gpointer user_data)
+{
+       const char *text = gtk_entry_get_text (GTK_ENTRY (widget));
+       GtkStyleContext *context;
+       GdkRGBA color;
+
+       if (!text || !strlen (text)) {
+               gtk_entry_set_text (GTK_ENTRY (widget), SUBJECT_NOTE);
+               context = gtk_widget_get_style_context (widget);
+               gtk_style_context_get_color (context, 
GTK_STATE_FLAG_INSENSITIVE, &color);
+               gtk_widget_override_color (widget, GTK_STATE_FLAG_NORMAL, 
&color);
+       }
+       return FALSE;
+}
+
 EAPMethodPEAP *
 eap_method_peap_new (WirelessSecurity *ws_parent,
                      NMConnection *connection,
@@ -390,12 +427,42 @@ eap_method_peap_new (WirelessSecurity *ws_parent,
                          ws_parent);
 
        widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, 
"eap_peap_subject_entry"));
-       if (s_8021x && nm_setting_802_1x_get_subject_match (s_8021x))
-               gtk_entry_set_text (GTK_ENTRY (widget), 
nm_setting_802_1x_get_subject_match (s_8021x));
+       if (s_8021x) {
+               const char *text = nm_setting_802_1x_get_subject_match 
(s_8021x);
+               if (!text) {
+                       GtkStyleContext *context;
+                       GdkRGBA color;
+                       context = gtk_widget_get_style_context (widget);
+                       gtk_style_context_get_color (context, 
GTK_STATE_FLAG_INSENSITIVE, &color);
+                       gtk_widget_override_color (widget, 
GTK_STATE_FLAG_NORMAL, &color);
+                       gtk_entry_set_text (GTK_ENTRY (widget), SUBJECT_NOTE);
+               } else {
+                       gtk_entry_set_text (GTK_ENTRY (widget), text);
+               }
+               g_signal_connect (G_OBJECT (widget), "focus-in-event",
+                                 (GCallback) subject_entry_focus_in_cb,
+                                 NULL);
+               g_signal_connect (G_OBJECT (widget), "focus-out-event",
+                                 (GCallback) subject_entry_focus_out_cb,
+                                 NULL);
+       }
        g_signal_connect (G_OBJECT (widget), "changed",
                          (GCallback) wireless_security_changed_cb,
                          ws_parent);
 
+       widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, 
"eap_peap_note_label"));
+       if (s_8021x) {
+               NMSetting8021xCKScheme cert_scheme;
+               cert_scheme = nm_setting_802_1x_get_ca_cert_scheme (s_8021x);
+               if (cert_scheme == NM_SETTING_802_1X_CK_SCHEME_HASH) {
+                       gtk_label_set_text (GTK_LABEL (widget),
+                                           _("<b>Note:</b> Server hash is used 
instead of CA certificate"));
+                       gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
+               } else {
+                       gtk_widget_hide (widget);
+               }
+       }
+
        widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, 
"eap_peap_anon_identity_entry"));
        if (s_8021x && nm_setting_802_1x_get_anonymous_identity (s_8021x))
                gtk_entry_set_text (GTK_ENTRY (widget), 
nm_setting_802_1x_get_anonymous_identity (s_8021x));
@@ -416,6 +483,8 @@ eap_method_peap_new (WirelessSecurity *ws_parent,
                gtk_widget_hide (widget);
                widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, 
"eap_peap_ca_cert_button"));
                gtk_widget_hide (widget);
+               widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, 
"eap_peap_note_label"));
+               gtk_widget_hide (widget);
                widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, 
"eap_peap_inner_auth_label"));
                gtk_widget_hide (widget);
                widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, 
"eap_peap_inner_auth_combo"));
diff --git a/src/wireless-security/eap-method-peap.ui 
b/src/wireless-security/eap-method-peap.ui
index f38fc83..e0a9370 100644
--- a/src/wireless-security/eap-method-peap.ui
+++ b/src/wireless-security/eap-method-peap.ui
@@ -35,7 +35,7 @@
         <child>
           <object class="GtkTable" id="table13">
             <property name="visible">True</property>
-            <property name="n_rows">6</property>
+            <property name="n_rows">7</property>
             <property name="n_columns">2</property>
             <property name="column_spacing">12</property>
             <property name="row_spacing">6</property>
@@ -122,6 +122,17 @@
               </packing>
             </child>
             <child>
+              <object class="GtkLabel" id="eap_peap_note_label">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">Note</property>
+              </object>
+              <packing>
+                <property name="right_attach">2</property>
+                <property name="top_attach">3</property>
+                <property name="bottom_attach">4</property>
+              </packing>
+            </child>
+            <child>
               <object class="GtkVBox" id="eap_peap_inner_auth_vbox">
                 <property name="visible">True</property>
                 <property name="orientation">vertical</property>
@@ -131,8 +142,8 @@
               </object>
               <packing>
                 <property name="right_attach">2</property>
-                <property name="top_attach">5</property>
-                <property name="bottom_attach">6</property>
+                <property name="top_attach">6</property>
+                <property name="bottom_attach">7</property>
                 <property name="x_options">GTK_FILL</property>
               </packing>
             </child>
@@ -145,8 +156,8 @@
                 <property 
name="mnemonic_widget">eap_peap_inner_auth_combo</property>
               </object>
               <packing>
-                <property name="top_attach">4</property>
-                <property name="bottom_attach">5</property>
+                <property name="top_attach">5</property>
+                <property name="bottom_attach">6</property>
                 <property name="x_options">GTK_FILL</property>
                 <property name="y_options"/>
               </packing>
@@ -165,8 +176,8 @@
               <packing>
                 <property name="left_attach">1</property>
                 <property name="right_attach">2</property>
-                <property name="top_attach">4</property>
-                <property name="bottom_attach">5</property>
+                <property name="top_attach">5</property>
+                <property name="bottom_attach">6</property>
                 <property name="x_options">GTK_FILL</property>
                 <property name="y_options">GTK_FILL</property>
               </packing>
@@ -180,8 +191,8 @@
                 <property 
name="mnemonic_widget">eap_peap_version_combo</property>
               </object>
               <packing>
-                <property name="top_attach">3</property>
-                <property name="bottom_attach">4</property>
+                <property name="top_attach">4</property>
+                <property name="bottom_attach">5</property>
                 <property name="x_options">GTK_FILL</property>
                 <property name="y_options"/>
               </packing>
@@ -200,8 +211,8 @@
               <packing>
                 <property name="left_attach">1</property>
                 <property name="right_attach">2</property>
-                <property name="top_attach">3</property>
-                <property name="bottom_attach">4</property>
+                <property name="top_attach">4</property>
+                <property name="bottom_attach">5</property>
                 <property name="x_options">GTK_FILL</property>
                 <property name="y_options">GTK_FILL</property>
               </packing>
diff --git a/src/wireless-security/eap-method-ttls.c 
b/src/wireless-security/eap-method-ttls.c
index bea8741..d5e55bf 100644
--- a/src/wireless-security/eap-method-ttls.c
+++ b/src/wireless-security/eap-method-ttls.c
@@ -35,6 +35,8 @@
 #define I_NAME_COLUMN   0
 #define I_METHOD_COLUMN 1
 
+#define SUBJECT_NOTE _("<will be filled automatically>")
+
 struct _EAPMethodTTLS {
        EAPMethod parent;
 
@@ -93,6 +95,10 @@ add_to_size_group (EAPMethod *parent, GtkSizeGroup *group)
        g_assert (widget);
        gtk_size_group_add_widget (group, widget);
 
+       widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, 
"eap_ttls_subject_label"));
+       g_assert (widget);
+       gtk_size_group_add_widget (group, widget);
+
        widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, 
"eap_ttls_ca_cert_label"));
        g_assert (widget);
        gtk_size_group_add_widget (group, widget);
@@ -139,7 +145,7 @@ fill_connection (EAPMethod *parent, NMConnection 
*connection)
        widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, 
"eap_ttls_subject_entry"));
        g_assert (widget);
        text = gtk_entry_get_text (GTK_ENTRY (widget));
-       if (text && strlen (text))
+       if (text && strlen (text)  && g_strcmp0 (text, SUBJECT_NOTE) != 0)
                g_object_set (s_8021x, NM_SETTING_802_1X_SUBJECT_MATCH, text, 
NULL);
 
        widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, 
"eap_ttls_ca_cert_button"));
@@ -314,6 +320,37 @@ update_secrets (EAPMethod *parent, NMConnection 
*connection)
                                                 I_METHOD_COLUMN);
 }
 
+static gboolean
+subject_entry_focus_in_cb (GtkWidget *widget,
+                           GdkEvent  *event,
+                           gpointer user_data)
+{
+       const char *text = gtk_entry_get_text (GTK_ENTRY (widget));
+       if (g_strcmp0 (text, SUBJECT_NOTE) == 0) {
+               gtk_entry_set_text (GTK_ENTRY (widget), "");
+               gtk_widget_override_color (widget, GTK_STATE_FLAG_NORMAL, NULL);
+       }
+       return FALSE;
+}
+
+static gboolean
+subject_entry_focus_out_cb (GtkWidget *widget,
+                            GdkEvent  *event,
+                            gpointer user_data)
+{
+       const char *text = gtk_entry_get_text (GTK_ENTRY (widget));
+       GtkStyleContext *context;
+       GdkRGBA color;
+
+       if (!text || !strlen (text)) {
+               gtk_entry_set_text (GTK_ENTRY (widget), SUBJECT_NOTE);
+               context = gtk_widget_get_style_context (widget);
+               gtk_style_context_get_color (context, 
GTK_STATE_FLAG_INSENSITIVE, &color);
+               gtk_widget_override_color (widget, GTK_STATE_FLAG_NORMAL, 
&color);
+       }
+       return FALSE;
+}
+
 EAPMethodTTLS *
 eap_method_ttls_new (WirelessSecurity *ws_parent,
                      NMConnection *connection,
@@ -368,12 +405,42 @@ eap_method_ttls_new (WirelessSecurity *ws_parent,
        }
 
        widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, 
"eap_ttls_subject_entry"));
-       if (s_8021x && nm_setting_802_1x_get_subject_match (s_8021x))
-               gtk_entry_set_text (GTK_ENTRY (widget), 
nm_setting_802_1x_get_subject_match (s_8021x));
+       if (s_8021x) {
+               const char *text = nm_setting_802_1x_get_subject_match 
(s_8021x);
+               if (!text) {
+                       GtkStyleContext *context;
+                       GdkRGBA color;
+                       context = gtk_widget_get_style_context (widget);
+                       gtk_style_context_get_color (context, 
GTK_STATE_FLAG_INSENSITIVE, &color);
+                       gtk_widget_override_color (widget, 
GTK_STATE_FLAG_NORMAL, &color);
+                       gtk_entry_set_text (GTK_ENTRY (widget), SUBJECT_NOTE);
+               } else {
+                       gtk_entry_set_text (GTK_ENTRY (widget), text);
+               }
+               g_signal_connect (G_OBJECT (widget), "focus-in-event",
+                                 (GCallback) subject_entry_focus_in_cb,
+                                 NULL);
+               g_signal_connect (G_OBJECT (widget), "focus-out-event",
+                                 (GCallback) subject_entry_focus_out_cb,
+                                 NULL);
+       }
        g_signal_connect (G_OBJECT (widget), "changed",
                          (GCallback) wireless_security_changed_cb,
                          ws_parent);
 
+       widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, 
"eap_ttls_note_label"));
+       if (s_8021x) {
+               NMSetting8021xCKScheme cert_scheme;
+               cert_scheme = nm_setting_802_1x_get_ca_cert_scheme (s_8021x);
+               if (cert_scheme == NM_SETTING_802_1X_CK_SCHEME_HASH) {
+                       gtk_label_set_text (GTK_LABEL (widget),
+                                           _("<b>Note:</b> Server hash is used 
instead of CA certificate"));
+                       gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
+               } else {
+                       gtk_widget_hide (widget);
+               }
+       }
+
        widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, 
"eap_ttls_anon_identity_entry"));
        if (s_8021x && nm_setting_802_1x_get_anonymous_identity (s_8021x))
                gtk_entry_set_text (GTK_ENTRY (widget), 
nm_setting_802_1x_get_anonymous_identity (s_8021x));
@@ -397,6 +464,8 @@ eap_method_ttls_new (WirelessSecurity *ws_parent,
                gtk_widget_hide (widget);
                widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, 
"eap_ttls_ca_cert_button"));
                gtk_widget_hide (widget);
+               widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, 
"eap_ttls_note_label"));
+               gtk_widget_hide (widget);
                widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, 
"eap_ttls_inner_auth_label"));
                gtk_widget_hide (widget);
                widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, 
"eap_ttls_inner_auth_combo"));
diff --git a/src/wireless-security/eap-method-ttls.ui 
b/src/wireless-security/eap-method-ttls.ui
index 4a82630..bb2444a 100644
--- a/src/wireless-security/eap-method-ttls.ui
+++ b/src/wireless-security/eap-method-ttls.ui
@@ -19,7 +19,7 @@
         <child>
           <object class="GtkTable" id="table10">
             <property name="visible">True</property>
-            <property name="n_rows">5</property>
+            <property name="n_rows">6</property>
             <property name="n_columns">2</property>
             <property name="column_spacing">12</property>
             <property name="row_spacing">6</property>
@@ -106,6 +106,17 @@
               </packing>
             </child>
             <child>
+              <object class="GtkLabel" id="eap_ttls_note_label">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">Note</property>
+              </object>
+              <packing>
+                <property name="right_attach">2</property>
+                <property name="top_attach">3</property>
+                <property name="bottom_attach">4</property>
+              </packing>
+            </child>
+            <child>
               <object class="GtkLabel" id="eap_ttls_inner_auth_label">
                 <property name="visible">True</property>
                 <property name="xalign">0</property>
@@ -114,8 +125,8 @@
                 <property 
name="mnemonic_widget">eap_ttls_inner_auth_combo</property>
               </object>
               <packing>
-                <property name="top_attach">3</property>
-                <property name="bottom_attach">4</property>
+                <property name="top_attach">4</property>
+                <property name="bottom_attach">5</property>
                 <property name="x_options">GTK_FILL</property>
                 <property name="y_options"/>
               </packing>
@@ -134,8 +145,8 @@
               <packing>
                 <property name="left_attach">1</property>
                 <property name="right_attach">2</property>
-                <property name="top_attach">3</property>
-                <property name="bottom_attach">4</property>
+                <property name="top_attach">4</property>
+                <property name="bottom_attach">5</property>
                 <property name="x_options">GTK_FILL</property>
                 <property name="y_options">GTK_FILL</property>
               </packing>
@@ -151,8 +162,8 @@
               </object>
               <packing>
                 <property name="right_attach">2</property>
-                <property name="top_attach">4</property>
-                <property name="bottom_attach">5</property>
+                <property name="top_attach">5</property>
+                <property name="bottom_attach">6</property>
                 <property name="x_options">GTK_FILL</property>
               </packing>
             </child>
-- 
1.7.3.4

_______________________________________________
networkmanager-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/networkmanager-list

Reply via email to