Skip to content

Commit

Permalink
Finish v0.11.2
Browse files Browse the repository at this point in the history
  • Loading branch information
manuroe committed Aug 24, 2018
2 parents 821b289 + 9c4ea50 commit 3248084
Show file tree
Hide file tree
Showing 25 changed files with 964 additions and 186 deletions.
15 changes: 15 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
Changes in Matrix iOS SDK in 0.11.2 (2018-08-24)
===============================================

Improvements:
* MXSession: Add the supportedMatrixVersions method getting versions of the specification supported by the homeserver.
* MXRestClient: Add testUserRegistration to check earlier if a username can be registered.
* MXSession: Add MXSessionStateSyncError state and MXSession.syncError to manage homeserver resource quota on /sync requests (vector-im/riot-ios/issues/1937).
* MXError: Add kMXErrCodeStringResourceLimitExceeded to manage homeserver resource quota (vector-im/riot-ios/issues/1937).
* MXError: Define constant strings for keys and values that can be found in a Matrix JSON dictionary error.
* Tests: MXHTTPClient_Private.h: Add method to set fake delay in HTTP requests.

Bug fix:
* People tab is empty in the share extension (vector-im/riot-ios/issues/1988).
* MXError: MXError lost NSError.userInfo information.

Changes in Matrix iOS SDK in 0.11.1 (2018-08-17)
===============================================

Expand Down
30 changes: 6 additions & 24 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.11.1"
s.version = "0.11.2"
s.summary = "The iOS SDK to build apps compatible with Matrix (https://www.matrix.org)"

s.description = <<-DESC
Expand Down Expand Up @@ -54,29 +54,11 @@ Pod::Spec.new do |s|
# Use WebRTC build at https://github.com/Anakros/WebRTC instead
ss.ios.dependency 'WebRTC', '63.11.20455'
end

s.subspec 'GoogleAnalytics' do |ss|
ss.ios.deployment_target = "8.0"

ss.source_files = "MatrixSDKExtensions/MXAnalyticsDelegate/GoogleAnalytics/**/*.{h,m}"

ss.dependency 'MatrixSDK/Core'

ss.ios.dependency 'GoogleAnalytics'
end

#
# This podspec has been disabled because it prevents from publishing the whole pod.
# pod lint returns:
#
# - ERROR | [iOS] [MatrixSDK/SwiftSupport] unknown: Encountered an unknown error (The following Swift pods cannot yet be integrated as static libraries:
#
# The Swift pod `MatrixSDK` depends upon `AFNetworking`, `GZIP`, `OLMKit`, and `Realm`, which do not define modules. To opt into those targets generating module maps (which is necessary to import them from Swift when building as static libraries), you may set `use_modular_headers!` globally in your Podfile, or specify `:modular_headers => true` for particular dependencies.) during validation.
#
# s.subspec 'SwiftSupport' do |ss|
# ss.source_files = "MatrixSDK", "MatrixSDK/**/*.{swift}"
#
# ss.dependency 'MatrixSDK/Core'
# end
s.subspec 'SwiftSupport' do |ss|
ss.source_files = "MatrixSDK", "MatrixSDK/**/*.{swift}"

ss.dependency 'MatrixSDK/Core'
end

