dbus/dbus dbus-bus.c,1.44,1.45 dbus-bus.h,1.14,1.15

John Palmieri johnp at freedesktop.org
Mon Sep 26 11:49:55 PDT 2005


Update of /cvs/dbus/dbus/dbus
In directory gabe:/tmp/cvs-serv579/dbus

Modified Files:
	dbus-bus.c dbus-bus.h 
Log Message:
* Integrate patches from Lennart Poettering <mzsqb at 0pointer.de>:
- dbus/dbus-bus.c
(internal_bus_get): new method that take over the heavy lifting
of dbus_bus_get and adds the ability to get a private connection
to the bus
(dbus_bus_get): wrapper to internal_bus_get that provides the same
interface as in previous versions
(dbus_bus_get_private): new method that is a wrapper to 
internal_bus_get to get a private connection to the bus

- dbus/dbus-bus.h
(dbus_bus_get_private): add as a public libdbus interface

- dbus-1.pc.in: output system_bus_default_address and 
sysconfdir variables so apps can use them when compiling


Index: dbus-bus.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-bus.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- dbus-bus.c	2 Aug 2005 11:26:59 -0000	1.44
+++ dbus-bus.c	26 Sep 2005 18:49:53 -0000	1.45
@@ -302,27 +302,9 @@
   return bd;
 }
 
-/** @} */ /* end of implementation details docs */
-
-/**
- * @addtogroup DBusBus
- * @{
- */
-
-/**
- * Connects to a bus daemon and registers the client with it.  If a
- * connection to the bus already exists, then that connection is
- * returned.  Caller owns a reference to the bus.
- *
- * @todo alex thinks we should nullify the connection when we get a disconnect-message.
- *
- * @param type bus type
- * @param error address where an error can be returned.
- * @returns a DBusConnection with new ref
- */
-DBusConnection *
-dbus_bus_get (DBusBusType  type,
-	      DBusError   *error)
+static DBusConnection *
+internal_bus_get (DBusBusType  type,
+	      DBusError   *error, dbus_bool_t private)
 {
   const char *address;
   DBusConnection *connection;
@@ -356,7 +338,7 @@
       bus_connection_addresses[activation_bus_type] != NULL)
     type = activation_bus_type;
   
-  if (bus_connections[type] != NULL)
+  if (!private && bus_connections[type] != NULL)
     {
       connection = bus_connections[type];
       dbus_connection_ref (connection);
@@ -374,7 +356,10 @@
       return NULL;
     }
 
-  connection = dbus_connection_open (address, error);
+  if (private)
+    connection = dbus_connection_open_private(address, error);
+  else
+    connection = dbus_connection_open (address, error);
   
   if (!connection)
     {
@@ -399,7 +384,9 @@
       return NULL;
     }
 
-  bus_connections[type] = connection;
+  if (!private)
+    bus_connections[type] = connection;
+  
   bd = ensure_bus_data (connection);
   _dbus_assert (bd != NULL);
 
@@ -410,6 +397,46 @@
 }
 
 
+/** @} */ /* end of implementation details docs */
+
+/**
+ * @addtogroup DBusBus
+ * @{
+ */
+
+/**
+ * Connects to a bus daemon and registers the client with it.  If a
+ * connection to the bus already exists, then that connection is
+ * returned.  Caller owns a reference to the bus.
+ *
+ * @todo alex thinks we should nullify the connection when we get a disconnect-message.
+ *
+ * @param type bus type
+ * @param error address where an error can be returned.
+ * @returns a DBusConnection with new ref
+ */
+DBusConnection *
+dbus_bus_get (DBusBusType  type,
+	      DBusError   *error) {
+  return internal_bus_get(type, error, FALSE);
+}
+
+/**
+ * Connects to a bus daemon and registers the client with it.  Unlike
+ * dbus_bus_get(), always creates a new connection. This connection
+ * will not be saved or recycled by libdbus. Caller owns a reference
+ * to the bus.
+ *
+ * @param type bus type
+ * @param error address where an error can be returned.
+ * @returns a DBusConnection with new ref
+ */
+DBusConnection *
+dbus_bus_get_private (DBusBusType  type,
+	      DBusError   *error) {
+  return internal_bus_get(type, error, TRUE);
+}
+
 /**
  * Registers a connection with the bus. This must be the first
  * thing an application does when connecting to the message bus.

Index: dbus-bus.h
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-bus.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- dbus-bus.h	18 Jan 2005 20:42:15 -0000	1.14
+++ dbus-bus.h	26 Sep 2005 18:49:53 -0000	1.15
@@ -33,6 +33,9 @@
 
 DBusConnection *dbus_bus_get              (DBusBusType     type,
 					   DBusError      *error);
+DBusConnection *dbus_bus_get_private      (DBusBusType     type,
+					   DBusError      *error);
+
 dbus_bool_t     dbus_bus_register         (DBusConnection *connection,
 					   DBusError      *error);
 dbus_bool_t     dbus_bus_set_unique_name  (DBusConnection *connection,



More information about the dbus-commit mailing list