cordova-plugin-crosswire-sword 0.2.4 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -33,7 +33,7 @@ Although the object is in the global scope, it is not available until after the
33
33
  var moduleName = 'KJV';
34
34
  var verse = 'Jn.3.16';
35
35
 
36
- SWORD.mgr.getModuleByName(moduleName, function (module) {
36
+ SWORD.mgr.getModuleByName(moduleName, function(module) {
37
37
  module.setKeyText(verse, function() {
38
38
  module.getRenderText(function(entryText) {
39
39
  console.log(verse + ': ' + entryText + '(' + moduleName + ')');
@@ -100,6 +100,7 @@ Although the object is in the global scope, it is not available until after the
100
100
 
101
101
  SWModule.setKeyText
102
102
  SWModule.search
103
+ SWModule.terminateSearch
103
104
  SWModule.getKeyText
104
105
  SWModule.getRenderText
105
106
  SWModule.getStripText
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cordova-plugin-crosswire-sword",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "description": "The SWORD Project Plugin",
5
5
  "cordova": {
6
6
  "id": "cordova-plugin-crosswire-sword",
package/plugin.xml CHANGED
@@ -4,7 +4,7 @@
4
4
  xmlns:rim="http://www.blackberry.com/ns/widgets"
5
5
  xmlns:android="http://schemas.android.com/apk/res/android"
6
6
  id="cordova-plugin-crosswire-sword"
7
- version="0.2.4">
7
+ version="0.2.6">
8
8
  <name>cordova-plugin-crosswire-sword</name>
9
9
  <description>The SWORD Project Plugin</description>
10
10
  <license>GNU 2.0</license>
@@ -56,6 +56,22 @@
56
56
  <source-file src="libs/android/armeabi-v7a/libsword.so" target-dir="libs/armeabi-v7a" />
57
57
  <source-file src="libs/android/x86/libsword.so" target-dir="libs/x86" />
58
58
  <source-file src="libs/android/x86_64/libsword.so" target-dir="libs/x86_64" />
59
+ <source-file src="libs/android/arm64-v8a/libcrypto.so" target-dir="libs/arm64-v8a" />
60
+ <source-file src="libs/android/armeabi-v7a/libcrypto.so" target-dir="libs/armeabi-v7a" />
61
+ <source-file src="libs/android/x86/libcrypto.so" target-dir="libs/x86" />
62
+ <source-file src="libs/android/x86_64/libcrypto.so" target-dir="libs/x86_64" />
63
+ <source-file src="libs/android/arm64-v8a/libc++_shared.so" target-dir="libs/arm64-v8a" />
64
+ <source-file src="libs/android/armeabi-v7a/libc++_shared.so" target-dir="libs/armeabi-v7a" />
65
+ <source-file src="libs/android/x86/libc++_shared.so" target-dir="libs/x86" />
66
+ <source-file src="libs/android/x86_64/libc++_shared.so" target-dir="libs/x86_64" />
67
+ <source-file src="libs/android/arm64-v8a/libcurl.so" target-dir="libs/arm64-v8a" />
68
+ <source-file src="libs/android/armeabi-v7a/libcurl.so" target-dir="libs/armeabi-v7a" />
69
+ <source-file src="libs/android/x86/libcurl.so" target-dir="libs/x86" />
70
+ <source-file src="libs/android/x86_64/libcurl.so" target-dir="libs/x86_64" />
71
+ <source-file src="libs/android/arm64-v8a/libssl.so" target-dir="libs/arm64-v8a" />
72
+ <source-file src="libs/android/armeabi-v7a/libssl.so" target-dir="libs/armeabi-v7a" />
73
+ <source-file src="libs/android/x86/libssl.so" target-dir="libs/x86" />
74
+ <source-file src="libs/android/x86_64/libssl.so" target-dir="libs/x86_64" />
59
75
 
60
76
  <!-- no longer needed with latest ndk
61
77
  <source-file src="libs/android/arm64-v8a/libc++_shared.so" target-dir="libs/arm64-v8a" />
@@ -159,7 +159,7 @@ public class SWORD extends CordovaPlugin {
159
159
  m.put("shortCopyright", mod.getConfigEntry("ShortCopyright"));
160
160
  m.put("shortPromo", mod.getConfigEntry("ShortPromo"));
161
161
  m.put("cipherKey", mod.getConfigEntry("CipherKey"));
162
- Log.d(TAG, "SWModule_getRemoteModuleByName("+args.getString(0)+", " + args.getString(1) + " returned successfully.");
162
+ //Log.d(TAG, "SWModule_getRemoteModuleByName("+args.getString(0)+", " + args.getString(1) + " returned successfully.");
163
163
  callbackContext.success(m);
164
164
  }
165
165
  else if (action.equals("InstallMgr_remoteInstallModule")) {
@@ -295,6 +295,12 @@ Log.d(TAG, "SWModule_getRemoteModuleByName("+args.getString(0)+", " + args.getSt
295
295
  if (mod == null) { callbackContext.error("couldn't find module: " + args.getString(0)); return true; }
296
296
  callbackContext.success(mod.getKeyText());
297
297
  }
298
+ else if (action.equals("SWModule_terminateSearch")) {
299
+ SWModule mod = mgr.getModuleByName(args.getString(0));
300
+ if (mod == null) { callbackContext.error("couldn't find module: " + args.getString(0)); return true; }
301
+ mod.terminateSearch();
302
+ callbackContext.success();
303
+ }
298
304
  else if (action.equals("SWModule_search")) {
299
305
  final SWModule mod = mgr.getModuleByName(args.getString(0));
300
306
  final String expression = args.getString(1);
@@ -579,20 +585,20 @@ Log.d(TAG, "... finished renderChapter");
579
585
  final String url = args.getString(0);
580
586
  final String postData = args.getString(1);
581
587
  final int method = args.getInt(2);
582
- Log.d(TAG, "about to spawn thread makeRequest(url: " + url + ", postData: " + postData + ", method: " + method);
588
+ //Log.d(TAG, "about to spawn thread makeRequest(url: " + url + ", postData: " + postData + ", method: " + method);
583
589
 
584
590
  cordova.getThreadPool().execute(new Runnable() {
585
591
  private CallbackContext makeRequestContext = callbackContext;
586
592
  @Override
587
593
  public void run() {
588
594
  String response = makeRequest(url, postData, method, null);
589
- Log.d(TAG, "received response from makeRequest with .length(): " + (response != null ? response.length() : "null"));
595
+ //Log.d(TAG, "received response from makeRequest with .length(): " + (response != null ? response.length() : "null"));
590
596
  PluginResult result = new PluginResult(PluginResult.Status.OK, response);
591
- Log.d(TAG, "added response to result object");
597
+ //Log.d(TAG, "added response to result object");
592
598
  result.setKeepCallback(false);
593
- Log.d(TAG, "setting result object keepCallback to false and calling sendPluginResult");
599
+ //Log.d(TAG, "setting result object keepCallback to false and calling sendPluginResult");
594
600
  makeRequestContext.sendPluginResult(result);
595
- Log.d(TAG, "finished calling sendPluginResult");
601
+ //Log.d(TAG, "finished calling sendPluginResult");
596
602
  }
597
603
  });
598
604
 
@@ -631,20 +637,20 @@ Log.d(TAG, "finished calling sendPluginResult");
631
637
 
632
638
  String currentKey[] = masterMod.getKeyChildren();
633
639
 
634
- Log.d(TAG, "getRenderChapter: checking currentKey");
640
+ //Log.d(TAG, "getRenderChapter: checking currentKey");
635
641
  // assert we have a valid location
636
642
  if (currentKey.length <= SWModule.VERSEKEY_BOOKABBREV || currentKey.length <= SWModule.VERSEKEY_CHAPTER) return r;
637
- Log.d(TAG, "getRenderChapter: currentKey valid.");
643
+ //Log.d(TAG, "getRenderChapter: currentKey valid.");
638
644
 
639
645
  masterMod.setKeyText(currentKey[SWModule.VERSEKEY_BOOKABBREV]+"."+currentKey[SWModule.VERSEKEY_CHAPTER]+".1");
640
- Log.d(TAG, "getRenderChapter: masterMod.setKeyText returned.");
646
+ //Log.d(TAG, "getRenderChapter: masterMod.setKeyText returned.");
641
647
 
642
648
  String [] verseKey = masterMod.getKeyChildren();
643
649
  while (
644
650
  masterMod.error() == 0
645
651
  && currentKey[SWModule.VERSEKEY_BOOK].equals(verseKey[SWModule.VERSEKEY_BOOK])
646
652
  && currentKey[SWModule.VERSEKEY_CHAPTER].equals(verseKey[SWModule.VERSEKEY_CHAPTER])) {
647
- Log.d(TAG, "looping chapter: " + verseKey[SWModule.VERSEKEY_OSISREF]);
653
+ //Log.d(TAG, "looping chapter: " + verseKey[SWModule.VERSEKEY_OSISREF]);
648
654
 
649
655
  mod.setKeyText(verseKey[SWModule.VERSEKEY_OSISREF]);
650
656
  char error = mod.error();
@@ -669,7 +675,7 @@ Log.d(TAG, "looping chapter: " + verseKey[SWModule.VERSEKEY_OSISREF]);
669
675
  masterMod.next();
670
676
  verseKey = masterMod.getKeyChildren();
671
677
  }
672
- Log.d(TAG, "Done looping chapter");
678
+ //Log.d(TAG, "Done looping chapter");
673
679
 
674
680
  masterMod.setKeyText(saveMasterKey);
675
681
  mod.setKeyText(saveKey);
@@ -704,14 +710,14 @@ Log.d(TAG, "makeRequest(url: " + url + ", postData: " + postData + ", method: "
704
710
  defaultHeaders.put("Accept", "*/*");
705
711
  // defaultHeaders.put("Content-Type", "application/xml");
706
712
  defaultHeaders.put("Content-Type", "application/x-www-form-urlencoded");
707
- Log.d(TAG, "about to add postData length to header");
713
+ //Log.d(TAG, "about to add postData length to header");
708
714
  if (method != METHOD_GET && postData != null) defaultHeaders.put("Content-Length", Integer.toString(postData.length()));
709
- Log.d(TAG, "finished adding postData length to header");
715
+ //Log.d(TAG, "finished adding postData length to header");
710
716
 
711
717
  try {
712
- Log.d(TAG, "adding any given headers");
718
+ //Log.d(TAG, "adding any given headers");
713
719
  if (headers != null) defaultHeaders.putAll(headers);
714
- Log.d(TAG, "done adding any given headers");
720
+ //Log.d(TAG, "done adding any given headers");
715
721
 
716
722
  if (method == METHOD_GET && postData != null && postData.length() > 0) {
717
723
  // some sanity checks for appending GET params to URL
@@ -721,16 +727,16 @@ Log.d(TAG, "done adding any given headers");
721
727
  url += postData;
722
728
  }
723
729
 
724
- Log.d(TAG, "opening connection");
730
+ //Log.d(TAG, "opening connection");
725
731
  connection = (HttpURLConnection) new URL(url).openConnection();
726
- Log.d(TAG, "setting request method");
732
+ //Log.d(TAG, "setting request method");
727
733
  connection.setRequestMethod(METHODS_TEXT[method]);
728
- Log.d(TAG, "setting request properties");
734
+ //Log.d(TAG, "setting request properties");
729
735
  for (String k : defaultHeaders.keySet()) {
730
736
  connection.setRequestProperty(k, defaultHeaders.get(k));
731
737
  }
732
738
  if (method == METHOD_POST) {
733
- Log.d(TAG, "sending post data");
739
+ //Log.d(TAG, "sending post data");
734
740
  connection.setDoOutput(true);
735
741
  if (postData != null) {
736
742
  DataOutputStream dos = new DataOutputStream(connection.getOutputStream());
@@ -739,10 +745,10 @@ Log.d(TAG, "sending post data");
739
745
  dos.close();
740
746
  }
741
747
  }
742
- Log.d(TAG, "getting response code");
748
+ //Log.d(TAG, "getting response code");
743
749
  int responseCode = connection.getResponseCode();
744
750
  Log.d(TAG, "response code: " + responseCode);
745
- Log.d(TAG, "getting response");
751
+ //Log.d(TAG, "getting response");
746
752
  BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream()));
747
753
  StringBuilder response = new StringBuilder();
748
754
  String line;
@@ -758,7 +764,7 @@ Log.d(TAG, "finished. returning response with .length(): " + response.length());
758
764
  return response.toString();
759
765
  }
760
766
  catch (Exception e) {
761
- Log.d(TAG, "an exception occurred in makeRequest thread: " + e);
767
+ Log.i(TAG, "an exception occurred in makeRequest thread: " + e);
762
768
  e.printStackTrace();
763
769
  }
764
770
  return null;
@@ -350,7 +350,7 @@ debugPrint("initMgr, mgr: " + String(describing: mgr))
350
350
  "name": vkInfo[VERSEKEY_BOOKNAME],
351
351
  "abbrev": vkInfo[VERSEKEY_BOOKABBREV],
352
352
  "osisName": vkInfo[VERSEKEY_OSISBOOKNAME],
353
- "chapterMax": Int(vkInfo[VERSEKEY_CHAPTERMAX]),
353
+ "chapterMax": Int(vkInfo[VERSEKEY_CHAPTERMAX])!,
354
354
  ] as [AnyHashable : Any]
355
355
  retVal.append(bookInfo)
356
356
 
@@ -671,7 +671,7 @@ debugPrint("initMgr, mgr: " + String(describing: mgr))
671
671
  let saveMasterKey = String(cString: org_crosswire_sword_SWModule_getKeyText(masterMod))
672
672
  let saveKey = String(cString: org_crosswire_sword_SWModule_getKeyText(mod))
673
673
  var r = [[String: Any]]()
674
- var currentKey = getStringArray(buffer: org_crosswire_sword_SWModule_getKeyChildren(masterMod))
674
+ let currentKey = getStringArray(buffer: org_crosswire_sword_SWModule_getKeyChildren(masterMod))
675
675
  let book = currentKey[VERSEKEY_BOOKABBREV]
676
676
  let chapter = currentKey[VERSEKEY_CHAPTER]
677
677
  org_crosswire_sword_SWModule_setKeyText(masterMod, book + "." + chapter + ".1")
@@ -724,6 +724,14 @@ debugPrint("initMgr, mgr: " + String(describing: mgr))
724
724
  return retVal;
725
725
  }
726
726
 
727
+ @objc(SWModule_terminateSearch:)
728
+ func SWModule_terminateSearch(command: CDVInvokedUrlCommand) {
729
+ let module = getModule(command: command)
730
+ if (module != 0) {
731
+ org_crosswire_sword_SWModule_terminateSearch(module)
732
+ self.commandDelegate!.send(CDVPluginResult(status: CDVCommandStatus_OK, messageAs: "SWModule_terminateSearch"), callbackId: command.callbackId)
733
+ }
734
+ }
727
735
 
728
736
  @objc(SWModule_search:)
729
737
  func SWModule_search(command: CDVInvokedUrlCommand) {
package/www/SWORD.js CHANGED
@@ -118,6 +118,15 @@ SWModule.prototype.setKeyText = function(keyText, callback) {
118
118
  return retVal;
119
119
  }
120
120
 
121
+ SWModule.prototype.terminateSearch = function(callback) {
122
+ var retVal = null;
123
+ exec(callback?callback:function(r) { retVal = r; },
124
+ function(err) { utils.alert('[ERROR] problem: ' + err); },
125
+ "SWORD", "SWModule_terminateSearch", [this.name]
126
+ );
127
+ return retVal;
128
+ }
129
+
121
130
  SWModule.prototype.search = function(expression, searchType, flags, scope, callback) {
122
131
  var retVal = null;
123
132
  exec(callback?callback:function(r) { retVal = r; },