NetworkManager/libnm-core/nm-connection.h
Dan Winship 2d8e7bd247 libnm-core: merge NMSetting*Error into NMConnectionError
Each setting type was defining its own error type, but most of them
had exactly the same three errors ("unknown", "missing property", and
"invalid property"), and none of the other values was of much use
programmatically anyway.

So, this commit merges NMSettingError, NMSettingAdslError, etc, all
into NMConnectionError. (The reason for merging into NMConnectionError
rather than NMSettingError is that we also already have
"NMSettingsError", for errors related to the settings service, so
"NMConnectionError" is a less-confusable name for settings/connection
errors than "NMSettingError".)

Also, make sure that all of the affected error messages are localized,
and (where appropriate) prefix them with the relevant property name.

Renamed error codes:

NM_SETTING_ERROR_PROPERTY_NOT_FOUND -> NM_CONNECTION_ERROR_PROPERTY_NOT_FOUND
NM_SETTING_ERROR_PROPERTY_NOT_SECRET -> NM_CONNECTION_ERROR_PROPERTY_NOT_SECRET

Remapped error codes:

NM_SETTING_*_ERROR_MISSING_PROPERTY -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_*_ERROR_INVALID_PROPERTY -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_ERROR_PROPERTY_TYPE_MISMATCH -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_BLUETOOTH_ERROR_TYPE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_INVALID_SETTING
NM_SETTING_BOND_ERROR_INVALID_OPTION -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_BOND_ERROR_MISSING_OPTION -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_CONNECTION_ERROR_TYPE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_CONNECTION_ERROR_SLAVE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_IP4_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_IP6_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_VLAN_ERROR_INVALID_PARENT -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_MISSING_802_1X_SETTING -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_802_1X -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_USERNAME -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_SHARED_KEY_REQUIRES_WEP -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_ERROR_CHANNEL_REQUIRES_BAND -> NM_CONNECTION_ERROR_MISSING_PROPERTY

Dropped error codes (were previously defined but unused):

NM_SETTING_CDMA_ERROR_MISSING_SERIAL_SETTING
NM_SETTING_CONNECTION_ERROR_IP_CONFIG_NOT_ALLOWED
NM_SETTING_GSM_ERROR_MISSING_SERIAL_SETTING
NM_SETTING_PPP_ERROR_REQUIRE_MPPE_NOT_ALLOWED
NM_SETTING_PPPOE_ERROR_MISSING_PPP_SETTING
NM_SETTING_SERIAL_ERROR_MISSING_PPP_SETTING
NM_SETTING_WIRELESS_ERROR_MISSING_SECURITY_SETTING
2014-10-22 08:29:07 -04:00

286 lines
13 KiB
C

