[sword-svn] r2443 - in trunk/bindings/corba: . java/src/org/crosswire/sword/orb omniorbcpp orbitcpp

scribe at crosswire.org scribe at crosswire.org
Sat Aug 22 23:16:26 MST 2009


Author: scribe
Date: 2009-08-22 23:16:26 -0700 (Sat, 22 Aug 2009)
New Revision: 2443

Added:
   trunk/bindings/corba/omniorbcpp/
   trunk/bindings/corba/omniorbcpp/Makefile
   trunk/bindings/corba/omniorbcpp/server.cpp
   trunk/bindings/corba/omniorbcpp/swordorb-impl.cpp
   trunk/bindings/corba/omniorbcpp/swordorb-impl.hpp
   trunk/bindings/corba/omniorbcpp/testclient.cpp
Modified:
   trunk/bindings/corba/Makefile.am
   trunk/bindings/corba/java/src/org/crosswire/sword/orb/SwordOrb.java
   trunk/bindings/corba/orbitcpp/swordorb-impl.cpp
   trunk/bindings/corba/orbitcpp/swordorb-impl.hpp
   trunk/bindings/corba/swordorb.idl
Log:
Added omniorb bindings


Modified: trunk/bindings/corba/Makefile.am
===================================================================
--- trunk/bindings/corba/Makefile.am	2009-08-16 20:50:32 UTC (rev 2442)
+++ trunk/bindings/corba/Makefile.am	2009-08-23 06:16:26 UTC (rev 2443)
@@ -1,3 +1,3 @@
 EXTRA_DIST = swordorb.idl
 
-SUBDIRS = orbitcpp java
+SUBDIRS = orbitcpp omniorbcpp java

Modified: trunk/bindings/corba/java/src/org/crosswire/sword/orb/SwordOrb.java
===================================================================
--- trunk/bindings/corba/java/src/org/crosswire/sword/orb/SwordOrb.java	2009-08-16 20:50:32 UTC (rev 2442)
+++ trunk/bindings/corba/java/src/org/crosswire/sword/orb/SwordOrb.java	2009-08-23 06:16:26 UTC (rev 2443)
@@ -257,9 +257,10 @@
 			System.out.println(module.getRenderText());
 		}
 */
+/*
 		module = mgr.getModuleByName("WHNU");
 		module.setKeyText("rev.22.21");
-		System.out.println(new String(module.getRawEntry().getBytes("iso8859-1"), "UTF-8"));
+		System.out.println(module.getRawEntry());
 /*
 		boolean lucene = module.hasSearchFramework();
 		SearchHit[] searchResults = module.search("God love world", (lucene)?SearchType.LUCENE:SearchType.MULTIWORD, 0, "");

Added: trunk/bindings/corba/omniorbcpp/Makefile
===================================================================
--- trunk/bindings/corba/omniorbcpp/Makefile	                        (rev 0)
+++ trunk/bindings/corba/omniorbcpp/Makefile	2009-08-23 06:16:26 UTC (rev 2443)
@@ -0,0 +1,46 @@
+all: server testclient
+
+PREFIX = $(shell grep ^prefix ../../../Makefile|cut -f3 -d' ')
+
+#sword stuff
+CXXFLAGS += $(shell PKG_CONFIG_PATH=${PREFIX}/lib/pkgconfig pkg-config --cflags sword)
+CFLAGS += $(shell PKG_CONFIG_PATH=${PREFIX}/lib/pkgconfig pkg-config --cflags sword)
+LIBS += $(shell PKG_CONFIG_PATH=${PREFIX}/lib/pkgconfig pkg-config --libs sword)
+
+#orbit stuff
+CFLAGS += $(shell orbit2-config --cflags)
+CFLAGS += $(shell PKG_CONFIG_PATH=${PREFIX}/lib/pkgconfig pkg-config --cflags omniORB4)
+CXXFLAGS += $(shell PKG_CONFIG_PATH=${PREFIX}/lib/pkgconfig pkg-config --cflags omniORB4)
+LIBS += $(shell PKG_CONFIG_PATH=${PREFIX}/lib/pkgconfig pkg-config --libs omniORB4)
+
+LIBS += -L/usr/lib64 
+
+#comment out for release
+CXXFLAGS += -g -O0
+CFLAGS += -g -O0
+LDFLAGS += -g -O0
+#-----------------------------------------------------------------------------
+
+
+server: server.cpp swordorb-impl.o swordorb-stubs.o 
+	$(CXX) $(CXXFLAGS) -I. -o server server.cpp swordorb-impl.o swordorb-stubs.o $(LIBS)
+
+testclient: testclient.cpp swordorb-impl.cpp swordorb-stubs.o 
+	$(CXX) $(CXXFLAGS) -I. -o testclient testclient.cpp swordorb-stubs.o $(LIBS)
+
+swordorb-impl.o: swordorb.h swordorb-impl.cpp 
+	$(CXX) $(CXXFLAGS) -I. -c swordorb-impl.cpp
+
+
+swordorb.h: ./../swordorb.idl
+	omniidl -bcxx -Wbh=.h -Wbs=-stubs.cpp ./../swordorb.idl
+
+swordorb-stubs.o: swordorb-stubs.cpp
+	$(CC) $(CFLAGS) -I. -c swordorb-stubs.cpp
+
+clean:
+	rm -f *.h *-stubs.cpp *.cc *.o *.c server testclient
+
+install:
+	mkdir -p $(PREFIX)/bin
+	cp -f server $(PREFIX)/bin/swordorbserver

Added: trunk/bindings/corba/omniorbcpp/server.cpp
===================================================================
--- trunk/bindings/corba/omniorbcpp/server.cpp	                        (rev 0)
+++ trunk/bindings/corba/omniorbcpp/server.cpp	2009-08-23 06:16:26 UTC (rev 2443)
@@ -0,0 +1,117 @@
+/*
+ * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ *	CrossWire Bible Society
+ *	P. O. Box 2528
+ *	Tempe, AZ  85280-2528
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ */
+
+
+#include "swordorb-impl.hpp"
+#include <iostream>
+#include <swmgr.h>
+#include "../orbitcpp/webmgr.hpp"
+
+SWConfig *sysConf = 0;
+WebMgr *swordMgr = 0;
+
+class CleanStatics {
+public:
+	CleanStatics() {}
+	~CleanStatics() {
+		if (swordMgr)
+			delete swordMgr;
+
+		if (sysConf)
+			delete sysConf;
+	}
+} cleanStatics;
+
+
+
+
+int main (int argc, char** argv)
+{
+  try {
+
+	for (int i = 1; i < argc; i++) {
+		if (!strcmp(argv[i], "-sysConf")) {
+			if ((i+1) < argc)
+				sysConf = new SWConfig(argv[i+1]);
+		}
+	}
+
+	swordMgr = new WebMgr(sysConf);
+
+
+	const char* options[][2] = {
+		{ "nativeCharCodeSet", "UTF-8" }
+	   , { 0, 0 }
+     };
+
+
+    // Initialise the ORB.
+    CORBA::ORB_var orb = CORBA::ORB_init(argc, argv, "omniORB4", options);
+
+    // Obtain a reference to the root POA.
+    CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
+    PortableServer::POA_var poa = PortableServer::POA::_narrow(obj);
+
+    // We allocate the objects on the heap.  Since these are reference
+    // counted objects, they will be deleted by the POA when they are no
+    // longer needed.
+//    swordorb_SWModule_i* myswordorb_SWModule_i = new swordorb_SWModule_i();
+    swordorb_SWMgr_i* myswordorb_SWMgr_i = new swordorb_SWMgr_i(swordMgr);
+
+
+    // Activate the objects.  This tells the POA that the objects are
+    // ready to accept requests.
+ //   PortableServer::ObjectId_var myswordorb_SWModule_iid = poa->activate_object(myswordorb_SWModule_i);
+    PortableServer::ObjectId_var myswordorb_SWMgr_iid = poa->activate_object(myswordorb_SWMgr_i);
+
+
+    {
+      // IDL interface: swordorb::SWMgr
+      CORBA::Object_var ref = myswordorb_SWMgr_i->_this();
+      CORBA::String_var sior(orb->object_to_string(ref));
+      std::cout << (char*)sior << std::endl;
+    }
+
+
+
+    // Obtain a POAManager, and tell the POA to start accepting
+    // requests on its objects.
+    PortableServer::POAManager_var pman = poa->the_POAManager();
+    pman->activate();
+
+    orb->run();
+    orb->destroy();
+  }
+  catch(CORBA::TRANSIENT&) {
+    std::cerr << "Caught system exception TRANSIENT -- unable to contact the "
+         << "server." << std::endl;
+  }
+  catch(CORBA::SystemException& ex) {
+    std::cerr << "Caught a CORBA::" << ex._name() << std::endl;
+  }
+  catch(CORBA::Exception& ex) {
+    std::cerr << "Caught CORBA::Exception: " << ex._name() << std::endl;
+  }
+  catch(omniORB::fatalException& fe) {
+    std::cerr << "Caught omniORB::fatalException:" << std::endl;
+    std::cerr << "  file: " << fe.file() << std::endl;
+    std::cerr << "  line: " << fe.line() << std::endl;
+    std::cerr << "  mesg: " << fe.errmsg() << std::endl;
+  }
+  return 0;
+}
+

