[PATCH] libnm-glib: Add missing properties to suppress warnings



Hello,

NMVPNConnection class in libnm-glib doesn't contain 'vpn-state' and 'banner' 
properties, which causes these errors:

 WARNING **: handle_property_changed: property 'vpn-state' changed but wasn't 
defined by object type NMVPNConnection.

The attached patch adds the properties and thus suppresses the errors.

Jirka

diff --git a/libnm-glib/Makefile.am b/libnm-glib/Makefile.am
index c177fa3..8b4163e 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 "4:1:2"
 
 noinst_PROGRAMS = libnm-glib-test
 
diff --git a/libnm-glib/nm-vpn-connection.c b/libnm-glib/nm-vpn-connection.c
index f66ed19..6910b6f 100644
--- a/libnm-glib/nm-vpn-connection.c
+++ b/libnm-glib/nm-vpn-connection.c
@@ -18,7 +18,7 @@
  * Boston, MA 02110-1301 USA.
  *
  * Copyright (C) 2007 - 2008 Novell, Inc.
- * Copyright (C) 2007 - 2008 Red Hat, Inc.
+ * Copyright (C) 2007 - 2010 Red Hat, Inc.
  */
 
 #include <string.h>
@@ -41,6 +41,17 @@ typedef struct {
 } NMVPNConnectionPrivate;
 
 enum {
+	PROP_0,
+	PROP_VPN_STATE,
+	PROP_BANNER,
+
+	LAST_PROP
+};
+
+#define DBUS_PROP_VPN_STATE "VpnState"
+#define DBUS_PROP_BANNER "Banner"
+
+enum {
 	VPN_STATE_CHANGED,
 
 	LAST_SIGNAL
@@ -74,8 +85,8 @@ nm_vpn_connection_get_banner (NMVPNConnection *vpn)
 
 	if (!priv->banner) {
 		priv->banner = _nm_object_get_string_property (NM_OBJECT (vpn),
-		                                              NM_DBUS_INTERFACE_VPN_CONNECTION,
-		                                              "Banner");
+		                                               NM_DBUS_INTERFACE_VPN_CONNECTION,
+		                                               DBUS_PROP_BANNER);
 		if (priv->banner && !strlen (priv->banner)) {
 			g_free (priv->banner);
 			priv->banner = NULL;
@@ -94,8 +105,8 @@ nm_vpn_connection_get_vpn_state (NMVPNConnection *vpn)
 	priv = NM_VPN_CONNECTION_GET_PRIVATE (vpn);
 	if (priv->vpn_state == NM_VPN_CONNECTION_STATE_UNKNOWN) {
 		priv->vpn_state = _nm_object_get_uint_property (NM_OBJECT (vpn),
-		                                           NM_DBUS_INTERFACE_VPN_CONNECTION,
-		                                           "VpnState");
+		                                                NM_DBUS_INTERFACE_VPN_CONNECTION,
+		                                                DBUS_PROP_VPN_STATE);
 	}
 	return priv->vpn_state;
 }
@@ -173,6 +184,27 @@ finalize (GObject *object)
 }
 
 static void
+get_property (GObject *object,
+              guint prop_id,
+              GValue *value,
+              GParamSpec *pspec)
+{
+	NMVPNConnection *self = NM_VPN_CONNECTION (object);
+
+	switch (prop_id) {
+	case PROP_VPN_STATE:
+		g_value_set_uint (value, nm_vpn_connection_get_vpn_state (self));
+		break;
+	case PROP_BANNER:
+		g_value_set_string (value, nm_vpn_connection_get_banner (self));
+		break;
+	default:
+		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+		break;
+	}
+}
+
+static void
 nm_vpn_connection_class_init (NMVPNConnectionClass *connection_class)
 {
 	GObjectClass *object_class = G_OBJECT_CLASS (connection_class);
@@ -181,8 +213,37 @@ nm_vpn_connection_class_init (NMVPNConnectionClass *connection_class)
 
 	/* virtual methods */
 	object_class->constructor = constructor;
+	object_class->get_property = get_property;
 	object_class->finalize = finalize;
 
+	/* properties */
+
+	/**
+	 * NMVPNConnection:vpn-state:
+	 *
+	 * The VPN state of the active VPN connection.
+	 **/
+	g_object_class_install_property (object_class, PROP_VPN_STATE,
+	                                 g_param_spec_uint (NM_VPN_CONNECTION_VPN_STATE,
+	                                                    "VpnState",
+	                                                    "Current VPN state",
+	                                                    NM_VPN_CONNECTION_STATE_UNKNOWN,
+	                                                    NM_VPN_CONNECTION_STATE_DISCONNECTED,
+	                                                    NM_VPN_CONNECTION_STATE_UNKNOWN,
+	                                                    G_PARAM_READABLE));
+
+	/**
+	 * NMVPNConnection:banner:
+	 *
+	 * The VPN login banner of the active VPN connection.
+	 **/
+	g_object_class_install_property (object_class, PROP_BANNER,
+	                                 g_param_spec_string (NM_VPN_CONNECTION_BANNER,
+	                                                      "Banner",
+	                                                      "Login Banner",
+	                                                      NULL,
+	                                                      G_PARAM_READABLE));
+
 	/* signals */
 	signals[VPN_STATE_CHANGED] =
 		g_signal_new ("vpn-state-changed",
diff --git a/libnm-glib/nm-vpn-connection.h b/libnm-glib/nm-vpn-connection.h
index 122a85b..e03a80c 100644
--- a/libnm-glib/nm-vpn-connection.h
+++ b/libnm-glib/nm-vpn-connection.h
@@ -18,7 +18,7 @@
  * Boston, MA 02110-1301 USA.
  *
  * Copyright (C) 2007 - 2008 Novell, Inc.
- * Copyright (C) 2007 - 2008 Red Hat, Inc.
+ * Copyright (C) 2007 - 2010 Red Hat, Inc.
  */
 
 #ifndef NM_VPN_CONNECTION_H
@@ -39,6 +39,9 @@ G_BEGIN_DECLS
 #define NM_IS_VPN_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_VPN_CONNECTION))
 #define NM_VPN_CONNECTION_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_VPN_CONNECTION, NMVPNConnectionClass))
 
+#define NM_VPN_CONNECTION_VPN_STATE "vpn-state"
+#define NM_VPN_CONNECTION_BANNER "banner"
+
 typedef struct {
 	NMActiveConnection parent;
 } NMVPNConnection;


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