about the D-Bus C API.
Thiago Macieira
thiago at kde.org
Tue Nov 13 00:34:35 PST 2007
Em Tuesday 13 November 2007 08:56:15 Wang Jun escreveu:
> Hi Thiago Macieira,
>
> Thank you for your reply. but I kind of find exception to
> what you said. check below.
Please reply to the list. If you mail me directly, I might ignore the message
because I don't know the answer (or am busy), but other people may be able to
answer.
> On Tue, 2007-11-13 at 08:20 +0100, Thiago Macieira wrote:
> > Wang Jun wrote:
> > >I am using D-Bus C API. Is it possible to make sure the well known names
> > >are returned when dbus_message_get_sender(msg)
> > >and dbus_message_get_destination(msg) are called?
> >
> > No.
> >
> > get_sender ALWAYS returns the unique name.
> >
> > get_destination returns what the sender chose. It can be either a unique
> > or a well-known name.
>
> can you give a bit more elaboration on this?
Yes.
The sender is set by the bus daemon. It always sets to the unique name.
Therefore, get_sender always returns a unique name.
As for the destination, it's set by the sender, so it's what the sender chose
it to be. If it set the destination to a unique name, you get a unique name.
If it set the destination to a well-known name, you get a well-known name.
> > >Currently, I am not using any matching rule for listening on dbus as
> > >I want to catch both method_calls and signals. So I use the
> > > dbus_message_get_sender(msg) to check the sender and then call
> > >the relevant subroutines. But the function returns unique names
> > >instead of well known name...
> >
> > That paragraph doesn't make sense. Without a matching rule, you don't
> > receive the message in the first place.
>
> actually I am not familiar with the C implementation inside in dBus.
> But My program does be able to receive both SIGNAL and METHOD_CALLS
> without specifying any addMatch..
I guess that the dbus-daemon has some implicit rules, then. But you should not
be receiving signals without an add match rule.
Someone else may be able to clarify the behaviour of the daemon in case there
aren't any rules set.
> currently I dispatch the call based on interface, path, name..
> But cannot based on SENDER and DESTINATION due to the problem I
> mentioned
You don't want to dispatch based on sender and destination.
If the destination is set (i.e., method calls), then the destination is you
because you received the message in the first place. Therefore, you don't
need to check if the destination is you. You should handle all messages
equally.
If the destination isn't set, it's a signal.
As for the sender, you shouldn't treat messages differently based on the
sender. You should treat all senders equally.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
Url : http://lists.freedesktop.org/archives/dbus/attachments/20071113/6eb72b9d/attachment-0001.pgp
More information about the dbus
mailing list