Added: trunk/bindings/corba/omniorbcpp/swordorb-impl.cpp
===================================================================
--- trunk/bindings/corba/omniorbcpp/swordorb-impl.cpp	                        (rev 0)
+++ trunk/bindings/corba/omniorbcpp/swordorb-impl.cpp	2009-08-23 06:16:26 UTC (rev 2443)
@@ -0,0 +1,508 @@
+/*
+ * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ *	CrossWire Bible Society
+ *	P. O. Box 2528
+ *	Tempe, AZ  85280-2528
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ */
+
+#include <iostream>
+#include <vector>
+
+#include <swordorb-impl.hpp>
+
+#include <swmgr.h>
+#include <versekey.h>
+#include <treekeyidx.h>
+#include <swbuf.h>
+#include <localemgr.h>
+#include <utilstr.h>
+
+
+using sword::VerseKey;
+using sword::SWBuf;
+using sword::TreeKeyIdx;
+
+
+sword::RawText NULLMod("/dev/null", SWNULL, SWNULL);
+
+namespace {
+
+// something about this still doesn't work. see gerlut1545.conf
+SWBuf assureValidUTF8(SWBuf buf) {
+
+	const unsigned char *b = (const unsigned char *)buf.c_str();
+	const unsigned char *q = 0;
+	bool invalidChar = false;
+	while (*b) {
+		q = b;
+		if (!getUniCharFromUTF8(&b)) {
+			long len = b - q;
+			if (len) {
+				invalidChar = true;
+				for (long start = q - (const unsigned char *)buf.c_str(); len; len--) {
+					buf[start+len-1] = 0x1a;	// unicode replacement character
+//					buf[start+len-1] = '?';	// unicode replacement character
+				}
+				
+			}
+		}
+	}
+	if (invalidChar) {
+		std::cerr << "Changing invalid UTF-8 string to (" << buf << ")" << std::endl;
+	}
+	return buf;
+}
+
+}
+
+
+
+swordorb_SWModule_i::swordorb_SWModule_i(sword::SWModule *delegate)
+{
+	this->delegate = delegate;
+}
+
+void swordorb_SWModule_i::terminateSearch() {
+	delegate->terminateSearch = true;
+}
+
+swordorb::SearchHitList* swordorb_SWModule_i::search(const char* istr, swordorb::SearchType srchType, ::CORBA::Long flags, const char* scope){
+	int stype = 2;
+	sword::ListKey lscope;
+	if (srchType == swordorb::REGEX) stype = 0;
+	if (srchType == swordorb::PHRASE) stype = -1;
+	if (srchType == swordorb::MULTIWORD) stype = -2;
+	if (srchType == swordorb::ENTRYATTR) stype = -3;
+	if (srchType == swordorb::LUCENE) stype = -4;
+	sword::ListKey result;
+
+	if ((scope) && (strlen(scope)) > 0) {
+		sword::SWKey *p = delegate->CreateKey();
+        	sword::VerseKey *parser = SWDYNAMIC_CAST(VerseKey, p);
+	        if (!parser) {
+        		delete p;
+	                parser = new VerseKey();
+	        }
+	        *parser = delegate->getKeyText();
+		lscope = parser->ParseVerseList(scope, *parser, true);
+		result = delegate->Search(istr, stype, flags, &lscope);
+                delete parser;
+	}
+	else	result = delegate->Search(istr, stype, flags);
+
+	swordorb::SearchHitList *retVal = new swordorb::SearchHitList;
+	int count = 0;
+	for (result = sword::TOP; !result.Error(); result++) count++;
+	retVal->length(count);
+	int i = 0;
+
+	// if we're sorted by score, let's re-sort by verse, because Java can always re-sort by score
+	result = sword::TOP;
+	if ((count) && (long)result.getElement()->userData)
+		result.sort();
+
+	for (result = sword::TOP; !result.Error(); result++) {
+		(*retVal)[i].modName = CORBA::string_dup(assureValidUTF8(delegate->Name()));
+		(*retVal)[i].key = CORBA::string_dup(assureValidUTF8((const char *)result));
+		(*retVal)[i++].score = (long)result.getElement()->userData;
+	}
+
+	return retVal;
+}
+
+::CORBA::Char swordorb_SWModule_i::error() {
+	return delegate->Error();
+}
+
+::CORBA::Long swordorb_SWModule_i::getEntrySize(){
+	return delegate->getEntrySize();
+}
+
+swordorb::StringList* swordorb_SWModule_i::getEntryAttribute(const char* level1, const char* level2, const char* level3, ::CORBA::Boolean filtered){
+	delegate->RenderText();	// force parse
+	std::vector<SWBuf> results;
+	swordorb::StringList *retVal = new swordorb::StringList;
+	int count = 0;
+
+	sword::AttributeTypeList &entryAttribs = delegate->getEntryAttributes();
+	sword::AttributeTypeList::iterator i1Start, i1End;
+	sword::AttributeList::iterator i2Start, i2End;
+	sword::AttributeValue::iterator i3Start, i3End;
+
+	if ((level1) && (*level1)) {
+		i1Start = entryAttribs.find(level1);
+		i1End = i1Start;
+		if (i1End != entryAttribs.end())
+			i1End++;
+	}
+	else {
+		i1Start = entryAttribs.begin();
+		i1End   = entryAttribs.end();
+	}
+	for (;i1Start != i1End; i1Start++) {
+		if ((level2) && (*level2)) {
+			i2Start = i1Start->second.find(level2);
+			i2End = i2Start;
+			if (i2End != i1Start->second.end())
+				i2End++;
+		}
+		else {
+			i2Start = i1Start->second.begin();
+			i2End   = i1Start->second.end();
+		}
+		for (;i2Start != i2End; i2Start++) {
+			if ((level3) && (*level3)) {
+				i3Start = i2Start->second.find(level3);
+				i3End = i3Start;
+				if (i3End != i2Start->second.end())
+					i3End++;
+			}
+			else {
+				i3Start = i2Start->second.begin();
+				i3End   = i2Start->second.end();
+			}
+			for (;i3Start != i3End; i3Start++) {
+				results.push_back(i3Start->second);
+			}
+			if (i3Start != i3End)
+				break;
+		}
+		if (i2Start != i2End)
+			break;
+	}
+
+	retVal->length(results.size());
+	for (int i = 0; i < results.size(); i++) {
+		if (filtered) {
+			(*retVal)[i] = CORBA::string_dup(assureValidUTF8(delegate->RenderText(results[i].c_str())));
+		}
+		else {
+			(*retVal)[count++] = CORBA::string_dup(assureValidUTF8(results[i].c_str()));
+		}
+	}
+
+	return retVal;
+}
+
+swordorb::StringList* swordorb_SWModule_i::parseKeyList(const char* keyText){
+	sword::VerseKey *parser = dynamic_cast<VerseKey *>(delegate->getKey());
+	swordorb::StringList *retVal = new swordorb::StringList;
+	if (parser) {
+		sword::ListKey result;
+		result = parser->ParseVerseList(keyText, *parser, true);
+		int count = 0;
+		for (result = sword::TOP; !result.Error(); result++) {
+			count++;
+		}
+		retVal->length(count);
+		count = 0;
+		for (result = sword::TOP; !result.Error(); result++) {
+			(*retVal)[count++] = CORBA::string_dup(assureValidUTF8((const char *)result));
+		}
+	}
+	else	{
+		retVal->length(1);
+		(*retVal)[0] = CORBA::string_dup(assureValidUTF8(keyText));
+	}
+
+	return retVal;
+}
+
+void swordorb_SWModule_i::setKeyText(const char* key){
+	delegate->KeyText(key);
+}
+
+char* swordorb_SWModule_i::getKeyText(){
+	return CORBA::string_dup(assureValidUTF8((char *)delegate->KeyText()));
+}
+
+::CORBA::Boolean swordorb_SWModule_i::hasKeyChildren(){
+	sword::SWKey *key = delegate->getKey();
+	bool retVal = "";
+
+	TreeKeyIdx *tkey = SWDYNAMIC_CAST(TreeKeyIdx, key);
+	if (tkey) {
+		retVal = tkey->hasChildren();
+	}
+	return retVal;
+}
+
+swordorb::StringList* swordorb_SWModule_i::getKeyChildren(){
+	sword::SWKey *key = delegate->getKey();
+	swordorb::StringList *retVal = new swordorb::StringList;
+	int count = 0;
+
+	sword::VerseKey *vkey = SWDYNAMIC_CAST(VerseKey, key);
+	if (vkey) {
+		retVal->length(6);
+		SWBuf num;
+		num.appendFormatted("%d", vkey->Testament());
+		(*retVal)[0] = CORBA::string_dup(num.c_str());
+		num = "";
+		num.appendFormatted("%d", vkey->Book());
+		(*retVal)[1] = CORBA::string_dup(num.c_str());
+		num = "";
+		num.appendFormatted("%d", vkey->Chapter());
+		(*retVal)[2] = CORBA::string_dup(num.c_str());
+		num = "";
+		num.appendFormatted("%d", vkey->Verse());
+		(*retVal)[3] = CORBA::string_dup(num.c_str());
+		num = "";
+		num.appendFormatted("%d", vkey->getChapterMax());
+		(*retVal)[4] = CORBA::string_dup(num.c_str());
+		num = "";
+		num.appendFormatted("%d", vkey->getVerseMax());
+		(*retVal)[5] = CORBA::string_dup(num.c_str());
+	}
+	else {
+		TreeKeyIdx *tkey = SWDYNAMIC_CAST(TreeKeyIdx, key);
+		if (tkey) {
+			if (tkey->firstChild()) {
+				do {
+					count++;
+				}
+				while (tkey->nextSibling());
+				tkey->parent();
+			}
+			retVal->length(count);
+			count = 0;
+			if (tkey->firstChild()) {
+				do {
+					(*retVal)[count++] = CORBA::string_dup(assureValidUTF8(tkey->getLocalName()));
+				}
+				while (tkey->nextSibling());
+				tkey->parent();
+			}
+		}
+	}
+	return retVal;
+}
+
+char* swordorb_SWModule_i::getKeyParent(){
+	sword::SWKey *key = delegate->getKey();
+	SWBuf retVal = "";
+
+	TreeKeyIdx *tkey = SWDYNAMIC_CAST(TreeKeyIdx, key);
+	if (tkey) {
+		if (tkey->parent()) {
+			retVal = tkey->getText();
+		}
+	}
+	return CORBA::string_dup(assureValidUTF8((const char *)retVal));
+}
+
+char* swordorb_SWModule_i::getName(){
+	return CORBA::string_dup(assureValidUTF8((char *)delegate->Name()));
+}
+
+char* swordorb_SWModule_i::getDescription(){
+	return CORBA::string_dup(assureValidUTF8((char *)delegate->Description()));
+}
+
+char* swordorb_SWModule_i::getCategory(){
+	SWBuf type = delegate->Type();
+	SWBuf cat = delegate->getConfigEntry("Category");
+	if (cat.length() > 0)
+		type = cat;
+	return CORBA::string_dup(assureValidUTF8((char *)type.c_str()));
+}
+
+void swordorb_SWModule_i::previous(){
+	delegate->decrement();
+}
+
+void swordorb_SWModule_i::next(){
+	delegate->increment();
+}
+
+void swordorb_SWModule_i::begin(){
+	delegate->setPosition(sword::TOP);
+}
+
+char* swordorb_SWModule_i::getStripText(){
+	return CORBA::string_dup(assureValidUTF8((char *)delegate->StripText()));
+}
+
+char* swordorb_SWModule_i::getRenderText(){
+	return CORBA::string_dup(assureValidUTF8((char *)delegate->RenderText()));
+}
+
+char* swordorb_SWModule_i::getRawEntry(){
+	return CORBA::string_dup(assureValidUTF8((char *)delegate->getRawEntry()));
+}
+
+void swordorb_SWModule_i::setRawEntry(const char* entryBuffer){
+	delegate->setEntry(entryBuffer);
+}
+
+char* swordorb_SWModule_i::getConfigEntry(const char* key){
+	return CORBA::string_dup(assureValidUTF8(((char *)delegate->getConfigEntry(key)) ? (char *)delegate->getConfigEntry(key):SWNULL));
+}
+
+void swordorb_SWModule_i::deleteSearchFramework(){
+	delegate->deleteSearchFramework(); 
+}
+
+::CORBA::Boolean swordorb_SWModule_i::hasSearchFramework(){
+	return (delegate->hasSearchFramework() && delegate->isSearchOptimallySupported("God", -4, 0, 0));
+}
+
+
+// -------------------------------------------------------------------------
+
+
+swordorb_SWMgr_i::swordorb_SWMgr_i(WebMgr *delegate)
+{
+	this->delegate = delegate;
+}
+
+//   Methods corresponding to IDL attributes and operations
+swordorb::ModInfoList* swordorb_SWMgr_i::getModInfoList() {
+
+	swordorb::ModInfoList *milist = new swordorb::ModInfoList;
+	sword::SWModule *module = 0;
+
+	int size = 0;
+	for (sword::ModMap::iterator it = delegate->Modules.begin(); it != delegate->Modules.end(); it++) {
+		if ((!(it->second->getConfigEntry("CipherKey"))) || (*(it->second->getConfigEntry("CipherKey"))))
+			size++;
+	}
+
+//	if (size > 183) size = 183;
+	milist->length(size);
+	int i = 0;
+	for (sword::ModMap::iterator it = delegate->Modules.begin(); it != delegate->Modules.end(); it++) {
+		module = it->second;
+		if ((!(module->getConfigEntry("CipherKey"))) || (*(module->getConfigEntry("CipherKey")))) {
+			SWBuf type = module->Type();
+			SWBuf cat = module->getConfigEntry("Category");
+			if (cat.length() > 0)
+				type = cat;
+			(*milist)[i].name = CORBA::string_dup(assureValidUTF8(module->Name()));
+			(*milist)[i].description = CORBA::string_dup(assureValidUTF8(module->Description()));
+			(*milist)[i].category = CORBA::string_dup(assureValidUTF8(type.c_str()));
+			(*milist)[i++].language = CORBA::string_dup(assureValidUTF8(module->Lang()));
+			if (i >= size) break;
+		}
+	}
+	return milist;
+}
+
+swordorb::SWModule_ptr swordorb_SWMgr_i::getModuleByName(const char* name){
+	SWModuleMap::iterator it;
+	swordorb::SWModule_ptr retVal;
+	sword::SWModule *mod = delegate->Modules[name];
+	it = moduleImpls.find((mod)?name:SWNULL);
+	if (it == moduleImpls.end()) {
+		moduleImpls[(mod)?name:SWNULL] = new swordorb_SWModule_i((mod)?mod:&NULLMod);
+		it = moduleImpls.find((mod)?name:SWNULL);
+	}
+	if (it != moduleImpls.end()) {
+		retVal = it->second->_this();
+	}
+	return swordorb::SWModule::_duplicate(retVal);
+}
+
+char* swordorb_SWMgr_i::getPrefixPath(){
+	return CORBA::string_dup(assureValidUTF8(delegate->prefixPath));
+}
+
+char* swordorb_SWMgr_i::getConfigPath(){
+	return CORBA::string_dup(assureValidUTF8(delegate->configPath));
+}
+
+void swordorb_SWMgr_i::setGlobalOption(const char* option, const char* value){
+	delegate->setGlobalOption(option, value);
+}
+
+char* swordorb_SWMgr_i::getGlobalOption(const char* option){
+	return CORBA::string_dup(assureValidUTF8((char *)delegate->getGlobalOption(option)));
+}
+
+char* swordorb_SWMgr_i::getGlobalOptionTip(const char* option){
+	return CORBA::string_dup(assureValidUTF8((char *)delegate->getGlobalOptionTip(option)));
+}
+
+char* swordorb_SWMgr_i::filterText(const char* filterName, const char* text){
+	SWBuf buf = text;
+	delegate->setGlobalOption("Greek Accents", "Off");
+	char errStatus = delegate->filterText(filterName, buf);
+	return CORBA::string_dup(assureValidUTF8((char *)buf.c_str()));
+}
+
+swordorb::StringList* swordorb_SWMgr_i::getGlobalOptions(){
+	sword::StringList options = delegate->getGlobalOptions();
+	swordorb::StringList *retVal = new swordorb::StringList;
+	int count = 0;
+	for (sword::StringList::iterator it = options.begin(); it != options.end(); it++) {
+		count++;
+	}
+	retVal->length(count);
+	count = 0;
+	for (sword::StringList::iterator it = options.begin(); it != options.end(); it++) {
+		(*retVal)[count++] = CORBA::string_dup(assureValidUTF8(it->c_str()));
+	}
+	return retVal;
+}
+
+swordorb::StringList* swordorb_SWMgr_i::getGlobalOptionValues(const char* option){
+	sword::StringList options = delegate->getGlobalOptionValues(option);
+	swordorb::StringList *retVal = new swordorb::StringList;
+	int count = 0;
+	for (sword::StringList::iterator it = options.begin(); it != options.end(); it++) {
+		count++;
+	}
+	retVal->length(count);
+	count = 0;
+	for (sword::StringList::iterator it = options.begin(); it != options.end(); it++) {
+		(*retVal)[count++] = CORBA::string_dup(assureValidUTF8(it->c_str()));
+	}
+	return retVal;
+}
+
+void swordorb_SWMgr_i::setCipherKey(const char* modName, const char* key){
+	delegate->setCipherKey(modName, key);
+}
+
+void swordorb_SWMgr_i::terminate(){
+	exit(0);
+}
+
+::CORBA::Boolean swordorb_SWMgr_i::testConnection(){
+	return true;
+}
+
+void swordorb_SWMgr_i::setJavascript(::CORBA::Boolean val){
+	delegate->setJavascript(val);
+}
+
+swordorb::StringList* swordorb_SWMgr_i::getAvailableLocales(){
+	sword::StringList localeNames = LocaleMgr::getSystemLocaleMgr()->getAvailableLocales();
+	swordorb::StringList *retVal = new swordorb::StringList;
+	int count = 0;
+	for (sword::StringList::iterator it = localeNames.begin(); it != localeNames.end(); it++) {
+		count++;
+	}
+	retVal->length(count);
+	count = 0;
+	for (sword::StringList::iterator it = localeNames.begin(); it != localeNames.end(); it++) {
+		(*retVal)[count++] = CORBA::string_dup(assureValidUTF8(it->c_str()));
+	}
+	return retVal;
+}
+
+void swordorb_SWMgr_i::setDefaultLocale(const char* name){
+	LocaleMgr::getSystemLocaleMgr()->setDefaultLocaleName(name);
+}
+
+

