Home of the Squeezebox™ & Transporter® network music players.
Page 1 of 2 12 LastLast
Results 1 to 10 of 12
  1. #1
    Senior Member
    Join Date
    Apr 2005
    Location
    UK/London
    Posts
    4,904

    Replacing one plugin with another

    I am working through ideas for how I can make a new plugin of mine replace a number of my old ones within an existing installation.

    i.e. if the end-user installs my plugin Z after already installing and using plugin X and plugin Y (etc) then X and Y should stop functioning (because I know that Z does everything that X and Y do).

    I could make a new version of X and Y to do something to help ... but I can't be certain that the end-user will install it (although it is probably reasonable to assume that if the end-user installs my plugin Z then they probably would let X and Y upgrade as well).

    The order that plugins are started by LMS is not documented (although I think it is alphabetical) but I don't really want a mechanism that relies on that and I don't really want to call my Z plugin AAAZ.

    If someone uninstalls a plugin the prefs are left in place so I cannot use the presence of prefs as being proof that a plugin is installed.

    I would like it to be done no later than the plugin actions the initPlugin call because the plugins call registerParser and registerProvider and this might cause issues with more than one plugin trying to run off the same regex matches (I have not tried).

    If it can all be done in the new plugin Z then that is great because I would not have to update X and Y.

    I suspect that it could be possible for plugin Z to clear clear the plugin-enabled flag for X and Y ... but what happens if X or Y has already been started up by LMS?

    Any ideas?
    Paul Webster
    Author of "Now Playing" plugins covering Radio France (FIP etc), PlanetRadio (Bauer - Kiss, Absolute, Scala, JazzFM etc), KCRW, ABC Australia and CBC/Radio-Canada
    and, via the extra "Radio Now Playing" plugin, AllZIC Radio, Caroline Flashback, Cesky rozhlas, Dandelion Radio, Europa Radio Jazz, Frequence3, FSK, JukeRadio, KlassikRadio.de, Linn Radio, Mother Earth, Naim Radio, Nova.fr, RadioBlues Flac, Radio Espace, Radio Swiss, RTE Ireland, Somehow Jazz, Supla Finland

  2. #2
    Senior Member
    Join Date
    May 2010
    Location
    London, UK
    Posts
    923
    Might you be able to do something with postinitPlugin ?

    Refer PluginManager: https://github.com/Logitech/slimserv...anager.pm#L381

  3. #3
    Senior Member
    Join Date
    Apr 2005
    Location
    UK/London
    Posts
    4,904
    Thanks - that looks interesting.
    Paul Webster
    Author of "Now Playing" plugins covering Radio France (FIP etc), PlanetRadio (Bauer - Kiss, Absolute, Scala, JazzFM etc), KCRW, ABC Australia and CBC/Radio-Canada
    and, via the extra "Radio Now Playing" plugin, AllZIC Radio, Caroline Flashback, Cesky rozhlas, Dandelion Radio, Europa Radio Jazz, Frequence3, FSK, JukeRadio, KlassikRadio.de, Linn Radio, Mother Earth, Naim Radio, Nova.fr, RadioBlues Flac, Radio Espace, Radio Swiss, RTE Ireland, Somehow Jazz, Supla Finland

  4. #4
    Senior Member
    Join Date
    Apr 2005
    Location
    UK/London
    Posts
    4,904
    I can see a couple of different approaches using the pre/post functionality.

    One would be to have a pre function in plugin Z that disables plugin X and Y (if author same as plugin Z).

    An alternative would be for Z to have a callable function ... and then modify plugin X and Y to call it in their initPlugin to ask if they should continue.
    This approach would require the end-user to update (or remove) the X and Y plugin but might make it easier to revert in the event of a problem in my new plugin Z (for example if I had missed something in porting the functionality from X and Y to Z.
    Paul Webster
    Author of "Now Playing" plugins covering Radio France (FIP etc), PlanetRadio (Bauer - Kiss, Absolute, Scala, JazzFM etc), KCRW, ABC Australia and CBC/Radio-Canada
    and, via the extra "Radio Now Playing" plugin, AllZIC Radio, Caroline Flashback, Cesky rozhlas, Dandelion Radio, Europa Radio Jazz, Frequence3, FSK, JukeRadio, KlassikRadio.de, Linn Radio, Mother Earth, Naim Radio, Nova.fr, RadioBlues Flac, Radio Espace, Radio Swiss, RTE Ireland, Somehow Jazz, Supla Finland

  5. #5
    Senior Member erland's Avatar
    Join Date
    Dec 2005
    Location
    Sweden
    Posts
    11,305
    If my interpretation of the code is correct the key is the “plugin.extensions” preferences. You should be able to set “plugin.extensions.<your plugin>“ to “needs-uninstall” and it should uninstall at next restart.
    https://github.com/Logitech/slimserv...anager.pm#L104
    Look at the prefs file to see what <your plugin> should be.

    Of course, modifying other plugins properties like this could be a bit risky and might break at any time.

    To trigger a server restart automatically is even more risky as it aborts any operation in progress, but if you still like to go that route you can see how LMS handles it after you have selected to install/uninstall plugins via web interface here:
    https://github.com/Logitech/slimserv...Plugins.pm#L67

    Michael is likely going to spot this thread and give you a better suggestion.
    Erland Isaksson (My homepage)
    Developer of many plugins/applets
    Starting with LMS 8.0 I no longer support my plugins/applets (see here for more information )

  6. #6
    Senior Member
    Join Date
    Apr 2005
    Location
    UK/London
    Posts
    4,904
    I have the basis of something that works ....
    in plugin Z (the new one) preinitPlugin

    Code:
    	my $targetPlugin = 'x';	# use the short form from 'Slim::Plugin::x::Plugin'
    	if ( Slim::Utils::PluginManager->isConfiguredEnabled($targetPlugin) ) {
    		Slim::Utils::PluginManager->disablePlugin($targetPlugin);
    		main::INFOLOG && $log->info("disabling $targetPlugin plugin because capability moved to $pluginNamePackage" );
    	}
    Needed to use isConfiguredEnabled rather than isEnabled because isEnabled is really a check to see if the target plugin has loaded ... which, in this case, it will not have done yet because we are still in preinit phase.

    This does result in plugin x being disabled - but if you go into the LMS Settings/Plugins then LMS will want to download plugin x again ... so I would also have to remove it from the list of available plugins (which is OK for me because I would be withdrawing plugin x).

    However, I need to put in extra check on plugin author (or some other unique thing) so that I do not zap a future plugin by someone else that happens to be called x.
    Paul Webster
    Author of "Now Playing" plugins covering Radio France (FIP etc), PlanetRadio (Bauer - Kiss, Absolute, Scala, JazzFM etc), KCRW, ABC Australia and CBC/Radio-Canada
    and, via the extra "Radio Now Playing" plugin, AllZIC Radio, Caroline Flashback, Cesky rozhlas, Dandelion Radio, Europa Radio Jazz, Frequence3, FSK, JukeRadio, KlassikRadio.de, Linn Radio, Mother Earth, Naim Radio, Nova.fr, RadioBlues Flac, Radio Espace, Radio Swiss, RTE Ireland, Somehow Jazz, Supla Finland

  7. #7
    Babelfish's Best Boy mherger's Avatar
    Join Date
    Apr 2005
    Location
    Switzerland
    Posts
    20,622
    You might want to add something like

    Code:
    preferences('plugin.state')->set($plugin, 'needs-uninstall');
    I'm sorry for chiming in late. Still catching up :-)
    Michael

    "It doesn't work - what shall I do?" - "Please check your server.log and/or scanner.log file!"
    (LMS: Settings/Information)

  8. #8
    Senior Member
    Join Date
    May 2010
    Location
    London, UK
    Posts
    923
    Quote Originally Posted by Paul Webster View Post
    However, I need to put in extra check on plugin author (or some other unique thing) so that I do not zap a future plugin by someone else that happens to be called x.
    I recall that there can exist an 'id' field in the install.xml, which could be a UUID. This might serve the purpose if you have used it. I forget what LMS does with it.

  9. #9
    Senior Member
    Join Date
    Apr 2005
    Location
    UK/London
    Posts
    4,904
    I did think about that id… but I don’t set it so to put it in place would require me to release a new build of the plugins and the user to install.

    What I have done for now is put the obsolete plugin name (X) in an external config file that is loaded by plugin Z … then becomes very easy to remove in the future by anyone if really needed before I have a better solution.
    Paul Webster
    Author of "Now Playing" plugins covering Radio France (FIP etc), PlanetRadio (Bauer - Kiss, Absolute, Scala, JazzFM etc), KCRW, ABC Australia and CBC/Radio-Canada
    and, via the extra "Radio Now Playing" plugin, AllZIC Radio, Caroline Flashback, Cesky rozhlas, Dandelion Radio, Europa Radio Jazz, Frequence3, FSK, JukeRadio, KlassikRadio.de, Linn Radio, Mother Earth, Naim Radio, Nova.fr, RadioBlues Flac, Radio Espace, Radio Swiss, RTE Ireland, Somehow Jazz, Supla Finland

  10. #10
    Senior Member
    Join Date
    Apr 2005
    Location
    UK/London
    Posts
    4,904
    It is working - but I now have the old plugin in a strange state.

    It is listed in the Inactive Plugins in LMS/Settings/Plugins

    If I turn off the ability for plugin Z to replace plugin X and restart LMS then I would expect to be able to re-enable plugin X ... but I cannot.
    I can tick the box next to it but LMS does not offer me the opportunity to restart - and if I do force a restart then plugin X is still marked as inactive.
    Could this be because it wants to download it again but it is not listed in 3rd-party pluins any more (I took it out today)?

    To see it in action I have made plugin Z available as a general release (even though there is this issue).
    Plugin X = Supla Finland Track Information
    Plugin Z = Radio Now Playing (version 0.0.11)

    To disable Z taking over the X functions go to Plugin/Settings/Radio Now Playing and in "Broadcasters to suppress" select Supla Finland
    Paul Webster
    Author of "Now Playing" plugins covering Radio France (FIP etc), PlanetRadio (Bauer - Kiss, Absolute, Scala, JazzFM etc), KCRW, ABC Australia and CBC/Radio-Canada
    and, via the extra "Radio Now Playing" plugin, AllZIC Radio, Caroline Flashback, Cesky rozhlas, Dandelion Radio, Europa Radio Jazz, Frequence3, FSK, JukeRadio, KlassikRadio.de, Linn Radio, Mother Earth, Naim Radio, Nova.fr, RadioBlues Flac, Radio Espace, Radio Swiss, RTE Ireland, Somehow Jazz, Supla Finland

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •