[gnome-control-center] network: Show VPN type and info in panel
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] network: Show VPN type and info in panel
- Date: Fri, 26 Aug 2011 12:32:38 +0000 (UTC)
commit 382509986aab8ebc701bb37f2ab861f4f54f4448
Author: JiÅÃ KlimeÅ <jklimes redhat com>
Date: Fri Jul 22 13:52:44 2011 +0200
network: Show VPN type and info in panel
For all the VPN types
https://bugzilla.gnome.org/show_bug.cgi?id=657303
panels/network/cc-network-panel.c | 14 ++++--
panels/network/net-vpn.c | 86 +++++++++++++++++++++++++++++++++++--
panels/network/net-vpn.h | 1 +
panels/network/network.ui | 48 +++++++++++++++++---
4 files changed, 133 insertions(+), 16 deletions(-)
---
diff --git a/panels/network/cc-network-panel.c b/panels/network/cc-network-panel.c
index 8277b4c..4474fb5 100644
--- a/panels/network/cc-network-panel.c
+++ b/panels/network/cc-network-panel.c
@@ -1947,29 +1947,35 @@ nm_device_refresh_vpn_ui (CcNetworkPanel *panel, NetVpn *vpn)
state != NM_VPN_CONNECTION_STATE_DISCONNECTED);
priv->updating_device = FALSE;
+ /* service type */
+ panel_set_widget_data (panel,
+ sub_pane,
+ "service_type",
+ net_vpn_get_service_type (vpn));
+
/* gateway */
panel_set_widget_data (panel,
sub_pane,
"gateway",
- net_vpn_get_gateway (vpn));
+ net_vpn_get_gateway (vpn));
/* groupname */
panel_set_widget_data (panel,
sub_pane,
"group_name",
- net_vpn_get_id (vpn));
+ net_vpn_get_id (vpn));
/* username */
panel_set_widget_data (panel,
sub_pane,
"username",
- net_vpn_get_username (vpn));
+ net_vpn_get_username (vpn));
/* password */
panel_set_widget_data (panel,
sub_pane,
"group_password",
- net_vpn_get_password (vpn));
+ net_vpn_get_password (vpn));
}
static gboolean
diff --git a/panels/network/net-vpn.c b/panels/network/net-vpn.c
index 250fb39..5315d38 100644
--- a/panels/network/net-vpn.c
+++ b/panels/network/net-vpn.c
@@ -33,6 +33,7 @@
struct _NetVpnPrivate
{
NMConnection *connection;
+ gchar *service_type;
gboolean valid;
};
@@ -65,7 +66,9 @@ void
net_vpn_set_connection (NetVpn *vpn, NMConnection *connection)
{
NetVpnPrivate *priv = vpn->priv;
+ const gchar *type, *p;
/*
+ * vpnc config exmaple:
* key=IKE DH Group, value=dh2
* key=xauth-password-type, value=ask
* key=ipsec-secret-type, value=save
@@ -89,6 +92,10 @@ net_vpn_set_connection (NetVpn *vpn, NMConnection *connection)
G_CALLBACK (connection_vpn_state_changed_cb),
vpn);
}
+
+ type = nm_setting_vpn_get_service_type (nm_connection_get_setting_vpn (priv->connection));
+ p = strrchr (type, '.');
+ priv->service_type = g_strdup (p ? p + 1 : type);
}
NMConnection *
@@ -97,6 +104,12 @@ net_vpn_get_connection (NetVpn *vpn)
return vpn->priv->connection;
}
+const gchar *
+net_vpn_get_service_type (NetVpn *vpn)
+{
+ return vpn->priv->service_type;
+}
+
NMVPNConnectionState
net_vpn_get_state (NetVpn *vpn)
{
@@ -106,32 +119,96 @@ net_vpn_get_state (NetVpn *vpn)
return nm_vpn_connection_get_vpn_state (NM_VPN_CONNECTION (priv->connection));
}
+/* VPN parameters can be found at:
+ * http://git.gnome.org/browse/network-manager-openvpn/tree/src/nm-openvpn-service.h
+ * http://git.gnome.org/browse/network-manager-vpnc/tree/src/nm-vpnc-service.h
+ * http://git.gnome.org/browse/network-manager-pptp/tree/src/nm-pptp-service.h
+ * http://git.gnome.org/browse/network-manager-openconnect/tree/src/nm-openconnect-service.h
+ * http://git.gnome.org/browse/network-manager-openswan/tree/src/nm-openswan-service.h
+ * See also 'properties' directory in these plugins.
+ */
+static const gchar *
+get_vpn_key_gateway (const char *vpn_type)
+{
+ if (g_strcmp0 (vpn_type, "openvpn") == 0) return "remote";
+ if (g_strcmp0 (vpn_type, "vpnc") == 0) return "IPSec gateway";
+ if (g_strcmp0 (vpn_type, "pptp") == 0) return "gateway";
+ if (g_strcmp0 (vpn_type, "openconnect") == 0) return "gateway";
+ if (g_strcmp0 (vpn_type, "openswan") == 0) return "right";
+ return "";
+}
+
+static const gchar *
+get_vpn_key_group (const char *vpn_type)
+{
+ if (g_strcmp0 (vpn_type, "openvpn") == 0) return "";
+ if (g_strcmp0 (vpn_type, "vpnc") == 0) return "IPSec ID";
+ if (g_strcmp0 (vpn_type, "pptp") == 0) return "";
+ if (g_strcmp0 (vpn_type, "openconnect") == 0) return "";
+ if (g_strcmp0 (vpn_type, "openswan") == 0) return "";
+ return "";
+}
+
+static const gchar *
+get_vpn_key_username (const char *vpn_type)
+{
+ if (g_strcmp0 (vpn_type, "openvpn") == 0) return "username";
+ if (g_strcmp0 (vpn_type, "vpnc") == 0) return "Xauth username";
+ if (g_strcmp0 (vpn_type, "pptp") == 0) return "user";
+ if (g_strcmp0 (vpn_type, "openconnect") == 0) return "username";
+ if (g_strcmp0 (vpn_type, "openswan") == 0) return "leftxauthusername";
+ return "";
+}
+
+static const gchar *
+get_vpn_key_group_password (const char *vpn_type)
+{
+ if (g_strcmp0 (vpn_type, "openvpn") == 0) return "";
+ if (g_strcmp0 (vpn_type, "vpnc") == 0) return "Xauth password";
+ if (g_strcmp0 (vpn_type, "pptp") == 0) return "";
+ if (g_strcmp0 (vpn_type, "openconnect") == 0) return "";
+ if (g_strcmp0 (vpn_type, "openswan") == 0) return "";
+ return "";
+}
+
const gchar *
net_vpn_get_gateway (NetVpn *vpn)
{
NetVpnPrivate *priv = vpn->priv;
- return nm_setting_vpn_get_data_item (nm_connection_get_setting_vpn (priv->connection), "IPSec gateway");
+ const gchar *key;
+
+ key = get_vpn_key_gateway (priv->service_type);
+ return nm_setting_vpn_get_data_item (nm_connection_get_setting_vpn (priv->connection), key);
}
const gchar *
net_vpn_get_id (NetVpn *vpn)
{
NetVpnPrivate *priv = vpn->priv;
- return nm_setting_vpn_get_data_item (nm_connection_get_setting_vpn (priv->connection), "IPSec ID");
+ const gchar *key;
+
+ key = get_vpn_key_group (priv->service_type);
+ return nm_setting_vpn_get_data_item (nm_connection_get_setting_vpn (priv->connection), key);
}
const gchar *
net_vpn_get_username (NetVpn *vpn)
{
NetVpnPrivate *priv = vpn->priv;
- return nm_setting_vpn_get_data_item (nm_connection_get_setting_vpn (priv->connection), "Xauth username");
+ const gchar *key;
+
+ key = get_vpn_key_username (priv->service_type);
+ return nm_setting_vpn_get_data_item (nm_connection_get_setting_vpn (priv->connection), key);
}
const gchar *
net_vpn_get_password (NetVpn *vpn)
{
NetVpnPrivate *priv = vpn->priv;
- return nm_setting_vpn_get_data_item (nm_connection_get_setting_vpn (priv->connection), "Xauth password");
+ const gchar *key;
+
+ key = get_vpn_key_group_password (priv->service_type);
+ return nm_setting_vpn_get_data_item (nm_connection_get_setting_vpn (priv->connection), key);
}
static void
@@ -141,6 +218,7 @@ net_vpn_finalize (GObject *object)
NetVpnPrivate *priv = vpn->priv;
g_object_unref (priv->connection);
+ g_free (priv->service_type);
G_OBJECT_CLASS (net_vpn_parent_class)->finalize (object);
}
diff --git a/panels/network/net-vpn.h b/panels/network/net-vpn.h
index 38c81dc..da79d2f 100644
--- a/panels/network/net-vpn.h
+++ b/panels/network/net-vpn.h
@@ -58,6 +58,7 @@ NetVpn *net_vpn_new (void);
void net_vpn_set_connection (NetVpn *vpn,
NMConnection *connection);
NMConnection *net_vpn_get_connection (NetVpn *vpn);
+const gchar *net_vpn_get_service_type (NetVpn *vpn);
const gchar *net_vpn_get_gateway (NetVpn *vpn);
const gchar *net_vpn_get_id (NetVpn *vpn);
const gchar *net_vpn_get_username (NetVpn *vpn);
diff --git a/panels/network/network.ui b/panels/network/network.ui
index 2afeae5..59f761b 100644
--- a/panels/network/network.ui
+++ b/panels/network/network.ui
@@ -1679,6 +1679,23 @@
</packing>
</child>
<child>
+ <object class="GtkLabel" id="heading_vpn_service_type">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">VPN Type</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
<object class="GtkLabel" id="heading_vpn_gateway">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -1690,7 +1707,7 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">1</property>
+ <property name="top_attach">2</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
@@ -1707,7 +1724,7 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">2</property>
+ <property name="top_attach">3</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
@@ -1724,7 +1741,7 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">3</property>
+ <property name="top_attach">4</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
@@ -1741,12 +1758,27 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">4</property>
+ <property name="top_attach">5</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
+ <object class="GtkLabel" id="label_vpn_service_type">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label">openvpn</property>
+ <property name="selectable">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">1</property>
+ <property name="width">2</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
<object class="GtkLabel" id="label_vpn_gateway">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -1756,7 +1788,7 @@
</object>
<packing>
<property name="left_attach">1</property>
- <property name="top_attach">1</property>
+ <property name="top_attach">2</property>
<property name="width">2</property>
<property name="height">1</property>
</packing>
@@ -1771,7 +1803,7 @@
</object>
<packing>
<property name="left_attach">1</property>
- <property name="top_attach">2</property>
+ <property name="top_attach">3</property>
<property name="width">2</property>
<property name="height">1</property>
</packing>
@@ -1786,7 +1818,7 @@
</object>
<packing>
<property name="left_attach">1</property>
- <property name="top_attach">3</property>
+ <property name="top_attach">4</property>
<property name="width">2</property>
<property name="height">1</property>
</packing>
@@ -1801,7 +1833,7 @@
</object>
<packing>
<property name="left_attach">1</property>
- <property name="top_attach">4</property>
+ <property name="top_attach">5</property>
<property name="width">2</property>
<property name="height">1</property>
</packing>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]