151 lines
4.1 KiB
Diff
151 lines
4.1 KiB
Diff
diff -urN dbus-0.22.orig/tools/dbus-monitor.1 dbus-0.22/tools/dbus-monitor.1
|
|
--- dbus-0.22.orig/tools/dbus-monitor.1 2004-10-10 20:47:19.906823680 +1000
|
|
+++ dbus-0.22/tools/dbus-monitor.1 2004-10-10 20:47:27.791625008 +1000
|
|
@@ -9,6 +9,7 @@
|
|
.PP
|
|
.B dbus-monitor
|
|
[\-\-system | \-\-session]
|
|
+[watch expressions]
|
|
|
|
.SH DESCRIPTION
|
|
|
|
@@ -25,6 +26,11 @@
|
|
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 @@
|
|
.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.
|
|
|
|
--- dbus-0.22-1ubuntu1/tools/dbus-monitor.c 2004-08-10 13:03:37.000000000 +1000
|
|
+++ dbus-0.22/tools/dbus-monitor.c 2004-10-10 21:38:08.532362152 +1000
|
|
@@ -45,7 +45,7 @@
|
|
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);
|
|
}
|
|
|
|
@@ -56,8 +56,8 @@
|
|
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];
|
|
@@ -69,14 +69,18 @@
|
|
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);
|
|
@@ -92,26 +102,45 @@
|
|
|
|
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);
|