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
		
	
| 
											8 years ago
										 | //
 | ||
|  | //  Copyright (c) 2018 Open Whisper Systems. All rights reserved.
 | ||
|  | //
 | ||
|  | 
 | ||
|  | NS_ASSUME_NONNULL_BEGIN | ||
|  | 
 | ||
| 
											8 years ago
										 | extern NSString *const NSNotificationNameBackupStateDidChange; | ||
| 
											8 years ago
										 | 
 | ||
| 
											8 years ago
										 | typedef void (^OWSBackupBoolBlock)(BOOL value); | ||
| 
											7 years ago
										 | typedef void (^OWSBackupStringListBlock)(NSArray<NSString *> *value); | ||
| 
											8 years ago
										 | typedef void (^OWSBackupErrorBlock)(NSError *error); | ||
|  | 
 | ||
| 
											8 years ago
										 | typedef NS_ENUM(NSUInteger, OWSBackupState) { | ||
| 
											8 years ago
										 |     // Has never backed up, not trying to backup yet.
 | ||
|  |     OWSBackupState_Idle = 0, | ||
|  |     // Backing up.
 | ||
| 
											8 years ago
										 |     OWSBackupState_InProgress, | ||
| 
											8 years ago
										 |     // Last backup failed.
 | ||
| 
											8 years ago
										 |     OWSBackupState_Failed, | ||
| 
											8 years ago
										 |     // Last backup succeeded.
 | ||
|  |     OWSBackupState_Succeeded, | ||
| 
											8 years ago
										 | }; | ||
|  | 
 | ||
| 
											7 years ago
										 | NSString *NSStringForBackupExportState(OWSBackupState state); | ||
|  | NSString *NSStringForBackupImportState(OWSBackupState state); | ||
|  | 
 | ||
| 
											7 years ago
										 | NSArray<NSString *> *MiscCollectionsToBackup(void); | ||
|  | 
 | ||
| 
											7 years ago
										 | NSError *OWSBackupErrorWithDescription(NSString *description); | ||
|  | 
 | ||
| 
											7 years ago
										 | @class AnyPromise; | ||
| 
											8 years ago
										 | @class OWSBackupIO; | ||
| 
											7 years ago
										 | @class TSAttachmentPointer; | ||
| 
											8 years ago
										 | @class TSThread; | ||
| 
											7 years ago
										 | @class YapDatabaseConnection; | ||
| 
											8 years ago
										 | 
 | ||
| 
											8 years ago
										 | @interface OWSBackup : NSObject | ||
|  | 
 | ||
| 
											7 years ago
										 | - (instancetype)init NS_DESIGNATED_INITIALIZER; | ||
| 
											8 years ago
										 | 
 | ||
| 
											8 years ago
										 | + (instancetype)sharedManager NS_SWIFT_NAME(shared()); | ||
| 
											8 years ago
										 | 
 | ||
| 
											8 years ago
										 | #pragma mark - Backup Export
 | ||
|  | 
 | ||
| 
											7 years ago
										 | @property (atomic, readonly) OWSBackupState backupExportState; | ||
| 
											8 years ago
										 | 
 | ||
| 
											8 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; | ||
|  | 
 | ||
| 
											7 years ago
										 | + (BOOL)isFeatureEnabled; | ||
|  | 
 | ||
| 
											8 years ago
										 | - (BOOL)isBackupEnabled; | ||
|  | - (void)setIsBackupEnabled:(BOOL)value; | ||
|  | 
 | ||
| 
											7 years ago
										 | - (BOOL)hasPendingRestoreDecision; | ||
|  | - (void)setHasPendingRestoreDecision:(BOOL)value; | ||
|  | 
 | ||
| 
											8 years ago
										 | - (void)tryToExportBackup; | ||
|  | - (void)cancelExportBackup; | ||
|  | 
 | ||
| 
											8 years ago
										 | #pragma mark - Backup Import
 | ||
|  | 
 | ||
| 
											7 years ago
										 | @property (atomic, readonly) OWSBackupState backupImportState; | ||
| 
											8 years ago
										 | 
 | ||
| 
											8 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; | ||
|  | 
 | ||
| 
											7 years ago
										 | - (void)allRecipientIdsWithManifestsInCloud:(OWSBackupStringListBlock)success failure:(OWSBackupErrorBlock)failure; | ||
|  | 
 | ||
| 
											7 years ago
										 | - (AnyPromise *)ensureCloudKitAccess __attribute__((warn_unused_result)); | ||
| 
											7 years ago
										 | 
 | ||
| 
											8 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; | ||
| 
											8 years ago
										 | - (void)cancelImportBackup; | ||
| 
											8 years ago
										 | 
 | ||
| 
											8 years ago
										 | - (void)logBackupRecords; | ||
| 
											8 years ago
										 | - (void)clearAllCloudKitRecords; | ||
| 
											8 years ago
										 | 
 | ||
| 
											7 years ago
										 | - (void)logBackupMetadataCache:(YapDatabaseConnection *)dbConnection; | ||
|  | 
 | ||
| 
											8 years ago
										 | #pragma mark - Lazy Restore
 | ||
|  | 
 | ||
| 
											8 years ago
										 | - (NSArray<NSString *> *)attachmentRecordNamesForLazyRestore; | ||
| 
											8 years ago
										 | 
 | ||
|  | - (NSArray<NSString *> *)attachmentIdsForLazyRestore; | ||
|  | 
 | ||
| 
											7 years ago
										 | - (AnyPromise *)lazyRestoreAttachment:(TSAttachmentPointer *)attachment backupIO:(OWSBackupIO *)backupIO __attribute__((warn_unused_result)); | ||
| 
											8 years ago
										 | 
 | ||
| 
											8 years ago
										 | @end | ||
|  | 
 | ||
|  | NS_ASSUME_NONNULL_END |