diff options
author | Dan Winship <danw@gnome.org> | 2014-10-15 15:27:25 -0400 |
---|---|---|
committer | Dan Winship <danw@gnome.org> | 2014-10-22 08:29:10 -0400 |
commit | 5a181bcaae2b8a029ca201156ad22ccae2383319 (patch) | |
tree | 2a325eee1970300a1cffa8b43f2ba5dbc1eaf7ae | |
parent | 821258048b620bdc381089c0f442674b0f83be6e (diff) | |
download | NetworkManager-5a181bcaae2b8a029ca201156ad22ccae2383319.tar.gz |
libnm-core, libnm: move NMVpnPluginError to nm-errors
Move the definition of NMVpnPluginError to nm-errors and register it
with D-Bus. Rename GENERAL to FAILED, and CONNECTION_INVALID to
INVALID_CONNECTION, for consistency.
(As with the NMSecretAgentError renamings, the renaming here is not an
ABI break, because the daemon currently never checks for any specific
error codes other than INTERACTIVE_NOT_SUPPORTED.)
-rw-r--r-- | libnm-core/nm-errors.c | 8 | ||||
-rw-r--r-- | libnm-core/nm-errors.h | 44 | ||||
-rw-r--r-- | libnm/nm-vpn-plugin.c | 18 | ||||
-rw-r--r-- | libnm/nm-vpn-plugin.h | 43 |
4 files changed, 53 insertions, 60 deletions
diff --git a/libnm-core/nm-errors.c b/libnm-core/nm-errors.c index 12da2aa89c..105425504c 100644 --- a/libnm-core/nm-errors.c +++ b/libnm-core/nm-errors.c @@ -24,6 +24,7 @@ #include "nm-errors.h" #include "nm-glib-compat.h" #include "nm-dbus-interface.h" +#include "nm-vpn-dbus-interface.h" #include "nm-core-internal.h" G_DEFINE_QUARK (nm-agent-manager-error-quark, nm_agent_manager_error) @@ -33,6 +34,7 @@ G_DEFINE_QUARK (nm-device-error-quark, nm_device_error) G_DEFINE_QUARK (nm-manager-error-quark, nm_manager_error) G_DEFINE_QUARK (nm-secret-agent-error-quark, nm_secret_agent_error) G_DEFINE_QUARK (nm-settings-error-quark, nm_settings_error) +G_DEFINE_QUARK (nm-vpn-plugin-quark, nm_vpn_plugin_error) static void register_error_domain (GQuark domain, @@ -77,4 +79,10 @@ _nm_dbus_errors_init (void) register_error_domain (NM_SETTINGS_ERROR, NM_DBUS_INTERFACE_SETTINGS, NM_TYPE_SETTINGS_ERROR); + register_error_domain (NM_SETTINGS_ERROR, + NM_DBUS_INTERFACE_SETTINGS, + NM_TYPE_SETTINGS_ERROR); + register_error_domain (NM_VPN_PLUGIN_ERROR, + NM_VPN_DBUS_PLUGIN_INTERFACE, + NM_TYPE_VPN_PLUGIN_ERROR); } diff --git a/libnm-core/nm-errors.h b/libnm-core/nm-errors.h index c3c26e8763..fa6919c569 100644 --- a/libnm-core/nm-errors.h +++ b/libnm-core/nm-errors.h @@ -272,4 +272,48 @@ typedef enum { GQuark nm_settings_error_quark (void); #define NM_SETTINGS_ERROR (nm_settings_error_quark ()) +/** + * NMVpnPluginError: + * @NM_VPN_PLUGIN_ERROR_FAILED: unknown or unclassified error + * @NM_VPN_PLUGIN_ERROR_STARTING_IN_PROGRESS: the plugin is already starting, + * and another connect request was received + * @NM_VPN_PLUGIN_ERROR_ALREADY_STARTED: the plugin is already connected, and + * another connect request was received + * @NM_VPN_PLUGIN_ERROR_STOPPING_IN_PROGRESS: the plugin is already stopping, + * and another stop request was received + * @NM_VPN_PLUGIN_ERROR_ALREADY_STOPPED: the plugin is already stopped, and + * another disconnect request was received + * @NM_VPN_PLUGIN_ERROR_WRONG_STATE: the operation could not be performed in + * this state + * @NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS: the operation could not be performed as + * the request contained malformed arguments, or arguments of unexpected type. + * Usually means that one of the VPN setting data items or secrets was not of + * the expected type (ie int, string, bool, etc). + * @NM_VPN_PLUGIN_ERROR_LAUNCH_FAILED: a child process failed to launch + * @NM_VPN_PLUGIN_ERROR_INVALID_CONNECTION: the operation could not be performed + * because the connection was invalid. Usually means that the connection's + * VPN setting was missing some required data item or secret. + * @NM_VPN_PLUGIN_ERROR_INTERACTIVE_NOT_SUPPORTED: the operation could not be + * performed as the plugin does not support interactive operations, such as + * ConnectInteractive() or NewSecrets() + * + * Returned by the VPN service plugin to indicate errors. These codes correspond + * to errors in the "org.freedesktop.NetworkManager.VPN.Error" namespace. + **/ +typedef enum { + NM_VPN_PLUGIN_ERROR_FAILED, /*< nick=Failed >*/ + NM_VPN_PLUGIN_ERROR_STARTING_IN_PROGRESS, /*< nick=StartingInProgress >*/ + NM_VPN_PLUGIN_ERROR_ALREADY_STARTED, /*< nick=AlreadyStarted >*/ + NM_VPN_PLUGIN_ERROR_STOPPING_IN_PROGRESS, /*< nick=StoppingInProgress >*/ + NM_VPN_PLUGIN_ERROR_ALREADY_STOPPED, /*< nick=AlreadyStopped >*/ + NM_VPN_PLUGIN_ERROR_WRONG_STATE, /*< nick=WrongState >*/ + NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS, /*< nick=BadArguments >*/ + NM_VPN_PLUGIN_ERROR_LAUNCH_FAILED, /*< nick=LaunchFailed >*/ + NM_VPN_PLUGIN_ERROR_INVALID_CONNECTION, /*< nick=InvalidConnection >*/ + NM_VPN_PLUGIN_ERROR_INTERACTIVE_NOT_SUPPORTED, /*< nick=InteractiveNotSupported >*/ +} NMVpnPluginError; + +#define NM_VPN_PLUGIN_ERROR (nm_vpn_plugin_error_quark ()) +GQuark nm_vpn_plugin_error_quark (void); + #endif /* __NM_ERRORS_H__ */ diff --git a/libnm/nm-vpn-plugin.c b/libnm/nm-vpn-plugin.c index d3fe87bf0a..ed61052ad8 100644 --- a/libnm/nm-vpn-plugin.c +++ b/libnm/nm-vpn-plugin.c @@ -91,18 +91,6 @@ enum { static GSList *active_plugins = NULL; -GQuark -nm_vpn_plugin_error_quark (void) -{ - static GQuark quark = 0; - - if (!quark) - quark = g_quark_from_static_string ("nm_vpn_plugin_error"); - - return quark; -} - - static void nm_vpn_plugin_set_connection (NMVpnPlugin *plugin, GDBusConnection *connection) @@ -490,7 +478,7 @@ impl_vpn_plugin_need_secrets (NMVpnPlugin *plugin, if (!connection) { g_dbus_method_invocation_return_error (context, NM_VPN_PLUGIN_ERROR, - NM_VPN_PLUGIN_ERROR_CONNECTION_INVALID, + NM_VPN_PLUGIN_ERROR_INVALID_CONNECTION, "The connection was invalid: %s", error->message); g_error_free (error); @@ -1033,10 +1021,6 @@ nm_vpn_plugin_class_init (NMVpnPluginClass *plugin_class) G_TYPE_NONE, 0, G_TYPE_NONE); - _nm_dbus_register_error_domain (NM_VPN_PLUGIN_ERROR, - NM_DBUS_VPN_ERROR_PREFIX, - NM_TYPE_VPN_PLUGIN_ERROR); - setup_unix_signal_handler (); } diff --git a/libnm/nm-vpn-plugin.h b/libnm/nm-vpn-plugin.h index a81a5c7abe..02245d9a44 100644 --- a/libnm/nm-vpn-plugin.h +++ b/libnm/nm-vpn-plugin.h @@ -42,48 +42,6 @@ G_BEGIN_DECLS #define NM_VPN_PLUGIN_DBUS_SERVICE_NAME "service-name" #define NM_VPN_PLUGIN_STATE "state" -/** - * NMVpnPluginError: - * @NM_VPN_PLUGIN_ERROR_GENERAL: general failure - * @NM_VPN_PLUGIN_ERROR_STARTING_IN_PROGRESS: the plugin is already starting, - * and another connect request was received - * @NM_VPN_PLUGIN_ERROR_ALREADY_STARTED: the plugin is already connected, and - * another connect request was received - * @NM_VPN_PLUGIN_ERROR_STOPPING_IN_PROGRESS: the plugin is already stopping, - * and another stop request was received - * @NM_VPN_PLUGIN_ERROR_ALREADY_STOPPED: the plugin is already stopped, and - * another disconnect request was received - * @NM_VPN_PLUGIN_ERROR_WRONG_STATE: the operation could not be performed in - * this state - * @NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS: the operation could not be performed as - * the request contained malformed arguments, or arguments of unexpected type. - * Usually means that one of the VPN setting data items or secrets was not of - * the expected type (ie int, string, bool, etc). - * @NM_VPN_PLUGIN_ERROR_LAUNCH_FAILED: a child process failed to launch - * @NM_VPN_PLUGIN_ERROR_CONNECTION_INVALID: the operation could not be performed - * because the connection was invalid. Usually means that the connection's - * VPN setting was missing some required data item or secret. - * @NM_VPN_PLUGIN_ERROR_INTERACTIVE_NOT_SUPPORTED: the operation could not be - * performed as the plugin does not support interactive operations, such as - * ConnectInteractive() or NewSecrets() - * - * Returned by the VPN service plugin to indicate errors. - **/ -typedef enum { - NM_VPN_PLUGIN_ERROR_GENERAL, /*< nick=General >*/ - NM_VPN_PLUGIN_ERROR_STARTING_IN_PROGRESS, /*< nick=StartingInProgress >*/ - NM_VPN_PLUGIN_ERROR_ALREADY_STARTED, /*< nick=AlreadyStarted >*/ - NM_VPN_PLUGIN_ERROR_STOPPING_IN_PROGRESS, /*< nick=StoppingInProgress >*/ - NM_VPN_PLUGIN_ERROR_ALREADY_STOPPED, /*< nick=AlreadyStopped >*/ - NM_VPN_PLUGIN_ERROR_WRONG_STATE, /*< nick=WrongState >*/ - NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS, /*< nick=BadArguments >*/ - NM_VPN_PLUGIN_ERROR_LAUNCH_FAILED, /*< nick=LaunchFailed >*/ - NM_VPN_PLUGIN_ERROR_CONNECTION_INVALID, /*< nick=ConnectionInvalid >*/ - NM_VPN_PLUGIN_ERROR_INTERACTIVE_NOT_SUPPORTED /*< nick=InteractiveNotSupported >*/ -} NMVpnPluginError; - -#define NM_VPN_PLUGIN_ERROR (nm_vpn_plugin_error_quark ()) - typedef struct { GObject parent; } NMVpnPlugin; @@ -139,7 +97,6 @@ typedef struct { } NMVpnPluginClass; GType nm_vpn_plugin_get_type (void); -GQuark nm_vpn_plugin_error_quark (void); GDBusConnection *nm_vpn_plugin_get_connection (NMVpnPlugin *plugin); NMVpnServiceState nm_vpn_plugin_get_state (NMVpnPlugin *plugin); |