On 2013-01-02 21:58, Erik Johansson wrote:
> On Tue, Jan 1, 2013 at 10:03 PM, Anders Olofsson<
fl...@licq.org> wrote:
>>> Instead of making each plugin handle multiple owners, is it possible
>>> to create multiple instances of the plugin's main class instead and
>>> bind each owner to a separate instance?
>>
>> I guess the biggest difference in the end would just be how many threads the
>> plugins are running.
>> It would require changing the PluginManager to keep track of both libraries
>> and instances separately.
>
> I think it would be good if protocols don't have to handle multiple
> owners explicitly. It will probably make them easier to grasp. I've
> started looking into how this could be done.
I would like to bring down the number of running threads, especially in
the ICQ protocol, but I guess one per owner isn't that bad.
But what would happen if you have a different type of protocol?
Example 1: A skype interface that talks to the Skype application via
D-Bus don't know which account the Skype client has configured until
after it's connected. Here it would make more sense to let the protocol
fetch the account id from the Skype client and than add it itself to
Licq. (A Skype plugin also adds some other strange things, like how to
differ between not connected to the Skype client, and connected but the
Skype client is offline.)
Example 2: A weather plugin (I know it exists for other IM clients) or
similar status information may not have any type of real account. If it
starts when loaded, it can add its own hardcoded dummy account rather
than forcing to user to do it.
I'm also thinking about flexibility for how the protocol is threaded.
If we only start one thread (as today) it would be possible for the
protocol main class to spawn additional threads for each owner if it
wants to. But if we start one thread per owner and the protocol only
wants/needs one global thread, it could get a bit tricky.
Anyway, which ever way we do this I'm assuming we just can't enable it
globally for all protocols (due to globals in some protocol's code) so
I've added a new capability flag for protocol plugins to control if
multiple owners are supported, and I've updated everything I could
remember in the daemon and GUI to check for that flag instead of just
hardcoding one owner per protocol.
>> It opens the question of what actually needs to exist for a protocol that is
>> loaded but has no owner configured. I'm guessing there should still be some
>> small singleton per protocol to hold static data like the protocol name,
>> capability flags, etc...
>
> This can be a later improvement. Previously I have thought about
> making each plugin have a xml-file (or other format) that describes
> the plugin. This way you could list some info about each plugin
> without having to load them.
A separate file is an option, and it would be nice to have the
information available before the library is loaded, but having it inside
the library is a guarantee that the information is in sync with the
library code.
However, if you do want to make a file, please keep away from xml. Xml
only makes it harder to parse the file and for this case I can't see
that we benefit from any of the flexibility in XML. A simpler format
(like the INI-files we use for everything else) will be easier to parse
both for Licq and humans, and as long as the first parameter is a
version (Licq version or file format version) it doesn't matter if the
format for the rest of the file changes between versions.
/Anders