cordova-plugin-mserviceinterface-2.0 1.0.93 → 1.0.94
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/package.json +1 -1
- package/plugin.xml +1 -1
- package/src/ios/mInterface.h +1 -0
- package/src/ios/mInterface.m +336 -1
package/package.json
CHANGED
package/plugin.xml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
2
|
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
|
3
|
-
xmlns:android="http://schemas.android.com/apk/res/android" id="cordova-plugin-mserviceinterface-2.0" version="1.0.
|
|
3
|
+
xmlns:android="http://schemas.android.com/apk/res/android" id="cordova-plugin-mserviceinterface-2.0" version="1.0.94">
|
|
4
4
|
<name>mserviceinterface-2.0</name>
|
|
5
5
|
<description>This plugin establishes the connection to the native interface and performs the requested task.</description>
|
|
6
6
|
<author>selfservit@gmail.com</author>
|
package/src/ios/mInterface.h
CHANGED
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
UIInterfaceOrientation _lastOrientation;
|
|
44
44
|
}
|
|
45
45
|
@property(strong) NSString* callbackID;
|
|
46
|
+
- (void)GetConfigCascade:(CDVInvokedUrlCommand*)command;
|
|
46
47
|
- (void)ScanBarCode:(CDVInvokedUrlCommand*)command;
|
|
47
48
|
- (void)ScanQRCode:(CDVInvokedUrlCommand*)command;
|
|
48
49
|
- (void)viewRoute:(CDVInvokedUrlCommand*)command;
|
package/src/ios/mInterface.m
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
#import "OneSignalPush.h"
|
|
14
14
|
#import <objc/runtime.h>
|
|
15
15
|
#import <AVFoundation/AVFoundation.h>
|
|
16
|
+
#import <Cordova/CDV.h>
|
|
16
17
|
#if defined(__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
|
|
17
18
|
@import UserNotifications;
|
|
18
19
|
#endif
|
|
@@ -20,7 +21,14 @@
|
|
|
20
21
|
#ifndef NSFoundationVersionNumber_iOS_9_x_Max
|
|
21
22
|
#define NSFoundationVersionNumber_iOS_9_x_Max 1299
|
|
22
23
|
#endif
|
|
23
|
-
|
|
24
|
+
/*** TOP-LEVEL helper (NOT inside @implementation mInterface) ***/
|
|
25
|
+
@interface ResolveResult : NSObject
|
|
26
|
+
@property (nonatomic, strong) NSURL *fileURL;
|
|
27
|
+
@property (nonatomic, copy) NSString *ext;
|
|
28
|
+
@end
|
|
29
|
+
|
|
30
|
+
@implementation ResolveResult
|
|
31
|
+
@end
|
|
24
32
|
@implementation mInterface
|
|
25
33
|
@synthesize btnGallery;
|
|
26
34
|
@synthesize indicator = _indicator;
|
|
@@ -29,6 +37,333 @@
|
|
|
29
37
|
@synthesize callbackID;
|
|
30
38
|
|
|
31
39
|
|
|
40
|
+
|
|
41
|
+
- (void)GetConfigCascade:(CDVInvokedUrlCommand*)command {
|
|
42
|
+
// Declarations first
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
@try {
|
|
46
|
+
[self.commandDelegate runInBackground:^{
|
|
47
|
+
@try {
|
|
48
|
+
// --- parse input
|
|
49
|
+
NSDictionary *p = (command.arguments.count > 0 && [command.arguments[0] isKindOfClass:[NSDictionary class]]) ? command.arguments[0] : @{};
|
|
50
|
+
NSString *kind = p[@"configType"] ?: @"controller";
|
|
51
|
+
NSString *identifier = p[@"id"] ?: @"";
|
|
52
|
+
NSString *clientId = p[@"clientId"] ?: @"";
|
|
53
|
+
NSString *countryCode = p[@"countryCode"] ?: @"";
|
|
54
|
+
NSString *clientGroup = p[@"clientGroup"] ?: @"";
|
|
55
|
+
NSString *vertical = p[@"vertical"] ?: @"";
|
|
56
|
+
NSString *solution = p[@"solution"] ?: @"";
|
|
57
|
+
NSString *scope = p[@"scope"] ?: kind;
|
|
58
|
+
NSString *transNo = p[@"transNo"] ?: @"";
|
|
59
|
+
NSString *rootPrefix = p[@"root"] ?: @"";
|
|
60
|
+
NSString *localeId = p[@"localeId"] ?: @"";
|
|
61
|
+
|
|
62
|
+
// --- base dir
|
|
63
|
+
NSFileManager *fm = [NSFileManager defaultManager];
|
|
64
|
+
NSURL *baseDir = [[fm URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] firstObject];
|
|
65
|
+
if (!baseDir) baseDir = [[fm URLsForDirectory:NSLibraryDirectory inDomains:NSUserDomainMask] firstObject];
|
|
66
|
+
|
|
67
|
+
// --- roots
|
|
68
|
+
NSArray<NSURL *> *roots = [self buildRootsWithBase:baseDir
|
|
69
|
+
rootPrefix:rootPrefix
|
|
70
|
+
clientGroup:clientGroup
|
|
71
|
+
clientId:clientId
|
|
72
|
+
countryCode:countryCode];
|
|
73
|
+
|
|
74
|
+
// --- keys (label is locale-aware)
|
|
75
|
+
NSMutableArray<NSString *> *keys = [NSMutableArray array];
|
|
76
|
+
if ([kind isEqualToString:@"label"] && localeId.length > 0) {
|
|
77
|
+
if (clientId.length && countryCode.length) [keys addObject:[NSString stringWithFormat:@"%@_%@_%@_%@", identifier, clientId, countryCode, localeId]];
|
|
78
|
+
if (clientId.length) [keys addObject:[NSString stringWithFormat:@"%@_%@_%@", identifier, clientId, localeId]];
|
|
79
|
+
if (clientGroup.length) [keys addObject:[NSString stringWithFormat:@"%@_%@_%@", identifier, clientGroup, localeId]];
|
|
80
|
+
if (vertical.length) [keys addObject:[NSString stringWithFormat:@"%@_%@_%@", identifier, vertical, localeId]];
|
|
81
|
+
if (solution.length) [keys addObject:[NSString stringWithFormat:@"%@_%@_%@", identifier, solution, localeId]];
|
|
82
|
+
[keys addObject:[NSString stringWithFormat:@"%@_%@", identifier, localeId]];
|
|
83
|
+
} else {
|
|
84
|
+
if (clientId.length && countryCode.length) [keys addObject:[NSString stringWithFormat:@"%@_%@_%@", identifier, clientId, countryCode]];
|
|
85
|
+
if (clientId.length) [keys addObject:[NSString stringWithFormat:@"%@_%@", identifier, clientId]];
|
|
86
|
+
if (clientGroup.length) [keys addObject:[NSString stringWithFormat:@"%@_%@", identifier, clientGroup]];
|
|
87
|
+
if (vertical.length) [keys addObject:[NSString stringWithFormat:@"%@_%@", identifier, vertical]];
|
|
88
|
+
if (solution.length) [keys addObject:[NSString stringWithFormat:@"%@_%@", identifier, solution]];
|
|
89
|
+
[keys addObject:identifier ?: @""];
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// --- scopes
|
|
93
|
+
NSMutableArray<NSString *> *scopesToTry = [NSMutableArray array];
|
|
94
|
+
if ([scope isEqualToString:@"containR"]) {
|
|
95
|
+
[scopesToTry addObject:@"containR"];
|
|
96
|
+
[scopesToTry addObject:kind];
|
|
97
|
+
} else {
|
|
98
|
+
[scopesToTry addObject:kind];
|
|
99
|
+
[scopesToTry addObject:@"containR"];
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// --- search
|
|
103
|
+
BOOL found = NO;
|
|
104
|
+
NSString *resolvedKey = nil; NSString *usedExt = nil; NSString *absPath = nil; NSString *content = nil;
|
|
105
|
+
|
|
106
|
+
for (NSString *key in keys) {
|
|
107
|
+
for (NSString *sc in scopesToTry) {
|
|
108
|
+
ResolveResult *rr = [self resolveGenericFileWithRoots:roots
|
|
109
|
+
scope:sc
|
|
110
|
+
kind:kind
|
|
111
|
+
id:identifier
|
|
112
|
+
transNo:transNo
|
|
113
|
+
key:key];
|
|
114
|
+
if (rr && rr.fileURL) {
|
|
115
|
+
NSString *tryPath = rr.fileURL.path;
|
|
116
|
+
NSLog(@"mInterface: Trying: %@", tryPath);
|
|
117
|
+
BOOL isDir = NO;
|
|
118
|
+
if ([fm fileExistsAtPath:tryPath isDirectory:&isDir] && !isDir) {
|
|
119
|
+
NSError *readErr = nil;
|
|
120
|
+
NSString *txt = [NSString stringWithContentsOfURL:rr.fileURL
|
|
121
|
+
encoding:NSUTF8StringEncoding
|
|
122
|
+
error:&readErr];
|
|
123
|
+
if (!readErr && txt != nil) {
|
|
124
|
+
content = txt;
|
|
125
|
+
resolvedKey = key;
|
|
126
|
+
usedExt = rr.ext ?: @"";
|
|
127
|
+
absPath = tryPath;
|
|
128
|
+
found = YES;
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (found) break;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// --- respond
|
|
138
|
+
if (found) {
|
|
139
|
+
NSDictionary *payload = @{
|
|
140
|
+
@"configType": kind ?: @"",
|
|
141
|
+
@"srcKey": resolvedKey ?: @"",
|
|
142
|
+
@"ext": usedExt ?: @"",
|
|
143
|
+
@"path": absPath ?: @"",
|
|
144
|
+
@"content": content ?: @""
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
NSError *jsonError = nil; // declare inside the block
|
|
148
|
+
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:payload
|
|
149
|
+
options:0
|
|
150
|
+
error:&jsonError];
|
|
151
|
+
NSString *jsonStr = [[NSString alloc] initWithData:jsonData
|
|
152
|
+
encoding:NSUTF8StringEncoding];
|
|
153
|
+
|
|
154
|
+
CDVPluginResult *ok = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
|
|
155
|
+
messageAsString:jsonStr ?: @"{}"];
|
|
156
|
+
[self.commandDelegate sendPluginResult:ok callbackId:command.callbackId];
|
|
157
|
+
} else {
|
|
158
|
+
CDVPluginResult *errRes = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR
|
|
159
|
+
messageAsString:@"NOT_FOUND"];
|
|
160
|
+
[self.commandDelegate sendPluginResult:errRes callbackId:command.callbackId];
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
} @catch (NSException *ex) {
|
|
164
|
+
CDVPluginResult *errRes = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:[NSString stringWithFormat:@"GetConfigCascade failed: %@", ex.reason ?: @""]];
|
|
165
|
+
[self.commandDelegate sendPluginResult:errRes callbackId:command.callbackId];
|
|
166
|
+
}
|
|
167
|
+
}];
|
|
168
|
+
} @catch (NSException *exOuter) {
|
|
169
|
+
CDVPluginResult *errRes = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:[NSString stringWithFormat:@"GetConfigCascade failed: %@", exOuter.reason ?: @""]];
|
|
170
|
+
[self.commandDelegate sendPluginResult:errRes callbackId:command.callbackId];
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
#pragma mark - Helpers
|
|
175
|
+
|
|
176
|
+
- (NSArray<NSURL*> *)buildRootsWithBase:(NSURL *)baseDir
|
|
177
|
+
rootPrefix:(NSString *)rootPrefix
|
|
178
|
+
clientGroup:(NSString *)clientGroup
|
|
179
|
+
clientId:(NSString *)clientId
|
|
180
|
+
countryCode:(NSString *)countryCode {
|
|
181
|
+
NSMutableArray<NSURL*> *roots = [NSMutableArray array];
|
|
182
|
+
NSMutableSet<NSString*> *seen = [NSMutableSet set];
|
|
183
|
+
|
|
184
|
+
void (^addIfUnique)(NSURL *) = ^(NSURL *u){
|
|
185
|
+
if (!u) return;
|
|
186
|
+
NSString *p = u.path;
|
|
187
|
+
if (p.length && ![seen containsObject:p]) { [roots addObject:u]; [seen addObject:p]; }
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
@try {
|
|
191
|
+
NSURL *r1 = [[[baseDir URLByAppendingPathComponent:rootPrefix isDirectory:YES]
|
|
192
|
+
URLByAppendingPathComponent:clientId isDirectory:YES]
|
|
193
|
+
URLByAppendingPathComponent:countryCode isDirectory:YES];
|
|
194
|
+
addIfUnique(r1);
|
|
195
|
+
|
|
196
|
+
NSURL *r2 = [[[[baseDir URLByAppendingPathComponent:rootPrefix isDirectory:YES]
|
|
197
|
+
URLByAppendingPathComponent:clientId isDirectory:YES]
|
|
198
|
+
URLByAppendingPathComponent:clientId isDirectory:YES]
|
|
199
|
+
URLByAppendingPathComponent:countryCode isDirectory:YES];
|
|
200
|
+
addIfUnique(r2);
|
|
201
|
+
|
|
202
|
+
if (clientGroup.length) {
|
|
203
|
+
NSURL *r3 = [[[[baseDir URLByAppendingPathComponent:rootPrefix isDirectory:YES]
|
|
204
|
+
URLByAppendingPathComponent:clientGroup isDirectory:YES]
|
|
205
|
+
URLByAppendingPathComponent:clientId isDirectory:YES]
|
|
206
|
+
URLByAppendingPathComponent:countryCode isDirectory:YES];
|
|
207
|
+
addIfUnique(r3);
|
|
208
|
+
}
|
|
209
|
+
} @catch (__unused NSException *e) {}
|
|
210
|
+
return roots;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
- (NSString *)prefixForKind:(NSString *)kind {
|
|
214
|
+
if ([kind isEqualToString:@"controller"]) return @"controller_";
|
|
215
|
+
if ([kind isEqualToString:@"label"]) return @"label_";
|
|
216
|
+
if ([kind isEqualToString:@"rule"]) return @"rule_";
|
|
217
|
+
if ([kind isEqualToString:@"template"]) return @"template_";
|
|
218
|
+
if ([kind isEqualToString:@"ui"]) return @"ui_";
|
|
219
|
+
return [kind stringByAppendingString:@"_"];
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
- (NSArray<NSString*> *)extensionsForKind:(NSString *)kind {
|
|
223
|
+
if ([kind isEqualToString:@"controller"]) return @[ @"json" ];
|
|
224
|
+
if ([kind isEqualToString:@"label"]) return @[ @"json", @"txt" ];
|
|
225
|
+
if ([kind isEqualToString:@"rule"]) return @[ @"txt", @"json" ];
|
|
226
|
+
if ([kind isEqualToString:@"template"]) return @[ @"html", @"json" ];
|
|
227
|
+
if ([kind isEqualToString:@"ui"]) return @[ @"html", @"json" ];
|
|
228
|
+
return @[ @"json" ];
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
- (ResolveResult *)resolveGenericFileWithRoots:(NSArray<NSURL*> *)roots
|
|
232
|
+
scope:(NSString *)scope
|
|
233
|
+
kind:(NSString *)kind
|
|
234
|
+
id:(NSString *)identifier
|
|
235
|
+
transNo:(NSString *)transNo
|
|
236
|
+
key:(NSString *)key {
|
|
237
|
+
NSArray<NSString*> *exts = [self extensionsForKind:kind];
|
|
238
|
+
NSString *prefix = [self prefixForKind:kind];
|
|
239
|
+
|
|
240
|
+
NSArray<NSString*> *nameVariants = [kind isEqualToString:@"label"]
|
|
241
|
+
? @[ [prefix stringByAppendingString:key], key ]
|
|
242
|
+
: @[ [prefix stringByAppendingString:key] ];
|
|
243
|
+
|
|
244
|
+
NSFileManager *fm = [NSFileManager defaultManager];
|
|
245
|
+
|
|
246
|
+
@try {
|
|
247
|
+
for (NSURL *root in roots) {
|
|
248
|
+
if (!root) continue;
|
|
249
|
+
|
|
250
|
+
for (NSString *ext in exts) {
|
|
251
|
+
|
|
252
|
+
if ([scope isEqualToString:@"containR"]) {
|
|
253
|
+
NSURL *containRDir = [root URLByAppendingPathComponent:@"containR" isDirectory:YES];
|
|
254
|
+
NSURL *screenDir = [containRDir URLByAppendingPathComponent:identifier isDirectory:YES];
|
|
255
|
+
|
|
256
|
+
if (transNo.length) {
|
|
257
|
+
NSURL *transDir = [screenDir URLByAppendingPathComponent:transNo isDirectory:YES];
|
|
258
|
+
|
|
259
|
+
if ([kind isEqualToString:@"label"]) {
|
|
260
|
+
NSURL *labelDir = [transDir URLByAppendingPathComponent:@"label" isDirectory:YES];
|
|
261
|
+
NSURL *labelsDir = [transDir URLByAppendingPathComponent:@"labels" isDirectory:YES];
|
|
262
|
+
|
|
263
|
+
for (NSString *nv in nameVariants) {
|
|
264
|
+
NSArray<NSURL*> *cands = @[
|
|
265
|
+
[labelDir URLByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", nv, ext]],
|
|
266
|
+
[labelsDir URLByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", nv, ext]],
|
|
267
|
+
[transDir URLByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", nv, ext]]
|
|
268
|
+
];
|
|
269
|
+
for (NSURL *u in cands) {
|
|
270
|
+
if ([fm fileExistsAtPath:u.path isDirectory:NULL]) {
|
|
271
|
+
ResolveResult *rr = [ResolveResult new]; rr.fileURL = u; rr.ext = ext; return rr;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
} else {
|
|
276
|
+
NSURL *typeDir = [transDir URLByAppendingPathComponent:kind isDirectory:YES];
|
|
277
|
+
NSURL *f1 = [typeDir URLByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", [prefix stringByAppendingString:key], ext]];
|
|
278
|
+
NSURL *f2 = [transDir URLByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", [prefix stringByAppendingString:key], ext]];
|
|
279
|
+
if ([fm fileExistsAtPath:f1.path isDirectory:NULL]) { ResolveResult *rr=[ResolveResult new]; rr.fileURL=f1; rr.ext=ext; return rr; }
|
|
280
|
+
if ([fm fileExistsAtPath:f2.path isDirectory:NULL]) { ResolveResult *rr=[ResolveResult new]; rr.fileURL=f2; rr.ext=ext; return rr; }
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
if ([kind isEqualToString:@"label"]) {
|
|
285
|
+
NSURL *labelDirNT = [screenDir URLByAppendingPathComponent:@"label" isDirectory:YES];
|
|
286
|
+
NSURL *labelsDirNT = [screenDir URLByAppendingPathComponent:@"labels" isDirectory:YES];
|
|
287
|
+
for (NSString *nv in nameVariants) {
|
|
288
|
+
NSArray<NSURL*> *cands = @[
|
|
289
|
+
[labelDirNT URLByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", nv, ext]],
|
|
290
|
+
[labelsDirNT URLByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", nv, ext]],
|
|
291
|
+
[screenDir URLByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", nv, ext]]
|
|
292
|
+
];
|
|
293
|
+
for (NSURL *u in cands) {
|
|
294
|
+
if ([fm fileExistsAtPath:u.path isDirectory:NULL]) {
|
|
295
|
+
ResolveResult *rr = [ResolveResult new]; rr.fileURL = u; rr.ext = ext; return rr;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
} else {
|
|
300
|
+
NSURL *typeDirNT = [screenDir URLByAppendingPathComponent:kind isDirectory:YES];
|
|
301
|
+
NSURL *f1 = [typeDirNT URLByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", [prefix stringByAppendingString:key], ext]];
|
|
302
|
+
NSURL *f2 = [screenDir URLByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", [prefix stringByAppendingString:key], ext]];
|
|
303
|
+
if ([fm fileExistsAtPath:f1.path isDirectory:NULL]) { ResolveResult *rr=[ResolveResult new]; rr.fileURL=f1; rr.ext=ext; return rr; }
|
|
304
|
+
if ([fm fileExistsAtPath:f2.path isDirectory:NULL]) { ResolveResult *rr=[ResolveResult new]; rr.fileURL=f2; rr.ext=ext; return rr; }
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
} else {
|
|
308
|
+
NSURL *cfg = [root URLByAppendingPathComponent:@"configuration_package" isDirectory:YES];
|
|
309
|
+
|
|
310
|
+
if ([kind isEqualToString:@"label"]) {
|
|
311
|
+
NSURL *labelDir = [cfg URLByAppendingPathComponent:@"label" isDirectory:YES];
|
|
312
|
+
NSURL *labelsDir = [cfg URLByAppendingPathComponent:@"labels" isDirectory:YES];
|
|
313
|
+
|
|
314
|
+
for (NSString *nv in nameVariants) {
|
|
315
|
+
NSArray<NSURL*> *cands1 = @[
|
|
316
|
+
[labelDir URLByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", nv, ext]],
|
|
317
|
+
[labelsDir URLByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", nv, ext]]
|
|
318
|
+
];
|
|
319
|
+
for (NSURL *u in cands1) {
|
|
320
|
+
if ([fm fileExistsAtPath:u.path isDirectory:NULL]) { ResolveResult *rr=[ResolveResult new]; rr.fileURL=u; rr.ext=ext; return rr; }
|
|
321
|
+
}
|
|
322
|
+
NSArray<NSURL*> *cands2 = @[
|
|
323
|
+
[[labelDir URLByAppendingPathComponent:identifier isDirectory:YES] URLByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", nv, ext]],
|
|
324
|
+
[[labelsDir URLByAppendingPathComponent:identifier isDirectory:YES] URLByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", nv, ext]]
|
|
325
|
+
];
|
|
326
|
+
for (NSURL *u in cands2) {
|
|
327
|
+
if ([fm fileExistsAtPath:u.path isDirectory:NULL]) { ResolveResult *rr=[ResolveResult new]; rr.fileURL=u; rr.ext=ext; return rr; }
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
NSURL *cfg2 = [root URLByAppendingPathComponent:@"configuration" isDirectory:YES];
|
|
332
|
+
NSURL *label2 = [cfg2 URLByAppendingPathComponent:@"label" isDirectory:YES];
|
|
333
|
+
NSURL *labels2 = [cfg2 URLByAppendingPathComponent:@"labels" isDirectory:YES];
|
|
334
|
+
for (NSString *nv in nameVariants) {
|
|
335
|
+
NSArray<NSURL*> *cands3 = @[
|
|
336
|
+
[label2 URLByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", nv, ext]],
|
|
337
|
+
[labels2 URLByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", nv, ext]],
|
|
338
|
+
[[label2 URLByAppendingPathComponent:identifier isDirectory:YES] URLByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", nv, ext]],
|
|
339
|
+
[[labels2 URLByAppendingPathComponent:identifier isDirectory:YES] URLByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", nv, ext]]
|
|
340
|
+
];
|
|
341
|
+
for (NSURL *u in cands3) {
|
|
342
|
+
if ([fm fileExistsAtPath:u.path isDirectory:NULL]) { ResolveResult *rr=[ResolveResult new]; rr.fileURL=u; rr.ext=ext; return rr; }
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
} else {
|
|
347
|
+
NSURL *typeDir = [cfg URLByAppendingPathComponent:kind isDirectory:YES];
|
|
348
|
+
NSURL *f1 = [typeDir URLByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", [prefix stringByAppendingString:key], ext]];
|
|
349
|
+
NSURL *f2 = [[typeDir URLByAppendingPathComponent:identifier isDirectory:YES] URLByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", [prefix stringByAppendingString:key], ext]];
|
|
350
|
+
if ([fm fileExistsAtPath:f1.path isDirectory:NULL]) { ResolveResult *rr=[ResolveResult new]; rr.fileURL=f1; rr.ext=ext; return rr; }
|
|
351
|
+
if ([fm fileExistsAtPath:f2.path isDirectory:NULL]) { ResolveResult *rr=[ResolveResult new]; rr.fileURL=f2; rr.ext=ext; return rr; }
|
|
352
|
+
|
|
353
|
+
NSURL *cfg2 = [root URLByAppendingPathComponent:@"configuration" isDirectory:YES];
|
|
354
|
+
NSURL *type2 = [cfg2 URLByAppendingPathComponent:kind isDirectory:YES];
|
|
355
|
+
NSURL *f3 = [type2 URLByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", [prefix stringByAppendingString:key], ext]];
|
|
356
|
+
NSURL *f4 = [[type2 URLByAppendingPathComponent:identifier isDirectory:YES] URLByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", [prefix stringByAppendingString:key], ext]];
|
|
357
|
+
if ([fm fileExistsAtPath:f3.path isDirectory:NULL]) { ResolveResult *rr=[ResolveResult new]; rr.fileURL=f3; rr.ext=ext; return rr; }
|
|
358
|
+
if ([fm fileExistsAtPath:f4.path isDirectory:NULL]) { ResolveResult *rr=[ResolveResult new]; rr.fileURL=f4; rr.ext=ext; return rr; }
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
} @catch (__unused NSException *e) {}
|
|
364
|
+
return nil;
|
|
365
|
+
}
|
|
366
|
+
|
|
32
367
|
|
|
33
368
|
// Inside the @implementation block
|
|
34
369
|
- (void)ScanBarCode:(CDVInvokedUrlCommand*)command {
|