/** Initializes the backend */ void BibleTime::initBackends() { qDebug("BibleTime::initBackends"); sword::StringMgr::setSystemStringMgr( new BTStringMgr() ); sword::SWLog::getSystemLog()->setLogLevel(1); CSwordBackend* backend = new CSwordBackend(); backend->booknameLanguage(CBTConfig::get(CBTConfig::language) ); CPointers::setBackend(backend); const CSwordBackend::LoadError errorCode = CPointers::backend()->initModules(CSwordBackend::OtherChange); m_moduleList = 0; if ( errorCode == CSwordBackend::NoError ) { //no error m_moduleList = &(CPointers::backend()->moduleList()); } else { m_moduleList = 0; //show error message that initBackend failed //TODO: // switch (errorCode) { // case CSwordBackend::NoSwordConfig: //mods.d or mods.conf missing // { // KStartupLogo::hideSplash(); // qDebug("case CSwordBackend::NoSwordConfig"); // BookshelfManager::CSwordSetupDialog dlg; // dlg.showPart( BookshelfManager::CSwordSetupDialog::Sword ); // dlg.exec(); // break; // } // // case CSwordBackend::NoModules: //no modules installed, but config exists // { // KStartupLogo::hideSplash(); // qDebug("case CSwordBackend::NoModules"); // BookshelfManager::CSwordSetupDialog dlg; // dlg.showPart( BookshelfManager::CSwordSetupDialog::Install ); // dlg.exec(); // break; // } // // default: //unknown error // { // KStartupLogo::hideSplash(); // qDebug("unknown error"); // BookshelfManager::CSwordSetupDialog dlg; // dlg.showPart( BookshelfManager::CSwordSetupDialog::Sword ); // dlg.exec(); // break; // } // } } //This function will // - delete all orphaned indexes (no module present) if autoDeleteOrphanedIndices is true // - delete all indices of modules where hasIndex() returns false //BookshelfManager::CManageIndicesWidget::deleteOrphanedIndices(); //TODO: //backend::deleteOrphanedIndices(); }
void ModuleInterface::unlock(const QString& moduleName, const QString& unlockKey) { CSwordModuleInfo* module = CSwordBackend::instance()->findModuleByName(moduleName); if (module) { module->unlock(unlockKey); // Re-initialize module pointers: CSwordBackend *backend = CSwordBackend::instance(); backend->reloadModules(CSwordBackend::OtherChange); module = CSwordBackend::instance()->findModuleByName(moduleName); updateWorksModel(); } }
// Also tests key() void test_CSwordVerseKey::setKey() { QFETCH(QString, moduleName); QFETCH(QString, reference); CSwordBackend* backend = CSwordBackend::instance(); CSwordModuleInfo* module = backend->findModuleByName(moduleName); QVERIFY(module != 0); CSwordVerseKey* vKey = dynamic_cast<CSwordVerseKey*>(CSwordKey::createInstance(module)); vKey->setKey(reference); QString newKey = vKey->key(); QCOMPARE(newKey, reference); }
void test_CSwordVerseKey::initTestCase() { QVERIFY(util::directory::initDirectoryCache()); CSwordBackend* backend = CSwordBackend::createInstance(); QVERIFY(backend != 0); BibleTimeApp::init(); backend->initModules(CSwordBackend::OtherChange); m_moduleKJV = backend->findModuleByName("KJV"); QVERIFY(m_moduleKJV != 0); m_moduleKJVA = backend->findModuleByName("KJVA"); QVERIFY(m_moduleKJVA != 0); m_moduleJosephus = backend->findModuleByName("Josephus"); QVERIFY(m_moduleKJVA != 0); }
CSwordBackend* BTInstallMgr::Tool::backend( sword::InstallSource* const is) { Q_ASSERT(is); if (!is) { return 0; } CSwordBackend* ret = 0; if (RemoteConfig::isRemoteSource(is)) { // qWarning("## remote backend for %s", is->localShadow.c_str()); ret = new CSwordBackend( QString(is->localShadow.c_str()), false ); } else { // qWarning("## local backend for %s", QString(is->directory.c_str()).latin1()); ret = new CSwordBackend( QString(is->directory.c_str()) ); } Q_ASSERT(ret); if (ret) { ret->initModules(); } return ret; }
/** Initializes the backend */ void BibleTime::initBackends() { initSwordConfigFile(); if (!sword::SWMgr::isICU) sword::StringMgr::setSystemStringMgr(new BtStringMgr()); sword::SWLog::getSystemLog()->setLogLevel(btApp->debugMode() ? sword::SWLog::LOG_DEBUG : sword::SWLog::LOG_ERROR); #ifdef Q_OS_MAC // set a LocaleMgr with a fixed path to the locales.d of the DMG image on MacOS // note: this must be done after setting the BTStringMgr, because this will reset the LocaleMgr qDebug() << "Using sword locales dir: " << util::directory::getSwordLocalesDir().absolutePath().toUtf8(); sword::LocaleMgr::setSystemLocaleMgr(new sword::LocaleMgr(util::directory::getSwordLocalesDir().absolutePath().toUtf8())); #endif /* Set book names language if not set. This is a hack. We do this call here, because we need to keep the setting displayed in BtLanguageSettingsPage in sync with the language of the book names displayed, so that both would always use the same setting. */ CDisplaySettingsPage::resetLanguage(); /// \todo refactor this hack CSwordBackend *backend = CSwordBackend::createInstance(); backend->booknameLanguage(btConfig().value<QString>("GUI/booknameLanguage", QLocale::system().name())); CSwordBackend::instance()->initModules(CSwordBackend::OtherChange); // This function will // - delete all orphaned indexes (no module present) if autoDeleteOrphanedIndices is true // - delete all indices of modules where hasIndex() returns false backend->deleteOrphanedIndices(); }
/** Initializes the backend */ void BibleTime::initBackends() { initSwordConfigFile(); sword::StringMgr::setSystemStringMgr( new BtStringMgr() ); sword::SWLog::getSystemLog()->setLogLevel(sword::SWLog::LOG_ERROR); if (qApp->property("--debug").toBool()) { sword::SWLog::getSystemLog()->setLogLevel(sword::SWLog::LOG_DEBUG); } #ifdef Q_OS_MAC // set a LocaleMgr with a fixed path to the locales.d of the DMG image on MacOS // note: this must be done after setting the BTStringMgr, because this will reset the LocaleMgr qDebug() << "Using sword locales dir: " << util::directory::getSwordLocalesDir().absolutePath().toUtf8(); sword::LocaleMgr::setSystemLocaleMgr(new sword::LocaleMgr(util::directory::getSwordLocalesDir().absolutePath().toUtf8())); #endif /* Set book names language if not set. This is a hack. We do this call here, because we need to keep the setting displayed in BtLanguageSettingsPage in sync with the language of the book names displayed, so that both would always use the same setting. */ BtLanguageSettingsPage::resetLanguage(); /// \todo refactor this hack CSwordBackend *backend = CSwordBackend::createInstance(); backend->booknameLanguage(btConfig().value<QString>("language", QLocale::system().name())); const CSwordBackend::LoadError errorCode = CSwordBackend::instance()->initModules(CSwordBackend::OtherChange); if (errorCode != CSwordBackend::NoError) { //show error message that initBackend failed /// \todo // switch (errorCode) { // case CSwordBackend::NoSwordConfig: //mods.d or mods.conf missing // { // KStartupLogo::hideSplash(); // qDebug() << "case CSwordBackend::NoSwordConfig"; // BookshelfManager::CSwordSetupDialog dlg; // dlg.showPart( BookshelfManager::CSwordSetupDialog::Sword ); // dlg.exec(); // break; // } // // case CSwordBackend::NoModules: //no modules installed, but config exists // { // KStartupLogo::hideSplash(); // qDebug() << "case CSwordBackend::NoModules"; // BookshelfManager::CSwordSetupDialog dlg; // dlg.showPart( BookshelfManager::CSwordSetupDialog::Install ); // dlg.exec(); // break; // } // // default: //unknown error // { // KStartupLogo::hideSplash(); // qDebug() << "unknown error"; // BookshelfManager::CSwordSetupDialog dlg; // dlg.showPart( BookshelfManager::CSwordSetupDialog::Sword ); // dlg.exec(); // break; // } // } } // This function will // - delete all orphaned indexes (no module present) if autoDeleteOrphanedIndices is true // - delete all indices of modules where hasIndex() returns false backend->deleteOrphanedIndices(); }