Added: trunk/bindings/corba/omniorbcpp/swordorb-impl.hpp
===================================================================
--- trunk/bindings/corba/omniorbcpp/swordorb-impl.hpp	                        (rev 0)
+++ trunk/bindings/corba/omniorbcpp/swordorb-impl.hpp	2009-08-23 06:16:26 UTC (rev 2443)
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ *	CrossWire Bible Society
+ *	P. O. Box 2528
+ *	Tempe, AZ  85280-2528
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ */
+
+#ifndef SWORDORB_IMPL_H
+#define SWORDORB_IMPL_H
+
+#include "swordorb.h"
+#include "../orbitcpp/webmgr.hpp"
+#include <swmodule.h>
+#include <swmgr.h>
+#include <rawtext.h>
+#include <string>
+#include <map>
+
+
+static const char *SWNULL = "<SWNULL>";
+extern sword::RawText NULLMod;
+
+
+class swordorb_SWModule_i: public POA_swordorb::SWModule {
+private:
+	sword::SWModule *delegate;
+  // Make sure all instances are built on the heap by making the
+  // destructor non-public
+  //virtual ~swordorb_SWModule_i();
+public:
+  // standard constructor
+  swordorb_SWModule_i(sword::SWModule *delegate);
+  virtual ~swordorb_SWModule_i() {}
+
+  // methods corresponding to defined IDL attributes and operations
+  void terminateSearch();
+  swordorb::SearchHitList* search(const char* istr, swordorb::SearchType srchType, ::CORBA::Long flags, const char* scope);
+  ::CORBA::Char error();
+  ::CORBA::Long getEntrySize();
+  swordorb::StringList* getEntryAttribute(const char* level1, const char* level2, const char* level3, ::CORBA::Boolean filtered);
+  swordorb::StringList* parseKeyList(const char* keyText);
+  void setKeyText(const char* key);
+  char* getKeyText();
+  ::CORBA::Boolean hasKeyChildren();
+  swordorb::StringList* getKeyChildren();
+  char* getKeyParent();
+  char* getName();
+  char* getDescription();
+  char* getCategory();
+  void previous();
+  void next();
+  void begin();
+  char* getStripText();
+  char* getRenderText();
+  char* getRawEntry();
+  void setRawEntry(const char* entryBuffer);
+  char* getConfigEntry(const char* key);
+  void deleteSearchFramework();
+  ::CORBA::Boolean hasSearchFramework();
+
+};
+
+
+// ----------------------------------------------------------------------------------
+
+typedef std::map<std::string, swordorb_SWModule_i *> SWModuleMap;
+
+// ----------------------------------------------------------------------------------
+
+
+class swordorb_SWMgr_i: public POA_swordorb::SWMgr {
+private:
+	WebMgr *delegate;
+	SWModuleMap moduleImpls;
+  // Make sure all instances are built on the heap by making the
+  // destructor non-public
+  //virtual ~swordorb_SWMgr_i();
+public:
+  // standard constructor
+  swordorb_SWMgr_i(WebMgr *delegate);
+  virtual ~swordorb_SWMgr_i() {};
+
+  // methods corresponding to defined IDL attributes and operations
+  swordorb::ModInfoList* getModInfoList();
+  swordorb::SWModule_ptr getModuleByName(const char* name);
+  char* getPrefixPath();
+  char* getConfigPath();
+  void setGlobalOption(const char* option, const char* value);
+  char* getGlobalOption(const char* option);
+  char* getGlobalOptionTip(const char* option);
+  char* filterText(const char* filterName, const char* text);
+  swordorb::StringList* getGlobalOptions();
+  swordorb::StringList* getGlobalOptionValues(const char* option);
+  void setCipherKey(const char* modName, const char* key);
+  void terminate();
+  ::CORBA::Boolean testConnection();
+  void setJavascript(::CORBA::Boolean val);
+  swordorb::StringList* getAvailableLocales();
+  void setDefaultLocale(const char* name);
+
+};
+
+
+#endif

