[sword-svn] r1743 - in trunk: . bindings/corba bindings/corba/java bindings/corba/java/src/org/crosswire/sword/orb bindings/corba/orbitcpp src/modules/filters

scribe at crosswire.org scribe at crosswire.org
Fri Mar 18 17:55:26 MST 2005


Author: scribe
Date: 2005-03-18 17:55:26 -0700 (Fri, 18 Mar 2005)
New Revision: 1743

Modified:
   trunk/bindings/corba/java/Makefile
   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/orbitcpp/testclient.cpp
   trunk/bindings/corba/swordorb.idl
   trunk/src/modules/filters/thmlwordjs.cpp
   trunk/usrinst.sh
Log:
Fixed thmlwordjs.cpp to not try to make morph popup work yet.
Added CORBA interface for obtaining a list of locales and setting
a locale in the orb.
In Java, you'll need to call: SWMgr.getAvailableLocales(), like usual
and it should return a String[].
But when you set, you shouldn't use SWMgr.setDefaultLocale(), as this will
only set your current server.  If your server times out or gets restarted,
then it won't have the setting any longer.  INSTEAD, use:
SwordOrb.setSessionLocale(String localeName, HttpSession sesson);
This sets the locale AND tells the orb manager that if it has to restart the orb, then it should
set the locale of that orb again.


Modified: trunk/bindings/corba/java/Makefile
===================================================================
--- trunk/bindings/corba/java/Makefile	2005-03-17 13:20:32 UTC (rev 1742)
+++ trunk/bindings/corba/java/Makefile	2005-03-19 00:55:26 UTC (rev 1743)
@@ -1,4 +1,4 @@
-TOMCAT_HOME=/home/tomcat/jakarta-tomcat
+TOMCAT_HOME=/usr/local/tomcat
 instdir=/home/swordweb/livehtml
 all: src/org/crosswire/sword/orb/SWMgr.java classes/org/crosswire/sword/orb/SwordOrb.class
 

Modified: trunk/bindings/corba/java/src/org/crosswire/sword/orb/SwordOrb.java
===================================================================
--- trunk/bindings/corba/java/src/org/crosswire/sword/orb/SwordOrb.java	2005-03-17 13:20:32 UTC (rev 1742)
+++ trunk/bindings/corba/java/src/org/crosswire/sword/orb/SwordOrb.java	2005-03-19 00:55:26 UTC (rev 1743)
@@ -16,6 +16,7 @@
 	public static final String DAILYDEVOS = "Daily Devotional";
 	static org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(new String[]{}, null);
 	String ior = null;
+	String localeName = null;
 
 	private SWMgr attach() {
 		SWMgr retVal = null;
@@ -96,6 +97,11 @@
 				startOrb();
 System.out.println("trying to attach to newly launched ORB");
 				retVal = attach();
+				if (retVal != null) {
+					if (localeName != null) {
+						retVal.setDefaultLocale(localeName);
+					}
+				}
 			}
 			catch(org.omg.CORBA.SystemException e) {
 				e.printStackTrace();
@@ -104,17 +110,34 @@
 		return retVal;
 	}
 
+	public static void setSessionLocale(String localeName, HttpSession session) {
+		session.setAttribute("SwordOrbLocale", localeName);
+		SWMgr mgr = getSWMgrInstance(session);
+		if (mgr != null) {
+			mgr.setDefaultLocale(localeName);
+		}
+	}
 
