node-sword-interface 1.0.8 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-sword-interface",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "Javascript (N-API) interface to SWORD library",
5
5
  "keywords": [
6
6
  "C++",
@@ -23,6 +23,7 @@
23
23
  #include <algorithm>
24
24
 
25
25
  // sword includes
26
+ #include <swmgr.h>
26
27
  #include <swmodule.h>
27
28
  #include <versekey.h>
28
29
 
@@ -100,7 +101,7 @@ vector<Verse> ModuleSearch::getModuleSearchResults(string moduleName,
100
101
  bool useExtendedVerseBoundaries)
101
102
  {
102
103
  this->_currentModuleName = moduleName;
103
- SWModule* module = this->_moduleStore.getLocalModule(moduleName);
104
+ SWModule* module = this->_moduleStore.getSearchSwMgr()->getModule(moduleName.c_str());
104
105
  ListKey listKey;
105
106
  SWKey* scope = 0;
106
107
  int flags = 0;
@@ -196,7 +197,7 @@ vector<Verse> ModuleSearch::getModuleSearchResults(string moduleName,
196
197
  void ModuleSearch::terminate()
197
198
  {
198
199
  if (this->_currentModuleName != "") {
199
- SWModule* module = this->_moduleStore.getLocalModule(this->_currentModuleName);
200
+ SWModule* module = this->_moduleStore.getSearchSwMgr()->getModule(this->_currentModuleName.c_str());
200
201
  module->terminateSearch = true;
201
202
  this->_currentModuleName = "";
202
203
  }
@@ -36,60 +36,78 @@ ModuleStore::ModuleStore(string customHomeDir)
36
36
  {
37
37
  this->_fileSystemHelper.setCustomHomeDir(customHomeDir);
38
38
  this->_fileSystemHelper.createBasicDirectories();
39
+ this->customHomeDir = customHomeDir;
39
40
 
41
+ this->_mgr = this->createSWMgr();
42
+ this->_mgr->setGlobalOption("Headings", "On");
43
+
44
+ // After creating the searchMgr we turn off features that we are not interested in when searching
45
+ this->_searchMgr = this->createSWMgr();
46
+ this->_searchMgr->setGlobalOption("Headings", "Off");
47
+ }
48
+
49
+ ModuleStore::~ModuleStore()
50
+ {
51
+ if (this->_mgr != 0) {
52
+ delete this->_mgr;
53
+ }
54
+
55
+ if (this->_searchMgr != 0) {
56
+ delete this->_searchMgr;
57
+ }
58
+ }
59
+
60
+ SWMgr* ModuleStore::createSWMgr()
61
+ {
62
+ SWMgr* swMgr = 0;
40
63
  bool isAndroid = false;
41
64
  #if defined(__ANDROID__)
42
65
  isAndroid = true;
43
66
  #endif
44
67
 
45
68
  if (customHomeDir != "" || isAndroid) {
46
- this->_mgr = new SWMgr(this->_fileSystemHelper.getUserSwordDir().c_str(),
47
- true, // autoload
48
- 0, // filterMgr
49
- false, // multiMod
50
- false); // augmentHome
69
+ swMgr = new SWMgr(this->_fileSystemHelper.getUserSwordDir().c_str(),
70
+ true, // autoload
71
+ 0, // filterMgr
72
+ false, // multiMod
73
+ false); // augmentHome
51
74
 
52
75
  if (isAndroid) {
53
76
  // Also consider the originally used path for Android, which does not work anymore from Android 11, but is still relevant
54
77
  // for existing translations on Android versions < 11.
55
- this->_mgr->augmentModules("/sdcard/sword");
78
+ swMgr->augmentModules("/sdcard/sword");
56
79
  }
57
80
  } else {
58
81
  #ifdef _WIN32
59
- this->_mgr = new SWMgr(this->_fileSystemHelper.getUserSwordDir().c_str());
82
+ swMgr = new SWMgr(this->_fileSystemHelper.getUserSwordDir().c_str());
60
83
 
61
84
  // This has been disabled because it lead to a crash.
62
85
  // We're keeping it here for now in case this becomes relevant again.
63
86
  // this->_mgr->augmentModules(this->_fileSystemHelper.getSystemSwordDir().c_str());
64
87
  #elif defined(__APPLE__)
65
- this->_mgr = new SWMgr();
88
+ swMgr = new SWMgr();
66
89
 
67
90
  stringstream appSupport;
68
91
  appSupport << string(getenv("HOME")) << "/Library/Application Support/Sword";
69
- this->_mgr->augmentModules(appSupport.str().c_str());
92
+ swMgr->augmentModules(appSupport.str().c_str());
70
93
  #else
71
- this->_mgr = new SWMgr();
94
+ swMgr = new SWMgr();
72
95
  #endif
73
96
  }
74
97
 
75
- this->_mgr->setGlobalOption("Headings", "On");
76
- }
77
-
78
- ModuleStore::~ModuleStore()
79
- {
80
- if (this->_mgr != 0) {
81
- delete this->_mgr;
82
- }
98
+ return swMgr;
83
99
  }
84
100
 
85
101
  void ModuleStore::refreshMgr()
86
102
  {
87
103
  this->_mgr->augmentModules(this->_fileSystemHelper.getUserSwordDir().c_str());
104
+ this->_searchMgr->augmentModules(this->_fileSystemHelper.getUserSwordDir().c_str());
88
105
  }
89
106
 
90
107
  void ModuleStore::deleteModule(string moduleName)
91
108
  {
92
109
  this->_mgr->deleteModule(moduleName.c_str());
110
+ this->_searchMgr->deleteModule(moduleName.c_str());
93
111
  }
94
112
 
95
113
  SWModule* ModuleStore::getLocalModule(string moduleName)
@@ -189,7 +207,12 @@ string ModuleStore::getModuleDataPath(sword::SWModule* module)
189
207
  return dataPath;
190
208
  }
191
209
 
192
- sword::SWMgr* ModuleStore::getSwMgr()
210
+ SWMgr* ModuleStore::getSwMgr()
193
211
  {
194
212
  return this->_mgr;
195
213
  }
214
+
215
+ SWMgr* ModuleStore::getSearchSwMgr()
216
+ {
217
+ return this->_searchMgr;
218
+ }
@@ -35,6 +35,7 @@ public:
35
35
  ModuleStore(std::string customHomeDir="");
36
36
  virtual ~ModuleStore();
37
37
 
38
+ sword::SWMgr* createSWMgr();
38
39
  sword::SWModule* getLocalModule(std::string moduleName);
39
40
  std::vector<sword::SWModule*> getAllLocalModules(ModuleType moduleType=ModuleType::bible);
40
41
 
@@ -46,10 +47,13 @@ public:
46
47
  void deleteModule(std::string moduleName);
47
48
 
48
49
  sword::SWMgr* getSwMgr();
50
+ sword::SWMgr* getSearchSwMgr();
49
51
 
50
52
  private:
53
+ std::string customHomeDir;
51
54
  std::vector<std::string> getModuleLanguages(ModuleType moduleType=ModuleType::bible);
52
55
  sword::SWMgr* _mgr = 0;
56
+ sword::SWMgr* _searchMgr = 0;
53
57
  FileSystemHelper _fileSystemHelper;
54
58
  };
55
59