2003-04-06 Havoc Pennington <hp@pobox.com>

* qt/Makefile.am (dbusinclude_HEADERS): install dbus-qt.h,
	from Colin Walters

	* configure.in: fixes to Qt detection from Colin Walters

	* doc/Makefile.am: Only remove generated docbook dirs if they
	exist, from Colin Walters

	* dbus/dbus-bus.c: change how we set well-known connections to
	NULL, so that it works if a single connection is stored in
	two well-known array slots.

	* test/Makefile.am: remove a lot of stuff that isn't immediately
	useful, it's in CVS history if we want it.

	* test/test-service.c: use dbus-mainloop instead of that
	watch.[hc] crack
This commit is contained in:
Havoc Pennington 2003-04-07 02:01:53 +00:00
parent 98572905e6
commit a7f69a41d5
7 changed files with 91 additions and 25 deletions

View file

@ -1,5 +1,17 @@
2003-04-06 Havoc Pennington <hp@pobox.com>
* qt/Makefile.am (dbusinclude_HEADERS): install dbus-qt.h,
from Colin Walters
* configure.in: fixes to Qt detection from Colin Walters
* doc/Makefile.am: Only remove generated docbook dirs if they
exist, from Colin Walters
* dbus/dbus-bus.c: change how we set well-known connections to
NULL, so that it works if a single connection is stored in
two well-known array slots.
* test/Makefile.am: remove a lot of stuff that isn't immediately
useful, it's in CVS history if we want it.

View file

@ -350,9 +350,22 @@ AC_SUBST(DBUS_GLIB_THREADS_LIBS)
# Qt detection
have_qt=no
if test -n "$QTDIR" -a -f $QTDIR/include/qglobal.h; then
AC_MSG_CHECKING([for qglobal.h])
if test -n "$QTDIR" -a -f "$QTDIR/include/qglobal.h"; then
have_qt=yes
DBUS_QT_CXXFLAGS=-I$QTDIR/include
DBUS_QT_CXXFLAGS="-I$QTDIR/include"
else
for dir in "${prefix}/include/qt" "/usr/include/qt3" "/usr/include/qt" "/usr/lib/qt/include"; do
if test -f "$dir/qglobal.h"; then
have_qt=yes
DBUS_QT_CXXFLAGS="-I$dir"
fi
done
fi
if test x"$have_qt" = x"yes"; then
AC_MSG_RESULT([found])
else
AC_MSG_RESULT([not found])
fi
dnl linking to kdecore will give us a bit of help from libtool
@ -360,10 +373,10 @@ if (! kde-config >& /dev/null); then
have_qt=no
else
kdelibs=`kde-config --install lib --expandvars 2>/dev/null`
if test -z $kdelibs -a -f $kdelibs/libkdecore.la; then
if test -z $kdelibs -o ! -f $kdelibs/libkdecore.la; then
have_qt=no
else
DBUS_QT_LIBS=$kdelibs/libkdecore.la
DBUS_QT_LIBS="$kdelibs/libkdecore.la"
fi
fi

View file

@ -50,9 +50,10 @@
*/
typedef struct
{
DBusConnection *connection; /**< Connection we're associated with */
char *base_service; /**< Base service name of this connection */
DBusConnection **connection; /**< Pointer to bus_connections entry */
unsigned int is_well_known : 1; /**< Is one of the well-known connections in our global array */
} BusData;
/** The slot we have reserved to store BusData
@ -120,10 +121,14 @@ init_connections_unlocked (void)
if (!initialized)
{
const char *s;
bus_connections[0] = NULL;
bus_connections[1] = NULL;
bus_connections[2] = NULL;
int i;
i = 0;
while (i < N_BUS_TYPES)
{
bus_connections[i] = NULL;
++i;
}
/* Don't init these twice, we may run this code twice if
* init_connections_unlocked() fails midway through.
@ -238,10 +243,19 @@ bus_data_free (void *data)
{
BusData *bd = data;
if (bd->connection)
if (bd->is_well_known)
{
int i;
_DBUS_LOCK (bus);
*bd->connection = NULL;
/* We may be stored in more than one slot */
i = 0;
while (i < N_BUS_TYPES)
{
if (bus_connections[i] == bd->connection)
bus_connections[i] = NULL;
++i;
}
_DBUS_UNLOCK (bus);
}
@ -268,6 +282,8 @@ ensure_bus_data (DBusConnection *connection)
data_slot_unref ();
return NULL;
}
bd->connection = connection;
if (!dbus_connection_set_data (connection, bus_data_slot, bd,
bus_data_free))
@ -385,7 +401,7 @@ dbus_bus_get (DBusBusType type,
bd = ensure_bus_data (connection);
_dbus_assert (bd != NULL);
bd->connection = &bus_connections[type];
bd->is_well_known = TRUE;
_DBUS_UNLOCK (bus);
return connection;

View file

@ -350,6 +350,7 @@ dbus_threads_init (const DBusThreadFunctions *functions)
return TRUE;
}
/** @} */
#ifdef DBUS_BUILD_TESTS
/** Fake mutex used for debugging */
@ -489,5 +490,3 @@ _dbus_threads_init_debug (void)
}
#endif /* DBUS_BUILD_TESTS */
/** @} */

View file

@ -14,12 +14,12 @@ endif
dbus-specification.html: dbus-specification.sgml
db2html -o . --nochunks dbus-specification.sgml && \
rm -r dbus-specification/stylesheet-images && \
rmdir dbus-specification
(if test -d dbus-specification ; then rmdir dbus-specification ; fi)
dbus-test-plan.html: dbus-test-plan.sgml
db2html -o . --nochunks dbus-test-plan.sgml && \
db2html -o . --nochunks dbus-test-plan.sgml && \
rm -r dbus-test-plan/stylesheet-images && \
rmdir dbus-test-plan
(if test -d dbus-test-plan ; then rmdir dbus-test-plan ; fi)
maintainer-clean-local:
rm -f dbus-test-plan.html

View file

@ -1,7 +1,12 @@
INCLUDES=-I$(top_srcdir) $(DBUS_CLIENT_CFLAGS) $(DBUS_QT_CXXFLAGS)
dbusincludedir=$(includedir)/dbus-1.0/dbus
lib_LTLIBRARIES=libdbus-qt-1.la
dbusinclude_HEADERS= \
dbus-qt.h
libdbus_qt_1_la_SOURCES = \
dbus-qthread.cpp

View file

@ -11,10 +11,8 @@ die (const char *message)
}
static DBusHandlerResult
echo_handler (DBusMessageHandler *handler,
DBusConnection *connection,
DBusMessage *message,
void *user_data)
handle_echo (DBusConnection *connection,
DBusMessage *message)
{
DBusError error;
DBusMessage *reply;
@ -59,6 +57,25 @@ echo_handler (DBusMessageHandler *handler,
return DBUS_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
}
static DBusHandlerResult
filter_func (DBusMessageHandler *handler,
DBusConnection *connection,
DBusMessage *message,
void *user_data)
{
if (dbus_message_name_is (message, "org.freedesktop.DBus.TestSuiteEcho"))
return handle_echo (connection, message);
else if (dbus_message_name_is (message, DBUS_MESSAGE_LOCAL_DISCONNECT))
{
_dbus_loop_quit (loop);
return DBUS_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
}
else
{
return DBUS_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
}
}
int
main (int argc,
char **argv)
@ -66,7 +83,10 @@ main (int argc,
DBusConnection *connection;
DBusError error;
DBusMessageHandler *handler;
const char *to_handle[] = { "org.freedesktop.DBus.TestSuiteEcho" };
const char *to_handle[] = {
"org.freedesktop.DBus.TestSuiteEcho",
DBUS_MESSAGE_LOCAL_DISCONNECT,
};
int result;
dbus_error_init (&error);
@ -86,11 +106,12 @@ main (int argc,
if (!test_connection_setup (loop, connection))
die ("No memory\n");
handler = dbus_message_handler_new (echo_handler, NULL, NULL);
handler = dbus_message_handler_new (filter_func, NULL, NULL);
if (handler == NULL)
die ("No memory");
if (!dbus_connection_register_handler (connection, handler, to_handle, 1))
if (!dbus_connection_register_handler (connection, handler, to_handle,
_DBUS_N_ELEMENTS (to_handle)))
die ("No memory");
result = dbus_bus_acquire_service (connection, "org.freedesktop.DBus.TestSuiteEchoService",
@ -106,7 +127,7 @@ main (int argc,
_dbus_loop_run (loop);
dbus_connection_unref (connection);
dbus_message_handler_unref (handler);
_dbus_loop_unref (loop);