This commit is contained in:
2025-10-28 10:18:10 +08:00
parent efb04d134e
commit 1deca2ae5b
166 changed files with 17288 additions and 1427 deletions

View File

@@ -0,0 +1,64 @@
#ifdef SHOULD_COMPILE_LOOKIN_SERVER
//
// LookinHierarchyFile.m
// Lookin
//
// Created by Li Kai on 2019/5/12.
// https://lookin.work
//
#import "LookinHierarchyFile.h"
#import "NSArray+Lookin.h"
@implementation LookinHierarchyFile
- (void)encodeWithCoder:(NSCoder *)aCoder {
[aCoder encodeInt:self.serverVersion forKey:@"serverVersion"];
[aCoder encodeObject:self.hierarchyInfo forKey:@"hierarchyInfo"];
[aCoder encodeObject:self.soloScreenshots forKey:@"soloScreenshots"];
[aCoder encodeObject:self.groupScreenshots forKey:@"groupScreenshots"];
}
- (instancetype)initWithCoder:(NSCoder *)aDecoder {
if (self = [super init]) {
self.serverVersion = [aDecoder decodeIntForKey:@"serverVersion"];
self.hierarchyInfo = [aDecoder decodeObjectForKey:@"hierarchyInfo"];
self.soloScreenshots = [aDecoder decodeObjectForKey:@"soloScreenshots"];
self.groupScreenshots = [aDecoder decodeObjectForKey:@"groupScreenshots"];
}
return self;
}
+ (BOOL)supportsSecureCoding {
return YES;
}
+ (NSError *)verifyHierarchyFile:(LookinHierarchyFile *)hierarchyFile {
if (![hierarchyFile isKindOfClass:[LookinHierarchyFile class]]) {
return LookinErr_Inner;
}
if (hierarchyFile.serverVersion < LOOKIN_SUPPORTED_SERVER_MIN) {
//
// serverVersion 6
int fileVersion = hierarchyFile.serverVersion ? : 6;
NSString *detail = [NSString stringWithFormat:NSLocalizedString(@"The document was created by a Lookin app with too old version. Current Lookin app version is %@, but the document version is %@.", nil), @(LOOKIN_CLIENT_VERSION), @(fileVersion)];
return [NSError errorWithDomain:LookinErrorDomain code:LookinErrCode_ServerVersionTooLow userInfo:@{NSLocalizedDescriptionKey:NSLocalizedString(@"Failed to open the document.", nil), NSLocalizedRecoverySuggestionErrorKey:detail}];
}
if (hierarchyFile.serverVersion > LOOKIN_SUPPORTED_SERVER_MAX) {
//
NSString *detail = [NSString stringWithFormat:NSLocalizedString(@"Current Lookin app is too old to open this document. Current Lookin app version is %@, but the document version is %@.", nil), @(LOOKIN_CLIENT_VERSION), @(hierarchyFile.serverVersion)];
return [NSError errorWithDomain:LookinErrorDomain code:LookinErrCode_ServerVersionTooHigh userInfo:@{NSLocalizedDescriptionKey:NSLocalizedString(@"Failed to open the document.", nil), NSLocalizedRecoverySuggestionErrorKey:detail}];
}
return nil;
}
@end
#endif /* SHOULD_COMPILE_LOOKIN_SERVER */