The other day, Ralph asked me about the upgrade tool in BottomFeeder. Well, until this evening it had mostly been a component piece of Bf, not easily reusable elsewhere. I think I've fixed that. I just spent some time refactoring the tool and splitting it out of the bf bundle (which makes it entirely possible that the upgrade tool will be used to upgrade itself sometime. Such is Smalltalk :) ). The code is in the public store as PatchFileDelivery.
One thing you'll notice is the existence of PatchManager and PatchManagerUI, which I don't really use. That's an artifact of the way I used to deliver bf updates. The more current classes of interest are UpgradeManager and UpgradeManagerUI. Here's how I use them:
First, I set up an XML Manifest file on the server. I use the XML Configuration Files package in the public store for that:
defs := OrderedCollection new.
list := #('dev\Emote-Support.pcl' 'dev\ExtraEmphases.pcl' 'dev\VRCommonDialogs.pcl' 'dev\Http-Access.pcl' 'dev\PatchFileDelivery.pcl' 'dev\Browsing-Assist.pcl' 'dev\OSTimeZone.pcl' 'dev\XmlRpcClient.pcl' 'dev\XML-Configuration-Files.pcl' 'dev\BottomFeeder.pcl' 'dev\TwoflowerBundle.pcl' 'IRC-BottomFeeder-Plugin.pcl' 'Pongo.pcl' 'Blog-Tools.pcl' 'WinMineGame.pcl').
names := #('Base Component, Icon Support' 'Base Component, Font Support' 'Base Component, Dialog Support' 'Base Component, Http Support' 'Upgrade Tools Support' 'Base Component, Browser Support' 'Base Component, Local Time Support' 'Base Component, XML-RPC Support' 'Base Component, Upgrade System Support' 'Base Component, Main Application' 'Base Component, HTML Browsing Support' 'Plugin, IRC Client' 'Plugin, MSN IM Client' 'Plugin, Blog Posting Tool' 'Plugin, Minesweeper Game' ).
descripts := #('' '' '' 'encoding priority fix' 'Refactored Patch File Code' '' '' '' '' 'remote browsing includes top 5 items' 'encoding changes' 'Fix for settings reading problem' '' 'preview load could fail, fixed' '').
sizes := list collect: [:each | each asFilename fileSize].
allows := #(true true true true true true true true true true true true true true true ).
list do: [:each | | version nm timestamp properties index |
properties := [CodeReader new readInfoFromFileNamed: each]
on: OsError, CodeReader fileFormatSignal
do: [:ex | ex return: Dictionary new].
version := properties at: #version.
nm := properties at: #parcel.
timestamp := properties at: #timestamp.
index := list indexOf: each.
comp := ComponentDefinition
parcelFilename: (each asFilename tail asString)
descriptiveName: (names at: index).
comp description: (descripts at: index).
comp fileSize: (sizes at: index).
comp allowDynamicLoad: (allows at: index).
defs add: comp].
(defs at: 12) isPlugin: true.
(defs at: 13) isPlugin: true.
(defs at: 14) isPlugin: true.
defs last isPlugin: true.
"now save it"
file := Tools.XMLConfigFileSupport.XMLConfigFile filename: 'upgradeBtf.xml'.
file saveObject: defs.
That saves a configuratioin file to disk - the plugins/main components thing is Bf specific, but it's not really essential to the package. To open the UI and check for upgrades, this is all you need to do:
loader := Patch.UpgradeManagerUI new.
loader viewer: self.
Cursor wait showWhile: [loader doUpgradeCheck].
Of course, to specify where the upgrade information lives, you need a settings file that looks like this:
By default, the code will look for a file called 'patches.ini'. You can also hand the manager object (the domain underneath the UI) settings in code; there's an API for that. That's pretty much it; Assuming that you have Http access to the remote server, you now have patch file delivery.