Signal filtering

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Signal filtering

Philip Van Hoof
Hi there,

At this moment I'm working on a specification. For the specification I
will have use the D-BUS signal filtering features.

I was wondering what the status of this feature is. If it's implemented
and ready for use I'd like to know how I can use it. I'd also like to
know where I can find documentation or source code from which I can
learn myself how I'd have to use it.

And when making a specification (like dbus-specification.html) what
would be the preferred notation for this feature?

Like:

org.freedesktop.DBus.NameOwnerChanged
This is a signal:
            NameOwnerChanged (STRING name, STRING old_owner, STRING new_owner)

         
Perhaps are other applications using this already?


Many questions about the feature, I hope somebody can help me :-).


Thanks

--
Philip Van Hoof, software developer at x-tend
home: me at pvanhoof dot be
gnome: pvanhoof at gnome dot org
work: vanhoof at x-tend dot be
http://www.pvanhoof.be - http://www.x-tend.be
--
Philip Van Hoof, software developer at x-tend
home: me at pvanhoof dot be
gnome: pvanhoof at gnome dot org
work: vanhoof at x-tend dot be
http://www.pvanhoof.be - http://www.x-tend.be

_______________________________________________
dbus mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/dbus
Reply | Threaded
Open this post in threaded view
|

Re: Signal filtering

John Palmieri-2
On Fri, 2005-08-26 at 11:50 +0200, Philip Van Hoof wrote:
> Hi there,
>
> At this moment I'm working on a specification. For the specification I
> will have use the D-BUS signal filtering features.

Filtering has been in since the beginning.  We just added filtering on
argument types.  

> I was wondering what the status of this feature is. If it's implemented
> and ready for use I'd like to know how I can use it. I'd also like to
> know where I can find documentation or source code from which I can
> learn myself how I'd have to use it.

libhal has some good examples.  The filtering stuff isn't documented
extensively but I believe it is on our TODO.  To add a match rule you
call the dbus_bus_add_match:

dbus_bus_add_match (dbus_connection,
                            "type='signal',"
                            "interface='org.freedesktop.Hal.Manager',"
                            "sender='org.freedesktop.Hal',"
                            "path='/org/freedesktop/Hal/Manager'", &error);

Basically it takes a dbus connection object, a string of comma seperated
key/value pairs that specify the rule and a dbus error object so you can
get errors back.  If you exclude any of the key value pairs it becomes a
wildcard (i.e. if you exclude all but the type='signal' key you would
get all signals coming from the bus).

With the latest releases 0.36.x you can add arg keys.  So arg0, arg1,
arg2 ... argn.  They will match on arguments sent by the signal or
method.

> And when making a specification (like dbus-specification.html) what
> would be the preferred notation for this feature?
>
> Like:
>
> org.freedesktop.DBus.NameOwnerChanged
> This is a signal:
>             NameOwnerChanged (STRING name, STRING old_owner, STRING new_owner)
>

Filters shouldn't be noted in a specification.  They are optimizations
so that every program is not spammed by every signal that goes over the
bus.  In fact if you use the bindings filters are hidden from the user.

--
John (J5) Palmieri <[hidden email]>

_______________________________________________
dbus mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/dbus
Reply | Threaded
Open this post in threaded view
|

Re: Signal filtering

Philip Van Hoof
On Mon, 2005-08-29 at 13:36 -0400, John (J5) Palmieri wrote:
> With the latest releases 0.36.x you can add arg keys.  So arg0, arg1,
> arg2 ... argn.  They will match on arguments sent by the signal or
> method.

I think this is the part that I'm interested in. Where can I find more
information about this specific (new) feature?

> > And when making a specification (like dbus-specification.html) what
> > would be the preferred notation for this feature?
> >
> > Like:
> >
> > org.freedesktop.DBus.NameOwnerChanged
> > This is a signal:
> >             NameOwnerChanged (STRING name, STRING old_owner, STRING new_owner)
> >

> Filters shouldn't be noted in a specification.  They are optimizations
> so that every program is not spammed by every signal that goes over the
> bus.  In fact if you use the bindings filters are hidden from the user.

And the arguments (the new feature of 0.36.x)?


Thanks a lot for the answer

--
Philip Van Hoof, software developer at x-tend
home: me at pvanhoof dot be
gnome: pvanhoof at gnome dot org
work: vanhoof at x-tend dot be
http://www.pvanhoof.be - http://www.x-tend.be

_______________________________________________
dbus mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/dbus
Reply | Threaded
Open this post in threaded view
|

Re: Signal filtering

John Palmieri-2
On Mon, 2005-08-29 at 20:52 +0200, Philip Van Hoof wrote:

> On Mon, 2005-08-29 at 13:36 -0400, John (J5) Palmieri wrote:
> > With the latest releases 0.36.x you can add arg keys.  So arg0, arg1,
> > arg2 ... argn.  They will match on arguments sent by the signal or
> > method.
>
> I think this is the part that I'm interested in. Where can I find more
> information about this specific (new) feature?
>
> > > And when making a specification (like dbus-specification.html) what
> > > would be the preferred notation for this feature?
> > >
> > > Like:
> > >
> > > org.freedesktop.DBus.NameOwnerChanged
> > > This is a signal:
> > >             NameOwnerChanged (STRING name, STRING old_owner, STRING new_owner)
> > >
>
> > Filters shouldn't be noted in a specification.  They are optimizations
> > so that every program is not spammed by every signal that goes over the
> > bus.  In fact if you use the bindings filters are hidden from the user.
>
> And the arguments (the new feature of 0.36.x)?
>
>
> Thanks a lot for the answer