Added: trunk/bindings/corba/omniorbcpp/testclient.cpp
===================================================================
--- trunk/bindings/corba/omniorbcpp/testclient.cpp	                        (rev 0)
+++ trunk/bindings/corba/omniorbcpp/testclient.cpp	2009-08-23 06:16:26 UTC (rev 2443)
@@ -0,0 +1,114 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: f; c-basic-offset: 4 -*- */
+
+/*
+ * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ *	CrossWire Bible Society
+ *	P. O. Box 2528
+ *	Tempe, AZ  85280-2528
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ */
+
+
+#include "swordorb.h"
+#include <iostream>
+#include <swbuf.h>
+	
+int main (int argc, char *argv[])
+{
+	if (argc != 2)
+	{
+		std::cerr << "Usage:" << std::endl
+				  << "  " << argv[0] << " IOR" << std::endl
+				  << std::endl;
+		return -1;
+	}
+	
+	try {
+
+
+		const char* options[][2] = {
+			{ "nativeCharCodeSet", "UTF-8" }
+		   , { 0, 0 }
+		};
+
+
+	     // Initialise the ORB.
+	     CORBA::ORB_var orb = CORBA::ORB_init(argc, argv, "omniORB4", options);
+//	     CORBA::ORB_var orb = CORBA::ORB_init(argc, argv, "omniORB4");
+
+		// Get a reference to the server from the IOR passed on the
+		// command line
+		CORBA::Object_var obj = orb->string_to_object(argv[1]);
+		swordorb::SWMgr_var mgr = swordorb::SWMgr::_narrow(obj);
+
+		swordorb::SWModule_ptr module;
+		swordorb::ModInfoList *modInfoList;
+
+		std::cout << "Connected: "  << mgr->testConnection() << "\n";
+		std::cout << "PrefixPath: " << mgr->getPrefixPath() << "\n";
+		std::cout << "ConfigPath: " << mgr->getConfigPath() << "\n";
+		modInfoList = mgr->getModInfoList();
+		std::cout << "sequence length: " << modInfoList->length() << "\n";
+		for (int i = 0; i < modInfoList->length(); i++) {
+			std::cout << (*modInfoList)[i].name << ": " << (*modInfoList)[i].category << ": " << (*modInfoList)[i].language << "\n";
+/*
+			if (!strncmp((*modInfoList)[i].category, "Bibl", 4)) {
+				module = mgr->getModuleByName((*modInfoList)[i].name);
+				module->setKeyText("jas1:19");
+				std::cout << module->getRenderText() << "\n";
+			}
+			std::cout << "\n";
+*/
+		}
+/*
+		swordorb::StringList *localeNames = mgr->getAvailableLocales();
+		for (int i = 0; i < localeNames->length(); i++) {
+			std::cout << (*localeNames)[i] << "\n";
+		}
+*/
+		mgr->setDefaultLocale("de");
+		mgr->setJavascript(true);
+		mgr->setGlobalOption("Textual Variants", "Secondary Reading");
+		mgr->setGlobalOption("Footnotes", "On");
+		module = mgr->getModuleByName("NASB");
+/*
+		module->setKeyText("jas.1.19");
+		swordorb::StringList *attr = module->getEntryAttribute("Footnote", "", "body", true);
+		std::cout << "length: " << attr->length() << "\n";
+		for (int i = 0; i < attr->length(); i++) {
+			std::cout << (*attr)[i] << "\n";
+		}
+*/
+		int i = 0;
+		for (module->setKeyText("gen.2.8"); !module->error() && i < 3; module->next(), i++) {
+			std::cout << "KeyText: " << module->getKeyText() << "\n";
+			std::cout << "Text: " << module->getRenderText() << "\n";
+		}
+/*
+		swordorb::SearchHitList *searchResults;
+		bool lucene = module->hasSearchFramework();
+		searchResults = module->search("David", (lucene)?swordorb::LUCENE:swordorb::MULTIWORD, 0, "");
+		for (int i = 0; i < searchResults->length(); i++) {
+			std::cout << (*searchResults)[i].key << "\n";
+		}
+
+		mgr->setGlobalOption("Greek Accents", "Off");
+		std::cout << "\nFiltered text: " << mgr->filterText("Greek Accents", "ὁ θεὸς") << "\n";
+*/
+
+		
+	} catch(const CORBA::Exception& ex) {
+		std::cout << "exception: " << ex._name() << std::endl;
+	}
+	
+	return 0;
+}

