core: add 'default6' property to ActiveConnection implementations
authorDan Williams <dcbw@redhat.com>
Thu, 15 Apr 2010 22:26:11 +0000 (15:26 -0700)
committerDan Williams <dcbw@redhat.com>
Thu, 15 Apr 2010 22:26:11 +0000 (15:26 -0700)
src/nm-activation-request.c
src/nm-activation-request.h
src/nm-active-connection.h
src/vpn-manager/nm-vpn-connection.c

index 1335c35..2529e77 100644 (file)
@@ -72,6 +72,7 @@ typedef struct {
 
        NMActiveConnectionState state;
        gboolean is_default;
+       gboolean is_default6;
        gboolean shared;
        GSList *share_rules;
 
@@ -88,6 +89,7 @@ enum {
        PROP_DEVICES,
        PROP_STATE,
        PROP_DEFAULT,
+       PROP_DEFAULT6,
        PROP_VPN,
 
        LAST_PROP
@@ -104,7 +106,7 @@ device_state_changed (NMDevice *device,
        NMActRequest *self = NM_ACT_REQUEST (user_data);
        NMActRequestPrivate *priv = NM_ACT_REQUEST_GET_PRIVATE (self);
        NMActiveConnectionState new_ac_state;
-       gboolean new_default = FALSE;
+       gboolean new_default = FALSE, new_default6 = FALSE;
 
        /* Set NMActiveConnection state based on the device's state */
        switch (new_state) {
@@ -117,6 +119,7 @@ device_state_changed (NMDevice *device,
        case NM_DEVICE_STATE_ACTIVATED:
                new_ac_state = NM_ACTIVE_CONNECTION_STATE_ACTIVATED;
                new_default = priv->is_default;
+               new_default6 = priv->is_default6;
                break;
        default:
                new_ac_state = NM_ACTIVE_CONNECTION_STATE_UNKNOWN;
@@ -132,6 +135,11 @@ device_state_changed (NMDevice *device,
                priv->is_default = new_default;
                g_object_notify (G_OBJECT (self), NM_ACTIVE_CONNECTION_DEFAULT);
        }
+
+       if (new_default6 != priv->is_default6) {
+               priv->is_default6 = new_default6;
+               g_object_notify (G_OBJECT (self), NM_ACTIVE_CONNECTION_DEFAULT6);
+       }
 }
 
 NMActRequest *
@@ -271,6 +279,9 @@ get_property (GObject *object, guint prop_id,
        case PROP_DEFAULT:
                g_value_set_boolean (value, priv->is_default);
                break;
+       case PROP_DEFAULT6:
+               g_value_set_boolean (value, priv->is_default6);
+               break;
        case PROP_VPN:
                g_value_set_boolean (value, FALSE);
                break;
@@ -334,7 +345,14 @@ nm_act_request_class_init (NMActRequestClass *req_class)
                (object_class, PROP_DEFAULT,
                 g_param_spec_boolean (NM_ACTIVE_CONNECTION_DEFAULT,
                                                           "Default",
-                                                          "Is the default active connection",
+                                                          "Is the default IPv4 active connection",
+                                                          FALSE,
+                                                          G_PARAM_READABLE));
+       g_object_class_install_property
+               (object_class, PROP_DEFAULT6,
+                g_param_spec_boolean (NM_ACTIVE_CONNECTION_DEFAULT6,
+                                                          "Default6",
+                                                          "Is the default IPv6 active connection",
                                                           FALSE,
                                                           G_PARAM_READABLE));
        g_object_class_install_property
@@ -548,6 +566,29 @@ nm_act_request_get_default (NMActRequest *req)
        return NM_ACT_REQUEST_GET_PRIVATE (req)->is_default;
 }
 
+void
+nm_act_request_set_default6 (NMActRequest *req, gboolean is_default6)
+{
+       NMActRequestPrivate *priv;
+
+       g_return_if_fail (NM_IS_ACT_REQUEST (req));
+
+       priv = NM_ACT_REQUEST_GET_PRIVATE (req);
+       if (priv->is_default6 == is_default6)
+               return;
+
+       priv->is_default6 = is_default6;
+       g_object_notify (G_OBJECT (req), NM_ACTIVE_CONNECTION_DEFAULT6);
+}
+
+gboolean
+nm_act_request_get_default6 (NMActRequest *req)
+{
+       g_return_val_if_fail (NM_IS_ACT_REQUEST (req), FALSE);
+
+       return NM_ACT_REQUEST_GET_PRIVATE (req)->is_default6;
+}
+
 static void
 share_child_setup (gpointer user_data G_GNUC_UNUSED)
 {
index a3c0d97..a243694 100644 (file)
@@ -15,7 +15,7 @@
  * with this program; if not, write to the Free Software Foundation, Inc.,
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  *
- * (C) Copyright 2005 - 2008 Red Hat, Inc.
+ * (C) Copyright 2005 - 2010 Red Hat, Inc.
  */
 
 #ifndef NM_ACTIVATION_REQUEST_H
@@ -76,6 +76,10 @@ void          nm_act_request_set_default (NMActRequest *req, gboolean is_default
 
 gboolean      nm_act_request_get_default (NMActRequest *req);
 
+void          nm_act_request_set_default6 (NMActRequest *req, gboolean is_default6);
+
+gboolean      nm_act_request_get_default6 (NMActRequest *req);
+
 gboolean      nm_act_request_get_shared (NMActRequest *req);
 
 void          nm_act_request_set_shared (NMActRequest *req, gboolean shared);
index 4a1f2e1..6a463cb 100644 (file)
@@ -15,7 +15,7 @@
  * with this program; if not, write to the Free Software Foundation, Inc.,
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  *
- * Copyright (C) 2008 Red Hat, Inc.
+ * Copyright (C) 2008 - 2010 Red Hat, Inc.
  */
 
 #ifndef NM_ACTIVE_CONNECTION_H
@@ -30,6 +30,7 @@
 #define NM_ACTIVE_CONNECTION_DEVICES "devices"
 #define NM_ACTIVE_CONNECTION_STATE "state"
 #define NM_ACTIVE_CONNECTION_DEFAULT "default"
+#define NM_ACTIVE_CONNECTION_DEFAULT6 "default6"
 #define NM_ACTIVE_CONNECTION_VPN "vpn"
 
 char *nm_active_connection_get_next_object_path (void);
index 01f639a..a594df5 100644 (file)
@@ -69,6 +69,7 @@ typedef struct {
        gulong device_ip4;
 
        gboolean is_default;
+       gboolean is_default6;
        NMActiveConnectionState state;
 
        NMVPNConnectionState vpn_state;
@@ -102,6 +103,7 @@ enum {
        PROP_DEVICES,
        PROP_STATE,
        PROP_DEFAULT,
+       PROP_DEFAULT6,
        PROP_VPN,
        PROP_VPN_STATE,
        PROP_BANNER,
@@ -1052,6 +1054,9 @@ get_property (GObject *object, guint prop_id,
        case PROP_DEFAULT:
                g_value_set_boolean (value, priv->is_default);
                break;
+       case PROP_DEFAULT6:
+               g_value_set_boolean (value, priv->is_default6);
+               break;
        case PROP_VPN:
                g_value_set_boolean (value, TRUE);
                break;
@@ -1122,7 +1127,14 @@ nm_vpn_connection_class_init (NMVPNConnectionClass *connection_class)
                (object_class, PROP_DEFAULT,
                 g_param_spec_boolean (NM_ACTIVE_CONNECTION_DEFAULT,
                                                           "Default",
-                                                          "Is the default active connection",
+                                                          "Is the default IPv4 active connection",
+                                                          FALSE,
+                                                          G_PARAM_READABLE));
+       g_object_class_install_property
+               (object_class, PROP_DEFAULT6,
+                g_param_spec_boolean (NM_ACTIVE_CONNECTION_DEFAULT6,
+                                                          "Default6",
+                                                          "Is the default IPv6 active connection",
                                                           FALSE,
                                                           G_PARAM_READABLE));
        g_object_class_install_property