static void
nm_session_monitor_finalize (GObject *object)
{
#ifdef SESSION_TRACKING_SYSTEMD
	sd_finalize (NM_SESSION_MONITOR (object));
#endif

#ifdef SESSION_TRACKING_CONSOLEKIT
	ck_finalize (NM_SESSION_MONITOR (object));
#endif

	if (G_OBJECT_CLASS (nm_session_monitor_parent_class)->finalize != NULL)
		G_OBJECT_CLASS (nm_session_monitor_parent_class)->finalize (object);
}
static gboolean
sessions_changed (gpointer user_data)
{
	NMSessionMonitor *monitor = NM_SESSION_MONITOR (user_data);

	g_signal_emit (monitor, signals[CHANGED_SIGNAL], 0);
	return TRUE;
}
NMSessionMonitor *
nm_session_monitor_get (void)
{
	static NMSessionMonitor *singleton = NULL;

	if (singleton)
		return g_object_ref (singleton);

	singleton = NM_SESSION_MONITOR (g_object_new (NM_TYPE_SESSION_MONITOR, NULL));
	return singleton;
}
static void
nm_session_monitor_finalize (GObject *object)
{
	NMSessionMonitor *monitor = NM_SESSION_MONITOR (object);

	if (monitor->sd_source != NULL) {
		g_source_destroy (monitor->sd_source);
		g_source_unref (monitor->sd_source);
	}

	if (G_OBJECT_CLASS (nm_session_monitor_parent_class)->finalize != NULL)
		G_OBJECT_CLASS (nm_session_monitor_parent_class)->finalize (object);
}
static void
finalize (GObject *object)
{
	NMSessionMonitor *self = NM_SESSION_MONITOR (object);

	if (self->database_monitor != NULL)
		g_object_unref (self->database_monitor);

	free_database (self);

	if (G_OBJECT_CLASS (nm_session_monitor_parent_class)->finalize != NULL)
		G_OBJECT_CLASS (nm_session_monitor_parent_class)->finalize (object);
}
static void
on_file_monitor_changed (GFileMonitor *    file_monitor,
                         GFile *           file,
                         GFile *           other_file,
                         GFileMonitorEvent event_type,
                         gpointer          user_data)
{
	NMSessionMonitor *self = NM_SESSION_MONITOR (user_data);

	/* throw away cache */
	free_database (self);

	g_signal_emit (self, signals[CHANGED], 0);
}