crosswire/jsword — pull request #78 by chrisburrell (2014-04-24 22:26:39+00:00)
Title: Sidecar configuration

All these changes should be backwards compatible and you should see no difference.

A starter for 10. I will likely commit some more changes to finish this off. I wanted to give a bit of an early preview. This isn't quite ready to be pulled, but I can't see any way of showing stuff properly.

Noteworthy changes
- The SBMD now holds a reference (possibly null) to the parent configuration. Parent is defined as a fallback configuration (perhaps we need to change the name - might make it easier?)
- Parent's are generally used when the current SBMD doesn't hold a value.
- The ConfigEntryTable now knows whether it's a master table (i.e. a SBMD with no further parents)
- Levels of configuration (see MetaFile.Level) have been introduced to rank the levels. Essentially, the higher the rank, the more important the config is. The Level also holds where the config can be found (i.e. write directory, read directory, etc.
- A new save(ConfigEntry, value, Level) is now in place to allow saving of new entries. This is probably the more complicated part as it has to handle: creation of directory/file/config entry. As well as managing the 'parent' pointers.
- The SBMD now holds a reference to its owning book. This is because if we're adding a JSword configuration, we want the Book to point to JSword configuration which in turns point to the Sword configuration.

Things that have been done
=================
- Added a 'parent' to the SBMD (this basically is the lesser config which is used when no value can be found in the current config).
- Amended a number of comments to state which bits are overridable and which bits aren't.
- Tested with a small change to the description field
- Tested that scope gets calculated correctly (e.g. ESV gets written to correct file, directories get auto-created, and the key in the scope is missing the right bits, first 'missing' verse occurs as expected - i think - in Matthew. )
- Added a way to register an frontend name and have your own configuration
- Added 5 levels of configurations (FRONTEND_WRITE, FRONTEND_READ, JSWORD_WRITE, JSWORD_READ, SWORD). These are respectively the write and read-only directories of the frontend configuration holder and the jsword configured homes
- Made a few assumptions that may need changing. Unlocking never delegates. We could change that ( i know that I will want to use this where the frontend is in control of the unlock key). But by default we may want it the other way around
- A number of properties have been made never to override - again worth checking the comments to see if you guys agree.
- Kept the 'migration' code (not sure what that is), so the jsword mods.d is actually called jsword-mods.d

Yet to do:
- Use Martin's code to get list of books and introduce this into sidecar configuration
- Test with installers
- Test more thoroughly - done this briefly and it seems to work fine.

As I said, a starter for ten. Keen to get earlyish feedback. This change has turned out to be bigger than I had hoped originally, partly because of the wish to keep ConfigEntryTable separate (each CET maps to a single file), but also because the logic around deciding a value for a conf entry is spread in a few different locations (AbstractMetaData, SBMD, ConfigEntryTable, ConfigEntryType(default), etc.

Anyway, let me know what you think.
Chris