Пример #1
0
static gboolean
validate (CEPage *page, NMConnection *connection, GError **error)
{
	CEPageWired *self = CE_PAGE_WIRED (page);
	CEPageWiredPrivate *priv = CE_PAGE_WIRED_GET_PRIVATE (self);
	gboolean invalid = FALSE;
	GByteArray *ignore;
	GtkWidget *entry;

	entry = gtk_bin_get_child (GTK_BIN (priv->device_mac));
	if (entry) {
		ignore = ce_page_entry_to_mac (GTK_ENTRY (entry), &invalid);
		if (invalid)
			return FALSE;
		if (ignore)
			g_byte_array_free (ignore, TRUE);
	}

	ignore = ce_page_entry_to_mac (priv->cloned_mac, &invalid);
	if (invalid)
		return FALSE;
	if (ignore)
		g_byte_array_free (ignore, TRUE);

	ui_to_setting (self);
	return nm_setting_verify (NM_SETTING (priv->setting), NULL, error);
}
Пример #2
0
static gboolean
ce_page_validate_v (CEPage *page, NMConnection *connection, GError **error)
{
	CEPageWifi *self = CE_PAGE_WIFI (page);
	CEPageWifiPrivate *priv = CE_PAGE_WIFI_GET_PRIVATE (self);
	gboolean success;
	GtkWidget *entry;

	entry = gtk_bin_get_child (GTK_BIN (priv->bssid));
	if (entry) {
		if (!ce_page_mac_entry_valid (GTK_ENTRY (entry), ARPHRD_ETHER, _("bssid"), error))
			return FALSE;
	}

	entry = gtk_bin_get_child (GTK_BIN (priv->device_combo));
	if (entry) {
		if (!ce_page_device_entry_get (GTK_ENTRY (entry), ARPHRD_ETHER, TRUE, NULL, NULL, _("Wi-Fi device"), error))
			return FALSE;
	}

	if (!ce_page_mac_entry_valid (priv->cloned_mac, ARPHRD_ETHER, _("cloned MAC"), error))
		return FALSE;

	ui_to_setting (self);

	success = nm_setting_verify (NM_SETTING (priv->setting), NULL, error);

	return success;
}
Пример #3
0
static gboolean
validate (CEPage *page, NMConnection *connection, GError **error)
{
	CEPageWireless *self = CE_PAGE_WIRELESS (page);
	CEPageWirelessPrivate *priv = CE_PAGE_WIRELESS_GET_PRIVATE (self);
	char *security;
	gboolean success;
	gboolean invalid = FALSE;
	GByteArray *ignore;

	ignore = ce_page_entry_to_mac (priv->bssid, &invalid);
	if (invalid)
		return FALSE;

	ignore = ce_page_entry_to_mac (priv->mac, &invalid);
	if (invalid)
		return FALSE;

	ui_to_setting (self);

	/* A hack to not check the wireless security here */
	security = g_strdup (nm_setting_wireless_get_security (priv->setting));
	g_object_set (priv->setting, NM_SETTING_WIRELESS_SEC, NULL, NULL);

	success = nm_setting_verify (NM_SETTING (priv->setting), NULL, error);
	g_object_set (priv->setting, NM_SETTING_WIRELESS_SEC, security, NULL);
	g_free (security);

	return success;
}
static gboolean
validate (CEPage        *page,
          NMConnection  *connection,
          GError       **error)
{
        GtkWidget *entry;
        GByteArray *ignore;
        gboolean invalid;
        gchar *security;
        NMSettingWireless *setting;
        gboolean ret = TRUE;

        entry = gtk_bin_get_child (GTK_BIN (gtk_builder_get_object (page->builder, "combo_bssid")));
        ignore = ce_page_entry_to_mac (GTK_ENTRY (entry), ARPHRD_ETHER, &invalid);
        if (invalid) {
                widget_set_error (entry);
                ret = FALSE;
        } else {
                if (ignore)
                        g_byte_array_free (ignore, TRUE);
                widget_unset_error (entry);
        }

        entry = gtk_bin_get_child (GTK_BIN (gtk_builder_get_object (page->builder, "combo_mac")));
        ignore = ce_page_entry_to_mac (GTK_ENTRY (entry), ARPHRD_ETHER, &invalid);
        if (invalid) {
                widget_set_error (entry);
                ret = FALSE;
        } else {
                if (ignore)
                        g_byte_array_free (ignore, TRUE);
                widget_unset_error (entry);
        }

        entry = GTK_WIDGET (gtk_builder_get_object (page->builder, "entry_cloned_mac"));
        ignore = ce_page_entry_to_mac (GTK_ENTRY (entry), ARPHRD_ETHER, &invalid);
        if (invalid) {
                widget_set_error (entry);
                ret = FALSE;
        } else {
                if (ignore)
                        g_byte_array_free (ignore, TRUE);
                widget_unset_error (entry);
        }

        if (!ret)
                return ret;

        ui_to_setting (CE_PAGE_WIFI (page));

        /* A hack to not check the wifi security here */
        setting = CE_PAGE_WIFI (page)->setting;
        security = g_strdup (nm_setting_wireless_get_security (setting));
        g_object_set (setting, NM_SETTING_WIRELESS_SEC, NULL, NULL);
        ret = nm_setting_verify (NM_SETTING (setting), NULL, error);
        g_object_set (setting, NM_SETTING_WIRELESS_SEC, security, NULL);
        g_free (security);

        return ret;
}
static gboolean
ce_page_validate_v (CEPage *page, NMConnection *connection, GError **error)
{
	CEPageBridgePort *self = CE_PAGE_BRIDGE_PORT (page);
	CEPageBridgePortPrivate *priv = CE_PAGE_BRIDGE_PORT_GET_PRIVATE (self);

	ui_to_setting (self);
	return nm_setting_verify (NM_SETTING (priv->setting), NULL, error);
}
Пример #6
0
static gboolean
validate (CEPage *page, NMConnection *connection, GError **error)
{
	CEPagePpp *self = CE_PAGE_PPP (page);
	CEPagePppPrivate *priv = CE_PAGE_PPP_GET_PRIVATE (self);

	ui_to_setting (self);
	return nm_setting_verify (NM_SETTING (priv->setting), NULL, error);
}
Пример #7
0
static gboolean
ce_page_validate_v (CEPage *page, NMConnection *connection, GError **error)
{
	CEPageDsl *self = CE_PAGE_DSL (page);
	CEPageDslPrivate *priv = CE_PAGE_DSL_GET_PRIVATE (self);

	ui_to_setting (self);
	return nm_setting_verify (NM_SETTING (priv->setting), connection, error);
}
static gboolean
validate (CEPage *page, NMConnection *connection, GError **error)
{
	CEPageMobile *self = CE_PAGE_MOBILE (page);
	CEPageMobilePrivate *priv = CE_PAGE_MOBILE_GET_PRIVATE (self);

	ui_to_setting (self);
	return nm_setting_verify (priv->setting, NULL, error);
}
Пример #9
0
static gboolean
validate (CEPage        *page,
          NMConnection  *connection,
          GError       **error)
{
        if (!ui_to_setting (CE_PAGE_IP6 (page)))
                return FALSE;

        return nm_setting_verify (NM_SETTING (CE_PAGE_IP6 (page)->setting), NULL, error);
}
Пример #10
0
static gboolean
ce_page_validate_v (CEPage *page, NMConnection *connection, GError **error)
{
	CEPageIP4 *self = CE_PAGE_IP4 (page);
	CEPageIP4Private *priv = CE_PAGE_IP4_GET_PRIVATE (self);

	if (!ui_to_setting (self, error))
		return FALSE;
	return nm_setting_verify (NM_SETTING (priv->setting), NULL, error);
}
static gboolean
ce_page_validate_v (CEPage *page, NMConnection *connection, GError **error)
{
	CEPageBluetooth *self = CE_PAGE_BLUETOOTH (page);
	CEPageBluetoothPrivate *priv = CE_PAGE_BLUETOOTH_GET_PRIVATE (self);

	if (!ce_page_mac_entry_valid (priv->bdaddr, ARPHRD_ETHER, _("bdaddr"), error))
		return FALSE;

	ui_to_setting (self);
	return nm_setting_verify (NM_SETTING (priv->setting), NULL, error);
}
static void
connection_editor_validate (NMConnectionEditor *editor)
{
	NMSettingConnection *s_con;
	GSList *iter;
	gs_free char *validation_error = NULL;
	GError *error = NULL;

	if (!editor_is_initialized (editor)) {
		validation_error = g_strdup (_("Editor initializing…"));
		goto done_silent;
	}

	s_con = nm_connection_get_setting_connection (editor->connection);
	g_assert (s_con);
	if (nm_setting_connection_get_read_only (s_con)) {
		validation_error = g_strdup (_("Connection cannot be modified"));
		goto done;
	}

	if (!ui_to_setting (editor, &error)) {
		validation_error = g_strdup (error->message);
		g_clear_error (&error);
		goto done;
	}

	for (iter = editor->pages; iter; iter = g_slist_next (iter)) {
		if (!ce_page_validate (CE_PAGE (iter->data), editor->connection, &error)) {
			if (!validation_error) {
				validation_error = g_strdup_printf (_("Invalid setting %s: %s"),
				                                    CE_PAGE (iter->data)->title,
				                                    error->message);
			}
			g_clear_error (&error);
		}
	}

done:
	if (g_strcmp0 (validation_error, editor->last_validation_error) != 0) {
		if (editor->last_validation_error && !validation_error)
			g_message ("Connection validates and can be saved");
		else if (validation_error)
			g_message ("Cannot save connection due to error: %s", validation_error);
		g_free (editor->last_validation_error);
		editor->last_validation_error = g_strdup (validation_error);
	}

done_silent:
	ce_polkit_button_set_validation_error (CE_POLKIT_BUTTON (editor->ok_button), validation_error);
	gtk_widget_set_sensitive (editor->export_button, !validation_error);

	update_sensitivity (editor);
}
static gboolean
validate (CEPage *page, NMConnection *connection, GError **error)
{
	CEPageBond *self = CE_PAGE_BOND (page);
	CEPageBondPrivate *priv = CE_PAGE_BOND_GET_PRIVATE (self);

	if (!CE_PAGE_CLASS (ce_page_bond_parent_class)->validate (page, connection, error))
		return FALSE;

	ui_to_setting (self);
	return nm_setting_verify (NM_SETTING (priv->setting), NULL, error);
}
Пример #14
0
static gboolean
validate (CEPage *page, NMConnection *connection, GError **error)
{
	CEPageWired *self = CE_PAGE_WIRED (page);
	CEPageWiredPrivate *priv = CE_PAGE_WIRED_GET_PRIVATE (self);
	gboolean invalid = FALSE;
	GByteArray *ignore;

	ignore = ce_page_entry_to_mac (priv->mac, &invalid);
	if (invalid)
		return FALSE;

	ui_to_setting (self);
	return nm_setting_verify (NM_SETTING (priv->setting), NULL, error);
}
Пример #15
0
static gboolean
ce_page_validate_v (CEPage *page, NMConnection *connection, GError **error)
{
	CEPageBond *self = CE_PAGE_BOND (page);
	CEPageBondPrivate *priv = CE_PAGE_BOND_GET_PRIVATE (self);

	if (!CE_PAGE_CLASS (ce_page_bond_parent_class)->ce_page_validate_v (page, connection, error))
		return FALSE;

	if (!ce_page_interface_name_valid (gtk_entry_get_text (priv->primary),
	                                   _("primary"), error))
		return FALSE;

	ui_to_setting (self);
	return nm_setting_verify (NM_SETTING (priv->setting), connection, error);
}
static gboolean
validate (CEPage *page, NMConnection *connection, GError **error)
{
	CEPageWifi *self = CE_PAGE_WIFI (page);
	CEPageWifiPrivate *priv = CE_PAGE_WIFI_GET_PRIVATE (self);
	char *security;
	gboolean success;
	gboolean invalid = FALSE;
	GByteArray *ignore;
	GtkWidget *entry;

	entry = gtk_bin_get_child (GTK_BIN (priv->bssid));
	if (entry) {
		ignore = ce_page_entry_to_mac (GTK_ENTRY (entry), ARPHRD_ETHER, &invalid);
		if (invalid)
			return FALSE;
		if (ignore)
			g_byte_array_free (ignore, TRUE);
	}

	entry = gtk_bin_get_child (GTK_BIN (priv->device_mac));
	if (entry) {
		ignore = ce_page_entry_to_mac (GTK_ENTRY (entry), ARPHRD_ETHER, &invalid);
		if (invalid)
			return FALSE;
		if (ignore)
			g_byte_array_free (ignore, TRUE);
	}

	ignore = ce_page_entry_to_mac (priv->cloned_mac, ARPHRD_ETHER, &invalid);
	if (invalid)
		return FALSE;
	if (ignore)
		g_byte_array_free (ignore, TRUE);

	ui_to_setting (self);

	/* A hack to not check the wifi security here */
	security = g_strdup (nm_setting_wireless_get_security (priv->setting));
	g_object_set (priv->setting, NM_SETTING_WIRELESS_SEC, NULL, NULL);

	success = nm_setting_verify (NM_SETTING (priv->setting), NULL, error);
	g_object_set (priv->setting, NM_SETTING_WIRELESS_SEC, security, NULL);
	g_free (security);

	return success;
}
static gboolean
validate (CEPage *page, NMConnection *connection, GError **error)
{
	CEPageInfiniband *self = CE_PAGE_INFINIBAND (page);
	CEPageInfinibandPrivate *priv = CE_PAGE_INFINIBAND_GET_PRIVATE (self);
	GtkWidget *entry;
	char buf[INFINIBAND_ALEN];
	const char *hwaddr;

	entry = gtk_bin_get_child (GTK_BIN (priv->device_mac));
	hwaddr = gtk_entry_get_text (GTK_ENTRY (entry));
	if (hwaddr && *hwaddr && !nm_utils_hwaddr_aton (hwaddr, ARPHRD_INFINIBAND, buf))
		return FALSE;

	ui_to_setting (self);
	return nm_setting_verify (NM_SETTING (priv->setting), NULL, error);
}
static gboolean
validate (CEPage        *page,
          NMConnection  *connection,
          GError       **error)
{
        CEPageEthernet *self = CE_PAGE_ETHERNET (page);
        gboolean invalid = FALSE;
        GByteArray *ignore;
        GtkWidget *entry;
        gboolean ret = TRUE;

        entry = gtk_bin_get_child (GTK_BIN (self->device_mac));
        if (entry) {
                ignore = ce_page_entry_to_mac (GTK_ENTRY (entry), ARPHRD_ETHER, &invalid);
                if (invalid) {
                        widget_set_error (entry);
                        ret = FALSE;
                } else {
                        if (ignore)
                                g_byte_array_free (ignore, TRUE);
                        widget_unset_error (entry);
                }
        }

        ignore = ce_page_entry_to_mac (self->cloned_mac, ARPHRD_ETHER, &invalid);
        if (invalid) {
                widget_set_error (GTK_WIDGET (self->cloned_mac));
                ret = FALSE;
        } else {
                if (ignore)
                        g_byte_array_free (ignore, TRUE);
                widget_unset_error (GTK_WIDGET (self->cloned_mac));
        }

        if (!ret)
                return ret;

        ui_to_setting (self);

        return nm_setting_verify (NM_SETTING (self->setting_connection), NULL, error) &&
               nm_setting_verify (NM_SETTING (self->setting_wired), NULL, error);
}
Пример #19
0
static gboolean
ce_page_validate_v (CEPage *page, NMConnection *connection, GError **error)
{
	CEPageDcb *self = CE_PAGE_DCB (page);
	CEPageDcbPrivate *priv = CE_PAGE_DCB_GET_PRIVATE (self);
	NMSettingDcb *s_dcb;

	if (!gtk_toggle_button_get_active (priv->enabled)) {
		nm_connection_remove_setting (connection, NM_TYPE_SETTING_DCB);
		return TRUE;
	}

	s_dcb = nm_connection_get_setting_dcb (connection);
	if (!s_dcb) {
		s_dcb = (NMSettingDcb *) nm_setting_dcb_new ();
		nm_connection_add_setting (connection, NM_SETTING (s_dcb));
	}
	ui_to_setting (self, s_dcb);

	return nm_setting_verify (NM_SETTING (s_dcb), NULL, error);
}
Пример #20
0
static gboolean
validate (CEPage *page, NMConnection *connection, GError **error)
{
    CEPageVlan *self = CE_PAGE_VLAN (page);
    CEPageVlanPrivate *priv = CE_PAGE_VLAN_GET_PRIVATE (self);
    gboolean invalid = FALSE;
    GByteArray *ignore;
    int parent_id;
    const char *parent;
    char *parent_iface;

    parent_id = gtk_combo_box_get_active (GTK_COMBO_BOX (priv->parent));
    if (parent_id == -1) {
        gboolean valid;

        parent = gtk_entry_get_text (priv->parent_entry);
        parent_iface = g_strndup (parent, strcspn (parent, " "));
        valid = nm_utils_iface_valid_name (parent_iface);
        g_free (parent_iface);
        if (!valid)
            return FALSE;
    }

    ignore = ce_page_entry_to_mac (priv->cloned_mac, ARPHRD_ETHER, &invalid);
    if (invalid)
        return FALSE;
    if (ignore)
        g_byte_array_free (ignore, TRUE);

    ui_to_setting (self);

    if (   priv->s_hw
            && !nm_setting_verify (priv->s_hw, NULL, error))
        return FALSE;

    return nm_setting_verify (NM_SETTING (priv->setting), NULL, error);
}