Skip to content

Commit 09cdd54

Browse files
committed
fixed Xcode 15 compatibility by bumping deployment target to 10.13
1 parent 789f86d commit 09cdd54

18 files changed

+296
-22
lines changed

Cartfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
github "MacPass/KissXML" "933f04fe5ad95c2be07ec0c2f801e140007f20fa"
1+
github "MacPass/KissXML" "503fc012b73a4507965019720cbf1c157e849657"

Cartfile.resolved

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
github "MacPass/KissXML" "933f04fe5ad95c2be07ec0c2f801e140007f20fa"
1+
github "MacPass/KissXML" "503fc012b73a4507965019720cbf1c157e849657"

KeePassKit.xcodeproj/project.pbxproj

+64-8
Large diffs are not rendered by default.

KeePassKit.xcodeproj/xcshareddata/xcschemes/KeePassKit iOS.xcscheme

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1200"
3+
LastUpgradeVersion = "1400"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

KeePassKit.xcodeproj/xcshareddata/xcschemes/KeePassKit macOS.xcscheme

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1200"
3+
LastUpgradeVersion = "1400"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

KeePassKit.xcodeproj/xcshareddata/xcschemes/KeePassKit tvOS.xcscheme

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1200"
3+
LastUpgradeVersion = "1400"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

