Files
Sparkle/Sparkle/SPUUserUpdateState.m
T
Zorg 253f45b476 Add optional version field to sparkle:criticalUpdate element
This version indicates the version that was first marked critical. So versions below this specified version will treat the update as critical while versions >= the specified version will not.

Also move sparkle:criticalUpdate to root level element instead of it being a tag. The tagged version is now deprecated and doesn't support the version field.
2021-05-30 23:37:38 -07:00

63 lines
2.0 KiB
Objective-C

//
// SPUUserUpdateState.m
// Sparkle
//
// Created by Mayur Pawashe on 5/9/21.
// Copyright © 2021 Sparkle Project. All rights reserved.
//
#import "SPUUserUpdateState.h"
#import "SPUUserUpdateState+Private.h"
#include "AppKitPrevention.h"
#define SPUUserUpdateStateStageKey @"SPUUserUpdateStateStage"
#define SPUUserUpdateStateUserInitiatedKey @"SPUUserUpdateStateUserInitiated"
#define SPUUserUpdateStateMajorUpgradeKey @"SPUUserUpdateStateMajorUpgrade"
#define SPUUserUpdateStateCriticalUpdateKey @"SPUUserUpdateStateCriticalUpdate"
@implementation SPUUserUpdateState
@synthesize stage = _stage;
@synthesize userInitiated = _userInitiated;
@synthesize majorUpgrade = _majorUpgrade;
@synthesize criticalUpdate = _criticalUpdate;
- (instancetype)initWithStage:(SPUUserUpdateStage)stage userInitiated:(BOOL)userInitiated majorUpgrade:(BOOL)majorUpgrade criticalUpdate:(BOOL)criticalUpdate
{
self = [super init];
if (self != nil) {
_stage = stage;
_userInitiated = userInitiated;
_majorUpgrade = majorUpgrade;
_criticalUpdate = criticalUpdate;
}
return self;
}
- (void)encodeWithCoder:(NSCoder *)encoder
{
[encoder encodeInteger:self.stage forKey:SPUUserUpdateStateStageKey];
[encoder encodeBool:self.userInitiated forKey:SPUUserUpdateStateUserInitiatedKey];
[encoder encodeBool:self.majorUpgrade forKey:SPUUserUpdateStateMajorUpgradeKey];
[encoder encodeBool:self.criticalUpdate forKey:SPUUserUpdateStateCriticalUpdateKey];
}
- (instancetype)initWithCoder:(NSCoder *)decoder
{
SPUUserUpdateStage stage = [decoder decodeIntegerForKey:SPUUserUpdateStateStageKey];
BOOL userInitiated = [decoder decodeBoolForKey:SPUUserUpdateStateUserInitiatedKey];
BOOL majorUpgrade = [decoder decodeBoolForKey:SPUUserUpdateStateMajorUpgradeKey];
BOOL criticalUpdate = [decoder decodeBoolForKey:SPUUserUpdateStateCriticalUpdateKey];
return [self initWithStage:stage userInitiated:userInitiated majorUpgrade:majorUpgrade criticalUpdate:criticalUpdate];
}
+ (BOOL)supportsSecureCoding
{
return YES;
}
@end