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.
		
		
		
		
		
			
		
			
	
	
		
			104 lines
		
	
	
		
			4.0 KiB
		
	
	
	
		
			C
		
	
		
		
			
		
	
	
			104 lines
		
	
	
		
			4.0 KiB
		
	
	
	
		
			C
		
	
| 
											5 years ago
										 | #import <SessionUtilitiesKit/TSYapDatabaseObject.h>
 | ||
| 
											5 years ago
										 | #import <SessionMessagingKit/TSMessage.h>
 | ||
| 
											5 years ago
										 | 
 | ||
|  | NS_ASSUME_NONNULL_BEGIN | ||
|  | 
 | ||
|  | @class TSAttachmentPointer; | ||
|  | 
 | ||
|  | typedef NS_ENUM(NSUInteger, TSAttachmentType) { | ||
|  |     TSAttachmentTypeDefault = 0, | ||
|  |     TSAttachmentTypeVoiceMessage = 1, | ||
|  | }; | ||
|  | 
 | ||
|  | @interface TSAttachment : TSYapDatabaseObject { | ||
|  | 
 | ||
|  | @protected | ||
|  |     NSString *_contentType; | ||
|  | } | ||
|  | 
 | ||
|  | // TSAttachment is a base class for TSAttachmentPointer (a yet-to-be-downloaded
 | ||
|  | // incoming attachment) and TSAttachmentStream (an outgoing or already-downloaded
 | ||
|  | // incoming attachment).
 | ||
|  | //
 | ||
|  | // The attachmentSchemaVersion and serverId properties only apply to
 | ||
|  | // TSAttachmentPointer, which can be distinguished by the isDownloaded
 | ||
|  | // property.
 | ||
|  | @property (atomic, readwrite) UInt64 serverId; | ||
|  | @property (atomic, readwrite, nullable) NSData *encryptionKey; | ||
|  | @property (nonatomic, readonly) NSString *contentType; | ||
|  | @property (atomic, readwrite) BOOL isDownloaded; | ||
|  | @property (nonatomic) TSAttachmentType attachmentType; | ||
|  | @property (nonatomic) NSString *downloadURL; | ||
|  | 
 | ||
|  | // Though now required, may incorrectly be 0 on legacy attachments.
 | ||
|  | @property (nonatomic, readonly) UInt32 byteCount; | ||
|  | 
 | ||
|  | // Represents the "source" filename sent or received in the protos,
 | ||
|  | // not the filename on disk.
 | ||
|  | @property (nonatomic, readonly, nullable) NSString *sourceFilename; | ||
|  | 
 | ||
|  | #pragma mark - Media Album
 | ||
|  | 
 | ||
|  | @property (nonatomic, readonly, nullable) NSString *caption; | ||
|  | @property (nonatomic, nullable) NSString *albumMessageId; | ||
|  | 
 | ||
|  | #pragma mark -
 | ||
|  | 
 | ||
|  | // This constructor is used for new instances of TSAttachmentPointer,
 | ||
|  | // i.e. undownloaded incoming attachments.
 | ||
|  | - (instancetype)initWithServerId:(UInt64)serverId | ||
|  |                    encryptionKey:(nullable NSData *)encryptionKey | ||
|  |                        byteCount:(UInt32)byteCount | ||
|  |                      contentType:(NSString *)contentType | ||
|  |                   sourceFilename:(nullable NSString *)sourceFilename | ||
|  |                          caption:(nullable NSString *)caption | ||
|  |                   albumMessageId:(nullable NSString *)albumMessageId; | ||
|  | 
 | ||
|  | // This constructor is used for new instances of TSAttachmentPointer,
 | ||
|  | // i.e. undownloaded restoring attachments.
 | ||
|  | - (instancetype)initForRestoreWithUniqueId:(NSString *)uniqueId | ||
|  |                                contentType:(NSString *)contentType | ||
|  |                             sourceFilename:(nullable NSString *)sourceFilename | ||
|  |                                    caption:(nullable NSString *)caption | ||
|  |                             albumMessageId:(nullable NSString *)albumMessageId; | ||
|  | 
 | ||
|  | // This constructor is used for new instances of TSAttachmentStream
 | ||
|  | // that represent new, un-uploaded outgoing attachments.
 | ||
|  | - (instancetype)initWithContentType:(NSString *)contentType | ||
|  |                           byteCount:(UInt32)byteCount | ||
|  |                      sourceFilename:(nullable NSString *)sourceFilename | ||
|  |                             caption:(nullable NSString *)caption | ||
|  |                      albumMessageId:(nullable NSString *)albumMessageId; | ||
|  | 
 | ||
|  | // This constructor is used for new instances of TSAttachmentStream
 | ||
|  | // that represent downloaded incoming attachments.
 | ||
|  | - (instancetype)initWithPointer:(TSAttachmentPointer *)pointer; | ||
|  | 
 | ||
|  | - (nullable instancetype)initWithCoder:(NSCoder *)coder; | ||
|  | 
 | ||
|  | - (void)upgradeFromAttachmentSchemaVersion:(NSUInteger)attachmentSchemaVersion; | ||
|  | 
 | ||
|  | @property (nonatomic, readonly) BOOL isAnimated; | ||
|  | @property (nonatomic, readonly) BOOL isImage; | ||
|  | @property (nonatomic, readonly) BOOL isVideo; | ||
|  | @property (nonatomic, readonly) BOOL isAudio; | ||
|  | @property (nonatomic, readonly) BOOL isVoiceMessage; | ||
|  | @property (nonatomic, readonly) BOOL isVisualMedia; | ||
|  | @property (nonatomic, readonly) BOOL isOversizeText; | ||
|  | 
 | ||
|  | + (NSString *)emojiForMimeType:(NSString *)contentType; | ||
|  | 
 | ||
| 
											5 years ago
										 | #pragma mark - Media Album
 | ||
|  | 
 | ||
|  | - (nullable TSMessage *)fetchAlbumMessageWithTransaction:(YapDatabaseReadTransaction *)transaction; | ||
|  | 
 | ||
|  | // `migrateAlbumMessageId` is only used in the migration to the new multi-attachment message scheme,
 | ||
|  | // and shouldn't be used as a general purpose setter. Instead, `albumMessageId` should be passed as
 | ||
|  | // an initializer param.
 | ||
|  | - (void)migrateAlbumMessageId:(NSString *)albumMesssageId; | ||
|  | 
 | ||
|  | 
 | ||
| 
											5 years ago
										 | @end | ||
|  | 
 | ||
|  | NS_ASSUME_NONNULL_END |