mirror of https://github.com/oxen-io/session-ios
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
106 lines
3.3 KiB
C
106 lines
3.3 KiB
C
7 years ago
|
//
|
||
|
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||
|
//
|
||
|
|
||
|
NS_ASSUME_NONNULL_BEGIN
|
||
|
|
||
7 years ago
|
extern NSString *const NSNotificationNameBackupStateDidChange;
|
||
7 years ago
|
|
||
7 years ago
|
typedef void (^OWSBackupBoolBlock)(BOOL value);
|
||
6 years ago
|
typedef void (^OWSBackupStringListBlock)(NSArray<NSString *> *value);
|
||
7 years ago
|
typedef void (^OWSBackupErrorBlock)(NSError *error);
|
||
|
|
||
7 years ago
|
typedef NS_ENUM(NSUInteger, OWSBackupState) {
|
||
7 years ago
|
// Has never backed up, not trying to backup yet.
|
||
|
OWSBackupState_Idle = 0,
|
||
|
// Backing up.
|
||
7 years ago
|
OWSBackupState_InProgress,
|
||
7 years ago
|
// Last backup failed.
|
||
7 years ago
|
OWSBackupState_Failed,
|
||
7 years ago
|
// Last backup succeeded.
|
||
|
OWSBackupState_Succeeded,
|
||
7 years ago
|
};
|
||
|
|
||
7 years ago
|
NSString *NSStringForBackupExportState(OWSBackupState state);
|
||
|
NSString *NSStringForBackupImportState(OWSBackupState state);
|
||
|
|
||
6 years ago
|
NSArray<NSString *> *MiscCollectionsToBackup(void);
|
||
|
|
||
6 years ago
|
NSError *OWSBackupErrorWithDescription(NSString *description);
|
||
|
|
||
6 years ago
|
@class AnyPromise;
|
||
7 years ago
|
@class OWSBackupIO;
|
||
7 years ago
|
@class TSAttachmentPointer;
|
||
7 years ago
|
@class TSThread;
|
||
6 years ago
|
@class YapDatabaseConnection;
|
||
7 years ago
|
|
||
7 years ago
|
@interface OWSBackup : NSObject
|
||
|
|
||
7 years ago
|
- (instancetype)init NS_DESIGNATED_INITIALIZER;
|
||
7 years ago
|
|
||
7 years ago
|
+ (instancetype)sharedManager NS_SWIFT_NAME(shared());
|
||
7 years ago
|
|
||
7 years ago
|
#pragma mark - Backup Export
|
||
|
|
||
6 years ago
|
@property (atomic, readonly) OWSBackupState backupExportState;
|
||
7 years ago
|
|
||
7 years ago
|
// If a "backup export" is in progress (see backupExportState),
|
||
|
// backupExportDescription _might_ contain a string that describes
|
||
|
// the current phase and backupExportProgress _might_ contain a
|
||
|
// 0.0<=x<=1.0 progress value that indicates progress within the
|
||
|
// current phase.
|
||
|
@property (nonatomic, readonly, nullable) NSString *backupExportDescription;
|
||
|
@property (nonatomic, readonly, nullable) NSNumber *backupExportProgress;
|
||
|
|
||
6 years ago
|
+ (BOOL)isFeatureEnabled;
|
||
|
|
||
7 years ago
|
- (BOOL)isBackupEnabled;
|
||
|
- (void)setIsBackupEnabled:(BOOL)value;
|
||
|
|
||
7 years ago
|
- (BOOL)hasPendingRestoreDecision;
|
||
|
- (void)setHasPendingRestoreDecision:(BOOL)value;
|
||
|
|
||
7 years ago
|
- (void)tryToExportBackup;
|
||
|
- (void)cancelExportBackup;
|
||
|
|
||
7 years ago
|
#pragma mark - Backup Import
|
||
|
|
||
6 years ago
|
@property (atomic, readonly) OWSBackupState backupImportState;
|
||
7 years ago
|
|
||
7 years ago
|
// If a "backup import" is in progress (see backupImportState),
|
||
|
// backupImportDescription _might_ contain a string that describes
|
||
|
// the current phase and backupImportProgress _might_ contain a
|
||
|
// 0.0<=x<=1.0 progress value that indicates progress within the
|
||
|
// current phase.
|
||
|
@property (nonatomic, readonly, nullable) NSString *backupImportDescription;
|
||
|
@property (nonatomic, readonly, nullable) NSNumber *backupImportProgress;
|
||
|
|
||
6 years ago
|
- (void)allRecipientIdsWithManifestsInCloud:(OWSBackupStringListBlock)success failure:(OWSBackupErrorBlock)failure;
|
||
|
|
||
6 years ago
|
- (AnyPromise *)ensureCloudKitAccess __attribute__((warn_unused_result));
|
||
6 years ago
|
|
||
7 years ago
|
- (void)checkCanImportBackup:(OWSBackupBoolBlock)success failure:(OWSBackupErrorBlock)failure;
|
||
|
|
||
|
// TODO: After a successful import, we should enable backup and
|
||
|
// preserve our PIN and/or private key so that restored users
|
||
|
// continues to backup.
|
||
|
- (void)tryToImportBackup;
|
||
7 years ago
|
- (void)cancelImportBackup;
|
||
7 years ago
|
|
||
7 years ago
|
- (void)logBackupRecords;
|
||
7 years ago
|
- (void)clearAllCloudKitRecords;
|
||
7 years ago
|
|
||
6 years ago
|
- (void)logBackupMetadataCache:(YapDatabaseConnection *)dbConnection;
|
||
|
|
||
7 years ago
|
#pragma mark - Lazy Restore
|
||
|
|
||
7 years ago
|
- (NSArray<NSString *> *)attachmentRecordNamesForLazyRestore;
|
||
7 years ago
|
|
||
|
- (NSArray<NSString *> *)attachmentIdsForLazyRestore;
|
||
|
|
||
6 years ago
|
- (AnyPromise *)lazyRestoreAttachment:(TSAttachmentPointer *)attachment backupIO:(OWSBackupIO *)backupIO __attribute__((warn_unused_result));
|
||
7 years ago
|
|
||
7 years ago
|
@end
|
||
|
|
||
|
NS_ASSUME_NONNULL_END
|