end
10 changes: 10 additions & 0 deletions MatrixSDK.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
323EF7471C7CB4C7000DC98C /* MXEventTimelineTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 323EF7461C7CB4C7000DC98C /* MXEventTimelineTests.m */; };
323F3F9320D3F0C700D26D6A /* MXRoomEventFilter.m in Sources */ = {isa = PBXBuildFile; fileRef = 323F3F9120D3F0C700D26D6A /* MXRoomEventFilter.m */; };
323F3F9420D3F0C700D26D6A /* MXRoomEventFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = 323F3F9220D3F0C700D26D6A /* MXRoomEventFilter.h */; settings = {ATTRIBUTES = (Public, ); }; };
323F8864212D4E470001C73C /* MXMatrixVersions.h in Headers */ = {isa = PBXBuildFile; fileRef = 323F8862212D4E470001C73C /* MXMatrixVersions.h */; settings = {ATTRIBUTES = (Public, ); }; };
323F8865212D4E480001C73C /* MXMatrixVersions.m in Sources */ = {isa = PBXBuildFile; fileRef = 323F8863212D4E470001C73C /* MXMatrixVersions.m */; };
324095221AFA432F00D81C97 /* MXCallStackCall.h in Headers */ = {isa = PBXBuildFile; fileRef = 3240951E1AFA432F00D81C97 /* MXCallStackCall.h */; settings = {ATTRIBUTES = (Public, ); }; };
3240969D1F9F751600DBA607 /* MXPushRuleSenderNotificationPermissionConditionChecker.h in Headers */ = {isa = PBXBuildFile; fileRef = 3240969B1F9F751600DBA607 /* MXPushRuleSenderNotificationPermissionConditionChecker.h */; };
3240969E1F9F751600DBA607 /* MXPushRuleSenderNotificationPermissionConditionChecker.m in Sources */ = {isa = PBXBuildFile; fileRef = 3240969C1F9F751600DBA607 /* MXPushRuleSenderNotificationPermissionConditionChecker.m */; };
Expand Down Expand Up @@ -337,6 +339,7 @@
322A51C51D9BBD3C00C8536D /* MXOlmDevice.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MXOlmDevice.h; sourceTree = "<group>"; };
322A51C61D9BBD3C00C8536D /* MXOlmDevice.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MXOlmDevice.m; sourceTree = "<group>"; };
322A51D71D9E846800C8536D /* MXCryptoTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MXCryptoTests.m; sourceTree = "<group>"; };
322DB456212EB8E600F4EFE9 /* MXHTTPClient_Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MXHTTPClient_Private.h; sourceTree = "<group>"; };
32322A471E57264E005DD155 /* MXSelfSignedHomeserverTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MXSelfSignedHomeserverTests.m; sourceTree = "<group>"; };
32322A491E575F65005DD155 /* MXAllowedCertificates.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MXAllowedCertificates.h; sourceTree = "<group>"; };
32322A4A1E575F65005DD155 /* MXAllowedCertificates.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MXAllowedCertificates.m; sourceTree = "<group>"; };
Expand All @@ -348,6 +351,8 @@
323EF7461C7CB4C7000DC98C /* MXEventTimelineTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MXEventTimelineTests.m; sourceTree = "<group>"; };
323F3F9120D3F0C700D26D6A /* MXRoomEventFilter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MXRoomEventFilter.m; sourceTree = "<group>"; };
323F3F9220D3F0C700D26D6A /* MXRoomEventFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MXRoomEventFilter.h; sourceTree = "<group>"; };
323F8862212D4E470001C73C /* MXMatrixVersions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MXMatrixVersions.h; sourceTree = "<group>"; };
323F8863212D4E470001C73C /* MXMatrixVersions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MXMatrixVersions.m; sourceTree = "<group>"; };
3240951E1AFA432F00D81C97 /* MXCallStackCall.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MXCallStackCall.h; sourceTree = "<group>"; };
3240969B1F9F751600DBA607 /* MXPushRuleSenderNotificationPermissionConditionChecker.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MXPushRuleSenderNotificationPermissionConditionChecker.h; sourceTree = "<group>"; };
3240969C1F9F751600DBA607 /* MXPushRuleSenderNotificationPermissionConditionChecker.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MXPushRuleSenderNotificationPermissionConditionChecker.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -676,6 +681,7 @@
F03EF5021DF01596009DF592 /* MXLRUCache.h */,
F03EF5031DF01596009DF592 /* MXLRUCache.m */,
320DFDD719DD99B60068622A /* MXHTTPClient.h */,
322DB456212EB8E600F4EFE9 /* MXHTTPClient_Private.h */,
320DFDD819DD99B60068622A /* MXHTTPClient.m */,
32CAB1091A925B41008C5BB9 /* MXHTTPOperation.h */,
32CAB10A1A925B41008C5BB9 /* MXHTTPOperation.m */,
Expand Down Expand Up @@ -847,6 +853,8 @@
B17982F22119E4A1001FD722 /* MXRoomCreateContent.m */,
B17982EF2119E49F001FD722 /* MXRoomPredecessorInfo.h */,
B17982F32119E4A1001FD722 /* MXRoomPredecessorInfo.m */,
323F8862212D4E470001C73C /* MXMatrixVersions.h */,
323F8863212D4E470001C73C /* MXMatrixVersions.m */,
);
path = JSONModels;
sourceTree = "<group>";
Expand Down Expand Up @@ -1223,6 +1231,7 @@
3245A7521AF7B2930001D8A7 /* MXCallManager.h in Headers */,
C6FE1EF01E65C4F7008587E4 /* MXAnalyticsDelegate.h in Headers */,
92634B7F1EF2A37A00DB9F60 /* MXCallAudioSessionConfigurator.h in Headers */,
323F8864212D4E470001C73C /* MXMatrixVersions.h in Headers */,
3291D4D41A68FFEB00C3BA41 /* MXFileRoomStore.h in Headers */,
320BBF431D6C81550079890E /* MXEventsEnumeratorOnArray.h in Headers */,
32B76EA320FDE2BE00B095F6 /* MXRoomMembersCount.h in Headers */,
Expand Down Expand Up @@ -1536,6 +1545,7 @@
F0C34CBB1C18C93700C36F09 /* MXSDKOptions.m in Sources */,
320BBF441D6C81550079890E /* MXEventsEnumeratorOnArray.m in Sources */,
32618E7220ED2DF500E1D2EA /* MXFilterJSONModel.m in Sources */,
323F8865212D4E480001C73C /* MXMatrixVersions.m in Sources */,
320DFDDC19DD99B60068622A /* MXRoom.m in Sources */,
F08B8D5D1E014711006171A8 /* NSData+MatrixSDK.m in Sources */,
3291D4D51A68FFEB00C3BA41 /* MXFileRoomStore.m in Sources */,
Expand Down
47 changes: 33 additions & 14 deletions MatrixSDK/Data/MXRoom.m
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,41 @@ - (MXHTTPOperation*)members:(void (^)(MXRoomMembers *members))success
self->pendingMembersRequesters = [NSMutableArray array];

