Merge branch 'charlesmchen/voiceMessagesUI'

pull/1/head
Matthew Chen 8 years ago
commit 85ccf2db78

@ -31,15 +31,20 @@ typedef NS_ENUM(NSUInteger, TSAttachmentType) {
@property (atomic, readwrite) BOOL isDownloaded;
@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,
// i.e. undownloaded incoming attachments.
- (instancetype)initWithServerId:(UInt64)serverId
encryptionKey:(NSData *)encryptionKey
contentType:(NSString *)contentType;
contentType:(NSString *)contentType
filename:(nullable NSString *)filename;
// This constructor is used for new instances of TSAttachmentStream
// 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
// that represent downloaded incoming attachments.

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

@ -28,7 +28,6 @@ typedef NS_ENUM(NSUInteger, TSAttachmentPointerState) {
attachmentType:(TSAttachmentType)attachmentType NS_DESIGNATED_INITIALIZER;
@property (nonatomic, readonly) NSString *relay;
@property (nonatomic, readonly, nullable) NSString *filename;
@property (atomic) TSAttachmentPointerState state;
// 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
attachmentType:(TSAttachmentType)attachmentType
{
self = [super initWithServerId:serverId encryptionKey:key contentType:contentType];
self = [super initWithServerId:serverId encryptionKey:key contentType:contentType filename:filename];
if (!self) {
return self;
}
@ -41,7 +41,6 @@ NS_ASSUME_NONNULL_BEGIN
_digest = digest;
_state = TSAttachmentPointerStateEnqueued;
_relay = relay;
_filename = filename;
self.attachmentType = attachmentType;
return self;

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

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

@ -516,6 +516,9 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
dispatch_async([OWSDispatch attachmentsQueue], ^{
TSAttachmentStream *attachmentStream =
[[TSAttachmentStream alloc] initWithContentType:contentType filename:filename];
if (message.isVoiceMessage) {
attachmentStream.attachmentType = TSAttachmentTypeVoiceMessage;
}
NSError *error;
[attachmentStream writeData:dataCopy error:&error];

Loading…
Cancel
Save