[network-manager-vpnc/lr/libnm] fixup! service: port to libnm
- From: Lubomir Rintel <lkundrak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-vpnc/lr/libnm] fixup! service: port to libnm
- Date: Sun, 16 Aug 2015 13:46:44 +0000 (UTC)
commit 152dbc40dc49602f43002e9e3fdb102c4109ac86
Author: Lubomir Rintel <lkundrak v3 sk>
Date: Sun Aug 16 14:59:04 2015 +0200
fixup! service: port to libnm
port to gdbus
UNTESTED!
configure.ac | 2 -
properties/tests/test-import-export.c | 5 --
src/Makefile.am | 3 -
src/nm-vpnc-service-vpnc-helper.c | 82 ++++++++++++++-------------------
4 files changed, 35 insertions(+), 57 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index caa767a..d5a85d8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -62,8 +62,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)
-
if test x"$with_gnome" != xno; then
PKG_CHECK_MODULES(GTK, gtk+-3.0 >= 3.4)
GTK_CFLAGS="$GTK_CFLAGS -DGDK_VERSION_MIN_REQUIRED=GDK_VERSION_3_4"
diff --git a/properties/tests/test-import-export.c b/properties/tests/test-import-export.c
index 7c29b2d..350d424 100644
--- a/properties/tests/test-import-export.c
+++ b/properties/tests/test-import-export.c
@@ -20,8 +20,6 @@
*/
#include <string.h>
-#include <dbus/dbus.h>
-#include <dbus/dbus-glib.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <locale.h>
@@ -747,7 +745,6 @@ test_empty_keyfile_string_null (const char *dir)
int main (int argc, char **argv)
{
GError *error = NULL;
- DBusGConnection *bus;
char *basename;
NMVpnEditorPlugin *plugin = NULL;
@@ -758,8 +755,6 @@ int main (int argc, char **argv)
g_type_init ();
#endif
- bus = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
-
plugin = nm_vpn_editor_plugin_factory (&error);
if (error)
FAIL ("plugin-init", "failed to initialize UI plugin: %s", error->message);
diff --git a/src/Makefile.am b/src/Makefile.am
index 9bce180..a544287 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,5 +1,4 @@
AM_CPPFLAGS = \
- $(DBUS_CFLAGS) \
$(GLIB_CFLAGS) \
$(LIBNM_CFLAGS) \
-DG_DISABLE_DEPRECATED \
@@ -23,7 +22,6 @@ nm_vpnc_service_SOURCES = \
utils.h
nm_vpnc_service_LDADD = \
- $(DBUS_LIBS) \
$(GLIB_LIBS) \
$(LIBNM_LIBS)
@@ -32,7 +30,6 @@ nm_vpnc_service_vpnc_helper_SOURCES = \
nm-vpnc-service-vpnc-helper.c
nm_vpnc_service_vpnc_helper_LDADD = \
- $(DBUS_LIBS) \
$(GTHREAD_LIBS) \
$(LIBNM_LIBS)
diff --git a/src/nm-vpnc-service-vpnc-helper.c b/src/nm-vpnc-service-vpnc-helper.c
index 381ae1c..e0dec41 100644
--- a/src/nm-vpnc-service-vpnc-helper.c
+++ b/src/nm-vpnc-service-vpnc-helper.c
@@ -29,71 +29,43 @@
#include <arpa/inet.h>
#include <errno.h>
#include <locale.h>
-#include <dbus/dbus.h>
-#include <dbus/dbus-glib-lowlevel.h>
-#include <dbus/dbus-glib.h>
#include <NetworkManager.h>
#include "nm-vpnc-service.h"
#include "nm-utils.h"
-/* 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))
-
static void
-helper_failed (DBusGConnection *connection, const char *reason)
+helper_failed (GDBusProxy *proxy, const char *reason)
{
- DBusGProxy *proxy;
GError *err = NULL;
g_warning ("nm-nvpnc-service-vpnc-helper did not receive a valid %s from vpnc", reason);
- proxy = dbus_g_proxy_new_for_name (connection,
- NM_DBUS_SERVICE_VPNC,
- 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_string (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_ip4_config (DBusGConnection *connection, GVariant *config)
+send_ip4_config (GDBusProxy *proxy, GVariant *config)
{
-#if 0
- DBusGProxy *proxy;
GError *err = NULL;
- proxy = dbus_g_proxy_new_for_name (connection,
- NM_DBUS_SERVICE_VPNC,
- NM_VPN_DBUS_PLUGIN_PATH,
- NM_VPN_DBUS_PLUGIN_INTERFACE);
-
- dbus_g_proxy_call (proxy, "SetIp4Config", &err,
- dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE),
- config,
- G_TYPE_INVALID,
- G_TYPE_INVALID);
-
- if (err) {
+ if (!g_dbus_proxy_call_sync (proxy, "SetIp4Config",
+ config,
+ G_DBUS_CALL_FLAGS_NONE, -1,
+ NULL,
+ &err)) {
g_warning ("Could not send IPv4 configuration: %s", err->message);
g_error_free (err);
}
-
- g_object_unref (proxy);
-#endif
}
static GVariant *
@@ -271,7 +243,8 @@ get_ip4_routes (void)
int
main (int argc, char *argv[])
{
- DBusGConnection *connection;
+ GDBusConnection *connection;
+ GDBusProxy *proxy;
char *tmp;
GVariantBuilder config;
GVariant *val;
@@ -292,9 +265,22 @@ main (int argc, char *argv[])
if (tmp && strcmp (tmp, "connect") != 0)
exit (0);
- connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &err);
+ connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &err);
if (!connection) {
g_warning ("Could not get the system bus: %s", err->message);
+ g_error_free (err);
+ exit (1);
+ }
+
+ proxy = g_dbus_proxy_new_sync (connection, G_DBUS_CALL_FLAGS_NONE, NULL,
+ NM_DBUS_SERVICE_VPNC,
+ NM_VPN_DBUS_PLUGIN_PATH,
+ NM_VPN_DBUS_PLUGIN_INTERFACE,
+ NULL, &err);
+ g_object_unref (connection);
+ if (!proxy) {
+ g_warning ("Could not create a D-Bus proxy: %s", err->message);
+ g_error_free (err);
exit (1);
}
@@ -305,28 +291,28 @@ main (int argc, char *argv[])
if (val)
g_variant_builder_add (&config, "{sv}", NM_VPN_PLUGIN_IP4_CONFIG_GATEWAY, val);
else
- helper_failed (connection, "VPN Gateway");
+ helper_failed (proxy, "VPN Gateway");
/* Tunnel device */
val = str_to_gvariant (getenv ("TUNDEV"), FALSE);
if (val)
g_variant_builder_add (&config, "{sv}", NM_VPN_PLUGIN_IP4_CONFIG_TUNDEV, val);
else
- helper_failed (connection, "Tunnel Device");
+ helper_failed (proxy, "Tunnel Device");
/* IP address */
val = addr4_to_gvariant (getenv ("INTERNAL_IP4_ADDRESS"));
if (val)
g_variant_builder_add (&config, "{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 */
val = addr4_to_gvariant (getenv ("INTERNAL_IP4_ADDRESS"));
if (val)
g_variant_builder_add (&config, "{sv}", NM_VPN_PLUGIN_IP4_CONFIG_PTP, val);
else
- helper_failed (connection, "IP4 PTP Address");
+ helper_failed (proxy, "IP4 PTP Address");
/* Netmask / Prefix */
tmp = getenv ("INTERNAL_IP4_NETMASKLEN");
@@ -404,7 +390,9 @@ main (int argc, char *argv[])
g_variant_builder_add (&config, "{sv}", NM_VPN_PLUGIN_IP4_CONFIG_MTU, val);
/* Send the config info to nm-vpnc-service */
- send_ip4_config (connection, g_variant_builder_end (&config));
+ send_ip4_config (proxy, g_variant_builder_end (&config));
+
+ g_object_unref (proxy);
exit (0);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]