OSDN Git Service

Add the ability for addons to run code at install/uninstall time, and simplify addons...
authorMichael Curran <mick@kulgan.net>
Mon, 7 May 2012 03:57:48 +0000 (13:57 +1000)
committerMichael Curran <mick@kulgan.net>
Mon, 7 May 2012 03:57:48 +0000 (13:57 +1000)
commit81bf8ae13aea13d27580205edf411feaf6bdd669
tree7034667556831b3d41602ec85c92ee98852c3128
parentc9078c468ebb1495fb7330f39c6302951802b137
Add the ability for addons to run code at install/uninstall time, and simplify addons in general by removing a few features, at least for 2012.2.
Specific changes:
* Add the concept of install tasks, which are functions  in an addon that will be run at install/uninstall time. onInstall and onUninstall can be defined in the addon's installTasks.py. onInstall will be run after the addon has been copied in to nvda as a pending install, but if the function raises an exception, then the installation will fail. onUninstall is called on NVDA restart after an addon has been marked for removal and just before its directory is deleted. Note that installTasks.py should not load any addon-specific python c extensions or load dlls etc as removal may then fail. This should only be used for copying/removing files or for validating licenses or other info.
* Remove the existing hook implementation for addons for now. There were a few problems such as it loading the hooksModule too early, and possibilities that unLoad may have been never called due to incorrect state. We may eventually have something similar, but probably not for 2012.2. For general initialization/termination code, this could be placed in a global plugin.
* Rename Addon.isLoaded to isRunning to match getRunningAddons and the GUI, and reimplement it simply as being true if isPendingInstall is false. Also remove Addon.load and Addon.unload. This now therefore means any addon that is not currently being installed must be running as its packages are available to the rest of NVDA.
* addonHandler._availableAddons is now an ordered dictionary, and installAddonBundle manually adds the new addon to it. this is so that the GUI can guarantee some kind of predictable order when refreshing or adding to its list of addons.
* addon GUI: don't call getAvailableAddons with refresh=True any more as its no longer needed.
* Addon GUI: rename the 'new' and 'removed' addon status translatable strings to 'install' and 'remove' respectivly to make it a little clearer that the action isn't actually complete yet.
* Addon GUI: Try to select the most appropriate addon in the list after an action completes.
* core: Initialize addonHandler before appModuleHandler.
source/addonHandler.py
source/core.py
source/gui/addonGui.py