static gboolean validate (CEPage *page, NMConnection *connection, GError **error) { NMSettingWireless *sw; NMSettingConnection *sc; WirelessSecurity *sec; gboolean valid = FALSE; const char *mode; sw = nm_connection_get_setting_wireless (connection); mode = nm_setting_wireless_get_mode (sw); if (g_strcmp0 (mode, NM_SETTING_WIRELESS_MODE_ADHOC) == 0) CE_PAGE_SECURITY (page)->adhoc = TRUE; else CE_PAGE_SECURITY (page)->adhoc = FALSE; sec = security_combo_get_active (CE_PAGE_SECURITY (page)); if (sec) { GBytes *ssid = nm_setting_wireless_get_ssid (sw); if (ssid) { /* FIXME: get failed property and error out of wifi security objects */ valid = wireless_security_validate (sec, error); if (valid) wireless_security_fill_connection (sec, connection); } else { g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_MISSING_SETTING, "Missing SSID"); valid = FALSE; } if (CE_PAGE_SECURITY (page)->adhoc) { if (!wireless_security_adhoc_compatible (sec)) { g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_SETTING, "Security not compatible with Ad-Hoc mode"); valid = FALSE; } } wireless_security_unref (sec); } else { /* No security, unencrypted */ nm_connection_remove_setting (connection, NM_TYPE_SETTING_WIRELESS_SECURITY); nm_connection_remove_setting (connection, NM_TYPE_SETTING_802_1X); valid = TRUE; } sc = nm_connection_get_setting_connection (connection); firewall_ui_to_setting (sc, GTK_WIDGET (CE_PAGE_SECURITY (page)->firewall_combo)); return valid; }
static gboolean validate (CEPage *page, NMConnection *connection, GError **error) { NMSettingWireless *sw; WirelessSecurity *sec; gboolean valid = FALSE; const char *mode; sw = nm_connection_get_setting_wireless (connection); mode = nm_setting_wireless_get_mode (sw); if (g_strcmp0 (mode, NM_SETTING_WIRELESS_MODE_ADHOC) == 0) CE_PAGE_SECURITY (page)->adhoc = TRUE; else CE_PAGE_SECURITY (page)->adhoc = FALSE; sec = security_combo_get_active (CE_PAGE_SECURITY (page)); if (sec) { const GByteArray *ssid = nm_setting_wireless_get_ssid (sw); if (ssid) { /* FIXME: get failed property and error out of wifi security objects */ valid = wireless_security_validate (sec, ssid); if (valid) wireless_security_fill_connection (sec, connection); else g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_UNKNOWN, "Invalid Wi-Fi security"); } else { g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_UNKNOWN, "Missing SSID"); valid = FALSE; } if (CE_PAGE_SECURITY (page)->adhoc) { if (!wireless_security_adhoc_compatible (sec)) { g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_UNKNOWN, "Security not compatible with Ad-Hoc mode"); valid = FALSE; } } wireless_security_unref (sec); } else { /* No security, unencrypted */ g_object_set (sw, NM_SETTING_WIRELESS_SEC, NULL, NULL); nm_connection_remove_setting (connection, NM_TYPE_SETTING_WIRELESS_SECURITY); nm_connection_remove_setting (connection, NM_TYPE_SETTING_802_1X); valid = TRUE; } return valid; }
static void dispose (GObject *object) { CEPageSecurity *page = CE_PAGE_SECURITY (object); g_clear_object (&page->group); G_OBJECT_CLASS (ce_page_security_parent_class)->dispose (object); }
static void security_combo_changed (GtkComboBox *combo, gpointer user_data) { CEPageSecurity *page = CE_PAGE_SECURITY (user_data); GtkWidget *vbox; GList *l, *children; WirelessSecurity *sec; wsec_size_group_clear (page->group); vbox = GTK_WIDGET (gtk_builder_get_object (CE_PAGE (page)->builder, "vbox")); children = gtk_container_get_children (GTK_CONTAINER (vbox)); for (l = children; l; l = l->next) { gtk_container_remove (GTK_CONTAINER (vbox), GTK_WIDGET (l->data)); } sec = security_combo_get_active (page); if (sec) { GtkWidget *sec_widget; GtkWidget *parent; sec_widget = wireless_security_get_widget (sec); g_assert (sec_widget); parent = gtk_widget_get_parent (sec_widget); if (parent) gtk_container_remove (GTK_CONTAINER (parent), sec_widget); gtk_size_group_add_widget (page->group, page->security_heading); gtk_size_group_add_widget (page->group, page->firewall_heading); wireless_security_add_to_size_group (sec, page->group); gtk_container_add (GTK_CONTAINER (vbox), sec_widget); wireless_security_unref (sec); } ce_page_changed (CE_PAGE (page)); }