[network-manager-openconnect] Use new openconnect_{get, free}_supported_protocols in API version 5.5, instead of static list
- From: dwmw2 <dwmw2 src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-openconnect] Use new openconnect_{get, free}_supported_protocols in API version 5.5, instead of static list
- Date: Sun, 14 May 2017 23:23:30 +0000 (UTC)
commit 1ed6de801a398887277fbb9c35d9f5f5d6c4d5c3
Author: Daniel Lenski <daniel lenski finalphasesystems com>
Date: Sat Apr 8 18:42:27 2017 -0700
Use new openconnect_{get,free}_supported_protocols in API version 5.5, instead of static list
auth-dialog/main.c | 8 ++++----
properties/nm-openconnect-dialog.ui | 6 ------
properties/nm-openconnect-editor-plugin.c | 21 ++++++++++++++++++---
properties/nm-openconnect-editor.c | 25 +++++++++++++++++++++----
4 files changed, 43 insertions(+), 17 deletions(-)
---
diff --git a/auth-dialog/main.c b/auth-dialog/main.c
index 508c8f3..28929c7 100644
--- a/auth-dialog/main.c
+++ b/auth-dialog/main.c
@@ -1073,12 +1073,12 @@ static int get_config (auth_ui_data *ui_data,
}
protocol = g_hash_table_lookup (options, NM_OPENCONNECT_KEY_PROTOCOL);
- if (protocol && strcmp(protocol, "anyconnect")) {
#if OPENCONNECT_CHECK_VER(5,1)
- if (openconnect_set_protocol(vpninfo, protocol))
+ if (openconnect_set_protocol(vpninfo, protocol))
+#else
+ if (protocol && strcmp(protocol, "anyconnect"))
#endif
- return -EINVAL;
- }
+ return -EINVAL;
cafile = g_hash_table_lookup (options, NM_OPENCONNECT_KEY_CACERT);
if (cafile)
diff --git a/properties/nm-openconnect-dialog.ui b/properties/nm-openconnect-dialog.ui
index 8f2bb60..dc51f46 100644
--- a/properties/nm-openconnect-dialog.ui
+++ b/properties/nm-openconnect-dialog.ui
@@ -872,11 +872,5 @@
<!-- column-name protocol_value -->
<column type="gchararray"/>
</columns>
- <data>
- <row>
- <col id="0" translatable="yes">Cisco AnyConnect</col>
- <col id="1" translatable="no">anyconnect</col>
- </row>
- </data>
</object>
</interface>
diff --git a/properties/nm-openconnect-editor-plugin.c b/properties/nm-openconnect-editor-plugin.c
index 9137d46..52b9ee7 100644
--- a/properties/nm-openconnect-editor-plugin.c
+++ b/properties/nm-openconnect-editor-plugin.c
@@ -360,15 +360,29 @@ notify_plugin_info_set (NMVpnEditorPlugin *plugin,
NMVpnPluginInfo *plugin_info)
{
OpenconnectEditorPluginPrivate *priv = OPENCONNECT_EDITOR_PLUGIN_GET_PRIVATE (plugin);
- const char *supported_protocols;
guint i, j;
if (!plugin_info)
return;
- supported_protocols = nm_vpn_plugin_info_lookup_property (plugin_info, "openconnect",
"supported-protocols");
-
g_strfreev (priv->supported_protocols);
+
+#if OPENCONNECT_CHECK_VER(5,5)
+ struct oc_vpn_proto *protos, *p;
+
+ if ((i = openconnect_get_supported_protocols(&protos)) < 0)
+ priv->supported_protocols = g_new0(gchar *, 1);
+ else {
+ priv->supported_protocols = g_new0(gchar *, i+1);
+ for (i=0, p=protos; p && p->name; p++) {
+ priv->supported_protocols[i] = g_strdup(p->name);
+ }
+ openconnect_free_supported_protocols(protos);
+ }
+
+#else
+ const char *supported_protocols = nm_vpn_plugin_info_lookup_property (plugin_info, "openconnect",
"supported-protocols");
+
priv->supported_protocols = supported_protocols
? g_strsplit_set (supported_protocols, ",", -1)
: g_new0 (char *, 1);
@@ -382,6 +396,7 @@ notify_plugin_info_set (NMVpnEditorPlugin *plugin,
priv->supported_protocols[i++] = priv->supported_protocols[j];
}
priv->supported_protocols[i] = NULL;
+#endif
}
static char **
diff --git a/properties/nm-openconnect-editor.c b/properties/nm-openconnect-editor.c
index fba9fd9..b4ad947 100644
--- a/properties/nm-openconnect-editor.c
+++ b/properties/nm-openconnect-editor.c
@@ -217,19 +217,36 @@ init_token_ui (OpenconnectEditor *self,
static gboolean
init_protocol_combo_options (GtkComboBox *protocol_combo)
{
-#if OPENCONNECT_CHECK_VER(5,1)
GtkListStore *protocol_combo_list = GTK_LIST_STORE (gtk_combo_box_get_model (protocol_combo));
GtkTreeIter iter;
+#if OPENCONNECT_CHECK_VER(5,5)
+ struct oc_vpn_proto *protos, *p;
+ openconnect_get_supported_protocols(&protos);
+ for (p=protos; p && p->name; p++) {
+ gtk_list_store_append(protocol_combo_list, &iter);
+ gtk_list_store_set(protocol_combo_list, &iter,
+ 0, p->pretty_name,
+ 1, p->name,
+ -1);
+ }
+ openconnect_free_supported_protocols(protos);
+#else
+ gtk_list_store_append(protocol_combo_list, &iter);
+ gtk_list_store_set(protocol_combo_list, &iter,
+ 0, _("Cisco AnyConnect"),
+ 1, "anyconnect",
+ -1);
+# if OPENCONNECT_CHECK_VER(5,1)
gtk_list_store_append(protocol_combo_list, &iter);
gtk_list_store_set(protocol_combo_list, &iter,
0, _("Juniper/Pulse Network Connect"),
1, "nc",
-1);
- return TRUE;
-#else
- return FALSE;
+# endif
#endif
+
+ return OPENCONNECT_CHECK_VER(5,1);
}
static gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]