2017-03-15 14:17:41 +01:00
|
|
|
//
|
|
|
|
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
|
|
|
//
|
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
|
|
|
|
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;
|
2015-12-07 03:31:43 +01: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
|
|
|
|
contentType:(NSString *)contentType;
|
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.
|
|
|
|
- (instancetype)initWithContentType:(NSString *)contentType;
|
|
|
|
|
|
|
|
// 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-15 14:17:41 +01:00
|
|
|
- (void)upgradeFromAttachmentSchemaVersion:(NSUInteger)attachmentSchemaVersion;
|
|
|
|
|
2015-12-07 03:31:43 +01:00
|
|
|
@end
|
2016-10-14 23:00:29 +02:00
|
|
|
|
|
|
|
NS_ASSUME_NONNULL_END
|