1
#include "swordorb-impl.hpp"
5
#include <treekeyidx.h>
9
char* swordorb::SWModule_impl::helloWorld(const char* greeting) throw(CORBA::SystemException) {
10
std::cout << "Server: Greeting was \"" << greeting << "\"" << std::endl;
11
return CORBA::string_dup("Hello client, from server!");
15
using sword::VerseKey;
17
using sword::TreeKeyIdx;
21
sword::RawText NULLMod("/dev/null", SWNULL, SWNULL);
23
ModInfoList *SWMgr_impl::getModInfoList() throw(CORBA::SystemException) {
25
ModInfoList *milist = new ModInfoList;
26
sword::SWModule *module = 0;
28
for (sword::ModMap::iterator it = delegate->Modules.begin(); it != delegate->Modules.end(); it++) {
29
if ((!(it->second->getConfigEntry("CipherKey"))) || (*(it->second->getConfigEntry("CipherKey"))))
34
for (sword::ModMap::iterator it = delegate->Modules.begin(); it != delegate->Modules.end(); it++) {
36
if ((!(module->getConfigEntry("CipherKey"))) || (*(module->getConfigEntry("CipherKey")))) {
37
SWBuf type = module->Type();
38
SWBuf cat = module->getConfigEntry("Category");
41
(*milist)[i].name = CORBA::string_dup(module->Name());
42
(*milist)[i].description = CORBA::string_dup(module->Description());
43
(*milist)[i].category = CORBA::string_dup(type.c_str());
44
(*milist)[i++].language = CORBA::string_dup(module->Lang());
52
SWModule_ptr SWMgr_impl::getModuleByName(const char *name) throw(CORBA::SystemException) {
53
SWModuleMap::iterator it;
55
sword::SWModule *mod = delegate->Modules[name];
56
it = moduleImpls.find((mod)?name:SWNULL);
57
if (it == moduleImpls.end()) {
58
moduleImpls[(mod)?name:SWNULL] = new SWModule_impl((mod)?mod:&NULLMod);
59
it = moduleImpls.find((mod)?name:SWNULL);
61
if (it != moduleImpls.end()) {
62
retVal = it->second->_this();
64
return ::swordorb::SWModule::_duplicate(retVal);
68
StringList *SWMgr_impl::getGlobalOptions() throw(CORBA::SystemException) {
69
sword::StringList options = delegate->getGlobalOptions();
70
StringList *retVal = new StringList;
72
for (sword::StringList::iterator it = options.begin(); it != options.end(); it++) {
75
retVal->length(count);
77
for (sword::StringList::iterator it = options.begin(); it != options.end(); it++) {
78
(*retVal)[count++] = CORBA::string_dup(it->c_str());
84
StringList *SWMgr_impl::getGlobalOptionValues(const char *option) throw(CORBA::SystemException) {
85
sword::StringList options = delegate->getGlobalOptionValues(option);
86
StringList *retVal = new StringList;
88
for (sword::StringList::iterator it = options.begin(); it != options.end(); it++) {
91
retVal->length(count);
93
for (sword::StringList::iterator it = options.begin(); it != options.end(); it++) {
94
(*retVal)[count++] = CORBA::string_dup(it->c_str());
99
void SWMgr_impl::terminate() throw(CORBA::SystemException) {
104
CORBA::Boolean SWMgr_impl::testConnection() throw(CORBA::SystemException) {
109
char *SWModule_impl::getCategory() throw(CORBA::SystemException) {
110
SWBuf type = delegate->Type();
111
SWBuf cat = delegate->getConfigEntry("Category");
112
if (cat.length() > 0)
114
return CORBA::string_dup((char *)type.c_str());
118
SearchHitList *SWModule_impl::search(const char *istr, SearchType searchType, CORBA::Long flags, const char *scope) throw(CORBA::SystemException) {
120
sword::ListKey lscope;
121
sword::VerseKey parser;
122
if (searchType == REGEX) stype = 0;
123
if (searchType == PHRASE) stype = -1;
124
if (searchType == MULTIWORD) stype = -2;
125
sword::ListKey result;
127
if ((scope) && (strlen(scope)) > 0) {
128
lscope = parser.ParseVerseList(scope, parser, true);
129
result = delegate->Search(istr, stype, flags, &lscope);
131
else result = delegate->Search(istr, stype, flags);
133
SearchHitList *retVal = new SearchHitList;
135
for (result = sword::TOP; !result.Error(); result++) count++;
136
retVal->length(count);
138
for (result = sword::TOP; !result.Error(); result++) {
139
(*retVal)[i].modName = CORBA::string_dup(delegate->Name());
140
(*retVal)[i].key = CORBA::string_dup((const char *)result);
141
(*retVal)[i++].score = (long)result.getElement()->userData;
149
StringList *SWModule_impl::getEntryAttribute(const char *level1, const char *level2, const char *level3) throw(CORBA::SystemException) {
150
delegate->RenderText(); // force parse
151
sword::AttributeTypeList &entryAttribs = delegate->getEntryAttributes();
152
sword::AttributeTypeList::iterator i1 = entryAttribs.find(level1);
153
sword::AttributeList::iterator i2;
154
sword::AttributeValue::iterator i3, j3;
155
StringList *retVal = new StringList;
158
if (i1 != entryAttribs.end()) {
159
i2 = i1->second.find(level2);
160
if (i2 != i1->second.end()) {
161
i3 = i2->second.find(level3);
162
if (i3 != i2->second.end()) {
163
for (j3 = i3; j3 != i2->second.end(); j3++)
165
retVal->length(count);
167
for (j3 = i3; j3 != i2->second.end(); j3++) {
168
(*retVal)[count++] = CORBA::string_dup(i3->second.c_str());
174
retVal->length(count);
180
StringList *SWModule_impl::getKeyChildren() throw(CORBA::SystemException) {
181
sword::SWKey *key = delegate->getKey();
182
StringList *retVal = new StringList;
185
sword::VerseKey *vkey = SWDYNAMIC_CAST(VerseKey, key);
189
num.appendFormatted("%d", vkey->Testament());
190
(*retVal)[0] = CORBA::string_dup(num.c_str());
192
num.appendFormatted("%d", vkey->Book());
193
(*retVal)[1] = CORBA::string_dup(num.c_str());
195
num.appendFormatted("%d", vkey->Chapter());
196
(*retVal)[2] = CORBA::string_dup(num.c_str());
198
num.appendFormatted("%d", vkey->Verse());
199
(*retVal)[3] = CORBA::string_dup(num.c_str());
201
num.appendFormatted("%d", vkey->books[vkey->Testament()-1][vkey->Book()-1].chapmax);
202
(*retVal)[4] = CORBA::string_dup(num.c_str());
204
num.appendFormatted("%d", vkey->books[vkey->Testament()-1][vkey->Book()-1].versemax[vkey->Chapter()-1]);
205
(*retVal)[5] = CORBA::string_dup(num.c_str());
208
TreeKeyIdx *tkey = SWDYNAMIC_CAST(TreeKeyIdx, key);
210
if (tkey->firstChild()) {
214
while (tkey->nextSibling());
217
retVal->length(count);
219
if (tkey->firstChild()) {
221
(*retVal)[count++] = CORBA::string_dup(tkey->getLocalName());
223
while (tkey->nextSibling());