[network-manager-vpnc/lr/libnm: 2/7] service: port to libnm
- From: Lubomir Rintel <lkundrak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-vpnc/lr/libnm: 2/7] service: port to libnm
- Date: Fri, 21 Aug 2015 10:52:53 +0000 (UTC)
commit d7291286575517c8b787e9dfa389bc97986c176c
Author: Lubomir Rintel <lkundrak v3 sk>
Date: Fri Jul 24 19:27:02 2015 +0200
service: port to libnm
properties/nm-vpnc.c | 9 ++----
src/Makefile.am | 6 ++--
src/nm-vpnc-service.c | 75 +++++++++++++++++++++++++++---------------------
src/nm-vpnc-service.h | 6 ++--
4 files changed, 51 insertions(+), 45 deletions(-)
---
diff --git a/properties/nm-vpnc.c b/properties/nm-vpnc.c
index 116cabb..b2ae0a8 100644
--- a/properties/nm-vpnc.c
+++ b/properties/nm-vpnc.c
@@ -57,9 +57,6 @@
#define nm_setting_ip_config_add_route nm_setting_ip4_config_add_route
#define NM_SETTING_IP_CONFIG_NEVER_DEFAULT NM_SETTING_IP4_CONFIG_NEVER_DEFAULT
-#define VPNC_PLUGIN_NAME _("Cisco Compatible VPN (vpnc)")
-#define VPNC_PLUGIN_DESC _("Compatible with various Cisco, Juniper, Netscreen, and Sonicwall IPsec-based
VPN gateways.")
-
#define VPNC_PLUGIN_UI_ERROR NM_SETTING_VPN_ERROR
#define VPNC_PLUGIN_UI_ERROR_FAILED NM_SETTING_VPN_ERROR_UNKNOWN
#define VPNC_PLUGIN_UI_ERROR_INVALID_PROPERTY NM_SETTING_VPN_ERROR_INVALID_PROPERTY
@@ -69,9 +66,6 @@
#include <NetworkManager.h>
#include <nma-ui-utils.h>
-#define VPNC_PLUGIN_NAME _("vpnc")
-#define VPNC_PLUGIN_DESC _("Cisco Compatible VPN (vpnc)")
-
#define VPNC_PLUGIN_UI_ERROR NM_CONNECTION_ERROR
#define VPNC_PLUGIN_UI_ERROR_FAILED NM_CONNECTION_ERROR_FAILED
#define VPNC_PLUGIN_UI_ERROR_INVALID_PROPERTY NM_CONNECTION_ERROR_INVALID_PROPERTY
@@ -81,6 +75,9 @@
#include "nm-vpnc-helper.h"
#include "nm-vpnc.h"
+#define VPNC_PLUGIN_NAME _("Cisco Compatible VPN (vpnc)")
+#define VPNC_PLUGIN_DESC _("Compatible with various Cisco, Juniper, Netscreen, and Sonicwall IPsec-based
VPN gateways.")
+
#define ENC_TYPE_SECURE 0
#define ENC_TYPE_WEAK 1
#define ENC_TYPE_NONE 2
diff --git a/src/Makefile.am b/src/Makefile.am
index 267c21c..9bce180 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,7 +1,7 @@
AM_CPPFLAGS = \
$(DBUS_CFLAGS) \
$(GLIB_CFLAGS) \
- $(LIBNM_GLIB_CFLAGS) \
+ $(LIBNM_CFLAGS) \
-DG_DISABLE_DEPRECATED \
-DBINDIR=\"$(bindir)\" \
-DPREFIX=\""$(prefix)"\" \
@@ -25,7 +25,7 @@ nm_vpnc_service_SOURCES = \
nm_vpnc_service_LDADD = \
$(DBUS_LIBS) \
$(GLIB_LIBS) \
- $(LIBNM_GLIB_LIBS)
+ $(LIBNM_LIBS)
nm_vpnc_service_vpnc_helper_SOURCES = \
@@ -34,7 +34,7 @@ nm_vpnc_service_vpnc_helper_SOURCES = \
nm_vpnc_service_vpnc_helper_LDADD = \
$(DBUS_LIBS) \
$(GTHREAD_LIBS) \
- $(LIBNM_GLIB_LIBS)
+ $(LIBNM_LIBS)
noinst_PROGRAMS = test-vpnc-output
diff --git a/src/nm-vpnc-service.c b/src/nm-vpnc-service.c
index 4e7b9bb..e78ab9d 100644
--- a/src/nm-vpnc-service.c
+++ b/src/nm-vpnc-service.c
@@ -34,7 +34,7 @@
#include <locale.h>
#include <glib/gi18n.h>
-#include <nm-setting-vpn.h>
+#include <NetworkManager.h>
#include <nm-utils.h>
#include "nm-vpnc-service.h"
@@ -50,7 +50,7 @@ static GMainLoop *loop = NULL;
/* TRUE if we can use vpnc's interactive mode (version 0.5.4 or greater)*/
static gboolean interactive_available = FALSE;
-G_DEFINE_TYPE (NMVPNCPlugin, nm_vpnc_plugin, NM_TYPE_VPN_PLUGIN)
+G_DEFINE_TYPE (NMVPNCPlugin, nm_vpnc_plugin, NM_TYPE_VPN_SERVICE_PLUGIN)
typedef struct {
int fd;
@@ -226,7 +226,7 @@ validate_one_property (const char *key, const char *value, gpointer user_data)
}
static gboolean
-nm_vpnc_properties_validate (NMSettingVPN *s_vpn, GError **error)
+nm_vpnc_properties_validate (NMSettingVpn *s_vpn, GError **error)
{
ValidateInfo info = { &valid_properties[0], error, FALSE };
@@ -244,7 +244,7 @@ nm_vpnc_properties_validate (NMSettingVPN *s_vpn, GError **error)
}
static gboolean
-nm_vpnc_secrets_validate (NMSettingVPN *s_vpn,
+nm_vpnc_secrets_validate (NMSettingVpn *s_vpn,
gboolean allow_missing,
GError **error)
{
@@ -401,17 +401,17 @@ vpnc_watch_cb (GPid pid, gint status, gpointer user_data)
switch (error) {
case 2:
/* Couldn't log in due to bad user/pass */
- nm_vpn_plugin_failure (NM_VPN_PLUGIN (plugin), NM_VPN_PLUGIN_FAILURE_LOGIN_FAILED);
+ nm_vpn_service_plugin_failure (NM_VPN_SERVICE_PLUGIN (plugin),
NM_VPN_PLUGIN_FAILURE_LOGIN_FAILED);
break;
case 1:
/* Other error (couldn't bind to address, etc) */
- nm_vpn_plugin_failure (NM_VPN_PLUGIN (plugin), NM_VPN_PLUGIN_FAILURE_CONNECT_FAILED);
+ nm_vpn_service_plugin_failure (NM_VPN_SERVICE_PLUGIN (plugin),
NM_VPN_PLUGIN_FAILURE_CONNECT_FAILED);
break;
default:
break;
}
- nm_vpn_plugin_set_state (NM_VPN_PLUGIN (plugin), NM_VPN_SERVICE_STATE_STOPPED);
+ nm_vpn_service_plugin_set_state (NM_VPN_SERVICE_PLUGIN (plugin), NM_VPN_SERVICE_STATE_STOPPED);
}
#define XAUTH_USERNAME_PROMPT "Enter username for "
@@ -473,7 +473,7 @@ vpnc_prompt (const char *data, gsize dlen, gpointer user_data)
if (debug)
g_message ("Requesting new secrets: '%s' (%s)", prompt, hints[0]);
- nm_vpn_plugin_secrets_required (NM_VPN_PLUGIN (plugin),
+ nm_vpn_service_plugin_secrets_required (NM_VPN_SERVICE_PLUGIN (plugin),
priv->server_message->len ? priv->server_message->str : prompt,
(const char **) hints);
g_string_truncate (priv->server_message, 0);
@@ -758,7 +758,7 @@ write_one_property (const char *key, const char *value, gpointer user_data)
static gboolean
nm_vpnc_config_write (gint vpnc_fd,
NMSettingConnection *s_con,
- NMSettingVPN *s_vpn,
+ NMSettingVpn *s_vpn,
GError **error)
{
WriteConfigInfo *info;
@@ -851,14 +851,14 @@ nm_vpnc_config_write (gint vpnc_fd,
}
static gboolean
-_connect_common (NMVPNPlugin *plugin,
+_connect_common (NMVpnServicePlugin *plugin,
gboolean interactive,
NMConnection *connection,
- GHashTable *details,
+ GVariant *details,
GError **error)
{
NMVPNCPluginPrivate *priv = NM_VPNC_PLUGIN_GET_PRIVATE (plugin);
- NMSettingVPN *s_vpn;
+ NMSettingVpn *s_vpn;
NMSettingConnection *s_con;
char end[] = { 0x04 };
@@ -901,7 +901,7 @@ out:
}
static gboolean
-real_connect (NMVPNPlugin *plugin,
+real_connect (NMVpnServicePlugin *plugin,
NMConnection *connection,
GError **error)
{
@@ -909,9 +909,9 @@ real_connect (NMVPNPlugin *plugin,
}
static gboolean
-real_connect_interactive (NMVPNPlugin *plugin,
+real_connect_interactive (NMVpnServicePlugin *plugin,
NMConnection *connection,
- GHashTable *details,
+ GVariant *details,
GError **error)
{
if (!interactive_available) {
@@ -930,18 +930,18 @@ real_connect_interactive (NMVPNPlugin *plugin,
}
static gboolean
-real_new_secrets (NMVPNPlugin *plugin,
+real_new_secrets (NMVpnServicePlugin *plugin,
NMConnection *connection,
GError **error)
{
NMVPNCPluginPrivate *priv = NM_VPNC_PLUGIN_GET_PRIVATE (plugin);
- NMSettingVPN *s_vpn;
+ NMSettingVpn *s_vpn;
const char *secret;
if (!interactive_available || !priv->interactive) {
g_set_error_literal (error,
NM_VPN_PLUGIN_ERROR,
- NM_VPN_PLUGIN_ERROR_GENERAL,
+ NM_VPN_PLUGIN_ERROR_FAILED,
_("Could not use new secrets as interactive mode is disabled."));
return FALSE;
}
@@ -950,7 +950,7 @@ real_new_secrets (NMVPNPlugin *plugin,
if (!s_vpn) {
g_set_error_literal (error,
NM_VPN_PLUGIN_ERROR,
- NM_VPN_PLUGIN_ERROR_CONNECTION_INVALID,
+ NM_VPN_PLUGIN_ERROR_INVALID_CONNECTION,
_("Could not process the request because the VPN connection settings
were invalid."));
return FALSE;
}
@@ -958,7 +958,7 @@ real_new_secrets (NMVPNPlugin *plugin,
if (!priv->pending_auth) {
g_set_error_literal (error,
NM_VPN_PLUGIN_ERROR,
- NM_VPN_PLUGIN_ERROR_CONNECTION_INVALID,
+ NM_VPN_PLUGIN_ERROR_INVALID_CONNECTION,
_("Could not process the request because no pending authentication is
required."));
return FALSE;
}
@@ -970,7 +970,7 @@ real_new_secrets (NMVPNPlugin *plugin,
if (!secret) {
g_set_error (error,
NM_VPN_PLUGIN_ERROR,
- NM_VPN_PLUGIN_ERROR_CONNECTION_INVALID,
+ NM_VPN_PLUGIN_ERROR_INVALID_CONNECTION,
_("Could not process the request because the requested info '%s' was not
provided."),
priv->pending_auth);
return FALSE;
@@ -984,7 +984,7 @@ real_new_secrets (NMVPNPlugin *plugin,
}
static NMSettingSecretFlags
-get_pw_flags (NMSettingVPN *s_vpn, const char *secret_name, const char *type_name)
+get_pw_flags (NMSettingVpn *s_vpn, const char *secret_name, const char *type_name)
{
const char *val;
NMSettingSecretFlags flags = NM_SETTING_SECRET_FLAG_NONE;
@@ -1008,23 +1008,23 @@ get_pw_flags (NMSettingVPN *s_vpn, const char *secret_name, const char *type_nam
}
static gboolean
-real_need_secrets (NMVPNPlugin *plugin,
+real_need_secrets (NMVpnServicePlugin *plugin,
NMConnection *connection,
- char **out_setting_name,
+ const char **out_setting_name,
GError **error)
{
- NMSettingVPN *s_vpn;
+ NMSettingVpn *s_vpn;
NMSettingSecretFlags pw_flags;
const char *pw = NULL;
- g_return_val_if_fail (NM_IS_VPN_PLUGIN (plugin), FALSE);
+ g_return_val_if_fail (NM_IS_VPN_SERVICE_PLUGIN (plugin), FALSE);
g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
s_vpn = nm_connection_get_setting_vpn (connection);
if (!s_vpn) {
g_set_error (error,
NM_VPN_PLUGIN_ERROR,
- NM_VPN_PLUGIN_ERROR_CONNECTION_INVALID,
+ NM_VPN_PLUGIN_ERROR_INVALID_CONNECTION,
"%s",
_("Could not process the request because the VPN connection settings were
invalid."));
return FALSE;
@@ -1050,7 +1050,7 @@ real_need_secrets (NMVPNPlugin *plugin,
}
static gboolean
-real_disconnect (NMVPNPlugin *plugin, GError **error)
+real_disconnect (NMVpnServicePlugin *plugin, GError **error)
{
vpnc_cleanup (NM_VPNC_PLUGIN (plugin), TRUE);
return TRUE;
@@ -1071,7 +1071,7 @@ static void
nm_vpnc_plugin_class_init (NMVPNCPluginClass *vpnc_class)
{
GObjectClass *object_class = G_OBJECT_CLASS (vpnc_class);
- NMVPNPluginClass *parent_class = NM_VPN_PLUGIN_CLASS (vpnc_class);
+ NMVpnServicePluginClass *parent_class = NM_VPN_SERVICE_PLUGIN_CLASS (vpnc_class);
g_type_class_add_private (object_class, sizeof (NMVPNCPluginPrivate));
@@ -1086,10 +1086,19 @@ nm_vpnc_plugin_class_init (NMVPNCPluginClass *vpnc_class)
NMVPNCPlugin *
nm_vpnc_plugin_new (void)
{
- return (NMVPNCPlugin *) g_object_new (NM_TYPE_VPNC_PLUGIN,
- NM_VPN_PLUGIN_DBUS_SERVICE_NAME,
- NM_DBUS_SERVICE_VPNC,
- NULL);
+ NMVPNCPlugin *plugin;
+ GError *error = NULL;
+
+ plugin = (NMVPNCPlugin *) g_initable_new (NM_TYPE_VPNC_PLUGIN, NULL, &error,
+ NM_VPN_SERVICE_PLUGIN_DBUS_SERVICE_NAME,
+ NM_DBUS_SERVICE_VPNC,
+ NULL);
+ if (!plugin) {
+ g_warning ("Failed to initialize a plugin instance: %s", error->message);
+ g_error_free (error);
+ }
+
+ return plugin;
}
static void
diff --git a/src/nm-vpnc-service.h b/src/nm-vpnc-service.h
index f7ae9be..f570e09 100644
--- a/src/nm-vpnc-service.h
+++ b/src/nm-vpnc-service.h
@@ -24,7 +24,7 @@
#include <glib.h>
#include <glib-object.h>
-#include <nm-vpn-plugin.h>
+#include <nm-vpn-service-plugin.h>
#include "nm-vpnc-service-defines.h"
@@ -36,11 +36,11 @@
#define NM_VPNC_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_VPNC_PLUGIN,
NMVPNCPluginClass))
typedef struct {
- NMVPNPlugin parent;
+ NMVpnServicePlugin parent;
} NMVPNCPlugin;
typedef struct {
- NMVPNPluginClass parent;
+ NMVpnServicePluginClass parent;
} NMVPNCPluginClass;
GType nm_vpnc_plugin_get_type (void);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]