2017-03-15 14:17:41 +01:00
|
|
|
//
|
2018-04-02 23:02:47 +02:00
|
|
|
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
2017-03-15 14:17:41 +01:00
|
|
|
//
|
2015-12-07 03:31:43 +01:00
|
|
|
|
|
|
|
#import "TSYapDatabaseObject.h"
|
|
|
|
|
2016-10-14 23:00:29 +02:00
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
2015-12-07 03:31:43 +01:00
|
|
|
|
2017-05-09 15:30:54 +02:00
|
|
|
typedef NS_ENUM(NSUInteger, TSAttachmentType) {
|
|
|
|
TSAttachmentTypeDefault = 0,
|
|
|
|
TSAttachmentTypeVoiceMessage = 1,
|
|
|
|
};
|
|
|
|
|
2016-10-14 23:00:29 +02:00
|
|
|
@interface TSAttachment : TSYapDatabaseObject {
|
2015-12-07 03:31:43 +01:00
|
|
|
|
2016-10-14 23:00:29 +02:00
|
|
|
@protected
|
|
|
|
NSString *_contentType;
|
|
|
|
}
|
2015-12-07 03:31:43 +01:00
|
|
|
|
2017-03-13 22:33:54 +01:00
|
|
|
// 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.
|
2016-10-14 23:00:29 +02:00
|
|
|
@property (atomic, readwrite) UInt64 serverId;
|
|
|
|
@property (atomic, readwrite) NSData *encryptionKey;
|
|
|
|
@property (nonatomic, readonly) NSString *contentType;
|
2017-03-13 22:33:54 +01:00
|
|
|
@property (atomic, readwrite) BOOL isDownloaded;
|
2017-05-09 15:30:54 +02:00
|
|
|
@property (nonatomic) TSAttachmentType attachmentType;
|
2015-12-07 03:31:43 +01:00
|
|
|
|
2017-10-27 00:08:25 +02:00
|
|
|
// Though now required, may incorrectly be 0 on legacy attachments.
|
|
|
|
@property (nonatomic, readonly) UInt32 byteCount;
|
|
|
|
|
2017-05-15 15:53:16 +02:00
|
|
|
// Represents the "source" filename sent or received in the protos,
|
2017-05-11 21:25:41 +02:00
|
|
|
// not the filename on disk.
|
2017-05-15 15:53:16 +02:00
|
|
|
@property (nonatomic, readonly, nullable) NSString *sourceFilename;
|
2017-05-11 21:25:41 +02:00
|
|
|
|
2017-03-13 22:33:54 +01:00
|
|
|
// This constructor is used for new instances of TSAttachmentPointer,
|
|
|
|
// i.e. undownloaded incoming attachments.
|
2016-10-14 23:00:29 +02:00
|
|
|
- (instancetype)initWithServerId:(UInt64)serverId
|
|
|
|
encryptionKey:(NSData *)encryptionKey
|
2017-10-27 00:08:25 +02:00
|
|
|
byteCount:(UInt32)byteCount
|
2017-05-11 21:25:41 +02:00
|
|
|
contentType:(NSString *)contentType
|
2017-05-15 15:53:16 +02:00
|
|
|
sourceFilename:(nullable NSString *)sourceFilename;
|
2015-12-07 03:31:43 +01:00
|
|
|
|
2017-03-13 22:33:54 +01:00
|
|
|
// This constructor is used for new instances of TSAttachmentStream
|
|
|
|
// that represent new, un-uploaded outgoing attachments.
|
2017-10-27 00:08:25 +02:00
|
|
|
- (instancetype)initWithContentType:(NSString *)contentType
|
|
|
|
byteCount:(UInt32)byteCount
|
|
|
|
sourceFilename:(nullable NSString *)sourceFilename;
|
2017-03-13 22:33:54 +01:00
|
|
|
|
|
|
|
// This constructor is used for new instances of TSAttachmentStream
|
|
|
|
// that represent downloaded incoming attachments.
|
2017-03-15 16:32:58 +01:00
|
|
|
- (instancetype)initWithPointer:(TSAttachment *)pointer;
|
2017-03-13 22:33:54 +01:00
|
|
|
|
2017-03-28 23:47:43 +02:00
|
|
|
- (nullable instancetype)initWithCoder:(NSCoder *)coder;
|
|
|
|
|
2017-03-15 14:17:41 +01:00
|
|
|
- (void)upgradeFromAttachmentSchemaVersion:(NSUInteger)attachmentSchemaVersion;
|
|
|
|
|
2018-11-05 15:53:48 +01:00
|
|
|
@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;
|
2018-11-05 17:07:00 +01:00
|
|
|
@property (nonatomic, readonly) BOOL isVisualMedia;
|
2017-05-09 15:30:54 +02:00
|
|
|
|
2018-04-02 23:02:47 +02:00
|
|
|
+ (NSString *)emojiForMimeType:(NSString *)contentType;
|
|
|
|
|
2015-12-07 03:31:43 +01:00
|
|
|
@end
|
2016-10-14 23:00:29 +02:00
|
|
|
|
|
|
|
NS_ASSUME_NONNULL_END
|