[gnome-control-center] network: use an abstract device so we can get the VPN connection data
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] network: use an abstract device so we can get the VPN connection data
- Date: Fri, 11 Mar 2011 13:02:14 +0000 (UTC)
commit bb70c1bd1a9d3fa9c7e22f8fa3779bc7f99684a2
Author: Richard Hughes <richard hughsie com>
Date: Fri Mar 11 12:28:14 2011 +0000
network: use an abstract device so we can get the VPN connection data
panels/network/Makefile.am | 6 ++
panels/network/cc-network-panel.c | 102 ++++++++++++++++++++++++--------
panels/network/net-device.c | 83 ++++++++++++++++++++++++++
panels/network/net-device.h | 63 ++++++++++++++++++++
panels/network/net-object.c | 94 ++++++++++++++++++++++++++++++
panels/network/net-object.h | 59 +++++++++++++++++++
panels/network/net-vpn.c | 115 +++++++++++++++++++++++++++++++++++++
panels/network/net-vpn.h | 66 +++++++++++++++++++++
panels/network/network.ui | 8 +-
9 files changed, 566 insertions(+), 30 deletions(-)
---
diff --git a/panels/network/Makefile.am b/panels/network/Makefile.am
index f53036f..67394c1 100644
--- a/panels/network/Makefile.am
+++ b/panels/network/Makefile.am
@@ -16,6 +16,12 @@ libnetwork_la_SOURCES = \
network-module.c \
panel-common.c \
panel-common.h \
+ net-object.c \
+ net-object.h \
+ net-device.c \
+ net-device.h \
+ net-vpn.c \
+ net-vpn.h \
panel-cell-renderer-mode.c \
panel-cell-renderer-mode.h \
panel-cell-renderer-signal.c \
diff --git a/panels/network/cc-network-panel.c b/panels/network/cc-network-panel.c
index 9158ae0..463b3c2 100644
--- a/panels/network/cc-network-panel.c
+++ b/panels/network/cc-network-panel.c
@@ -39,6 +39,10 @@
#include "nm-setting-connection.h"
#include "nm-setting-vpn.h"
+#include "net-object.h"
+#include "net-device.h"
+#include "net-vpn.h"
+
#include "panel-common.h"
#include "panel-cell-renderer-mode.h"
#include "panel-cell-renderer-signal.h"
@@ -64,7 +68,7 @@ enum {
PANEL_DEVICES_COLUMN_ID,
PANEL_DEVICES_COLUMN_SORT,
PANEL_DEVICES_COLUMN_TOOLTIP,
- PANEL_DEVICES_COLUMN_COMPOSITE_DEVICE, /* needs to be a custom object */
+ PANEL_DEVICES_COLUMN_COMPOSITE_DEVICE,
PANEL_DEVICES_COLUMN_LAST
};
@@ -77,7 +81,7 @@ enum {
PANEL_WIRELESS_COLUMN_LAST
};
-static void nm_device_refresh_item_ui (CcNetworkPanel *panel, NMDevice *device);
+static void nm_device_refresh_device_ui (CcNetworkPanel *panel, NMDevice *device);
static void
cc_network_panel_get_property (GObject *object,
@@ -374,6 +378,7 @@ panel_add_device (CcNetworkPanel *panel, NMDevice *device)
GtkTreeIter iter;
gchar *title = NULL;
NMDeviceType type;
+ NetDevice *net_device;
CcNetworkPanelPrivate *priv = panel->priv;
g_debug ("device %s type %i",
@@ -412,6 +417,8 @@ panel_add_device (CcNetworkPanel *panel, NMDevice *device)
liststore_devices = GTK_LIST_STORE (gtk_builder_get_object (priv->builder,
"liststore_devices"));
+ net_device = net_device_new ();
+ net_device_set_nm_device (net_device, device);
gtk_list_store_append (liststore_devices, &iter);
gtk_list_store_set (liststore_devices,
&iter,
@@ -420,7 +427,7 @@ panel_add_device (CcNetworkPanel *panel, NMDevice *device)
PANEL_DEVICES_COLUMN_TITLE, title,
PANEL_DEVICES_COLUMN_ID, nm_device_get_udi (device),
PANEL_DEVICES_COLUMN_TOOLTIP, NULL,
- PANEL_DEVICES_COLUMN_COMPOSITE_DEVICE, device,
+ PANEL_DEVICES_COLUMN_COMPOSITE_DEVICE, net_device,
-1);
g_free (title);
}
@@ -517,8 +524,10 @@ panel_set_widget_data (CcNetworkPanel *panel,
/* hide the parent bix if there is no value */
hbox_id = g_strdup_printf ("hbox_%s_%s", sub_pane, widget_suffix);
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, hbox_id));
- if (widget == NULL)
+ if (widget == NULL) {
+ g_warning ("no %s widget", hbox_id);
goto out;
+ }
if (value == NULL) {
gtk_widget_hide (widget);
goto out;
@@ -770,7 +779,7 @@ out:
}
static void
-nm_device_refresh_item_ui (CcNetworkPanel *panel, NMDevice *device)
+nm_device_refresh_device_ui (CcNetworkPanel *panel, NMDevice *device)
{
CcNetworkPanelPrivate *priv = panel->priv;
const gchar *str;
@@ -1022,12 +1031,55 @@ out:
}
static void
+nm_device_refresh_vpn_ui (CcNetworkPanel *panel, NetVpn *vpn)
+{
+ GtkWidget *widget;
+ const gchar *sub_pane = "vpn";
+ CcNetworkPanelPrivate *priv = panel->priv;
+
+ /* Hide the header: TODO: confirm with designers */
+ widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
+ "hbox_device_header"));
+ gtk_widget_set_visible (widget, FALSE);
+
+ /* use proxy note page */
+ widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
+ "notebook_types"));
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (widget), 3);
+
+ /* gateway */
+ panel_set_widget_data (panel,
+ sub_pane,
+ "gateway",
+ net_vpn_get_gateway (vpn));
+
+ /* groupname */
+ panel_set_widget_data (panel,
+ sub_pane,
+ "groupname",
+ net_vpn_get_id (vpn));
+
+ /* username */
+ panel_set_widget_data (panel,
+ sub_pane,
+ "username",
+ net_vpn_get_username (vpn));
+
+ /* password */
+ panel_set_widget_data (panel,
+ sub_pane,
+ "group_password",
+ net_vpn_get_password (vpn));
+}
+
+static void
nm_devices_treeview_clicked_cb (GtkTreeSelection *selection, CcNetworkPanel *panel)
{
GtkTreeIter iter;
GtkTreeModel *model;
GtkWidget *widget;
NMDevice *device;
+ NetObject *object;
CcNetworkPanelPrivate *priv = panel->priv;
/* will only work in single or browse selection mode! */
@@ -1038,11 +1090,11 @@ nm_devices_treeview_clicked_cb (GtkTreeSelection *selection, CcNetworkPanel *pan
/* get id */
gtk_tree_model_get (model, &iter,
- PANEL_DEVICES_COLUMN_COMPOSITE_DEVICE, &device,
+ PANEL_DEVICES_COLUMN_COMPOSITE_DEVICE, &object,
-1);
/* this is the proxy settings device */
- if (device == NULL) {
+ if (object == NULL) {
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
"hbox_device_header"));
gtk_widget_set_visible (widget, FALSE);
@@ -1056,12 +1108,22 @@ nm_devices_treeview_clicked_cb (GtkTreeSelection *selection, CcNetworkPanel *pan
goto out;
}
+ /* VPN */
+ if (NET_IS_VPN (object)) {
+ nm_device_refresh_vpn_ui (panel, NET_VPN (object));
+ /* save so we ignore */
+ g_free (priv->current_device);
+ priv->current_device = NULL;
+ goto out;
+ }
+
/* save so we can update */
g_free (priv->current_device);
+ device = net_device_get_nm_device (NET_DEVICE (object));
priv->current_device = g_strdup (nm_device_get_udi (device));
/* refresh device */
- nm_device_refresh_item_ui (panel, device);
+ nm_device_refresh_device_ui (panel, device);
out:
return;
}
@@ -1135,7 +1197,7 @@ device_state_notify_changed_cb (NMDevice *device,
/* only refresh the selected device */
if (g_strcmp0 (panel->priv->current_device,
nm_device_get_udi (device)) == 0) {
- nm_device_refresh_item_ui (panel, device);
+ nm_device_refresh_device_ui (panel, device);
}
}
@@ -1191,23 +1253,11 @@ panel_add_vpn_device (CcNetworkPanel *panel, NMConnection *connection)
gchar *title_markup;
GtkListStore *liststore_devices;
GtkTreeIter iter;
- NMSettingVPN *setting;
-
- /*
- * key=IKE DH Group, value=dh2
- * key=xauth-password-type, value=ask
- * key=ipsec-secret-type, value=save
- * key=IPSec gateway, value=66.187.233.252
- * key=NAT Traversal Mode, value=natt
- * key=IPSec ID, value=rh-vpn
- * key=Xauth username, value=rhughes
- */
-
- setting = NM_SETTING_VPN (nm_connection_get_setting_by_name (connection, "vpn"));
-
- /* TODO: add as a virtual object */
- nm_setting_vpn_get_data_item (setting, "IPSec gateway");
+ NetVpn *net_vpn;
+ /* add as a virtual object */
+ net_vpn = net_vpn_new ();
+ net_vpn_set_connection (net_vpn, connection);
liststore_devices = GTK_LIST_STORE (gtk_builder_get_object (panel->priv->builder,
"liststore_devices"));
title = g_strdup_printf (_("%s VPN"), nm_connection_get_id (connection));
@@ -1222,7 +1272,7 @@ panel_add_vpn_device (CcNetworkPanel *panel, NMConnection *connection)
PANEL_DEVICES_COLUMN_ID, NULL,
PANEL_DEVICES_COLUMN_SORT, "5",
PANEL_DEVICES_COLUMN_TOOLTIP, _("Virtual private network"),
- PANEL_DEVICES_COLUMN_COMPOSITE_DEVICE, NULL,
+ PANEL_DEVICES_COLUMN_COMPOSITE_DEVICE, net_vpn,
-1);
g_free (title);
g_free (title_markup);
diff --git a/panels/network/net-device.c b/panels/network/net-device.c
new file mode 100644
index 0000000..0743cd4
--- /dev/null
+++ b/panels/network/net-device.c
@@ -0,0 +1,83 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2011 Richard Hughes <richard hughsie com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "config.h"
+
+#include <glib-object.h>
+#include <glib/gi18n.h>
+
+#include "net-device.h"
+
+#define NET_DEVICE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NET_TYPE_DEVICE, NetDevicePrivate))
+
+struct _NetDevicePrivate
+{
+ NMDevice *nm_device;
+};
+
+G_DEFINE_TYPE (NetDevice, net_device, NET_TYPE_OBJECT)
+
+void
+net_device_set_nm_device (NetDevice *device, NMDevice *nm_device)
+{
+ device->priv->nm_device = g_object_ref (nm_device);
+}
+
+NMDevice *
+net_device_get_nm_device (NetDevice *device)
+{
+ return device->priv->nm_device;
+}
+
+static void
+net_device_finalize (GObject *object)
+{
+ NetDevice *device = NET_DEVICE (object);
+ NetDevicePrivate *priv = device->priv;
+
+ if (priv->nm_device != NULL)
+ g_object_unref (priv->nm_device);
+
+ G_OBJECT_CLASS (net_device_parent_class)->finalize (object);
+}
+
+static void
+net_device_class_init (NetDeviceClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ object_class->finalize = net_device_finalize;
+ g_type_class_add_private (klass, sizeof (NetDevicePrivate));
+}
+
+static void
+net_device_init (NetDevice *device)
+{
+ device->priv = NET_DEVICE_GET_PRIVATE (device);
+}
+
+NetDevice *
+net_device_new (void)
+{
+ NetDevice *device;
+ device = g_object_new (NET_TYPE_DEVICE, NULL);
+ return NET_DEVICE (device);
+}
+
diff --git a/panels/network/net-device.h b/panels/network/net-device.h
new file mode 100644
index 0000000..709f909
--- /dev/null
+++ b/panels/network/net-device.h
@@ -0,0 +1,63 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2011 Richard Hughes <richard hughsie com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __NET_DEVICE_H
+#define __NET_DEVICE_H
+
+#include <glib-object.h>
+
+#include "net-object.h"
+#include "nm-device.h"
+
+G_BEGIN_DECLS
+
+#define NET_TYPE_DEVICE (net_device_get_type ())
+#define NET_DEVICE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), NET_TYPE_DEVICE, NetDevice))
+#define NET_DEVICE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), NET_TYPE_DEVICE, NetDeviceClass))
+#define NET_IS_DEVICE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), NET_TYPE_DEVICE))
+#define NET_IS_DEVICE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), NET_TYPE_DEVICE))
+#define NET_DEVICE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), NET_TYPE_DEVICE, NetDeviceClass))
+
+typedef struct _NetDevicePrivate NetDevicePrivate;
+typedef struct _NetDevice NetDevice;
+typedef struct _NetDeviceClass NetDeviceClass;
+
+struct _NetDevice
+{
+ NetObject parent;
+ NetDevicePrivate *priv;
+};
+
+struct _NetDeviceClass
+{
+ NetObjectClass parent_class;
+};
+
+GType net_device_get_type (void);
+NetDevice *net_device_new (void);
+void net_device_set_nm_device (NetDevice *device,
+ NMDevice *nm_device);
+NMDevice *net_device_get_nm_device (NetDevice *device);
+
+G_END_DECLS
+
+#endif /* __NET_DEVICE_H */
+
diff --git a/panels/network/net-object.c b/panels/network/net-object.c
new file mode 100644
index 0000000..dd32cac
--- /dev/null
+++ b/panels/network/net-object.c
@@ -0,0 +1,94 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2011 Richard Hughes <richard hughsie com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "config.h"
+
+#include <glib-object.h>
+#include <glib/gi18n.h>
+
+#include "net-object.h"
+
+#define NET_OBJECT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NET_TYPE_OBJECT, NetObjectPrivate))
+
+struct _NetObjectPrivate
+{
+ guint dummy;
+};
+
+enum {
+ SIGNAL_CHANGED,
+ SIGNAL_LAST
+};
+
+static guint signals[SIGNAL_LAST] = { 0 };
+G_DEFINE_TYPE (NetObject, net_object, G_TYPE_OBJECT)
+
+void
+net_object_emit_changed (NetObject *object)
+{
+ g_return_if_fail (NET_IS_OBJECT (object));
+ g_debug ("NetObject: emit 'changed'");
+ g_signal_emit (object, signals[SIGNAL_CHANGED], 0);
+}
+
+static void
+net_object_finalize (GObject *object)
+{
+#if 0
+ NetObject *object = NET_OBJECT (object);
+ NetObjectPrivate *priv = object->priv;
+#endif
+ G_OBJECT_CLASS (net_object_parent_class)->finalize (object);
+}
+
+static void
+net_object_class_init (NetObjectClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ object_class->finalize = net_object_finalize;
+
+ /**
+ * NetObject::changed:
+ **/
+ signals[SIGNAL_CHANGED] =
+ g_signal_new ("changed",
+ G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (NetObjectClass, changed),
+ NULL, NULL, g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ g_type_class_add_private (klass, sizeof (NetObjectPrivate));
+}
+
+static void
+net_object_init (NetObject *object)
+{
+ object->priv = NET_OBJECT_GET_PRIVATE (object);
+}
+
+NetObject *
+net_object_new (void)
+{
+ NetObject *object;
+ object = g_object_new (NET_TYPE_OBJECT, NULL);
+ return NET_OBJECT (object);
+}
+
diff --git a/panels/network/net-object.h b/panels/network/net-object.h
new file mode 100644
index 0000000..98c0c9c
--- /dev/null
+++ b/panels/network/net-object.h
@@ -0,0 +1,59 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2011 Richard Hughes <richard hughsie com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __NET_OBJECT_H
+#define __NET_OBJECT_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define NET_TYPE_OBJECT (net_object_get_type ())
+#define NET_OBJECT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), NET_TYPE_OBJECT, NetObject))
+#define NET_OBJECT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), NET_TYPE_OBJECT, NetObjectClass))
+#define NET_IS_OBJECT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), NET_TYPE_OBJECT))
+#define NET_IS_OBJECT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), NET_TYPE_OBJECT))
+#define NET_OBJECT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), NET_TYPE_OBJECT, NetObjectClass))
+
+typedef struct _NetObjectPrivate NetObjectPrivate;
+typedef struct _NetObject NetObject;
+typedef struct _NetObjectClass NetObjectClass;
+
+struct _NetObject
+{
+ GObject parent;
+ NetObjectPrivate *priv;
+};
+
+struct _NetObjectClass
+{
+ GObjectClass parent_class;
+ void (* changed) (NetObject *object);
+};
+
+GType net_object_get_type (void);
+NetObject *net_object_new (void);
+void net_object_emit_changed (NetObject *object);
+
+G_END_DECLS
+
+#endif /* __NET_OBJECT_H */
+
diff --git a/panels/network/net-vpn.c b/panels/network/net-vpn.c
new file mode 100644
index 0000000..8238367
--- /dev/null
+++ b/panels/network/net-vpn.c
@@ -0,0 +1,115 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2011 Richard Hughes <richard hughsie com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "config.h"
+
+#include <glib-object.h>
+#include <glib/gi18n.h>
+
+#include "net-vpn.h"
+#include "nm-setting-vpn.h"
+
+#define NET_VPN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NET_TYPE_VPN, NetVpnPrivate))
+
+struct _NetVpnPrivate
+{
+ NMSettingVPN *setting;
+};
+
+G_DEFINE_TYPE (NetVpn, net_vpn, NET_TYPE_OBJECT)
+
+void
+net_vpn_set_connection (NetVpn *vpn, NMConnection *connection)
+{
+ NetVpnPrivate *priv = vpn->priv;
+ /*
+ * key=IKE DH Group, value=dh2
+ * key=xauth-password-type, value=ask
+ * key=ipsec-secret-type, value=save
+ * key=IPSec gateway, value=66.187.233.252
+ * key=NAT Traversal Mode, value=natt
+ * key=IPSec ID, value=rh-vpn
+ * key=Xauth username, value=rhughes
+ */
+ priv->setting = NM_SETTING_VPN (nm_connection_get_setting_by_name (connection, "vpn"));
+}
+
+const gchar *
+net_vpn_get_gateway (NetVpn *vpn)
+{
+ NetVpnPrivate *priv = vpn->priv;
+ return nm_setting_vpn_get_data_item (priv->setting, "IPSec gateway");
+}
+
+const gchar *
+net_vpn_get_id (NetVpn *vpn)
+{
+ NetVpnPrivate *priv = vpn->priv;
+ return nm_setting_vpn_get_data_item (priv->setting, "IPSec ID");
+}
+
+const gchar *
+net_vpn_get_username (NetVpn *vpn)
+{
+ NetVpnPrivate *priv = vpn->priv;
+ return nm_setting_vpn_get_data_item (priv->setting, "Xauth username");
+}
+
+const gchar *
+net_vpn_get_password (NetVpn *vpn)
+{
+ NetVpnPrivate *priv = vpn->priv;
+ return nm_setting_vpn_get_data_item (priv->setting, "Xauth password");
+}
+
+static void
+net_vpn_finalize (GObject *object)
+{
+ NetVpn *vpn = NET_VPN (object);
+ NetVpnPrivate *priv = vpn->priv;
+
+ g_object_unref (priv->setting);
+
+ G_OBJECT_CLASS (net_vpn_parent_class)->finalize (object);
+}
+
+static void
+net_vpn_class_init (NetVpnClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ object_class->finalize = net_vpn_finalize;
+ g_type_class_add_private (klass, sizeof (NetVpnPrivate));
+}
+
+static void
+net_vpn_init (NetVpn *vpn)
+{
+ vpn->priv = NET_VPN_GET_PRIVATE (vpn);
+}
+
+NetVpn *
+net_vpn_new (void)
+{
+ NetVpn *vpn;
+ vpn = g_object_new (NET_TYPE_VPN, NULL);
+ return NET_VPN (vpn);
+}
+
diff --git a/panels/network/net-vpn.h b/panels/network/net-vpn.h
new file mode 100644
index 0000000..c50507d
--- /dev/null
+++ b/panels/network/net-vpn.h
@@ -0,0 +1,66 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2011 Richard Hughes <richard hughsie com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __NET_VPN_H
+#define __NET_VPN_H
+
+#include <glib-object.h>
+
+#include "net-object.h"
+#include "nm-connection.h"
+
+G_BEGIN_DECLS
+
+#define NET_TYPE_VPN (net_vpn_get_type ())
+#define NET_VPN(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), NET_TYPE_VPN, NetVpn))
+#define NET_VPN_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), NET_TYPE_VPN, NetVpnClass))
+#define NET_IS_VPN(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), NET_TYPE_VPN))
+#define NET_IS_VPN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), NET_TYPE_VPN))
+#define NET_VPN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), NET_TYPE_VPN, NetVpnClass))
+
+typedef struct _NetVpnPrivate NetVpnPrivate;
+typedef struct _NetVpn NetVpn;
+typedef struct _NetVpnClass NetVpnClass;
+
+struct _NetVpn
+{
+ NetObject parent;
+ NetVpnPrivate *priv;
+};
+
+struct _NetVpnClass
+{
+ NetObjectClass parent_class;
+};
+
+GType net_vpn_get_type (void);
+NetVpn *net_vpn_new (void);
+void net_vpn_set_connection (NetVpn *vpn,
+ NMConnection *connection);
+const gchar *net_vpn_get_gateway (NetVpn *vpn);
+const gchar *net_vpn_get_id (NetVpn *vpn);
+const gchar *net_vpn_get_username (NetVpn *vpn);
+const gchar *net_vpn_get_password (NetVpn *vpn);
+
+G_END_DECLS
+
+#endif /* __NET_VPN_H */
+
diff --git a/panels/network/network.ui b/panels/network/network.ui
index a184cb7..1c49a84 100644
--- a/panels/network/network.ui
+++ b/panels/network/network.ui
@@ -1162,7 +1162,7 @@
<property name="border_width">12</property>
<property name="spacing">6</property>
<child>
- <object class="GtkHBox" id="hbox38">
+ <object class="GtkHBox" id="hbox_vpn_gateway">
<property name="visible">True</property>
<property name="spacing">9</property>
<child>
@@ -1207,7 +1207,7 @@
</packing>
</child>
<child>
- <object class="GtkHBox" id="hbox40">
+ <object class="GtkHBox" id="hbox_vpn_groupname">
<property name="visible">True</property>
<property name="spacing">9</property>
<child>
@@ -1252,7 +1252,7 @@
</packing>
</child>
<child>
- <object class="GtkHBox" id="hbox42">
+ <object class="GtkHBox" id="hbox_vpn_group_password">
<property name="visible">True</property>
<property name="spacing">9</property>
<child>
@@ -1297,7 +1297,7 @@
</packing>
</child>
<child>
- <object class="GtkHBox" id="hbox44">
+ <object class="GtkHBox" id="hbox_vpn_username">
<property name="visible">True</property>
<property name="spacing">9</property>
<child>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]