summaryrefslogtreecommitdiff
path: root/bindings/corba/orbitcpp
diff options
context:
space:
mode:
Diffstat (limited to 'bindings/corba/orbitcpp')
-rw-r--r--bindings/corba/orbitcpp/Makefile66
-rw-r--r--bindings/corba/orbitcpp/Makefile.am40
-rw-r--r--bindings/corba/orbitcpp/server.cpp71
-rw-r--r--bindings/corba/orbitcpp/swordorb-impl.cpp357
-rw-r--r--bindings/corba/orbitcpp/swordorb-impl.hpp79
-rw-r--r--bindings/corba/orbitcpp/testclient.cpp87
-rw-r--r--bindings/corba/orbitcpp/webmgr.hpp97
7 files changed, 797 insertions, 0 deletions
diff --git a/bindings/corba/orbitcpp/Makefile b/bindings/corba/orbitcpp/Makefile
new file mode 100644
index 0000000..c7a48a7
--- /dev/null
+++ b/bindings/corba/orbitcpp/Makefile
@@ -0,0 +1,66 @@
+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)
+CXXFLAGS += $(shell orbit2-config --cflags)
+LIBS += $(shell orbit2-config --libs)
+
+#orbitcpp stuff-- this is silly. Is there really NOT a way to derive this?
+CFLAGS += -I/usr/include/orbitcpp-2.0
+CXXFLAGS += -I/usr/include/orbitcpp-2.0
+LIBS += -L/usr/lib64 -lORBit-2-cpp
+
+#comment out for release
+#CXXFLAGS += -g -O0
+#CFLAGS += -g -O0
+#LDFLAGS += -g -O0
+#-----------------------------------------------------------------------------
+
+
+server: swordorb-common.o server.cpp swordorb-impl.o swordorb-cpp.o swordorb-cpp-common.o swordorb-stubs.o swordorb-cpp-stubs.o swordorb-cpp-skels.o swordorb-skels.o swordorb-cpp.o
+ $(CXX) $(CXXFLAGS) -I. -o server server.cpp swordorb-impl.o swordorb-common.o swordorb-cpp-common.o swordorb-stubs.o swordorb-cpp-stubs.o swordorb-cpp-skels.o swordorb-skels.o $(LIBS)
+
+testclient: testclient.cpp swordorb-impl.cpp swordorb-common.o swordorb-cpp-common.o swordorb-stubs.o swordorb-cpp-stubs.o swordorb-skels.o swordorb-cpp-skels.o
+ $(CXX) $(CXXFLAGS) -I. -o testclient testclient.cpp swordorb-common.o swordorb-cpp-common.o swordorb-stubs.o swordorb-cpp-stubs.o swordorb-skels.o swordorb-cpp-skels.o $(LIBS)
+
+swordorb-cpp.o: swordorb-cpp.cc
+ $(CXX) $(CXXFLAGS) -I. -c swordorb-cpp.cc
+
+swordorb-impl.o: swordorb-impl.cpp
+ $(CXX) $(CXXFLAGS) -I. -c swordorb-impl.cpp
+
+swordorb-common.o: swordorb-common.c
+ $(CC) $(CFLAGS) -I. -c swordorb-common.c
+
+swordorb-common.c: ./../swordorb.idl
+ orbit-idl-2 -l c ./../swordorb.idl
+ orbit-idl-2 -l cpp ./../swordorb.idl
+
+swordorb-cpp-common.o: swordorb-cpp-common.cc
+ $(CXX) $(CXXFLAGS) -I. -c swordorb-cpp-common.cc
+
+swordorb-stubs.o: swordorb-stubs.c
+ $(CC) $(CFLAGS) -I. -c swordorb-stubs.c
+
+swordorb-cpp-stubs.o: swordorb-cpp-stubs.cc
+ $(CXX) $(CXXFLAGS) -I. -c swordorb-cpp-stubs.cc
+
+swordorb-skels.o: swordorb-skels.c
+ $(CC) $(CFLAGS) -I. -c swordorb-skels.c
+
+swordorb-cpp-skels.o: swordorb-cpp-skels.cc
+ $(CXX) $(CXXFLAGS) -I. -c swordorb-cpp-skels.cc
+
+clean:
+ rm -f *.h *.cc *.o *.c server testclient
+
+install:
+ mkdir -p $(PREFIX)/bin
+ cp -f server $(PREFIX)/bin/swordorbserver
diff --git a/bindings/corba/orbitcpp/Makefile.am b/bindings/corba/orbitcpp/Makefile.am
new file mode 100644
index 0000000..2d36ddf
--- /dev/null
+++ b/bindings/corba/orbitcpp/Makefile.am
@@ -0,0 +1,40 @@
+bin_PROGRAMS = swordorbserver
+
+noinst_PROGRAMS = testclient
+
+swordorbserver_SOURCES = server.cpp
+swordorbserver_SOURCES += swordorb-common.c
+swordorbserver_SOURCES += swordorb-impl.cpp
+swordorbserver_SOURCES += swordorb-cpp-common.cc
+swordorbserver_SOURCES += swordorb-stubs.c
+swordorbserver_SOURCES += swordorb-cpp-stubs.cc
+swordorbserver_SOURCES += swordorb-skels.c
+swordorbserver_SOURCES += swordorb-cpp-skels.cc
+
+swordorbserver_CFLAGS = $(SWORD_CFLAGS) $(ORBIT_CFLAGS)
+swordorbserver_CXXFLAGS = $(SWORD_CFLAGS) $(ORBIT_CXXFLAGS)
+swordorbserver_LDADD = $(SWORD_LIBS) $(ORBIT_LIBS)
+
+testclient_SOURCES = testclient.cpp
+testclient_SOURCES += swordorb-common.c
+testclient_SOURCES += swordorb-impl.cpp
+testclient_SOURCES += swordorb-cpp-common.cc
+testclient_SOURCES += swordorb-stubs.c
+testclient_SOURCES += swordorb-cpp-stubs.cc
+testclient_SOURCES += swordorb-skels.c
+testclient_SOURCES += swordorb-cpp-skels.cc
+
+testclient_CFLAGS = $(SWORD_CFLAGS) $(ORBIT_CFLAGS)
+testclient_CXXFLAGS = $(SWORD_CFLAGS) $(ORBIT_CXXFLAGS)
+testclient_LDADD = $(SWORD_LIBS) $(ORBIT_LIBS)
+
+BUILT_SOURCES = swordorb-common.c
+
+swordorb-common.c: $(top_srcdir)/corba/swordorb.idl
+ orbit-idl-2 -l c $(top_srcdir)/corba/swordorb.idl
+ orbit-idl-2 -l cpp $(top_srcdir)/corba/swordorb.idl
+
+clean:
+ rm -f *.h *.cc *.o *.c server testclient
+
+
diff --git a/bindings/corba/orbitcpp/server.cpp b/bindings/corba/orbitcpp/server.cpp
new file mode 100644
index 0000000..83b1864
--- /dev/null
+++ b/bindings/corba/orbitcpp/server.cpp
@@ -0,0 +1,71 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
+#include "swordorb-impl.hpp"
+#include <iostream>
+#include <swmgr.h>
+#include "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);
+
+ // Initialize the CORBA orb
+ CORBA::ORB_ptr orb = CORBA::ORB_init (argc, argv);
+
+ // Get the root POA
+ CORBA::Object_var pfobj = orb->resolve_initial_references("RootPOA");
+
+ PortableServer::POA_var rootPOA =
+ PortableServer::POA::_narrow(pfobj);
+
+ // Activate the root POA's manager
+ PortableServer::POAManager_var mgr = rootPOA->the_POAManager();
+
+ mgr->activate();
+
+ // Create a Servant and explicitly create a CORBA object
+ swordorb::SWMgr_impl servant(swordMgr);
+ CORBA::Object_var object = servant._this();
+
+ // Here we get the IOR for the Hello server object.
+ // Our "client" will use the IOR to find the object to connect to
+ CORBA::String_var ref = orb->object_to_string( object );
+
+ // print out the IOR
+ std::cout << ref << std::endl;
+
+ // run the server event loop
+ orb->run();
+ }
+ catch(const CORBA::Exception& ex)
+ {
+ std::cout << "Exception caught." << std::endl;
+ }
+
+}
diff --git a/bindings/corba/orbitcpp/swordorb-impl.cpp b/bindings/corba/orbitcpp/swordorb-impl.cpp
new file mode 100644
index 0000000..29b5b5e
--- /dev/null
+++ b/bindings/corba/orbitcpp/swordorb-impl.cpp
@@ -0,0 +1,357 @@
+#include "swordorb-impl.hpp"
+#include <iostream>
+#include <swmgr.h>
+#include <versekey.h>
+#include <treekeyidx.h>
+#include <swbuf.h>
+#include <localemgr.h>
+#include <vector>
+
+/*
+char* swordorb::SWModule_impl::helloWorld(const char* greeting) throw(CORBA::SystemException) {
+ std::cout << "Server: Greeting was \"" << greeting << "\"" << std::endl;
+ return CORBA::string_dup("Hello client, from server!");
+}
+*/
+
+using sword::VerseKey;
+using sword::SWBuf;
+using sword::TreeKeyIdx;
+
+namespace swordorb {
+
+sword::RawText NULLMod("/dev/null", SWNULL, SWNULL);
+
+ModInfoList *SWMgr_impl::getModInfoList() throw(CORBA::SystemException) {
+
+ ModInfoList *milist = new 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++;
+ }
+ 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(module->Name());
+ (*milist)[i].description = CORBA::string_dup(module->Description());
+ (*milist)[i].category = CORBA::string_dup(type.c_str());
+ (*milist)[i++].language = CORBA::string_dup(module->Lang());
+ }
+ }
+ return milist;
+}
+
+
+
+SWModule_ptr SWMgr_impl::getModuleByName(const char *name) throw(CORBA::SystemException) {
+ SWModuleMap::iterator it;
+ SWModule_ptr retVal;
+ sword::SWModule *mod = delegate->Modules[name];
+ it = moduleImpls.find((mod)?name:SWNULL);
+ if (it == moduleImpls.end()) {
+ moduleImpls[(mod)?name:SWNULL] = new SWModule_impl((mod)?mod:&NULLMod);
+ it = moduleImpls.find((mod)?name:SWNULL);
+ }
+ if (it != moduleImpls.end()) {
+ retVal = it->second->_this();
+ }
+ return ::swordorb::SWModule::_duplicate(retVal);
+}
+
+
+StringList *SWMgr_impl::getGlobalOptions() throw(CORBA::SystemException) {
+ sword::StringList options = delegate->getGlobalOptions();
+ StringList *retVal = new 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(it->c_str());
+ }
+ return retVal;
+}
+
+
+StringList *SWMgr_impl::getGlobalOptionValues(const char *option) throw(CORBA::SystemException) {
+ sword::StringList options = delegate->getGlobalOptionValues(option);
+ StringList *retVal = new 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(it->c_str());
+ }
+ return retVal;
+}
+
+void SWMgr_impl::terminate() throw(CORBA::SystemException) {
+ exit(0);
+}
+
+
+CORBA::Boolean SWMgr_impl::testConnection() throw(CORBA::SystemException) {
+ return true;
+}
+
+void SWMgr_impl::setJavascript(CORBA::Boolean val) throw(CORBA::SystemException) {
+ delegate->setJavascript(val);
+}
+
+char *SWMgr_impl::filterText(const char *filterName, const char *text) throw(CORBA::SystemException) {
+ SWBuf buf = text;
+ delegate->setGlobalOption("Greek Accents", "Off");
+ char errStatus = delegate->filterText(filterName, buf);
+ return CORBA::string_dup((char *)buf.c_str());
+}
+
+char *SWModule_impl::getCategory() throw(CORBA::SystemException) {
+ SWBuf type = delegate->Type();
+ SWBuf cat = delegate->getConfigEntry("Category");
+ if (cat.length() > 0)
+ type = cat;
+ return CORBA::string_dup((char *)type.c_str());
+}
+
+
+StringList *SWModule_impl::parseKeyList(const char *keyText) throw(CORBA::SystemException) {
+ sword::VerseKey *parser = dynamic_cast<VerseKey *>(delegate->getKey());
+ StringList *retVal = new 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((const char *)result);
+ }
+ }
+ else {
+ retVal->length(1);
+ (*retVal)[0] = CORBA::string_dup(keyText);
+ }
+
+ return retVal;
+}
+
+
+SearchHitList *SWModule_impl::search(const char *istr, SearchType searchType, CORBA::Long flags, const char *scope) throw(CORBA::SystemException) {
+ int stype = 2;
+ sword::ListKey lscope;
+ sword::VerseKey parser;
+ if (searchType == REGEX) stype = 0;
+ if (searchType == PHRASE) stype = -1;
+ if (searchType == MULTIWORD) stype = -2;
+ if (searchType == ENTRYATTR) stype = -3;
+ if (searchType == LUCENE) stype = -4;
+ sword::ListKey result;
+
+ if ((scope) && (strlen(scope)) > 0) {
+ lscope = parser.ParseVerseList(scope, parser, true);
+ result = delegate->Search(istr, stype, flags, &lscope);
+ }
+ else result = delegate->Search(istr, stype, flags);
+
+ SearchHitList *retVal = new 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(delegate->Name());
+ (*retVal)[i].key = CORBA::string_dup((const char *)result);
+ (*retVal)[i++].score = (long)result.getElement()->userData;
+ }
+
+ return retVal;
+}
+
+
+StringList *SWModule_impl::getEntryAttribute(const char *level1, const char *level2, const char *level3, CORBA::Boolean filtered) throw(CORBA::SystemException) {
+ delegate->RenderText(); // force parse
+ std::vector<SWBuf> results;
+ StringList *retVal = new 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(delegate->RenderText(results[i].c_str()));
+ }
+ else {
+ (*retVal)[count++] = CORBA::string_dup(results[i].c_str());
+ }
+ }
+
+ return retVal;
+}
+
+
+StringList *SWModule_impl::getKeyChildren() throw(CORBA::SystemException) {
+ sword::SWKey *key = delegate->getKey();
+ StringList *retVal = new 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->books[vkey->Testament()-1][vkey->Book()-1].chapmax);
+ (*retVal)[4] = CORBA::string_dup(num.c_str());
+ num = "";
+ num.appendFormatted("%d", vkey->books[vkey->Testament()-1][vkey->Book()-1].versemax[vkey->Chapter()-1]);
+ (*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(tkey->getLocalName());
+ }
+ while (tkey->nextSibling());
+ tkey->parent();
+ }
+ }
+ }
+ return retVal;
+}
+
+CORBA::Boolean SWModule_impl::hasKeyChildren() throw(CORBA::SystemException) {
+ sword::SWKey *key = delegate->getKey();
+ bool retVal = "";
+
+ TreeKeyIdx *tkey = SWDYNAMIC_CAST(TreeKeyIdx, key);
+ if (tkey) {
+ retVal = tkey->hasChildren();
+ }
+ return retVal;
+}
+
+
+char *SWModule_impl::getKeyParent() throw(CORBA::SystemException) {
+ 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((const char *)retVal);
+}
+
+
+StringList *SWMgr_impl::getAvailableLocales() throw(CORBA::SystemException) {
+ sword::StringList localeNames = LocaleMgr::getSystemLocaleMgr()->getAvailableLocales();
+ StringList *retVal = new 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(it->c_str());
+ }
+ return retVal;
+}
+
+
+void SWMgr_impl::setDefaultLocale(const char *name) throw(CORBA::SystemException) {
+ LocaleMgr::getSystemLocaleMgr()->setDefaultLocaleName(name);
+}
+
+}
diff --git a/bindings/corba/orbitcpp/swordorb-impl.hpp b/bindings/corba/orbitcpp/swordorb-impl.hpp
new file mode 100644
index 0000000..f9a88b1
--- /dev/null
+++ b/bindings/corba/orbitcpp/swordorb-impl.hpp
@@ -0,0 +1,79 @@
+#ifndef _ORBIT_CPP_IDL_sword_IMPL_HH
+#define _ORBIT_CPP_IDL_sword_IMPL_HH
+
+#include "swordorb-cpp-skels.h"
+#include "webmgr.hpp"
+#include <swmodule.h>
+#include <swmgr.h>
+#include <rawtext.h>
+#include <map>
+
+
+namespace swordorb {
+
+static const char *SWNULL = "<SWNULL>";
+extern sword::RawText NULLMod;
+
+//Inherit from abstract Skeleton:
+class SWModule_impl : public POA_swordorb::SWModule {
+ sword::SWModule *delegate;
+public:
+ SWModule_impl(sword::SWModule *delegate) { this->delegate = delegate; }
+
+ SearchHitList *search(const char *istr, SearchType searchType, CORBA::Long flags, const char *scope) throw(CORBA::SystemException);
+ StringList *parseKeyList(const char *keyText) throw(CORBA::SystemException);
+ void terminateSearch() throw(CORBA::SystemException) { delegate->terminateSearch = true; }
+ char error() throw(CORBA::SystemException) { return delegate->Error(); }
+ CORBA::Long getEntrySize() throw(CORBA::SystemException) { return delegate->getEntrySize(); }
+ void setKeyText(const char *key) throw(CORBA::SystemException) { delegate->KeyText(key); }
+ char *getKeyText() throw(CORBA::SystemException) { return CORBA::string_dup((char *)delegate->KeyText()); }
+ StringList *getKeyChildren() throw(CORBA::SystemException);
+ char *getKeyParent() throw(CORBA::SystemException);
+ CORBA::Boolean hasKeyChildren() throw(CORBA::SystemException);
+ char *getName() throw(CORBA::SystemException) { return CORBA::string_dup((char *)delegate->Name()); }
+ char *getDescription() throw(CORBA::SystemException) { return CORBA::string_dup((char *)delegate->Description()); }
+ char *getCategory() throw(CORBA::SystemException);
+ void previous() throw(CORBA::SystemException) { delegate->decrement(); }
+ void next() throw(CORBA::SystemException) { delegate->increment(); }
+ void begin() throw(CORBA::SystemException) { delegate->setPosition(sword::TOP); }
+ char *getStripText() throw(CORBA::SystemException) { return CORBA::string_dup((char *)delegate->StripText()); }
+ StringList *getEntryAttribute(const char *level1, const char *level2, const char *level3, CORBA::Boolean filtered) throw(CORBA::SystemException);
+ char *getRenderText() throw(CORBA::SystemException) { return CORBA::string_dup((char *)delegate->RenderText()); }
+ 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(); }
+ 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;
+public:
+ SWMgr_impl(WebMgr *delegate) { this->delegate = delegate; }
+
+ ModInfoList *getModInfoList() throw(CORBA::SystemException);
+ SWModule_ptr getModuleByName(const char *name) throw(CORBA::SystemException);
+ char *filterText(const char *filterName, const char *text) throw(CORBA::SystemException);
+ char *getPrefixPath() throw(CORBA::SystemException) { return CORBA::string_dup(delegate->prefixPath); }
+ char *getConfigPath() throw(CORBA::SystemException) { return CORBA::string_dup(delegate->configPath); }
+ void setGlobalOption(const char *option, const char *value) throw(CORBA::SystemException) { delegate->setGlobalOption(option, value); }
+ char *getGlobalOption(const char *option) throw(CORBA::SystemException) { return CORBA::string_dup((char *)delegate->getGlobalOption(option)); }
+ char *getGlobalOptionTip(const char *option) throw(CORBA::SystemException) { return CORBA::string_dup((char *)delegate->getGlobalOptionTip(option)); }
+ StringList *getGlobalOptions() throw(CORBA::SystemException);
+ StringList *getGlobalOptionValues(const char *option) throw(CORBA::SystemException);
+ void setCipherKey(const char *modName, const char *key) throw(CORBA::SystemException) { delegate->setCipherKey(modName, key); }
+ void terminate() throw(CORBA::SystemException);
+ CORBA::Boolean testConnection() throw(CORBA::SystemException);
+ void setJavascript(CORBA::Boolean) throw(CORBA::SystemException);
+ StringList *getAvailableLocales() throw(CORBA::SystemException);
+ void setDefaultLocale(const char *name) throw(CORBA::SystemException);
+
+};
+}; // namespace hellomodule
+
+
+#endif //_ORBIT_CPP_IDL_helloworld_IMPL_HH
diff --git a/bindings/corba/orbitcpp/testclient.cpp b/bindings/corba/orbitcpp/testclient.cpp
new file mode 100644
index 0000000..8477d18
--- /dev/null
+++ b/bindings/corba/orbitcpp/testclient.cpp
@@ -0,0 +1,87 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: f; c-basic-offset: 4 -*- */
+
+#include "swordorb-cpp-stubs.h"
+#include "swordorb-cpp-common.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
+ {
+ // Initialize ORBit
+ CORBA::ORB_ptr orb = CORBA::ORB_init(argc, argv, "orbit-local-orb");
+
+ // 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 caught. Maybe the server is not running, or the IOR is wrong." << std::endl;
+ }
+
+ return 0;
+}
diff --git a/bindings/corba/orbitcpp/webmgr.hpp b/bindings/corba/orbitcpp/webmgr.hpp
new file mode 100644
index 0000000..2fba2c3
--- /dev/null
+++ b/bindings/corba/orbitcpp/webmgr.hpp
@@ -0,0 +1,97 @@
+#ifndef WEBMGR_HPP
+#define WEBMGR_HPP
+
+#include <swmgr.h>
+#include <swmodule.h>
+#include <swfilter.h>
+#include <markupfiltmgr.h>
+#include <osiswordjs.h>
+#include <thmlwordjs.h>
+#include <gbfwordjs.h>
+
+using namespace sword;
+
+class WebMgr : public SWMgr {
+ OSISWordJS *osisWordJS;
+ ThMLWordJS *thmlWordJS;
+ GBFWordJS *gbfWordJS;
+ SWModule *defaultGreekLex;
+ SWModule *defaultHebLex;
+ SWModule *defaultGreekParse;
+ SWModule *defaultHebParse;
+
+public:
+ WebMgr(SWConfig *sysConf) : SWMgr(0, sysConf, false, new MarkupFilterMgr(FMT_WEBIF)) {
+ defaultGreekLex = 0;
+ defaultHebLex = 0;
+ defaultGreekParse = 0;
+ defaultHebParse = 0;
+
+ osisWordJS = new OSISWordJS();
+ thmlWordJS = new ThMLWordJS();
+ gbfWordJS = new GBFWordJS();
+ Load();
+ osisWordJS->setDefaultModules(defaultGreekLex, defaultHebLex, defaultGreekParse, defaultHebParse);
+ thmlWordJS->setDefaultModules(defaultGreekLex, defaultHebLex, defaultGreekParse, defaultHebParse);
+ gbfWordJS->setDefaultModules(defaultGreekLex, defaultHebLex, defaultGreekParse, defaultHebParse);
+ osisWordJS->setMgr(this);
+ thmlWordJS->setMgr(this);
+ gbfWordJS->setMgr(this);
+ setGlobalOption("Textual Variants", "Primary Reading");
+ }
+
+ ~WebMgr() {
+ delete osisWordJS;
+ delete thmlWordJS;
+ delete gbfWordJS;
+ }
+
+
+ void AddGlobalOptions(SWModule *module, ConfigEntMap &section, ConfigEntMap::iterator start, ConfigEntMap::iterator end) {
+
+ // ThML word stuff needs to process before strongs strip
+ if (module->Markup() == FMT_THML) {
+ module->AddOptionFilter(thmlWordJS);
+ }
+
+ if (module->Markup() == FMT_GBF) {
+ module->AddOptionFilter(gbfWordJS);
+ }
+
+ // add other module filters
+ SWMgr::AddGlobalOptions(module, section, start, end);
+
+ // add our special filters
+ if (module->getConfig().has("Feature", "GreekDef")) {
+ defaultGreekLex = module;
+ }
+ if (module->getConfig().has("Feature", "HebrewDef")) {
+ defaultHebLex = module;
+ }
+ if (module->getConfig().has("Feature", "GreekParse")) {
+ defaultGreekParse = module;
+ }
+ if (module->getConfig().has("Feature", "HebrewParse")) {
+ defaultHebParse = module;
+ }
+ if (module->getConfig().has("GlobalOptionFilter", "ThMLVariants")) {
+ OptionFilterMap::iterator it = optionFilters.find("ThMLVariants");
+ if (it != optionFilters.end()) {
+ module->AddOptionFilter((*it).second); // add filter to module and option as a valid option
+ }
+ }
+
+ if (module->Markup() == FMT_OSIS) {
+ module->AddOptionFilter(osisWordJS);
+ }
+ }
+
+
+ void setJavascript(bool val) {
+ osisWordJS->setOptionValue((val)?"On":"Off");
+ thmlWordJS->setOptionValue((val)?"On":"Off");
+ gbfWordJS->setOptionValue((val)?"On":"Off");
+ }
+};
+
+#endif