Newbie trying to get things to work...

Tako Schotanus quintesse@palacio-cristal.com
Thu, 26 Feb 2004 15:34:03 +0100


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
<br>
Thanks, the patch applied without any problems and I now actually get
some response from the monitor. Only thing is that most of it is in the
form of access denied errors like this one:<br>
<br>
method call interface=org.freedesktop.DBus; member=Hello; sender=:1.14<br>
error name=org.freedesktop.DBus.Error.AccessDenied;
sender=org.freedesktop.DBus<br>
string:A security policy in place prevents this recipient from
receiving this message from this sender, see message bus configuration
file (rejected message had interface "(unset)" member "(unset)" error
name "org.freedesktop.DBus.Error.UnknownMethod" destination ":1.14"
reply serial 1 requested_reply=0)<br>
<br>
The session.conf has all rights set to "allow" (the deafult) so that
shouldn't be a problem and the monitor I start like this:<br>
<br>
dbus-monitor --session ''<br>
<br>
which seems to work as a wildcard for just any message that passes.<br>
<br>
So is there anything else that I need to do to get this to work?<br>
<br>
Cheers,<br>
&nbsp;-Tako<br>
<br>
PS: Does any of the tools allow "discovery" like you can do with dcop?<br>
The way that you can just&nbsp; do 'dcop' for a list of
applications/services and 'dcop &lt;service&gt;' for the list of
interfaces that it supports, 'dcop &lt;service&gt; &lt;interface&gt;'
for its list of messages etc.<br>
<br>
<br>
Daniel Silverstone wrote:
<blockquote cite="mid1077800417.30242.23.camel@kenton.mips.com"
 type="cite">
  <pre wrap="">On Thu, 2004-02-26 at 12:49, Tako Schotanus wrote:
  </pre>
  <blockquote type="cite">
    <pre wrap="">I would have expected at least some kind of reaction from either the 
monitor or the send command or am I missing something important here. Of 
course there is no service foo/bar, but like I said I would have 
expected at least some kind of message.
    </pre>
  </blockquote>
  <pre wrap=""><!---->
IME, the dbus-monitor code is fairly useless without a simple patch to
get it to be able to listen out for events.

The Debian packages of 0.20 carry that patch and I have attached it here
for you. 

I don't know if it'll apply to CVS though, so good luck.

D.

  </pre>
  <pre wrap="">
<hr width="90%" size="4">
--- dbus-0.20/tools/dbus-monitor.1.old	2004-01-08 22:41:13.000000000 +0000
+++ dbus-0.20/tools/dbus-monitor.1	2004-01-08 22:40:34.000000000 +0000
@@ -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.20/tools/dbus-monitor.c.old	2004-01-08 22:41:42.000000000 +0000
+++ dbus-0.20/tools/dbus-monitor.c	2004-01-08 22:35:56.000000000 +0000
@@ -47,7 +47,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);
 }
 
@@ -74,11 +74,10 @@
 	break;
       else if (arg[0] == '-')
 	usage (argv[0], 1);
+      else
+        break;
     }
 
-  if (argc &gt; 2)
-    usage (argv[0], 1);
-
   loop = g_main_loop_new (NULL, FALSE);
 
   dbus_error_init (&amp;error);
@@ -94,6 +93,18 @@
 
   dbus_connection_setup_with_g_main (connection, NULL);
 
+  while (i &lt; argc) 
+    {
+      dbus_bus_add_match (connection, argv[i++], &amp;error);
+      if (dbus_error_is_set (&amp;error))
+        {
+          fprintf (stderr, "Failed to set up match \"%s\": %s\n",
+                   argv[i-1], error.message);
+          dbus_error_free (&amp;error);
+          exit (1);
+        }
+    }
+  
   dbus_connection_add_filter (connection, filter_func, NULL, NULL);
 
   g_main_loop_run (loop);
  </pre>
</blockquote>
</body>
</html>