I've pushed an update to make the plugin reply to introspect queries. It
seems to work in qdbusviewer so I hope I got it right.
>>> It is usually also a good idea to provide a D-Bus introspection XML
>>> file as part of the sources, potentially even installing it.
>>>
>>> It is a way of documenting which interfaces are available as
>>> "public API" as opposed to D-Bus being used for an internal purpose
>>> ("private API") or still experimental features ("unstable API").
>>
>> It sounds like a good idea, but I have put all the contacts in the
>> object tree so it's not a fixed structure and the examples I have
>> seen for the introspective data is for a static structure only. Is it
>> possible to describe a runtime dynamic tree in a static text file? I
>> guess the interfaces could be documented but I haven't seen any
>> example on how to write it.
>
> I am not sure I fully understand you so please correct me if I am
> wrong :)
>
> As far as I can tell after a quick look into the code is that you
> have the following interfaces:
> org.licq.Core
> org.licq.ContactList
> org.licq.Contact
> org.licq.Account
>
> Each of these can be described in a separate XML file, each interface
> can be applicable to one or more object paths.
> I guess the first two are for a single object each, while the latter
> two apply to multiple objects.
Yes, that is correct. But the only syntax I've seen is the introspect
data which includes object paths. Could you point to an example for how
the files should look if I only define interfaces without object paths?
Although I'm slightly skeptic to having another file describing the API.
Right now there are three "copies": The implemented code, the introspect
response in the code, and the examples in the README file.
Adding XML files as well would be a fourth copy which is at least one
too many to expect all of them to stay in sync.
> I had a better look at the implementation now and I think it would improve
> maintainablity and extendability if handling of each interface were delegated
> to a respective implementation.
>
> E.g. something like an interface similar to DbusCallback but as a base for
> each interface implementation:
>
> And then registering an instance of each with the DbusCallback implementor
> such that it only needs to do a lookup based on "iface" and then delegate.
This would require the plugin to instantiate objects for every contact
in Licq which would make the plugin much larger (both code and memory
usage).
If/when the API becomes larger it might be more efficient, but for now I
think I prefer to keep the code simple.
> I think it would also be good to have GetAccounts() return an array of object
> paths, i.e. D-Bus type "ao".
> That allows "clients" to treat the values as opaque identifiers, allowing you
> to change the scheme, e.g. have them as a flat list instead of grouped by
> protocol, etc.
Yes, it's probably more convenient for clients to get object paths
rather than account names. I'll change GetAccounts and GetContacts to
return object paths instead.
> At some point it might be worthwhile to think about "bulk notifications", e.g.
> a signal "ContactsStatusChanged" with D-Bus signature "a{s(us)}".
> I.e. a map, where the key (first s) would be the contact identifier (or object
> path if contacts are addressable individually) and the value would be the
> status value and status text.
The plugin get individual signals for each contact so this would require
buffering of status changes in the plugin.
Also, I tried to keep the DbusInterface class simple so right now it
can't create arrays of structs.
/Anders