[network-manager-openconnect/lr/multiple-vpn: 3/4] service: add --bus-name argument



commit 188a96fa4472227d8ccb4d6d36bb59ef059bed43
Author: Lubomir Rintel <lkundrak v3 sk>
Date:   Tue Oct 13 19:19:57 2015 +0200

    service: add --bus-name argument
    
    Make it possible to specify a different bus name to acquire.

 nm-openconnect-service.name.in       |    1 +
 src/nm-openconnect-service-defines.h |    2 +-
 src/nm-openconnect-service.c         |   12 ++++++++----
 src/nm-openconnect-service.h         |    2 +-
 4 files changed, 11 insertions(+), 6 deletions(-)
---
diff --git a/nm-openconnect-service.name.in b/nm-openconnect-service.name.in
index 943b1ec..78d8535 100644
--- a/nm-openconnect-service.name.in
+++ b/nm-openconnect-service.name.in
@@ -2,6 +2,7 @@
 name=openconnect
 service=org.freedesktop.NetworkManager.openconnect
 program= LIBEXECDIR@/nm-openconnect-service
+supports-multiple-connections=true
 
 [libnm]
 plugin= PLUGINDIR@/libnm-vpn-plugin-openconnect.so
diff --git a/src/nm-openconnect-service-defines.h b/src/nm-openconnect-service-defines.h
index 9366edc..8bc2626 100644
--- a/src/nm-openconnect-service-defines.h
+++ b/src/nm-openconnect-service-defines.h
@@ -25,7 +25,7 @@
 #ifndef NM_OPENCONNECT_SERVICE_DEFINES_H
 #define NM_OPENCONNECT_SERVICE_DEFINES_H
 
-#define NM_VPN_SERVICE_TYPE_OPENCONNECT    "org.freedesktop.NetworkManager.openconnect"
+#define NM_VPN_SERVICE_TYPE_OPENCONNECT "org.freedesktop.NetworkManager.openconnect"
 
 #define NM_DBUS_SERVICE_OPENCONNECT    "org.freedesktop.NetworkManager.openconnect"
 #define NM_DBUS_INTERFACE_OPENCONNECT  "org.freedesktop.NetworkManager.openconnect"
diff --git a/src/nm-openconnect-service.c b/src/nm-openconnect-service.c
index b1fe8a8..83222c2 100644
--- a/src/nm-openconnect-service.c
+++ b/src/nm-openconnect-service.c
@@ -593,13 +593,13 @@ nm_openconnect_plugin_class_init (NMOpenconnectPluginClass *openconnect_class)
 }
 
 NMOpenconnectPlugin *
-nm_openconnect_plugin_new (void)
+nm_openconnect_plugin_new (const char *bus_name)
 {
        NMOpenconnectPlugin *plugin;
        GError *error = NULL;
 
        plugin = (NMOpenconnectPlugin *) g_initable_new (NM_TYPE_OPENCONNECT_PLUGIN, NULL, &error,
-                                                        NM_VPN_SERVICE_PLUGIN_DBUS_SERVICE_NAME, 
NM_VPN_SERVICE_TYPE_OPENCONNECT,
+                                                        NM_VPN_SERVICE_PLUGIN_DBUS_SERVICE_NAME, bus_name,
                                                         NULL);
        if (!plugin) {
                g_warning ("Failed to initialize a plugin instance: %s", error->message);
@@ -639,13 +639,14 @@ quit_mainloop (NMOpenconnectPlugin *plugin, gpointer user_data)
 int main (int argc, char *argv[])
 {
        NMOpenconnectPlugin *plugin;
-
        gboolean persist = FALSE;
        GOptionContext *opt_ctx = NULL;
+       gchar *bus_name = NM_DBUS_SERVICE_OPENCONNECT;
 
        GOptionEntry options[] = {
                { "persist", 0, 0, G_OPTION_ARG_NONE, &persist, N_("Don't quit when VPN connection 
terminates"), NULL },
                { "debug", 0, 0, G_OPTION_ARG_NONE, &debug, N_("Enable verbose debug logging (may expose 
passwords)"), NULL },
+               { "bus-name", 0, 0, G_OPTION_ARG_STRING, &bus_name, N_("DBus name to use for this instance"), 
NULL },
                {NULL}
        };
 
@@ -683,7 +684,10 @@ int main (int argc, char *argv[])
        if (system ("/sbin/modprobe tun") == -1)
                exit (EXIT_FAILURE);
 
-       plugin = nm_openconnect_plugin_new ();
+       if (bus_name)
+               setenv ("NM_DBUS_SERVICE_OPENCONNECT", bus_name, 0);
+
+       plugin = nm_openconnect_plugin_new (bus_name);
        if (!plugin)
                exit (EXIT_FAILURE);
 
diff --git a/src/nm-openconnect-service.h b/src/nm-openconnect-service.h
index 5305af7..81a3e96 100644
--- a/src/nm-openconnect-service.h
+++ b/src/nm-openconnect-service.h
@@ -48,7 +48,7 @@ typedef struct {
 
 GType nm_openconnect_plugin_get_type (void);
 
-NMOpenconnectPlugin *nm_openconnect_plugin_new (void);
+NMOpenconnectPlugin *nm_openconnect_plugin_new (const char *bus_name);
 
 #define NM_OPENCONNECT_USER "nm-openconnect"
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]