network: Show VPN type and info in panel
For all the VPN types https://bugzilla.gnome.org/show_bug.cgi?id=657303
This commit is contained in:
parent
e04d0bb787
commit
382509986a
4 changed files with 133 additions and 16 deletions
|
@ -1947,29 +1947,35 @@ nm_device_refresh_vpn_ui (CcNetworkPanel *panel, NetVpn *vpn)
|
||||||
state != NM_VPN_CONNECTION_STATE_DISCONNECTED);
|
state != NM_VPN_CONNECTION_STATE_DISCONNECTED);
|
||||||
priv->updating_device = FALSE;
|
priv->updating_device = FALSE;
|
||||||
|
|
||||||
|
/* service type */
|
||||||
|
panel_set_widget_data (panel,
|
||||||
|
sub_pane,
|
||||||
|
"service_type",
|
||||||
|
net_vpn_get_service_type (vpn));
|
||||||
|
|
||||||
/* gateway */
|
/* gateway */
|
||||||
panel_set_widget_data (panel,
|
panel_set_widget_data (panel,
|
||||||
sub_pane,
|
sub_pane,
|
||||||
"gateway",
|
"gateway",
|
||||||
net_vpn_get_gateway (vpn));
|
net_vpn_get_gateway (vpn));
|
||||||
|
|
||||||
/* groupname */
|
/* groupname */
|
||||||
panel_set_widget_data (panel,
|
panel_set_widget_data (panel,
|
||||||
sub_pane,
|
sub_pane,
|
||||||
"group_name",
|
"group_name",
|
||||||
net_vpn_get_id (vpn));
|
net_vpn_get_id (vpn));
|
||||||
|
|
||||||
/* username */
|
/* username */
|
||||||
panel_set_widget_data (panel,
|
panel_set_widget_data (panel,
|
||||||
sub_pane,
|
sub_pane,
|
||||||
"username",
|
"username",
|
||||||
net_vpn_get_username (vpn));
|
net_vpn_get_username (vpn));
|
||||||
|
|
||||||
/* password */
|
/* password */
|
||||||
panel_set_widget_data (panel,
|
panel_set_widget_data (panel,
|
||||||
sub_pane,
|
sub_pane,
|
||||||
"group_password",
|
"group_password",
|
||||||
net_vpn_get_password (vpn));
|
net_vpn_get_password (vpn));
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
struct _NetVpnPrivate
|
struct _NetVpnPrivate
|
||||||
{
|
{
|
||||||
NMConnection *connection;
|
NMConnection *connection;
|
||||||
|
gchar *service_type;
|
||||||
gboolean valid;
|
gboolean valid;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -65,7 +66,9 @@ void
|
||||||
net_vpn_set_connection (NetVpn *vpn, NMConnection *connection)
|
net_vpn_set_connection (NetVpn *vpn, NMConnection *connection)
|
||||||
{
|
{
|
||||||
NetVpnPrivate *priv = vpn->priv;
|
NetVpnPrivate *priv = vpn->priv;
|
||||||
|
const gchar *type, *p;
|
||||||
/*
|
/*
|
||||||
|
* vpnc config exmaple:
|
||||||
* key=IKE DH Group, value=dh2
|
* key=IKE DH Group, value=dh2
|
||||||
* key=xauth-password-type, value=ask
|
* key=xauth-password-type, value=ask
|
||||||
* key=ipsec-secret-type, value=save
|
* 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),
|
G_CALLBACK (connection_vpn_state_changed_cb),
|
||||||
vpn);
|
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 *
|
NMConnection *
|
||||||
|
@ -97,6 +104,12 @@ net_vpn_get_connection (NetVpn *vpn)
|
||||||
return vpn->priv->connection;
|
return vpn->priv->connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const gchar *
|
||||||
|
net_vpn_get_service_type (NetVpn *vpn)
|
||||||
|
{
|
||||||
|
return vpn->priv->service_type;
|
||||||
|
}
|
||||||
|
|
||||||
NMVPNConnectionState
|
NMVPNConnectionState
|
||||||
net_vpn_get_state (NetVpn *vpn)
|
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));
|
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 *
|
const gchar *
|
||||||
net_vpn_get_gateway (NetVpn *vpn)
|
net_vpn_get_gateway (NetVpn *vpn)
|
||||||
{
|
{
|
||||||
NetVpnPrivate *priv = vpn->priv;
|
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 *
|
const gchar *
|
||||||
net_vpn_get_id (NetVpn *vpn)
|
net_vpn_get_id (NetVpn *vpn)
|
||||||
{
|
{
|
||||||
NetVpnPrivate *priv = vpn->priv;
|
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 *
|
const gchar *
|
||||||
net_vpn_get_username (NetVpn *vpn)
|
net_vpn_get_username (NetVpn *vpn)
|
||||||
{
|
{
|
||||||
NetVpnPrivate *priv = vpn->priv;
|
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 *
|
const gchar *
|
||||||
net_vpn_get_password (NetVpn *vpn)
|
net_vpn_get_password (NetVpn *vpn)
|
||||||
{
|
{
|
||||||
NetVpnPrivate *priv = vpn->priv;
|
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
|
static void
|
||||||
|
@ -141,6 +218,7 @@ net_vpn_finalize (GObject *object)
|
||||||
NetVpnPrivate *priv = vpn->priv;
|
NetVpnPrivate *priv = vpn->priv;
|
||||||
|
|
||||||
g_object_unref (priv->connection);
|
g_object_unref (priv->connection);
|
||||||
|
g_free (priv->service_type);
|
||||||
|
|
||||||
G_OBJECT_CLASS (net_vpn_parent_class)->finalize (object);
|
G_OBJECT_CLASS (net_vpn_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,6 +58,7 @@ NetVpn *net_vpn_new (void);
|
||||||
void net_vpn_set_connection (NetVpn *vpn,
|
void net_vpn_set_connection (NetVpn *vpn,
|
||||||
NMConnection *connection);
|
NMConnection *connection);
|
||||||
NMConnection *net_vpn_get_connection (NetVpn *vpn);
|
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_gateway (NetVpn *vpn);
|
||||||
const gchar *net_vpn_get_id (NetVpn *vpn);
|
const gchar *net_vpn_get_id (NetVpn *vpn);
|
||||||
const gchar *net_vpn_get_username (NetVpn *vpn);
|
const gchar *net_vpn_get_username (NetVpn *vpn);
|
||||||
|
|
|
@ -1678,6 +1678,23 @@
|
||||||
<property name="height">1</property>
|
<property name="height">1</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</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>
|
<child>
|
||||||
<object class="GtkLabel" id="heading_vpn_gateway">
|
<object class="GtkLabel" id="heading_vpn_gateway">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
@ -1690,7 +1707,7 @@
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="left_attach">0</property>
|
<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="width">1</property>
|
||||||
<property name="height">1</property>
|
<property name="height">1</property>
|
||||||
</packing>
|
</packing>
|
||||||
|
@ -1707,7 +1724,7 @@
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="left_attach">0</property>
|
<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="width">1</property>
|
||||||
<property name="height">1</property>
|
<property name="height">1</property>
|
||||||
</packing>
|
</packing>
|
||||||
|
@ -1724,7 +1741,7 @@
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="left_attach">0</property>
|
<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="width">1</property>
|
||||||
<property name="height">1</property>
|
<property name="height">1</property>
|
||||||
</packing>
|
</packing>
|
||||||
|
@ -1741,11 +1758,26 @@
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="left_attach">0</property>
|
<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="width">1</property>
|
||||||
<property name="height">1</property>
|
<property name="height">1</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</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>
|
<child>
|
||||||
<object class="GtkLabel" id="label_vpn_gateway">
|
<object class="GtkLabel" id="label_vpn_gateway">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
@ -1756,7 +1788,7 @@
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="left_attach">1</property>
|
<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="width">2</property>
|
||||||
<property name="height">1</property>
|
<property name="height">1</property>
|
||||||
</packing>
|
</packing>
|
||||||
|
@ -1771,7 +1803,7 @@
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="left_attach">1</property>
|
<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="width">2</property>
|
||||||
<property name="height">1</property>
|
<property name="height">1</property>
|
||||||
</packing>
|
</packing>
|
||||||
|
@ -1786,7 +1818,7 @@
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="left_attach">1</property>
|
<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="width">2</property>
|
||||||
<property name="height">1</property>
|
<property name="height">1</property>
|
||||||
</packing>
|
</packing>
|
||||||
|
@ -1801,7 +1833,7 @@
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="left_attach">1</property>
|
<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="width">2</property>
|
||||||
<property name="height">1</property>
|
<property name="height">1</property>
|
||||||
</packing>
|
</packing>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue