From a65587676f6791ff6a7c9ed98bbc53d740f51fa8 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Thu, 17 Mar 2005 17:48:29 +0000 Subject: 2005-03-17 Colin Walters * bus/print-introspect.c: Move to tools/. * bus/run-with-tmp-session-bus.sh: Ditto. * glib/Makefile.am (dbus-glib-bindings.h): Move generation to tools/Makefile.am. * test/glib/run-test.sh: Update to handle move of run-with-tmp-session-bus.sh. * test/glib/test-service-glib.c: Update to handle move of dbus-glib-bindings.h. * tools/print-introspect.c: Moved here from bus/, and ported to GLib bindings. * tools/run-with-tmp-session-bus.sh: Moved here from bus/. * tools/Makefile.am: Generate dbus-glib-bindings.h and dbus-bus-introspect.xml here. * tools/.cvsignore, glib/.cvsignore, bus/.cvsignore: Update. --- ChangeLog | 26 ++++++++++ bus/.cvsignore | 3 -- bus/Makefile.am | 15 +----- bus/print-introspect.c | 104 -------------------------------------- bus/run-with-tmp-session-bus.sh | 65 ------------------------ glib/.cvsignore | 1 - glib/Makefile.am | 8 --- test/glib/run-test.sh | 2 +- test/glib/test-service-glib.c | 2 +- tools/.cvsignore | 4 ++ tools/Makefile.am | 21 +++++++- tools/print-introspect.c | 83 ++++++++++++++++++++++++++++++ tools/run-with-tmp-session-bus.sh | 65 ++++++++++++++++++++++++ 13 files changed, 202 insertions(+), 197 deletions(-) delete mode 100644 bus/print-introspect.c delete mode 100755 bus/run-with-tmp-session-bus.sh create mode 100644 tools/print-introspect.c create mode 100755 tools/run-with-tmp-session-bus.sh diff --git a/ChangeLog b/ChangeLog index 8f9582f2..1fbd7654 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,29 @@ +2005-03-17 Colin Walters + + * bus/print-introspect.c: Move to tools/. + * bus/run-with-tmp-session-bus.sh: Ditto. + + * glib/Makefile.am (dbus-glib-bindings.h): Move + generation to tools/Makefile.am. + + * test/glib/run-test.sh: Update to handle move + of run-with-tmp-session-bus.sh. + + * test/glib/test-service-glib.c: Update to handle + move of dbus-glib-bindings.h. + + * tools/print-introspect.c: Moved here + from bus/, and ported to GLib bindings. + + * tools/run-with-tmp-session-bus.sh: Moved here + from bus/. + + * tools/Makefile.am: Generate dbus-glib-bindings.h + and dbus-bus-introspect.xml here. + + * tools/.cvsignore, glib/.cvsignore, bus/.cvsignore: + Update. + 2005-03-14 Colin Walters * bus/driver.c (write_args_for_direction): Use diff --git a/bus/.cvsignore b/bus/.cvsignore index 2c6c9b7e..e522ea23 100644 --- a/bus/.cvsignore +++ b/bus/.cvsignore @@ -14,7 +14,4 @@ rc.messagebus messagebus session.conf system.conf -run-with-tmp-session-bus.conf dbus-daemon.1 -print-introspect -dbus-bus-introspect.xml diff --git a/bus/Makefile.am b/bus/Makefile.am index a1fb76a0..56770656 100644 --- a/bus/Makefile.am +++ b/bus/Makefile.am @@ -77,7 +77,7 @@ endif ## we use noinst_PROGRAMS not check_PROGRAMS so that we build ## even when not doing "make check" -noinst_PROGRAMS=$(TESTS) print-introspect +noinst_PROGRAMS=$(TESTS) bus_test_SOURCES= \ $(BUS_SOURCES) \ @@ -85,20 +85,9 @@ bus_test_SOURCES= \ bus_test_LDADD=$(top_builddir)/dbus/libdbus-convenience.la $(DBUS_BUS_LIBS) -print_introspect_SOURCES = print-introspect.c -print_introspect_LDADD = $(top_builddir)/dbus/libdbus-convenience.la $(DBUS_BUS_LIBS) - -run-with-tmp-session-bus.sh: dbus-daemon - -all-local: dbus-bus-introspect.xml - -dbus-bus-introspect.xml: $(srcdir)/run-with-tmp-session-bus.sh dbus-daemon - DBUS_TOP_BUILDDIR=$(top_builddir) $(srcdir)/run-with-tmp-session-bus.sh ./print-introspect org.freedesktop.DBus /org/freedesktop/DBus > dbus-bus-introspect.xml.tmp && mv dbus-bus-introspect.xml.tmp dbus-bus-introspect.xml - ## mop up the gcov files clean-local: /bin/rm *.bb *.bbg *.da *.gcov || true - /bin/rm -f run-with-tmp-session-bus.conf install-data-hook: $(mkinstalldirs) $(DESTDIR)/$(localstatedir)/run/dbus @@ -136,4 +125,4 @@ man_MANS = dbus-daemon.1 #### Extra dist -EXTRA_DIST=$(CONFIG_IN_FILES) $(SCRIPT_IN_FILES) $(man_MANS) $(MAN_IN_FILES) run-with-tmp-session-bus.sh +EXTRA_DIST=$(CONFIG_IN_FILES) $(SCRIPT_IN_FILES) $(man_MANS) $(MAN_IN_FILES) diff --git a/bus/print-introspect.c b/bus/print-introspect.c deleted file mode 100644 index c040af41..00000000 --- a/bus/print-introspect.c +++ /dev/null @@ -1,104 +0,0 @@ -/* -*- mode: C; c-file-style: "gnu" -*- */ -/* gather-introspect.c Dump introspection data from service to stdout - * - * Copyright (C) 2005 Red Hat, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include -#include -#include - -#include - -static void -usage (char *name, int ecode) -{ - fprintf (stderr, "Usage: %s \n", name); - exit (ecode); -} - -int -main (int argc, char *argv[]) -{ - DBusConnection *connection; - DBusError error; - DBusMessage *message; - DBusMessage *reply; - const char *service; - const char *path; - const char *introspect_data; - - if (argc != 3) - usage (argv[0], 1); - - service = argv[1]; - path = argv[2]; - - dbus_error_init (&error); - connection = dbus_bus_get (DBUS_BUS_SESSION, &error); - if (connection == NULL) - { - fprintf (stderr, "Failed to open connection to session bus: %s\n", - error.message); - dbus_error_free (&error); - exit (1); - } - - message = dbus_message_new_method_call (NULL, - path, - DBUS_INTERFACE_INTROSPECTABLE, - "Introspect"); - if (message == NULL) - { - fprintf (stderr, "Couldn't allocate D-BUS message\n"); - exit (1); - } - - if (!dbus_message_set_destination (message, service)) - { - fprintf (stderr, "Not enough memory\n"); - exit (1); - } - - reply = dbus_connection_send_with_reply_and_block (connection, - message, - -1, - &error); - dbus_message_unref (message); - if (dbus_error_is_set (&error)) - { - fprintf (stderr, "Error: %s\n", error.message); - exit (1); - } - - if (!dbus_message_get_args (reply, &error, - DBUS_TYPE_STRING, - &introspect_data, - DBUS_TYPE_INVALID)) - { - fprintf (stderr, "Error: %s\n", error.message); - exit (1); - } - printf ("%s", introspect_data); - - dbus_message_unref (reply); - - dbus_connection_disconnect (connection); - - exit (0); -} diff --git a/bus/run-with-tmp-session-bus.sh b/bus/run-with-tmp-session-bus.sh deleted file mode 100755 index ce077d72..00000000 --- a/bus/run-with-tmp-session-bus.sh +++ /dev/null @@ -1,65 +0,0 @@ -#! /bin/bash - -SCRIPTNAME=$0 -WRAPPED_SCRIPT=$1 -shift - -function die() -{ - if ! test -z "$DBUS_SESSION_BUS_PID" ; then - echo "killing message bus "$DBUS_SESSION_BUS_PID >&2 - kill -9 $DBUS_SESSION_BUS_PID - fi - echo $SCRIPTNAME: $* >&2 - exit 1 -} - -if test -z "$DBUS_TOP_BUILDDIR" ; then - die "Must set DBUS_TOP_BUILDDIR" -fi - -## convenient to be able to ctrl+C without leaking the message bus process -trap 'die "Received SIGINT"' SIGINT - -CONFIG_FILE=./run-with-tmp-session-bus.conf -SERVICE_DIR="$DBUS_TOP_BUILDDIR/test/data/valid-service-files" -ESCAPED_SERVICE_DIR=`echo $SERVICE_DIR | sed -e 's/\//\\\\\\//g'` -echo "escaped service dir is: $ESCAPED_SERVICE_DIR" >&2 - -## create a configuration file based on the standard session.conf -cat $DBUS_TOP_BUILDDIR/bus/session.conf | \ - sed -e 's/.*$/'$ESCAPED_SERVICE_DIR'<\/servicedir>/g' | \ - sed -e 's/ $CONFIG_FILE - -echo "Created configuration file $CONFIG_FILE" >&2 - -export PATH=$DBUS_TOP_BUILDDIR/bus:$PATH -## the libtool script found by the path search should already do this, but -export LD_LIBRARY_PATH=$DBUS_TOP_BUILDDIR/dbus/.libs:$LD_LIBRARY_PATH - -unset DBUS_SESSION_BUS_ADDRESS -unset DBUS_SESSION_BUS_PID - -echo "Running $DBUS_TOP_BUILDDIR/tools/dbus-launch --sh-syntax --config-file=$CONFIG_FILE" >&2 - -eval `$DBUS_TOP_BUILDDIR/tools/dbus-launch --sh-syntax --config-file=$CONFIG_FILE` - -if test -z "$DBUS_SESSION_BUS_PID" ; then - die "Failed to launch message bus for introspection generation to run" -fi - -echo "Started bus pid $DBUS_SESSION_BUS_PID at $DBUS_SESSION_BUS_ADDRESS" >&2 - -# Execute wrapped script -echo "Running $WRAPPED_SCRIPT $@" >&2 -$WRAPPED_SCRIPT "$@" || die "script \"$WRAPPED_SCRIPT\" failed" - -kill -TERM $DBUS_SESSION_BUS_PID || die "Message bus vanished! should not have happened" && echo "Killed daemon $DBUS_SESSION_BUS_PID" >&2 - -sleep 2 - -## be sure it really died -kill -9 $DBUS_SESSION_BUS_PID > /dev/null 2>&1 || true - -exit 0 diff --git a/glib/.cvsignore b/glib/.cvsignore index e1a6372c..4e197a9f 100644 --- a/glib/.cvsignore +++ b/glib/.cvsignore @@ -6,7 +6,6 @@ Makefile.in *.la dbus-glib-test dbus-binding-tool -dbus-glib-bindings.h *.bb *.bbg *.da diff --git a/glib/Makefile.am b/glib/Makefile.am index b4256fac..6d81e7d1 100644 --- a/glib/Makefile.am +++ b/glib/Makefile.am @@ -2,9 +2,6 @@ INCLUDES=-I$(top_srcdir) $(DBUS_CLIENT_CFLAGS) $(DBUS_GLIB_CFLAGS) $(DBUS_GLIB_T lib_LTLIBRARIES=libdbus-glib-1.la -libdbus_glib_HEADERS = dbus-glib-bindings.h -libdbus_glibdir = $(includedir)/dbus-1.0/dbus - libdbus_glib_1_la_SOURCES = \ dbus-glib.c \ dbus-gmain.c \ @@ -50,11 +47,6 @@ dbus_binding_tool_SOURCES = \ dbus_binding_tool_LDADD= -lexpat libdbus-gtool.la -dbus-glib-bindings.h: $(top_builddir)/bus/dbus-bus-introspect.xml dbus-binding-tool - ./dbus-binding-tool --ignore-unsupported --mode=glib-client --output=dbus-glib-bindings.h $(top_builddir)/bus/dbus-bus-introspect.xml # FIXME - remove --ignore-unsupported when we can do arrays - -BUILT_SOURCES = dbus-glib-bindings.h - ## we just rebuilt these manually and check them into cvs; easier than ## convincing automake/make to do this properly regenerate-built-sources: diff --git a/test/glib/run-test.sh b/test/glib/run-test.sh index 51d4a713..86f1aee8 100755 --- a/test/glib/run-test.sh +++ b/test/glib/run-test.sh @@ -10,7 +10,7 @@ export DBUS_TEST_GLIB_RUN_TEST_SCRIPT=1 if test -z "$DBUS_TEST_GLIB_IN_RUN_TEST"; then DBUS_TEST_GLIB_IN_RUN_TEST=1 export DBUS_TEST_GLIB_IN_RUN_TEST - exec $DBUS_TOP_BUILDDIR/bus/run-with-tmp-session-bus.sh $SCRIPTNAME $MODE + exec $DBUS_TOP_BUILDDIR/tools/run-with-tmp-session-bus.sh $SCRIPTNAME $MODE fi if test x$MODE = xprofile ; then diff --git a/test/glib/test-service-glib.c b/test/glib/test-service-glib.c index fef8a9da..d929999d 100644 --- a/test/glib/test-service-glib.c +++ b/test/glib/test-service-glib.c @@ -3,7 +3,7 @@ /* NOTE - outside of D-BUS core this would be * include */ -#include "glib/dbus-glib-bindings.h" +#include "tools/dbus-glib-bindings.h" #include #include #include diff --git a/tools/.cvsignore b/tools/.cvsignore index c9dffa00..ae3996bd 100644 --- a/tools/.cvsignore +++ b/tools/.cvsignore @@ -13,3 +13,7 @@ dbus-launch *.gcov *.da dbus-viewer +dbus-glib-bindings.h +run-with-tmp-session-bus.conf +print-introspect +dbus-bus-introspect.xml diff --git a/tools/Makefile.am b/tools/Makefile.am index 7cc6cadf..aeb6d6ce 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -2,6 +2,15 @@ INCLUDES=-I$(top_srcdir) $(DBUS_CLIENT_CFLAGS) $(DBUS_GLIB_CFLAGS) $(DBUS_X_CFLA if HAVE_GLIB GLIB_TOOLS=dbus-monitor + +libdbus_glib_HEADERS = dbus-glib-bindings.h +libdbus_glibdir = $(includedir)/dbus-1.0/dbus + +dbus-glib-bindings.h: dbus-bus-introspect.xml $(top_builddir)/glib/dbus-binding-tool + $(top_builddir)/glib/dbus-binding-tool --ignore-unsupported --mode=glib-client --output=dbus-glib-bindings.h dbus-bus-introspect.xml # FIXME - remove --ignore-unsupported when we can do arrays + +BUILT_SOURCES = dbus-glib-bindings.h + else GLIB_TOOLS= endif @@ -12,6 +21,16 @@ else GTK_TOOLS= endif +noinst_PROGRAMS = print-introspect + +print_introspect_SOURCES = print-introspect.c +print_introspect_LDADD = $(top_builddir)/glib/libdbus-glib-1.la + +run-with-tmp-session-bus.sh: $(top_builddir)/bus/dbus-daemon dbus-launch + +dbus-bus-introspect.xml: $(srcdir)/run-with-tmp-session-bus.sh print-introspect $(top_builddir)/bus/dbus-daemon + DBUS_TOP_BUILDDIR=$(top_builddir) $(srcdir)/run-with-tmp-session-bus.sh ./print-introspect org.freedesktop.DBus /org/freedesktop/DBus > dbus-bus-introspect.xml.tmp && mv dbus-bus-introspect.xml.tmp dbus-bus-introspect.xml + bin_PROGRAMS=dbus-send $(GLIB_TOOLS) dbus-launch dbus-cleanup-sockets $(GTK_TOOLS) dbus_send_SOURCES= \ @@ -43,6 +62,6 @@ dbus_launch_LDADD= $(DBUS_X_LIBS) dbus_viewer_LDADD= $(DBUS_GLIB_TOOL_LIBS) $(top_builddir)/glib/libdbus-gtool.la $(DBUS_GTK_THREADS_LIBS) man_MANS = dbus-send.1 dbus-monitor.1 dbus-launch.1 dbus-cleanup-sockets.1 -EXTRA_DIST = $(man_MANS) +EXTRA_DIST = $(man_MANS) run-with-tmp-session-bus.sh diff --git a/tools/print-introspect.c b/tools/print-introspect.c new file mode 100644 index 00000000..9784af00 --- /dev/null +++ b/tools/print-introspect.c @@ -0,0 +1,83 @@ +/* -*- mode: C; c-file-style: "gnu" -*- */ +/* gather-introspect.c Dump introspection data from service to stdout + * + * Copyright (C) 2005 Red Hat, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include +#include +#include + +#include + +static void +usage (char *name, int ecode) +{ + fprintf (stderr, "Usage: %s \n", name); + exit (ecode); +} + +int +main (int argc, char *argv[]) +{ + DBusGConnection *connection; + DBusGProxy *proxy; + DBusGPendingCall *call; + GError *error; + const char *service; + const char *path; + const char *introspect_data; + + if (argc != 3) + usage (argv[0], 1); + + service = argv[1]; + path = argv[2]; + + g_type_init (); + + error = NULL; + connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); + if (connection == NULL) + { + fprintf (stderr, "Failed to open connection to session bus: %s\n", + error->message); + g_clear_error (&error); + exit (1); + } + + proxy = dbus_g_proxy_new_for_name (connection, + service, path, + DBUS_INTERFACE_INTROSPECTABLE); + call = dbus_g_proxy_begin_call (proxy, "Introspect", DBUS_TYPE_INVALID); + if (!dbus_g_proxy_end_call (proxy, call, &error, DBUS_TYPE_STRING, + &introspect_data, DBUS_TYPE_INVALID)) + { + fprintf (stderr, "Failed to get introspection data: %s\n", + error->message); + g_clear_error (&error); + exit (1); + } + + printf ("%s", introspect_data); + + dbus_g_pending_call_unref (call); + g_object_unref (proxy); + + exit (0); +} diff --git a/tools/run-with-tmp-session-bus.sh b/tools/run-with-tmp-session-bus.sh new file mode 100755 index 00000000..ce077d72 --- /dev/null +++ b/tools/run-with-tmp-session-bus.sh @@ -0,0 +1,65 @@ +#! /bin/bash + +SCRIPTNAME=$0 +WRAPPED_SCRIPT=$1 +shift + +function die() +{ + if ! test -z "$DBUS_SESSION_BUS_PID" ; then + echo "killing message bus "$DBUS_SESSION_BUS_PID >&2 + kill -9 $DBUS_SESSION_BUS_PID + fi + echo $SCRIPTNAME: $* >&2 + exit 1 +} + +if test -z "$DBUS_TOP_BUILDDIR" ; then + die "Must set DBUS_TOP_BUILDDIR" +fi + +## convenient to be able to ctrl+C without leaking the message bus process +trap 'die "Received SIGINT"' SIGINT + +CONFIG_FILE=./run-with-tmp-session-bus.conf +SERVICE_DIR="$DBUS_TOP_BUILDDIR/test/data/valid-service-files" +ESCAPED_SERVICE_DIR=`echo $SERVICE_DIR | sed -e 's/\//\\\\\\//g'` +echo "escaped service dir is: $ESCAPED_SERVICE_DIR" >&2 + +## create a configuration file based on the standard session.conf +cat $DBUS_TOP_BUILDDIR/bus/session.conf | \ + sed -e 's/.*$/'$ESCAPED_SERVICE_DIR'<\/servicedir>/g' | \ + sed -e 's/ $CONFIG_FILE + +echo "Created configuration file $CONFIG_FILE" >&2 + +export PATH=$DBUS_TOP_BUILDDIR/bus:$PATH +## the libtool script found by the path search should already do this, but +export LD_LIBRARY_PATH=$DBUS_TOP_BUILDDIR/dbus/.libs:$LD_LIBRARY_PATH + +unset DBUS_SESSION_BUS_ADDRESS +unset DBUS_SESSION_BUS_PID + +echo "Running $DBUS_TOP_BUILDDIR/tools/dbus-launch --sh-syntax --config-file=$CONFIG_FILE" >&2 + +eval `$DBUS_TOP_BUILDDIR/tools/dbus-launch --sh-syntax --config-file=$CONFIG_FILE` + +if test -z "$DBUS_SESSION_BUS_PID" ; then + die "Failed to launch message bus for introspection generation to run" +fi + +echo "Started bus pid $DBUS_SESSION_BUS_PID at $DBUS_SESSION_BUS_ADDRESS" >&2 + +# Execute wrapped script +echo "Running $WRAPPED_SCRIPT $@" >&2 +$WRAPPED_SCRIPT "$@" || die "script \"$WRAPPED_SCRIPT\" failed" + +kill -TERM $DBUS_SESSION_BUS_PID || die "Message bus vanished! should not have happened" && echo "Killed daemon $DBUS_SESSION_BUS_PID" >&2 + +sleep 2 + +## be sure it really died +kill -9 $DBUS_SESSION_BUS_PID > /dev/null 2>&1 || true + +exit 0 -- cgit