KeePassKit.xcodeproj/xcshareddata/xcschemes/KeePassKit watchOS.xcscheme

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1200"
3+
LastUpgradeVersion = "1400"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
//
2+
// KPKSynchronizationChangesItem.h
3+
// KeePassKit
4+
//
5+
// Created by Michael Starke on 05.10.22.
6+
// Copyright © 2022 HicknHack Software GmbH. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
11+
NS_ASSUME_NONNULL_BEGIN
12+
13+
typedef NS_ENUM(NSUInteger, KPKSynchronizationChangeType) {
14+
KPKSynchronizationChangeTypeAddedNode,
15+
KPKSynchronizationChangeTypeRemovedNode,
16+
KPKSynchronizationChangeTypeMovedNode,
17+
KPKSynchronizationChangeTypeChangedNodeAttribute, // Node attributes have changed
18+
KPKSynchronizationChangeTypeAddedNodeAttribute, // Node attributes where added - valid only for entries
19+
KPKSynchronizationChangeTypeRemovedNodeAttribute, // Node attributes where removed - valid only for entries
20+
KPKSynchronizationChangeTypeAddedIcon,
21+
KPKSynchronizationChangeTypeRemovedIcon,
22+
KPKSynchronizationChangeTypeChangedIcon,
23+
KPKSynchronizationChangeTypeChangedMetaData, // Any changes in inner settings e.g. Templates, Recycle Bin, History, Name, Color
24+
};
25+
26+
@class KPKNode;
27+
@class KPKGroup;
28+
@class KPKAttribute;
29+
30+
@interface KPKSynchronizationChangesItem : NSObject
31+
32+
@property (readonly) KPKSynchronizationChangeType changeType;
33+
34+
@property (readonly, copy) NSUUID *uuid; // the uuid of the affected node
35+
36+
+ (instancetype)itemWithChangedAttributeKey:(NSString *)key localValue:(NSString *)localValue remoteValue:(NSString *)remoteValue;
37+
+ (instancetype)itemWithAddedNode:(KPKNode *)node parent:(KPKGroup *)group;
38+
+ (instancetype)itemWithRemovedNode:(KPKNode *)node;
39+
40+
- (instancetype)init NS_UNAVAILABLE;
41+
42+
@end
43+
44+
@interface KPKSynchronizationAttributeChangesItem : KPKSynchronizationChangesItem
45+
46+
@property (readonly, copy) NSString *key;
47+
@property (readonly, copy) NSString *localValue;
48+
@property (readonly, copy) NSString *remoteValue;
49+
50+
@end
51+
52+
NS_ASSUME_NONNULL_END
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//
2+
// KPKSynchronizationChangesItem.m
3+
// KeePassKit
4+
//
5+
// Created by Michael Starke on 05.10.22.
6+
// Copyright © 2022 HicknHack Software GmbH. All rights reserved.
7+
//
8+
9+
#import "KPKSynchronizationChangesItem.h"
10+
11+
@implementation KPKSynchronizationChangesItem
12+
13+
@end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//
2+
// KPKSynchronizationChangesStore.h
3+
// KeePassKit
4+
//
5+
// Created by Michael Starke on 02.10.22.
6+
// Copyright © 2022 HicknHack Software GmbH. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
11+
NS_ASSUME_NONNULL_BEGIN
12+
13+
@class KPKGroup;
14+
@class KPKNode;
15+
@class KPKAttribute;
16+
@class KPKSynchronizationChangesItem;
17+
18+
@interface KPKSynchronizationChangesStore : NSObject
19+
20+
@property (readonly, copy, nonatomic) NSArray<KPKSynchronizationChangesItem *> *allChanges;
21+
22+
@property (readonly, copy, nonatomic) NSArray<KPKSynchronizationChangesItem *> *addedNodes;
23+
@property (readonly, copy, nonatomic) NSArray<KPKSynchronizationChangesItem *> *removedNodes;
24+
25+
- (NSArray<KPKSynchronizationChangesItem *> *)changesForUUID:(NSUUID *)uuid;
26+
// icons
27+
// metadata
28+
// attributes
29+
30+
@end
31+
32+
NS_ASSUME_NONNULL_END
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
//
2+
// KPKSynchronizationChangesStore.m
3+
// KeePassKit
4+
//
5+
// Created by Michael Starke on 02.10.22.
6+
// Copyright © 2022 HicknHack Software GmbH. All rights reserved.
7+
//
8+
9+
#import "KPKSynchronizationChangesStore.h"
10+
#import "KPKSynchronizationChangesStore_Private.h"
11+
#import "KPKSynchronizationChangesItem.h"
12+
13+
@implementation KPKSynchronizationChangesStore
14+
15+
@dynamic addedNodes;
16+
@dynamic removedNodes;
17+
@dynamic allChanges;
18+
19+
- (instancetype)init {
20+
self = [super init];
21+
if(self) {
22+
self.mutableChanges = [[NSMutableArray alloc] init];
23+
self.recordingChanges = NO;
24+
}
25+
return self;
26+
}
27+
28+
- (void)_beginRecordingChanges {
29+
[self.mutableChanges removeAllObjects];
30+
self.recordingChanges = YES;
31+
}
32+
33+
- (void)_endRecordingChanges {
34+
self.recordingChanges = NO;
35+
}
36+
37+
- (void)_addChange:(KPKSynchronizationChangesItem *)changeItem {
38+
NSAssert(self.isRecordingChanges, @"Change recording is only possible while in active recording");
39+
[self.mutableChanges addObject:changeItem];
40+
}
41+
42+
- (NSArray<KPKSynchronizationChangesItem *> *)allChanges {
43+
NSAssert(!self.isRecordingChanges, @"Cannot access changes while actively recording them");
44+
return [self.mutableChanges copy];
45+
}
46+
47+
- (NSArray<KPKSynchronizationChangesItem *> *)addedNodes {
48+
NSAssert(!self.isRecordingChanges, @"Cannot access changes while actively recording them");
49+
NSPredicate *addedNodesPredicate = [NSPredicate predicateWithBlock:^BOOL(id _Nullable evaluatedObject, NSDictionary<NSString *,id> * _Nullable bindings) {
50+
KPKSynchronizationChangesItem *item = (KPKSynchronizationChangesItem *)evaluatedObject;
51+
return (item.changeType == KPKSynchronizationChangeTypeAddedNode);
52+
53+
}];
54+
return [self.mutableChanges filteredArrayUsingPredicate:addedNodesPredicate];
55+
}
56+
57+
- (NSArray<KPKSynchronizationChangesItem *> *)removedNodes {
58+
NSAssert(!self.isRecordingChanges, @"Cannot access changes while actively recording them");
59+
NSPredicate *addedNodesPredicate = [NSPredicate predicateWithBlock:^BOOL(id _Nullable evaluatedObject, NSDictionary<NSString *,id> * _Nullable bindings) {
60+
KPKSynchronizationChangesItem *item = (KPKSynchronizationChangesItem *)evaluatedObject;
61+
return (item.changeType == KPKSynchronizationChangeTypeRemovedNode);
62+
63+
}];
64+
return [self.mutableChanges filteredArrayUsingPredicate:addedNodesPredicate];
65+
}
66+
67+
- (NSArray<KPKSynchronizationChangesItem *> *)changesForUUID:(NSUUID *)uuid {
68+
NSAssert(!self.isRecordingChanges, @"Cannot access changes while actively recording them");
69+
NSPredicate *addedNodesPredicate = [NSPredicate predicateWithBlock:^BOOL(id _Nullable evaluatedObject, NSDictionary<NSString *,id> * _Nullable bindings) {
70+
KPKSynchronizationChangesItem *item = (KPKSynchronizationChangesItem *)evaluatedObject;
71+
return ([item.uuid isEqual:uuid]);
72+
}];
73+
return [self.mutableChanges filteredArrayUsingPredicate:addedNodesPredicate];
74+
75+
}
76+
77+
@end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//
2+
// KPKSynchronizationChangesStore+Private.h
3+
// KeePassKit
4+
//
5+
// Created by Michael Starke on 05.10.22.
6+
// Copyright © 2022 HicknHack Software GmbH. All rights reserved.
7+
//
8+
9+
#import <KeePassKit/KeePassKit.h>
10+
#import "KPKSynchronizationChangesStore.h"
11+
#import "KPKSynchronizationChangesItem.h"
12+
13+
NS_ASSUME_NONNULL_BEGIN
14+
15+
@interface KPKSynchronizationChangesStore ()
16+
17+
@property (strong) NSMutableArray *mutableChanges;
18+
@property (assign, getter=isRecordingChanges) BOOL recordingChanges;
19+
20+
- (void)_beginRecordingChanges;
21+
- (void)_endRecordingChanges;
22+
- (void)_addChange:(KPKSynchronizationChangesItem *)changeItem;
23+
24+
@end
25+
26+
NS_ASSUME_NONNULL_END

