[PATCH] libnm-glib: Add missing function nm_active_connection_get_vpn()



Hello,

the attached patch adds nm_active_connection_get_vpn() method
for NMActiveConnection obtaining Vpn property of 
org.freedesktop.NetworkManager.Connection.Active interface.

Cheers,
Jirka
diff --git a/libnm-glib/Makefile.am b/libnm-glib/Makefile.am
index c177fa3..f3e9b0a 100644
--- a/libnm-glib/Makefile.am
+++ b/libnm-glib/Makefile.am
@@ -108,7 +108,7 @@ libnm_glib_la_LIBADD = \
 	$(GUDEV_LIBS)
 
 libnm_glib_la_LDFLAGS = -Wl,--version-script=$(srcdir)/libnm-glib.ver \
-	-version-info "4:0:2"
+	-version-info "5:0:3"
 
 noinst_PROGRAMS = libnm-glib-test
 
diff --git a/libnm-glib/libnm-glib.ver b/libnm-glib/libnm-glib.ver
index 1caa2d4..92345a6 100644
--- a/libnm-glib/libnm-glib.ver
+++ b/libnm-glib/libnm-glib.ver
@@ -18,6 +18,7 @@ global:
 	nm_access_point_new;
 	nm_active_connection_get_connection;
 	nm_active_connection_get_default;
+	nm_active_connection_get_vpn;
 	nm_active_connection_get_devices;
 	nm_active_connection_get_scope;
 	nm_active_connection_get_service_name;
diff --git a/libnm-glib/nm-active-connection.c b/libnm-glib/nm-active-connection.c
index df8bb98..0819434 100644
--- a/libnm-glib/nm-active-connection.c
+++ b/libnm-glib/nm-active-connection.c
@@ -17,7 +17,7 @@
  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  * Boston, MA 02110-1301 USA.
  *
- * Copyright (C) 2007 - 2008 Red Hat, Inc.
+ * Copyright (C) 2007 - 2010 Red Hat, Inc.
  * Copyright (C) 2008 Novell, Inc.
  */
 
@@ -50,6 +50,7 @@ typedef struct {
 	GPtrArray *devices;
 	NMActiveConnectionState state;
 	gboolean is_default;
+	gboolean is_vpn;
 } NMActiveConnectionPrivate;
 
 enum {
@@ -60,6 +61,7 @@ enum {
 	PROP_DEVICES,
 	PROP_STATE,
 	PROP_DEFAULT,
+	PROP_VPN,
 
 	LAST_PROP
 };
@@ -70,6 +72,7 @@ enum {
 #define DBUS_PROP_DEVICES "Devices"
 #define DBUS_PROP_STATE "State"
 #define DBUS_PROP_DEFAULT "Default"
+#define DBUS_PROP_VPN "Vpn"
 
 /**
  * nm_active_connection_new:
@@ -285,6 +288,32 @@ nm_active_connection_get_default (NMActiveConnection *connection)
 	return priv->is_default;
 }
 
+/**
+ * nm_active_connection_get_vpn:
+ * @connection: a #NMActiveConnection
+ *
+ * Whether the active connection is a VPN connection (that is, represents a connection
+ * to a Virtual Private Network).
+ *
+ * Returns: %TRUE if the active connection is a VPN connection
+ **/
+gboolean
+nm_active_connection_get_vpn (NMActiveConnection *connection)
+{
+	NMActiveConnectionPrivate *priv;
+
+	g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), FALSE);
+
+	priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (connection);
+	if (!priv->is_vpn) {
+		priv->is_vpn = _nm_object_get_boolean_property (NM_OBJECT (connection),
+		                                                NM_DBUS_INTERFACE_ACTIVE_CONNECTION,
+		                                                DBUS_PROP_VPN);
+	}
+
+	return priv->is_vpn;
+}
+
 static void
 nm_active_connection_init (NMActiveConnection *ap)
 {
@@ -350,6 +379,9 @@ get_property (GObject *object,
 	case PROP_DEFAULT:
 		g_value_set_boolean (value, nm_active_connection_get_default (self));
 		break;
+	case PROP_VPN:
+		g_value_set_boolean (value, nm_active_connection_get_vpn (self));
+		break;
 	default:
 		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
 		break;
@@ -392,6 +424,7 @@ register_for_property_changed (NMActiveConnection *connection)
 		{ NM_ACTIVE_CONNECTION_DEVICES,             demarshal_devices,           &priv->devices },
 		{ NM_ACTIVE_CONNECTION_STATE,               _nm_object_demarshal_generic, &priv->state },
 		{ NM_ACTIVE_CONNECTION_DEFAULT,             _nm_object_demarshal_generic, &priv->is_default },
+		{ NM_ACTIVE_CONNECTION_VPN,                 _nm_object_demarshal_generic, &priv->is_vpn },
 		{ NULL },
 	};
 
@@ -521,4 +554,17 @@ nm_active_connection_class_init (NMActiveConnectionClass *ap_class)
 							   "Is the default active connection",
 							   FALSE,
 							   G_PARAM_READABLE));
+
+	/**
+	 * NMActiveConnection:vpn:
+	 *
+	 * Whether the active connection is a VPN connection.
+	 **/
+	g_object_class_install_property
+		(object_class, PROP_VPN,
+		 g_param_spec_boolean (NM_ACTIVE_CONNECTION_VPN,
+		                       "Vpn",
+		                       "Is this a VPN connection",
+		                       FALSE,
+		                       G_PARAM_READABLE));
 }
diff --git a/libnm-glib/nm-active-connection.h b/libnm-glib/nm-active-connection.h
index f717c05..969580b 100644
--- a/libnm-glib/nm-active-connection.h
+++ b/libnm-glib/nm-active-connection.h
@@ -17,7 +17,7 @@
  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  * Boston, MA 02110-1301 USA.
  *
- * Copyright (C) 2007 - 2008 Red Hat, Inc.
+ * Copyright (C) 2007 - 2010 Red Hat, Inc.
  * Copyright (C) 2008 Novell, Inc.
  */
 
@@ -45,6 +45,7 @@ G_BEGIN_DECLS
 #define NM_ACTIVE_CONNECTION_DEVICES             "devices"
 #define NM_ACTIVE_CONNECTION_STATE               "state"
 #define NM_ACTIVE_CONNECTION_DEFAULT             "default"
+#define NM_ACTIVE_CONNECTION_VPN                 "vpn"
 
 typedef struct {
 	NMObject parent;
@@ -73,6 +74,7 @@ const char * nm_active_connection_get_specific_object     (NMActiveConnection *c
 const GPtrArray *nm_active_connection_get_devices         (NMActiveConnection *connection);
 NMActiveConnectionState nm_active_connection_get_state    (NMActiveConnection *connection);
 gboolean nm_active_connection_get_default                 (NMActiveConnection *connection);
+gboolean nm_active_connection_get_vpn                     (NMActiveConnection *connection);
 
 G_END_DECLS
 


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