Modified: trunk/bindings/corba/orbitcpp/swordorb-impl.cpp
===================================================================
--- trunk/bindings/corba/orbitcpp/swordorb-impl.cpp	2009-08-16 20:50:32 UTC (rev 2442)
+++ trunk/bindings/corba/orbitcpp/swordorb-impl.cpp	2009-08-23 06:16:26 UTC (rev 2443)
@@ -135,6 +135,14 @@
 	return CORBA::string_dup((char *)buf.c_str());
 }
 
+
+
+
+// ------------------------------------------------------------------------
+
+
+
+
 char *SWModule_impl::getCategory() throw(CORBA::SystemException) {
 	SWBuf type = delegate->Type();
 	SWBuf cat = delegate->getConfigEntry("Category");

Modified: trunk/bindings/corba/orbitcpp/swordorb-impl.hpp
===================================================================
--- trunk/bindings/corba/orbitcpp/swordorb-impl.hpp	2009-08-16 20:50:32 UTC (rev 2442)
+++ trunk/bindings/corba/orbitcpp/swordorb-impl.hpp	2009-08-23 06:16:26 UTC (rev 2443)
@@ -31,6 +31,7 @@
 static const char *SWNULL = "<SWNULL>";
 extern sword::RawText NULLMod;
 
+
 //Inherit from abstract Skeleton:
 class SWModule_impl : public POA_swordorb::SWModule {
 	sword::SWModule *delegate;
@@ -59,13 +60,17 @@
 	char *getRawEntry() throw(CORBA::SystemException) { return CORBA::string_dup((char *)delegate->getRawEntry()); }
 	void  setRawEntry(const char *entryBuffer) throw(CORBA::SystemException) { delegate->setEntry(entryBuffer); }
 	char *getConfigEntry(const char *key) throw(CORBA::SystemException) { return CORBA::string_dup(((char *)delegate->getConfigEntry(key)) ? (char *)delegate->getConfigEntry(key):SWNULL); }
-	void deleteSearchFramework() throw(CORBA::SystemException) { return delegate->deleteSearchFramework(); }
+	void deleteSearchFramework() throw(CORBA::SystemException) { delegate->deleteSearchFramework(); }
 	CORBA::Boolean hasSearchFramework() throw(CORBA::SystemException) { return (delegate->hasSearchFramework() && delegate->isSearchOptimallySupported("God", -4, 0, 0)); }
 
 };
 
+// ----------------------------------------------------------------------------------
+
 typedef std::map<std::string, SWModule_impl *> SWModuleMap;
 
+// ----------------------------------------------------------------------------------
+
 class SWMgr_impl : public POA_swordorb::SWMgr {
 	WebMgr *delegate;
 	SWModuleMap moduleImpls;
@@ -90,7 +95,7 @@
 	void setDefaultLocale(const char *name) throw(CORBA::SystemException);
 
 };
-}; // namespace hellomodule
+};
 
 
-#endif //_ORBIT_CPP_IDL_helloworld_IMPL_HH
+#endif

Modified: trunk/bindings/corba/swordorb.idl
===================================================================
--- trunk/bindings/corba/swordorb.idl	2009-08-16 20:50:32 UTC (rev 2442)
+++ trunk/bindings/corba/swordorb.idl	2009-08-23 06:16:26 UTC (rev 2443)
@@ -57,7 +57,7 @@
 
 interface SWModule {
 	void          terminateSearch();
-	SearchHitList search(in string istr, in SearchType searchType, in long flags, in string scope);
+	SearchHitList search(in string istr, in SearchType srchType, in long flags, in string scope);
 	char          error();
 	long          getEntrySize();
 	StringList    getEntryAttribute(in string level1, in string level2, in string level3, in boolean filtered);




More information about the sword-cvs mailing list