Example #1
0
SWModule *getModule(JNIEnv *env, jobject me) {

	init(); 

	SWModule *module = 0;
	jclass clazzSWModule = env->FindClass("org/crosswire/android/sword/SWModule");
	jfieldID fieldID = env->GetFieldID(clazzSWModule, "name", "Ljava/lang/String;");
	jfieldID sourceFieldID = env->GetFieldID(clazzSWModule, "remoteSourceName", "Ljava/lang/String;");
	jstring modNameJS = (jstring)env->GetObjectField(me, fieldID);
	jstring sourceNameJS = (jstring)env->GetObjectField(me, sourceFieldID);
     const char *modName = (modNameJS?env->GetStringUTFChars(modNameJS, NULL):0);
     const char *sourceName = (sourceNameJS?env->GetStringUTFChars(sourceNameJS, NULL):0);
	if (sourceName && *sourceName) {
		initInstall();
		InstallSourceMap::iterator source = installMgr->sources.find(sourceName);
		if (source == installMgr->sources.end()) {
			SWMgr *mgr = source->second->getMgr();
			module = mgr->getModule(modName);
		}
	}
	else module = mgr->getModule(modName);
     if (modName) env->ReleaseStringUTFChars(modNameJS, modName);
     if (sourceName) env->ReleaseStringUTFChars(sourceNameJS, sourceName);
	return module;
}
Example #2
0
int main(int argc, char **argv) {
	SWMgr library;
	SWModule *darby = library.getModule("Darby");
	darby->setKey("James 1:19");
	cout << darby->RenderText();

	return 0;
}
Example #3
0
int main(int argc, char **argv) {

	SWMgr mgr;
	SWModule *mod = mgr.getModule("KJVgb");

	VerseKey *key1 = (VerseKey *)mod->createKey();

	key1->setTestament(2);
	key1->setBook(4);
	key1->setChapter(2);
	key1->setVerse(3);

	cout << "\n" << key1->getText() << ":\n\n";

	ListKey keys;
	keys << *key1;

	cout << "\n" << keys.getRangeText() << ":\n\n";

	ListKey keys2 = keys;

	cout << "\n" << keys2.getRangeText() << ":\n\n";

	keys = key1->parseVerseList("Lk.4.5");

	cout << "\n" << key1->getText() << ":\n\n";

	key1->setText("jn.6.7");

	cout << "\n" << key1->getText() << ":\n\n";
	

	mod->setKey("lk.2.3");

	cout << "\n" << mod->getKeyText() << ":\n" << endl;
	cout << mod->getRawEntry() << endl;


	cout << "\nListkey persist key iteration test\n\n";
	keys = key1->parseVerseList("mat1", 0, true);

	for (keys = TOP; !keys.popError(); keys++) {
		cout << "\n" << keys.getText() << ":\n" << endl;
	}


	keys.setPersist(true);

	mod->setKey(keys);

	for ((*mod) = TOP; !mod->popError(); (*mod)++) {
		cout << "\n" << mod->getKeyText() << ":\n" << endl;
	}

	delete key1;

	return 0;
}
Example #4
0
/************************************************************************
 * getModuleStatus - compare the modules of two SWMgrs and return a 
 * 	vector describing the status of each.  See MODSTAT_*
 */
