mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
86 lines
2.2 KiB
Objective-C
86 lines
2.2 KiB
Objective-C
//
|
|
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
|
//
|
|
|
|
#import <YapDatabase/YapDatabaseConnection.h>
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
extern NSString *const StorageIsReadyNotification;
|
|
|
|
@class YapDatabaseExtension;
|
|
|
|
@protocol OWSDatabaseConnectionDelegate <NSObject>
|
|
|
|
- (BOOL)areAllRegistrationsComplete;
|
|
|
|
@end
|
|
|
|
#pragma mark -
|
|
|
|
@interface OWSDatabaseConnection : YapDatabaseConnection
|
|
|
|
@property (atomic, weak) id<OWSDatabaseConnectionDelegate> delegate;
|
|
|
|
#ifdef DEBUG
|
|
@property (atomic) BOOL canWriteBeforeStorageReady;
|
|
#endif
|
|
|
|
- (instancetype)init NS_UNAVAILABLE;
|
|
- (instancetype)initWithDatabase:(YapDatabase *)database
|
|
delegate:(id<OWSDatabaseConnectionDelegate>)delegate NS_DESIGNATED_INITIALIZER;
|
|
|
|
@end
|
|
|
|
#pragma mark -
|
|
|
|
@interface OWSStorage : NSObject
|
|
|
|
- (instancetype)init NS_UNAVAILABLE;
|
|
- (instancetype)initStorage NS_DESIGNATED_INITIALIZER;
|
|
|
|
// Returns YES if _ALL_ storage classes have completed both their
|
|
// sync _AND_ async view registrations.
|
|
+ (BOOL)isStorageReady;
|
|
|
|
// This object can be used to filter database notifications.
|
|
@property (nonatomic, readonly, nullable) id dbNotificationObject;
|
|
|
|
+ (void)setupStorage;
|
|
|
|
+ (void)resetAllStorage;
|
|
|
|
// TODO: Deprecate?
|
|
- (nullable YapDatabaseConnection *)newDatabaseConnection;
|
|
|
|
#ifdef DEBUG
|
|
- (BOOL)registerExtension:(YapDatabaseExtension *)extension withName:(NSString *)extensionName;
|
|
#endif
|
|
- (void)asyncRegisterExtension:(YapDatabaseExtension *)extension withName:(NSString *)extensionName;
|
|
- (nullable id)registeredExtension:(NSString *)extensionName;
|
|
|
|
- (unsigned long long)databaseFileSize;
|
|
|
|
- (YapDatabaseConnection *)registrationConnection;
|
|
|
|
#pragma mark - Password
|
|
|
|
/**
|
|
* Returns NO if:
|
|
*
|
|
* - Keychain is locked because device has just been restarted.
|
|
* - Password could not be retrieved because of a keychain error.
|
|
*/
|
|
+ (BOOL)isDatabasePasswordAccessible;
|
|
|
|
+ (nullable NSData *)tryToLoadDatabasePassword:(NSError **)errorHandle;
|
|
|
|
+ (nullable NSData *)tryToLoadDatabaseSalt:(NSError **)errorHandle;
|
|
+ (void)storeDatabaseSalt:(NSData *)saltData;
|
|
|
|
+ (nullable NSData *)tryToLoadDatabaseKeySpec:(NSError **)errorHandle;
|
|
+ (void)storeDatabaseKeySpec:(NSData *)keySpecData;
|
|
|
|
@end
|
|
|
|
NS_ASSUME_NONNULL_END
|