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.
		
		
		
		
		
			
		
			
	
	
		
			105 lines
		
	
	
		
			3.6 KiB
		
	
	
	
		
			C
		
	
		
		
			
		
	
	
			105 lines
		
	
	
		
			3.6 KiB
		
	
	
	
		
			C
		
	
| 
											5 years ago
										 | #import <SessionUtilitiesKit/DataSource.h>
 | ||
|  | #import <SessionMessagingKit/TSAttachment.h>
 | ||
| 
											5 years ago
										 | 
 | ||
|  | #if TARGET_OS_IPHONE
 | ||
|  | #import <UIKit/UIKit.h>
 | ||
|  | 
 | ||
|  | #endif
 | ||
|  | 
 | ||
|  | NS_ASSUME_NONNULL_BEGIN | ||
|  | 
 | ||
| 
											5 years ago
										 | @class SNProtoAttachmentPointer; | ||
| 
											5 years ago
										 | @class TSAttachmentPointer; | ||
|  | @class YapDatabaseReadWriteTransaction; | ||
|  | 
 | ||
|  | typedef void (^OWSThumbnailSuccess)(UIImage *image); | ||
|  | typedef void (^OWSThumbnailFailure)(void); | ||
|  | 
 | ||
| 
											5 years ago
										 | @interface TSAttachmentStream : TSAttachment | ||
| 
											5 years ago
										 | 
 | ||
|  | - (instancetype)init NS_UNAVAILABLE; | ||
|  | - (instancetype)initWithContentType:(NSString *)contentType | ||
|  |                           byteCount:(UInt32)byteCount | ||
|  |                      sourceFilename:(nullable NSString *)sourceFilename | ||
|  |                             caption:(nullable NSString *)caption | ||
|  |                      albumMessageId:(nullable NSString *)albumMessageId NS_DESIGNATED_INITIALIZER; | ||
|  | 
 | ||
|  | - (instancetype)initWithPointer:(TSAttachmentPointer *)pointer NS_DESIGNATED_INITIALIZER; | ||
|  | - (nullable instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER; | ||
|  | 
 | ||
|  | // Though now required, `digest` may be null for pre-existing records or from
 | ||
|  | // messages received from other clients
 | ||
|  | @property (nullable, nonatomic) NSData *digest; | ||
|  | 
 | ||
|  | // This only applies for attachments being uploaded.
 | ||
|  | @property (atomic) BOOL isUploaded; | ||
|  | 
 | ||
|  | @property (nonatomic, readonly) NSDate *creationTimestamp; | ||
|  | 
 | ||
|  | #if TARGET_OS_IPHONE
 | ||
|  | - (nullable NSData *)validStillImageData; | ||
|  | #endif
 | ||
|  | 
 | ||
|  | @property (nonatomic, readonly, nullable) UIImage *originalImage; | ||
|  | @property (nonatomic, readonly, nullable) NSString *originalFilePath; | ||
|  | @property (nonatomic, readonly, nullable) NSURL *originalMediaURL; | ||
|  | 
 | ||
|  | - (NSArray<NSString *> *)allThumbnailPaths; | ||
|  | 
 | ||
|  | + (BOOL)hasThumbnailForMimeType:(NSString *)contentType; | ||
|  | 
 | ||
| 
											5 years ago
										 | - (nullable NSData *)readDataFromFileAndReturnError:(NSError **)error; | ||
| 
											5 years ago
										 | - (BOOL)writeData:(NSData *)data error:(NSError **)error; | ||
|  | - (BOOL)writeDataSource:(DataSource *)dataSource; | ||
|  | 
 | ||
|  | + (void)deleteAttachments; | ||
|  | 
 | ||
|  | + (NSString *)attachmentsFolder; | ||
|  | + (NSString *)legacyAttachmentsDirPath; | ||
|  | + (NSString *)sharedDataAttachmentsDirPath; | ||
|  | 
 | ||
|  | - (BOOL)shouldHaveImageSize; | ||
|  | - (CGSize)imageSize; | ||
|  | 
 | ||
|  | - (CGFloat)audioDurationSeconds; | ||
|  | 
 | ||
|  | + (nullable NSError *)migrateToSharedData; | ||
|  | 
 | ||
|  | #pragma mark - Thumbnails
 | ||
|  | 
 | ||
|  | // On cache hit, the thumbnail will be returned synchronously and completion will never be invoked.
 | ||
|  | // On cache miss, nil will be returned and success will be invoked if thumbnail can be generated;
 | ||
|  | // otherwise failure will be invoked.
 | ||
|  | //
 | ||
|  | // success and failure are invoked async on main.
 | ||
|  | - (nullable UIImage *)thumbnailImageWithSizeHint:(CGSize)sizeHint | ||
|  |                                          success:(OWSThumbnailSuccess)success | ||
|  |                                          failure:(OWSThumbnailFailure)failure; | ||
|  | - (nullable UIImage *)thumbnailImageSmallWithSuccess:(OWSThumbnailSuccess)success failure:(OWSThumbnailFailure)failure; | ||
|  | - (nullable UIImage *)thumbnailImageMediumWithSuccess:(OWSThumbnailSuccess)success failure:(OWSThumbnailFailure)failure; | ||
|  | - (nullable UIImage *)thumbnailImageLargeWithSuccess:(OWSThumbnailSuccess)success failure:(OWSThumbnailFailure)failure; | ||
|  | - (nullable UIImage *)thumbnailImageSmallSync; | ||
|  | 
 | ||
|  | // This method should only be invoked by OWSThumbnailService.
 | ||
|  | - (NSString *)pathForThumbnailDimensionPoints:(NSUInteger)thumbnailDimensionPoints; | ||
|  | 
 | ||
|  | #pragma mark - Validation
 | ||
|  | 
 | ||
|  | @property (nonatomic, readonly) BOOL isValidImage; | ||
|  | @property (nonatomic, readonly) BOOL isValidVideo; | ||
|  | @property (nonatomic, readonly) BOOL isValidVisualMedia; | ||
|  | 
 | ||
|  | #pragma mark - Update With... Methods
 | ||
|  | 
 | ||
|  | - (nullable TSAttachmentStream *)cloneAsThumbnail; | ||
|  | 
 | ||
|  | #pragma mark - Protobuf
 | ||
|  | 
 | ||
| 
											5 years ago
										 | + (nullable SNProtoAttachmentPointer *)buildProtoForAttachmentId:(nullable NSString *)attachmentId; | ||
| 
											5 years ago
										 | 
 | ||
| 
											5 years ago
										 | - (nullable SNProtoAttachmentPointer *)buildProto; | ||
| 
											5 years ago
										 | 
 | ||
|  | @end | ||
|  | 
 | ||
|  | NS_ASSUME_NONNULL_END |