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.
		
		
		
		
		
			
		
			
	
	
		
			93 lines
		
	
	
		
			2.9 KiB
		
	
	
	
		
			C
		
	
		
		
			
		
	
	
			93 lines
		
	
	
		
			2.9 KiB
		
	
	
	
		
			C
		
	
| 
								 
											8 years ago
										 
									 | 
							
								//
							 | 
						||
| 
								 | 
							
								//  Copyright (c) 2018 Open Whisper Systems. All rights reserved.
							 | 
						||
| 
								 | 
							
								//
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								#import "TSYapDatabaseObject.h"
							 | 
						||
| 
								 
											5 years ago
										 
									 | 
							
								#import <SessionMessagingKit/OWSBackupFragment.h>
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								NS_ASSUME_NONNULL_BEGIN
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								extern NSString *const kOWSBackup_ManifestKey_DatabaseFiles;
							 | 
						||
| 
								 | 
							
								extern NSString *const kOWSBackup_ManifestKey_AttachmentFiles;
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								extern NSString *const kOWSBackup_ManifestKey_RecordName;
							 | 
						||
| 
								 | 
							
								extern NSString *const kOWSBackup_ManifestKey_EncryptionKey;
							 | 
						||
| 
								 | 
							
								extern NSString *const kOWSBackup_ManifestKey_RelativeFilePath;
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								extern NSString *const kOWSBackup_ManifestKey_AttachmentId;
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								extern NSString *const kOWSBackup_ManifestKey_DataSize;
							 | 
						||
| 
								 
											7 years ago
										 
									 | 
							
								extern NSString *const kOWSBackup_ManifestKey_LocalProfileAvatar;
							 | 
						||
| 
								 | 
							
								extern NSString *const kOWSBackup_ManifestKey_LocalProfileName;
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 
											7 years ago
										 
									 | 
							
								@class AnyPromise;
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								@class OWSBackupIO;
							 | 
						||
| 
								 | 
							
								@class OWSBackupJob;
							 | 
						||
| 
								 | 
							
								@class OWSBackupManifestContents;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								typedef void (^OWSBackupJobBoolCompletion)(BOOL success);
							 | 
						||
| 
								 | 
							
								typedef void (^OWSBackupJobCompletion)(NSError *_Nullable error);
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								typedef void (^OWSBackupJobManifestSuccess)(OWSBackupManifestContents *manifest);
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								typedef void (^OWSBackupJobManifestFailure)(NSError *error);
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								@interface OWSBackupManifestContents : NSObject
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								@property (nonatomic) NSArray<OWSBackupFragment *> *databaseItems;
							 | 
						||
| 
								 | 
							
								@property (nonatomic) NSArray<OWSBackupFragment *> *attachmentsItems;
							 | 
						||
| 
								 
											7 years ago
										 
									 | 
							
								@property (nonatomic, nullable) OWSBackupFragment *localProfileAvatarItem;
							 | 
						||
| 
								 | 
							
								@property (nonatomic, nullable) NSString *localProfileName;
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 | 
							
								@end
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#pragma mark -
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 | 
							
								@protocol OWSBackupJobDelegate <NSObject>
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								- (nullable NSData *)backupEncryptionKey;
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 | 
							
								// Either backupJobDidSucceed:... or backupJobDidFail:... will
							 | 
						||
| 
								 | 
							
								// be called exactly once on the main thread UNLESS:
							 | 
						||
| 
								 | 
							
								//
							 | 
						||
| 
								 | 
							
								// * The job was never started.
							 | 
						||
| 
								 | 
							
								// * The job was cancelled.
							 | 
						||
| 
								 | 
							
								- (void)backupJobDidSucceed:(OWSBackupJob *)backupJob;
							 | 
						||
| 
								 | 
							
								- (void)backupJobDidFail:(OWSBackupJob *)backupJob error:(NSError *)error;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								- (void)backupJobDidUpdate:(OWSBackupJob *)backupJob
							 | 
						||
| 
								 | 
							
								               description:(nullable NSString *)description
							 | 
						||
| 
								 | 
							
								                  progress:(nullable NSNumber *)progress;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								@end
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#pragma mark -
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								@interface OWSBackupJob : NSObject
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								@property (nonatomic, weak, readonly) id<OWSBackupJobDelegate> delegate;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 
											7 years ago
										 
									 | 
							
								@property (nonatomic, readonly) NSString *recipientId;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								// Indicates that the backup succeeded, failed or was cancelled.
							 | 
						||
| 
								 | 
							
								@property (atomic, readonly) BOOL isComplete;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								@property (nonatomic, readonly) NSString *jobTempDirPath;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								- (instancetype)init NS_UNAVAILABLE;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 
											7 years ago
										 
									 | 
							
								- (instancetype)initWithDelegate:(id<OWSBackupJobDelegate>)delegate recipientId:(NSString *)recipientId;
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 | 
							
								#pragma mark - Private
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								- (BOOL)ensureJobTempDir;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								- (void)cancel;
							 | 
						||
| 
								 | 
							
								- (void)succeed;
							 | 
						||
| 
								 | 
							
								- (void)failWithErrorDescription:(NSString *)description;
							 | 
						||
| 
								 | 
							
								- (void)failWithError:(NSError *)error;
							 | 
						||
| 
								 | 
							
								- (void)updateProgressWithDescription:(nullable NSString *)description progress:(nullable NSNumber *)progress;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								#pragma mark - Manifest
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 
											7 years ago
										 
									 | 
							
								- (AnyPromise *)downloadAndProcessManifestWithBackupIO:(OWSBackupIO *)backupIO __attribute__((warn_unused_result));
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								@end
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								NS_ASSUME_NONNULL_END
							 |