KeePassKit/Core/KPKTree+Synchronization.m

+9-4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#import "KPKNode.h"
2222
#import "KPKNode_Private.h"
2323
#import "KPKScopedSet.h"
24+
#import "KPKSynchronizationChangesItem.h"
25+
#import "KPKSynchronizationChangesStore_Private.h"
2426
#import "KPKTimeInfo.h"
2527
#import "KPKTree_Private.h"
2628

@@ -41,8 +43,11 @@
4143
@implementation KPKTree (Synchronization)
4244

4345
- (void)synchronizeWithTree:(KPKTree *)tree mode:(KPKSynchronizationMode)mode options:(KPKSynchronizationOptions)options {
44-
45-
if(options & KPKSynchronizationOptionCreateNewUuids) {
46+
KPKSynchronizationChangesStore *changesStore;
47+
if([tree.delegate respondsToSelector:@selector(synchronizationChangeStoreForTree:)]) {
48+
changesStore = [tree.delegate synchronizationChangeStoreForTree:tree];
49+
}
50+
if(!(options & KPKSynchronizationOptionDryRun) && (options & KPKSynchronizationOptionCreateNewUuids)) {
4651
/* create new uuid in the sourc tree */
4752
[tree.root _regenerateUUIDs];
4853
}
@@ -57,6 +62,7 @@ - (void)synchronizeWithTree:(KPKTree *)tree mode:(KPKSynchronizationMode)mode op
5762
7) update deleted information
5863
8) reapply deletions to ensure entries and groups are at final place
5964
*/
65+
[changesStore _beginRecordingChanges];
6066
[self _mergeNodes:[@[tree.root] arrayByAddingObjectsFromArray:tree.allGroups] mode:mode options:options];
6167
[self _mergeNodes:tree.allEntries mode:mode options:options];
6268
[self _mergeLocationFromNodes:tree.allEntries options:options];
@@ -67,8 +73,7 @@ - (void)synchronizeWithTree:(KPKTree *)tree mode:(KPKSynchronizationMode)mode op
6773
[self _reapplyNodeDeletions:self.root];
6874
[self _reapplyIconDeletions];
6975
}
70-
71-
;
76+
[changesStore _endRecordingChanges];
7277
/* clear undo stack since merge is not supposed to be undoable */
7378
[self.undoManager removeAllActions];
7479
}

KeePassKit/Core/KPKTree.h

+6
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#import <Foundation/Foundation.h>
2424
#import <KeePassKit/KPKFormat.h>
2525
#import <KeePassKit/KPKSynchronizationOptions.h>
26+
#import <KeePassKit/KPKSynchronizationChangesStore.h>
2627
#import <KeePassKit/KPKNode.h>
2728

2829
NS_ASSUME_NONNULL_BEGIN
@@ -98,6 +99,11 @@ FOUNDATION_EXTERN NSString *const KPKEntryKey;
9899
*/
99100
- (BOOL)tree:(KPKTree *)tree resolveUnknownPlaceholdersInString:(NSMutableString *)string forEntry:(KPKEntry *)entry;
100101