map<SWModule *, int> InstallMgr::getModuleStatus(const SWMgr &base, const SWMgr &other) {
	map<SWModule *, int> retVal;
	SWBuf targetVersion;
	SWBuf sourceVersion;
	SWBuf softwareVersion;
	bool cipher;
	bool keyPresent;
	int modStat;
	
	for (ModMap::const_iterator mod = other.Modules.begin(); mod != other.Modules.end(); mod++) {
	
		modStat = 0;

		cipher = false;
		keyPresent = false;
		
		const char *v = mod->second->getConfigEntry("CipherKey");
		if (v) {
			cipher = true;
			keyPresent = *v;
		}
		
		targetVersion = "0.0";
		sourceVersion = "1.0";
		softwareVersion = (const char *)SWVersion::currentVersion;
		
		v = mod->second->getConfigEntry("Version");
		if (v) sourceVersion = v;

		v = mod->second->getConfigEntry("MinimumVersion");
		if (v) softwareVersion = v;

		const SWModule *baseMod = base.getModule(mod->first);
		if (baseMod) {
			targetVersion = "1.0";
			v = baseMod->getConfigEntry("Version");
			if (v) targetVersion = v;
			modStat |= (SWVersion(sourceVersion.c_str()) > SWVersion(targetVersion.c_str())) ? MODSTAT_UPDATED : (SWVersion(sourceVersion.c_str()) < SWVersion(targetVersion.c_str())) ? MODSTAT_OLDER : MODSTAT_SAMEVERSION;
		}
		else modStat |= MODSTAT_NEW;

		if (cipher) modStat |= MODSTAT_CIPHERED;
		if (keyPresent) modStat |= MODSTAT_CIPHERKEYPRESENT;
		retVal[mod->second] = modStat;
	}
	return retVal;
}
Example #5
0
int main() {
    SWMgr library;

    auto const book(library.getModule("KJV"));

    VerseKey *vk = (VerseKey *) book->getKey();
    for (;!vk->popError();vk->setChapter(vk->getChapter()+1)) {
        vk->setVerse(vk->getVerseMax());
        std::string text = book->stripText();
        trimString(text);
        if (!text.empty() && (*text.rbegin()) == ',') {
            cout << vk->getText() << ":\n\n";
            cout << text << endl;
        }
    }

    return 0;
}
Example #6
0
int main(int argc, char **argv) {

        const char *modName = "HunKar";
        SWMgr library;
        SWModule *book = library.getModule(modName);
        if (!book) {
                cerr << "Can't find module: " << modName << endl;
                return -1;
        }
        VerseKey* key = ((VerseKey *)book->getKey());

        key->setIntros(true);
        book->setSkipConsecutiveLinks(true);
        book->setPosition(TOP);

        cout << *key << endl;
        return 0;
}
Example #7
0
int main(int argc, char **argv) {

	SWMgr library;

	SWModule *book = library.getModule("KJV");

	VerseKey *vk = (VerseKey *) book->getKey();
	for (;!vk->popError();vk->setChapter(vk->getChapter()+1)) {
		vk->setVerse(vk->getVerseMax());
		SWBuf text = book->stripText();
		text = text.trim();
		if (text.endsWith(",")) {
			cout << vk->getText() << ":\n\n";
			cout << text << endl;
		}
	}

	return 0;
}
Example #8
0
int main(int argc, char **argv) {

	cout << "\n";

	const char *modName = (argc > 1) ? argv[1] : "KJV";
	SWMgr manager;
	SWModule *bible = manager.getModule(modName);
	if (!bible) {
		cout << modName << " module is not installed.\nPlease install to show versification (v11n) from this specific Bible.\nShowing builtin KJV v11n scheme..\n\n";
	}

	VerseKey *vk = (bible) ? (VerseKey *)bible->getKey() : new VerseKey();

	for ((*vk) = TOP; !vk->popError(); vk->setBook(vk->getBook()+1)) {
		cout << vk->getBookName() << "\n";
	}

	// if we 'new'ed a VerseKey unassociated with a module, above, then we should delete it.
	if (!bible) delete vk;

	return 0;
}
Example #9
0
int main() {

        const char *modName = "RusCARS";
        const char *keyTextRegular = "1Sam1.20";
        const char *keyTextNeedsNormalization = "1Sam1.200";


        SWMgr library;
        auto const book(library.getModule(modName));
        if (!book) {
                cerr << "Can't find module: " << modName << endl;
                return -1;
        }


    // get two VerseKey objects for a module
    std::unique_ptr<VerseKey> verse(
                static_cast<VerseKey *>(book->createKey().release()));
    std::unique_ptr<VerseKey> verseNormalized(
                static_cast<VerseKey *>(book->createKey().release()));

    // turn off autonormalization for one VerseKey reference
        verse->setAutoNormalize(false);

    // set a reference not requiring normalization to both VerseKey objects
    verse->setText(keyTextRegular);
    verseNormalized->setText(keyTextRegular);

    // check to see if they are equal
        cout << verse->getText() << ((*verse) == (*verseNormalized) ? " == " : " != ") << verseNormalized->getText() << endl;

    // now do the same for a reference which requires normalization in this module's v11n system
    verse->setText(keyTextNeedsNormalization);
    verseNormalized->setText(keyTextNeedsNormalization);

        cout << verse->getText() << ((*verse) == (*verseNormalized) ? " == " : " != ") << verseNormalized->getText() << endl;

    return 0;
}
Example #10
0
/*
 * Class:     org_crosswire_android_sword_InstallMgr
 * Method:    getRemoteModuleByName
 * Signature: (Ljava/lang/String;Ljava/lang/String;)Lorg/crosswire/android/sword/SWModule;
 */
