cordova-plugin-mserviceinterface-2.0 1.0.21 → 1.0.25

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.
Files changed (59) hide show
  1. package/package.json +28 -28
  2. package/plugin.xml +153 -153
  3. package/src/android/CallbackProgressDialog.java +53 -53
  4. package/src/android/FileProvider.java +7 -7
  5. package/src/android/backgroundNotification.java +120 -120
  6. package/src/android/doubleogradle.gradle +5 -5
  7. package/src/android/mInterface.java +2087 -2066
  8. package/src/android/mInterfaceReceiver.java +59 -59
  9. package/src/android/mInterfaceService.java +749 -749
  10. package/src/android/mInterfaceUtil.java +1686 -1688
  11. package/src/android/res/xml/network_security_config.xml +8 -8
  12. package/src/android/res/xml/opener_paths.xml +16 -16
  13. package/src/ios/InternetConnection.h +64 -64
  14. package/src/ios/InternetConnection.m +242 -242
  15. package/src/ios/SSZipArchive.h +146 -146
  16. package/src/ios/SSZipArchive.m +1180 -1180
  17. package/src/ios/SSZipCommon.h +66 -66
  18. package/src/ios/UICKeyChainStore.h +64 -64
  19. package/src/ios/UICKeyChainStore.m +434 -434
  20. package/src/ios/XMLConverter.h +61 -61
  21. package/src/ios/XMLConverter.m +243 -243
  22. package/src/ios/ZipArchive.h +19 -19
  23. package/src/ios/aes/aes.h +270 -270
  24. package/src/ios/aes/aes_ni.c +687 -687
  25. package/src/ios/aes/aes_ni.h +59 -59
  26. package/src/ios/aes/aescrypt.c +301 -301
  27. package/src/ios/aes/aeskey.c +554 -554
  28. package/src/ios/aes/aesopt.h +776 -776
  29. package/src/ios/aes/aestab.c +418 -418
  30. package/src/ios/aes/aestab.h +173 -173
  31. package/src/ios/aes/brg_endian.h +127 -127
  32. package/src/ios/aes/brg_types.h +191 -191
  33. package/src/ios/aes/fileenc.c +145 -145
  34. package/src/ios/aes/fileenc.h +121 -121
  35. package/src/ios/aes/hmac.c +209 -209
  36. package/src/ios/aes/hmac.h +119 -119
  37. package/src/ios/aes/prng.c +155 -155
  38. package/src/ios/aes/prng.h +82 -82
  39. package/src/ios/aes/pwd2key.c +181 -181
  40. package/src/ios/aes/pwd2key.h +45 -45
  41. package/src/ios/aes/sha1.c +283 -283
  42. package/src/ios/aes/sha1.h +72 -72
  43. package/src/ios/mInterface.h +2 -0
  44. package/src/ios/mInterface.m +18 -1
  45. package/src/ios/minizip/crypt.c +146 -146
  46. package/src/ios/minizip/crypt.h +66 -66
  47. package/src/ios/minizip/ioapi.c +353 -353
  48. package/src/ios/minizip/ioapi.h +154 -154
  49. package/src/ios/minizip/ioapi_buf.c +452 -452
  50. package/src/ios/minizip/ioapi_buf.h +52 -52
  51. package/src/ios/minizip/ioapi_mem.c +167 -167
  52. package/src/ios/minizip/ioapi_mem.h +52 -52
  53. package/src/ios/minizip/minishared.c +292 -292
  54. package/src/ios/minizip/minishared.h +50 -50
  55. package/src/ios/minizip/unzip.c +2007 -2007
  56. package/src/ios/minizip/unzip.h +254 -254
  57. package/src/ios/minizip/zip.c +2007 -2007
  58. package/src/ios/minizip/zip.h +215 -215
  59. package/www/mInterface.js +3 -3