102+
/// Allows the delegate to supply a changesStore to retrieve any changes when a synchonization is done.
103+
/// Run the synchronization in dry mode to retriefe those changes before applying the merge
104+
/// - Parameter tree: the tree to supply the store for
105+
- (KPKSynchronizationChangesStore *)synchronizationChangeStoreForTree:(KPKTree *)tree;
106+
101107
@end
102108

103109
@class KPKGroup;

KeePassKit/Format/KPKSynchronizationOptions.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ typedef NS_ENUM(NSUInteger, KPKSynchronizationMode) {
2020

2121
typedef NS_OPTIONS(NSUInteger, KPKSynchronizationOptions) {
2222
KPKSynchronizationOptionCreateNewUuids = 1 << 0, // generate new UUIDs in source tree before merging it into target
23-
KPKSynchronizationOptionMatchGroupsByTitleOnly = 1 << 1 // match groups by title not by UUID. This is usefull when trying to merge KDB trees since only entry retain their UUID after save and load
23+
KPKSynchronizationOptionMatchGroupsByTitleOnly = 1 << 1, // match groups by title not by UUID. This is usefull when trying to merge KDB trees since only entry retain their UUID after save and load
24+
KPKSynchronizationOptionDryRun = 1 << 2 // do not make any real changes, just run a dry run
2425
};
2526

2627
#endif /* KPKSynchronizationOptions_h */

KeePassKit/IO/KDB/KPKKdbTreeWriter.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ NS_ASSUME_NONNULL_BEGIN
3434

3535
- (instancetype)initWithTree:(KPKTree *)tree;
3636

37-
- (NSData *)treeDataWithHeaderHash:(NSData *)hash;
37+
- (NSData * _Nullable)treeDataWithHeaderHash:(NSData *)hash;
3838

3939
@end
4040

KeePassKit/KeePassKit.h

+2
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ FOUNDATION_EXPORT const unsigned char KeePassKitVersionString[];
6565

6666
#import <KeePassKit/KPKModificationRecording.h>
6767
#import <KeePassKit/KPKCommandEvaluationContext.h>
68+
#import <KeePassKit/KPKSynchronizationChangesStore.h>
6869

6970
#import <KeePassKit/KPKErrors.h>
7071

@@ -77,6 +78,7 @@ FOUNDATION_EXPORT const unsigned char KeePassKitVersionString[];
7778
#import <KeePassKit/NSString+KPKCommands.h>
7879
#import <KeePassKit/NSString+KPKEmpty.h>
7980
#import <KeePassKit/NSString+KPKXmlUtilities.h>
81+
#import <KeePassKit/NSString+KPKHexData.h>
8082
#import <KeePassKit/NSUUID+KPKAdditions.h>
8183
#import <KeePassKit/NSUIColor+KPKAdditions.h>
8284
#import <KeePassKit/NSUIImage+KPKAdditions.h>

KeePassKitTests/KPKTestOTP.m

+6-2
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ - (void)testHmacOTP {
124124
}
125125
}
126126

127-
- (void)testHmacOTPWithEmpyKey {
127+
- (void)testHmacOTPWithEmptyKey {
128128
KPKHmacOTPGenerator *generator = [[KPKHmacOTPGenerator alloc] init];
129129
NSString *string = generator.string;
130130
XCTAssertNotNil(string);
@@ -258,7 +258,7 @@ - (void)testHmacCounterUpdate {
258258

259259
}
260260

261-
- (void)testEntryOTPproperties {
261+
- (void)testEntryOTPProperties {
262262
KPKEntry *entry = [[KPKEntry alloc] init];
263263
KPKAttribute *otpAttribute = [[KPKAttribute alloc] initWithKey:kKPKAttributeKeyOTPOAuthURL value:@"This-is-no-valid-URL"];
264264
[entry addCustomAttribute:otpAttribute];
@@ -267,6 +267,10 @@ - (void)testEntryOTPproperties {
267267
XCTAssertFalse(entry.hasHmacOTP);
268268
}
269269

270+
- (void)testEntryOTPPropertiesUpdate {
271+
XCTFail();
272+
}
273+
270274
/*
271275
- (void)testTimeOTPEntry {
272276
KPKEntry *entry = [[KPKEntry alloc] init];

0 commit comments

Comments
 (0)