From 2d74492ba2c61a41d9d22a8872806a8184acef16 Mon Sep 17 00:00:00 2001 From: Robert McQueen Date: Sat, 29 Oct 2005 17:02:58 +0000 Subject: 2005-10-29 Robert McQueen * glib/Makefile.am, glib/examples/Makefile.am, glib/examples/statemachine/Makefile.am: Merge patch from Ubuntu by Daniel Stone to replace explicit calls to libtool with $(LIBTOOL). * test/python/.cvsignore: Add run-with-tmp-session-bus.conf. * tools/dbus-monitor.1, tools/dbus-monitor.c: Merge dbus-monitor patch from Ubuntu by Daniel Silverstone to allow specifying match rules on the command line. --- ChangeLog | 12 ++++++ glib/Makefile.am | 2 +- glib/examples/Makefile.am | 4 +- glib/examples/statemachine/Makefile.am | 4 +- test/python/.cvsignore | 1 + tools/dbus-monitor.1 | 15 +++++++ tools/dbus-monitor.c | 77 ++++++++++++++++++++++------------ 7 files changed, 83 insertions(+), 32 deletions(-) diff --git a/ChangeLog b/ChangeLog index f30b3455..626aa79c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2005-10-29 Robert McQueen + + * glib/Makefile.am, glib/examples/Makefile.am, + glib/examples/statemachine/Makefile.am: Merge patch from Ubuntu by + Daniel Stone to replace explicit calls to libtool with $(LIBTOOL). + + * test/python/.cvsignore: Add run-with-tmp-session-bus.conf. + + * tools/dbus-monitor.1, tools/dbus-monitor.c: Merge dbus-monitor patch + from Ubuntu by Daniel Silverstone to allow specifying match rules on + the command line. + 2005-10-27 Ross Burton * dbus/dbus-marshal-header.c: diff --git a/glib/Makefile.am b/glib/Makefile.am index 6e5c78ee..f87145e2 100644 --- a/glib/Makefile.am +++ b/glib/Makefile.am @@ -5,7 +5,7 @@ INCLUDES=-I$(top_srcdir) $(DBUS_CLIENT_CFLAGS) $(DBUS_GLIB_CFLAGS) $(DBUS_GLIB_T lib_LTLIBRARIES=libdbus-glib-1.la dbus-glib-error-switch.h: $(top_srcdir)/dbus/dbus-protocol.h make-dbus-glib-error-switch.sh - libtool --mode=execute $(srcdir)/make-dbus-glib-error-switch.sh $(top_srcdir)/dbus/dbus-protocol.h $@ + $(LIBTOOL) --mode=execute $(srcdir)/make-dbus-glib-error-switch.sh $(top_srcdir)/dbus/dbus-protocol.h $@ BUILT_SOURCES = dbus-glib-error-switch.h diff --git a/glib/examples/Makefile.am b/glib/examples/Makefile.am index e0f825ce..34b9cb8b 100644 --- a/glib/examples/Makefile.am +++ b/glib/examples/Makefile.am @@ -15,7 +15,7 @@ example_service_LDADD= $(top_builddir)/glib/libdbus-glib-1.la BUILT_SOURCES = example-service-glue.h example-service-glue.h: example-service.xml - libtool --mode=execute $(top_builddir)/glib/dbus-binding-tool --prefix=some_object --mode=glib-server --output=example-service-glue.h $(srcdir)/example-service.xml + $(LIBTOOL) --mode=execute $(top_builddir)/glib/dbus-binding-tool --prefix=some_object --mode=glib-server --output=example-service-glue.h $(srcdir)/example-service.xml ## Makefile.am bits for another client/server pair @@ -31,7 +31,7 @@ example_signal_emitter_LDADD= $(top_builddir)/glib/libdbus-glib-1.la BUILT_SOURCES += example-signal-emitter-glue.h example-signal-emitter-glue.h: example-signal-emitter.xml - libtool --mode=execute $(top_builddir)/glib/dbus-binding-tool --prefix=test_object --mode=glib-server --output=example-signal-emitter-glue.h $(srcdir)/example-signal-emitter.xml + $(LIBTOOL) --mode=execute $(top_builddir)/glib/dbus-binding-tool --prefix=test_object --mode=glib-server --output=example-signal-emitter-glue.h $(srcdir)/example-signal-emitter.xml CLEANFILES = $(BUILT_SOURCES) diff --git a/glib/examples/statemachine/Makefile.am b/glib/examples/statemachine/Makefile.am index 8395457f..0fea83ed 100644 --- a/glib/examples/statemachine/Makefile.am +++ b/glib/examples/statemachine/Makefile.am @@ -19,10 +19,10 @@ statemachine_client_LDADD= $(top_builddir)/glib/libdbus-glib-1.la $(DBUS_GTK_THR BUILT_SOURCES = statemachine-server-glue.h statemachine-glue.h statemachine-server-glue.h: statemachine-server.xml - libtool --mode=execute $(top_builddir)/glib/dbus-binding-tool --prefix=sm_server --mode=glib-server --output=$@ $< + $(LIBTOOL) --mode=execute $(top_builddir)/glib/dbus-binding-tool --prefix=sm_server --mode=glib-server --output=$@ $< statemachine-glue.h: statemachine.xml - libtool --mode=execute $(top_builddir)/glib/dbus-binding-tool --prefix=sm_object --mode=glib-server --output=$@ $< + $(LIBTOOL) --mode=execute $(top_builddir)/glib/dbus-binding-tool --prefix=sm_object --mode=glib-server --output=$@ $< sm-marshal.c: Makefile sm-marshal.list @GLIB_GENMARSHAL@ --prefix=sm_marshal $(srcdir)/sm-marshal.list --header --body > $@.tmp && mv $@.tmp $@ diff --git a/test/python/.cvsignore b/test/python/.cvsignore index 282522db..f5e130db 100644 --- a/test/python/.cvsignore +++ b/test/python/.cvsignore @@ -1,2 +1,3 @@ Makefile Makefile.in +run-with-tmp-session-bus.conf diff --git a/tools/dbus-monitor.1 b/tools/dbus-monitor.1 index d6a780dd..6a8a2126 100644 --- a/tools/dbus-monitor.1 +++ b/tools/dbus-monitor.1 @@ -9,6 +9,7 @@ dbus-monitor \- debug probe to print message bus messages .PP .B dbus-monitor [\-\-system | \-\-session] +[watch expressions] .SH DESCRIPTION @@ -25,6 +26,11 @@ The \-\-system and \-\-session options direct \fIdbus-monitor\fP to monitor the system or session buses respectively. If neither is specified, \fIdbus-monitor\fP monitors the session bus. +.PP +In order to get \fIdbus-monitor\fP to see the messages you are interested +in, you should specify a set of watch expressions as you would expect to +be passed to the \fIdbus_bus_add_watch\fP function. + .PP The message bus configuration may keep \fIdbus-monitor\fP from seeing all messages, especially if you run the monitor as a non-root user. @@ -37,6 +43,15 @@ Monitor the system message bus. .I "--session" Monitor the session message bus. (This is the default.) +.SH EXAMPLE +Here is an example of using dbus-monitor to watch for the gnome typing +monitor to say things +.nf + + dbus-monitor "type='signal',sender='org.gnome.TypingMonitor',interface='org.gnome.TypingMonitor'" + +.fi + .SH AUTHOR dbus-monitor was written by Philip Blundell. diff --git a/tools/dbus-monitor.c b/tools/dbus-monitor.c index 9bd95ea3..d768cad3 100644 --- a/tools/dbus-monitor.c +++ b/tools/dbus-monitor.c @@ -49,7 +49,7 @@ filter_func (DBusConnection *connection, static void usage (char *name, int ecode) { - fprintf (stderr, "Usage: %s [--system | --session]\n", name); + fprintf (stderr, "Usage: %s [--system | --session] [watch expressions]\n", name); exit (ecode); } @@ -60,8 +60,8 @@ main (int argc, char *argv[]) DBusError error; DBusBusType type = DBUS_BUS_SESSION; GMainLoop *loop; - int i; - + int i = 0, j = 0, numFilters = 0; + char **filters = NULL; for (i = 1; i < argc; i++) { char *arg = argv[i]; @@ -73,14 +73,18 @@ main (int argc, char *argv[]) else if (!strcmp (arg, "--help")) usage (argv[0], 0); else if (!strcmp (arg, "--")) - break; + continue; else if (arg[0] == '-') usage (argv[0], 1); + else { + numFilters++; + filters = (char **)realloc(filters, numFilters * sizeof(char *)); + filters[j] = (char *)malloc((strlen(arg) + 1) * sizeof(char *)); + snprintf(filters[j], strlen(arg) + 1, "%s", arg); + j++; + } } - if (argc > 2) - usage (argv[0], 1); - loop = g_main_loop_new (NULL, FALSE); dbus_error_init (&error); @@ -96,26 +100,45 @@ main (int argc, char *argv[]) dbus_connection_setup_with_g_main (connection, NULL); - dbus_bus_add_match (connection, - "type='signal'", - &error); - if (dbus_error_is_set (&error)) - goto lose; - dbus_bus_add_match (connection, - "type='method_call'", - &error); - if (dbus_error_is_set (&error)) - goto lose; - dbus_bus_add_match (connection, - "type='method_return'", - &error); - if (dbus_error_is_set (&error)) - goto lose; - dbus_bus_add_match (connection, - "type='error'", - &error); - if (dbus_error_is_set (&error)) - goto lose; + if (numFilters) + { + for (i = 0; i < j; i++) + { + dbus_bus_add_match (connection, filters[i], &error); + if (dbus_error_is_set (&error)) + { + fprintf (stderr, "Failed to setup match \"%s\": %s\n", + filters[i], error.message); + dbus_error_free (&error); + exit (1); + } + free(filters[i]); + } + } + else + { + dbus_bus_add_match (connection, + "type='signal'", + &error); + if (dbus_error_is_set (&error)) + goto lose; + dbus_bus_add_match (connection, + "type='method_call'", + &error); + if (dbus_error_is_set (&error)) + goto lose; + dbus_bus_add_match (connection, + "type='method_return'", + &error); + if (dbus_error_is_set (&error)) + goto lose; + dbus_bus_add_match (connection, + "type='error'", + &error); + if (dbus_error_is_set (&error)) + goto lose; + } + if (!dbus_connection_add_filter (connection, filter_func, NULL, NULL)) { fprintf (stderr, "Couldn't add filter!\n"); exit (1); -- cgit