Skip to content

Commit

Permalink
Merge branch 'release/0.21.0/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
pixlwave committed Jan 25, 2022
2 parents 650dba8 + 3a692b0 commit f9f71bd
Show file tree
Hide file tree
Showing 82 changed files with 3,208 additions and 718 deletions.
20 changes: 20 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
## Changes in 0.21.0 (2022-01-25)

✨ Features

- MXRoomSummaryStore & MXRoomListDataManager: Implementation with Core Data. ([#4384](https://github.com/vector-im/element-ios/issues/4384))
- Allow editing poll start events. ([#5114](https://github.com/vector-im/element-ios/issues/5114))
- Added static location sharing sending and rendering support. ([#5298](https://github.com/vector-im/element-ios/issues/5298))

🙌 Improvements

- MXCoreDataRoomSummaryStore: Use nested contexts to better manage main context updates. ([#5412](https://github.com/vector-im/element-ios/issues/5412))
- Only count joined rooms when profiling sync performance. ([#5429](https://github.com/vector-im/element-ios/issues/5429))

🐛 Bugfixes

- Fixes DTMF(dial tones) during voice calls. ([#5375](https://github.com/vector-im/element-ios/issues/5375))
- MXCoreDataRoomListDataFetcher: Update fetchRequest if properties changed before fetching the first page. ([#5377](https://github.com/vector-im/element-ios/issues/5377))
- MXSession: Fix remove room race case. ([#5412](https://github.com/vector-im/element-ios/issues/5412))


## Changes in 0.20.16 (2022-01-11)

🙌 Improvements
Expand Down
12 changes: 7 additions & 5 deletions MatrixSDK.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = "MatrixSDK"
s.version = "0.20.16"
s.version = "0.21.0"
s.summary = "The iOS SDK to build apps compatible with Matrix (https://www.matrix.org)"

s.description = <<-DESC
Expand All @@ -22,17 +22,19 @@ Pod::Spec.new do |s|
s.requires_arc = true
s.swift_versions = ['5.1', '5.2']

s.ios.deployment_target = "9.0"
s.osx.deployment_target = "10.10"
s.ios.deployment_target = "10.0"
s.osx.deployment_target = "10.12"

s.default_subspec = 'Core'
s.subspec 'Core' do |ss|
ss.ios.deployment_target = "9.0"
ss.osx.deployment_target = "10.10"
ss.ios.deployment_target = "10.0"
ss.osx.deployment_target = "10.12"

ss.source_files = "MatrixSDK", "MatrixSDK/**/*.{h,m}", "MatrixSDK/**/*.{swift}"
ss.osx.exclude_files = "MatrixSDK/VoIP/MXiOSAudioOutputRoute*.swift"
ss.private_header_files = ['MatrixSDK/MatrixSDKSwiftHeader.h', "MatrixSDK/**/*_Private.h"]
ss.resources = "MatrixSDK/**/*.{xcdatamodeld}"
ss.frameworks = "CoreData"

ss.dependency 'AFNetworking', '~> 4.0.0'
ss.dependency 'GZIP', '~> 1.3.0'
Expand Down
209 changes: 194 additions & 15 deletions MatrixSDK.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions MatrixSDK/Aggregations/MXAggregations.m
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ - (void)registerListener
[self.mxSession listenToEvents:^(MXEvent *event, MXTimelineDirection direction, id customObject) {

switch (event.eventType) {
case MXEventTypePollStart:
case MXEventTypeRoomMessage:
if (direction == MXTimelineDirectionForwards
&& [event.relatesTo.relationType isEqualToString:MXEventRelationTypeReplace])
Expand Down
2 changes: 1 addition & 1 deletion MatrixSDK/Background/MXBackgroundPushRulesManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ import Foundation
private var permissionConditionChecker: MXPushRuleSenderNotificationPermissionConditionChecker

/// Initializer.
/// - Parameter restClient: Rest client to fetch initial push rules.
/// - Parameter credentials: Credentials to use when fetching initial push rules.
public init(withCredentials credentials: MXCredentials) {
self.credentials = credentials
eventMatchConditionChecker = MXPushRuleEventMatchConditionChecker()
Expand Down
32 changes: 29 additions & 3 deletions MatrixSDK/Background/MXBackgroundStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -259,19 +259,45 @@ class MXBackgroundStore: NSObject, MXStore {
return []
}

// MARK: - MXRoomSummaryStore
var roomSummaryStore: MXRoomSummaryStore {
return self
}

}

// MARK: - MXRoomSummaryStore

extension MXBackgroundStore: MXRoomSummaryStore {

var rooms: [String] {
return []
}

func storeSummary(forRoom roomId: String, summary: MXRoomSummaryProtocol) {
var countOfRooms: UInt {
return 0
}

func storeSummary(_ summary: MXRoomSummaryProtocol) {

}

// Fetch real soom summary
func summary(ofRoom roomId: String) -> MXRoomSummaryProtocol? {
return fileStore.summary(ofRoom: roomId)
return fileStore.roomSummaryStore.summary(ofRoom: roomId)
}

func removeSummary(ofRoom roomId: String) {

}

func removeAllSummaries() {

}

func fetchAllSummaries(_ completion: @escaping ([MXRoomSummaryProtocol]) -> Void) {
DispatchQueue.main.async {
completion([])
}
}

}
2 changes: 1 addition & 1 deletion MatrixSDK/Background/MXBackgroundSyncService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public enum MXBackgroundSyncServiceError: Error {
/// - Parameter roomId: The room identifier to fetch.
/// - Returns: Summary of room.
public func roomSummary(forRoomId roomId: String) -> MXRoomSummaryProtocol? {
let summary = store.summary(ofRoom: roomId)
let summary = store.roomSummaryStore.summary(ofRoom: roomId)
return syncResponseStoreManager.roomSummary(forRoomId: roomId, using: summary)
}

Expand Down
6 changes: 6 additions & 0 deletions MatrixSDK/Crypto/Data/Trust/MXUsersTrustLevelSummary.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

#import <Foundation/Foundation.h>

@class MXUsersTrustLevelSummaryMO;

NS_ASSUME_NONNULL_BEGIN

/**
Expand All @@ -31,6 +33,10 @@ NS_ASSUME_NONNULL_BEGIN

- (instancetype)initWithTrustedUsersProgress:(NSProgress*)trustedUsersProgress andTrustedDevicesProgress:(NSProgress*)trustedDevicesProgress;

#pragma mark - CoreData Model

- (instancetype)initWithManagedObject:(MXUsersTrustLevelSummaryMO *)model;

@end

NS_ASSUME_NONNULL_END
15 changes: 15 additions & 0 deletions MatrixSDK/Crypto/Data/Trust/MXUsersTrustLevelSummary.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

#import "MXUsersTrustLevelSummary.h"
#import "MatrixSDKSwiftHeader.h"

@interface MXUsersTrustLevelSummary()

Expand All @@ -36,6 +37,20 @@ - (instancetype)initWithTrustedUsersProgress:(NSProgress*)trustedUsersProgress a
return self;
}

#pragma mark - CoreData Model

- (instancetype)initWithManagedObject:(MXUsersTrustLevelSummaryMO *)model
{
if (self = [super init])
{
self.trustedUsersProgress = [NSProgress progressWithTotalUnitCount:model.s_usersCount];
self.trustedUsersProgress.completedUnitCount = model.s_trustedUsersCount;

self.trustedDevicesProgress = [NSProgress progressWithTotalUnitCount:model.s_devicesCount];
self.trustedDevicesProgress.completedUnitCount = model.s_trustedDevicesCount;
}
return self;
}

#pragma mark - NSCoding

Expand Down
7 changes: 7 additions & 0 deletions MatrixSDK/Data/MXRoom.h
Original file line number Diff line number Diff line change
Expand Up @@ -950,6 +950,13 @@ FOUNDATION_EXPORT NSInteger const kMXRoomAlreadyJoinedErrorCode;
success:(void (^)(NSString *eventId))success
failure:(void (^)(NSError *error))failure;

- (MXHTTPOperation *)sendPollUpdateForEvent:(MXEvent *)pollStartEvent
oldContent:(MXEventContentPollStart *)oldContent
newContent:(MXEventContentPollStart *)newContent
localEcho:(MXEvent **)localEcho
success:(void (^)(NSString *))success
failure:(void (^)(NSError *))failure;

#pragma mark - Location sharing

- (MXHTTPOperation *)sendLocationWithLatitude:(double)latitude
Expand Down
65 changes: 40 additions & 25 deletions MatrixSDK/Data/MXRoom.m
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,6 @@ + (id)loadRoomFromStore:(id<MXStore>)store withRoomId:(NSString *)roomId matrixS
// Report the provided accountData.
// Allocate a new instance if none, in order to handle room tag events for this room.
room->_accountData = accountData ? accountData : [[MXRoomAccountData alloc] init];

// Check whether the room is pending on an invitation.
if (room.summary.membership == MXMembershipInvite)
{
// Handle direct flag to decide if it is direct or not
[room handleInviteDirectFlag];
}
}
return room;
}
Expand Down Expand Up @@ -1464,7 +1457,7 @@ - (MXHTTPOperation*)sendVoiceMessage:(NSURL*)fileLocalURL
return [self _sendFile:fileLocalURL
msgType:kMXMessageTypeAudio
additionalTypes:@{kMXMessageContentKeyVoiceMessageMSC3245 : @{},
kMXMessageContentKeyExtensibleAudio: extensibleAudioContent}
kMXMessageContentKeyExtensibleAudioMSC1767: extensibleAudioContent}
mimeType:(mimeType ?: @"audio/ogg")
localEcho:localEcho
success:success
Expand Down Expand Up @@ -1541,8 +1534,8 @@ - (MXHTTPOperation*)_sendFile:(NSURL*)fileLocalURL
@"mimetype": mimeType,
@"size": @(fileData.length)
},
kMXMessageContentKeyExtensibleText: filename,
kMXMessageContentKeyExtensibleFile: @{
kMXMessageContentKeyExtensibleTextMSC1767: filename,
kMXMessageContentKeyExtensibleFileMSC1767: @{
kMXMessageContentKeyExtensibleFileSize: @(fileData.length),
kMXMessageContentKeyExtensibleFileName: filename,
kMXMessageContentKeyExtensibleFileURL: fakeMediaURI,
Expand Down Expand Up @@ -1652,7 +1645,7 @@ - (MXHTTPOperation*)_sendFile:(NSURL*)fileLocalURL
}

msgContent[@"url"] = nil;
msgContent[kMXMessageContentKeyExtensibleFile][kMXMessageContentKeyExtensibleFileURL] = nil;
msgContent[kMXMessageContentKeyExtensibleFileMSC1767][kMXMessageContentKeyExtensibleFileURL] = nil;
msgContent[@"file"] = result.JSONDictionary;

MXHTTPOperation *operation2 = [self sendMessageWithContent:msgContent localEcho:&event success:onSuccess failure:onFailure];
Expand Down Expand Up @@ -1683,7 +1676,7 @@ - (MXHTTPOperation*)_sendFile:(NSURL*)fileLocalURL

// Update the message content with the mxc:// of the media on the homeserver
msgContent[@"url"] = url;
msgContent[kMXMessageContentKeyExtensibleFile][kMXMessageContentKeyExtensibleFileURL] = url;
msgContent[kMXMessageContentKeyExtensibleFileMSC1767][kMXMessageContentKeyExtensibleFileURL] = url;

// Make the final request that posts the image event
MXHTTPOperation *operation2 = [self sendMessageWithContent:msgContent localEcho:&event success:onSuccess failure:onFailure];
Expand Down Expand Up @@ -2364,7 +2357,7 @@ - (MXHTTPOperation *)sendPollResponseForEvent:(MXEvent *)pollStartEvent

NSDictionary *content = @{
kMXEventRelationRelatesToKey: relatesTo.JSONDictionary,
kMXMessageContentKeyExtensiblePollResponse: @{ kMXMessageContentKeyExtensiblePollAnswers: answerIdentifiers }
kMXMessageContentKeyExtensiblePollResponseMSC3381: @{ kMXMessageContentKeyExtensiblePollAnswers: answerIdentifiers }
};

return [self sendEventOfType:[MXTools eventTypeString:MXEventTypePollResponse] content:content localEcho:localEcho success:success failure:failure];
Expand All @@ -2383,12 +2376,36 @@ - (MXHTTPOperation *)sendPollEndForEvent:(MXEvent *)pollStartEvent

NSDictionary *content = @{
kMXEventRelationRelatesToKey: relatesTo.JSONDictionary,
kMXMessageContentKeyExtensiblePollEnd: @{}
kMXMessageContentKeyExtensiblePollEndMSC3381: @{}
};

return [self sendEventOfType:[MXTools eventTypeString:MXEventTypePollEnd] content:content localEcho:localEcho success:success failure:failure];
}

- (MXHTTPOperation *)sendPollUpdateForEvent:(MXEvent *)pollStartEvent
oldContent:(MXEventContentPollStart *)oldContent
newContent:(MXEventContentPollStart *)newContent
localEcho:(MXEvent **)localEcho
success:(void (^)(NSString *))success
failure:(void (^)(NSError *))failure
{
NSParameterAssert(oldContent);
NSParameterAssert(newContent);

NSMutableDictionary *content = [NSMutableDictionary dictionary];

[content addEntriesFromDictionary:oldContent.JSONDictionary];

MXEventContentRelatesTo *relatesTo = [[MXEventContentRelatesTo alloc] initWithRelationType:MXEventRelationTypeReplace
eventId:pollStartEvent.eventId];

[content setObject:relatesTo.JSONDictionary forKey:kMXEventRelationRelatesToKey];

[content setObject:newContent.JSONDictionary forKey:kMXMessageContentKeyNewContent];

return [self sendEventOfType:[MXTools eventTypeString:MXEventTypePollStart] content:content localEcho:localEcho success:success failure:failure];
}

#pragma mark - Location sharing

- (MXHTTPOperation *)sendLocationWithLatitude:(double)latitude
Expand All @@ -2398,23 +2415,21 @@ - (MXHTTPOperation *)sendLocationWithLatitude:(double)latitude
success:(void (^)(NSString *))success
failure:(void (^)(NSError *))failure
{
NSMutableDictionary *content = [NSMutableDictionary dictionary];
content[kMXMessageTypeKey] = kMXMessageTypeLocation;

MXEventContentLocation *locationContent = [[MXEventContentLocation alloc] initWithLatitude:latitude
longitude:longitude
description:description];

content[kMXMessageContentKeyExtensibleLocationMSC3488] = locationContent.JSONDictionary;
MXEventContentLocation *locationContent = [[MXEventContentLocation alloc] initWithAssetType:MXEventAssetTypeUser
latitude:latitude
longitude:longitude
description:description];

content[kMXMessageGeoURIKey] = locationContent.geoURI;
NSMutableDictionary *content = [NSMutableDictionary dictionary];

[content addEntriesFromDictionary:locationContent.JSONDictionary];

NSString *fallbackText = [NSString stringWithFormat:@"%@ was at %@ as of %@", self.mxSession.myUser.displayname, locationContent.geoURI, NSDate.date];
content[kMXMessageBodyKey] = fallbackText;
content[kMXMessageContentKeyExtensibleText] = fallbackText;
content[kMXMessageContentKeyExtensibleTextMSC1767] = fallbackText;

NSInteger timestamp = NSDate.date.timeIntervalSince1970 * 1000; // milliseconds since UNIX epoch
content[kMXMessageContentKeyExtensibleTimestamp] = @(timestamp);
content[kMXMessageContentKeyExtensibleTimestampMSC3488] = @(timestamp);

return [self sendMessageWithContent:content
localEcho:localEcho
Expand Down
5 changes: 5 additions & 0 deletions MatrixSDK/Data/MXRoomLastMessage.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ NS_ASSUME_NONNULL_BEGIN
FOUNDATION_EXPORT NSString *const MXRoomLastMessageDataType;

@class MXEvent;
@class MXRoomLastMessageMO;

/**
`MXRoomLastMessage` is a model class to store some lastMessage properties for room summary objects.
Expand Down Expand Up @@ -68,6 +69,10 @@ FOUNDATION_EXPORT NSString *const MXRoomLastMessageDataType;

- (instancetype)initWithEvent:(MXEvent *)event;

#pragma mark - CoreData Model

- (instancetype)initWithManagedObject:(MXRoomLastMessageMO *)model;

- (NSComparisonResult)compareOriginServerTs:(MXRoomLastMessage *)otherMessage;

@end
Expand Down
24 changes: 24 additions & 0 deletions MatrixSDK/Data/MXRoomLastMessage.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#import "MXKeyProvider.h"
#import "MXAesKeyData.h"
#import "MXAes.h"
#import "MatrixSDKSwiftHeader.h"

#import <Security/Security.h>
#import <CommonCrypto/CommonCryptor.h>
Expand Down Expand Up @@ -76,6 +77,29 @@ - (NSString*)description
return [NSString stringWithFormat:@"%@: %@ - %llu", super.description, self.eventId, self.originServerTs];
}

#pragma mark - CoreData Model

- (instancetype)initWithManagedObject:(MXRoomLastMessageMO *)model
{
if (self = [super init])
{
_eventId = model.s_eventId;
_originServerTs = model.s_originServerTs;
_isEncrypted = model.s_isEncrypted;
_sender = model.s_sender;
_text = model.s_text;
if (model.s_attributedText)
{
_attributedText = [NSKeyedUnarchiver unarchiveObjectWithData:model.s_attributedText];
}
if (model.s_others)
{
_others = [NSKeyedUnarchiver unarchiveObjectWithData:model.s_others];
}
}
return self;
}

#pragma mark - NSCoding

- (instancetype)initWithCoder:(NSCoder *)coder
Expand Down
Loading

0 comments on commit f9f71bd

Please sign in to comment.