Parse and remember the IsHdrSupported app attribute

This commit is contained in:
Cameron Gutman
2018-06-02 12:32:12 -07:00
parent 2cec53ab6b
commit 59506a2364
5 changed files with 15 additions and 3 deletions
+1
View File
@@ -14,6 +14,7 @@
@property (nullable, nonatomic, retain) NSString *id; @property (nullable, nonatomic, retain) NSString *id;
@property (nullable, nonatomic, retain) NSData *image; @property (nullable, nonatomic, retain) NSData *image;
@property (nullable, nonatomic, retain) NSString *name; @property (nullable, nonatomic, retain) NSString *name;
@property (nonatomic) BOOL hdrSupported;
@property (nullable, nonatomic, retain) TemporaryHost *host; @property (nullable, nonatomic, retain) TemporaryHost *host;
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
+2
View File
@@ -16,6 +16,7 @@
self.id = app.id; self.id = app.id;
self.image = app.image; self.image = app.image;
self.name = app.name; self.name = app.name;
self.hdrSupported = app.hdrSupported;
self.host = tempHost; self.host = tempHost;
return self; return self;
@@ -24,6 +25,7 @@
- (void) propagateChangesToParent:(App*)parent withHost:(Host*)host { - (void) propagateChangesToParent:(App*)parent withHost:(Host*)host {
parent.id = self.id; parent.id = self.id;
parent.name = self.name; parent.name = self.name;
parent.hdrSupported = self.hdrSupported;
parent.host = host; parent.host = host;
} }
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="14133" systemVersion="17E202" minimumToolsVersion="Xcode 7.3" sourceLanguage="Objective-C" userDefinedModelVersionIdentifier=""> <model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="14135" systemVersion="17F77" minimumToolsVersion="Xcode 7.3" sourceLanguage="Objective-C" userDefinedModelVersionIdentifier="">
<entity name="App" representedClassName="App" syncable="YES" codeGenerationType="class"> <entity name="App" representedClassName="App" syncable="YES" codeGenerationType="class">
<attribute name="hdrSupported" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES" syncable="YES"/>
<attribute name="id" attributeType="String" syncable="YES"/> <attribute name="id" attributeType="String" syncable="YES"/>
<attribute name="image" optional="YES" attributeType="Binary" allowsExternalBinaryDataStorage="YES" syncable="YES"/> <attribute name="image" optional="YES" attributeType="Binary" allowsExternalBinaryDataStorage="YES" syncable="YES"/>
<attribute name="name" attributeType="String" syncable="YES"/> <attribute name="name" attributeType="String" syncable="YES"/>
+9 -2
View File
@@ -19,6 +19,7 @@
static const char* TAG_APP = "App"; static const char* TAG_APP = "App";
static const char* TAG_APP_TITLE = "AppTitle"; static const char* TAG_APP_TITLE = "AppTitle";
static const char* TAG_APP_ID = "ID"; static const char* TAG_APP_ID = "ID";
static const char* TAG_HDR_SUPPORTED = "IsHdrSupported";
- (void)populateWithData:(NSData *)xml { - (void)populateWithData:(NSData *)xml {
self.data = xml; self.data = xml;
@@ -66,14 +67,13 @@ static const char* TAG_APP_ID = "ID";
xmlNodePtr appInfoNode = node->xmlChildrenNode; xmlNodePtr appInfoNode = node->xmlChildrenNode;
NSString* appName = @""; NSString* appName = @"";
NSString* appId = nil; NSString* appId = nil;
NSString* hdrSupported = @"0";
while (appInfoNode != NULL) { while (appInfoNode != NULL) {
if (!xmlStrcmp(appInfoNode->name, (xmlChar*)TAG_APP_TITLE)) { if (!xmlStrcmp(appInfoNode->name, (xmlChar*)TAG_APP_TITLE)) {
xmlChar* nodeVal = xmlNodeListGetString(docPtr, appInfoNode->xmlChildrenNode, 1); xmlChar* nodeVal = xmlNodeListGetString(docPtr, appInfoNode->xmlChildrenNode, 1);
if (nodeVal != NULL) { if (nodeVal != NULL) {
appName = [[NSString alloc] initWithCString:(const char*)nodeVal encoding:NSUTF8StringEncoding]; appName = [[NSString alloc] initWithCString:(const char*)nodeVal encoding:NSUTF8StringEncoding];
xmlFree(nodeVal); xmlFree(nodeVal);
} else {
appName = @"";
} }
} else if (!xmlStrcmp(appInfoNode->name, (xmlChar*)TAG_APP_ID)) { } else if (!xmlStrcmp(appInfoNode->name, (xmlChar*)TAG_APP_ID)) {
xmlChar* nodeVal = xmlNodeListGetString(docPtr, appInfoNode->xmlChildrenNode, 1); xmlChar* nodeVal = xmlNodeListGetString(docPtr, appInfoNode->xmlChildrenNode, 1);
@@ -81,6 +81,12 @@ static const char* TAG_APP_ID = "ID";
appId = [[NSString alloc] initWithCString:(const char*)nodeVal encoding:NSUTF8StringEncoding]; appId = [[NSString alloc] initWithCString:(const char*)nodeVal encoding:NSUTF8StringEncoding];
xmlFree(nodeVal); xmlFree(nodeVal);
} }
} else if (!xmlStrcmp(appInfoNode->name, (xmlChar*)TAG_HDR_SUPPORTED)) {
xmlChar* nodeVal = xmlNodeListGetString(docPtr, appInfoNode->xmlChildrenNode, 1);
if (nodeVal != NULL) {
hdrSupported = [[NSString alloc] initWithCString:(const char*)nodeVal encoding:NSUTF8StringEncoding];
xmlFree(nodeVal);
}
} }
appInfoNode = appInfoNode->next; appInfoNode = appInfoNode->next;
} }
@@ -88,6 +94,7 @@ static const char* TAG_APP_ID = "ID";
TemporaryApp* app = [[TemporaryApp alloc] init]; TemporaryApp* app = [[TemporaryApp alloc] init];
app.name = appName; app.name = appName;
app.id = appId; app.id = appId;
app.hdrSupported = [hdrSupported intValue] != 0;
[_appList addObject:app]; [_appList addObject:app];
} }
} }
@@ -176,6 +176,7 @@ static NSMutableSet* hostList;
for (TemporaryApp* savedApp in host.appList) { for (TemporaryApp* savedApp in host.appList) {
if ([app.id isEqualToString:savedApp.id]) { if ([app.id isEqualToString:savedApp.id]) {
savedApp.name = app.name; savedApp.name = app.name;
savedApp.hdrSupported = app.hdrSupported;
appAlreadyInList = YES; appAlreadyInList = YES;
break; break;
} }