mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 16:22:21 +00:00
Fixed #20 Now using [NSDocument fileUrl]
This commit is contained in:
@@ -25,7 +25,6 @@ APPKIT_EXTERN NSString *const MPDocumentGroupKey;
|
|||||||
|
|
||||||
@property (assign, readonly) BOOL isProtected;
|
@property (assign, readonly) BOOL isProtected;
|
||||||
@property (assign, readonly) KdbGroup *root;
|
@property (assign, readonly) KdbGroup *root;
|
||||||
@property (nonatomic, retain, readonly) NSURL *file;
|
|
||||||
@property (nonatomic,retain) NSString *password;
|
@property (nonatomic,retain) NSString *password;
|
||||||
@property (nonatomic, retain) NSURL *key;
|
@property (nonatomic, retain) NSURL *key;
|
||||||
@property (assign, readonly) MPDatabaseVersion version;
|
@property (assign, readonly) MPDatabaseVersion version;
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey";
|
|||||||
|
|
||||||
@property (assign, nonatomic) BOOL isProtected;
|
@property (assign, nonatomic) BOOL isProtected;
|
||||||
@property (retain) KdbTree *tree;
|
@property (retain) KdbTree *tree;
|
||||||
@property (retain) NSURL *file;
|
|
||||||
@property (nonatomic, readonly) KdbPassword *passwordHash;
|
@property (nonatomic, readonly) KdbPassword *passwordHash;
|
||||||
@property (assign) MPDatabaseVersion version;
|
@property (assign) MPDatabaseVersion version;
|
||||||
@property (assign) BOOL isDecrypted;
|
@property (assign) BOOL isDecrypted;
|
||||||
@@ -80,10 +79,8 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey";
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)writeToURL:(NSURL *)url ofType:(NSString *)typeName error:(NSError **)outError {
|
- (BOOL)writeToURL:(NSURL *)url ofType:(NSString *)typeName error:(NSError **)outError {
|
||||||
self.file = url;
|
|
||||||
|
|
||||||
@try {
|
@try {
|
||||||
[KdbWriterFactory persist:self.tree file:[self.file path] withPassword:self.passwordHash];
|
[KdbWriterFactory persist:self.tree file:[url path] withPassword:self.passwordHash];
|
||||||
}
|
}
|
||||||
@catch (NSException *exception) {
|
@catch (NSException *exception) {
|
||||||
NSLog(@"%@", [exception description]);
|
NSLog(@"%@", [exception description]);
|
||||||
@@ -95,7 +92,6 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey";
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)readFromURL:(NSURL *)url ofType:(NSString *)typeName error:(NSError **)outError {
|
- (BOOL)readFromURL:(NSURL *)url ofType:(NSString *)typeName error:(NSError **)outError {
|
||||||
self.file = url;
|
|
||||||
self.isDecrypted = NO;
|
self.isDecrypted = NO;
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
@@ -105,10 +101,9 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey";
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)decryptWithPassword:(NSString *)password keyFileURL:(NSURL *)keyFileURL {
|
- (BOOL)decryptWithPassword:(NSString *)password keyFileURL:(NSURL *)keyFileURL {
|
||||||
self.key = keyFileURL;
|
|
||||||
self.password = password;
|
self.password = password;
|
||||||
@try {
|
@try {
|
||||||
self.tree = [KdbReaderFactory load:[self.file path] withPassword:self.passwordHash];
|
self.tree = [KdbReaderFactory load:[[self fileURL] path] withPassword:self.passwordHash];
|
||||||
}
|
}
|
||||||
@catch (NSException *exception) {
|
@catch (NSException *exception) {
|
||||||
NSLog(@"%@", [exception description]);
|
NSLog(@"%@", [exception description]);
|
||||||
|
|||||||
Reference in New Issue
Block a user