[network-manager-libreswan/th/vpn-service-info-bgo767197: 1/2] properties: implement "get-service-info" call



commit 7baed5c3913c62460455415114a82bb8f0e85b04
Author: Thomas Haller <thaller redhat com>
Date:   Tue Jun 7 14:52:25 2016 +0200

    properties: implement "get-service-info" call

 properties/nm-libreswan-editor-plugin.c |   55 +++++++++++++++++++++++++++++++
 1 files changed, 55 insertions(+), 0 deletions(-)
---
diff --git a/properties/nm-libreswan-editor-plugin.c b/properties/nm-libreswan-editor-plugin.c
index ff8cabe..d59bfea 100644
--- a/properties/nm-libreswan-editor-plugin.c
+++ b/properties/nm-libreswan-editor-plugin.c
@@ -117,6 +117,57 @@ get_capabilities (NMVpnEditorPlugin *iface)
 }
 
 #ifndef NM_VPN_OLD
+static gboolean
+call_get_signature (NMVpnEditorPlugin *plugin,
+                    const char *request,
+                    gboolean *free_types,
+                    GType **types_in,
+                    GType **types_out)
+{
+       if (nm_streq (request, NM_VPN_EDITOR_PLUGIN_CALL_GET_SERVICE_INFO)) {
+               static GType t_in[] = { G_TYPE_STRING, 0 };
+               static GType t_out[] = { G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT, 0 };
+
+               *types_in = t_in;
+               *types_out = t_out;
+               return TRUE;
+       }
+       return FALSE;
+}
+
+static gboolean
+call (NMVpnEditorPlugin *plugin,
+      const char *request,
+      GError **error,
+      const GValue *const*args_in,
+      GValue *const*args_out)
+{
+       const char *service_type;
+
+       if (nm_streq (request, NM_VPN_EDITOR_PLUGIN_CALL_GET_SERVICE_INFO)) {
+               service_type = g_value_get_string (args_in[0]);
+
+               if (nm_streq (service_type, NM_VPN_SERVICE_TYPE_LIBRESWAN)) {
+                       g_value_set_string (args_out[0], "libreswan");
+                       g_value_set_string (args_out[1], LIBRESWAN_PLUGIN_NAME);
+                       g_value_set_string (args_out[2], LIBRESWAN_PLUGIN_DESC);
+                       g_value_set_uint (args_out[3], NM_VPN_EDITOR_PLUGIN_SERVICE_FLAGS_CAN_ADD);
+                       return TRUE;
+               } else if (nm_streq (service_type, NM_VPN_SERVICE_TYPE_OPENSWAN)) {
+                       g_value_set_string (args_out[0], "openswan");
+                       g_value_set_string (args_out[1], _("IPSec based VPN (openswan)"));
+                       g_value_set_string (args_out[2], _("IPsec based VPN using IKEv1 (openswan)"));
+                       g_value_set_uint (args_out[3], NM_VPN_EDITOR_PLUGIN_SERVICE_FLAGS_NONE);
+                       return TRUE;
+               }
+               g_set_error (error, NM_VPN_PLUGIN_ERROR, NM_VPN_PLUGIN_ERROR_CALL_INVALID_ARGUMENT,
+                            _("Unknown service-type '%s'"), service_type);
+       }
+       return FALSE;
+}
+#endif
+
+#ifndef NM_VPN_OLD
 static NMVpnEditor *
 _call_editor_factory (gpointer factory,
                       NMVpnEditorPlugin *editor_plugin,
@@ -206,6 +257,10 @@ libreswan_editor_plugin_interface_init (NMVpnEditorPluginInterface *iface_class)
 
        iface_class->import_from_file = import_from_file;
        iface_class->export_to_file = export_to_file;
+#ifndef NM_VPN_OLD
+       iface_class->call_get_signature = call_get_signature;
+       iface_class->call = call;
+#endif
 
        iface_class->get_suggested_filename = NULL;
 }


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