Using libnm-glib issues after dbus and dbus-glib update



I have a small program which I use to detect device state changes,
that uses libnm-glib. A couple of days ago i updated dbus to 1.2.6 and
dbus-glib to 0.78 (this is a slackware base), and now the
"device-changed" signal among others no longer works, however, other
applications that use NM seems to work fine such as nm-applet. Here is
the code I am using, with irrelevant sections cut out:

#include <stdio.h>
#include <gtk/gtk.h>
#include <glib.h>
#include <NetworkManager.h>
#include <nm-client.h>
#include <nm-device.h>

static void device_state_changed_cb(NMDevice *device, NMDeviceState
new_state, NMDeviceState old_state, NMDeviceStateReason reason,
gpointer user_data){
	printf("device state changed\n");
	//handle_device(device, new_state);
}

static void device_update_cb(NMClient *client, NMDevice *device,
gpointer user_data){
	g_signal_connect(G_OBJECT(device), "state-changed",
G_CALLBACK(device_state_changed_cb), NULL);
}

static void init_devices(NMDevice* device, gpointer user_data){
	g_signal_connect(G_OBJECT(device), "state-changed",
G_CALLBACK(device_state_changed_cb), NULL);
	printf("device added %s\n", nm_device_get_iface(device));
	//handle_device(device, nm_device_get_state(device));
}

int main(){
	NMClient* nm_client;
	const GPtrArray* devices = NULL;
	
	gtk_init (NULL, NULL);
	
	nm_client = nm_client_new();
	
	g_signal_connect(G_OBJECT(nm_client), "device-added",
G_CALLBACK(device_update_cb), NULL);
	
	devices = nm_client_get_devices(nm_client);
	if(devices) g_ptr_array_foreach((GPtrArray*)devices,
(GFunc)init_devices, NULL);
	
	gtk_main();
	return 0;
}

Before, I could unplug my ethernet and replug it, and it would spam
"device state changed" all over the screen. Now, nothing happens on
the "state-changed" signal despite getting a valid connection handler.

Would anyone like to shed light on this strange issue?


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