2022-10-27, 13:46
An addon can be called from everywhere,
usually an user browse the addon (e.g. video addon) by opening it from his icon then you browse the addon in standard way
but an addon can be called by a lot of other ways:
Skin Widgets, Scripts, Kodi library, Keyboard shortcut, windows like file browser, external third party add-ons
and currently there is no way for an addon to identify the caller
Why?
Have better control over addon accesses
grant or deny an access from other addons, scripts etc...
allow an addon to handle and manage in custom way specific type of calls having a type of context
Current kind of workaround
an ugly workaround is to use:
getInfoLabel('Container.PluginName')
getCondVisibility("Window.IsMedia")
and other similar properties
these solutions are totally unsafe/limited/constrained so they depends on the current GUI state,
because for example while a script call an addon, meanwhile the user can do other things, like open other windows or addons
then GUI state provided by infolabels/condvisibility cannot be used to identify the caller because
are not valid for the context of the source call done by the script
Another example are widgets,
they call an addon at any time for updates, but an addon is not able to know that the call come from widget,
and therefore has no possibility of handling the situation in a certain way
A possible solution
Define some basic caller types for example:
widget, script, browser, player, addon, ...
so provide to the addon entry point in the
for example:
caller_type = "widget"
caller_identifier = "widget_name"
caller_type = "addon"
caller_identifier = "addon_id"
usually an user browse the addon (e.g. video addon) by opening it from his icon then you browse the addon in standard way
but an addon can be called by a lot of other ways:
Skin Widgets, Scripts, Kodi library, Keyboard shortcut, windows like file browser, external third party add-ons
and currently there is no way for an addon to identify the caller
Why?
Have better control over addon accesses
grant or deny an access from other addons, scripts etc...
allow an addon to handle and manage in custom way specific type of calls having a type of context
Current kind of workaround
an ugly workaround is to use:
getInfoLabel('Container.PluginName')
getCondVisibility("Window.IsMedia")
and other similar properties
these solutions are totally unsafe/limited/constrained so they depends on the current GUI state,
because for example while a script call an addon, meanwhile the user can do other things, like open other windows or addons
then GUI state provided by infolabels/condvisibility cannot be used to identify the caller because
are not valid for the context of the source call done by the script
Another example are widgets,
they call an addon at any time for updates, but an addon is not able to know that the call come from widget,
and therefore has no possibility of handling the situation in a certain way
A possible solution
Define some basic caller types for example:
widget, script, browser, player, addon, ...
so provide to the addon entry point in the
the info of the caller (or context of call)pyhton:sys.argv
for example:
caller_type = "widget"
caller_identifier = "widget_name"
caller_type = "addon"
caller_identifier = "addon_id"