There isn't much documentation.  Like I said it is on the TODO list.
But lets take NameOwnerChanged for instance.  You can only match on
strings with arg matches which makes this signal perfect.  Say you want
to receive signals from only org.freedesktop.Foo you would do this:

dbus_bus_add_match (dbus_connection,
                    "type='signal',"
                    "interface='org.freedesktop.DBus',"
                    "memeber='NameOwnerChanged',"
                    "arg0='org.freedesktop.Foo'", &error);

if you knew the bus name of the org.freedesktop.Foo service you could do
this:

 dbus_bus_add_match (dbus_connection,
                    "type='signal',"
                    "interface='org.freedesktop.DBus',"
                    "memeber='NameOwnerChanged',"
                    "arg1=':1.23'", &error);

--
John (J5) Palmieri <[hidden email]>

_______________________________________________
dbus mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/dbus
Reply | Threaded
Open this post in threaded view
|

Re: Signal filtering

Philip Van Hoof
On Mon, 2005-08-29 at 15:02 -0400, John (J5) Palmieri wrote:

> There isn't much documentation.  Like I said it is on the TODO list.
> But lets take NameOwnerChanged for instance.  You can only match on
> strings with arg matches which makes this signal perfect.  Say you want
> to receive signals from only org.freedesktop.Foo you would do this:
>
> dbus_bus_add_match (dbus_connection,
>                     "type='signal',"
>                     "interface='org.freedesktop.DBus',"
>                     "memeber='NameOwnerChanged',"
>                     "arg0='org.freedesktop.Foo'", &error);

Is arg0 "any string"? Could it be like this?

"arg0='/some/tests/testing1'" or
"arg0='/some/tests/testing2'" or
"arg0='/some/tests/testing3'" or
"arg0='/some/tests/more/testing4'" or


And can I let the filter succeed on tests like this?

"arg0='/some/tests/*'"

So an argument for testing1, testing2, testing3 and even more/testing4.

The purpose is, indeed, a specification for a system like gconf. Not yet
a software or implemented infrastructure. A.t.m. it's just for defining
a specification. Don't worry :p.


--
Philip Van Hoof, software developer at x-tend
home: me at pvanhoof dot be
gnome: pvanhoof at gnome dot org
work: vanhoof at x-tend dot be
http://www.pvanhoof.be - http://www.x-tend.be

_______________________________________________
dbus mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/dbus
Reply | Threaded
Open this post in threaded view
|

Re: Signal filtering

John Palmieri-2
On Mon, 2005-08-29 at 21:22 +0200, Philip Van Hoof wrote:

> On Mon, 2005-08-29 at 15:02 -0400, John (J5) Palmieri wrote:
>
> > There isn't much documentation.  Like I said it is on the TODO list.
> > But lets take NameOwnerChanged for instance.  You can only match on
> > strings with arg matches which makes this signal perfect.  Say you want
> > to receive signals from only org.freedesktop.Foo you would do this:
> >
> > dbus_bus_add_match (dbus_connection,
> >                     "type='signal',"
> >                     "interface='org.freedesktop.DBus',"
> >                     "memeber='NameOwnerChanged',"
> >                     "arg0='org.freedesktop.Foo'", &error);
>
> Is arg0 "any string"? Could it be like this?
>
> "arg0='/some/tests/testing1'" or
> "arg0='/some/tests/testing2'" or
> "arg0='/some/tests/testing3'" or
> "arg0='/some/tests/more/testing4'" or

Yep this works.

> And can I let the filter succeed on tests like this?
>
> "arg0='/some/tests/*'"

Nope.  Havoc vetoed my suggestion of allowing this.  Wildcards aren't
allowed in matches.

> So an argument for testing1, testing2, testing3 and even more/testing4.
>
> The purpose is, indeed, a specification for a system like gconf. Not yet
> a software or implemented infrastructure. A.t.m. it's just for defining
> a specification. Don't worry :p.

Actually I rather see implementations before specifications, it kinda
keeps things grounded in what is possible to implement instead of
writing something that would be hard to implement.  But that is a
different topic :-)

--
John (J5) Palmieri <[hidden email]>

_______________________________________________
dbus mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/dbus
Reply | Threaded
Open this post in threaded view
|

Re: Signal filtering

Philip Van Hoof
On Mon, 2005-08-29 at 15:33 -0400, John (J5) Palmieri wrote:
> On Mon, 2005-08-29 at 21:22 +0200, Philip Van Hoof wrote:

> > > dbus_bus_add_match (dbus_connection,
> > >                     "type='signal',"
> > >                     "interface='org.freedesktop.DBus',"
> > >                     "memeber='NameOwnerChanged',"
> > >                     "arg0='org.freedesktop.Foo'", &error);
> >
> > Is arg0 "any string"? Could it be like this?
> >
> > "arg0='/some/tests/testing1'" or
> > "arg0='/some/tests/testing2'" or
> > "arg0='/some/tests/testing3'" or
> > "arg0='/some/tests/more/testing4'" or
>
> Yep this works.
>
> > And can I let the filter succeed on tests like this?
> >
> > "arg0='/some/tests/*'"
>
> Nope.  Havoc vetoed my suggestion of allowing this.  Wildcards aren't
> allowed in matches.


And there's also no plans to one day support this? Or would it become
supported if somebody would provide a good patch that would implement
it?


--
Philip Van Hoof, software developer at x-tend
home: me at pvanhoof dot be
gnome: pvanhoof at gnome dot org
work: vanhoof at x-tend dot be
http://www.pvanhoof.be - http://www.x-tend.be

_______________________________________________
dbus mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/dbus