[sword-svn] r2663 - in trunk: bindings/corba bindings/corba/java bindings/corba/java/src/org/crosswire/sword/orb bindings/corba/omniorbcpp bindings/corba/orbitcpp src/modules/filters tests
scribe at crosswire.org
scribe at crosswire.org
Sat Oct 29 08:38:34 MST 2011
Author: scribe
Date: 2011-10-29 08:38:34 -0700 (Sat, 29 Oct 2011)
New Revision: 2663
Modified:
trunk/bindings/corba/java/Makefile
trunk/bindings/corba/java/src/org/crosswire/sword/orb/SwordOrb.java
trunk/bindings/corba/omniorbcpp/Makefile
trunk/bindings/corba/omniorbcpp/swordorb-impl.cpp
trunk/bindings/corba/omniorbcpp/swordorb-impl.hpp
trunk/bindings/corba/orbitcpp/swordorb-impl.cpp
trunk/bindings/corba/orbitcpp/swordorb-impl.hpp
trunk/bindings/corba/swordorb.idl
trunk/src/modules/filters/rtfhtml.cpp
trunk/tests/filtertest.cpp
Log:
Added parsing of rtf \\number codes to facilitate our rtf .conf files
Adjusted abuser detection in SwordOrb and made orbs cycle when max is reached for an IP (probably a server using us as a service)
Added translate and installmgr functions to orb
Modified: trunk/bindings/corba/java/Makefile
===================================================================
--- trunk/bindings/corba/java/Makefile 2011-10-29 15:28:23 UTC (rev 2662)
+++ trunk/bindings/corba/java/Makefile 2011-10-29 15:38:34 UTC (rev 2663)
@@ -1,9 +1,10 @@
#CHANGE THESE TO MATCH YOUR SYSTEM
TOMCAT_HOME=/opt/tomcat
-instdir=${TOMCAT_HOME}/webapps/swordweb
+#instdir=${TOMCAT_HOME}/webapps/swordweb
# Typically you'll point this to your home directory, e.g.
-#instdir=/home/swordweb/livehtml/webapp
+instdir=/home/swordweb/livehtml/webapp
+#instdir=/home/sword/html
#instdir=/home/scribe/src/swordweb/webapp
SERVLET_LIB=${TOMCAT_HOME}/lib/servlet-api.jar
@@ -30,4 +31,4 @@
rm -rf classes/*
install:
- cp -a classes/org/ ${instdir}/WEB-INF/classes/
+ cp -r classes/org/ ${instdir}/WEB-INF/classes/
Modified: trunk/bindings/corba/java/src/org/crosswire/sword/orb/SwordOrb.java
===================================================================
--- trunk/bindings/corba/java/src/org/crosswire/sword/orb/SwordOrb.java 2011-10-29 15:28:23 UTC (rev 2662)
+++ trunk/bindings/corba/java/src/org/crosswire/sword/orb/SwordOrb.java 2011-10-29 15:38:34 UTC (rev 2663)
@@ -35,9 +35,9 @@
public class SwordOrb extends Object implements HttpSessionBindingListener {
public static Properties config = null;
public static String ORBEXE = "swordorbserver";
- public static final int MAX_REMOTE_ADDR_CONNECTIONS = 20;
- public static final int MAX_ACCESS_COUNT_PER_INTERVAL = 10;
- public static final long MAX_ACCESS_COUNT_INTERVAL = 10 * 1000; // milliseconds
+ public static final int MAX_REMOTE_ADDR_CONNECTIONS = 10;
+ public static final int MAX_ACCESS_COUNT_PER_INTERVAL = 50;
+ public static final long MAX_ACCESS_COUNT_INTERVAL = 50 * 1000; // milliseconds
public static final long BLACKLIST_DURATION = 10 * 60 * 1000; // milliseconds
public static final String BIBLES = "Biblical Texts";
public static final String COMMENTARIES = "Commentaries";
@@ -256,7 +256,11 @@
session.setAttribute("SwordOrb", orb);
}
- else throw new Exception("Max Remote Addr Connections from: ["+remoteAddr+"]");
+ else {
+ // recycle oldest orb
+ orb = orbs.remove(0);
+ orbs.add(orb);
+ }
}
else {
log(INFO, "ORB found in session", null);
Modified: trunk/bindings/corba/omniorbcpp/Makefile
===================================================================
--- trunk/bindings/corba/omniorbcpp/Makefile 2011-10-29 15:28:23 UTC (rev 2662)
+++ trunk/bindings/corba/omniorbcpp/Makefile 2011-10-29 15:38:34 UTC (rev 2663)
@@ -16,9 +16,9 @@
LIBS += -L/usr/lib64
#comment out for release
-CXXFLAGS += -g -O0
-CFLAGS += -g -O0
-LDFLAGS += -g -O0
+#CXXFLAGS += -g -O0
+#CFLAGS += -g -O0
+#LDFLAGS += -g -O0
#-----------------------------------------------------------------------------
Modified: trunk/bindings/corba/omniorbcpp/swordorb-impl.cpp
===================================================================
--- trunk/bindings/corba/omniorbcpp/swordorb-impl.cpp 2011-10-29 15:28:23 UTC (rev 2662)
+++ trunk/bindings/corba/omniorbcpp/swordorb-impl.cpp 2011-10-29 15:38:34 UTC (rev 2663)
@@ -21,6 +21,7 @@
#include <swordorb-impl.hpp>
#include <swmgr.h>
+#include <installmgr.h>
#include <versekey.h>
#include <treekeyidx.h>
#include <swbuf.h>
@@ -177,7 +178,7 @@
retVal->length(count);
count = 0;
for (result = sword::TOP; !result.Error(); result++) {
- (*retVal)[count++] = CORBA::string_dup(assureValidUTF8((const char *)result));
+ (*retVal)[count++] = CORBA::string_dup(assureValidUTF8(VerseKey(result).getOSISRef()));
}
}
else {
@@ -499,3 +500,27 @@
}
+char* swordorb_SWMgr_i::translate(const char* text, const char* localeName) {
+ return CORBA::string_dup(LocaleMgr::getSystemLocaleMgr()->translate(text, localeName));
+}
+
+swordorb::StringList* swordorb_SWMgr_i::getRepos() {
+ swordorb::StringList *retVal = new swordorb::StringList;
+ int count = 0;
+ sword::InstallMgr *installMgr = new sword::InstallMgr();
+ for (InstallSourceMap::iterator it = installMgr->sources.begin(); it != installMgr->sources.end(); it++) {
+ count++;
+ }
+ retVal->length(count);
+ count = 0;
+ for (InstallSourceMap::iterator it = installMgr->sources.begin(); it != installMgr->sources.end(); it++) {
+ (*retVal)[count++] = CORBA::string_dup(assureValidUTF8(it->second->caption.c_str()));
+ }
+ delete installMgr;
+ return retVal;
+}
+
+// Don't call me yet
+swordorb::_objref_SWMgr* swordorb_SWMgr_i::getShadowMgr(const char*) {
+ return 0;
+}
Modified: trunk/bindings/corba/omniorbcpp/swordorb-impl.hpp
===================================================================
--- trunk/bindings/corba/omniorbcpp/swordorb-impl.hpp 2011-10-29 15:28:23 UTC (rev 2662)
+++ trunk/bindings/corba/omniorbcpp/swordorb-impl.hpp 2011-10-29 15:38:34 UTC (rev 2663)
@@ -65,6 +65,7 @@
char* getRawEntry();
void setRawEntry(const char* entryBuffer);
char* getConfigEntry(const char* key);
+ char* translate(const char* text, const char* localeName);
void deleteSearchFramework();
::CORBA::Boolean hasSearchFramework();
@@ -107,6 +108,9 @@
void setJavascript(::CORBA::Boolean val);
swordorb::StringList* getAvailableLocales();
void setDefaultLocale(const char* name);
+ char* translate(const char* text, const char* localeName);
+ swordorb::StringList* getRepos();
+ swordorb::_objref_SWMgr* getShadowMgr(const char*);
};
Modified: trunk/bindings/corba/orbitcpp/swordorb-impl.cpp
===================================================================
--- trunk/bindings/corba/orbitcpp/swordorb-impl.cpp 2011-10-29 15:28:23 UTC (rev 2662)
+++ trunk/bindings/corba/orbitcpp/swordorb-impl.cpp 2011-10-29 15:38:34 UTC (rev 2663)
@@ -410,4 +410,8 @@
LocaleMgr::getSystemLocaleMgr()->setDefaultLocaleName(name);
}
+char* SWMgr_impl::translate(const char* text, const char* localeName) throw(CORBA::SystemException) {
+ return CORBA::string_dup(LocaleMgr::getSystemLocaleMgr()->translate(text, localeName));
}
+
+}
Modified: trunk/bindings/corba/orbitcpp/swordorb-impl.hpp
===================================================================
--- trunk/bindings/corba/orbitcpp/swordorb-impl.hpp 2011-10-29 15:28:23 UTC (rev 2662)
+++ trunk/bindings/corba/orbitcpp/swordorb-impl.hpp 2011-10-29 15:38:34 UTC (rev 2663)
@@ -43,7 +43,7 @@
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); }
+ void setKeyText(const char *key) throw(CORBA::SystemException);
char *getKeyText() throw(CORBA::SystemException) { return CORBA::string_dup((char *)delegate->KeyText()); }
StringList *getKeyChildren() throw(CORBA::SystemException);
char *getKeyParent() throw(CORBA::SystemException);
@@ -93,6 +93,7 @@
void setJavascript(CORBA::Boolean) throw(CORBA::SystemException);
StringList *getAvailableLocales() throw(CORBA::SystemException);
void setDefaultLocale(const char *name) throw(CORBA::SystemException);
+ char *translate(const char *text, const char *locale) throw(CORBA::SystemException);
};
};
Modified: trunk/bindings/corba/swordorb.idl
===================================================================
--- trunk/bindings/corba/swordorb.idl 2011-10-29 15:28:23 UTC (rev 2662)
+++ trunk/bindings/corba/swordorb.idl 2011-10-29 15:38:34 UTC (rev 2663)
@@ -115,6 +115,9 @@
void setJavascript(in boolean val);
StringList getAvailableLocales();
void setDefaultLocale(in string name);
+ string translate(in string text, in string localeName);
+ StringList getRepos();
+ SWMgr getShadowMgr(in string repoName);
};
};
Modified: trunk/src/modules/filters/rtfhtml.cpp
===================================================================
--- trunk/src/modules/filters/rtfhtml.cpp 2011-10-29 15:28:23 UTC (rev 2662)
+++ trunk/src/modules/filters/rtfhtml.cpp 2011-10-29 15:38:34 UTC (rev 2663)
@@ -24,6 +24,9 @@
#include <stdlib.h>
#include <rtfhtml.h>
#include <swbuf.h>
+#include <swunicod.h>
+#include <ctype.h>
+#include <sysdata.h>
SWORD_NAMESPACE_START
@@ -43,12 +46,26 @@
{
if (*from == '\\') // a RTF command
{
+ // \u12345?
+ if ( *(from+1) == 'u' && (*(from+2) == '-' || isdigit(*(from+2)))) {
+ unsigned char buf[8];
+ from += 2;
+ const char *end = from;
+ while (isdigit(*++end));
+ SWBuf num;
+ num.append(from, end-from);
+ __s16 n = atoi(num.c_str());
+ __u32 u = (__u16)n;
+ text.append((const char *)UTF32to8(u, buf));
+ from += (end-from);
+ continue;
+ }
if ( !strncmp(from+1, "pard", 4) )
//(from[1] == 'p') && (from[2] == 'a') && (from[3] == 'r') && (from[4] == 'd'))
{ // switch all modifiers off
if (center)
{
- text += "</CENTER>";
+ text += "</center>";
center = false;
}
from += 4;
@@ -57,7 +74,7 @@
if ( !strncmp(from+1, "par", 3) )
//(from[1] == 'p') && (from[2] == 'a') && (from[3] == 'r'))
{
- text += "<P>\n";
+ text += "<p/>\n";
from += 3;
continue;
}
@@ -71,7 +88,7 @@
{
if (!center)
{
- text += "<CENTER>";
+ text += "<center>";
center = true;
}
from += 2;
Modified: trunk/tests/filtertest.cpp
===================================================================
--- trunk/tests/filtertest.cpp 2011-10-29 15:28:23 UTC (rev 2662)
+++ trunk/tests/filtertest.cpp 2011-10-29 15:38:34 UTC (rev 2663)
@@ -20,6 +20,7 @@
#include <filemgr.h>
#include <papyriplain.h>
#include <utf8utf16.h>
+#include <rtfhtml.h>
#include <sysdata.h>
//#include <swmgr.h>
#ifndef NO_SWORD_NAMESPACE
@@ -29,12 +30,13 @@
int main(int argc, char **argv) {
- UTF8UTF16 filter;
+// UTF8UTF16 filter;
+ RTFHTML filter;
// PapyriPlain filter;
//
FileDesc *fd = (argc > 1) ? FileMgr::getSystemFileMgr()->open(argv[1], FileMgr::RDONLY) : 0;
- SWBuf lineBuffer = "This is t<e>xt which has papy-\nri markings in it.\n L[et's be] sure it gets--\n cleaned up well for s(earching)";
+ SWBuf lineBuffer = "T\\u12345?his is t<e>xt which has papy-\nri markings in it.\n L[et's be] sure it gets--\n cleaned up well for s(earching)";
if (argc > 1 && !strcmp(argv[1], "-v")) {
std::cout << "Original:\n\n";
@@ -52,23 +54,24 @@
fd = FileMgr::getSystemFileMgr()->open(argv[1], FileMgr::RDONLY);
}
- cout << "\xff\xfe"; // UTF16LE file signature
+// cout << "\xff\xfe"; // UTF16LE file signature
while (!fd || FileMgr::getLine(fd, lineBuffer)) {
lineBuffer += "\n";
filter.processText(lineBuffer);
-/* Simply way to output byte stream
+// Simply way to output byte stream
for (unsigned int i = 0; i < lineBuffer.size(); ++i) {
std::cout << lineBuffer[i];
}
-*/
+/*
// Example showing safe to cast to u16 stream
unsigned int size = lineBuffer.size() / 2;
__u16 *wcharBuf = (__u16 *)lineBuffer.getRawData();
for (unsigned int i = 0; i < size; ++i) {
std::wcout << (wchar_t)wcharBuf[i]; // must cast for correct output and because wchar_t is different size on linux we couldn't declare out wcharBuf a wchar_t *
}
+*/
if (!fd) break;
}
More information about the sword-cvs
mailing list