libnm-glib: fix vpn-state-changed signal handling

Core D-Bus VpnStateChanged signal changed. In order to receive the signal,
the parameters was fixed. This commit also adjusts libnm-glib's vpn-state-changed
signal to match the D-Bus one.
This commit is contained in:
Jiří Klimeš 2012-06-29 14:10:21 +02:00
parent 9d85378045
commit 4d635b23cb
2 changed files with 31 additions and 20 deletions

View file

@ -127,6 +127,7 @@ nm_vpn_connection_get_vpn_state (NMVPNConnection *vpn)
static void static void
vpn_state_changed_proxy (DBusGProxy *proxy, vpn_state_changed_proxy (DBusGProxy *proxy,
NMVPNConnectionState vpn_state, NMVPNConnectionState vpn_state,
NMVPNConnectionState old_vpn_state,
NMVPNConnectionStateReason reason, NMVPNConnectionStateReason reason,
gpointer user_data) gpointer user_data)
{ {
@ -135,7 +136,7 @@ vpn_state_changed_proxy (DBusGProxy *proxy,
if (priv->vpn_state != vpn_state) { if (priv->vpn_state != vpn_state) {
priv->vpn_state = vpn_state; priv->vpn_state = vpn_state;
g_signal_emit (connection, signals[VPN_STATE_CHANGED], 0, vpn_state, reason); g_signal_emit (connection, signals[VPN_STATE_CHANGED], 0, vpn_state, old_vpn_state, reason);
} }
} }
@ -174,20 +175,20 @@ constructed (GObject *object)
priv = NM_VPN_CONNECTION_GET_PRIVATE (object); priv = NM_VPN_CONNECTION_GET_PRIVATE (object);
priv->proxy = dbus_g_proxy_new_for_name (nm_object_get_connection (NM_OBJECT (object)), priv->proxy = dbus_g_proxy_new_for_name (nm_object_get_connection (NM_OBJECT (object)),
NM_DBUS_SERVICE, NM_DBUS_SERVICE,
nm_object_get_path (NM_OBJECT (object)), nm_object_get_path (NM_OBJECT (object)),
NM_DBUS_INTERFACE_VPN_CONNECTION); NM_DBUS_INTERFACE_VPN_CONNECTION);
dbus_g_object_register_marshaller (_nm_glib_marshal_VOID__UINT_UINT, dbus_g_object_register_marshaller (_nm_glib_marshal_VOID__UINT_UINT_UINT,
G_TYPE_NONE, G_TYPE_NONE,
G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT,
G_TYPE_INVALID); G_TYPE_INVALID);
dbus_g_proxy_add_signal (priv->proxy, "VpnStateChanged", G_TYPE_UINT, G_TYPE_UINT, G_TYPE_INVALID); dbus_g_proxy_add_signal (priv->proxy, "VpnStateChanged", G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_INVALID);
dbus_g_proxy_connect_signal (priv->proxy, dbus_g_proxy_connect_signal (priv->proxy,
"VpnStateChanged", "VpnStateChanged",
G_CALLBACK (vpn_state_changed_proxy), G_CALLBACK (vpn_state_changed_proxy),
object, object,
NULL); NULL);
register_properties (NM_VPN_CONNECTION (object)); register_properties (NM_VPN_CONNECTION (object));
} }
@ -267,13 +268,22 @@ nm_vpn_connection_class_init (NMVPNConnectionClass *connection_class)
G_PARAM_READABLE)); G_PARAM_READABLE));
/* signals */ /* signals */
/**
* NMVPNConnection::vpn-state-changed:
* @connection: the VPN connection that received the signal
* @new_state: the new state of the VPN connection
* @old_state: the previous state of the VPN connection
* @reason: the reason for changing the state
*
* Notifies the state change of a #NMVPNConnection.
**/
signals[VPN_STATE_CHANGED] = signals[VPN_STATE_CHANGED] =
g_signal_new ("vpn-state-changed", g_signal_new ("vpn-state-changed",
G_OBJECT_CLASS_TYPE (object_class), G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST, G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (NMVPNConnectionClass, vpn_state_changed), G_STRUCT_OFFSET (NMVPNConnectionClass, vpn_state_changed),
NULL, NULL, NULL, NULL,
_nm_glib_marshal_VOID__UINT_UINT, _nm_glib_marshal_VOID__UINT_UINT_UINT,
G_TYPE_NONE, 2, G_TYPE_NONE, 3, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT);
G_TYPE_UINT, G_TYPE_UINT);
} }

View file

@ -18,7 +18,7 @@
* Boston, MA 02110-1301 USA. * Boston, MA 02110-1301 USA.
* *
* Copyright (C) 2007 - 2008 Novell, Inc. * Copyright (C) 2007 - 2008 Novell, Inc.
* Copyright (C) 2007 - 2010 Red Hat, Inc. * Copyright (C) 2007 - 2012 Red Hat, Inc.
*/ */
#ifndef NM_VPN_CONNECTION_H #ifndef NM_VPN_CONNECTION_H
@ -51,7 +51,8 @@ typedef struct {
/* Signals */ /* Signals */
void (*vpn_state_changed) (NMVPNConnection *connection, void (*vpn_state_changed) (NMVPNConnection *connection,
NMVPNConnectionState state, NMVPNConnectionState new_state,
NMVPNConnectionState old_state,
NMVPNConnectionStateReason reason); NMVPNConnectionStateReason reason);
/* Padding for future expansion */ /* Padding for future expansion */