[sword-devel] BibleZ HD Beta - webOS Bible Reader App for the HP TouchPad

Troy A. Griffitts scribe at crosswire.org
Sat Jul 23 07:35:34 MST 2011

Being new to C++, you've done quite well.

So webOS programming is pretty much all javascript with hooks to call
native library?  That's pretty cool.

Here are a few suggestions for pluginSword.cpp.  I'll walk through the
logic of how we get to an optimal configuration so you can understand
the reasoning for future reference:

In each method where you need an SWMgr object, you currently construct a
new instance.  Depending on the number of locales and modules you have
loaded, this can be fairly expensive.  As you've figured out, SWMgr is a
'factory class' which generates appropriate instances of SWModules for
you.  It is 'smart' enough to reuse the same SWModule instance if asked
for the same book a second time, so it caches well, but this has some
threading issues you should consider.

With the knowledge of all this, I would suggest creating 2 SWMgr
instances globally, which are used by the methods in your plugin.  This
will save lots of time if you repeatedly call,

e.g., PDL_bool getVerses(PDL_JSParameters *parms),

in a loop and should improve the general responsiveness of the application.

The reason I suggest 2 instances is because of the threading issue.  For
example, If I start a brute force regex search, which might take a
noticeable amount of time on a mobile device, so I'll start it in its
own thread with a progress bar, and then while that thread is running,
attempt to display the same book which I am searching, SWMgr will be
operating on the same SWModule instance because of caching and will
likely cause problems.  As long as each of your threads use their own
instance of SWMgr, you should never run into threading problems.

SWMgr displayLibrary(new MarkupFilterMgr(FMT_HTMLHREF);
SWMgr searchLibrary;

Now, where you'll run into problems is if you install new books, these
global copies will not be refreshed, you'll then want to make them:

SWMgr *displayLibrary = 0;
SWMgr *searchLibrary = 0;

void refreshManagers() {
	delete displayLibrary;
	delete searchLibrary;
	displayLibrary = new SWMgr(new MarkupFilterMgr(FMT_HTMLHREF);
	searchLibrary = new SWMgr();

then call refreshManagers(); at init time and after installing new modules.

Alternate Versification (av11n)...  Your app uses SWORD like it assumes
all Bibles have the same versification.  We have been recently preparing
quite a few Bibles which use versification other than the KJV (which is
the default for VerseKey).  I would suggest that your methods which
return versification information take a parameter Bible name, so you can
return versification information appropriate for that Bible.  Here is an

PDL_bool getBooknames(PDL_JSParameters *parms) {
  std::stringstream bnames;
  std::string bnStr;
// -------------------
  const char* moduleName = PDL_GetJSParamString(parms, 0);

  SWModule *module = displayLibrary.getModule(moduleName);
  if (!module) return PDL_FALSE;  // assert we found the module

  VerseKey *vkey = dynamic_cast<VerseKey *>(module.getKey());
  if (!vkey) return PDL_FALSE;    // assert our module uses verses

  VerseKey &vk = *vkey;
// -------------------
bnames << "[";
for (int b = 0; b < 2; b++) {

This uses the VerseKey from the module itself and will return the
correct versification information for the Bible the user is viewing.

PDL_bool readConfs(PDL_JSParameters *parms) {
SWMgr confReader("/media/internal/.sword/install");
for (it = confReader.Modules.begin(); it != library.Modules.end(); it++) {
  SWModule *module = it->second;


InstallMgr class (and sword/utilities/installmgr.cpp as an example)
might be useful for remote and local installation of modules.

Hope this helps.  Thank you for all the time you've committed to
developing this app!

Serving together,


On 23/07/11 14:24, Stephan Tetzel wrote:
> Am 23.07.2011 11:31, schrieb Peter von Kaehne:
>> On 21/07/11 08:09, Stephan Tetzel wrote:
>>> Hi,
>>> BibleZ HD is a port of one of my current webOS Apps
>>> (http://zefanjas.de/apps/biblez/) to the new webOS framework (enyo). The
>>> SWORD engine is now the new backend for this app. 
>> Where is the source? I see on your site nothing re GPL licensing
> BibleZ Pro (the current webOS (phone) App) doesn't use the SWORD Engine
> and isn't licensed under GPL.
> The new port (BibleZ HD) will be licensed under GPL. You can find the
> sources here[1]. (Sry that I haven't upload the sources immediately.) If
> you look at the sources you'll maybe notice, that I'm (very) new to the
> sword and c++ world =)
> Stephan
> [1]https://github.com/zefanja/biblez
> _______________________________________________
> 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