[sword-svn] r3634 - in trunk: bindings bindings/cordova/cordova-plugin-crosswire-sword bindings/cordova/cordova-plugin-crosswire-sword/src/ios bindings/objc bindings/objc/SWORD/SWORD.xcodeproj/project.xcworkspace/xcuserdata/scribe.xcuserdatad include
scribe at crosswire.org
scribe at crosswire.org
Fri May 24 23:54:38 MST 2019
Author: scribe
Date: 2019-05-24 23:54:37 -0700 (Fri, 24 May 2019)
New Revision: 3634
Modified:
trunk/bindings/cordova/cordova-plugin-crosswire-sword/plugin.xml
trunk/bindings/cordova/cordova-plugin-crosswire-sword/src/ios/SWORD.swift
trunk/bindings/flatapi.cpp
trunk/bindings/objc/Makefile
trunk/bindings/objc/SWORD/SWORD.xcodeproj/project.xcworkspace/xcuserdata/scribe.xcuserdatad/UserInterfaceState.xcuserstate
trunk/include/flatapi.h
Log:
Added StringMgr support to flatapi
Added locale support for ios cordova plugin
Modified: trunk/bindings/cordova/cordova-plugin-crosswire-sword/plugin.xml
===================================================================
--- trunk/bindings/cordova/cordova-plugin-crosswire-sword/plugin.xml 2019-05-24 22:40:50 UTC (rev 3633)
+++ trunk/bindings/cordova/cordova-plugin-crosswire-sword/plugin.xml 2019-05-25 06:54:37 UTC (rev 3634)
@@ -3,9 +3,9 @@
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:rim="http://www.blackberry.com/ns/widgets"
xmlns:android="http://schemas.android.com/apk/res/android"
- id="org.crosswire.sword.cordova.SWORD"
+ id="cordova-plugin-crosswire-sword"
version="0.0.1">
- <name>SWORD</name>
+ <name>cordova-plugin-crosswire-sword</name>
<description>The SWORD Project Plugin</description>
<license>GNU 2.0</license>
<keywords>cordova,sword,Bible</keywords>
Modified: trunk/bindings/cordova/cordova-plugin-crosswire-sword/src/ios/SWORD.swift
===================================================================
--- trunk/bindings/cordova/cordova-plugin-crosswire-sword/src/ios/SWORD.swift 2019-05-24 22:40:50 UTC (rev 3633)
+++ trunk/bindings/cordova/cordova-plugin-crosswire-sword/src/ios/SWORD.swift 2019-05-25 06:54:37 UTC (rev 3634)
@@ -24,6 +24,13 @@
VERSEKEY_BOOKNAME = Int(org_crosswire_sword_SWModule_VERSEKEY_BOOKNAME);
VERSEKEY_SHORTTEXT = Int(org_crosswire_sword_SWModule_VERSEKEY_SHORTTEXT);
+ org_crosswire_sword_StringMgr_setToUpper({ (text: Optional<UnsafePointer<Int8>>, maxBytes: u_long) in
+ let lower = String(cString: text!)
+ let upper = lower.uppercased()
+ strncpy(UnsafeMutablePointer<Int8>(mutating: text), upper, Int(maxBytes));
+ return UnsafeMutablePointer<Int8>(mutating: text)
+ })
+
initMgr()
let libswordVersion = String(cString: org_crosswire_sword_SWMgr_version(mgr))
@@ -220,7 +227,38 @@
let retVal = getStringArray(buffer: org_crosswire_sword_SWConfig_getSections(confPath))
self.commandDelegate!.send(CDVPluginResult(status: CDVCommandStatus_OK, messageAs: retVal), callbackId: command.callbackId)
}
+
+
+ @objc(SWMgr_getAvailableLocales:)
+ func SWMgr_getAvailableLocales(command: CDVInvokedUrlCommand) {
+ initMgr()
+ let retVal = getStringArray(buffer: org_crosswire_sword_SWMgr_getAvailableLocales(mgr))
+ self.commandDelegate!.send(CDVPluginResult(status: CDVCommandStatus_OK, messageAs: retVal), callbackId: command.callbackId)
+ }
+
+
+ @objc(SWMgr_setDefaultLocale:)
+ func SWMgr_setDefaultLocale(command: CDVInvokedUrlCommand) {
+ initMgr()
+ let localeName = command.arguments[0] as? String ?? ""
+ org_crosswire_sword_SWMgr_setDefaultLocale(mgr, localeName)
+ self.commandDelegate!.send(CDVPluginResult(status: CDVCommandStatus_OK, messageAs: "SWMgr_setDefaultLocale"), callbackId: command.callbackId)
+ }
+
+ @objc(SWMgr_translate:)
+ func SWMgr_translate(command: CDVInvokedUrlCommand) {
+
+ initMgr()
+
+ let text = command.arguments[0] as? String ?? ""
+ let localeName = command.arguments[1] as? String ?? ""
+
+ let translated = org_crosswire_sword_SWMgr_translate(mgr, text, localeName == "null" || localeName == "" ? nil : localeName)
+ let retVal = translated == nil ? nil : String(cString:translated!)
+ self.commandDelegate!.send(CDVPluginResult(status: CDVCommandStatus_OK, messageAs: retVal), callbackId: command.callbackId)
+ }
+
@objc(echo:)
func echo(command: CDVInvokedUrlCommand) {
Modified: trunk/bindings/flatapi.cpp
===================================================================
--- trunk/bindings/flatapi.cpp 2019-05-24 22:40:50 UTC (rev 3633)
+++ trunk/bindings/flatapi.cpp 2019-05-25 06:54:37 UTC (rev 3634)
@@ -32,6 +32,7 @@
#include <versekey.h>
#include <treekeyidx.h>
#include <filemgr.h>
+#include <stringmgr.h>
#include <swbuf.h>
#include <swlog.h>
#include <localemgr.h>
@@ -117,6 +118,7 @@
using std::string;
BibleSync *bibleSync = 0;
org_biblesync_MessageReceivedCallback bibleSyncListener = 0;
+org_crosswire_sword_StringMgr_toUpperUTF8 toUpperUTF8 = 0;
void bibleSyncCallback(char cmd, string pkt_uuid, string bible, string ref, string alt, string group, string domain, string info, string dump) {
SWLog::getSystemLog()->logDebug("bibleSync callback msg: %c; pkt_uuid: %s; bible: %s; ref: %s; alt: %s; group: %s; domain: %s; info: %s; dump: %s", cmd, pkt_uuid.c_str(), bible.c_str(), ref.c_str(), alt.c_str(), group.c_str(), domain.c_str(), info.c_str(), dump.c_str());
@@ -335,6 +337,17 @@
}
};
+class FlatStringMgr : public StringMgr {
+public:
+ virtual char *upperUTF8(char *buf, unsigned int maxLen = 0) const {
+ if (toUpperUTF8) {
+ return (*toUpperUTF8)(buf, maxLen);
+ }
+ return buf;
+ }
+protected:
+ virtual bool supportsUnicode() const { return toUpperUTF8 != 0; }
+};
const char **HandleSWMgr::globalOptions = 0;
@@ -355,6 +368,7 @@
HandleSWMgr::availableLocales = 0;
HandleInstMgr::remoteSources = 0;
+ StringMgr::setSystemStringMgr(new FlatStringMgr());
}
~InitStatics() {
@@ -1048,6 +1062,9 @@
bool exists = FileMgr::existsFile(extraPath.c_str());
SWLog::getSystemLog()->logDebug("libsword: extraConfig %s at path: %s", exists?"Exists":"Absent", extraPath.c_str());
+SWLog::getSystemLog()->logDebug("libsword: init() adding locales from baseDir.");
+ LocaleMgr::getSystemLocaleMgr()->loadConfigDir(SWBuf(confPath + "locales.d").c_str());
+ LocaleMgr::getSystemLocaleMgr()->loadConfigDir(SWBuf(confPath + "uilocales.d").c_str());
SWLog::getSystemLog()->logDebug("libsword: init() creating WebMgr using path: %s", path);
return (SWHANDLE) new HandleSWMgr(new WebMgr(confPath.c_str(), exists?extraPath.c_str():0));
}
@@ -1533,6 +1550,10 @@
//
//
+void SWDLLEXPORT org_crosswire_sword_StringMgr_setToUpper
+ (org_crosswire_sword_StringMgr_toUpperUTF8 toUpperUTF8Funct) {
+ toUpperUTF8 = toUpperUTF8Funct;
+}
/*
* Class: org_crosswire_sword_InstallMgr
Modified: trunk/bindings/objc/Makefile
===================================================================
--- trunk/bindings/objc/Makefile 2019-05-24 22:40:50 UTC (rev 3633)
+++ trunk/bindings/objc/Makefile 2019-05-25 06:54:37 UTC (rev 3634)
@@ -10,12 +10,12 @@
all: deploycordova
deploycordova:
- mkdir -p ../cordova/org.crosswire.sword.cordova.SWORD/libs/ios/
- cp ./dependencies/curl/lib/libcurl.a ../cordova/org.crosswire.sword.cordova.SWORD/libs/ios/
-# cp ./Build/Debug-iphonesimulator/libSWORD.a ../cordova/org.crosswire.sword.cordova.SWORD/libs/ios/
-# cp ./Build/Debug-iphoneos/libSWORD.a ../cordova/org.crosswire.sword.cordova.SWORD/libs/ios/
- cp SWORD/Release-universal/libSWORD.a ../cordova/org.crosswire.sword.cordova.SWORD/libs/ios/
- cp ../../include/defs.h ../../include/flatapi.h ../cordova/org.crosswire.sword.cordova.SWORD/src/ios/
+ mkdir -p ../cordova/cordova-plugin-crosswire-sword/libs/ios/
+ cp ./dependencies/curl/lib/libcurl.a ../cordova/cordova-plugin-crosswire-sword/libs/ios/
+# cp ./Build/Debug-iphonesimulator/libSWORD.a ../cordova/cordova-plugin-crosswire-sword/libs/ios/
+# cp ./Build/Debug-iphoneos/libSWORD.a ../cordova/cordova-plugin-crosswire-sword/libs/ios/
+ cp SWORD/Release-universal/libSWORD.a ../cordova/cordova-plugin-crosswire-sword/libs/ios/
+ cp ../../include/defs.h ../../include/flatapi.h ../cordova/cordova-plugin-crosswire-sword/src/ios/
Modified: trunk/bindings/objc/SWORD/SWORD.xcodeproj/project.xcworkspace/xcuserdata/scribe.xcuserdatad/UserInterfaceState.xcuserstate
===================================================================
(Binary files differ)
Modified: trunk/include/flatapi.h
===================================================================
--- trunk/include/flatapi.h 2019-05-24 22:40:50 UTC (rev 3633)
+++ trunk/include/flatapi.h 2019-05-25 06:54:37 UTC (rev 3634)
@@ -496,7 +496,10 @@
//
typedef void (*org_crosswire_sword_InstallMgr_StatusCallback)(const char *, unsigned long, unsigned long);
+typedef char * (*org_crosswire_sword_StringMgr_toUpperUTF8)(const char *, unsigned long);
+void SWDLLEXPORT org_crosswire_sword_StringMgr_setToUpper
+ (org_crosswire_sword_StringMgr_toUpperUTF8 toUpperUTF8);
/*
* Class: org_crosswire_sword_InstallMgr
* Method: new
More information about the sword-cvs
mailing list