// Else get them from the homeserver
NSDictionary *parameters;
if (self.mxSession.store.eventStreamToken)
{
parameters = @{
kMXMembersOfRoomParametersAt: self.mxSession.store.eventStreamToken
};
}

MXWeakify(self);
MXHTTPOperation *operation2 = [self.mxSession.matrixRestClient membersOfRoom:self.roomId success:^(NSArray *roomMemberEvents) {
MXHTTPOperation *operation2 = [self.mxSession.matrixRestClient membersOfRoom:self.roomId
withParameters:parameters
success:^(NSArray *roomMemberEvents)
{
MXStrongifyAndReturnIfNil(self);

// Manage the possible race condition where we could have received
// update of members from the events stream (/sync) while the /members
// request was pending.
// In that case, the response of /members is not up-to-date. We must not
// use this response as is.
// To fix that:
// - we consider that all lazy-loaded members are up-to-date
// - we ignore in the /member response all member events corresponding
// to these already lazy-loaded members
NSMutableArray *updatedRoomMemberEvents = [NSMutableArray array];
for (MXEvent *roomMemberEvent in roomMemberEvents)
{
if (![liveTimeline.state.members memberWithUserId:roomMemberEvent.stateKey])
{
// User not lazy loaded yet, keep their member event from /members response
[updatedRoomMemberEvents addObject:roomMemberEvent];
}
}
roomMemberEvents = updatedRoomMemberEvents;

[liveTimeline handleLazyLoadedStateEvents:roomMemberEvents];

[self.mxSession.store storeHasLoadedAllRoomMembersForRoom:self.roomId andValue:YES];
Expand Down Expand Up @@ -2820,20 +2851,8 @@ - (BOOL)isDirect

- (NSString *)directUserId
{
NSString *directUserId;

// Get the information from the user account data that is managed by MXSession
NSDictionary<NSString*, NSArray<NSString*>*> *directRooms = self.mxSession.directRooms;
for (NSString *userId in directRooms)
{
if ([directRooms[userId] containsObject:_roomId])
{
directUserId = userId;
break;
}
}

return directUserId;
return [self.mxSession directUserIdInRoom:_roomId];
}

- (MXHTTPOperation*)setIsDirect:(BOOL)isDirect
Expand Down
2 changes: 1 addition & 1 deletion MatrixSDK/Data/MXRoomSummary.h
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ FOUNDATION_EXPORT NSString *const kMXRoomSummaryDidChangeNotification;
The user identifier for whom this room is tagged as direct (if any).
nil if the room is not a direct chat.
*/
@property (nonatomic, readonly) NSString *directUserId;
@property (nonatomic) NSString *directUserId;

/**
Placeholder to store more information in the room summary.
Expand Down
7 changes: 2 additions & 5 deletions MatrixSDK/Data/MXRoomSummary.m
Original file line number Diff line number Diff line change
Expand Up @@ -374,11 +374,6 @@ - (NSUInteger)localUnreadEventCount
return [_mxSession.store localUnreadEventCount:_roomId withTypeIn:_mxSession.unreadEventTypes];
}

- (NSString *)directUserId
{
return self.room.directUserId;
}

- (BOOL)isDirect
{
return (self.directUserId != nil);
Expand Down Expand Up @@ -545,6 +540,7 @@ - (instancetype)initWithCoder:(NSCoder *)aDecoder
_isEncrypted = [aDecoder decodeBoolForKey:@"isEncrypted"];
_notificationCount = (NSUInteger)[aDecoder decodeIntegerForKey:@"notificationCount"];
_highlightCount = (NSUInteger)[aDecoder decodeIntegerForKey:@"highlightCount"];
_directUserId = [aDecoder decodeObjectForKey:@"directUserId"];

_lastMessageEventId = [aDecoder decodeObjectForKey:@"lastMessageEventId"];
_lastMessageOriginServerTs = [aDecoder decodeInt64ForKey:@"lastMessageOriginServerTs"];
Expand Down Expand Up @@ -586,6 +582,7 @@ - (void)encodeWithCoder:(NSCoder *)aCoder
[aCoder encodeBool:_isEncrypted forKey:@"isEncrypted"];
[aCoder encodeInteger:(NSInteger)_notificationCount forKey:@"notificationCount"];
[aCoder encodeInteger:(NSInteger)_highlightCount forKey:@"highlightCount"];
[aCoder encodeObject:_directUserId forKey:@"directUserId"];

// Store last message metadata
[aCoder encodeObject:_lastMessageEventId forKey:@"lastMessageEventId"];
Expand Down
2 changes: 1 addition & 1 deletion MatrixSDK/Data/Store/MXFileStore/MXFileStore.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#import "MXSDKOptions.h"
#import "MXTools.h"

static NSUInteger const kMXFileVersion = 57;
static NSUInteger const kMXFileVersion = 58;

static NSString *const kMXFileStoreFolder = @"MXFileStore";
static NSString *const kMXFileStoreMedaDataFile = @"MXFileStore";
Expand Down
1 change: 1 addition & 0 deletions MatrixSDK/JSONModels/MXJSONModels.h
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ FOUNDATION_EXPORT NSString *const kMXLoginIdentifierTypePhone;
*/
FOUNDATION_EXPORT NSString *const kMXRoomTagFavourite;
FOUNDATION_EXPORT NSString *const kMXRoomTagLowPriority;
FOUNDATION_EXPORT NSString *const kMXRoomTagServerNotice;

/**
`MXRoomTag` represents a room tag.
Expand Down
1 change: 1 addition & 0 deletions MatrixSDK/JSONModels/MXJSONModels.m
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ + (id)modelFromJSON:(NSDictionary *)JSONDictionary

NSString *const kMXRoomTagFavourite = @"m.favourite";
NSString *const kMXRoomTagLowPriority = @"m.lowpriority";
NSString *const kMXRoomTagServerNotice = @"m.server_notice";

@interface MXRoomTag()
{
Expand Down
53 changes: 53 additions & 0 deletions MatrixSDK/JSONModels/MXMatrixVersions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
Copyright 2018 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

#import <Foundation/Foundation.h>
#import "MXJSONModel.h"

/**
Features declared in the matrix specification.
*/
struct MXMatrixVersionsFeatureStruct
{
// Room members lazy loading
__unsafe_unretained NSString * const lazyLoadMembers;
};
extern const struct MXMatrixVersionsFeatureStruct MXMatrixVersionsFeature;

/**
`MXMatrixVersions` represents the versions of the Matrix specification supported
by the home server.
It is returned by the /versions API.
*/
@interface MXMatrixVersions : MXJSONModel

/**
The versions supported by the server.
*/
@property (nonatomic) NSArray<NSString *> *versions;

/**
The unstable features supported by the server.
*/
@property (nonatomic) NSDictionary<NSString*, NSNumber*> *unstableFeatures;

/**
Check whether the server supports the room members lazy loading.
*/
@property (nonatomic, readonly) BOOL supportLazyLoadMembers;

@end
41 changes: 41 additions & 0 deletions MatrixSDK/JSONModels/MXMatrixVersions.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
Copyright 2018 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

#import "MXMatrixVersions.h"

const struct MXMatrixVersionsFeatureStruct MXMatrixVersionsFeature = {
.lazyLoadMembers = @"m.lazy_load_members"
};

@implementation MXMatrixVersions

+ (id)modelFromJSON:(NSDictionary *)JSONDictionary
{
MXMatrixVersions *matrixVersions = [[MXMatrixVersions alloc] init];
if (matrixVersions)
{
MXJSONModelSetArray(matrixVersions.versions, JSONDictionary[@"versions"]);
MXJSONModelSetDictionary(matrixVersions.unstableFeatures, JSONDictionary[@"unstable_features"]);
}
return matrixVersions;
}

- (BOOL)supportLazyLoadMembers
{
return [self.unstableFeatures[MXMatrixVersionsFeature.lazyLoadMembers] boolValue];
}

@end
11 changes: 11 additions & 0 deletions MatrixSDK/MXError.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ FOUNDATION_EXPORT NSString *const kMXErrCodeStringThreePIDNotFound;
FOUNDATION_EXPORT NSString *const kMXErrCodeStringServerNotTrusted;
FOUNDATION_EXPORT NSString *const kMXErrCodeStringGuestAccessForbidden;
FOUNDATION_EXPORT NSString *const kMXErrCodeStringConsentNotGiven;
FOUNDATION_EXPORT NSString *const kMXErrCodeStringResourceLimitExceeded;

FOUNDATION_EXPORT NSString *const kMXErrorStringInvalidToken;

Expand All @@ -51,6 +52,16 @@ FOUNDATION_EXPORT NSString *const kMXErrorStringInvalidToken;
*/
FOUNDATION_EXPORT NSString *const kMXSDKErrCodeStringMissingParameters;

/**
Keys and values that can be found in a Matrix error JSON dictionary.
*/
FOUNDATION_EXPORT NSString *const kMXErrorCodeKey;
FOUNDATION_EXPORT NSString *const kMXErrorMessageKey;
FOUNDATION_EXPORT NSString *const kMXErrorConsentNotGivenConsentURIKey;
FOUNDATION_EXPORT NSString *const kMXErrorResourceLimitExceededLimitTypeKey;
FOUNDATION_EXPORT NSString *const kMXErrorResourceLimitExceededAdminContactKey;
FOUNDATION_EXPORT NSString *const kMXErrorResourceLimitExceededLimitTypeMonthlyActiveUserValue;

/**
`MXError` represents an error sent by the home server.
MXErrors are encapsulated in NSError. This class is an helper to create NSError or extract MXError from NSError.
Expand Down
Loading

0 comments on commit 3248084

Please sign in to comment.