mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Tidy files.
This commit is contained in:
parent
e6bc37d941
commit
dfc39b4a1d
|
@ -67,7 +67,7 @@ class ConversationConfigurationSyncOperation: OWSOperation {
|
|||
var dataSource: DataSource? = nil
|
||||
self.dbConnection.readWrite { transaction in
|
||||
let messageData: Data = syncMessage.buildPlainTextAttachmentData(with: transaction)
|
||||
dataSource = DataSourceValue.dataSource(withSyncMessageData: messageData, shouldDeleteOnDeallocation: true)
|
||||
dataSource = DataSourceValue.dataSource(withSyncMessageData: messageData)
|
||||
}
|
||||
|
||||
guard let attachmentDataSource = dataSource else {
|
||||
|
@ -88,7 +88,7 @@ class ConversationConfigurationSyncOperation: OWSOperation {
|
|||
var dataSource: DataSource? = nil
|
||||
self.dbConnection.read { transaction in
|
||||
let messageData: Data = syncMessage.buildPlainTextAttachmentData(with: transaction)
|
||||
dataSource = DataSourceValue.dataSource(withSyncMessageData: messageData, shouldDeleteOnDeallocation: true)
|
||||
dataSource = DataSourceValue.dataSource(withSyncMessageData: messageData)
|
||||
}
|
||||
|
||||
guard let attachmentDataSource = dataSource else {
|
||||
|
|
|
@ -50,8 +50,7 @@ import SignalMessaging
|
|||
|
||||
var dataSource: DataSource? = nil
|
||||
self.editingDatabaseConnection.readWrite { transaction in
|
||||
dataSource = DataSourceValue.dataSource(withSyncMessageData: syncContactsMessage.buildPlainTextAttachmentData(with: transaction),
|
||||
shouldDeleteOnDeallocation: true)
|
||||
dataSource = DataSourceValue.dataSource(withSyncMessageData: syncContactsMessage.buildPlainTextAttachmentData(with: transaction))
|
||||
}
|
||||
|
||||
guard let attachmentDataSource = dataSource else {
|
||||
|
|
|
@ -3099,9 +3099,8 @@ typedef enum : NSUInteger {
|
|||
}
|
||||
OWSAssertIsOnMainThread();
|
||||
|
||||
DataSource *_Nullable dataSource = [DataSourceValue dataSourceWithData:imageData
|
||||
utiType:dataUTI
|
||||
shouldDeleteOnDeallocation:YES];
|
||||
DataSource *_Nullable dataSource =
|
||||
[DataSourceValue dataSourceWithData:imageData utiType:dataUTI];
|
||||
[dataSource setSourceFilename:filename];
|
||||
SignalAttachment *attachment = [SignalAttachment attachmentWithDataSource:dataSource
|
||||
dataUTI:dataUTI
|
||||
|
@ -3940,8 +3939,7 @@ typedef enum : NSUInteger {
|
|||
|
||||
if (newGroupModel.groupImage) {
|
||||
NSData *data = UIImagePNGRepresentation(newGroupModel.groupImage);
|
||||
DataSource *_Nullable dataSource =
|
||||
[DataSourceValue dataSourceWithData:data fileExtension:@"png" shouldDeleteOnDeallocation:YES];
|
||||
DataSource *_Nullable dataSource = [DataSourceValue dataSourceWithData:data fileExtension:@"png"];
|
||||
[self.messageSender enqueueTemporaryAttachment:dataSource
|
||||
contentType:OWSMimeTypeImagePng
|
||||
inMessage:message
|
||||
|
@ -4433,8 +4431,7 @@ typedef enum : NSUInteger {
|
|||
TSOutgoingMessage *message;
|
||||
|
||||
if ([text lengthOfBytesUsingEncoding:NSUTF8StringEncoding] >= kOversizeTextMessageSizeThreshold) {
|
||||
DataSource *_Nullable dataSource =
|
||||
[DataSourceValue dataSourceWithOversizeText:text shouldDeleteOnDeallocation:YES];
|
||||
DataSource *_Nullable dataSource = [DataSourceValue dataSourceWithOversizeText:text];
|
||||
SignalAttachment *attachment =
|
||||
[SignalAttachment attachmentWithDataSource:dataSource dataUTI:kOversizeTextAttachmentUTI];
|
||||
// TODO we should redundantly send the first n chars in the body field so it can be viewed
|
||||
|
|
|
@ -3324,8 +3324,7 @@ typedef OWSContact * (^OWSContactBlock)(YapDatabaseReadWriteTransaction *transac
|
|||
{
|
||||
OWSMessageSender *messageSender = [Environment current].messageSender;
|
||||
NSString *message = [self randomOversizeText];
|
||||
DataSource *_Nullable dataSource =
|
||||
[DataSourceValue dataSourceWithOversizeText:message shouldDeleteOnDeallocation:YES];
|
||||
DataSource *_Nullable dataSource = [DataSourceValue dataSourceWithOversizeText:message];
|
||||
SignalAttachment *attachment =
|
||||
[SignalAttachment attachmentWithDataSource:dataSource dataUTI:kOversizeTextAttachmentUTI];
|
||||
[ThreadUtil sendMessageWithAttachment:attachment
|
||||
|
@ -3355,9 +3354,8 @@ typedef OWSContact * (^OWSContactBlock)(YapDatabaseReadWriteTransaction *transac
|
|||
+ (void)sendRandomAttachment:(TSThread *)thread uti:(NSString *)uti length:(NSUInteger)length
|
||||
{
|
||||
OWSMessageSender *messageSender = [Environment current].messageSender;
|
||||
DataSource *_Nullable dataSource = [DataSourceValue dataSourceWithData:[self createRandomNSDataOfSize:length]
|
||||
utiType:uti
|
||||
shouldDeleteOnDeallocation:YES];
|
||||
DataSource *_Nullable dataSource =
|
||||
[DataSourceValue dataSourceWithData:[self createRandomNSDataOfSize:length] utiType:uti];
|
||||
SignalAttachment *attachment =
|
||||
[SignalAttachment attachmentWithDataSource:dataSource dataUTI:uti imageQuality:TSImageQualityOriginal];
|
||||
|
||||
|
@ -4364,9 +4362,7 @@ typedef OWSContact * (^OWSContactBlock)(YapDatabaseReadWriteTransaction *transac
|
|||
NSString *utiType = (NSString *)kUTTypeData;
|
||||
const NSUInteger kDataLength = 32;
|
||||
DataSource *_Nullable dataSource =
|
||||
[DataSourceValue dataSourceWithData:[self createRandomNSDataOfSize:kDataLength]
|
||||
utiType:utiType
|
||||
shouldDeleteOnDeallocation:YES];
|
||||
[DataSourceValue dataSourceWithData:[self createRandomNSDataOfSize:kDataLength] utiType:utiType];
|
||||
[dataSource setSourceFilename:filename];
|
||||
SignalAttachment *attachment =
|
||||
[SignalAttachment attachmentWithDataSource:dataSource dataUTI:utiType imageQuality:TSImageQualityOriginal];
|
||||
|
|
|
@ -102,8 +102,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
__block DataSource *dataSource;
|
||||
[self.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) {
|
||||
dataSource = [DataSourceValue
|
||||
dataSourceWithSyncMessageData:[syncContactsMessage buildPlainTextAttachmentDataWithTransaction:transaction]
|
||||
shouldDeleteOnDeallocation:YES];
|
||||
dataSourceWithSyncMessageData:[syncContactsMessage
|
||||
buildPlainTextAttachmentDataWithTransaction:transaction]];
|
||||
}];
|
||||
|
||||
[self.messageSender enqueueTemporaryAttachment:dataSource
|
||||
|
@ -123,8 +123,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
__block DataSource *dataSource;
|
||||
[self.dbConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
|
||||
dataSource = [DataSourceValue
|
||||
dataSourceWithSyncMessageData:[syncGroupsMessage buildPlainTextAttachmentDataWithTransaction:transaction]
|
||||
shouldDeleteOnDeallocation:YES];
|
||||
dataSourceWithSyncMessageData:[syncGroupsMessage buildPlainTextAttachmentDataWithTransaction:transaction]];
|
||||
}];
|
||||
[self.messageSender enqueueTemporaryAttachment:dataSource
|
||||
contentType:OWSMimeTypeApplicationOctetStream
|
||||
|
|
|
@ -488,9 +488,8 @@ const NSUInteger kNewGroupViewControllerAvatarWidth = 68;
|
|||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||
if (model.groupImage) {
|
||||
NSData *data = UIImagePNGRepresentation(model.groupImage);
|
||||
DataSource *_Nullable dataSource = [DataSourceValue dataSourceWithData:data
|
||||
fileExtension:@"png"
|
||||
shouldDeleteOnDeallocation:YES];
|
||||
DataSource *_Nullable dataSource =
|
||||
[DataSourceValue dataSourceWithData:data fileExtension:@"png"];
|
||||
[self.messageSender enqueueTemporaryAttachment:dataSource
|
||||
contentType:OWSMimeTypeImagePng
|
||||
inMessage:message
|
||||
|
|
|
@ -519,7 +519,7 @@ public class SignalAttachment: NSObject {
|
|||
owsFail("\(logTag) Missing expected pasteboard data for UTI: \(dataUTI)")
|
||||
return nil
|
||||
}
|
||||
let dataSource = DataSourceValue.dataSource(with: data, utiType: dataUTI, shouldDeleteOnDeallocation: false)
|
||||
let dataSource = DataSourceValue.dataSource(with: data, utiType: dataUTI)
|
||||
// Pasted images _SHOULD _NOT_ be resized, if possible.
|
||||
return attachment(dataSource: dataSource, dataUTI: dataUTI, imageQuality: .medium)
|
||||
}
|
||||
|
@ -530,7 +530,7 @@ public class SignalAttachment: NSObject {
|
|||
owsFail("\(logTag) Missing expected pasteboard data for UTI: \(dataUTI)")
|
||||
return nil
|
||||
}
|
||||
let dataSource = DataSourceValue.dataSource(with: data, utiType: dataUTI, shouldDeleteOnDeallocation: false)
|
||||
let dataSource = DataSourceValue.dataSource(with: data, utiType: dataUTI)
|
||||
return videoAttachment(dataSource: dataSource, dataUTI: dataUTI)
|
||||
}
|
||||
}
|
||||
|
@ -540,7 +540,7 @@ public class SignalAttachment: NSObject {
|
|||
owsFail("\(logTag) Missing expected pasteboard data for UTI: \(dataUTI)")
|
||||
return nil
|
||||
}
|
||||
let dataSource = DataSourceValue.dataSource(with: data, utiType: dataUTI, shouldDeleteOnDeallocation: false)
|
||||
let dataSource = DataSourceValue.dataSource(with: data, utiType: dataUTI)
|
||||
return audioAttachment(dataSource: dataSource, dataUTI: dataUTI)
|
||||
}
|
||||
}
|
||||
|
@ -550,7 +550,7 @@ public class SignalAttachment: NSObject {
|
|||
owsFail("\(logTag) Missing expected pasteboard data for UTI: \(dataUTI)")
|
||||
return nil
|
||||
}
|
||||
let dataSource = DataSourceValue.dataSource(with: data, utiType: dataUTI, shouldDeleteOnDeallocation: false)
|
||||
let dataSource = DataSourceValue.dataSource(with: data, utiType: dataUTI)
|
||||
return genericAttachment(dataSource: dataSource, dataUTI: dataUTI)
|
||||
}
|
||||
|
||||
|
@ -723,7 +723,7 @@ public class SignalAttachment: NSObject {
|
|||
return attachment
|
||||
}
|
||||
|
||||
guard let dataSource = DataSourceValue.dataSource(with: jpgImageData, fileExtension: "jpg", shouldDeleteOnDeallocation: false) else {
|
||||
guard let dataSource = DataSourceValue.dataSource(with: jpgImageData, fileExtension: "jpg") else {
|
||||
attachment.error = .couldNotConvertToJpeg
|
||||
return attachment
|
||||
}
|
||||
|
@ -892,7 +892,7 @@ public class SignalAttachment: NSObject {
|
|||
}
|
||||
|
||||
if CGImageDestinationFinalize(destination) {
|
||||
guard let dataSource = DataSourceValue.dataSource(with: mutableData as Data, utiType: attachment.dataUTI, shouldDeleteOnDeallocation: false) else {
|
||||
guard let dataSource = DataSourceValue.dataSource(with: mutableData as Data, utiType: attachment.dataUTI) else {
|
||||
attachment.error = .couldNotRemoveMetadata
|
||||
return attachment
|
||||
}
|
||||
|
@ -1070,7 +1070,7 @@ public class SignalAttachment: NSObject {
|
|||
// NOTE: The attachment returned by this method may not be valid.
|
||||
// Check the attachment's error property.
|
||||
private class func oversizeTextAttachment(text: String?) -> SignalAttachment {
|
||||
let dataSource = DataSourceValue.dataSource(withOversizeText: text, shouldDeleteOnDeallocation: false)
|
||||
let dataSource = DataSourceValue.dataSource(withOversizeText: text)
|
||||
return newAttachment(dataSource: dataSource,
|
||||
dataUTI: kOversizeTextAttachmentUTI,
|
||||
validUTISet: nil,
|
||||
|
|
|
@ -139,8 +139,7 @@ NSString *const kOWSPrimaryStorageOWSContactsSyncingLastMessageKey
|
|||
|
||||
self.isRequestInFlight = YES;
|
||||
|
||||
DataSource *dataSource =
|
||||
[DataSourceValue dataSourceWithSyncMessageData:messageData shouldDeleteOnDeallocation:YES];
|
||||
DataSource *dataSource = [DataSourceValue dataSourceWithSyncMessageData:messageData];
|
||||
[self.messageSender enqueueTemporaryAttachment:dataSource
|
||||
contentType:OWSMimeTypeApplicationOctetStream
|
||||
inMessage:syncContactsMessage
|
||||
|
|
|
@ -657,8 +657,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
profileManager:self.profileManager];
|
||||
DataSource *dataSource = [DataSourceValue
|
||||
dataSourceWithSyncMessageData:[syncContactsMessage
|
||||
buildPlainTextAttachmentDataWithTransaction:transaction]
|
||||
shouldDeleteOnDeallocation:YES];
|
||||
buildPlainTextAttachmentDataWithTransaction:transaction]];
|
||||
[self.messageSender enqueueTemporaryAttachment:dataSource
|
||||
contentType:OWSMimeTypeApplicationOctetStream
|
||||
inMessage:syncContactsMessage
|
||||
|
@ -674,8 +673,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
OWSSyncGroupsMessage *syncGroupsMessage = [[OWSSyncGroupsMessage alloc] init];
|
||||
DataSource *dataSource = [DataSourceValue
|
||||
dataSourceWithSyncMessageData:[syncGroupsMessage
|
||||
buildPlainTextAttachmentDataWithTransaction:transaction]
|
||||
shouldDeleteOnDeallocation:YES];
|
||||
buildPlainTextAttachmentDataWithTransaction:transaction]];
|
||||
[self.messageSender enqueueTemporaryAttachment:dataSource
|
||||
contentType:OWSMimeTypeApplicationOctetStream
|
||||
inMessage:syncGroupsMessage
|
||||
|
@ -826,8 +824,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
if (gThread.groupModel.groupImage) {
|
||||
NSData *data = UIImagePNGRepresentation(gThread.groupModel.groupImage);
|
||||
DataSource *_Nullable dataSource =
|
||||
[DataSourceValue dataSourceWithData:data fileExtension:@"png" shouldDeleteOnDeallocation:YES];
|
||||
DataSource *_Nullable dataSource = [DataSourceValue dataSourceWithData:data fileExtension:@"png"];
|
||||
[self.messageSender enqueueTemporaryAttachment:dataSource
|
||||
contentType:OWSMimeTypeImagePng
|
||||
inMessage:message
|
||||
|
|
|
@ -37,19 +37,13 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
@interface DataSourceValue : DataSource
|
||||
|
||||
+ (nullable DataSource *)dataSourceWithData:(NSData *)data
|
||||
fileExtension:(NSString *)fileExtension
|
||||
shouldDeleteOnDeallocation:(BOOL)shouldDeleteOnDeallocation;
|
||||
+ (nullable DataSource *)dataSourceWithData:(NSData *)data fileExtension:(NSString *)fileExtension;
|
||||
|
||||
+ (nullable DataSource *)dataSourceWithData:(NSData *)data
|
||||
utiType:(NSString *)utiType
|
||||
shouldDeleteOnDeallocation:(BOOL)shouldDeleteOnDeallocation;
|
||||
+ (nullable DataSource *)dataSourceWithData:(NSData *)data utiType:(NSString *)utiType;
|
||||
|
||||
+ (nullable DataSource *)dataSourceWithOversizeText:(NSString *_Nullable)text
|
||||
shouldDeleteOnDeallocation:(BOOL)shouldDeleteOnDeallocation;
|
||||
+ (nullable DataSource *)dataSourceWithOversizeText:(NSString *_Nullable)text;
|
||||
|
||||
+ (DataSource *)dataSourceWithSyncMessageData:(NSData *)data
|
||||
shouldDeleteOnDeallocation:(BOOL)shouldDeleteOnDeallocation;
|
||||
+ (DataSource *)dataSourceWithSyncMessageData:(NSData *)data;
|
||||
|
||||
+ (DataSource *)emptyDataSource;
|
||||
|
||||
|
|
|
@ -123,7 +123,6 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
+ (nullable DataSource *)dataSourceWithData:(NSData *)data
|
||||
fileExtension:(NSString *)fileExtension
|
||||
shouldDeleteOnDeallocation:(BOOL)shouldDeleteOnDeallocation
|
||||
{
|
||||
OWSAssert(data);
|
||||
|
||||
|
@ -134,43 +133,35 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
DataSourceValue *instance = [DataSourceValue new];
|
||||
instance.dataValue = data;
|
||||
instance.fileExtension = fileExtension;
|
||||
instance.shouldDeleteOnDeallocation = shouldDeleteOnDeallocation;
|
||||
instance.shouldDeleteOnDeallocation = YES;
|
||||
return instance;
|
||||
}
|
||||
|
||||
+ (nullable DataSource *)dataSourceWithData:(NSData *)data
|
||||
utiType:(NSString *)utiType
|
||||
shouldDeleteOnDeallocation:(BOOL)shouldDeleteOnDeallocation
|
||||
{
|
||||
NSString *fileExtension = [MIMETypeUtil fileExtensionForUTIType:utiType];
|
||||
return [self dataSourceWithData:data
|
||||
fileExtension:fileExtension
|
||||
shouldDeleteOnDeallocation:shouldDeleteOnDeallocation];
|
||||
return [self dataSourceWithData:data fileExtension:fileExtension];
|
||||
}
|
||||
|
||||
+ (nullable DataSource *)dataSourceWithOversizeText:(NSString *_Nullable)text
|
||||
shouldDeleteOnDeallocation:(BOOL)shouldDeleteOnDeallocation
|
||||
{
|
||||
if (!text) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
NSData *data = [text.filterStringForDisplay dataUsingEncoding:NSUTF8StringEncoding];
|
||||
return [self dataSourceWithData:data
|
||||
fileExtension:kOversizeTextAttachmentFileExtension
|
||||
shouldDeleteOnDeallocation:shouldDeleteOnDeallocation];
|
||||
return [self dataSourceWithData:data fileExtension:kOversizeTextAttachmentFileExtension];
|
||||
}
|
||||
|
||||
+ (DataSource *)dataSourceWithSyncMessageData:(NSData *)data shouldDeleteOnDeallocation:(BOOL)shouldDeleteOnDeallocation
|
||||
+ (DataSource *)dataSourceWithSyncMessageData:(NSData *)data
|
||||
{
|
||||
return [self dataSourceWithData:data
|
||||
fileExtension:kSyncMessageFileExtension
|
||||
shouldDeleteOnDeallocation:shouldDeleteOnDeallocation];
|
||||
return [self dataSourceWithData:data fileExtension:kSyncMessageFileExtension];
|
||||
}
|
||||
|
||||
+ (DataSource *)emptyDataSource
|
||||
{
|
||||
return [self dataSourceWithData:[NSData new] fileExtension:@"bin" shouldDeleteOnDeallocation:YES];
|
||||
return [self dataSourceWithData:[NSData new] fileExtension:@"bin"];
|
||||
}
|
||||
|
||||
- (NSData *)data
|
||||
|
|
|
@ -634,8 +634,7 @@ public class ShareViewController: UIViewController, ShareViewDelegate, SAEFailed
|
|||
// NOTE: SharingThreadPickerViewController will try to unpack them
|
||||
// and send them as normal text messages if possible.
|
||||
let urlString = url.absoluteString
|
||||
return DataSourceValue.dataSource(withOversizeText: urlString,
|
||||
shouldDeleteOnDeallocation: true)
|
||||
return DataSourceValue.dataSource(withOversizeText: urlString)
|
||||
} else if UTTypeConformsTo(utiType as CFString, kUTTypeText) {
|
||||
// Share text as oversize text messages.
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue