[network-manager-openvpn/lr/libnm: 4/13] properties: use the NM error types & quarks
- From: Lubomir Rintel <lkundrak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-openvpn/lr/libnm: 4/13] properties: use the NM error types & quarks
- Date: Sun, 16 Aug 2015 14:22:09 +0000 (UTC)
commit d72b309b197d7ea582104036c2bf390094c4b06d
Author: Lubomir Rintel <lkundrak v3 sk>
Date: Thu Jul 16 16:01:23 2015 +0200
properties: use the NM error types & quarks
properties/auth-helpers.c | 6 +++++
properties/import-export.c | 8 ++++++
properties/nm-openvpn.c | 52 ++++++++++---------------------------------
properties/nm-openvpn.h | 17 --------------
4 files changed, 26 insertions(+), 57 deletions(-)
---
diff --git a/properties/auth-helpers.c b/properties/auth-helpers.c
index e1bddc7..6a2ff55 100644
--- a/properties/auth-helpers.c
+++ b/properties/auth-helpers.c
@@ -42,10 +42,16 @@
#include <nm-utils.h>
#include <nm-ui-utils.h>
+#define OPENVPN_PLUGIN_UI_ERROR NM_SETTING_VPN_ERROR
+#define OPENVPN_PLUGIN_UI_ERROR_INVALID_PROPERTY NM_SETTING_VPN_ERROR_INVALID_PROPERTY
+
#else /* !NM_OPENVPN_OLD */
#include <NetworkManager.h>
#include <nma-ui-utils.h>
+
+#define OPENVPN_PLUGIN_UI_ERROR NM_CONNECTION_ERROR
+#define OPENVPN_PLUGIN_UI_ERROR_INVALID_PROPERTY NM_CONNECTION_ERROR_INVALID_PROPERTY
#endif
#include "auth-helpers.h"
diff --git a/properties/import-export.c b/properties/import-export.c
index e0f9fd6..6f5f0fa 100644
--- a/properties/import-export.c
+++ b/properties/import-export.c
@@ -42,8 +42,16 @@
#include <nm-setting-ip4-config.h>
#define nm_simple_connection_new nm_connection_new
+
+#define OPENVPN_PLUGIN_UI_ERROR NM_SETTING_VPN_ERROR
+#define OPENVPN_PLUGIN_UI_ERROR_FILE_NOT_OPENVPN NM_SETTING_VPN_ERROR_UNKNOWN
+
#else /* !NM_OPENVPN_OLD */
+
#include <NetworkManager.h>
+
+#define OPENVPN_PLUGIN_UI_ERROR NM_CONNECTION_ERROR
+#define OPENVPN_PLUGIN_UI_ERROR_FILE_NOT_OPENVPN NM_CONNECTION_ERROR_FAILED
#endif
#include "import-export.h"
diff --git a/properties/nm-openvpn.c b/properties/nm-openvpn.c
index 4c604b4..827a629 100644
--- a/properties/nm-openvpn.c
+++ b/properties/nm-openvpn.c
@@ -47,12 +47,24 @@
#define OPENVPN_PLUGIN_NAME _("OpenVPN")
#define OPENVPN_PLUGIN_DESC _("Compatible with the OpenVPN server.")
+#define OPENVPN_PLUGIN_UI_ERROR NM_SETTING_VPN_ERROR
+#define OPENVPN_PLUGIN_UI_ERROR_INVALID_PROPERTY NM_SETTING_VPN_ERROR_INVALID_PROPERTY
+#define OPENVPN_PLUGIN_UI_ERROR_MISSING_PROPERTY NM_SETTING_VPN_ERROR_MISSING_PROPERTY
+#define OPENVPN_PLUGIN_UI_ERROR_FILE_NOT_OPENVPN NM_SETTING_VPN_ERROR_UNKNOWN
+#define OPENVPN_PLUGIN_UI_ERROR_FILE_NOT_READABLE NM_SETTING_VPN_ERROR_UNKNOWN
+
#else /* !NM_OPENVPN_OLD */
#include <NetworkManager.h>
#define OPENVPN_PLUGIN_NAME _("openvpn")
#define OPENVPN_PLUGIN_DESC _("OpenVPN")
+
+#define OPENVPN_PLUGIN_UI_ERROR NM_CONNECTION_ERROR
+#define OPENVPN_PLUGIN_UI_ERROR_INVALID_PROPERTY NM_CONNECTION_ERROR_INVALID_PROPERTY
+#define OPENVPN_PLUGIN_UI_ERROR_MISSING_PROPERTY NM_CONNECTION_ERROR_MISSING_PROPERTY
+#define OPENVPN_PLUGIN_UI_ERROR_FILE_NOT_OPENVPN NM_CONNECTION_ERROR_FAILED
+#define OPENVPN_PLUGIN_UI_ERROR_FILE_NOT_READABLE NM_CONNECTION_ERROR_FAILED
#endif
#include "../src/nm-openvpn-service-defines.h"
@@ -101,46 +113,6 @@ typedef struct {
#define COL_AUTH_PAGE 1
#define COL_AUTH_TYPE 2
-GQuark
-openvpn_plugin_ui_error_quark (void)
-{
- static GQuark error_quark = 0;
-
- if (G_UNLIKELY (error_quark == 0))
- error_quark = g_quark_from_static_string ("openvpn-plugin-ui-error-quark");
-
- return error_quark;
-}
-
-/* This should really be standard. */
-#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC }
-
-GType
-openvpn_plugin_ui_error_get_type (void)
-{
- static GType etype = 0;
-
- if (etype == 0) {
- static const GEnumValue values[] = {
- /* Unknown error. */
- ENUM_ENTRY (OPENVPN_PLUGIN_UI_ERROR_UNKNOWN, "UnknownError"),
- /* The connection was missing invalid. */
- ENUM_ENTRY (OPENVPN_PLUGIN_UI_ERROR_INVALID_CONNECTION, "InvalidConnection"),
- /* The specified property was invalid. */
- ENUM_ENTRY (OPENVPN_PLUGIN_UI_ERROR_INVALID_PROPERTY, "InvalidProperty"),
- /* The specified property was missing and is required. */
- ENUM_ENTRY (OPENVPN_PLUGIN_UI_ERROR_MISSING_PROPERTY, "MissingProperty"),
- /* The file to import could not be read. */
- ENUM_ENTRY (OPENVPN_PLUGIN_UI_ERROR_FILE_NOT_READABLE, "FileNotReadable"),
- /* The file to import could was not an OpenVPN client file. */
- ENUM_ENTRY (OPENVPN_PLUGIN_UI_ERROR_FILE_NOT_OPENVPN, "FileNotOpenVPN"),
- { 0, 0, 0 }
- };
- etype = g_enum_register_static ("OpenvpnPluginUiError", values);
- }
- return etype;
-}
-
/* Example: abc.com:1234:udp, ovpnserver.company.com:443, vpn.example.com::tcp */
static gboolean
check_gateway_entry (const char *str)
diff --git a/properties/nm-openvpn.h b/properties/nm-openvpn.h
index 98e5d6e..4aa3826 100644
--- a/properties/nm-openvpn.h
+++ b/properties/nm-openvpn.h
@@ -25,23 +25,6 @@
#include <glib-object.h>
-typedef enum
-{
- OPENVPN_PLUGIN_UI_ERROR_UNKNOWN = 0,
- OPENVPN_PLUGIN_UI_ERROR_INVALID_CONNECTION,
- OPENVPN_PLUGIN_UI_ERROR_INVALID_PROPERTY,
- OPENVPN_PLUGIN_UI_ERROR_MISSING_PROPERTY,
- OPENVPN_PLUGIN_UI_ERROR_FILE_NOT_READABLE,
- OPENVPN_PLUGIN_UI_ERROR_FILE_NOT_OPENVPN
-} OpenvpnPluginUiError;
-
-#define OPENVPN_TYPE_PLUGIN_UI_ERROR (openvpn_plugin_ui_error_get_type ())
-GType openvpn_plugin_ui_error_get_type (void);
-
-#define OPENVPN_PLUGIN_UI_ERROR (openvpn_plugin_ui_error_quark ())
-GQuark openvpn_plugin_ui_error_quark (void);
-
-
#define OPENVPN_TYPE_PLUGIN_UI (openvpn_plugin_ui_get_type ())
#define OPENVPN_PLUGIN_UI(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), OPENVPN_TYPE_PLUGIN_UI,
OpenvpnPluginUi))
#define OPENVPN_PLUGIN_UI_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), OPENVPN_TYPE_PLUGIN_UI,
OpenvpnPluginUiClass))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]