@capacitor-community/sqlite 3.4.0 → 3.4.1-3
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 +7 -0
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/CapacitorSQLite.java +134 -89
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/CapacitorSQLitePlugin.java +449 -264
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/Database.java +41 -27
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/ImportExportJson/ExportToJson.java +5 -0
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/ImportExportJson/ImportFromJson.java +24 -15
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/ImportExportJson/JsonSQLite.java +4 -1
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/ImportExportJson/UtilsJson.java +23 -0
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/SqliteConfig.java +9 -0
- package/dist/esm/definitions.js +1 -1
- package/dist/esm/definitions.js.map +1 -1
- package/dist/plugin.cjs.js +1 -1
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +1 -1
- package/dist/plugin.js.map +1 -1
- package/electron/dist/plugin.js +228 -176
- package/electron/dist/plugin.js.map +1 -1
- package/ios/Plugin/CapacitorSQLite.swift +150 -109
- package/ios/Plugin/CapacitorSQLitePlugin.swift +17 -10
- package/ios/Plugin/Database.swift +50 -20
- package/ios/Plugin/ImportExportJson/ExportToJson.swift +8 -0
- package/ios/Plugin/ImportExportJson/ImportFromJson.swift +20 -14
- package/ios/Plugin/SqliteConfig.swift +1 -0
- package/ios/Plugin/Utils/UtilsJson.swift +28 -0
- package/package.json +9 -6
package/android/src/main/java/com/getcapacitor/community/database/sqlite/CapacitorSQLitePlugin.java
CHANGED
|
@@ -6,6 +6,7 @@ import com.getcapacitor.JSArray;
|
|
|
6
6
|
import com.getcapacitor.JSObject;
|
|
7
7
|
import com.getcapacitor.Plugin;
|
|
8
8
|
import com.getcapacitor.PluginCall;
|
|
9
|
+
import com.getcapacitor.PluginConfig;
|
|
9
10
|
import com.getcapacitor.PluginMethod;
|
|
10
11
|
import com.getcapacitor.annotation.CapacitorPlugin;
|
|
11
12
|
import com.getcapacitor.community.database.sqlite.SQLite.Database;
|
|
@@ -28,6 +29,7 @@ public class CapacitorSQLitePlugin extends Plugin {
|
|
|
28
29
|
private RetHandler rHandler = new RetHandler();
|
|
29
30
|
private String passphrase = null;
|
|
30
31
|
private String oldpassphrase = null;
|
|
32
|
+
private String loadMessage = "";
|
|
31
33
|
|
|
32
34
|
/**
|
|
33
35
|
* Load Method
|
|
@@ -41,10 +43,12 @@ public class CapacitorSQLitePlugin extends Plugin {
|
|
|
41
43
|
implementation = new CapacitorSQLite(context, config);
|
|
42
44
|
} catch (JSONException e) {
|
|
43
45
|
implementation = null;
|
|
44
|
-
|
|
46
|
+
loadMessage = "CapacitorSQLitePlugin: " + e.getMessage();
|
|
47
|
+
Log.e(TAG, loadMessage);
|
|
45
48
|
} catch (Exception e) {
|
|
46
49
|
implementation = null;
|
|
47
|
-
|
|
50
|
+
loadMessage = "CapacitorSQLitePlugin: " + e.getMessage();
|
|
51
|
+
Log.e(TAG, loadMessage);
|
|
48
52
|
}
|
|
49
53
|
}
|
|
50
54
|
|
|
@@ -57,12 +61,16 @@ public class CapacitorSQLitePlugin extends Plugin {
|
|
|
57
61
|
@PluginMethod
|
|
58
62
|
public void echo(PluginCall call) {
|
|
59
63
|
String value = call.getString("value");
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
if (implementation != null) {
|
|
65
|
+
try {
|
|
66
|
+
JSObject ret = new JSObject();
|
|
67
|
+
ret.put("value", implementation.echo(value));
|
|
68
|
+
call.resolve(ret);
|
|
69
|
+
} catch (Exception e) {
|
|
70
|
+
call.reject(e.getMessage());
|
|
71
|
+
}
|
|
72
|
+
} else {
|
|
73
|
+
call.reject(loadMessage);
|
|
66
74
|
}
|
|
67
75
|
}
|
|
68
76
|
|
|
@@ -74,13 +82,18 @@ public class CapacitorSQLitePlugin extends Plugin {
|
|
|
74
82
|
*/
|
|
75
83
|
@PluginMethod
|
|
76
84
|
public void isSecretStored(PluginCall call) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
85
|
+
if (implementation != null) {
|
|
86
|
+
try {
|
|
87
|
+
Boolean res = implementation.isSecretStored();
|
|
88
|
+
rHandler.retResult(call, res, null);
|
|
89
|
+
return;
|
|
90
|
+
} catch (Exception e) {
|
|
91
|
+
String msg = "IsSecretStored: " + e.getMessage();
|
|
92
|
+
rHandler.retResult(call, null, msg);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
} else {
|
|
96
|
+
rHandler.retResult(call, null, loadMessage);
|
|
84
97
|
return;
|
|
85
98
|
}
|
|
86
99
|
}
|
|
@@ -100,13 +113,18 @@ public class CapacitorSQLitePlugin extends Plugin {
|
|
|
100
113
|
return;
|
|
101
114
|
}
|
|
102
115
|
passphrase = call.getString("passphrase");
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
116
|
+
if (implementation != null) {
|
|
117
|
+
try {
|
|
118
|
+
implementation.setEncryptionSecret(passphrase);
|
|
119
|
+
rHandler.retResult(call, null, null);
|
|
120
|
+
return;
|
|
121
|
+
} catch (Exception e) {
|
|
122
|
+
String msg = "SetEncryptionSecret: " + e.getMessage();
|
|
123
|
+
rHandler.retResult(call, null, msg);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
} else {
|
|
127
|
+
rHandler.retResult(call, null, loadMessage);
|
|
110
128
|
return;
|
|
111
129
|
}
|
|
112
130
|
}
|
|
@@ -133,22 +151,27 @@ public class CapacitorSQLitePlugin extends Plugin {
|
|
|
133
151
|
return;
|
|
134
152
|
}
|
|
135
153
|
oldpassphrase = call.getString("oldpassphrase");
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
154
|
+
if (implementation != null) {
|
|
155
|
+
getActivity()
|
|
156
|
+
.runOnUiThread(
|
|
157
|
+
new Runnable() {
|
|
158
|
+
@Override
|
|
159
|
+
public void run() {
|
|
160
|
+
try {
|
|
161
|
+
implementation.changeEncryptionSecret(call, passphrase, oldpassphrase);
|
|
162
|
+
return;
|
|
163
|
+
} catch (Exception e) {
|
|
164
|
+
String msg = "ChangeEncryptionSecret: " + e.getMessage();
|
|
165
|
+
rHandler.retResult(call, null, msg);
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
148
168
|
}
|
|
149
169
|
}
|
|
150
|
-
|
|
151
|
-
|
|
170
|
+
);
|
|
171
|
+
} else {
|
|
172
|
+
rHandler.retResult(call, null, loadMessage);
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
152
175
|
}
|
|
153
176
|
|
|
154
177
|
@PluginMethod
|
|
@@ -167,13 +190,18 @@ public class CapacitorSQLitePlugin extends Plugin {
|
|
|
167
190
|
return;
|
|
168
191
|
}
|
|
169
192
|
dbName = call.getString("database");
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
193
|
+
if (implementation != null) {
|
|
194
|
+
try {
|
|
195
|
+
String databasePath = implementation.getNCDatabasePath(folderPath, dbName);
|
|
196
|
+
rHandler.retPath(call, databasePath, null);
|
|
197
|
+
return;
|
|
198
|
+
} catch (Exception e) {
|
|
199
|
+
String msg = "getNCDatabasePath: " + e.getMessage();
|
|
200
|
+
rHandler.retResult(call, null, msg);
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
} else {
|
|
204
|
+
rHandler.retResult(call, null, loadMessage);
|
|
177
205
|
return;
|
|
178
206
|
}
|
|
179
207
|
}
|
|
@@ -195,13 +223,18 @@ public class CapacitorSQLitePlugin extends Plugin {
|
|
|
195
223
|
}
|
|
196
224
|
dbPath = call.getString("databasePath");
|
|
197
225
|
dbVersion = call.getInt("version", 1);
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
226
|
+
if (implementation != null) {
|
|
227
|
+
try {
|
|
228
|
+
implementation.createNCConnection(dbPath, dbVersion);
|
|
229
|
+
rHandler.retResult(call, null, null);
|
|
230
|
+
return;
|
|
231
|
+
} catch (Exception e) {
|
|
232
|
+
String msg = "CreateNCConnection: " + e.getMessage();
|
|
233
|
+
rHandler.retResult(call, null, msg);
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
} else {
|
|
237
|
+
rHandler.retResult(call, null, loadMessage);
|
|
205
238
|
return;
|
|
206
239
|
}
|
|
207
240
|
}
|
|
@@ -242,13 +275,18 @@ public class CapacitorSQLitePlugin extends Plugin {
|
|
|
242
275
|
inMode = "no-encryption";
|
|
243
276
|
}
|
|
244
277
|
Dictionary<Integer, JSONObject> upgDict = versionUpgrades.get(dbName);
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
278
|
+
if (implementation != null) {
|
|
279
|
+
try {
|
|
280
|
+
implementation.createConnection(dbName, encrypted, inMode, dbVersion, upgDict);
|
|
281
|
+
rHandler.retResult(call, null, null);
|
|
282
|
+
return;
|
|
283
|
+
} catch (Exception e) {
|
|
284
|
+
String msg = "CreateConnection: " + e.getMessage();
|
|
285
|
+
rHandler.retResult(call, null, msg);
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
} else {
|
|
289
|
+
rHandler.retResult(call, null, loadMessage);
|
|
252
290
|
return;
|
|
253
291
|
}
|
|
254
292
|
}
|
|
@@ -267,13 +305,18 @@ public class CapacitorSQLitePlugin extends Plugin {
|
|
|
267
305
|
return;
|
|
268
306
|
}
|
|
269
307
|
String dbName = call.getString("database");
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
308
|
+
if (implementation != null) {
|
|
309
|
+
try {
|
|
310
|
+
implementation.open(dbName);
|
|
311
|
+
rHandler.retResult(call, null, null);
|
|
312
|
+
return;
|
|
313
|
+
} catch (Exception e) {
|
|
314
|
+
String msg = "Open: " + e.getMessage();
|
|
315
|
+
rHandler.retResult(call, null, msg);
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
} else {
|
|
319
|
+
rHandler.retResult(call, null, loadMessage);
|
|
277
320
|
return;
|
|
278
321
|
}
|
|
279
322
|
}
|
|
@@ -292,13 +335,18 @@ public class CapacitorSQLitePlugin extends Plugin {
|
|
|
292
335
|
return;
|
|
293
336
|
}
|
|
294
337
|
String dbName = call.getString("database");
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
338
|
+
if (implementation != null) {
|
|
339
|
+
try {
|
|
340
|
+
implementation.close(dbName);
|
|
341
|
+
rHandler.retResult(call, null, null);
|
|
342
|
+
return;
|
|
343
|
+
} catch (Exception e) {
|
|
344
|
+
String msg = "Close: " + e.getMessage();
|
|
345
|
+
rHandler.retResult(call, null, msg);
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
} else {
|
|
349
|
+
rHandler.retResult(call, null, loadMessage);
|
|
302
350
|
return;
|
|
303
351
|
}
|
|
304
352
|
}
|
|
@@ -317,13 +365,18 @@ public class CapacitorSQLitePlugin extends Plugin {
|
|
|
317
365
|
return;
|
|
318
366
|
}
|
|
319
367
|
String dbName = call.getString("database");
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
368
|
+
if (implementation != null) {
|
|
369
|
+
try {
|
|
370
|
+
String res = implementation.getUrl(dbName);
|
|
371
|
+
rHandler.retUrl(call, res, null);
|
|
372
|
+
return;
|
|
373
|
+
} catch (Exception e) {
|
|
374
|
+
String msg = "GetUrl: " + e.getMessage();
|
|
375
|
+
rHandler.retUrl(call, null, msg);
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
378
|
+
} else {
|
|
379
|
+
rHandler.retUrl(call, null, loadMessage);
|
|
327
380
|
return;
|
|
328
381
|
}
|
|
329
382
|
}
|
|
@@ -342,13 +395,18 @@ public class CapacitorSQLitePlugin extends Plugin {
|
|
|
342
395
|
return;
|
|
343
396
|
}
|
|
344
397
|
String dbName = call.getString("database");
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
398
|
+
if (implementation != null) {
|
|
399
|
+
try {
|
|
400
|
+
Integer res = implementation.getVersion(dbName);
|
|
401
|
+
rHandler.retVersion(call, res, null);
|
|
402
|
+
return;
|
|
403
|
+
} catch (Exception e) {
|
|
404
|
+
String msg = "GetVersion: " + e.getMessage();
|
|
405
|
+
rHandler.retVersion(call, null, msg);
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
} else {
|
|
409
|
+
rHandler.retVersion(call, null, loadMessage);
|
|
352
410
|
return;
|
|
353
411
|
}
|
|
354
412
|
}
|
|
@@ -367,13 +425,18 @@ public class CapacitorSQLitePlugin extends Plugin {
|
|
|
367
425
|
return;
|
|
368
426
|
}
|
|
369
427
|
String dbPath = call.getString("databasePath");
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
428
|
+
if (implementation != null) {
|
|
429
|
+
try {
|
|
430
|
+
implementation.closeNCConnection(dbPath);
|
|
431
|
+
rHandler.retResult(call, null, null);
|
|
432
|
+
return;
|
|
433
|
+
} catch (Exception e) {
|
|
434
|
+
String msg = "CloseNCConnection: " + e.getMessage();
|
|
435
|
+
rHandler.retResult(call, null, msg);
|
|
436
|
+
return;
|
|
437
|
+
}
|
|
438
|
+
} else {
|
|
439
|
+
rHandler.retResult(call, null, loadMessage);
|
|
377
440
|
return;
|
|
378
441
|
}
|
|
379
442
|
}
|
|
@@ -392,13 +455,18 @@ public class CapacitorSQLitePlugin extends Plugin {
|
|
|
392
455
|
return;
|
|
393
456
|
}
|
|
394
457
|
String dbName = call.getString("database");
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
458
|
+
if (implementation != null) {
|
|
459
|
+
try {
|
|
460
|
+
implementation.closeConnection(dbName);
|
|
461
|
+
rHandler.retResult(call, null, null);
|
|
462
|
+
return;
|
|
463
|
+
} catch (Exception e) {
|
|
464
|
+
String msg = "CloseConnection: " + e.getMessage();
|
|
465
|
+
rHandler.retResult(call, null, msg);
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
468
|
+
} else {
|
|
469
|
+
rHandler.retResult(call, null, loadMessage);
|
|
402
470
|
return;
|
|
403
471
|
}
|
|
404
472
|
}
|
|
@@ -417,13 +485,18 @@ public class CapacitorSQLitePlugin extends Plugin {
|
|
|
417
485
|
return;
|
|
418
486
|
}
|
|
419
487
|
JSArray dbNames = call.getArray("dbNames");
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
488
|
+
if (implementation != null) {
|
|
489
|
+
try {
|
|
490
|
+
Boolean res = implementation.checkConnectionsConsistency(dbNames);
|
|
491
|
+
rHandler.retResult(call, res, null);
|
|
492
|
+
return;
|
|
493
|
+
} catch (Exception e) {
|
|
494
|
+
String msg = "CheckConnectionsConsistency: " + e.getMessage();
|
|
495
|
+
rHandler.retResult(call, null, msg);
|
|
496
|
+
return;
|
|
497
|
+
}
|
|
498
|
+
} else {
|
|
499
|
+
rHandler.retResult(call, null, loadMessage);
|
|
427
500
|
return;
|
|
428
501
|
}
|
|
429
502
|
}
|
|
@@ -441,13 +514,18 @@ public class CapacitorSQLitePlugin extends Plugin {
|
|
|
441
514
|
return;
|
|
442
515
|
}
|
|
443
516
|
String dbName = call.getString("database");
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
517
|
+
if (implementation != null) {
|
|
518
|
+
try {
|
|
519
|
+
Boolean res = implementation.isDatabase(dbName);
|
|
520
|
+
rHandler.retResult(call, res, null);
|
|
521
|
+
return;
|
|
522
|
+
} catch (Exception e) {
|
|
523
|
+
String msg = "isDatabase: " + e.getMessage();
|
|
524
|
+
rHandler.retResult(call, null, msg);
|
|
525
|
+
return;
|
|
526
|
+
}
|
|
527
|
+
} else {
|
|
528
|
+
rHandler.retResult(call, null, loadMessage);
|
|
451
529
|
return;
|
|
452
530
|
}
|
|
453
531
|
}
|
|
@@ -465,13 +543,18 @@ public class CapacitorSQLitePlugin extends Plugin {
|
|
|
465
543
|
return;
|
|
466
544
|
}
|
|
467
545
|
String dbPath = call.getString("databasePath");
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
546
|
+
if (implementation != null) {
|
|
547
|
+
try {
|
|
548
|
+
Boolean res = implementation.isNCDatabase(dbPath);
|
|
549
|
+
rHandler.retResult(call, res, null);
|
|
550
|
+
return;
|
|
551
|
+
} catch (Exception e) {
|
|
552
|
+
String msg = "isNCDatabase: " + e.getMessage();
|
|
553
|
+
rHandler.retResult(call, null, msg);
|
|
554
|
+
return;
|
|
555
|
+
}
|
|
556
|
+
} else {
|
|
557
|
+
rHandler.retResult(call, null, loadMessage);
|
|
475
558
|
return;
|
|
476
559
|
}
|
|
477
560
|
}
|
|
@@ -494,13 +577,18 @@ public class CapacitorSQLitePlugin extends Plugin {
|
|
|
494
577
|
return;
|
|
495
578
|
}
|
|
496
579
|
String tableName = call.getString("table");
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
580
|
+
if (implementation != null) {
|
|
581
|
+
try {
|
|
582
|
+
Boolean res = implementation.isTableExists(dbName, tableName);
|
|
583
|
+
rHandler.retResult(call, res, null);
|
|
584
|
+
return;
|
|
585
|
+
} catch (Exception e) {
|
|
586
|
+
String msg = "isTableExists: " + e.getMessage();
|
|
587
|
+
rHandler.retResult(call, null, msg);
|
|
588
|
+
return;
|
|
589
|
+
}
|
|
590
|
+
} else {
|
|
591
|
+
rHandler.retResult(call, null, loadMessage);
|
|
504
592
|
return;
|
|
505
593
|
}
|
|
506
594
|
}
|
|
@@ -511,13 +599,18 @@ public class CapacitorSQLitePlugin extends Plugin {
|
|
|
511
599
|
*/
|
|
512
600
|
@PluginMethod
|
|
513
601
|
public void getDatabaseList(PluginCall call) {
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
602
|
+
if (implementation != null) {
|
|
603
|
+
try {
|
|
604
|
+
JSArray res = implementation.getDatabaseList();
|
|
605
|
+
rHandler.retValues(call, res, null);
|
|
606
|
+
return;
|
|
607
|
+
} catch (Exception e) {
|
|
608
|
+
String msg = "getDatabaseList: " + e.getMessage();
|
|
609
|
+
rHandler.retValues(call, new JSArray(), msg);
|
|
610
|
+
return;
|
|
611
|
+
}
|
|
612
|
+
} else {
|
|
613
|
+
rHandler.retValues(call, new JSArray(), loadMessage);
|
|
521
614
|
return;
|
|
522
615
|
}
|
|
523
616
|
}
|
|
@@ -535,13 +628,18 @@ public class CapacitorSQLitePlugin extends Plugin {
|
|
|
535
628
|
} else {
|
|
536
629
|
folderPath = call.getString("folderPath");
|
|
537
630
|
}
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
631
|
+
if (implementation != null) {
|
|
632
|
+
try {
|
|
633
|
+
JSArray res = implementation.getMigratableDbList(folderPath);
|
|
634
|
+
rHandler.retValues(call, res, null);
|
|
635
|
+
return;
|
|
636
|
+
} catch (Exception e) {
|
|
637
|
+
String msg = "getMigratableDbList: " + e.getMessage();
|
|
638
|
+
rHandler.retValues(call, new JSArray(), msg);
|
|
639
|
+
return;
|
|
640
|
+
}
|
|
641
|
+
} else {
|
|
642
|
+
rHandler.retValues(call, new JSArray(), loadMessage);
|
|
545
643
|
return;
|
|
546
644
|
}
|
|
547
645
|
}
|
|
@@ -564,13 +662,18 @@ public class CapacitorSQLitePlugin extends Plugin {
|
|
|
564
662
|
} else {
|
|
565
663
|
dbList = call.getArray("dbNameList");
|
|
566
664
|
}
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
665
|
+
if (implementation != null) {
|
|
666
|
+
try {
|
|
667
|
+
implementation.addSQLiteSuffix(folderPath, dbList);
|
|
668
|
+
rHandler.retResult(call, null, null);
|
|
669
|
+
return;
|
|
670
|
+
} catch (Exception e) {
|
|
671
|
+
String msg = "addSQLiteSuffix: " + e.getMessage();
|
|
672
|
+
rHandler.retResult(call, null, msg);
|
|
673
|
+
return;
|
|
674
|
+
}
|
|
675
|
+
} else {
|
|
676
|
+
rHandler.retResult(call, null, loadMessage);
|
|
574
677
|
return;
|
|
575
678
|
}
|
|
576
679
|
}
|
|
@@ -593,13 +696,18 @@ public class CapacitorSQLitePlugin extends Plugin {
|
|
|
593
696
|
} else {
|
|
594
697
|
dbList = call.getArray("dbNameList");
|
|
595
698
|
}
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
699
|
+
if (implementation != null) {
|
|
700
|
+
try {
|
|
701
|
+
implementation.deleteOldDatabases(folderPath, dbList);
|
|
702
|
+
rHandler.retResult(call, null, null);
|
|
703
|
+
return;
|
|
704
|
+
} catch (Exception e) {
|
|
705
|
+
String msg = "deleteOldDatabases: " + e.getMessage();
|
|
706
|
+
rHandler.retResult(call, null, msg);
|
|
707
|
+
return;
|
|
708
|
+
}
|
|
709
|
+
} else {
|
|
710
|
+
rHandler.retResult(call, null, loadMessage);
|
|
603
711
|
return;
|
|
604
712
|
}
|
|
605
713
|
}
|
|
@@ -628,13 +736,18 @@ public class CapacitorSQLitePlugin extends Plugin {
|
|
|
628
736
|
String statements = call.getString("statements");
|
|
629
737
|
Boolean transaction = call.getBoolean("transaction", true);
|
|
630
738
|
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
739
|
+
if (implementation != null) {
|
|
740
|
+
try {
|
|
741
|
+
JSObject res = implementation.execute(dbName, statements, transaction);
|
|
742
|
+
rHandler.retChanges(call, res, null);
|
|
743
|
+
return;
|
|
744
|
+
} catch (Exception e) {
|
|
745
|
+
String msg = "Execute: " + e.getMessage();
|
|
746
|
+
rHandler.retChanges(call, retRes, msg);
|
|
747
|
+
return;
|
|
748
|
+
}
|
|
749
|
+
} else {
|
|
750
|
+
rHandler.retChanges(call, retRes, loadMessage);
|
|
638
751
|
return;
|
|
639
752
|
}
|
|
640
753
|
}
|
|
@@ -680,13 +793,18 @@ public class CapacitorSQLitePlugin extends Plugin {
|
|
|
680
793
|
}
|
|
681
794
|
}
|
|
682
795
|
Boolean transaction = call.getBoolean("transaction", true);
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
796
|
+
if (implementation != null) {
|
|
797
|
+
try {
|
|
798
|
+
JSObject res = implementation.executeSet(dbName, set, transaction);
|
|
799
|
+
rHandler.retChanges(call, res, null);
|
|
800
|
+
return;
|
|
801
|
+
} catch (Exception e) {
|
|
802
|
+
String msg = "ExecuteSet: " + e.getMessage();
|
|
803
|
+
rHandler.retChanges(call, retRes, msg);
|
|
804
|
+
return;
|
|
805
|
+
}
|
|
806
|
+
} else {
|
|
807
|
+
rHandler.retChanges(call, retRes, loadMessage);
|
|
690
808
|
return;
|
|
691
809
|
}
|
|
692
810
|
}
|
|
@@ -721,14 +839,18 @@ public class CapacitorSQLitePlugin extends Plugin {
|
|
|
721
839
|
JSArray values = call.getArray("values");
|
|
722
840
|
|
|
723
841
|
Boolean transaction = call.getBoolean("transaction", true);
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
842
|
+
if (implementation != null) {
|
|
843
|
+
try {
|
|
844
|
+
JSObject res = implementation.run(dbName, statement, values, transaction);
|
|
845
|
+
rHandler.retChanges(call, res, null);
|
|
846
|
+
return;
|
|
847
|
+
} catch (Exception e) {
|
|
848
|
+
String msg = "Run: " + e.getMessage();
|
|
849
|
+
rHandler.retChanges(call, retRes, msg);
|
|
850
|
+
return;
|
|
851
|
+
}
|
|
852
|
+
} else {
|
|
853
|
+
rHandler.retChanges(call, retRes, loadMessage);
|
|
732
854
|
return;
|
|
733
855
|
}
|
|
734
856
|
}
|
|
@@ -759,13 +881,18 @@ public class CapacitorSQLitePlugin extends Plugin {
|
|
|
759
881
|
return;
|
|
760
882
|
}
|
|
761
883
|
JSArray values = call.getArray("values");
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
884
|
+
if (implementation != null) {
|
|
885
|
+
try {
|
|
886
|
+
JSArray res = implementation.query(dbName, statement, values);
|
|
887
|
+
rHandler.retValues(call, res, null);
|
|
888
|
+
return;
|
|
889
|
+
} catch (Exception e) {
|
|
890
|
+
String msg = "Query: " + e.getMessage();
|
|
891
|
+
rHandler.retValues(call, new JSArray(), msg);
|
|
892
|
+
return;
|
|
893
|
+
}
|
|
894
|
+
} else {
|
|
895
|
+
rHandler.retValues(call, new JSArray(), loadMessage);
|
|
769
896
|
return;
|
|
770
897
|
}
|
|
771
898
|
}
|
|
@@ -785,13 +912,18 @@ public class CapacitorSQLitePlugin extends Plugin {
|
|
|
785
912
|
}
|
|
786
913
|
String dbName = call.getString("database");
|
|
787
914
|
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
915
|
+
if (implementation != null) {
|
|
916
|
+
try {
|
|
917
|
+
Boolean res = implementation.isDBExists(dbName);
|
|
918
|
+
rHandler.retResult(call, res, null);
|
|
919
|
+
return;
|
|
920
|
+
} catch (Exception e) {
|
|
921
|
+
String msg = "isDBExists: " + e.getMessage();
|
|
922
|
+
rHandler.retResult(call, false, msg);
|
|
923
|
+
return;
|
|
924
|
+
}
|
|
925
|
+
} else {
|
|
926
|
+
rHandler.retResult(call, null, loadMessage);
|
|
795
927
|
return;
|
|
796
928
|
}
|
|
797
929
|
}
|
|
@@ -810,13 +942,18 @@ public class CapacitorSQLitePlugin extends Plugin {
|
|
|
810
942
|
return;
|
|
811
943
|
}
|
|
812
944
|
String dbName = call.getString("database");
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
945
|
+
if (implementation != null) {
|
|
946
|
+
try {
|
|
947
|
+
Boolean res = implementation.isDBOpen(dbName);
|
|
948
|
+
rHandler.retResult(call, res, null);
|
|
949
|
+
return;
|
|
950
|
+
} catch (Exception e) {
|
|
951
|
+
String msg = "isDBOpen: " + e.getMessage();
|
|
952
|
+
rHandler.retResult(call, false, msg);
|
|
953
|
+
return;
|
|
954
|
+
}
|
|
955
|
+
} else {
|
|
956
|
+
rHandler.retResult(call, null, loadMessage);
|
|
820
957
|
return;
|
|
821
958
|
}
|
|
822
959
|
}
|
|
@@ -835,13 +972,18 @@ public class CapacitorSQLitePlugin extends Plugin {
|
|
|
835
972
|
return;
|
|
836
973
|
}
|
|
837
974
|
String dbName = call.getString("database");
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
975
|
+
if (implementation != null) {
|
|
976
|
+
try {
|
|
977
|
+
implementation.deleteDatabase(dbName);
|
|
978
|
+
rHandler.retResult(call, null, null);
|
|
979
|
+
return;
|
|
980
|
+
} catch (Exception e) {
|
|
981
|
+
String msg = "deleteDatabase: " + e.getMessage();
|
|
982
|
+
rHandler.retResult(call, null, msg);
|
|
983
|
+
return;
|
|
984
|
+
}
|
|
985
|
+
} else {
|
|
986
|
+
rHandler.retResult(call, null, loadMessage);
|
|
845
987
|
return;
|
|
846
988
|
}
|
|
847
989
|
}
|
|
@@ -862,13 +1004,18 @@ public class CapacitorSQLitePlugin extends Plugin {
|
|
|
862
1004
|
return;
|
|
863
1005
|
}
|
|
864
1006
|
String dbName = call.getString("database");
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
1007
|
+
if (implementation != null) {
|
|
1008
|
+
try {
|
|
1009
|
+
JSObject res = implementation.createSyncTable(dbName);
|
|
1010
|
+
rHandler.retChanges(call, res, null);
|
|
1011
|
+
return;
|
|
1012
|
+
} catch (Exception e) {
|
|
1013
|
+
String msg = "CreateSyncTable: " + e.getMessage();
|
|
1014
|
+
rHandler.retChanges(call, retRes, msg);
|
|
1015
|
+
return;
|
|
1016
|
+
}
|
|
1017
|
+
} else {
|
|
1018
|
+
rHandler.retChanges(call, retRes, loadMessage);
|
|
872
1019
|
return;
|
|
873
1020
|
}
|
|
874
1021
|
}
|
|
@@ -894,13 +1041,18 @@ public class CapacitorSQLitePlugin extends Plugin {
|
|
|
894
1041
|
return;
|
|
895
1042
|
}
|
|
896
1043
|
String syncDate = call.getString("syncdate");
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
1044
|
+
if (implementation != null) {
|
|
1045
|
+
try {
|
|
1046
|
+
implementation.setSyncDate(dbName, syncDate);
|
|
1047
|
+
rHandler.retResult(call, null, null);
|
|
1048
|
+
return;
|
|
1049
|
+
} catch (Exception e) {
|
|
1050
|
+
String msg = "SetSyncDate: " + e.getMessage();
|
|
1051
|
+
rHandler.retResult(call, null, msg);
|
|
1052
|
+
return;
|
|
1053
|
+
}
|
|
1054
|
+
} else {
|
|
1055
|
+
rHandler.retResult(call, null, loadMessage);
|
|
904
1056
|
return;
|
|
905
1057
|
}
|
|
906
1058
|
}
|
|
@@ -921,13 +1073,18 @@ public class CapacitorSQLitePlugin extends Plugin {
|
|
|
921
1073
|
return;
|
|
922
1074
|
}
|
|
923
1075
|
String dbName = call.getString("database");
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
1076
|
+
if (implementation != null) {
|
|
1077
|
+
try {
|
|
1078
|
+
long syncDate = implementation.getSyncDate(dbName);
|
|
1079
|
+
rHandler.retSyncDate(call, syncDate, null);
|
|
1080
|
+
return;
|
|
1081
|
+
} catch (Exception e) {
|
|
1082
|
+
String msg = "GetSyncDate: " + e.getMessage();
|
|
1083
|
+
rHandler.retSyncDate(call, new Long(0), msg);
|
|
1084
|
+
return;
|
|
1085
|
+
}
|
|
1086
|
+
} else {
|
|
1087
|
+
rHandler.retSyncDate(call, new Long(0), loadMessage);
|
|
931
1088
|
return;
|
|
932
1089
|
}
|
|
933
1090
|
}
|
|
@@ -953,14 +1110,19 @@ public class CapacitorSQLitePlugin extends Plugin {
|
|
|
953
1110
|
}
|
|
954
1111
|
JSArray upgrade = call.getArray("upgrade");
|
|
955
1112
|
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
1113
|
+
if (implementation != null) {
|
|
1114
|
+
try {
|
|
1115
|
+
Dictionary<Integer, JSONObject> upgDict = implementation.addUpgradeStatement(upgrade);
|
|
1116
|
+
versionUpgrades.put(dbName, upgDict);
|
|
1117
|
+
rHandler.retResult(call, null, null);
|
|
1118
|
+
return;
|
|
1119
|
+
} catch (Exception e) {
|
|
1120
|
+
String msg = "AddUpgradeStatement: " + e.getMessage();
|
|
1121
|
+
rHandler.retResult(call, null, msg);
|
|
1122
|
+
return;
|
|
1123
|
+
}
|
|
1124
|
+
} else {
|
|
1125
|
+
rHandler.retResult(call, null, loadMessage);
|
|
964
1126
|
return;
|
|
965
1127
|
}
|
|
966
1128
|
}
|
|
@@ -979,13 +1141,18 @@ public class CapacitorSQLitePlugin extends Plugin {
|
|
|
979
1141
|
return;
|
|
980
1142
|
}
|
|
981
1143
|
String parsingData = call.getString("jsonstring");
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
1144
|
+
if (implementation != null) {
|
|
1145
|
+
try {
|
|
1146
|
+
Boolean res = implementation.isJsonValid(parsingData);
|
|
1147
|
+
rHandler.retResult(call, res, null);
|
|
1148
|
+
return;
|
|
1149
|
+
} catch (Exception e) {
|
|
1150
|
+
String msg = "IsJsonValid: " + e.getMessage();
|
|
1151
|
+
rHandler.retResult(call, false, msg);
|
|
1152
|
+
return;
|
|
1153
|
+
}
|
|
1154
|
+
} else {
|
|
1155
|
+
rHandler.retResult(call, null, loadMessage);
|
|
989
1156
|
return;
|
|
990
1157
|
}
|
|
991
1158
|
}
|
|
@@ -1006,13 +1173,18 @@ public class CapacitorSQLitePlugin extends Plugin {
|
|
|
1006
1173
|
return;
|
|
1007
1174
|
}
|
|
1008
1175
|
String parsingData = call.getString("jsonstring");
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1176
|
+
if (implementation != null) {
|
|
1177
|
+
try {
|
|
1178
|
+
JSObject res = implementation.importFromJson(parsingData);
|
|
1179
|
+
rHandler.retChanges(call, res, null);
|
|
1180
|
+
return;
|
|
1181
|
+
} catch (Exception e) {
|
|
1182
|
+
String msg = "ImportFromJson: " + e.getMessage();
|
|
1183
|
+
rHandler.retChanges(call, retRes, msg);
|
|
1184
|
+
return;
|
|
1185
|
+
}
|
|
1186
|
+
} else {
|
|
1187
|
+
rHandler.retChanges(call, retRes, loadMessage);
|
|
1016
1188
|
return;
|
|
1017
1189
|
}
|
|
1018
1190
|
}
|
|
@@ -1046,13 +1218,18 @@ public class CapacitorSQLitePlugin extends Plugin {
|
|
|
1046
1218
|
return;
|
|
1047
1219
|
}
|
|
1048
1220
|
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1221
|
+
if (implementation != null) {
|
|
1222
|
+
try {
|
|
1223
|
+
JSObject res = implementation.exportToJson(dbName, expMode);
|
|
1224
|
+
rHandler.retJSObject(call, res, null);
|
|
1225
|
+
return;
|
|
1226
|
+
} catch (Exception e) {
|
|
1227
|
+
String msg = "ExportToJson: " + e.getMessage();
|
|
1228
|
+
rHandler.retJSObject(call, retObj, msg);
|
|
1229
|
+
return;
|
|
1230
|
+
}
|
|
1231
|
+
} else {
|
|
1232
|
+
rHandler.retJSObject(call, retObj, loadMessage);
|
|
1056
1233
|
return;
|
|
1057
1234
|
}
|
|
1058
1235
|
}
|
|
@@ -1067,13 +1244,18 @@ public class CapacitorSQLitePlugin extends Plugin {
|
|
|
1067
1244
|
public void copyFromAssets(PluginCall call) {
|
|
1068
1245
|
Boolean overwrite = call.getData().has("overwrite") ? call.getBoolean("overwrite") : true;
|
|
1069
1246
|
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1247
|
+
if (implementation != null) {
|
|
1248
|
+
try {
|
|
1249
|
+
implementation.copyFromAssets(overwrite);
|
|
1250
|
+
rHandler.retResult(call, null, null);
|
|
1251
|
+
return;
|
|
1252
|
+
} catch (Exception e) {
|
|
1253
|
+
String msg = "CopyFromAssets: " + e.getMessage();
|
|
1254
|
+
rHandler.retResult(call, null, msg);
|
|
1255
|
+
return;
|
|
1256
|
+
}
|
|
1257
|
+
} else {
|
|
1258
|
+
rHandler.retResult(call, null, loadMessage);
|
|
1077
1259
|
return;
|
|
1078
1260
|
}
|
|
1079
1261
|
}
|
|
@@ -1126,9 +1308,12 @@ public class CapacitorSQLitePlugin extends Plugin {
|
|
|
1126
1308
|
|
|
1127
1309
|
private SqliteConfig getSqliteConfig() throws JSONException {
|
|
1128
1310
|
SqliteConfig config = new SqliteConfig();
|
|
1129
|
-
JSONObject
|
|
1311
|
+
JSONObject pConfig = getConfig().getConfigJSON();
|
|
1312
|
+
Boolean isEncryption = pConfig.has("androidIsEncryption") ? pConfig.getBoolean("androidIsEncryption") : config.getIsEncryption();
|
|
1313
|
+
config.setIsEncryption(isEncryption);
|
|
1314
|
+
JSONObject androidBiometric = pConfig.has("androidBiometric") ? pConfig.getJSONObject("androidBiometric") : null;
|
|
1130
1315
|
if (androidBiometric != null) {
|
|
1131
|
-
Boolean biometricAuth = androidBiometric.has("biometricAuth")
|
|
1316
|
+
Boolean biometricAuth = androidBiometric.has("biometricAuth") && isEncryption
|
|
1132
1317
|
? androidBiometric.getBoolean("biometricAuth")
|
|
1133
1318
|
: config.getBiometricAuth();
|
|
1134
1319
|
config.setBiometricAuth(biometricAuth);
|