[sword-svn] r3627 - in trunk: bindings/cordova/org.crosswire.sword.cordova.SWORD/src/android bindings/cordova/org.crosswire.sword.cordova.SWORD/www include

scribe at crosswire.org scribe at crosswire.org
Sat May 18 20:53:38 MST 2019


Author: scribe
Date: 2019-05-18 20:53:38 -0700 (Sat, 18 May 2019)
New Revision: 3627

Added:
   trunk/include/swversion.h
Modified:
   trunk/bindings/cordova/org.crosswire.sword.cordova.SWORD/src/android/SWORD.java
   trunk/bindings/cordova/org.crosswire.sword.cordova.SWORD/www/SWORD.js
Log:
Added locale hooks into cordova plugin and add back swversion.h which was inadvertently removed in the previous commit

Modified: trunk/bindings/cordova/org.crosswire.sword.cordova.SWORD/src/android/SWORD.java
===================================================================
--- trunk/bindings/cordova/org.crosswire.sword.cordova.SWORD/src/android/SWORD.java	2019-05-19 02:49:51 UTC (rev 3626)
+++ trunk/bindings/cordova/org.crosswire.sword.cordova.SWORD/src/android/SWORD.java	2019-05-19 03:53:38 UTC (rev 3627)
@@ -415,6 +415,24 @@
 			mgr.sendBibleSyncMessage(osisRef);
 			callbackContext.success();
 		}
+		else if (action.equals("SWMgr_getAvailableLocales")) {
+			JSONArray r = new JSONArray();
+			for (String s : mgr.getAvailableLocales()) {
+				r.put(s);
+			}
+			callbackContext.success(r);
+		}
+		else if (action.equals("SWMgr_setDefaultLocale")) {
+			String val = args.getString(0);
+			mgr.setDefaultLocale(val);
+			callbackContext.success();
+		}
+		else if (action.equals("SWModule_translate")) {
+			String text = args.getString(0);
+			String locale = args.getString(1);
+			String translated = mgr.translate(text, locale);
+			callbackContext.success(translated);
+		}
 		else if (action.equals("SWModule_getRenderText")) {
 			SWModule mod = mgr.getModuleByName(args.getString(0));
 			if (mod == null) { callbackContext.error("couldn't find module: " + args.getString(0)); return true; }

Modified: trunk/bindings/cordova/org.crosswire.sword.cordova.SWORD/www/SWORD.js
===================================================================
--- trunk/bindings/cordova/org.crosswire.sword.cordova.SWORD/www/SWORD.js	2019-05-19 02:49:51 UTC (rev 3626)
+++ trunk/bindings/cordova/org.crosswire.sword.cordova.SWORD/www/SWORD.js	2019-05-19 03:53:38 UTC (rev 3627)
@@ -343,6 +343,30 @@
 	);
 }
 
+SWMgr.prototype.getAvailableLocales = function(callback) {
+	var retVal = [];
+	exec(callback?callback:function(r) { retVal = r; },
+		function(err) { utils.alert('[ERROR] problem: ' + err); },
+		"SWORD", "SWMgr_getAvailableLocales", []
+	);
+	return retVal;
+}
+
+SWMgr.prototype.setDefaultLocale = function(val, callback) {
+	exec(callback?callback:function() {},
+		function(err) { utils.alert('[ERROR] problem: ' + err); },
+		"SWORD", "SWMgr_setDefaultLocale", [val]
+	);
+}
+
+SWMgr.prototype.translate = function(text, locale, callback) {
+	exec(callback?callback:function() {},
+		function(err) { utils.alert('[ERROR] problem: ' + err); },
+		"SWORD", "SWMgr_translate", [text, locale]
+	);
+}
+
+
 function HTTPUtils() {}
 
 HTTPUtils.prototype.METHOD_GET  =  0;
@@ -371,8 +395,6 @@
 	public native String[]    getGlobalOptionValues(String option);
 	public native void        setCipherKey(String modName, String key);
 	public native void        setJavascript(boolean val);
-	public native String[]    getAvailableLocales();
-	public native void        setDefaultLocale(String name);
 */
 
 

Added: trunk/include/swversion.h
===================================================================
--- trunk/include/swversion.h	                        (rev 0)
+++ trunk/include/swversion.h	2019-05-19 03:53:38 UTC (rev 3627)
@@ -0,0 +1,74 @@
+/******************************************************************************
+ *
+ *  swversion.h -	definition of class SWVersion used to compare version
+ *			info
+ *
+ * $Id$
+ *
+ * Copyright 2001-2013 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 SWVERSION_H
+#define SWVERSION_H
+
+#define SWORD_VERSION_NUM 108900000
+#define SWORD_VERSION_STR "1.8.900"
+#define SWORD_VERSION_MAJOR 1
+#define SWORD_VERSION_MINOR 8
+#define SWORD_VERSION_MICRO 900
+#define SWORD_VERSION_NANO 0
+
+#include <defs.h>
+SWORD_NAMESPACE_START
+
+/** A basic tool class to handle program version numbers.
+*/
+class SWDLLEXPORT SWVersion {
+	public:
+	/** The different version subnumbers.
+	*/
+	int major, minor, minor2, minor3;
+	/**The constructor.
+	* @param version Version string to be parsed.
+	*/
+	SWVersion(const char *version = "0.0");
+	/** Compare 2 Versions with each other.
+	* @param vi Version number to compare with.
+	* @return >0:this>vi; 0:this==vi; <0:this<vi
+	*/
+	int compare(const SWVersion &vi) const;
+	/** @return The parsed version number text.
+	*/
+	const char *getText() const;
+	/** @return The parsed version number text.
+	*/
+	operator const char *() const { return getText(); }
+	bool operator>(const SWVersion &vi) const {return (compare(vi) > 0);}
+	bool operator<(const SWVersion &vi) const {return (compare(vi) < 0);}
+	bool operator>=(const SWVersion &vi) const {return (compare(vi) >= 0);}
+	bool operator<=(const SWVersion &vi) const {return (compare(vi) <= 0);}
+	bool operator==(const SWVersion &vi) const {return (compare(vi) == 0);}
+
+	/** Current sword library version.
+	* Use this to check (e.g. at compile time) if the
+	* version of the sword lib is recent enough for your program.
+	*/
+	static SWVersion currentVersion;
+};
+
+SWORD_NAMESPACE_END
+#endif
+




More information about the sword-cvs mailing list