Skip to content

Commit

Permalink
Merge pull request #7 from Ashton-W/master
Browse files Browse the repository at this point in the history
Added NSAppTransportSecurity, DTSDKName, and MinimumOSVersion
  • Loading branch information
ealeksandrov committed Dec 11, 2016
2 parents 3268e8a + 485b435 commit d363fe3
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 2 deletions.
53 changes: 53 additions & 0 deletions ProvisionQL/GeneratePreviewForURL.m
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,30 @@ void displayKeyAndValue(NSUInteger level, NSString *key, id value, NSMutableStri
return @{@"ProvisionedDevicesFormatted" : [devices copy], @"ProvisionedDevicesCount" : [NSString stringWithFormat:@"%zd Device%s", [array count], ([array count] == 1 ? "" : "s")]};
}

NSString *formattedDictionaryWithReplacements(NSDictionary *dictionary, NSDictionary *replacements) {

NSMutableString *string = [NSMutableString string];

for (NSString *key in dictionary) {
NSString *localizedKey = replacements[key] ?: key;
NSObject *object = dictionary[key];

if ([object isKindOfClass:[NSDictionary class]]) {
object = formattedDictionaryWithReplacements((NSDictionary *)object, replacements);
[string appendFormat:@"%@:<div class=\"list\">%@</div>", localizedKey, object];
}
else if ([object isKindOfClass:[NSNumber class]]) {
object = [(NSNumber *)object boolValue] ? @"YES" : @"NO";
[string appendFormat:@"%@: %@<br />", localizedKey, object];
}
else {
[string appendFormat:@"%@: %@<br />", localizedKey, object];
}
}

return string;
}

OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options) {
@autoreleasepool {
// create temp directory
Expand Down Expand Up @@ -279,6 +303,35 @@ OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview,
[synthesizedInfo setObject:[appPropertyList objectForKey:@"CFBundleShortVersionString"] forKey:@"CFBundleShortVersionString"];
[synthesizedInfo setObject:[appPropertyList objectForKey:@"CFBundleVersion"] forKey:@"CFBundleVersion"];

NSString *sdkName = [appPropertyList objectForKey:@"DTSDKName"] ?: @"";
[synthesizedInfo setObject:sdkName forKey:@"DTSDKName"];

NSString *minimumOSVersion = [appPropertyList objectForKey:@"MinimumOSVersion"] ?: @"";
[synthesizedInfo setObject:minimumOSVersion forKey:@"MinimumOSVersion"];

NSDictionary *appTransportSecurity = [appPropertyList objectForKey:@"NSAppTransportSecurity"];
NSString *appTransportSecurityFormatted = @"No exceptions";
if ([appTransportSecurity isKindOfClass:[NSDictionary class]]) {
NSDictionary *localizedKeys = @{
@"NSAllowsArbitraryLoads": @"Allows Arbitrary Loads",
@"NSAllowsArbitraryLoadsInWebContent": @"Allows Arbitrary Loads in Web Content",
@"NSAllowsArbitraryLoadsInWebContent": @"Allows Arbitrary Loads in Web Content",
@"NSExceptionDomains": @"Exception Domains"
};

NSString *formattedDictionaryString = formattedDictionaryWithReplacements(appTransportSecurity, localizedKeys);
appTransportSecurityFormatted = [NSString stringWithFormat:@"<div class=\"list\">%@</div>", formattedDictionaryString];
}
else {
double sdkNumber = [[sdkName stringByTrimmingCharactersInSet:[NSCharacterSet letterCharacterSet]] doubleValue];
if (sdkNumber < 9.0) {
appTransportSecurityFormatted = @"Not applicable before iOS 9.0";
}
}

[synthesizedInfo setObject:appTransportSecurityFormatted forKey:@"AppTransportSecurityFormatted"];


NSString *iconName = mainIconNameForApp(appPropertyList);
appIcon = imageFromApp(URL, dataType, iconName);

Expand Down
22 changes: 20 additions & 2 deletions ProvisionQL/Resources/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,21 @@
.info {
margin-left: 20px;
}


.info .subsection {
display: inline-block;
vertical-align: top;
}

.info .list {
padding-left: 20px;
}

.info > .list {
display: inline-block;
padding-left: 0px;
}

.floatLeft {
float: left;
}
Expand Down Expand Up @@ -99,7 +113,11 @@ <h1>App info</h1>
Name: <strong>__CFBundleName__</strong><br />
Version: __CFBundleShortVersionString__ (__CFBundleVersion__)<br />
BundleId: __CFBundleIdentifier__<br />
DeviceFamily: __UIDeviceFamily__</div>
DeviceFamily: __UIDeviceFamily__<br />
SDK: __DTSDKName__<br />
Minimum OS Version: __MinimumOSVersion__<br />
<div class="subsection">App Transport Security:</div> __AppTransportSecurityFormatted__
</div>
<br class="clear" />
</div>

Expand Down

0 comments on commit d363fe3

Please sign in to comment.