CEPage * ce_page_wired_new (NMConnection *connection, GtkWindow *parent_window, NMClient *client, const char **out_secrets_setting_name, GError **error) { CEPageWired *self; CEPageWiredPrivate *priv; self = CE_PAGE_WIRED (ce_page_new (CE_TYPE_PAGE_WIRED, connection, parent_window, client, UIDIR "/ce-page-wired.ui", "WiredPage", _("Wired"))); if (!self) { g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("Could not load wired user interface.")); return NULL; } wired_private_init (self); priv = CE_PAGE_WIRED_GET_PRIVATE (self); priv->setting = nm_connection_get_setting_wired (connection); if (!priv->setting) { priv->setting = NM_SETTING_WIRED (nm_setting_wired_new ()); nm_connection_add_setting (connection, NM_SETTING (priv->setting)); } g_signal_connect (self, "initialized", G_CALLBACK (finish_setup), NULL); return CE_PAGE (self); }
static void update_wired_setting_from_if_block(NMConnection *connection, if_block *block) { NMSettingWired *s_wired = NULL; s_wired = NM_SETTING_WIRED(nm_setting_wired_new()); nm_connection_add_setting(connection, NM_SETTING(s_wired)); }
CEPage * ce_page_wired_new (NMConnection *connection, GtkWindow *parent_window, const char **out_secrets_setting_name, GError **error) { CEPageWired *self; CEPageWiredPrivate *priv; CEPage *parent; self = CE_PAGE_WIRED (g_object_new (CE_TYPE_PAGE_WIRED, CE_PAGE_CONNECTION, connection, CE_PAGE_PARENT_WINDOW, parent_window, NULL)); parent = CE_PAGE (self); parent->xml = glade_xml_new (GLADEDIR "/ce-page-wired.glade", "WiredPage", NULL); if (!parent->xml) { g_set_error (error, 0, 0, "%s", _("Could not load wired user interface.")); g_object_unref (self); return NULL; } parent->page = glade_xml_get_widget (parent->xml, "WiredPage"); if (!parent->page) { g_set_error (error, 0, 0, "%s", _("Could not load wired user interface.")); g_object_unref (self); return NULL; } g_object_ref_sink (parent->page); parent->title = g_strdup (_("Wired")); wired_private_init (self); priv = CE_PAGE_WIRED_GET_PRIVATE (self); priv->setting = (NMSettingWired *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRED); if (!priv->setting) { priv->setting = NM_SETTING_WIRED (nm_setting_wired_new ()); nm_connection_add_setting (connection, NM_SETTING (priv->setting)); } g_signal_connect (self, "initialized", G_CALLBACK (finish_setup), NULL); return CE_PAGE (self); }
static void get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { NMSettingWired *setting = NM_SETTING_WIRED (object); NMSettingWiredPrivate *priv = NM_SETTING_WIRED_GET_PRIVATE (setting); switch (prop_id) { case PROP_PORT: g_value_set_string (value, nm_setting_wired_get_port (setting)); break; case PROP_SPEED: g_value_set_uint (value, nm_setting_wired_get_speed (setting)); break; case PROP_DUPLEX: g_value_set_string (value, nm_setting_wired_get_duplex (setting)); break; case PROP_AUTO_NEGOTIATE: g_value_set_boolean (value, nm_setting_wired_get_auto_negotiate (setting)); break; case PROP_MAC_ADDRESS: g_value_set_boxed (value, nm_setting_wired_get_mac_address (setting)); break; case PROP_CLONED_MAC_ADDRESS: g_value_set_boxed (value, nm_setting_wired_get_cloned_mac_address (setting)); break; case PROP_MAC_ADDRESS_BLACKLIST: g_value_set_boxed (value, nm_setting_wired_get_mac_address_blacklist (setting)); break; case PROP_MTU: g_value_set_uint (value, nm_setting_wired_get_mtu (setting)); break; case PROP_S390_SUBCHANNELS: g_value_set_boxed (value, nm_setting_wired_get_s390_subchannels (setting)); break; case PROP_S390_NETTYPE: g_value_set_string (value, nm_setting_wired_get_s390_nettype (setting)); break; case PROP_S390_OPTIONS: g_value_set_boxed (value, priv->s390_options); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
static void ui_to_setting (CEPageBond *self) { CEPageBondPrivate *priv = CE_PAGE_BOND_GET_PRIVATE (self); NMConnection *connection = CE_PAGE (self)->connection; const char *mode; const char *frequency; const char *updelay; const char *downdelay; const char *primary = NULL; char *targets; guint32 mtu; /* Mode */ switch (gtk_combo_box_get_active (priv->mode)) { case MODE_BALANCE_RR: mode = "balance-rr"; break; case MODE_ACTIVE_BACKUP: mode = "active-backup"; primary = gtk_entry_get_text (priv->primary); break; case MODE_BALANCE_XOR: mode = "balance-xor"; break; case MODE_BROADCAST: mode = "broadcast"; break; case MODE_802_3AD: mode = "802.3ad"; break; case MODE_BALANCE_TLB: mode = "balance-tlb"; break; case MODE_BALANCE_ALB: mode = "balance-alb"; break; default: g_assert_not_reached (); break; } /* Set bond mode and primary */ nm_setting_bond_add_option (priv->setting, NM_SETTING_BOND_OPTION_MODE, mode); if (primary && *primary) nm_setting_bond_add_option (priv->setting, NM_SETTING_BOND_OPTION_PRIMARY, primary); else nm_setting_bond_remove_option (priv->setting, NM_SETTING_BOND_OPTION_PRIMARY); /* Monitoring mode/frequency */ frequency = gtk_entry_get_text (GTK_ENTRY (priv->frequency)); updelay = gtk_entry_get_text (GTK_ENTRY (priv->updelay)); downdelay = gtk_entry_get_text (GTK_ENTRY (priv->downdelay)); targets = uglify_targets (gtk_entry_get_text (priv->arp_targets)); switch (gtk_combo_box_get_active (priv->monitoring)) { case MONITORING_MII: nm_setting_bond_add_option (priv->setting, NM_SETTING_BOND_OPTION_MIIMON, frequency); nm_setting_bond_add_option (priv->setting, NM_SETTING_BOND_OPTION_UPDELAY, updelay); nm_setting_bond_add_option (priv->setting, NM_SETTING_BOND_OPTION_DOWNDELAY, downdelay); nm_setting_bond_remove_option (priv->setting, NM_SETTING_BOND_OPTION_ARP_INTERVAL); nm_setting_bond_remove_option (priv->setting, NM_SETTING_BOND_OPTION_ARP_IP_TARGET); break; case MONITORING_ARP: nm_setting_bond_add_option (priv->setting, NM_SETTING_BOND_OPTION_ARP_INTERVAL, frequency); if (targets) nm_setting_bond_add_option (priv->setting, NM_SETTING_BOND_OPTION_ARP_IP_TARGET, targets); else nm_setting_bond_remove_option (priv->setting, NM_SETTING_BOND_OPTION_ARP_IP_TARGET); nm_setting_bond_remove_option (priv->setting, NM_SETTING_BOND_OPTION_MIIMON); nm_setting_bond_remove_option (priv->setting, NM_SETTING_BOND_OPTION_UPDELAY); nm_setting_bond_remove_option (priv->setting, NM_SETTING_BOND_OPTION_DOWNDELAY); break; default: g_assert_not_reached (); break; } g_free (targets); mtu = gtk_spin_button_get_value_as_int (priv->mtu); if (mtu && !priv->wired) { priv->wired = NM_SETTING_WIRED (nm_setting_wired_new ()); nm_connection_add_setting (connection, NM_SETTING (priv->wired)); } if (priv->wired) g_object_set (priv->wired, NM_SETTING_WIRED_MTU, mtu, NULL); }
static void populate_ui (CEPageVlan *self) { CEPageVlanPrivate *priv = CE_PAGE_VLAN_GET_PRIVATE (self); GSList *devices, *d_iter; NMConnection *parent_connection = NULL; NMDevice *device, *parent_device = NULL; const char *parent, *iface, *current_parent; int i, mtu_def, mtu_val; devices = get_vlan_devices (self); /* Parent */ build_vlan_parent_list (self, devices); parent = nm_setting_vlan_get_parent (priv->setting); if (parent) { /* UUID? */ parent_connection = (NMConnection *)nm_remote_settings_get_connection_by_uuid (CE_PAGE (self)->settings, parent); if (!parent_connection) { /* Interface name? */ for (d_iter = devices; d_iter; d_iter = d_iter->next) { device = d_iter->data; if (!g_strcmp0 (parent, nm_device_get_iface (device))) { parent_device = device; break; } } } } /* If NMSettingVlan:parent didn't indicate a device, but we have a * wired setting, figure out the device from that. */ if (priv->s_hw && !parent_device) { const GByteArray *mac; const char *device_mac_str; char *mac_str; if (NM_IS_SETTING_WIRED (priv->s_hw)) mac = nm_setting_wired_get_mac_address (NM_SETTING_WIRED (priv->s_hw)); else mac = NULL; if (mac) { mac_str = nm_utils_hwaddr_ntoa (mac->data, ARPHRD_ETHER); for (d_iter = devices; d_iter; d_iter = d_iter->next) { device = d_iter->data; if (NM_IS_DEVICE_ETHERNET (device)) device_mac_str = nm_device_ethernet_get_permanent_hw_address (NM_DEVICE_ETHERNET (device)); else device_mac_str = NULL; if (!g_strcmp0 (mac_str, device_mac_str)) { parent_device = device; break; } } } } current_parent = parent; if (parent_device || parent_connection) { for (i = 0; priv->parents[i]; i++) { if (parent_device && parent_device != priv->parents[i]->device) continue; if (parent_connection != priv->parents[i]->connection) continue; current_parent = priv->parents[i]->label; break; } } ce_page_setup_mac_combo (CE_PAGE (self), priv->parent, current_parent, priv->parent_labels); g_signal_connect (priv->parent, "changed", G_CALLBACK (parent_changed), self); if (current_parent) priv->last_parent = g_strndup (current_parent, strcspn (current_parent, " ")); /* Name */ iface = nm_setting_vlan_get_interface_name (priv->setting); if (iface) gtk_entry_set_text (priv->name_entry, iface); g_signal_connect (priv->name_entry, "changed", G_CALLBACK (name_changed), self); /* ID */ priv->last_id = nm_setting_vlan_get_id (priv->setting); gtk_spin_button_set_value (priv->id_entry, priv->last_id); g_signal_connect (priv->id_entry, "value-changed", G_CALLBACK (id_changed), self); /* Cloned MAC address */ if (NM_IS_SETTING_WIRED (priv->s_hw)) { ce_page_mac_to_entry (nm_setting_wired_get_cloned_mac_address (NM_SETTING_WIRED (priv->s_hw)), ARPHRD_ETHER, priv->cloned_mac); } g_signal_connect (priv->cloned_mac, "changed", G_CALLBACK (stuff_changed), self); /* MTU */ if (NM_IS_SETTING_WIRED (priv->s_hw)) { mtu_def = ce_get_property_default (priv->s_hw, NM_SETTING_WIRED_MTU); mtu_val = nm_setting_wired_get_mtu (NM_SETTING_WIRED (priv->s_hw)); } else { mtu_def = mtu_val = 1500; } g_signal_connect (priv->mtu, "output", G_CALLBACK (ce_spin_output_with_default), GINT_TO_POINTER (mtu_def)); gtk_spin_button_set_value (priv->mtu, (gdouble) mtu_val); g_signal_connect (priv->mtu, "value-changed", G_CALLBACK (stuff_changed), self); g_slist_free (devices); }