@@ -1,61 +1,61 @@
1
- /**
2
- * @class XMLConverter XMLConverter.h "XMLConverter.h"
3
- * @brief XMLConverter
4
- * @details XMLConverter.h in XMLConverter
5
- * @date 10/8/13
6
- * @copyright Copyright (c) 2013 Ruslan Soldatenko. All rights reserved.
7
- */
8
-
9
- #import <Foundation/Foundation.h>
10
-
11
- @interface XMLConverter : NSObject
12
-
13
- /**
14
- * The block called when XML-data convert finished
15
- * @param[in] success YES - when XML-data convert successful, otherwise - NO.
16
- * @param[in] dictionary Contains convert XML-data when success, otherwise - nil.
17
- * @param[in] error Contains error of processing XML-data if exist, otherwise - nil.
18
- */
19
- typedef void (^OutputBlock)(BOOL success, NSMutableDictionary *dictionary, NSError *error);
20
-
21
- /**
22
- *Convert XML data containing in input NSString object .
23
- *@param[in] string Contains an NSString object with XML-data in the string format.
24
- *@param[in] completion A block of code will be executed when the processing of XML-data is completed.
25
- *This parameter must not be NULL.
26
- */
27
- + (void)convertXMLString:(NSString *)string completion:(OutputBlock)completion;
28
-
29
- /**
30
- *Convert XML data containing in input file.
31
- *@param[in] filePath Contains an NSString object with absolute path to file with XML-data.
32
- *@param[in] completion A block of code will be executed when the processing of XML-data is completed.
33
- *This parameter must not be NULL.
34
- */
35
- + (void)convertXMLFile:(NSString *)filePath completion:(OutputBlock)completion;
36
-
37
- /**
38
- *Convert XML data containing in input NSData object.
39
- *@param[in] data Contains NSData object with encapsulated XML contents.
40
- *@param[in] completion A block of code will be executed when the processing of XML-data is completed.
41
- *This parameter must not be NULL.
42
- */
43
- + (void)convertXMLData:(NSData *)data completion:(OutputBlock)completion;
44
-
45
- /**
46
- *Convert XML content referenced by the given URL.
47
- *@param[in] url Contains an NSURL object specifying a URL.
48
- *@param[in] completion A block of code will be executed when the processing of XML-data is completed.
49
- *This parameter must not be NULL.
50
- */
51
- + (void)convertXMLURL:(NSURL *)url completion:(OutputBlock)completion;
52
-
53
- /**
54
- *Convert XML content from the specified stream.
55
- *@param[in] stream Contains the specified input stream in NSInputStream object.
56
- *@param[in] completion A block of code will be executed when the processing of XML-data is completed.
57
- *This parameter must not be NULL.
58
- */
59
- + (void)convertXMLStream:(NSInputStream *)stream completion:(OutputBlock)completion;
60
-
61
- @end
1
+ /**
2
+ * @class XMLConverter XMLConverter.h "XMLConverter.h"
3
+ * @brief XMLConverter
4
+ * @details XMLConverter.h in XMLConverter
5
+ * @date 10/8/13
6
+ * @copyright Copyright (c) 2013 Ruslan Soldatenko. All rights reserved.
7
+ */
8
+
9
+ #import <Foundation/Foundation.h>
10
+
11
+ @interface XMLConverter : NSObject
12
+
13
+ /**
14
+ * The block called when XML-data convert finished
15
+ * @param[in] success YES - when XML-data convert successful, otherwise - NO.
16
+ * @param[in] dictionary Contains convert XML-data when success, otherwise - nil.
17
+ * @param[in] error Contains error of processing XML-data if exist, otherwise - nil.
18
+ */
19
+ typedef void (^OutputBlock)(BOOL success, NSMutableDictionary *dictionary, NSError *error);
20
+
21
+ /**
22
+ *Convert XML data containing in input NSString object .
23
+ *@param[in] string Contains an NSString object with XML-data in the string format.
24
+ *@param[in] completion A block of code will be executed when the processing of XML-data is completed.
25
+ *This parameter must not be NULL.
26
+ */
27
+ + (void)convertXMLString:(NSString *)string completion:(OutputBlock)completion;
28
+
29
+ /**
30
+ *Convert XML data containing in input file.
31
+ *@param[in] filePath Contains an NSString object with absolute path to file with XML-data.
32
+ *@param[in] completion A block of code will be executed when the processing of XML-data is completed.
33
+ *This parameter must not be NULL.
34
+ */
35
+ + (void)convertXMLFile:(NSString *)filePath completion:(OutputBlock)completion;
36
+
37
+ /**
38
+ *Convert XML data containing in input NSData object.
39
+ *@param[in] data Contains NSData object with encapsulated XML contents.
40
+ *@param[in] completion A block of code will be executed when the processing of XML-data is completed.
41
+ *This parameter must not be NULL.
42
+ */
43
+ + (void)convertXMLData:(NSData *)data completion:(OutputBlock)completion;
44
+
45
+ /**
46
+ *Convert XML content referenced by the given URL.
47
+ *@param[in] url Contains an NSURL object specifying a URL.
48
+ *@param[in] completion A block of code will be executed when the processing of XML-data is completed.
49
+ *This parameter must not be NULL.
50
+ */
51
+ + (void)convertXMLURL:(NSURL *)url completion:(OutputBlock)completion;
52
+
53
+ /**
54
+ *Convert XML content from the specified stream.
55
+ *@param[in] stream Contains the specified input stream in NSInputStream object.
56
+ *@param[in] completion A block of code will be executed when the processing of XML-data is completed.
57
+ *This parameter must not be NULL.
58
+ */
59
+ + (void)convertXMLStream:(NSInputStream *)stream completion:(OutputBlock)completion;
60
+
61
+ @end
@@ -1,243 +1,243 @@
1
- /**
2
- * @class XMLConverter XMLConverter.m "XMLConverter.m"
3
- * @brief XMLConverter
4
- * @details XMLConverter.m in XMLConverter
5
- * @date 10/8/13
6
- * @copyright Copyright (c) 2013 Ruslan Soldatenko. All rights reserved.
7
- */
8
-
9
- #import "XMLConverter.h"
10
-
11
- #define TEXT_NODE_KEY @"#text"
12
- #define ATTRIBUTE_PREFIX @"-"
13
- #define AXIS_PARENT _axisAncestorOrSelf[_currentLevel - 1]
14
- #define AXIS_PRECEDING_SIBLING _axisAncestorOrSelf[_currentLevel - 1][elementName]
15
- #define AXIS_SELF _axisAncestorOrSelf[_currentLevel]
16
-
17
- @interface XMLConverter () <NSXMLParserDelegate>
18
-
19
- @property (strong, nonatomic) NSMutableArray *axisAncestorOrSelf;
20
- @property (strong, nonatomic) NSMutableString *selfText;
21
- @property (strong, nonatomic) NSMutableDictionary *root;
22
- @property (assign, nonatomic) NSError *error;
23
- @property (assign, nonatomic) NSInteger currentLevel;
24
-
25
- @end
26
-
27
- @implementation XMLConverter
28
-
29
- #pragma mark - Main Public Methods
30
-
31
- + (void)convertXMLData:(NSData *)data completion:(OutputBlock)completion
32
- {
33
- ///Wrapper for -initWithData: method of NSXMLParser
34
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
35
- NSXMLParser *parser = [[NSXMLParser alloc] initWithData:data];
36
- [[XMLConverter new] parser:parser completion:completion];
37
- });
38
- }
39
-
40
- + (void)convertXMLURL:(NSURL *)url completion:(OutputBlock)completion
41
- {
42
- ///Wrapper for -initWithContentsOfURL: method of NSXMLParser
43
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
44
- NSXMLParser *parser = [[NSXMLParser alloc] initWithContentsOfURL:url];
45
- [[XMLConverter new] parser:parser completion:completion];
46
- });
47
- }
48
-
49
- + (void)convertXMLStream:(NSInputStream *)stream completion:(OutputBlock)completion
50
- {
51
- ///Wrapper for -initWithStream: method of NSXMLParser
52
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
53
- NSXMLParser *parser = [[NSXMLParser alloc] initWithStream:stream];
54
- [[XMLConverter new] parser:parser completion:completion];
55
- });
56
- }
57
-
58
- #pragma mark - Additional Public Methods
59
-
60
- + (void)convertXMLString:(NSString *)string completion:(OutputBlock)completion
61
- {
62
- //Convert input string to NSData.
63
- NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding];
64
- //Use class method for NSData.
65
- [self convertXMLData:data completion:completion];
66
- }
67
-
68
- + (void)convertXMLFile:(NSString *)filePath completion:(OutputBlock)completion
69
- {
70
- //Convert input file to NSData
71
- NSData* data = [NSData dataWithContentsOfFile:filePath];
72
- //Use class method for NSData.
73
- [self convertXMLData:data completion:completion];
74
- }
75
-
76
- #pragma mark - Internal methods
77
-
78
- - (void)parser:(NSXMLParser *)parser completion:(OutputBlock)completion
79
- {
80
- ///Completion of the parser to work and run the parser.
81
- [parser setDelegate: self];
82
- //Start parsing
83
- BOOL success = [parser parse];
84
- //execute output block with results of parsing as synchronous
85
- dispatch_sync(dispatch_get_main_queue(), ^{
86
- completion(success, _root, _error);
87
- });
88
- }
89
-
90
- - (void)dealloc
91
- {
92
- ///Clear out all objects
93
- [_axisAncestorOrSelf removeAllObjects];
94
- _axisAncestorOrSelf = nil;
95
- _selfText = nil;
96
- _root = nil;
97
- }
98
-
99
- #pragma mark - NSXMLParserDelegate Handling XML
100
-
101
- - (void)parserDidStartDocument:(NSXMLParser *)parser
102
- {
103
- ///Initialize internal objects and values
104
- //Set counter for current level to root element level.
105
- _currentLevel = 0;
106
- //Create storage for parsing elements.
107
- _axisAncestorOrSelf = [NSMutableArray new];
108
- //Create object for result of parsing - the root object
109
- _root = [NSMutableDictionary new];
110
- //Put in the array as first the root object.
111
- [_axisAncestorOrSelf addObject:_root];
112
- //Create object for storing current element text value.
113
- _selfText = [NSMutableString new];
114
- }
115
-
116
- - (void)parserDidEndDocument:(NSXMLParser *)parser
117
- {
118
- ///Clear unused object
119
- [_axisAncestorOrSelf removeLastObject];
120
- }
121
-
122
- - (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict
123
- {
124
- ///Start processing of the current element
125
- _currentLevel++;
126
- if ([_axisAncestorOrSelf count] == _currentLevel)
127
- {
128
- //Add dictionary for started element if it not exist.
129
- [_axisAncestorOrSelf addObject:[NSMutableDictionary new]];
130
- //Processing a text value (if it exist) of the previous (parent) element.
131
- if ([_selfText length] > 0)
132
- {
133
- [AXIS_PARENT setObject:_selfText forKey:TEXT_NODE_KEY];
134
- _selfText = [NSMutableString new];
135
- }
136
- }
137
- //Add attribute values (if it exist) to current element.
138
- if ([attributeDict count] != 0)
139
- {
140
- for (id key in [attributeDict allKeys])
141
- {
142
- NSString *attributeKey = [NSString stringWithFormat:@"%@%@", ATTRIBUTE_PREFIX, key];
143
- [AXIS_SELF setObject:attributeDict[key] forKey:attributeKey];
144
- }
145
- }
146
- }
147
-
148
- - (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
149
- {
150
- ///Processing the text value of the current element
151
- NSCharacterSet *characterSet = [NSCharacterSet whitespaceAndNewlineCharacterSet];
152
- NSString *text = [string stringByTrimmingCharactersInSet: characterSet];
153
- [_selfText appendString:text];
154
- }
155
-
156
- - (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
157
- {
158
- ///Completion processing of the current element
159
- if ([AXIS_SELF count] == 0)
160
- {
161
- if (AXIS_PARENT[elementName])
162
- {
163
- if ([AXIS_PARENT[elementName] isKindOfClass:[NSMutableArray class]])
164
- {
165
- //If exist collection of preceding-sibling elements - add current element to collection.
166
- [AXIS_PARENT[elementName] addObject:_selfText];
167
- }
168
- else
169
- {
170
- /*
171
- If exist only one preceding-sibling element - create collection
172
- and add both (preceding-sibling and current) elements to collection.
173
- */
174
- NSMutableArray *elementsArray = [NSMutableArray new];
175
- [elementsArray addObjectsFromArray:@[AXIS_PRECEDING_SIBLING, _selfText]];
176
- [AXIS_PARENT setObject:elementsArray forKey:elementName];
177
- }
178
- }
179
- else
180
- {
181
- //If exist only text value of element - set it as element value.
182
- [AXIS_PARENT setObject:_selfText forKey:elementName];
183
- }
184
- _selfText = [NSMutableString new];
185
- }
186
- else
187
- {
188
- if ([_selfText length] > 0)
189
- {
190
- //If exist text value of element and child elements - set it as child element value.
191
- [AXIS_SELF setObject:_selfText forKey:TEXT_NODE_KEY];
192
- _selfText = [NSMutableString new];
193
- }
194
- if (AXIS_PRECEDING_SIBLING)
195
- {
196
- if ([AXIS_PRECEDING_SIBLING isKindOfClass:[NSMutableArray class]])
197
- {
198
- //If exist collection of preceding-sibling elements - add current element to collection.
199
- [AXIS_PRECEDING_SIBLING addObject:AXIS_SELF];
200
- }
201
- else if ([AXIS_PRECEDING_SIBLING isKindOfClass:[NSMutableDictionary class]])
202
- {
203
- /*
204
- If exist only one preceding-sibling element - create collection
205
- and add both (preceding-sibling and current) elements to collection.
206
- */
207
- NSMutableArray *elementsArray = [NSMutableArray new];
208
- [elementsArray addObjectsFromArray:@[AXIS_PRECEDING_SIBLING, AXIS_SELF]];
209
- [AXIS_PARENT setObject:elementsArray forKey:elementName];
210
- }
211
- }
212
- else
213
- {
214
- //If preceding-sibling elements not exist - add current element as child element.
215
- [AXIS_PARENT setObject:AXIS_SELF forKey:elementName];
216
- }
217
- //Remove current element from storage for parsing elements.
218
- [_axisAncestorOrSelf removeObject:AXIS_SELF];
219
- }
220
- _currentLevel--;
221
- }
222
-
223
- #pragma mark - NSXMLParserDelegate Handling XML Errors
224
-
225
- - (void)parser:(NSXMLParser *)parser parseErrorOccurred:(NSError *)parseError
226
- {
227
- ///Handle parse error
228
- //Output in the console error.
229
- NSLog(@"Line:%i Column:%i - Parse Error Occurred: %@", [parser lineNumber], [parser columnNumber], [parseError description]);
230
- //Set error prorerty pointer to parse error.
231
- _error = parseError;
232
- }
233
-
234
- - (void)parser:(NSXMLParser *)parser validationErrorOccurred:(NSError *)validationError
235
- {
236
- ///Handle validation error
237
- //Output in the console error.
238
- NSLog(@"Line:%i Column:%i - Validation Error Occurred: %@", [parser lineNumber], [parser columnNumber], [validationError description]);
239
- //Set error prorerty pointer to validation error.
240
- _error = validationError;
241
- }
242
-
243
- @end
1
+ /**
2
+ * @class XMLConverter XMLConverter.m "XMLConverter.m"
3
+ * @brief XMLConverter
4
+ * @details XMLConverter.m in XMLConverter
5
+ * @date 10/8/13
6
+ * @copyright Copyright (c) 2013 Ruslan Soldatenko. All rights reserved.
7
+ */
8
+
9
+ #import "XMLConverter.h"
10
+
11
+ #define TEXT_NODE_KEY @"#text"
12
+ #define ATTRIBUTE_PREFIX @"-"
13
+ #define AXIS_PARENT _axisAncestorOrSelf[_currentLevel - 1]
14
+ #define AXIS_PRECEDING_SIBLING _axisAncestorOrSelf[_currentLevel - 1][elementName]
15
+ #define AXIS_SELF _axisAncestorOrSelf[_currentLevel]
16
+
17
+ @interface XMLConverter () <NSXMLParserDelegate>
18
+
19
+ @property (strong, nonatomic) NSMutableArray *axisAncestorOrSelf;
20
+ @property (strong, nonatomic) NSMutableString *selfText;
21
+ @property (strong, nonatomic) NSMutableDictionary *root;
22
+ @property (assign, nonatomic) NSError *error;
23
+ @property (assign, nonatomic) NSInteger currentLevel;
24
+
25
+ @end
26
+
27
+ @implementation XMLConverter
28
+
29
+ #pragma mark - Main Public Methods
30
+
31
+ + (void)convertXMLData:(NSData *)data completion:(OutputBlock)completion
32
+ {
33
+ ///Wrapper for -initWithData: method of NSXMLParser
34
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
35
+ NSXMLParser *parser = [[NSXMLParser alloc] initWithData:data];
36
+ [[XMLConverter new] parser:parser completion:completion];
37
+ });
38
+ }
39
+
40
+ + (void)convertXMLURL:(NSURL *)url completion:(OutputBlock)completion
41
+ {
42
+ ///Wrapper for -initWithContentsOfURL: method of NSXMLParser
43
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
44
+ NSXMLParser *parser = [[NSXMLParser alloc] initWithContentsOfURL:url];
45
+ [[XMLConverter new] parser:parser completion:completion];
46
+ });
47
+ }
48
+
49
+ + (void)convertXMLStream:(NSInputStream *)stream completion:(OutputBlock)completion
50
+ {
51
+ ///Wrapper for -initWithStream: method of NSXMLParser
52
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
53
+ NSXMLParser *parser = [[NSXMLParser alloc] initWithStream:stream];
54
+ [[XMLConverter new] parser:parser completion:completion];
55
+ });
56
+ }
57
+
58
+ #pragma mark - Additional Public Methods
59
+
60
+ + (void)convertXMLString:(NSString *)string completion:(OutputBlock)completion
61
+ {
62
+ //Convert input string to NSData.
63
+ NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding];
64
+ //Use class method for NSData.
65
+ [self convertXMLData:data completion:completion];
66
+ }
67
+
68
+ + (void)convertXMLFile:(NSString *)filePath completion:(OutputBlock)completion
69
+ {
70
+ //Convert input file to NSData
71
+ NSData* data = [NSData dataWithContentsOfFile:filePath];
72
+ //Use class method for NSData.
73
+ [self convertXMLData:data completion:completion];
74
+ }
75
+
76
+ #pragma mark - Internal methods
77
+
78
+ - (void)parser:(NSXMLParser *)parser completion:(OutputBlock)completion
79
+ {
80
+ ///Completion of the parser to work and run the parser.
81
+ [parser setDelegate: self];
82
+ //Start parsing
83
+ BOOL success = [parser parse];
84
+ //execute output block with results of parsing as synchronous
85
+ dispatch_sync(dispatch_get_main_queue(), ^{
86
+ completion(success, _root, _error);
87
+ });
88
+ }
89
+
90
+ - (void)dealloc
91
+ {
92
+ ///Clear out all objects
93
+ [_axisAncestorOrSelf removeAllObjects];
94
+ _axisAncestorOrSelf = nil;
95
+ _selfText = nil;
96
+ _root = nil;
97
+ }
98
+
99
+ #pragma mark - NSXMLParserDelegate Handling XML
100
+
101
+ - (void)parserDidStartDocument:(NSXMLParser *)parser
102
+ {
103
+ ///Initialize internal objects and values
104
+ //Set counter for current level to root element level.
105
+ _currentLevel = 0;
106
+ //Create storage for parsing elements.
107
+ _axisAncestorOrSelf = [NSMutableArray new];
108
+ //Create object for result of parsing - the root object
109
+ _root = [NSMutableDictionary new];
110
+ //Put in the array as first the root object.
111
+ [_axisAncestorOrSelf addObject:_root];
112
+ //Create object for storing current element text value.
113
+ _selfText = [NSMutableString new];
114
+ }
115
+
116
+ - (void)parserDidEndDocument:(NSXMLParser *)parser
117
+ {
118
+ ///Clear unused object
119
+ [_axisAncestorOrSelf removeLastObject];
120
+ }
121
+
122
+ - (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict
123
+ {
124
+ ///Start processing of the current element
125
+ _currentLevel++;
126
+ if ([_axisAncestorOrSelf count] == _currentLevel)
127
+ {
128
+ //Add dictionary for started element if it not exist.
129
+ [_axisAncestorOrSelf addObject:[NSMutableDictionary new]];
130
+ //Processing a text value (if it exist) of the previous (parent) element.
131
+ if ([_selfText length] > 0)
132
+ {
133
+ [AXIS_PARENT setObject:_selfText forKey:TEXT_NODE_KEY];
134
+ _selfText = [NSMutableString new];
135
+ }
136
+ }
137
+ //Add attribute values (if it exist) to current element.
138
+ if ([attributeDict count] != 0)
139
+ {
140
+ for (id key in [attributeDict allKeys])
141
+ {
142
+ NSString *attributeKey = [NSString stringWithFormat:@"%@%@", ATTRIBUTE_PREFIX, key];
143
+ [AXIS_SELF setObject:attributeDict[key] forKey:attributeKey];
144
+ }
145
+ }
146
+ }
147
+
148
+ - (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
149
+ {
150
+ ///Processing the text value of the current element
151
+ NSCharacterSet *characterSet = [NSCharacterSet whitespaceAndNewlineCharacterSet];
152
+ NSString *text = [string stringByTrimmingCharactersInSet: characterSet];
153
+ [_selfText appendString:text];
154
+ }
155
+
156
+ - (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
157
+ {
158
+ ///Completion processing of the current element
159
+ if ([AXIS_SELF count] == 0)
160
+ {
161
+ if (AXIS_PARENT[elementName])
162
+ {
163
+ if ([AXIS_PARENT[elementName] isKindOfClass:[NSMutableArray class]])
164
+ {
165
+ //If exist collection of preceding-sibling elements - add current element to collection.
166
+ [AXIS_PARENT[elementName] addObject:_selfText];
167
+ }
168
+ else
169
+ {
170
+ /*
171
+ If exist only one preceding-sibling element - create collection
172
+ and add both (preceding-sibling and current) elements to collection.
173
+ */
174
+ NSMutableArray *elementsArray = [NSMutableArray new];
175
+ [elementsArray addObjectsFromArray:@[AXIS_PRECEDING_SIBLING, _selfText]];
176
+ [AXIS_PARENT setObject:elementsArray forKey:elementName];
177
+ }
178
+ }
179
+ else
180
+ {
181
+ //If exist only text value of element - set it as element value.
182
+ [AXIS_PARENT setObject:_selfText forKey:elementName];
183
+ }
184
+ _selfText = [NSMutableString new];
185
+ }
186
+ else
187
+ {
188
+ if ([_selfText length] > 0)
189
+ {
190
+ //If exist text value of element and child elements - set it as child element value.
191
+ [AXIS_SELF setObject:_selfText forKey:TEXT_NODE_KEY];
192
+ _selfText = [NSMutableString new];
193
+ }
194
+ if (AXIS_PRECEDING_SIBLING)
195
+ {
196
+ if ([AXIS_PRECEDING_SIBLING isKindOfClass:[NSMutableArray class]])
197
+ {
198
+ //If exist collection of preceding-sibling elements - add current element to collection.
199
+ [AXIS_PRECEDING_SIBLING addObject:AXIS_SELF];
200
+ }
201
+ else if ([AXIS_PRECEDING_SIBLING isKindOfClass:[NSMutableDictionary class]])
202
+ {
203
+ /*
204
+ If exist only one preceding-sibling element - create collection
205
+ and add both (preceding-sibling and current) elements to collection.
206
+ */
207
+ NSMutableArray *elementsArray = [NSMutableArray new];
208
+ [elementsArray addObjectsFromArray:@[AXIS_PRECEDING_SIBLING, AXIS_SELF]];
209
+ [AXIS_PARENT setObject:elementsArray forKey:elementName];
210
+ }
211
+ }
212
+ else
213
+ {
214
+ //If preceding-sibling elements not exist - add current element as child element.
215
+ [AXIS_PARENT setObject:AXIS_SELF forKey:elementName];
216
+ }
217
+ //Remove current element from storage for parsing elements.
218
+ [_axisAncestorOrSelf removeObject:AXIS_SELF];
219
+ }
220
+ _currentLevel--;
221
+ }
222
+
223
+ #pragma mark - NSXMLParserDelegate Handling XML Errors
224
+
225
+ - (void)parser:(NSXMLParser *)parser parseErrorOccurred:(NSError *)parseError
226
+ {
227
+ ///Handle parse error
228
+ //Output in the console error.
229
+ NSLog(@"Line:%i Column:%i - Parse Error Occurred: %@", [parser lineNumber], [parser columnNumber], [parseError description]);
230
+ //Set error prorerty pointer to parse error.
231
+ _error = parseError;
232
+ }
233
+
234
+ - (void)parser:(NSXMLParser *)parser validationErrorOccurred:(NSError *)validationError
235
+ {
236
+ ///Handle validation error
237
+ //Output in the console error.
238
+ NSLog(@"Line:%i Column:%i - Validation Error Occurred: %@", [parser lineNumber], [parser columnNumber], [validationError description]);
239
+ //Set error prorerty pointer to validation error.
240
+ _error = validationError;
241
+ }
242
+
243
+ @end
@@ -1,19 +1,19 @@
1
- //
2
- // ZipArchive.h
3
- // ZipArchive
4
- //
5
- // Created by Serhii Mumriak on 12/1/15.
6
- // Copyright © 2015 smumryak. All rights reserved.
7
- //
8
-
9
- #import <Foundation/Foundation.h>
10
-
11
- //! Project version number for ZipArchive.
12
- FOUNDATION_EXPORT double ZipArchiveVersionNumber;
13
-
14
- //! Project version string for ZipArchive.
15
- FOUNDATION_EXPORT const unsigned char ZipArchiveVersionString[];
16
-
17
- // In this header, you should import all the public headers of your framework using statements like #import <ZipArchive/SSZipArchive.h>
18
-
19
- #import "SSZipArchive.h"
1
+ //
2
+ // ZipArchive.h
3
+ // ZipArchive
4
+ //
5
+ // Created by Serhii Mumriak on 12/1/15.
6
+ // Copyright © 2015 smumryak. All rights reserved.
7
+ //
8
+
9
+ #import <Foundation/Foundation.h>
10
+
11
+ //! Project version number for ZipArchive.
12
+ FOUNDATION_EXPORT double ZipArchiveVersionNumber;
13
+
14
+ //! Project version string for ZipArchive.
15
+ FOUNDATION_EXPORT const unsigned char ZipArchiveVersionString[];
16
+
17
+ // In this header, you should import all the public headers of your framework using statements like #import <ZipArchive/SSZipArchive.h>
18
+
19
+ #import "SSZipArchive.h"