JNIEXPORT jobject JNICALL Java_org_crosswire_android_sword_InstallMgr_getRemoteModuleByName
  (JNIEnv *env, jobject me, jstring sourceNameJS, jstring modNameJS) {

	jobject retVal = 0;

	initInstall();

	const char *sourceName = env->GetStringUTFChars(sourceNameJS, NULL);
SWLog::getSystemLog()->logDebug("getRemoteModuleByName: sourceName: %s\n", sourceName);
	InstallSourceMap::iterator source = installMgr->sources.find(sourceName);
	env->ReleaseStringUTFChars(sourceNameJS, sourceName);

	if (source == installMgr->sources.end()) {
SWLog::getSystemLog()->logDebug("Couldn't find remote source [%s]\n", sourceName);
		return 0;
	}

	SWMgr *mgr = source->second->getMgr();

     const char *modName = env->GetStringUTFChars(modNameJS, NULL);
	sword::SWModule *module = mgr->getModule(modName);
     env->ReleaseStringUTFChars(modNameJS, modName);

	if (module) {
		SWBuf type = module->Type();
		SWBuf cat = module->getConfigEntry("Category");
		if (cat.length() > 0) type = cat;
		jfieldID fieldID;
		jclass clazzSWModule = env->FindClass("org/crosswire/android/sword/SWModule");
		retVal = env->AllocObject(clazzSWModule); 
		fieldID = env->GetFieldID(clazzSWModule, "name", "Ljava/lang/String;"); env->SetObjectField(retVal, fieldID, env->NewStringUTF(assureValidUTF8(module->getName())));
		fieldID = env->GetFieldID(clazzSWModule, "description", "Ljava/lang/String;"); env->SetObjectField(retVal, fieldID, env->NewStringUTF(assureValidUTF8(module->getDescription())));
		fieldID = env->GetFieldID(clazzSWModule, "category", "Ljava/lang/String;"); env->SetObjectField(retVal, fieldID, env->NewStringUTF(assureValidUTF8(type.c_str())));
		fieldID = env->GetFieldID(clazzSWModule, "remoteSourceName", "Ljava/lang/String;"); env->SetObjectField(retVal, fieldID, sourceNameJS);
	}

	return retVal;

}
Example #11
0
int main(int argc, char **argv) {

	SWMgr library;
	SWModule *kjv = library.getModule((argc > 1)?argv[1]:"KJV");

	kjv->setKey(argc > 2 ? argv[2] : "Jn.3.16");

	VerseKey *key = (VerseKey *)kjv->getKey();

	int curVerse = key->getVerse();
	int curChapter = key->getChapter();
	int curBook = key->getBook();

	for (key->setVerse(1);
				(key->getBook()    == curBook)    &&
				(key->getChapter() == curChapter) &&
				!kjv->popError();
				(*kjv)++) {
		if (key->getVerse() == curVerse) cout << "* ";
		cout << key->getVerse() << " " << kjv->stripText() << "\n";
	}

	return 0;
}