-	public static SWMgr getSWMgrInstance(HttpSession session) {
+	public static SwordOrb getSessionOrb(HttpSession session) {
 		SwordOrb orb = (SwordOrb)session.getAttribute("SwordOrb");
 		if (orb == null) {
 System.out.println("No ORB found in session; constructing a new instance");
 			orb = new SwordOrb();
+
+			String locName = (String)session.getAttribute("SwordOrbLocale");
+			if (locName != null)
+				orb.localeName = locName;
+
 			session.setAttribute("SwordOrb", orb);
 		}
 		else {
 System.out.println("ORB found in session");
 		}
+		return orb;
+	}
+
+	public static SWMgr getSWMgrInstance(HttpSession session) {
+		SwordOrb orb = getSessionOrb(session);
 		SWMgr mgr = orb.getSWMgrInstance();
 		return mgr;
 	}

Modified: trunk/bindings/corba/orbitcpp/swordorb-impl.cpp
===================================================================
--- trunk/bindings/corba/orbitcpp/swordorb-impl.cpp	2005-03-17 13:20:32 UTC (rev 1742)
+++ trunk/bindings/corba/orbitcpp/swordorb-impl.cpp	2005-03-19 00:55:26 UTC (rev 1743)
@@ -4,6 +4,7 @@
 #include <versekey.h>
 #include <treekeyidx.h>
 #include <swbuf.h>
+#include <localemgr.h>
 
 /*
 char* swordorb::SWModule_impl::helloWorld(const char* greeting) throw(CORBA::SystemException) {
@@ -232,4 +233,25 @@
 	return 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);
+}
+
+}

Modified: trunk/bindings/corba/orbitcpp/swordorb-impl.hpp
===================================================================
--- trunk/bindings/corba/orbitcpp/swordorb-impl.hpp	2005-03-17 13:20:32 UTC (rev 1742)
+++ trunk/bindings/corba/orbitcpp/swordorb-impl.hpp	2005-03-19 00:55:26 UTC (rev 1743)
@@ -64,6 +64,8 @@
 	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

Modified: trunk/bindings/corba/orbitcpp/testclient.cpp
===================================================================
--- trunk/bindings/corba/orbitcpp/testclient.cpp	2005-03-17 13:20:32 UTC (rev 1742)
+++ trunk/bindings/corba/orbitcpp/testclient.cpp	2005-03-19 00:55:26 UTC (rev 1743)
@@ -44,6 +44,11 @@
 			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");
 		module = mgr->getModuleByName("WHNU");

Modified: trunk/bindings/corba/swordorb.idl
===================================================================
--- trunk/bindings/corba/swordorb.idl	2005-03-17 13:20:32 UTC (rev 1742)
+++ trunk/bindings/corba/swordorb.idl	2005-03-19 00:55:26 UTC (rev 1743)
@@ -78,7 +78,8 @@
 	void     terminate();
 	boolean testConnection();
 	void setJavascript(in boolean val);
-
+	StringList getAvailableLocales();
+	void setDefaultLocale(in string name);
 };
 
 };

Modified: trunk/src/modules/filters/thmlwordjs.cpp
===================================================================
--- trunk/src/modules/filters/thmlwordjs.cpp	2005-03-17 13:20:32 UTC (rev 1742)
+++ trunk/src/modules/filters/thmlwordjs.cpp	2005-03-19 00:55:26 UTC (rev 1743)
@@ -192,11 +192,13 @@
 
 
 
+/*
 							if (sMorph) {
-								SWBuf popMorph = "";
-								popMorph.appendFormatted("<a onclick=\"p(\'%s\',\'%s\','%s_%s','');\" >%s</a>", sMorph->Name(), morph.c_str(), layer.c_str(), wstr, morph.c_str());
+								SWBuf popMorph = "<a onclick=\"";
+								popMorph.appendFormatted("p(\'%s\',\'%s\','%s_%s','');\" >%s</a>", sMorph->Name(), morph.c_str(), layer.c_str(), wstr, morph.c_str());
 								morph = popMorph;
 							}
+*/
 
 
 

Modified: trunk/usrinst.sh
===================================================================
--- trunk/usrinst.sh	2005-03-17 13:20:32 UTC (rev 1742)
+++ trunk/usrinst.sh	2005-03-19 00:55:26 UTC (rev 1743)
@@ -6,10 +6,10 @@
 OPTIONS="--sysconfdir=/etc $OPTIONS"
 OPTIONS="--with-icu $OPTIONS"
 #OPTIONS="--with-vcl $OPTIONS"
-#OPTIONS="--enable-debug $OPTIONS"
+OPTIONS="--enable-debug $OPTIONS"
 #OPTIONS="--enable-profile $OPTIONS"
 OPTIONS="--with-lucene $OPTIONS"
-#OPTIONS="--without-curl $OPTIONS"
+OPTIONS="--without-curl $OPTIONS"
 #OPTIONS="--enable-tests $OPTIONS"
 OPTIONS="--disable-utilities $OPTIONS"
 



More information about the sword-cvs mailing list