[network-manager-netbook] Fix a bug where an activated DHCP connection would show invalid "Advanced" contetnt (bnc #536429).



commit 3609e902e3d705dabb3fd5e5dc159aef5db04f8d
Author: Tambet Ingo <tambet gmail com>
Date:   Thu Sep 3 11:20:58 2009 +0300

    Fix a bug where an activated DHCP connection would show invalid "Advanced" contetnt (bnc #536429).

 src/nmn-connection-details.c |   30 +++++++++++++++++-------------
 src/nmn-item.c               |    2 +-
 src/nmn-network-item.c       |   25 ++++++++++++-------------
 3 files changed, 30 insertions(+), 27 deletions(-)
---
diff --git a/src/nmn-connection-details.c b/src/nmn-connection-details.c
index 787858e..7c924fb 100644
--- a/src/nmn-connection-details.c
+++ b/src/nmn-connection-details.c
@@ -113,23 +113,26 @@ nmn_connection_details_set_data (NmnConnectionDetails *self,
     NMIP4Address *address = NULL;
     GString *string;
     char *str;
-    const char *method;
     int i;
 
     g_return_if_fail (NMN_IS_CONNECTION_DETAILS (self));
-    g_return_if_fail (NM_IS_SETTING_IP4_CONFIG (setting));
 
     priv = GET_PRIVATE (self);
 
-    method = nm_setting_ip4_config_get_method (setting);
-    if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO))
+    if (setting) {
+        const char *method;
+
+        method = nm_setting_ip4_config_get_method (setting);
+        if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO))
+            gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->method_auto), TRUE);
+        else if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL))
+            gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->method_manual), TRUE);
+        else if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL))
+            gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->method_link_local), TRUE);
+        else
+            g_assert_not_reached ();
+    } else
         gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->method_auto), TRUE);
-    else if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL))
-        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->method_manual), TRUE);
-    else if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL))
-        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->method_link_local), TRUE);
-    else
-        g_assert_not_reached ();
 
     /* We're editable when we're not connected, ie, when
        the active IP4 config is not present */
@@ -143,7 +146,7 @@ nmn_connection_details_set_data (NmnConnectionDetails *self,
         address = list ? list->data : NULL;
     }
 
-    if (!address)
+    if (!address && setting)
         address = nm_setting_ip4_config_get_address (setting, 0);
 
     if (address) {
@@ -179,7 +182,7 @@ nmn_connection_details_set_data (NmnConnectionDetails *self,
         }
 
         str = g_string_free (string, FALSE);
-    } else {
+    } else if (setting) {
         string = g_string_sized_new (256);
         for (i = 0; i < nm_setting_ip4_config_get_num_dns (setting); i++) {
             if (i > 0)
@@ -191,7 +194,8 @@ nmn_connection_details_set_data (NmnConnectionDetails *self,
         }
 
         str = g_string_free (string, FALSE);
-    }
+    } else
+        str = g_strdup ("");
 
     buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->dns));
     gtk_text_buffer_set_text (buffer, str, -1);
diff --git a/src/nmn-item.c b/src/nmn-item.c
index 251070d..0659621 100644
--- a/src/nmn-item.c
+++ b/src/nmn-item.c
@@ -262,7 +262,7 @@ advanced_changed (NmnItemAdvanced *advanced,
 gboolean
 nmn_item_has_advanced (NmnItem *item)
 {
-    g_return_val_if_fail (NMN_IS_ITEM (item), NULL);
+    g_return_val_if_fail (NMN_IS_ITEM (item), FALSE);
 
     return NMN_ITEM_GET_PRIVATE (item)->advanced != NULL;
 }
diff --git a/src/nmn-network-item.c b/src/nmn-network-item.c
index 70fd80f..e07babf 100644
--- a/src/nmn-network-item.c
+++ b/src/nmn-network-item.c
@@ -86,23 +86,22 @@ update_details (NmnNetworkItem *self,
                 NmnConnectionDetails *details)
 {
     NmnNetworkItemPrivate *priv = GET_PRIVATE (self);
-    NMSettingIP4Config *setting = NULL;
+    NMConnection *connection;
+    NMSettingIP4Config *setting;
+    NMIP4Config *config;
 
-    if (priv->connection) {
-        NMConnection *connection;
-
-        connection = nm_exported_connection_get_connection (priv->connection);
-        setting = (NMSettingIP4Config *) nm_connection_get_setting (connection, NM_TYPE_SETTING_IP4_CONFIG);
-    }
+    if (!priv->connection)
+        return;
 
-    if (setting) {
-        NMIP4Config *config = NULL;
+    connection = nm_exported_connection_get_connection (priv->connection);
+    setting = (NMSettingIP4Config *) nm_connection_get_setting (connection, NM_TYPE_SETTING_IP4_CONFIG);
 
-        if (nm_device_get_state (priv->device) == NM_DEVICE_STATE_ACTIVATED)
-            config = nm_device_get_ip4_config (priv->device);
+    if (nm_device_get_state (priv->device) == NM_DEVICE_STATE_ACTIVATED)
+        config = nm_device_get_ip4_config (priv->device);
+    else
+        config = NULL;
 
-        nmn_connection_details_set_data (details, setting, config);
-    }
+    nmn_connection_details_set_data (details, setting, config);
 }
 
 static void



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