[network-manager-openvpn/lr/libnm-3: 6/10] service: port to libnm
- From: Lubomir Rintel <lkundrak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-openvpn/lr/libnm-3: 6/10] service: port to libnm
- Date: Wed, 19 Aug 2015 20:11:43 +0000 (UTC)
commit 1a18e02f113064a6420f2ebf221b42a3a930c684
Author: Lubomir Rintel <lkundrak v3 sk>
Date: Thu Jul 23 16:25:19 2015 +0200
service: port to libnm
configure.ac | 2 -
properties/import-export.c | 2 +-
src/Makefile.am | 10 +-
src/nm-openvpn-service-openvpn-helper.c | 427 +++++++++++++------------------
src/nm-openvpn-service.c | 109 ++++----
src/nm-openvpn-service.h | 6 +-
6 files changed, 238 insertions(+), 318 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index f364c02..eca1838 100644
--- a/configure.ac
+++ b/configure.ac
@@ -60,8 +60,6 @@ AM_GLIB_GNU_GETTEXT
PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.32)
GLIB_CFLAGS="$GLIB_CFLAGS -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_32"
-PKG_CHECK_MODULES(DBUS, dbus-glib-1 >= 0.74)
-
PKG_CHECK_MODULES(LIBNM_GLIB,
NetworkManager >= 1.1.0
libnm-util >= 1.1.0
diff --git a/properties/import-export.c b/properties/import-export.c
index 02db4f0..ab475b9 100644
--- a/properties/import-export.c
+++ b/properties/import-export.c
@@ -321,7 +321,7 @@ static gboolean
handle_num_seconds_item (const char *line,
const char *tag,
const char *key,
- NMSettingVPN *s_vpn)
+ NMSettingVpn *s_vpn)
{
char **items = NULL;
int nitems;
diff --git a/src/Makefile.am b/src/Makefile.am
index d7b8e86..0c3c3a3 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,7 +1,6 @@
AM_CPPFLAGS = \
$(GLIB_CFLAGS) \
- $(DBUS_CFLAGS) \
- $(LIBNM_GLIB_CFLAGS) \
+ $(LIBNM_CFLAGS) \
-DBINDIR=\"$(bindir)\" \
-DPREFIX=\""$(prefix)"\" \
-DSYSCONFDIR=\""$(sysconfdir)"\" \
@@ -21,14 +20,13 @@ nm_openvpn_service_SOURCES = \
nm-openvpn-service-defines.h
nm_openvpn_service_LDADD = \
- $(LIBNM_GLIB_LIBS) \
- $(top_builddir)/common/libnm-openvpn-common.la
+ $(LIBNM_LIBS) \
+ $(top_builddir)/common/libnm-vpn-plugin-openvpn-common.la
nm_openvpn_service_openvpn_helper_SOURCES = \
nm-openvpn-service-openvpn-helper.c
nm_openvpn_service_openvpn_helper_LDADD = \
- $(DBUS_LIBS) \
- $(LIBNM_GLIB_LIBS)
+ $(LIBNM_LIBS)
CLEANFILES = *~
diff --git a/src/nm-openvpn-service-openvpn-helper.c b/src/nm-openvpn-service-openvpn-helper.c
index 2c07cff..28456da 100644
--- a/src/nm-openvpn-service-openvpn-helper.c
+++ b/src/nm-openvpn-service-openvpn-helper.c
@@ -39,9 +39,6 @@
#include <ctype.h>
#include <netdb.h>
-#include <dbus/dbus.h>
-#include <dbus/dbus-glib-lowlevel.h>
-#include <dbus/dbus-glib.h>
#include <NetworkManager.h>
#include "nm-openvpn-service.h"
@@ -49,72 +46,49 @@
extern char **environ;
-/* These are here because nm-dbus-glib-types.h isn't exported */
-#define DBUS_TYPE_G_ARRAY_OF_UINT (dbus_g_type_get_collection ("GArray", G_TYPE_UINT))
-#define DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UINT (dbus_g_type_get_collection ("GPtrArray",
DBUS_TYPE_G_ARRAY_OF_UINT))
-#define DBUS_TYPE_G_PTR_ARRAY_OF_STRING (dbus_g_type_get_collection ("GPtrArray", G_TYPE_STRING))
-#define DBUS_TYPE_G_MAP_OF_VARIANT (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE))
-#define DBUS_TYPE_G_IP6_ROUTE (dbus_g_type_get_struct ("GValueArray", DBUS_TYPE_G_UCHAR_ARRAY,
G_TYPE_UINT, DBUS_TYPE_G_UCHAR_ARRAY, G_TYPE_UINT, G_TYPE_INVALID))
-#define DBUS_TYPE_G_ARRAY_OF_IP6_ROUTE (dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_IP6_ROUTE))
-
static gboolean helper_debug = FALSE;
static void
-helper_failed (DBusGConnection *connection, const char *reason)
+helper_failed (GDBusProxy *proxy, const char *reason)
{
- DBusGProxy *proxy;
GError *err = NULL;
g_warning ("nm-openvpn-service-openvpn-helper did not receive a valid %s from openvpn", reason);
- proxy = dbus_g_proxy_new_for_name (connection,
- NM_DBUS_SERVICE_OPENVPN,
- NM_VPN_DBUS_PLUGIN_PATH,
- NM_VPN_DBUS_PLUGIN_INTERFACE);
-
- dbus_g_proxy_call (proxy, "SetFailure", &err,
- G_TYPE_STRING, reason,
- G_TYPE_INVALID,
- G_TYPE_INVALID);
-
- if (err) {
+ if (!g_dbus_proxy_call_sync (proxy, "SetFailure",
+ g_variant_new ("(s)", reason),
+ G_DBUS_CALL_FLAGS_NONE, -1,
+ NULL,
+ &err)) {
g_warning ("Could not send failure information: %s", err->message);
g_error_free (err);
}
- g_object_unref (proxy);
-
exit (1);
}
static void
-send_config (DBusGConnection *connection, GHashTable *config,
- GHashTable *ip4config, GHashTable *ip6config)
+send_config (GDBusProxy *proxy, GVariant *config,
+ GVariant *ip4config, GVariant *ip6config)
{
- DBusGProxy *proxy;
GError *err = NULL;
- proxy = dbus_g_proxy_new_for_name (connection,
- NM_DBUS_SERVICE_OPENVPN,
- NM_VPN_DBUS_PLUGIN_PATH,
- NM_VPN_DBUS_PLUGIN_INTERFACE);
-
- if (!dbus_g_proxy_call (proxy, "SetConfig", &err,
- DBUS_TYPE_G_MAP_OF_VARIANT,
- config,
- G_TYPE_INVALID,
- G_TYPE_INVALID) && err) {
+ if (!g_dbus_proxy_call_sync (proxy, "SetConfig",
+ g_variant_new ("(*)", config),
+ G_DBUS_CALL_FLAGS_NONE, -1,
+ NULL,
+ &err)) {
g_warning ("Could not send configuration information: %s", err->message);
g_error_free (err);
err = NULL;
}
if (ip4config) {
- if (!dbus_g_proxy_call (proxy, "SetIp4Config", &err,
- DBUS_TYPE_G_MAP_OF_VARIANT,
- ip4config,
- G_TYPE_INVALID,
- G_TYPE_INVALID) && err) {
+ if (!g_dbus_proxy_call_sync (proxy, "SetIp4Config",
+ g_variant_new ("(*)", ip4config),
+ G_DBUS_CALL_FLAGS_NONE, -1,
+ NULL,
+ &err)) {
g_warning ("Could not send IPv4 configuration information: %s", err->message);
g_error_free (err);
err = NULL;
@@ -122,25 +96,21 @@ send_config (DBusGConnection *connection, GHashTable *config,
}
if (ip6config) {
- if (!dbus_g_proxy_call (proxy, "SetIp6Config", &err,
- DBUS_TYPE_G_MAP_OF_VARIANT,
- ip6config,
- G_TYPE_INVALID,
- G_TYPE_INVALID) && err) {
+ if (!g_dbus_proxy_call_sync (proxy, "SetIp6Config",
+ g_variant_new ("(*)", ip6config),
+ G_DBUS_CALL_FLAGS_NONE, -1,
+ NULL,
+ &err)) {
g_warning ("Could not send IPv6 configuration information: %s", err->message);
g_error_free (err);
err = NULL;
}
}
-
- g_object_unref (proxy);
}
-static GValue *
-str_to_gvalue (const char *str, gboolean try_convert)
+static GVariant *
+str_to_gvariant (const char *str, gboolean try_convert)
{
- GValue *val;
-
/* Empty */
if (!str || strlen (str) < 1)
return NULL;
@@ -154,44 +124,13 @@ str_to_gvalue (const char *str, gboolean try_convert)
return NULL;
}
- val = g_slice_new0 (GValue);
- g_value_init (val, G_TYPE_STRING);
- g_value_set_string (val, str);
-
- return val;
-}
-
-static GValue *
-uint_to_gvalue (guint32 num)
-{
- GValue *val;
-
- if (num == 0)
- return NULL;
-
- val = g_slice_new0 (GValue);
- g_value_init (val, G_TYPE_UINT);
- g_value_set_uint (val, num);
-
- return val;
-}
-
-static GValue *
-bool_to_gvalue (gboolean b)
-{
- GValue *val;
-
- val = g_slice_new0 (GValue);
- g_value_init (val, G_TYPE_BOOLEAN);
- g_value_set_boolean (val, b);
- return val;
+ return g_variant_new_string (str);
}
-static GValue *
-addr4_to_gvalue (const char *str)
+static GVariant *
+addr4_to_gvariant (const char *str)
{
struct in_addr temp_addr;
- GValue *val;
/* Empty */
if (!str || strlen (str) < 1)
@@ -200,55 +139,37 @@ addr4_to_gvalue (const char *str)
if (inet_pton (AF_INET, str, &temp_addr) <= 0)
return NULL;
- val = g_slice_new0 (GValue);
- g_value_init (val, G_TYPE_UINT);
- g_value_set_uint (val, temp_addr.s_addr);
-
- return val;
+ return g_variant_new_uint32 (temp_addr.s_addr);
}
-static GValue *
-parse_addr4_list (GValue *value_array, const char *str)
+static void
+parse_addr4_list (GPtrArray *array, const char *str)
{
char **split;
int i;
struct in_addr temp_addr;
- GArray *array;
/* Empty */
if (!str || strlen (str) < 1)
- return value_array;
-
- if (value_array)
- array = (GArray *) g_value_get_boxed (value_array);
- else
- array = g_array_new (FALSE, FALSE, sizeof (guint));
+ return;
split = g_strsplit (str, " ", -1);
for (i = 0; split[i]; i++) {
if (inet_pton (AF_INET, split[i], &temp_addr) > 0)
- g_array_append_val (array, temp_addr.s_addr);
+ g_ptr_array_add (array, g_variant_new_uint32 (temp_addr.s_addr));
}
g_strfreev (split);
- if (!value_array && array->len > 0) {
- value_array = g_slice_new0 (GValue);
- g_value_init (value_array, DBUS_TYPE_G_UINT_ARRAY);
- g_value_set_boxed (value_array, array);
- }
- if (!value_array)
- g_array_free (array, TRUE);
-
- return value_array;
+ return;
}
-static GValue *
-addr6_to_gvalue (const char *str)
+static GVariant *
+addr6_to_gvariant (const char *str)
{
struct in6_addr temp_addr;
- GValue *val;
- GByteArray *ba;
+ GVariantBuilder builder;
+ int i;
/* Empty */
if (!str || strlen (str) < 1)
@@ -257,12 +178,10 @@ addr6_to_gvalue (const char *str)
if (inet_pton (AF_INET6, str, &temp_addr) <= 0)
return NULL;
- val = g_slice_new0 (GValue);
- g_value_init (val, DBUS_TYPE_G_UCHAR_ARRAY);
- ba = g_byte_array_new ();
- g_byte_array_append (ba, (guint8 *) &temp_addr, sizeof (temp_addr));
- g_value_take_boxed (val, ba);
- return val;
+ g_variant_builder_init (&builder, G_VARIANT_TYPE ("ay"));
+ for (i = 0; i < sizeof (temp_addr); i++)
+ g_variant_builder_add (&builder, "y", ((guint8 *) &temp_addr)[i]);
+ return g_variant_builder_end (&builder);
}
static inline gboolean
@@ -273,18 +192,18 @@ is_domain_valid (const char *str)
#define BUFLEN 256
-static GValue *
+static GVariant *
get_ip4_routes (void)
{
- GValue *value = NULL;
- GPtrArray *routes;
+ GVariantBuilder builder;
+ GVariant *value;
char *tmp;
int i;
- routes = g_ptr_array_new ();
+ g_variant_builder_init (&builder, G_VARIANT_TYPE ("aau"));
for (i = 1; i < 256; i++) {
- GArray *array;
+ GVariantBuilder array;
char buf[BUFLEN];
struct in_addr network;
struct in_addr netmask;
@@ -331,41 +250,39 @@ get_ip4_routes (void)
metric = (guint32) tmp_metric;
}
- array = g_array_sized_new (FALSE, TRUE, sizeof (guint32), 4);
- g_array_append_val (array, network.s_addr);
+ g_variant_builder_init (&array, G_VARIANT_TYPE ("au"));
+ g_variant_builder_add_value (&array, g_variant_new_uint32 (network.s_addr));
prefix = nm_utils_ip4_netmask_to_prefix (netmask.s_addr);
- g_array_append_val (array, prefix);
- g_array_append_val (array, gateway.s_addr);
- g_array_append_val (array, metric);
- g_ptr_array_add (routes, array);
+ g_variant_builder_add_value (&array, g_variant_new_uint32 (prefix));
+ g_variant_builder_add_value (&array, g_variant_new_uint32 (gateway.s_addr));
+ g_variant_builder_add_value (&array, g_variant_new_uint32 (metric));
+ g_variant_builder_add_value (&builder, g_variant_builder_end (&array));
}
- if (routes->len > 0) {
- value = g_new0 (GValue, 1);
- g_value_init (value, DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UINT);
- g_value_take_boxed (value, routes);
- } else
- g_ptr_array_free (routes, TRUE);
+ value = g_variant_builder_end (&builder);
+ if (i > 1)
+ return value;
- return value;
+ g_variant_unref (value);
+ return NULL;
}
-static GValue *
+static GVariant *
get_ip6_routes (void)
{
- GValue *value = NULL;
- GSList *routes;
+ GVariant *value = NULL;
+ GPtrArray *routes;
char *tmp;
int i;
- routes = NULL;
+ routes = g_ptr_array_new_full (256, (GDestroyNotify) nm_ip_route_unref);
for (i = 1; i < 256; i++) {
- NMIP6Route *route;
+ NMIPRoute *route;
char buf[BUFLEN];
- struct in6_addr network, gateway;
guint32 prefix;
gchar **dest_prefix;
+ GError *error = NULL;
snprintf (buf, BUFLEN, "route_ipv6_network_%d", i);
tmp = getenv (buf);
@@ -375,13 +292,6 @@ get_ip6_routes (void)
/* Split network string in "dest/prefix" format */
dest_prefix = g_strsplit (tmp, "/", 2);
- tmp = dest_prefix[0];
- if (inet_pton (AF_INET6, tmp, &network) <= 0) {
- g_warning ("Ignoring invalid static route address '%s'", tmp ? tmp : "NULL");
- g_strfreev (dest_prefix);
- continue;
- }
-
tmp = dest_prefix[1];
if (tmp) {
long int tmp_prefix;
@@ -403,46 +313,34 @@ get_ip6_routes (void)
snprintf (buf, BUFLEN, "route_ipv6_gateway_%d", i);
tmp = getenv (buf);
- /* gateway can be missing */
- if (tmp && (inet_pton (AF_INET6, tmp, &gateway) <= 0)) {
- g_warning ("Ignoring invalid static route gateway '%s'", tmp ? tmp : "NULL");
+
+ route = nm_ip_route_new (AF_INET6, dest_prefix[0], prefix, tmp, -1, &error);
+ if (!route) {
+ g_warning ("Ignoring a route: %s", error->message);
+ g_error_free (error);
continue;
}
-
- route = nm_ip6_route_new ();
- nm_ip6_route_set_dest (route, &network);
- nm_ip6_route_set_prefix (route, prefix);
- nm_ip6_route_set_next_hop (route, &gateway);
-
- routes = g_slist_append (routes, route);
+ g_ptr_array_add (routes, route);
}
- if (routes) {
- GSList *iter;
-
- value = g_slice_new0 (GValue);
- g_value_init (value, DBUS_TYPE_G_ARRAY_OF_IP6_ROUTE);
- nm_utils_ip6_routes_to_gvalue (routes, value);
-
- for (iter = routes; iter; iter = iter->next)
- nm_ip6_route_unref (iter->data);
- g_slist_free (routes);
- }
+ if (routes->len)
+ value = nm_utils_ip6_routes_to_variant (routes);
+ g_ptr_array_unref (routes);
return value;
}
-static GValue *
-trusted_remote_to_gvalue (void)
+static GVariant *
+trusted_remote_to_gvariant (void)
{
char *tmp;
- GValue *val = NULL;
+ GVariant *val = NULL;
const char *p;
gboolean is_name = FALSE;
tmp = getenv ("trusted_ip6");
if (tmp) {
- val = addr6_to_gvalue(tmp);
+ val = addr6_to_gvariant (tmp);
if (val == NULL) {
g_warning ("%s: failed to convert VPN gateway address '%s' (%d)",
__func__, tmp, errno);
@@ -504,14 +402,14 @@ trusted_remote_to_gvalue (void)
freeaddrinfo (result);
if (addr.s_addr != 0)
- return uint_to_gvalue (addr.s_addr);
+ return g_variant_new_uint32 (addr.s_addr);
else {
g_warning ("%s: failed to convert or look up VPN gateway address '%s'",
__func__, tmp);
return NULL;
}
} else {
- val = addr4_to_gvalue (tmp);
+ val = addr4_to_gvariant (tmp);
if (val == NULL) {
g_warning ("%s: failed to convert VPN gateway address '%s' (%d)",
__func__, tmp, errno);
@@ -525,20 +423,22 @@ trusted_remote_to_gvalue (void)
int
main (int argc, char *argv[])
{
- DBusGConnection *connection;
- GHashTable *config, *ip4config, *ip6config;
+ GDBusProxy *proxy;
+ GVariantBuilder builder, ip4builder, ip6builder;
+ GVariant *ip4config, *ip6config;
char *tmp;
- GValue *val;
+ GVariant *val;
int i;
GError *err = NULL;
- GValue *dns_list = NULL;
- GValue *nbns_list = NULL;
- GPtrArray *dns_domains = NULL;
+ GPtrArray *dns_list;
+ GPtrArray *nbns_list;
+ GPtrArray *dns_domains;
struct in_addr temp_addr;
int tapdev = -1;
char **iter;
int shift = 0;
gboolean is_restart;
+ gboolean has_ip4_prefix = FALSE;
#if !GLIB_CHECK_VERSION (2, 35, 0)
g_type_init ();
@@ -590,41 +490,48 @@ main (int argc, char *argv[])
is_restart = argc >= 7 && !g_strcmp0 (argv[6], "restart");
- connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &err);
- if (!connection) {
- g_warning ("Could not get the system bus: %s", err->message);
+ proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
+ G_DBUS_PROXY_FLAGS_NONE,
+ NULL,
+ NM_DBUS_SERVICE_OPENVPN,
+ NM_VPN_DBUS_PLUGIN_PATH,
+ NM_VPN_DBUS_PLUGIN_INTERFACE,
+ NULL, &err);
+ if (!proxy) {
+ g_warning ("Could not create a D-Bus proxy: %s", err->message);
+ g_error_free (err);
exit (1);
}
- config = g_hash_table_new (g_str_hash, g_str_equal);
- ip4config = g_hash_table_new (g_str_hash, g_str_equal);
- ip6config = g_hash_table_new (g_str_hash, g_str_equal);
+ g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT);
+ g_variant_builder_init (&ip4builder, G_VARIANT_TYPE_VARDICT);
+ g_variant_builder_init (&ip6builder, G_VARIANT_TYPE_VARDICT);
/* External world-visible VPN gateway */
- val = trusted_remote_to_gvalue ();
+ val = trusted_remote_to_gvariant ();
if (val)
- g_hash_table_insert (config, NM_VPN_PLUGIN_CONFIG_EXT_GATEWAY, val);
+ g_variant_builder_add (&builder, "{sv}", NM_VPN_PLUGIN_CONFIG_EXT_GATEWAY, val);
else
- helper_failed (connection, "VPN Gateway");
+ helper_failed (proxy, "VPN Gateway");
/* Internal VPN subnet gateway */
tmp = getenv ("route_vpn_gateway");
- val = addr4_to_gvalue (tmp);
+ val = addr4_to_gvariant (tmp);
if (val)
- g_hash_table_insert (ip4config, NM_VPN_PLUGIN_IP4_CONFIG_INT_GATEWAY, val);
+ g_variant_builder_add (&ip4builder, "{sv}", NM_VPN_PLUGIN_IP4_CONFIG_INT_GATEWAY, val);
else {
- val = addr6_to_gvalue (tmp);
+ val = addr6_to_gvariant (tmp);
if (val)
- g_hash_table_insert (ip6config, NM_VPN_PLUGIN_IP6_CONFIG_INT_GATEWAY, val);
+ g_variant_builder_add (&ip6builder, "{sv}", NM_VPN_PLUGIN_IP6_CONFIG_INT_GATEWAY,
val);
}
/* VPN device */
tmp = getenv ("dev");
- val = str_to_gvalue (tmp, FALSE);
+ val = str_to_gvariant (tmp, FALSE);
if (val)
- g_hash_table_insert (config, NM_VPN_PLUGIN_CONFIG_TUNDEV, val);
+ g_variant_builder_add (&builder, "{sv}", NM_VPN_PLUGIN_CONFIG_TUNDEV, val);
else
- helper_failed (connection, "Tunnel Device");
+ helper_failed (proxy, "Tunnel Device");
if (tapdev == -1)
tapdev = strncmp (tmp, "tap", 3) == 0;
@@ -634,18 +541,18 @@ main (int argc, char *argv[])
if (!tmp && is_restart)
tmp = argv[4];
if (tmp && strlen (tmp)) {
- val = addr4_to_gvalue (tmp);
+ val = addr4_to_gvariant (tmp);
if (val)
- g_hash_table_insert (ip4config, NM_VPN_PLUGIN_IP4_CONFIG_ADDRESS, val);
+ g_variant_builder_add (&ip4builder, "{sv}", NM_VPN_PLUGIN_IP4_CONFIG_ADDRESS, val);
else
- helper_failed (connection, "IP4 Address");
+ helper_failed (proxy, "IP4 Address");
}
/* PTP address; for vpnc PTP address == internal IP4 address */
tmp = getenv ("ifconfig_remote");
if (!tmp && is_restart)
tmp = argv[5];
- val = addr4_to_gvalue (tmp);
+ val = addr4_to_gvariant (tmp);
if (val) {
/* Sigh. Openvpn added 'topology' stuff in 2.1 that changes the meaning
* of the ifconfig bits without actually telling you what they are
@@ -655,11 +562,13 @@ main (int argc, char *argv[])
guint32 addr;
/* probably a netmask, not a PTP address; topology == subnet */
- addr = g_value_get_uint (val);
- g_value_set_uint (val, nm_utils_ip4_netmask_to_prefix (addr));
- g_hash_table_insert (ip4config, NM_VPN_PLUGIN_IP4_CONFIG_PREFIX, val);
+ addr = g_variant_get_uint32 (val);
+ g_variant_unref (val);
+ val = g_variant_new_uint32 (nm_utils_ip4_netmask_to_prefix (addr));
+ g_variant_builder_add (&ip4builder, "{sv}", NM_VPN_PLUGIN_IP4_CONFIG_PREFIX, val);
+ has_ip4_prefix = TRUE;
} else
- g_hash_table_insert (ip4config, NM_VPN_PLUGIN_IP4_CONFIG_PTP, val);
+ g_variant_builder_add (&ip4builder, "{sv}", NM_VPN_PLUGIN_IP4_CONFIG_PTP, val);
}
/* Netmask
@@ -671,42 +580,38 @@ main (int argc, char *argv[])
*/
tmp = getenv ("ifconfig_netmask");
if (tmp && inet_pton (AF_INET, tmp, &temp_addr) > 0) {
- val = g_slice_new0 (GValue);
- g_value_init (val, G_TYPE_UINT);
- g_value_set_uint (val, nm_utils_ip4_netmask_to_prefix (temp_addr.s_addr));
- g_hash_table_insert (ip4config, NM_VPN_PLUGIN_IP4_CONFIG_PREFIX, val);
+ val = g_variant_new_uint32 (nm_utils_ip4_netmask_to_prefix (temp_addr.s_addr));
+ g_variant_builder_add (&ip4builder, "{sv}", NM_VPN_PLUGIN_IP4_CONFIG_PREFIX, val);
} else if (!tapdev) {
- if (!g_hash_table_lookup (ip4config, NM_VPN_PLUGIN_IP4_CONFIG_PREFIX)) {
- val = g_slice_new0 (GValue);
- g_value_init (val, G_TYPE_UINT);
- g_value_set_uint (val, 32);
- g_hash_table_insert (ip4config, NM_VPN_PLUGIN_IP4_CONFIG_PREFIX, val);
+ if (!has_ip4_prefix) {
+ val = g_variant_new_uint32 (32);
+ g_variant_builder_add (&ip4builder, "{sv}", NM_VPN_PLUGIN_IP4_CONFIG_PREFIX, val);
}
} else
g_warning ("No IP4 netmask/prefix (missing or invalid 'ifconfig_netmask')");
val = get_ip4_routes ();
if (val)
- g_hash_table_insert (ip4config, NM_VPN_PLUGIN_IP4_CONFIG_ROUTES, val);
+ g_variant_builder_add (&ip4builder, "{sv}", NM_VPN_PLUGIN_IP4_CONFIG_ROUTES, val);
/* IPv6 address */
tmp = getenv ("ifconfig_ipv6_local");
if (tmp && strlen (tmp)) {
- val = addr6_to_gvalue (tmp);
+ val = addr6_to_gvariant (tmp);
if (val)
- g_hash_table_insert (ip6config, NM_VPN_PLUGIN_IP6_CONFIG_ADDRESS, val);
+ g_variant_builder_add (&ip6builder, "{sv}", NM_VPN_PLUGIN_IP6_CONFIG_ADDRESS, val);
else
- helper_failed (connection, "IP6 Address");
+ helper_failed (proxy, "IP6 Address");
}
/* IPv6 remote address */
tmp = getenv ("ifconfig_ipv6_remote");
if (tmp && strlen (tmp)) {
- val = addr6_to_gvalue (tmp);
+ val = addr6_to_gvariant (tmp);
if (val)
- g_hash_table_insert (ip6config, NM_VPN_PLUGIN_IP6_CONFIG_PTP, val);
+ g_variant_builder_add (&ip6builder, "{sv}", NM_VPN_PLUGIN_IP6_CONFIG_PTP, val);
else
- helper_failed (connection, "IP6 PTP Address");
+ helper_failed (proxy, "IP6 PTP Address");
}
/* IPv6 netbits */
@@ -719,17 +624,20 @@ main (int argc, char *argv[])
if (errno || netbits < 0 || netbits > 128) {
g_warning ("Ignoring invalid prefix '%s'", tmp);
} else {
- val = uint_to_gvalue ((guint32) netbits);
- g_hash_table_insert (ip6config, NM_VPN_PLUGIN_IP6_CONFIG_PREFIX, val);
+ val = g_variant_new_uint32 ((guint32) netbits);
+ g_variant_builder_add (&ip6builder, "{sv}", NM_VPN_PLUGIN_IP6_CONFIG_PREFIX, val);
}
}
val = get_ip6_routes ();
if (val)
- g_hash_table_insert (ip6config, NM_VPN_PLUGIN_IP6_CONFIG_ROUTES, val);
+ g_variant_builder_add (&ip6builder, "{sv}", NM_VPN_PLUGIN_IP6_CONFIG_ROUTES, val);
/* DNS and WINS servers */
dns_domains = g_ptr_array_sized_new (3);
+ dns_list = g_ptr_array_new ();
+ nbns_list = g_ptr_array_new ();
+
for (i = 1; i < 256; i++) {
char *env_name;
@@ -746,24 +654,31 @@ main (int argc, char *argv[])
tmp += 12; /* strlen ("dhcp-option ") */
if (g_str_has_prefix (tmp, "DNS "))
- dns_list = parse_addr4_list (dns_list, tmp + 4);
+ parse_addr4_list (dns_list, tmp + 4);
else if (g_str_has_prefix (tmp, "WINS "))
- nbns_list = parse_addr4_list (nbns_list, tmp + 5);
+ parse_addr4_list (nbns_list, tmp + 5);
else if (g_str_has_prefix (tmp, "DOMAIN ") && is_domain_valid (tmp + 7))
g_ptr_array_add (dns_domains, tmp + 7);
}
- if (dns_list)
- g_hash_table_insert (ip4config, NM_VPN_PLUGIN_IP4_CONFIG_DNS, dns_list);
- if (nbns_list)
- g_hash_table_insert (ip4config, NM_VPN_PLUGIN_IP4_CONFIG_NBNS, nbns_list);
+ if (dns_list->len) {
+ val = g_variant_new_array (G_VARIANT_TYPE_UINT32, (GVariant **) dns_list->pdata,
dns_list->len);
+ g_variant_builder_add (&ip4builder, "{sv}", NM_VPN_PLUGIN_IP4_CONFIG_DNS, val);
+ }
+
+ if (nbns_list->len) {
+ val = g_variant_new_array (G_VARIANT_TYPE_UINT32, (GVariant **) nbns_list->pdata,
nbns_list->len);
+ g_variant_builder_add (&ip4builder, "{sv}", NM_VPN_PLUGIN_IP4_CONFIG_NBNS, val);
+ }
+
if (dns_domains->len) {
- val = g_slice_new0 (GValue);
- g_value_init (val, DBUS_TYPE_G_PTR_ARRAY_OF_STRING);
- g_value_take_boxed (val, dns_domains);
- g_hash_table_insert (ip4config, NM_VPN_PLUGIN_IP4_CONFIG_DOMAINS, val);
- } else
- g_ptr_array_free (dns_domains, TRUE);
+ val = g_variant_new_strv ((const gchar **) dns_domains->pdata, dns_domains->len);
+ g_variant_builder_add (&ip4builder, "{sv}", NM_VPN_PLUGIN_IP4_CONFIG_DOMAINS, val);
+ }
+
+ g_ptr_array_unref (dns_list);
+ g_ptr_array_unref (nbns_list);
+ g_ptr_array_unref (dns_domains);
/* Tunnel MTU */
tmp = getenv ("tun_mtu");
@@ -775,29 +690,35 @@ main (int argc, char *argv[])
if (errno || mtu < 0 || mtu > 20000) {
g_warning ("Ignoring invalid tunnel MTU '%s'", tmp);
} else {
- val = uint_to_gvalue ((guint32) mtu);
- g_hash_table_insert (config, NM_VPN_PLUGIN_CONFIG_MTU, val);
+ val = g_variant_new_uint32 ((guint32) mtu);
+ g_variant_builder_add (&builder, "{sv}", NM_VPN_PLUGIN_CONFIG_MTU, val);
}
}
- if (g_hash_table_size (ip4config)) {
- g_hash_table_insert (config, NM_VPN_PLUGIN_CONFIG_HAS_IP4,
- bool_to_gvalue (TRUE));
+ ip4config = g_variant_builder_end (&ip4builder);
+
+ if (g_variant_n_children (ip4config)) {
+ val = g_variant_new_boolean (TRUE);
+ g_variant_builder_add (&builder, "{sv}", NM_VPN_PLUGIN_CONFIG_HAS_IP4, val);
} else {
- g_hash_table_destroy (ip4config);
+ g_variant_unref (ip4config);
ip4config = NULL;
}
- if (g_hash_table_size (ip6config)) {
- g_hash_table_insert (config, NM_VPN_PLUGIN_CONFIG_HAS_IP6,
- bool_to_gvalue (TRUE));
+ ip6config = g_variant_builder_end (&ip6builder);
+
+ if (g_variant_n_children (ip6config)) {
+ val = g_variant_new_boolean (TRUE);
+ g_variant_builder_add (&builder, "{sv}", NM_VPN_PLUGIN_CONFIG_HAS_IP6, val);
} else {
- g_hash_table_destroy (ip6config);
+ g_variant_unref (ip6config);
ip6config = NULL;
}
/* Send the config info to nm-openvpn-service */
- send_config (connection, config, ip4config, ip6config);
+ send_config (proxy, g_variant_builder_end (&builder), ip4config, ip6config);
+
+ g_object_unref (proxy);
return 0;
}
diff --git a/src/nm-openvpn-service.c b/src/nm-openvpn-service.c
index f732f8d..aad65f8 100644
--- a/src/nm-openvpn-service.c
+++ b/src/nm-openvpn-service.c
@@ -28,9 +28,6 @@
#endif
#include <glib/gi18n.h>
-#include <dbus/dbus.h>
-#include <dbus/dbus-glib-lowlevel.h>
-#include <dbus/dbus-glib.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@@ -51,7 +48,7 @@
#include <grp.h>
#include <NetworkManager.h>
-#include <NetworkManagerVPN.h>
+#include <nm-vpn-service-plugin.h>
#include <nm-setting-vpn.h>
#include "nm-openvpn-service.h"
@@ -68,7 +65,7 @@ static GMainLoop *loop = NULL;
#define NM_OPENVPN_HELPER_PATH LIBEXECDIR"/nm-openvpn-service-openvpn-helper"
-G_DEFINE_TYPE (NMOpenvpnPlugin, nm_openvpn_plugin, NM_TYPE_VPN_PLUGIN)
+G_DEFINE_TYPE (NMOpenvpnPlugin, nm_openvpn_plugin, NM_TYPE_VPN_SERVICE_PLUGIN)
#define NM_OPENVPN_PLUGIN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_OPENVPN_PLUGIN,
NMOpenvpnPluginPrivate))
@@ -251,7 +248,7 @@ validate_one_property (const char *key, const char *value, gpointer user_data)
}
static gboolean
-nm_openvpn_properties_validate (NMSettingVPN *s_vpn, GError **error)
+nm_openvpn_properties_validate (NMSettingVpn *s_vpn, GError **error)
{
GError *validate_error = NULL;
ValidateInfo info = { &valid_properties[0], &validate_error, FALSE };
@@ -273,7 +270,7 @@ nm_openvpn_properties_validate (NMSettingVPN *s_vpn, GError **error)
}
static gboolean
-nm_openvpn_secrets_validate (NMSettingVPN *s_vpn, GError **error)
+nm_openvpn_secrets_validate (NMSettingVpn *s_vpn, GError **error)
{
GError *validate_error = NULL;
ValidateInfo info = { &valid_secrets[0], &validate_error, FALSE };
@@ -487,10 +484,10 @@ handle_auth (NMOpenvpnPluginIOData *io_data,
}
static gboolean
-handle_management_socket (NMVPNPlugin *plugin,
+handle_management_socket (NMVpnServicePlugin *plugin,
GIOChannel *source,
GIOCondition condition,
- NMVPNPluginFailure *out_failure)
+ NMVpnPluginFailure *out_failure)
{
NMOpenvpnPluginPrivate *priv = NM_OPENVPN_PLUGIN_GET_PRIVATE (plugin);
gboolean again = TRUE;
@@ -529,7 +526,7 @@ handle_management_socket (NMVPNPlugin *plugin,
g_message ("Requesting new secrets: '%s' (%s)", message,
joined);
g_free (joined);
}
- nm_vpn_plugin_secrets_required (plugin, message, (const char **)
hints);
+ nm_vpn_service_plugin_secrets_required (plugin, message, (const char
**) hints);
} else {
/* Interactive not allowed, can't ask for more secrets */
g_warning ("More secrets required but cannot ask interactively");
@@ -583,12 +580,12 @@ out:
static gboolean
nm_openvpn_socket_data_cb (GIOChannel *source, GIOCondition condition, gpointer user_data)
{
- NMVPNPlugin *plugin = NM_VPN_PLUGIN (user_data);
- NMVPNPluginFailure failure = NM_VPN_PLUGIN_FAILURE_CONNECT_FAILED;
+ NMVpnServicePlugin *plugin = NM_VPN_SERVICE_PLUGIN (user_data);
+ NMVpnPluginFailure failure = NM_VPN_PLUGIN_FAILURE_CONNECT_FAILED;
if (!handle_management_socket (plugin, source, condition, &failure)) {
- nm_vpn_plugin_failure (plugin, failure);
- nm_vpn_plugin_set_state (plugin, NM_VPN_SERVICE_STATE_STOPPED);
+ nm_vpn_service_plugin_failure (plugin, failure);
+ nm_vpn_service_plugin_set_state (plugin, NM_VPN_SERVICE_STATE_STOPPED);
return FALSE;
}
@@ -610,8 +607,8 @@ nm_openvpn_connect_timer_cb (gpointer data)
fd = socket (AF_UNIX, SOCK_STREAM, 0);
if (fd < 0) {
g_warning ("Could not create management socket");
- nm_vpn_plugin_failure (NM_VPN_PLUGIN (plugin), NM_VPN_PLUGIN_FAILURE_CONNECT_FAILED);
- nm_vpn_plugin_set_state (NM_VPN_PLUGIN (plugin), NM_VPN_SERVICE_STATE_STOPPED);
+ nm_vpn_service_plugin_failure (NM_VPN_SERVICE_PLUGIN (plugin),
NM_VPN_PLUGIN_FAILURE_CONNECT_FAILED);
+ nm_vpn_service_plugin_set_state (NM_VPN_SERVICE_PLUGIN (plugin),
NM_VPN_SERVICE_STATE_STOPPED);
goto out;
}
@@ -625,8 +622,8 @@ nm_openvpn_connect_timer_cb (gpointer data)
priv->connect_timer = 0;
g_warning ("Could not open management socket");
- nm_vpn_plugin_failure (NM_VPN_PLUGIN (plugin), NM_VPN_PLUGIN_FAILURE_CONNECT_FAILED);
- nm_vpn_plugin_set_state (NM_VPN_PLUGIN (plugin), NM_VPN_SERVICE_STATE_STOPPED);
+ nm_vpn_service_plugin_failure (NM_VPN_SERVICE_PLUGIN (plugin),
NM_VPN_PLUGIN_FAILURE_CONNECT_FAILED);
+ nm_vpn_service_plugin_set_state (NM_VPN_SERVICE_PLUGIN (plugin),
NM_VPN_SERVICE_STATE_STOPPED);
} else {
io_data->socket_channel = g_io_channel_unix_new (fd);
g_io_channel_set_encoding (io_data->socket_channel, NULL, NULL);
@@ -653,9 +650,9 @@ nm_openvpn_schedule_connect_timer (NMOpenvpnPlugin *plugin)
static void
openvpn_watch_cb (GPid pid, gint status, gpointer user_data)
{
- NMVPNPlugin *plugin = NM_VPN_PLUGIN (user_data);
+ NMVpnServicePlugin *plugin = NM_VPN_SERVICE_PLUGIN (user_data);
NMOpenvpnPluginPrivate *priv = NM_OPENVPN_PLUGIN_GET_PRIVATE (plugin);
- NMVPNPluginFailure failure = NM_VPN_PLUGIN_FAILURE_CONNECT_FAILED;
+ NMVpnPluginFailure failure = NM_VPN_PLUGIN_FAILURE_CONNECT_FAILED;
guint error = 0;
gboolean good_exit = FALSE;
@@ -699,9 +696,9 @@ openvpn_watch_cb (GPid pid, gint status, gpointer user_data)
}
if (!good_exit)
- nm_vpn_plugin_failure (plugin, failure);
+ nm_vpn_service_plugin_failure (plugin, failure);
- nm_vpn_plugin_set_state (plugin, NM_VPN_SERVICE_STATE_STOPPED);
+ nm_vpn_service_plugin_set_state (plugin, NM_VPN_SERVICE_STATE_STOPPED);
}
static gboolean
@@ -799,7 +796,7 @@ add_openvpn_arg_int (GPtrArray *args, const char *arg)
}
static void
-add_cert_args (GPtrArray *args, NMSettingVPN *s_vpn)
+add_cert_args (GPtrArray *args, NMSettingVpn *s_vpn)
{
const char *ca, *cert, *key;
@@ -837,7 +834,7 @@ add_cert_args (GPtrArray *args, NMSettingVPN *s_vpn)
static void
update_io_data_from_vpn_setting (NMOpenvpnPluginIOData *io_data,
- NMSettingVPN *s_vpn,
+ NMSettingVpn *s_vpn,
const char *default_username)
{
const char *tmp;
@@ -936,7 +933,7 @@ check_chroot_dir_usability (const char *chdir, const char *user)
static gboolean
nm_openvpn_start_openvpn_binary (NMOpenvpnPlugin *plugin,
- NMSettingVPN *s_vpn,
+ NMSettingVpn *s_vpn,
const char *default_username,
const char *uuid,
GError **error)
@@ -1485,7 +1482,7 @@ nm_openvpn_start_openvpn_binary (NMOpenvpnPlugin *plugin,
}
static const char *
-check_need_secrets (NMSettingVPN *s_vpn, gboolean *need_secrets)
+check_need_secrets (NMSettingVpn *s_vpn, gboolean *need_secrets)
{
const char *tmp, *key, *ctype;
NMSettingSecretFlags secret_flags = NM_SETTING_SECRET_FLAG_NONE;
@@ -1540,12 +1537,12 @@ check_need_secrets (NMSettingVPN *s_vpn, gboolean *need_secrets)
}
static gboolean
-_connect_common (NMVPNPlugin *plugin,
+_connect_common (NMVpnServicePlugin *plugin,
NMConnection *connection,
- GHashTable *details,
+ GVariant *details,
GError **error)
{
- NMSettingVPN *s_vpn;
+ NMSettingVpn *s_vpn;
const char *connection_type;
const char *user_name;
@@ -1553,7 +1550,7 @@ _connect_common (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;
}
@@ -1562,7 +1559,7 @@ _connect_common (NMVPNPlugin *plugin,
if (!validate_connection_type (connection_type)) {
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 openvpn connection type was
invalid."));
return FALSE;
}
@@ -1588,7 +1585,7 @@ _connect_common (NMVPNPlugin *plugin,
}
static gboolean
-real_connect (NMVPNPlugin *plugin,
+real_connect (NMVpnServicePlugin *plugin,
NMConnection *connection,
GError **error)
{
@@ -1596,9 +1593,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 (!_connect_common (plugin, connection, details, error))
@@ -1609,16 +1606,16 @@ real_connect_interactive (NMVPNPlugin *plugin,
}
static gboolean
-real_need_secrets (NMVPNPlugin *plugin,
+real_need_secrets (NMVpnServicePlugin *plugin,
NMConnection *connection,
- char **setting_name,
+ const char **setting_name,
GError **error)
{
- NMSettingVPN *s_vpn;
+ NMSettingVpn *s_vpn;
const char *connection_type;
gboolean need_secrets = FALSE;
- 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);
if (debug) {
@@ -1630,7 +1627,7 @@ real_need_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;
}
@@ -1651,12 +1648,12 @@ real_need_secrets (NMVPNPlugin *plugin,
}
static gboolean
-real_new_secrets (NMVPNPlugin *plugin,
+real_new_secrets (NMVpnServicePlugin *plugin,
NMConnection *connection,
GError **error)
{
NMOpenvpnPluginPrivate *priv = NM_OPENVPN_PLUGIN_GET_PRIVATE (plugin);
- NMSettingVPN *s_vpn;
+ NMSettingVpn *s_vpn;
const char *message = NULL;
char **hints = NULL;
@@ -1664,7 +1661,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;
}
@@ -1678,7 +1675,7 @@ real_new_secrets (NMVPNPlugin *plugin,
if (!handle_auth (priv->io_data, priv->io_data->pending_auth, &message, &hints)) {
g_set_error_literal (error,
NM_VPN_PLUGIN_ERROR,
- NM_VPN_PLUGIN_ERROR_GENERAL,
+ NM_VPN_PLUGIN_ERROR_FAILED,
_("Unhandled pending authentication."));
return FALSE;
}
@@ -1687,7 +1684,7 @@ real_new_secrets (NMVPNPlugin *plugin,
if (message) {
if (debug)
g_message ("Requesting new secrets: '%s'", message);
- nm_vpn_plugin_secrets_required (plugin, message, (const char **) hints);
+ nm_vpn_service_plugin_secrets_required (plugin, message, (const char **) hints);
}
if (hints)
g_free (hints); /* elements are 'const' */
@@ -1706,7 +1703,7 @@ ensure_killed (gpointer data)
}
static gboolean
-real_disconnect (NMVPNPlugin *plugin,
+real_disconnect (NMVpnServicePlugin *plugin,
GError **err)
{
NMOpenvpnPluginPrivate *priv = NM_OPENVPN_PLUGIN_GET_PRIVATE (plugin);
@@ -1736,7 +1733,7 @@ static void
nm_openvpn_plugin_class_init (NMOpenvpnPluginClass *plugin_class)
{
GObjectClass *object_class = G_OBJECT_CLASS (plugin_class);
- NMVPNPluginClass *parent_class = NM_VPN_PLUGIN_CLASS (plugin_class);
+ NMVpnServicePluginClass *parent_class = NM_VPN_SERVICE_PLUGIN_CLASS (plugin_class);
g_type_class_add_private (object_class, sizeof (NMOpenvpnPluginPrivate));
@@ -1750,7 +1747,7 @@ nm_openvpn_plugin_class_init (NMOpenvpnPluginClass *plugin_class)
static void
plugin_state_changed (NMOpenvpnPlugin *plugin,
- NMVPNServiceState state,
+ NMVpnServiceState state,
gpointer user_data)
{
NMOpenvpnPluginPrivate *priv = NM_OPENVPN_PLUGIN_GET_PRIVATE (plugin);
@@ -1777,13 +1774,19 @@ NMOpenvpnPlugin *
nm_openvpn_plugin_new (void)
{
NMOpenvpnPlugin *plugin;
+ GError *error = NULL;
- plugin = (NMOpenvpnPlugin *) g_object_new (NM_TYPE_OPENVPN_PLUGIN,
- NM_VPN_PLUGIN_DBUS_SERVICE_NAME,
- NM_DBUS_SERVICE_OPENVPN,
- NULL);
- if (plugin)
+ plugin = (NMOpenvpnPlugin *) g_initable_new (NM_TYPE_OPENVPN_PLUGIN, NULL, &error,
+ NM_VPN_SERVICE_PLUGIN_DBUS_SERVICE_NAME,
+ NM_DBUS_SERVICE_OPENVPN,
+ NULL);
+
+ if (plugin) {
g_signal_connect (G_OBJECT (plugin), "state-changed", G_CALLBACK (plugin_state_changed),
NULL);
+ } else {
+ g_warning ("Failed to initialize a plugin instance: %s", error->message);
+ g_error_free (error);
+ }
return plugin;
}
@@ -1810,7 +1813,7 @@ setup_signals (void)
}
static void
-quit_mainloop (NMVPNPlugin *plugin, gpointer user_data)
+quit_mainloop (NMVpnServicePlugin *plugin, gpointer user_data)
{
g_main_loop_quit ((GMainLoop *) user_data);
}
diff --git a/src/nm-openvpn-service.h b/src/nm-openvpn-service.h
index d4b5710..5c3b0a4 100644
--- a/src/nm-openvpn-service.h
+++ b/src/nm-openvpn-service.h
@@ -25,7 +25,7 @@
#include <glib.h>
#include <glib-object.h>
-#include <nm-vpn-plugin.h>
+#include <nm-vpn-service-plugin.h>
#include "nm-openvpn-service-defines.h"
@@ -37,11 +37,11 @@
#define NM_OPENVPN_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_OPENVPN_PLUGIN,
NMOpenvpnPluginClass))
typedef struct {
- NMVPNPlugin parent;
+ NMVpnServicePlugin parent;
} NMOpenvpnPlugin;
typedef struct {
- NMVPNPluginClass parent;
+ NMVpnServicePluginClass parent;
} NMOpenvpnPluginClass;
GType nm_openvpn_plugin_get_type (void);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]