Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > by-pkgid > b7dfe737e63c84a66685dbd61982b62a > files > 1

powersave-0.14.0-1mdv2008.1.src.rpm

--- trunk/powersave/daemon/dbus_server.cpp	2006/10/09 14:33:10	2537
+++ trunk/powersave/daemon/dbus_server.cpp	2006/11/01 12:22:24	2606
@@ -96,6 +96,8 @@
 	*/
 	if (dbus_message_is_signal(msg, DBUS_INTERFACE_LOCAL, "Disconnected")) {
 		pDebug(DBG_ERR, "DBus daemon disconnected. Trying to reconnect...");
+		dbus_connection_unref(_connection);
+		_connection = NULL;
 		// only way I see for now to get this information
 		Powersave::Globals::main_loop->addCallback(3000, (GSourceFunc) DBus_Server::dbus_reconnect);
 		return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
@@ -234,8 +236,7 @@
 	dbus_error_init(&error);
 	int ret;
 
-	_connection = dbus_connection_open_private(DBUS_SYSTEM_BUS_SOCKET, &error);
-
+	_connection = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
 	if (dbus_error_is_set(&error)) {
 		// only throw diag message. Real error message is thrown in main loop
 		pDebug(DBG_DIAG, "dbus_connection_open_private(): Error. (%s)", error.message);
@@ -243,17 +244,14 @@
 		return NULL;
 	} else {
 		dbus_connection_set_exit_on_disconnect(_connection, 0);
-		pDebug(DBG_INFO, "dbus_connection_open_private(): Success.");
+		pDebug(DBG_INFO, "dbus_bus_get(): Success.");
 	}
 
-	dbus_bus_register(_connection, &error);
-
 	dbus_bus_request_name(_connection, PS_DBUS_SERVICE, 0, &error);
 
 	if (dbus_error_is_set(&error)) {
 		pDebug(DBG_ERR, "dbus_bus_request_name(): Error. (%s)", error.message);
 		if (_connection != NULL) {
-			dbus_connection_close(_connection);
 			dbus_connection_unref(_connection);
 		}
 		dbus_error_free(&error);