Move filename property to TSAttachment.

// FREEBIE
pull/1/head
Matthew Chen 9 years ago
parent dd1591689c
commit f3ed7697db

@ -31,15 +31,20 @@ typedef NS_ENUM(NSUInteger, TSAttachmentType) {
@property (atomic, readwrite) BOOL isDownloaded; @property (atomic, readwrite) BOOL isDownloaded;
@property (nonatomic) TSAttachmentType attachmentType; @property (nonatomic) TSAttachmentType attachmentType;
// Represents the "nominal" filename sent or received in the protos,
// not the filename on disk.
@property (nonatomic, readonly, nullable) NSString *filename;
// This constructor is used for new instances of TSAttachmentPointer, // This constructor is used for new instances of TSAttachmentPointer,
// i.e. undownloaded incoming attachments. // i.e. undownloaded incoming attachments.
- (instancetype)initWithServerId:(UInt64)serverId - (instancetype)initWithServerId:(UInt64)serverId
encryptionKey:(NSData *)encryptionKey encryptionKey:(NSData *)encryptionKey
contentType:(NSString *)contentType; contentType:(NSString *)contentType
filename:(nullable NSString *)filename;
// This constructor is used for new instances of TSAttachmentStream // This constructor is used for new instances of TSAttachmentStream
// that represent new, un-uploaded outgoing attachments. // that represent new, un-uploaded outgoing attachments.
- (instancetype)initWithContentType:(NSString *)contentType; - (instancetype)initWithContentType:(NSString *)contentType filename:(nullable NSString *)filename;
// This constructor is used for new instances of TSAttachmentStream // This constructor is used for new instances of TSAttachmentStream
// that represent downloaded incoming attachments. // that represent downloaded incoming attachments.

@ -22,6 +22,7 @@ NSUInteger const TSAttachmentSchemaVersion = 3;
- (instancetype)initWithServerId:(UInt64)serverId - (instancetype)initWithServerId:(UInt64)serverId
encryptionKey:(NSData *)encryptionKey encryptionKey:(NSData *)encryptionKey
contentType:(NSString *)contentType contentType:(NSString *)contentType
filename:(nullable NSString *)filename
{ {
self = [super init]; self = [super init];
if (!self) { if (!self) {
@ -32,13 +33,14 @@ NSUInteger const TSAttachmentSchemaVersion = 3;
_encryptionKey = encryptionKey; _encryptionKey = encryptionKey;
_contentType = contentType; _contentType = contentType;
_attachmentSchemaVersion = TSAttachmentSchemaVersion; _attachmentSchemaVersion = TSAttachmentSchemaVersion;
_filename = filename;
return self; return self;
} }
// This constructor is used for new instances of TSAttachmentStream // This constructor is used for new instances of TSAttachmentStream
// that represent new, un-uploaded outgoing attachments. // that represent new, un-uploaded outgoing attachments.
- (instancetype)initWithContentType:(NSString *)contentType - (instancetype)initWithContentType:(NSString *)contentType filename:(nullable NSString *)filename
{ {
self = [super init]; self = [super init];
if (!self) { if (!self) {
@ -47,6 +49,7 @@ NSUInteger const TSAttachmentSchemaVersion = 3;
_contentType = contentType; _contentType = contentType;
_attachmentSchemaVersion = TSAttachmentSchemaVersion; _attachmentSchemaVersion = TSAttachmentSchemaVersion;
_filename = filename;
return self; return self;
} }
@ -64,6 +67,7 @@ NSUInteger const TSAttachmentSchemaVersion = 3;
_serverId = pointer.serverId; _serverId = pointer.serverId;
_encryptionKey = pointer.encryptionKey; _encryptionKey = pointer.encryptionKey;
_contentType = pointer.contentType; _contentType = pointer.contentType;
_filename = pointer.filename;
_attachmentSchemaVersion = TSAttachmentSchemaVersion; _attachmentSchemaVersion = TSAttachmentSchemaVersion;
return self; return self;

@ -28,7 +28,6 @@ typedef NS_ENUM(NSUInteger, TSAttachmentPointerState) {
attachmentType:(TSAttachmentType)attachmentType NS_DESIGNATED_INITIALIZER; attachmentType:(TSAttachmentType)attachmentType NS_DESIGNATED_INITIALIZER;
@property (nonatomic, readonly) NSString *relay; @property (nonatomic, readonly) NSString *relay;
@property (nonatomic, readonly, nullable) NSString *filename;
@property (atomic) TSAttachmentPointerState state; @property (atomic) TSAttachmentPointerState state;
// Though now required, `digest` may be null for pre-existing records or from // Though now required, `digest` may be null for pre-existing records or from

@ -33,7 +33,7 @@ NS_ASSUME_NONNULL_BEGIN
filename:(nullable NSString *)filename filename:(nullable NSString *)filename
attachmentType:(TSAttachmentType)attachmentType attachmentType:(TSAttachmentType)attachmentType
{ {
self = [super initWithServerId:serverId encryptionKey:key contentType:contentType]; self = [super initWithServerId:serverId encryptionKey:key contentType:contentType filename:filename];
if (!self) { if (!self) {
return self; return self;
} }
@ -41,7 +41,6 @@ NS_ASSUME_NONNULL_BEGIN
_digest = digest; _digest = digest;
_state = TSAttachmentPointerStateEnqueued; _state = TSAttachmentPointerStateEnqueued;
_relay = relay; _relay = relay;
_filename = filename;
self.attachmentType = attachmentType; self.attachmentType = attachmentType;
return self; return self;

@ -24,8 +24,6 @@ NS_ASSUME_NONNULL_BEGIN
// This only applies for attachments being uploaded. // This only applies for attachments being uploaded.
@property (atomic) BOOL isUploaded; @property (atomic) BOOL isUploaded;
@property (nonatomic, readonly, nullable) NSString *filename;
#if TARGET_OS_IPHONE #if TARGET_OS_IPHONE
- (nullable UIImage *)image; - (nullable UIImage *)image;
#endif #endif

@ -14,7 +14,7 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)initWithContentType:(NSString *)contentType filename:(NSString *)filename - (instancetype)initWithContentType:(NSString *)contentType filename:(NSString *)filename
{ {
self = [super initWithContentType:contentType]; self = [super initWithContentType:contentType filename:filename];
if (!self) { if (!self) {
return self; return self;
} }
@ -24,7 +24,6 @@ NS_ASSUME_NONNULL_BEGIN
// state, but this constructor is used only for new outgoing // state, but this constructor is used only for new outgoing
// attachments which haven't been uploaded yet. // attachments which haven't been uploaded yet.
_isUploaded = NO; _isUploaded = NO;
_filename = filename;
return self; return self;
} }
@ -43,7 +42,6 @@ NS_ASSUME_NONNULL_BEGIN
// state, but this constructor is used only for new incoming // state, but this constructor is used only for new incoming
// attachments which don't need to be uploaded. // attachments which don't need to be uploaded.
_isUploaded = YES; _isUploaded = YES;
_filename = pointer.filename;
self.attachmentType = pointer.attachmentType; self.attachmentType = pointer.attachmentType;
return self; return self;

Loading…
Cancel
Save