active = nm_client_activate_connection_finish (NM_CLIENT (client), result, &error);
if (error) {
- char *dbus_err;
-
/* If no connection existed for the device, create one and activate it */
- dbus_err = g_dbus_error_get_remote_error (error);
- if (g_strcmp0 (dbus_err, "org.freedesktop.NetworkManager.UnknownConnection") == 0) {
+ if (g_error_matches (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_UNKNOWN_CONNECTION)) {
create_connect_connection_for_device (info);
- g_free (dbus_err);
return;
}
- g_free (dbus_err);
g_dbus_error_strip_remote_error (error);
g_string_printf (nmc->return_text, _("Error: Device activation failed: %s"),
The path of the active connection object representing this active connection.
</tp:docstring>
</arg>
- <tp:possible-errors>
- <tp:error name="org.freedesktop.NetworkManager.Error.UnknownConnection"/>
- <tp:error name="org.freedesktop.NetworkManager.Error.UnknownDevice"/>
- <tp:error name="org.freedesktop.NetworkManager.Error.ConnectionActivating">
- <tp:docstring>Another connection is already activating or the same connection is already active. FIXME: check if the error name is correct. FIXME: split into 2 errors?</tp:docstring>
- </tp:error>
- <tp:error name="org.freedesktop.NetworkManager.Error.ConnectionInvalid">
- <tp:docstring>The connection is invalid for this device.</tp:docstring>
- </tp:error>
- </tp:possible-errors>
</method>
<method name="AddAndActivateConnection">
The path of the active connection object representing this active connection.
</tp:docstring>
</arg>
- <tp:possible-errors>
- <tp:error name="org.freedesktop.NetworkManager.Error.UnknownConnection"/>
- <tp:error name="org.freedesktop.NetworkManager.Error.UnknownDevice"/>
- <tp:error name="org.freedesktop.NetworkManager.Error.ConnectionInvalid">
- <tp:docstring>The connection is invalid for this device.</tp:docstring>
- </tp:error>
- </tp:possible-errors>
</method>
<method name="DeactivateConnection">
G_DEFINE_QUARK (nm-connection-error-quark, nm_connection_error)
G_DEFINE_QUARK (nm-crypto-error-quark, nm_crypto_error)
G_DEFINE_QUARK (nm-device-error-quark, nm_device_error)
+G_DEFINE_QUARK (nm-manager-error-quark, nm_manager_error)
static void
register_error_domain (GQuark domain,
register_error_domain (NM_DEVICE_ERROR,
NM_DBUS_INTERFACE_DEVICE,
NM_TYPE_DEVICE_ERROR);
+ register_error_domain (NM_MANAGER_ERROR,
+ NM_DBUS_INTERFACE,
+ NM_TYPE_MANAGER_ERROR);
}
#define NM_DEVICE_ERROR nm_device_error_quark ()
GQuark nm_device_error_quark (void);
+/**
+ * NMManagerError:
+ * @NM_MANAGER_ERROR_FAILED: unknown or unclassified error
+ * @NM_MANAGER_ERROR_PERMISSION_DENIED: Permission denied.
+ * @NM_MANAGER_ERROR_UNKNOWN_CONNECTION: The requested connection is not known.
+ * @NM_MANAGER_ERROR_UNKNOWN_DEVICE: The requested device is not known.
+ * @NM_MANAGER_ERROR_CONNECTION_NOT_AVAILABLE: The requested connection cannot be
+ * activated at this time.
+ * @NM_MANAGER_ERROR_CONNECTION_NOT_ACTIVE: The request could not be completed
+ * because a required connection is not active.
+ * @NM_MANAGER_ERROR_CONNECTION_ALREADY_ACTIVE: The connection to be activated was
+ * already active on another device.
+ * @NM_MANAGER_ERROR_DEPENDENCY_FAILED: An activation request failed due to a
+ * dependency being unavailable.
+ * @NM_MANAGER_ERROR_ALREADY_ASLEEP_OR_AWAKE: The manager is already in the requested
+ * sleep/wake state.
+ * @NM_MANAGER_ERROR_ALREADY_ENABLED_OR_DISABLED: The network is already
+ * enabled/disabled.
+ *
+ * Errors related to the main "network management" interface of NetworkManager.
+ * These may be returned from #NMClient methods that invoke D-Bus operations on
+ * the "org.freedesktop.NetworkManager" interface, and correspond to D-Bus
+ * errors in that namespace.
+ */
+typedef enum {
+ NM_MANAGER_ERROR_FAILED = 0, /*< nick=Failed >*/
+ NM_MANAGER_ERROR_PERMISSION_DENIED, /*< nick=PermissionDenied >*/
+ NM_MANAGER_ERROR_UNKNOWN_CONNECTION, /*< nick=UnknownConnection >*/
+ NM_MANAGER_ERROR_UNKNOWN_DEVICE, /*< nick=UnknownDevice >*/
+ NM_MANAGER_ERROR_CONNECTION_NOT_AVAILABLE, /*< nick=ConnectionNotAvailable >*/
+ NM_MANAGER_ERROR_CONNECTION_NOT_ACTIVE, /*< nick=ConnectionNotActive >*/
+ NM_MANAGER_ERROR_CONNECTION_ALREADY_ACTIVE, /*< nick=ConnectionAlreadyActive >*/
+ NM_MANAGER_ERROR_DEPENDENCY_FAILED, /*< nick=DependencyFailed >*/
+ NM_MANAGER_ERROR_ALREADY_ASLEEP_OR_AWAKE, /*< nick=AlreadyAsleepOrAwake >*/
+ NM_MANAGER_ERROR_ALREADY_ENABLED_OR_DISABLED, /*< nick=AlreadyEnabledOrDisabled >*/
+} NMManagerError;
+
+GQuark nm_manager_error_quark (void);
+#define NM_MANAGER_ERROR (nm_manager_error_quark ())
+
#endif /* __NM_ERRORS_H__ */
nm_ip6_route_set_next_hop;
nm_ip6_route_set_prefix;
nm_ip6_route_unref;
+ nm_manager_error_get_type;
+ nm_manager_error_quark;
nm_object_error_get_type;
nm_object_error_quark;
nm_object_get_path;
};
-/************************************************************************/
-
-#define NM_MANAGER_ERROR (nm_manager_error_quark ())
-
-static GQuark
-nm_manager_error_quark (void)
-{
- static GQuark quark = 0;
- if (!quark)
- quark = g_quark_from_static_string ("nm-manager-error");
- return quark;
-}
-
/************************************************************************/
static void active_connection_state_changed (NMActiveConnection *active,
ftype = nm_device_factory_get_device_type (factory);
for (iter = priv->factories; iter; iter = iter->next) {
if (ftype == nm_device_factory_get_device_type (iter->data)) {
- g_set_error (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_INTERNAL,
+ g_set_error (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_FAILED,
"multiple plugins for same type (using '%s' instead of '%s')",
(char *) g_object_get_data (G_OBJECT (iter->data), PLUGIN_PATH_TAG),
path);
/* Otherwise, the device is unmanaged, unavailable, or disconnecting */
g_set_error (error,
NM_MANAGER_ERROR,
- NM_MANAGER_ERROR_UNMANAGED_DEVICE,
+ NM_MANAGER_ERROR_DEPENDENCY_FAILED,
"Master device %s unmanaged or not available for activation",
nm_device_get_iface (master_device));
} else if (master_connection) {
*/
if (!nm_active_connection_get_user_requested (active) &&
!nm_device_autoconnect_allowed (device)) {
- g_set_error (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_AUTOCONNECT_NOT_ALLOWED,
+ g_set_error (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_CONNECTION_NOT_AVAILABLE,
"%s does not allow automatic connections at this time",
nm_device_get_iface (device));
return FALSE;
if (vpn) {
/* Try to fill the VPN's connection setting and name at least */
if (!nm_connection_get_setting_vpn (connection)) {
- error = g_error_new_literal (NM_MANAGER_ERROR,
- NM_MANAGER_ERROR_UNSUPPORTED_CONNECTION_TYPE,
+ error = g_error_new_literal (NM_CONNECTION_ERROR,
+ NM_CONNECTION_ERROR_MISSING_SETTING,
"VPN connections require a 'vpn' setting");
+ g_prefix_error (&error, "%s: ", NM_SETTING_VPN_SETTING_NAME);
goto error;
}
bus = nm_dbus_manager_get_connection (priv->dbus_mgr);
if (!bus) {
- g_set_error_literal (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_INTERNAL,
+ g_set_error_literal (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_FAILED,
"Failed to initialize D-Bus connection");
g_object_unref (singleton);
return NULL;
G_CALLBACK (connectivity_changed), singleton);
if (!dbus_connection_add_filter (dbus_connection, prop_filter, singleton, NULL)) {
- g_set_error_literal (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_INTERNAL,
+ g_set_error_literal (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_FAILED,
"Failed to register DBus connection filter");
g_object_unref (singleton);
return NULL;
G_TYPE_FROM_CLASS (manager_class),
&dbus_glib_nm_manager_object_info);
- dbus_g_error_domain_register (NM_MANAGER_ERROR, NULL, NM_TYPE_MANAGER_ERROR);
+ dbus_g_error_domain_register (NM_MANAGER_ERROR, NM_DBUS_INTERFACE, NM_TYPE_MANAGER_ERROR);
dbus_g_error_domain_register (NM_LOGGING_ERROR, "org.freedesktop.NetworkManager.Logging", NM_TYPE_LOGGING_ERROR);
}
#define NM_IS_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_MANAGER))
#define NM_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_MANAGER, NMManagerClass))
-typedef enum {
- NM_MANAGER_ERROR_UNKNOWN_CONNECTION = 0, /*< nick=UnknownConnection >*/
- NM_MANAGER_ERROR_UNKNOWN_DEVICE, /*< nick=UnknownDevice >*/
- NM_MANAGER_ERROR_UNMANAGED_DEVICE, /*< nick=UnmanagedDevice >*/
- NM_MANAGER_ERROR_SYSTEM_CONNECTION, /*< nick=SystemConnection >*/
- NM_MANAGER_ERROR_PERMISSION_DENIED, /*< nick=PermissionDenied >*/
- NM_MANAGER_ERROR_CONNECTION_NOT_ACTIVE, /*< nick=ConnectionNotActive >*/
- NM_MANAGER_ERROR_ALREADY_ASLEEP_OR_AWAKE, /*< nick=AlreadyAsleepOrAwake >*/
- NM_MANAGER_ERROR_ALREADY_ENABLED_OR_DISABLED, /*< nick=AlreadyEnabledOrDisabled >*/
- NM_MANAGER_ERROR_UNSUPPORTED_CONNECTION_TYPE, /*< nick=UnsupportedConnectionType >*/
- NM_MANAGER_ERROR_DEPENDENCY_FAILED, /*< nick=DependencyFailed >*/
- NM_MANAGER_ERROR_AUTOCONNECT_NOT_ALLOWED, /*< nick=AutoconnectNotAllowed >*/
- NM_MANAGER_ERROR_CONNECTION_ALREADY_ACTIVE, /*< nick=ConnectionAlreadyActive >*/
- NM_MANAGER_ERROR_INTERNAL, /*< nick=Internal >*/
-} NMManagerError;
-
#define NM_MANAGER_VERSION "version"
#define NM_MANAGER_STATE "state"
#define NM_MANAGER_STARTUP "startup"