/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* Copyright 2007 - 2013 Red Hat, Inc.
* Copyright 2007 - 2008 Novell, Inc.
*/
#ifndef __NM_CONNECTION_H__
#define __NM_CONNECTION_H__
#if !defined (__NETWORKMANAGER_H_INSIDE__) && !defined (NETWORKMANAGER_COMPILATION)
#error "Only <NetworkManager.h> can be included directly."
#endif
#include <glib.h>
#include <glib-object.h>
#include <nm-setting.h>
#include <nm-setting-8021x.h>
#include <nm-setting-bluetooth.h>
#include <nm-setting-bond.h>
#include <nm-setting-team.h>
#include <nm-setting-team-port.h>
#include <nm-setting-bridge.h>
#include <nm-setting-bridge-port.h>
#include <nm-setting-cdma.h>
#include <nm-setting-connection.h>
#include <nm-setting-dcb.h>
#include <nm-setting-generic.h>
#include <nm-setting-gsm.h>
#include <nm-setting-infiniband.h>
#include <nm-setting-ip4-config.h>
#include <nm-setting-ip6-config.h>
#include <nm-setting-olpc-mesh.h>
#include <nm-setting-ppp.h>
#include <nm-setting-pppoe.h>
#include <nm-setting-serial.h>
#include <nm-setting-vpn.h>
#include <nm-setting-wimax.h>
#include <nm-setting-wired.h>
#include <nm-setting-adsl.h>
#include <nm-setting-wireless.h>
#include <nm-setting-wireless-security.h>
#include <nm-setting-vlan.h>
G_BEGIN_DECLS
#define NM_TYPE_CONNECTION (nm_connection_get_type ())
#define NM_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_CONNECTION, NMConnection))
#define NM_IS_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_CONNECTION))
#define NM_CONNECTION_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), NM_TYPE_CONNECTION, NMConnectionClass))
/* Signals */
#define NM_CONNECTION_SECRETS_UPDATED "secrets-updated"
#define NM_CONNECTION_SECRETS_CLEARED "secrets-cleared"
#define NM_CONNECTION_CHANGED "changed"
/**
* NMConnectionError:
* @NM_CONNECTION_ERROR_FAILED: unknown or unclassified error
* @NM_CONNECTION_ERROR_SETTING_NOT_FOUND: the #NMConnection object
* did not contain the specified #NMSetting object
* @NM_CONNECTION_ERROR_PROPERTY_NOT_FOUND: the #NMConnection did not contain the
* requested #NMSetting property
* @NM_CONNECTION_ERROR_PROPERTY_NOT_SECRET: an operation which requires a secret
* was attempted on a non-secret property
* @NM_CONNECTION_ERROR_MISSING_SETTING: the #NMConnection object is missing an
* #NMSetting which is required for its configuration. The error message will
* always be prefixed with "<setting-name>: ", where "<setting-name>" is the
* name of the setting that is missing.
* @NM_CONNECTION_ERROR_INVALID_SETTING: the #NMConnection object contains an
* invalid or inappropriate #NMSetting. The error message will always be
* prefixed with "<setting-name>: ", where "<setting-name>" is the name of the
* setting that is invalid.
* @NM_CONNECTION_ERROR_MISSING_PROPERTY: the #NMConnection object is invalid
* because it is missing a required property. The error message will always be
* prefixed with "<setting-name>.<property-name>: ", where "<setting-name>" is
* the name of the setting with the missing property, and "<property-name>" is
* the property that is missing.
* @NM_CONNECTION_ERROR_INVALID_PROPERTY: the #NMConnection object is invalid
* because a property has an invalid value. The error message will always be
* prefixed with "<setting-name>.<property-name>: ", where "<setting-name>" is
* the name of the setting with the invalid property, and "<property-name>" is
* the property that is invalid.
*
* Describes errors that may result from operations involving a #NMConnection
* or its #NMSettings.
*/
typedef enum {
NM_CONNECTION_ERROR_FAILED = 0, /*< nick=Failed >*/
NM_CONNECTION_ERROR_SETTING_NOT_FOUND, /*< nick=SettingNotFound >*/
NM_CONNECTION_ERROR_PROPERTY_NOT_FOUND, /*< nick=PropertyNotFound >*/
NM_CONNECTION_ERROR_PROPERTY_NOT_SECRET, /*< nick=PropertyNotSecret >*/
NM_CONNECTION_ERROR_MISSING_SETTING, /*< nick=MissingSetting >*/
NM_CONNECTION_ERROR_INVALID_SETTING, /*< nick=InvalidSetting >*/
NM_CONNECTION_ERROR_MISSING_PROPERTY, /*< nick=MissingProperty >*/
NM_CONNECTION_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/
} NMConnectionError;
/*
* NM_CONNECTION_NORMALIZE_PARAM_IP6_CONFIG_METHOD: overwrite the ip6 method
* when normalizing ip6 configuration. If omited, this defaults to
* @NM_SETTING_IP6_CONFIG_METHOD_AUTO.
*/
#define NM_CONNECTION_NORMALIZE_PARAM_IP6_CONFIG_METHOD "ip6-config-method"
#define NM_CONNECTION_ERROR nm_connection_error_quark ()
GQuark nm_connection_error_quark (void);
/**
* NMConnection:
*
* NMConnection is the interface implemented by #NMRemoteConnection on the
* client side, and #NMSettingsConnection on the daemon side.
*/
typedef struct _NMConnection NMConnection;
typedef struct {
GTypeInterface parent;
/* Signals */
void (*secrets_updated) (NMConnection *connection,
const char *setting);
void (*secrets_cleared) (NMConnection *connection);
void (*changed) (NMConnection *connection);
} NMConnectionInterface;
GType nm_connection_get_type (void);
void nm_connection_add_setting (NMConnection *connection,
NMSetting *setting);
void nm_connection_remove_setting (NMConnection *connection,
GType setting_type);
NMSetting *nm_connection_get_setting (NMConnection *connection,
GType setting_type);
NMSetting *nm_connection_get_setting_by_name (NMConnection *connection,
const char *name);
/**
* NM_VARIANT_TYPE_CONNECTION:
*
* #GVariantType for a dictionary mapping from setting names to
* %NM_VARIANT_TYPE_SETTING variants. This is used to represent an
* #NMConnection, and is the type taken by nm_simple_connection_new_from_dbus()
* and returned from nm_connection_to_dbus().
*/
#define NM_VARIANT_TYPE_CONNECTION (G_VARIANT_TYPE ("a{sa{sv}}"))
/**
* NM_VARIANT_TYPE_SETTING:
*
* #GVariantType for a dictionary mapping from property names to values. This is
* an alias for %G_VARIANT_TYPE_VARDICT, and is the type of each element of
* an %NM_VARIANT_TYPE_CONNECTION dictionary.
*/
#define NM_VARIANT_TYPE_SETTING G_VARIANT_TYPE_VARDICT
/**
* NMConnectionSerializationFlags:
* @NM_CONNECTION_SERIALIZE_ALL: serialize all properties (including secrets)
* @NM_CONNECTION_SERIALIZE_NO_SECRETS: do not include secrets
* @NM_CONNECTION_SERIALIZE_ONLY_SECRETS: only serialize secrets
*
* These flags determine which properties are serialized when calling when
* calling nm_connection_to_dbus().
**/
typedef enum { /*< flags >*/
NM_CONNECTION_SERIALIZE_ALL = 0x00000000,
NM_CONNECTION_SERIALIZE_NO_SECRETS = 0x00000001,
NM_CONNECTION_SERIALIZE_ONLY_SECRETS = 0x00000002,
} NMConnectionSerializationFlags;
GVariant *nm_connection_to_dbus (NMConnection *connection,
NMConnectionSerializationFlags flags);
gboolean nm_connection_replace_settings (NMConnection *connection,
GVariant *new_settings,
GError **error);
void nm_connection_replace_settings_from_connection (NMConnection *connection,
NMConnection *new_connection);
void nm_connection_clear_settings (NMConnection *connection);
gboolean nm_connection_compare (NMConnection *a,
NMConnection *b,
NMSettingCompareFlags flags);
gboolean nm_connection_diff (NMConnection *a,
NMConnection *b,
NMSettingCompareFlags flags,
GHashTable **out_settings);
gboolean nm_connection_verify (NMConnection *connection, GError **error);
gboolean nm_connection_normalize (NMConnection *connection,
GHashTable *parameters,
gboolean *modified,
GError **error);
const char * nm_connection_need_secrets (NMConnection *connection,
GPtrArray **hints);
void nm_connection_clear_secrets (NMConnection *connection);
void nm_connection_clear_secrets_with_flags (NMConnection *connection,
NMSettingClearSecretsWithFlagsFn func,
gpointer user_data);
gboolean nm_connection_update_secrets (NMConnection *connection,
const char *setting_name,
GVariant *secrets,
GError **error);
void nm_connection_set_path (NMConnection *connection,
const char *path);
const char * nm_connection_get_path (NMConnection *connection);
const char * nm_connection_get_interface_name (NMConnection *connection);
gboolean nm_connection_is_type (NMConnection *connection, const char *type);
void nm_connection_for_each_setting_value (NMConnection *connection,
NMSettingValueIterFn func,
gpointer user_data);
void nm_connection_dump (NMConnection *connection);
/* Helpers */
const char * nm_connection_get_uuid (NMConnection *connection);
const char * nm_connection_get_id (NMConnection *connection);
const char * nm_connection_get_connection_type (NMConnection *connection);
gboolean nm_connection_is_virtual (NMConnection *connection);
char * nm_connection_get_virtual_device_description (NMConnection *connection);
NMSetting8021x * nm_connection_get_setting_802_1x (NMConnection *connection);
NMSettingBluetooth * nm_connection_get_setting_bluetooth (NMConnection *connection);
NMSettingBond * nm_connection_get_setting_bond (NMConnection *connection);
NMSettingTeam * nm_connection_get_setting_team (NMConnection *connection);
NMSettingTeamPort * nm_connection_get_setting_team_port (NMConnection *connection);
NMSettingBridge * nm_connection_get_setting_bridge (NMConnection *connection);
NMSettingBridgePort * nm_connection_get_setting_bridge_port (NMConnection *connection);
NMSettingCdma * nm_connection_get_setting_cdma (NMConnection *connection);
NMSettingConnection * nm_connection_get_setting_connection (NMConnection *connection);
NMSettingDcb * nm_connection_get_setting_dcb (NMConnection *connection);
NMSettingGeneric * nm_connection_get_setting_generic (NMConnection *connection);
NMSettingGsm * nm_connection_get_setting_gsm (NMConnection *connection);
NMSettingInfiniband * nm_connection_get_setting_infiniband (NMConnection *connection);
NMSettingIP4Config * nm_connection_get_setting_ip4_config (NMConnection *connection);
NMSettingIP6Config * nm_connection_get_setting_ip6_config (NMConnection *connection);
NMSettingOlpcMesh * nm_connection_get_setting_olpc_mesh (NMConnection *connection);
NMSettingPpp * nm_connection_get_setting_ppp (NMConnection *connection);
NMSettingPppoe * nm_connection_get_setting_pppoe (NMConnection *connection);
NMSettingSerial * nm_connection_get_setting_serial (NMConnection *connection);
NMSettingVpn * nm_connection_get_setting_vpn (NMConnection *connection);
NMSettingWimax * nm_connection_get_setting_wimax (NMConnection *connection);
NMSettingAdsl * nm_connection_get_setting_adsl (NMConnection *connection);
NMSettingWired * nm_connection_get_setting_wired (NMConnection *connection);
NMSettingWireless * nm_connection_get_setting_wireless (NMConnection *connection);
NMSettingWirelessSecurity *nm_connection_get_setting_wireless_security (NMConnection *connection);
NMSettingVlan * nm_connection_get_setting_vlan (NMConnection *connection);
G_END_DECLS
#endif /* __NM_CONNECTION_H__ */