[sword-devel] finding conf file for module

Troy A. Griffitts scribe at crosswire.org
Sun May 23 11:28:52 MST 2010


If you are using InstallMgr, then there is a facility for this in the
virtual method getCipherCode.

The relevant example from our BibleCS code is


bool InstallMgrWin::getCipherCode(const char *modName, SWConfig *config) {
        CipherForm->modName = modName;
        CipherForm->config = config;
        return (CipherForm->ShowModal() == mrCancel);

Where CipherForm is a popup dialog which asks the user for a cipher key,
let's them test it by grabbing an entry from the module with that key
(if it's the correct key, they will see module text, otherwise
gibberish), and then let's them accept or cancel.

If this does not fit for you, and if you wish to modify the conf file
after the module is already installed, there is example code in SWMgr.h
(the end of the file) to show  how to do this, but it is old and only
takes into account the primary module path which was discovered at
startup (this path is saved at SWMgr::configPath).

It will not work for modules found on AugmentPath entries (including the
automatic AugmentPath $HOME/.sword, unless $HOME/.sword is found as the
primary module path (i.e., no other module paths were found)).

If all of your modules are discovered in the same place, then it will work.

We add "AbsoluteDataPath" as a config entry when we load the
configuration of modules to help with things similar to this, so you can do:


to tell you where the module data lives. Though this will not officially
help you find the config, it should be at

We should make this easier for you and provide an 'official' way to do
this which works with our expanded definition of where modules can be
installed to.

An alternative to modifying the distributed .conf file is to have your
own 'stand off' per module config modifiers.  We do this in BibleCS with
a file like:



Then in code we provide a virtual SWMgr::Load method like:

signed char BibleCSMGR::Load () {
        signed char retval = SWMgr::Load();
        userPrefs = new SWConfig("./userprefs.conf");
        if ((config) && (userPrefs))

        return retval;

SWMgr::config is the globbed configuration of all modules.  The augment
method on SWConfig (or the += operator) will add to or update config
entries accordingly.

This allows you to get your user preference per module entries like any
other entry in the distributed .conf file:


The downside is that the CipherKey entry is needed at module load time
(base class version of SWMgr::Load) to know which low level decipher
filters to add for that module, so this will not help for your current

So, anyway, this is all more information than you probably care to
know.  Hope it helps some.


On 05/22/2010 05:06 PM, Matthew Talbert wrote:
> I'm writing gobject bindings for SWORD, which consists of refactoring
> most of our backend code that we've used for a long time in Xiphos.
> Part of the code we have is to set the cipher key for a module. In
> looking at that, I don't see an easy way to get the .conf file for a
> particular module. We even have these lines in our code (I didn't
> write them....):
>         return backend->get_config_file(mod_name, moddir);
> #else
>         lengthy way to get the config file...
> In fact, we have two separate methods for finding the conf file. In
> the documentation for setCipherKey(), there is example code for
> writing to the config file.  However, the code is fatally flawed in
> that it assumes that all of the conf files live in a single directory,
> "configPath". In a typical linux system, most of the conf files will
> be in ~/.mods.d, and SWORD is set up in such a way that there could be
> multiple directories for conf files.
> So, my first question is, "what is the best way to get the conf file
> for a given module?" and the second is, "could we please add this to
> the engine?"
> Also, how does SWModule::getConfigEntry("AbsoluteDataPath") work?
> There is no entry like this in the .conf files; is it documented
> somewhere? Couldn't it just be a method of SWModule?
> Thanks,
> Matthe
> _______________________________________________
> sword-devel mailing list: sword-devel at crosswire.org
> http://www.crosswire.org/mailman/listinfo/sword-devel
> Instructions to unsubscribe/change your settings at above page

More information about the sword-devel mailing list