Bibletime – a bible study tool
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cswordbackend.cpp 19KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692
  1. /*********
  2. *
  3. * This file is part of BibleTime's source code, http://www.bibletime.info/.
  4. *
  5. * Copyright 1999-2006 by the BibleTime developers.
  6. * The BibleTime source code is licensed under the GNU General Public License version 2.0.
  7. *
  8. **********/
  9. //BibleTime includes
  10. #include "cswordbackend.h"
  11. #include "centrydisplay.h"
  12. #include "cbookdisplay.h"
  13. #include "cchapterdisplay.h"
  14. #include "cswordbiblemoduleinfo.h"
  15. #include "cswordcommentarymoduleinfo.h"
  16. #include "cswordlexiconmoduleinfo.h"
  17. #include "cswordbookmoduleinfo.h"
  18. #include "bt_thmlhtml.h"
  19. #include "bt_thmlplain.h"
  20. #include "bt_osishtml.h"
  21. #include "bt_gbfhtml.h"
  22. #include "bt_plainhtml.h"
  23. #include "osismorphsegmentation.h"
  24. #include "frontend/cbtconfig.h"
  25. #include <dirent.h>
  26. #include <unistd.h>
  27. #include <ctype.h>
  28. //Qt includes
  29. #include <tqdir.h>
  30. #include <tqfileinfo.h>
  31. //KDE includes
  32. #include <klocale.h>
  33. #include <kstringhandler.h>
  34. //Sword includes
  35. #include <swdisp.h>
  36. #include <swfiltermgr.h>
  37. #include <encfiltmgr.h>
  38. #include <rtfhtml.h>
  39. #include <filemgr.h>
  40. #include <utilstr.h>
  41. #include <swfilter.h>
  42. using std::string;
  43. using namespace Filters;
  44. using namespace Rendering;
  45. CSwordBackend::CSwordBackend()
  46. : sword::SWMgr(0, 0, false, new sword::EncodingFilterMgr( sword::ENC_UTF8 ), true) {
  47. m_displays.entry = 0;
  48. m_displays.chapter = 0;
  49. m_displays.book = 0;
  50. m_filters.gbf = 0;
  51. m_filters.thml = 0;
  52. m_filters.osis = 0;
  53. m_filters.plain = 0;
  54. filterInit();
  55. }
  56. CSwordBackend::CSwordBackend(const TQString& path, const bool augmentHome)
  57. : sword::SWMgr(!path.isEmpty() ? (const char*)path.local8Bit() : 0, false, new sword::EncodingFilterMgr( sword::ENC_UTF8 ), false, augmentHome) // don't allow module renaming, because we load from a path
  58. {
  59. qDebug("CSwordBackend::CSwordBackend for %s, using %s", path.latin1(), configPath);
  60. m_displays.entry = 0;
  61. m_displays.chapter = 0;
  62. m_displays.book = 0;
  63. m_filters.gbf = 0;
  64. m_filters.thml = 0;
  65. m_filters.osis = 0;
  66. m_filters.plain = 0;
  67. filterInit();
  68. }
  69. CSwordBackend::~CSwordBackend() {
  70. shutdownModules();
  71. delete m_filters.gbf;
  72. delete m_filters.plain;
  73. delete m_filters.thml;
  74. delete m_filters.osis;
  75. delete m_displays.book;
  76. delete m_displays.chapter;
  77. delete m_displays.entry;
  78. }
  79. /** Initializes the Sword modules. */
  80. const CSwordBackend::LoadError CSwordBackend::initModules() {
  81. // qWarning("globalSwordConfigPath is %s", globalConfPath);
  82. LoadError ret = NoError;
  83. shutdownModules(); //remove previous modules
  84. m_moduleList.clear();
  85. sword::ModMap::iterator end = Modules.end();
  86. ret = LoadError( Load() );
  87. for (sword::ModMap::iterator it = Modules.begin(); it != end; it++) {
  88. sword::SWModule* const curMod = (*it).second;
  89. CSwordModuleInfo* newModule = 0;
  90. if (!strcmp(curMod->Type(), "Biblical Texts")) {
  91. newModule = new CSwordBibleModuleInfo(curMod, this);
  92. newModule->module()->Disp(
  93. m_displays.chapter
  94. ? m_displays.chapter
  95. : (m_displays.chapter = new CChapterDisplay)
  96. );
  97. }
  98. else if (!strcmp(curMod->Type(), "Commentaries")) {
  99. newModule = new CSwordCommentaryModuleInfo(curMod, this);
  100. newModule->module()->Disp(
  101. m_displays.entry
  102. ? m_displays.entry
  103. : (m_displays.entry = new CEntryDisplay)
  104. );
  105. }
  106. else if (!strcmp(curMod->Type(), "Lexicons / Dictionaries")) {
  107. newModule = new CSwordLexiconModuleInfo(curMod, this);
  108. newModule->module()->Disp(
  109. m_displays.entry
  110. ? m_displays.entry
  111. : (m_displays.entry = new CEntryDisplay)
  112. );
  113. }
  114. else if (!strcmp(curMod->Type(), "Generic Books")) {
  115. newModule = new CSwordBookModuleInfo(curMod, this);
  116. newModule->module()->Disp(
  117. m_displays.book
  118. ? m_displays.book
  119. : (m_displays.book = new CBookDisplay)
  120. );
  121. }
  122. if (newModule) {
  123. //append the new modules to our list, but only if it's supported
  124. //the constructor of CSwordModuleInfo prints a waring on stdout
  125. if (!newModule->hasVersion() || (newModule->minimumSwordVersion() <= sword::SWVersion::currentVersion)) {
  126. m_moduleList.append( newModule );
  127. }
  128. }
  129. }
  130. ListCSwordModuleInfo::iterator end_it = m_moduleList.end();
  131. for (ListCSwordModuleInfo::iterator it = m_moduleList.begin() ; it != end_it; ++it) {
  132. // for (m_moduleList.first(); m_moduleList.current(); m_moduleList.next()) {
  133. m_moduleDescriptionMap.insert( (*it)->config(CSwordModuleInfo::Description), (*it)->name() );
  134. }
  135. //unlock modules if keys are present
  136. // ListCSwordModuleInfo::iterator end_it = m_moduleList.end();
  137. for (ListCSwordModuleInfo::iterator it = m_moduleList.begin() ; it != end_it; ++it) {
  138. // for (m_moduleList.first(); m_moduleList.current(); m_moduleList.next()) {
  139. if ( (*it)->isEncrypted() ) {
  140. const TQString unlockKey = CBTConfig::getModuleEncryptionKey( (*it)->name() ).latin1();
  141. if (!unlockKey.isNull()) {
  142. setCipherKey( (*it)->name().latin1(), unlockKey.latin1() );
  143. }
  144. }
  145. }
  146. return ret;
  147. }
  148. void CSwordBackend::AddRenderFilters(sword::SWModule *module, sword::ConfigEntMap &section) {
  149. sword::SWBuf moduleDriver;
  150. sword::SWBuf sourceformat;
  151. sword::ConfigEntMap::iterator entry;
  152. bool noDriver = true;
  153. sourceformat = ((entry = section.find("SourceType")) != section.end()) ? (*entry).second : (sword::SWBuf) "";
  154. moduleDriver = ((entry = section.find("ModDrv")) != section.end()) ? (*entry).second : (sword::SWBuf) "";
  155. if (sourceformat == "GBF") {
  156. if (!m_filters.gbf) {
  157. m_filters.gbf = new BT_GBFHTML();
  158. }
  159. module->AddRenderFilter(m_filters.gbf);
  160. noDriver = false;
  161. }
  162. else if (sourceformat == "PLAIN") {
  163. if (!m_filters.plain) {
  164. m_filters.plain = new BT_PLAINHTML();
  165. }
  166. module->AddRenderFilter(m_filters.plain);
  167. noDriver = false;
  168. }
  169. else if (sourceformat == "ThML") {
  170. if (!m_filters.thml) {
  171. m_filters.thml = new BT_ThMLHTML();
  172. }
  173. module->AddRenderFilter(m_filters.thml);
  174. noDriver = false;
  175. }
  176. else if (sourceformat == "OSIS") {
  177. if (!m_filters.osis) {
  178. m_filters.osis = new BT_OSISHTML();
  179. }
  180. module->AddRenderFilter(m_filters.osis);
  181. noDriver = false;
  182. }
  183. if (noDriver) { //no driver found
  184. if ( (moduleDriver == "RawCom") || (moduleDriver == "RawLD") ) {
  185. if (!m_filters.plain) {
  186. m_filters.plain = new BT_PLAINHTML();
  187. }
  188. module->AddRenderFilter(m_filters.plain);
  189. noDriver = false;
  190. }
  191. }
  192. }
  193. /** This function deinitializes the modules and deletes them. */
  194. const bool CSwordBackend::shutdownModules() {
  195. ListCSwordModuleInfo::iterator it = m_moduleList.begin();
  196. ListCSwordModuleInfo::iterator end = m_moduleList.end();
  197. while (it != end) {
  198. CSwordModuleInfo* current = (*it);
  199. it = m_moduleList.remove(it);
  200. delete current;
  201. }
  202. Q_ASSERT(m_moduleList.count() == 0);
  203. //BT mods are deleted now, delete Sword mods, too.
  204. DeleteMods();
  205. return true;
  206. }
  207. /** Returns true if the given option is enabled. */
  208. const bool CSwordBackend::isOptionEnabled( const CSwordModuleInfo::FilterTypes type) {
  209. return (getGlobalOption( optionName(type).latin1() ) == "On");
  210. }
  211. /** Sets the given options enabled or disabled depending on the second parameter. */
  212. void CSwordBackend::setOption( const CSwordModuleInfo::FilterTypes type, const int state ) {
  213. sword::SWBuf value;
  214. switch (type) {
  215. case CSwordModuleInfo::textualVariants:
  216. if (state == 0) {
  217. value = "Primary Reading";
  218. }
  219. else if (state == 1) {
  220. value = "Secondary Reading";
  221. }
  222. else {
  223. value = "All Readings";
  224. }
  225. break;
  226. default:
  227. value = state ? "On": "Off";
  228. break;
  229. };
  230. if (value.length())
  231. setGlobalOption(optionName(type).latin1(), value.c_str());
  232. }
  233. void CSwordBackend::setFilterOptions( const CSwordBackend::FilterOptions options) {
  234. setOption( CSwordModuleInfo::footnotes, options.footnotes );
  235. setOption( CSwordModuleInfo::strongNumbers, options.strongNumbers );
  236. setOption( CSwordModuleInfo::headings, options.headings );
  237. setOption( CSwordModuleInfo::morphTags, options.morphTags );
  238. setOption( CSwordModuleInfo::lemmas, options.lemmas );
  239. setOption( CSwordModuleInfo::hebrewPoints, options.hebrewPoints );
  240. setOption( CSwordModuleInfo::hebrewCantillation, options.hebrewCantillation );
  241. setOption( CSwordModuleInfo::greekAccents, options.greekAccents );
  242. setOption( CSwordModuleInfo::redLetterWords, options.redLetterWords );
  243. setOption( CSwordModuleInfo::textualVariants, options.textualVariants );
  244. setOption( CSwordModuleInfo::morphSegmentation, options.morphSegmentation );
  245. // setOption( CSwordModuleInfo::transliteration, options.transliteration );
  246. setOption( CSwordModuleInfo::scriptureReferences, options.scriptureReferences);
  247. }
  248. void CSwordBackend::setDisplayOptions( const CSwordBackend::DisplayOptions ) {
  249. /* if (m_displays.entry) {
  250. m_displays.entry->setDisplayOptions(options);
  251. }
  252. if (m_displays.chapter) {
  253. m_displays.chapter->setDisplayOptions(options);
  254. }
  255. if (m_displays.book) {
  256. m_displays.book->setDisplayOptions(options);
  257. }
  258. */
  259. }
  260. /** This function searches for a module with the specified description */
  261. CSwordModuleInfo* const CSwordBackend::findModuleByDescription(const TQString& description) {
  262. CSwordModuleInfo* ret = 0;
  263. ListCSwordModuleInfo::iterator end_it = m_moduleList.end();
  264. for (ListCSwordModuleInfo::iterator it = m_moduleList.begin() ; it != end_it; ++it) {
  265. if ( (*it)->config(CSwordModuleInfo::Description) == description ) {
  266. ret = *it;
  267. break;
  268. }
  269. }
  270. return ret;
  271. }
  272. /** This function searches for a module with the specified description */
  273. const TQString CSwordBackend::findModuleNameByDescription(const TQString& description) {
  274. if (m_moduleDescriptionMap.contains(description)) {
  275. return m_moduleDescriptionMap[description];
  276. }
  277. return TQString::null;
  278. }
  279. /** This function searches for a module with the specified name */
  280. CSwordModuleInfo* const CSwordBackend::findModuleByName(const TQString& name) {
  281. CSwordModuleInfo* ret = 0;
  282. ListCSwordModuleInfo::iterator end_it = m_moduleList.end();
  283. for (ListCSwordModuleInfo::iterator it = m_moduleList.begin() ; it != end_it; ++it) {
  284. if ( (*it)->name() == name ) {
  285. ret = *it;
  286. break;
  287. }
  288. }
  289. return ret;
  290. }
  291. CSwordModuleInfo* const CSwordBackend::findSwordModuleByPointer(const sword::SWModule* const swmodule) {
  292. CSwordModuleInfo* ret = 0;
  293. ListCSwordModuleInfo::iterator end_it = m_moduleList.end();
  294. for (ListCSwordModuleInfo::iterator it = m_moduleList.begin() ; it != end_it; ++it) {
  295. if ( (*it)->module() == swmodule ) {
  296. ret = *it;
  297. break;
  298. }
  299. }
  300. return ret;
  301. }
  302. CSwordModuleInfo* const CSwordBackend::findModuleByPointer(const CSwordModuleInfo* const module) {
  303. CSwordModuleInfo* ret = 0;
  304. ListCSwordModuleInfo::iterator end_it = m_moduleList.end();
  305. for (ListCSwordModuleInfo::iterator it = m_moduleList.begin() ; it != end_it; ++it) {
  306. if ( (*it) == module ) {
  307. ret = *it;
  308. break;
  309. }
  310. }
  311. return ret;
  312. }
  313. /** Returns our local config object to store the cipher keys etc. locally for each user. The values of the config are merged with the global config. */
  314. const bool CSwordBackend::moduleConfig(const TQString& module, sword::SWConfig& moduleConfig) {
  315. sword::SectionMap::iterator section;
  316. DIR *dir = opendir(configPath);
  317. struct dirent *ent;
  318. bool foundConfig = false;
  319. TQString modFile;
  320. if (dir) { // find and update .conf file
  321. rewinddir(dir);
  322. while ((ent = readdir(dir)) && !foundConfig) {
  323. if ((strcmp(ent->d_name, ".")) && (strcmp(ent->d_name, ".."))) {
  324. modFile.setLatin1(configPath);
  325. modFile.append("/");
  326. modFile.append( TQString::fromLocal8Bit(ent->d_name) );
  327. moduleConfig = sword::SWConfig( (const char*)modFile.local8Bit() );
  328. section = moduleConfig.Sections.find( (const char*)module.local8Bit() );
  329. foundConfig = ( section != moduleConfig.Sections.end() );
  330. }
  331. }
  332. closedir(dir);
  333. }
  334. else { //try to read mods.conf
  335. moduleConfig = sword::SWConfig("");//global config
  336. section = config->Sections.find( (const char*)module.local8Bit() );
  337. foundConfig = ( section != config->Sections.end() );
  338. sword::ConfigEntMap::iterator entry;
  339. if (foundConfig) { //copy module section
  340. for (entry = (*section).second.begin(); entry != (*section).second.end(); entry++) {
  341. moduleConfig.Sections[(*section).first].insert(sword::ConfigEntMap::value_type((*entry).first, (*entry).second));
  342. }
  343. }
  344. }
  345. if (!foundConfig && configType != 2) { //search in $HOME/.sword/
  346. TQString myPath(getenv("HOME"));
  347. myPath.append("/.sword/mods.d");
  348. dir = opendir(myPath.latin1());
  349. if (dir) {
  350. rewinddir(dir);
  351. while ((ent = readdir(dir)) && !foundConfig) {
  352. if ((strcmp(ent->d_name, ".")) && (strcmp(ent->d_name, ".."))) {
  353. modFile = myPath;
  354. modFile.append('/');
  355. modFile.append(ent->d_name);
  356. moduleConfig = sword::SWConfig( (const char*)modFile.local8Bit() );
  357. section = moduleConfig.Sections.find( (const char*)module.local8Bit() );
  358. foundConfig = ( section != moduleConfig.Sections.end() );
  359. }
  360. }
  361. closedir(dir);
  362. }
  363. }
  364. return foundConfig;
  365. }
  366. /** Returns the text used for the option given as parameter. */
  367. const TQString CSwordBackend::optionName( const CSwordModuleInfo::FilterTypes option ) {
  368. switch (option) {
  369. case CSwordModuleInfo::footnotes:
  370. return TQString("Footnotes");
  371. case CSwordModuleInfo::strongNumbers:
  372. return TQString("Strong's Numbers");
  373. case CSwordModuleInfo::headings:
  374. return TQString("Headings");
  375. case CSwordModuleInfo::morphTags:
  376. return TQString("Morphological Tags");
  377. case CSwordModuleInfo::lemmas:
  378. return TQString("Lemmas");
  379. case CSwordModuleInfo::hebrewPoints:
  380. return TQString("Hebrew Vowel Points");
  381. case CSwordModuleInfo::hebrewCantillation:
  382. return TQString("Hebrew Cantillation");
  383. case CSwordModuleInfo::greekAccents:
  384. return TQString("Greek Accents");
  385. case CSwordModuleInfo::redLetterWords:
  386. return TQString("Words of Christ in Red");
  387. case CSwordModuleInfo::textualVariants:
  388. return TQString("Textual Variants");
  389. case CSwordModuleInfo::scriptureReferences:
  390. return TQString("Cross-references");
  391. case CSwordModuleInfo::morphSegmentation:
  392. return TQString("Morph Segmentation");
  393. // case CSwordModuleInfo::transliteration:
  394. // return TQString("Transliteration");
  395. }
  396. return TQString::null;
  397. }
  398. /** Returns the translated name of the option given as parameter. */
  399. const TQString CSwordBackend::translatedOptionName(const CSwordModuleInfo::FilterTypes option) {
  400. switch (option) {
  401. case CSwordModuleInfo::footnotes:
  402. return i18n("Footnotes");
  403. case CSwordModuleInfo::strongNumbers:
  404. return i18n("Strong's numbers");
  405. case CSwordModuleInfo::headings:
  406. return i18n("Headings");
  407. case CSwordModuleInfo::morphTags:
  408. return i18n("Morphological tags");
  409. case CSwordModuleInfo::lemmas:
  410. return i18n("Lemmas");
  411. case CSwordModuleInfo::hebrewPoints:
  412. return i18n("Hebrew vowel points");
  413. case CSwordModuleInfo::hebrewCantillation:
  414. return i18n("Hebrew cantillation marks");
  415. case CSwordModuleInfo::greekAccents:
  416. return i18n("Greek accents");
  417. case CSwordModuleInfo::redLetterWords:
  418. return i18n("Red letter words");
  419. case CSwordModuleInfo::textualVariants:
  420. return i18n("Textual variants");
  421. case CSwordModuleInfo::scriptureReferences:
  422. return i18n("Scripture cross-references");
  423. case CSwordModuleInfo::morphSegmentation:
  424. return i18n("Morph segmentation");
  425. // case CSwordModuleInfo::transliteration:
  426. // return i18n("Transliteration between scripts");
  427. }
  428. return TQString::null;
  429. }
  430. const TQString CSwordBackend::configOptionName( const CSwordModuleInfo::FilterTypes option ) {
  431. switch (option) {
  432. case CSwordModuleInfo::footnotes:
  433. return TQString("Footnotes");
  434. case CSwordModuleInfo::strongNumbers:
  435. return TQString("Strongs");
  436. case CSwordModuleInfo::headings:
  437. return TQString("Headings");
  438. case CSwordModuleInfo::morphTags:
  439. return TQString("Morph");
  440. case CSwordModuleInfo::lemmas:
  441. return TQString("Lemma");
  442. case CSwordModuleInfo::hebrewPoints:
  443. return TQString("HebrewPoints");
  444. case CSwordModuleInfo::hebrewCantillation:
  445. return TQString("Cantillation");
  446. case CSwordModuleInfo::greekAccents:
  447. return TQString("GreekAccents");
  448. case CSwordModuleInfo::redLetterWords:
  449. return TQString("RedLetterWords");
  450. case CSwordModuleInfo::textualVariants:
  451. return TQString("Variants");
  452. case CSwordModuleInfo::scriptureReferences:
  453. return TQString("Scripref");
  454. case CSwordModuleInfo::morphSegmentation:
  455. return TQString("MorphSegmentation");
  456. default:
  457. return TQString::null;
  458. }
  459. return TQString::null;
  460. }
  461. const TQString CSwordBackend::booknameLanguage( const TQString& language ) {
  462. if (!language.isEmpty()) {
  463. sword::LocaleMgr::getSystemLocaleMgr()->setDefaultLocaleName( language.latin1() );
  464. //refresh the locale of all Bible and commentary modules!
  465. const ListCSwordModuleInfo::iterator end_it = m_moduleList.end();
  466. //use what sword returns, language may be different
  467. TQString newLocaleName( sword::LocaleMgr::getSystemLocaleMgr()->getDefaultLocaleName() );
  468. for (ListCSwordModuleInfo::iterator it = m_moduleList.begin(); it != end_it; ++it) {
  469. if ( ((*it)->type() == CSwordModuleInfo::Bible) || ((*it)->type() == CSwordModuleInfo::Commentary) ) {
  470. //Create a new key, it will get the default bookname language
  471. ((sword::VerseKey*)((*it)->module()->getKey()))->setLocale( newLocaleName.latin1() );
  472. }
  473. }
  474. }
  475. return TQString( sword::LocaleMgr::getSystemLocaleMgr()->getDefaultLocaleName() );
  476. }
  477. /** Reload all Sword modules. */
  478. void CSwordBackend::reloadModules() {
  479. shutdownModules();
  480. //delete Sword's config to make Sword reload it!
  481. if (myconfig) { // force reload on config object because we may have changed the paths
  482. delete myconfig;
  483. config = myconfig = 0;
  484. loadConfigDir(configPath);
  485. }
  486. else if (config) {
  487. config->Load();
  488. }
  489. initModules();
  490. }
  491. const TQStringList CSwordBackend::swordDirList() {
  492. TQStringList ret;
  493. const TQString home = TQString(getenv("HOME"));
  494. //return a list of used Sword dirs. Useful for the installer
  495. TQString configPath = TQString("%1/.sword/sword.conf").arg(home);
  496. if (!TQFile(configPath).exists()) {
  497. configPath = globalConfPath; //e.g. /etc/sword.conf, /usr/local/etc/sword.conf
  498. }
  499. TQStringList configs = TQStringList::split(":", configPath);
  500. /*ToDo: Use the const iterator as soon as we switch to Qt > 3.1
  501. for (TQStringList::const_iterator it = configs.constBegin(); it != configs.constEnd(); ++it) {*/
  502. for (TQStringList::const_iterator it = configs.begin(); it != configs.end(); ++it) {
  503. if (!TQFileInfo(*it).exists()) {
  504. continue;
  505. }
  506. //get all DataPath and AugmentPath entries from the config file and add them to the list
  507. sword::SWConfig conf( (*it).latin1() );
  508. ret << conf["Install"]["DataPath"].c_str();
  509. sword::ConfigEntMap group = conf["Install"];
  510. sword::ConfigEntMap::iterator start = group.equal_range("AugmentPath").first;
  511. sword::ConfigEntMap::iterator end = group.equal_range("AugmentPath").second;
  512. for (sword::ConfigEntMap::const_iterator it = start; it != end; ++it) {
  513. ret << it->second.c_str(); //added augment path
  514. }
  515. }
  516. if (!home.isEmpty()) {
  517. ret << home + "/.sword/";
  518. }
  519. return ret;
  520. }
  521. void CSwordBackend::filterInit() {
  522. // qWarning("## INIT");
  523. SWOptionFilter* tmpFilter = new OSISMorphSegmentation();
  524. optionFilters.insert(OptionFilterMap::value_type("OSISMorphSegmentation", tmpFilter));
  525. cleanupFilters.push_back(tmpFilter);
  526. //HACK: replace Sword's ThML strip filter with our own version
  527. //remove this hack as soon as Sword is fixed
  528. cleanupFilters.remove(thmlplain);
  529. delete thmlplain;
  530. thmlplain = new BT_ThMLPlain();
  531. cleanupFilters.push_back(thmlplain);
  532. }