Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/release-v0.6.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
giomfo committed Feb 9, 2016
2 parents e91f34c + 2691f6a commit 3c58501
Show file tree
Hide file tree
Showing 23 changed files with 429 additions and 48 deletions.
11 changes: 11 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
Changes in Matrix iOS SDK in 0.6.2 (2016-02-09)
===============================================

Improvements:
* MXRoom: Add an argument to limit the pagination to the messages from the store.
* MXRoom: Support email invitation.

Bug fixes:
* App crashes on resume if a pause is pending.
* Account creation: reCaptcha is missing in registration fallback.

Changes in Matrix iOS SDK in 0.6.1 (2016-01-29)
===============================================

Expand Down
4 changes: 2 additions & 2 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.6.1"
s.version = "0.6.2"
s.summary = "The iOS SDK to build apps compatible with Matrix (http://www.matrix.org)"

s.description = <<-DESC
Expand All @@ -19,7 +19,7 @@ Pod::Spec.new do |s|

s.platform = :ios, "7.0"

s.source = { :git => "https://github.com/matrix-org/matrix-ios-sdk.git", :tag => "v0.6.1" }
s.source = { :git => "https://github.com/matrix-org/matrix-ios-sdk.git", :tag => "v0.6.2" }
s.source_files = "MatrixSDK", "MatrixSDK/**/*.{h,m}"
s.resources = "MatrixSDK/Data/Store/MXCoreDataStore/*.xcdatamodeld"

Expand Down
8 changes: 8 additions & 0 deletions MatrixSDK.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@
327E37B61A974F75007F026F /* MXLogger.h in Headers */ = {isa = PBXBuildFile; fileRef = 327E37B41A974F75007F026F /* MXLogger.h */; };
327E37B71A974F75007F026F /* MXLogger.m in Sources */ = {isa = PBXBuildFile; fileRef = 327E37B51A974F75007F026F /* MXLogger.m */; };
327E37B91A977810007F026F /* MXLoggerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 327E37B81A977810007F026F /* MXLoggerTests.m */; };
327F8DB21C6112BA00581CA3 /* MXRoomThirdPartyInvite.h in Headers */ = {isa = PBXBuildFile; fileRef = 327F8DB01C6112BA00581CA3 /* MXRoomThirdPartyInvite.h */; };
327F8DB31C6112BA00581CA3 /* MXRoomThirdPartyInvite.m in Sources */ = {isa = PBXBuildFile; fileRef = 327F8DB11C6112BA00581CA3 /* MXRoomThirdPartyInvite.m */; };
3281E89E19E299C000976E1A /* MXErrorTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 3281E89D19E299C000976E1A /* MXErrorTests.m */; };
3281E8A019E2CC1200976E1A /* MXHTTPClientTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 3281E89F19E2CC1200976E1A /* MXHTTPClientTests.m */; };
3281E8A219E2DE4300976E1A /* MXSessionTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 3281E8A119E2DE4300976E1A /* MXSessionTests.m */; };
Expand Down Expand Up @@ -219,6 +221,8 @@
327E37B41A974F75007F026F /* MXLogger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MXLogger.h; sourceTree = "<group>"; };
327E37B51A974F75007F026F /* MXLogger.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MXLogger.m; sourceTree = "<group>"; };
327E37B81A977810007F026F /* MXLoggerTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MXLoggerTests.m; sourceTree = "<group>"; };
327F8DB01C6112BA00581CA3 /* MXRoomThirdPartyInvite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MXRoomThirdPartyInvite.h; sourceTree = "<group>"; };
327F8DB11C6112BA00581CA3 /* MXRoomThirdPartyInvite.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MXRoomThirdPartyInvite.m; sourceTree = "<group>"; };
3281E89D19E299C000976E1A /* MXErrorTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MXErrorTests.m; sourceTree = "<group>"; };
3281E89F19E2CC1200976E1A /* MXHTTPClientTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MXHTTPClientTests.m; sourceTree = "<group>"; };
3281E8A119E2DE4300976E1A /* MXSessionTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = MXSessionTests.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
Expand Down Expand Up @@ -325,6 +329,8 @@
3220094419EFBF30008DE41D /* MXSessionEventListener.m */,
329FB1731A0A3A1600A5E88E /* MXRoomMember.h */,
329FB1741A0A3A1600A5E88E /* MXRoomMember.m */,
327F8DB01C6112BA00581CA3 /* MXRoomThirdPartyInvite.h */,
327F8DB11C6112BA00581CA3 /* MXRoomThirdPartyInvite.m */,
329FB17D1A0B665800A5E88E /* MXUser.h */,
329FB17E1A0B665800A5E88E /* MXUser.m */,
327137251A24D50A00DB6757 /* MXMyUser.h */,
Expand Down Expand Up @@ -608,6 +614,7 @@
32CE6FB81A409B1F00317F1E /* MXFileStoreMetaData.h in Headers */,
3281E8B719E42DFE00976E1A /* MXJSONModel.h in Headers */,
323E0C5B1A306D7A00A31D73 /* MXEvent.h in Headers */,
327F8DB21C6112BA00581CA3 /* MXRoomThirdPartyInvite.h in Headers */,
322360521A8E610500A3CA81 /* MXPushRuleDisplayNameCondtionChecker.h in Headers */,
3245A7521AF7B2930001D8A7 /* MXCallManager.h in Headers */,
3264E2A21BDF8D1500F89A86 /* MXCoreDataRoomState.h in Headers */,
Expand Down Expand Up @@ -789,6 +796,7 @@
32DC15D51A8CF874006F9AD3 /* MXPushRuleEventMatchConditionChecker.m in Sources */,
32CAB1081A91EA34008C5BB9 /* MXPushRuleRoomMemberCountConditionChecker.m in Sources */,
3245A7511AF7B2930001D8A7 /* MXCall.m in Sources */,
327F8DB31C6112BA00581CA3 /* MXRoomThirdPartyInvite.m in Sources */,
323B2AE21BCD4CB600B11F34 /* MXCoreDataAccount.m in Sources */,
3264E2A51BDF8D1500F89A86 /* MXCoreDataRoomState+CoreDataProperties.m in Sources */,
329FB1761A0A3A1600A5E88E /* MXRoomMember.m in Sources */,
Expand Down
19 changes: 17 additions & 2 deletions MatrixSDK/Data/MXRoom.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,17 @@ typedef void (^MXOnRoomEvent)(MXEvent *event, MXEventDirection direction, MXRoom
The retrieved events will be sent to registered listeners.
@param numItems the number of items to get.
@param onlyFromStore if YES, return available events from the store, do not make a pagination request to the homeserver.
@param complete A block object called when the operation is complete.
@param failure A block object called when the operation fails.
@return a MXHTTPOperation instance. This instance can be nil
if no request to the home server is required.
*/
- (MXHTTPOperation*)paginateBackMessages:(NSUInteger)numItems
complete:(void (^)())complete
failure:(void (^)(NSError *error))failure;
onlyFromStore:(BOOL)onlyFromStore
complete:(void (^)())complete
failure:(void (^)(NSError *error))failure;


/**
Expand Down Expand Up @@ -335,6 +337,19 @@ typedef void (^MXOnRoomEvent)(MXEvent *event, MXEventDirection direction, MXRoom
success:(void (^)())success
failure:(void (^)(NSError *error))failure;

/**
Invite a user to a room based on their email address to this room.
@param email the user email.
@param success A block object called when the operation succeeds.
@param failure A block object called when the operation fails.
@return a MXHTTPOperation instance.
*/
- (MXHTTPOperation*)inviteUserByEmail:(NSString*)email
success:(void (^)())success
failure:(void (^)(NSError *error))failure;

/**
Kick a user from this room.
Expand Down
21 changes: 19 additions & 2 deletions MatrixSDK/Data/MXRoom.m
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ - (id)initWithRoomId:(NSString *)roomId andMatrixSession:(MXSession *)mxSession2
kMXEventTypeStringRoomMessage,
kMXEventTypeStringRoomMessageFeedback,
kMXEventTypeStringRoomRedaction,
kMXEventTypeStringRoomThirdPartyInvite,
kMXEventTypeStringCallInvite,
kMXEventTypeStringCallCandidates,
kMXEventTypeStringCallAnswer,
Expand Down Expand Up @@ -528,8 +529,9 @@ - (void)resetBackState
}

- (MXHTTPOperation*)paginateBackMessages:(NSUInteger)numItems
complete:(void (^)())complete
failure:(void (^)(NSError *error))failure
onlyFromStore:(BOOL)onlyFromStore
complete:(void (^)())complete
failure:(void (^)(NSError *error))failure
{
MXHTTPOperation *operation;

Expand Down Expand Up @@ -561,6 +563,14 @@ - (MXHTTPOperation*)paginateBackMessages:(NSUInteger)numItems
}
}

if (onlyFromStore && messagesFromStoreCount)
{
complete();

NSLog(@"[MXRoom] paginateBackMessages : is done from the store");
return nil;
}

if (0 < numItems && NO == [mxSession.store hasReachedHomeServerPaginationEndForRoom:_state.roomId])
{
// Not enough messages: make a pagination request to the home server
Expand Down Expand Up @@ -722,6 +732,13 @@ - (MXHTTPOperation*)inviteUser:(NSString*)userId
return [mxSession.matrixRestClient inviteUser:userId toRoom:_state.roomId success:success failure:failure];
}

- (MXHTTPOperation*)inviteUserByEmail:(NSString*)email
success:(void (^)())success
failure:(void (^)(NSError *error))failure
{
return [mxSession.matrixRestClient inviteUserByEmail:email toRoom:_state.roomId success:success failure:failure];
}

- (MXHTTPOperation*)kickUser:(NSString*)userId
reason:(NSString*)reason
success:(void (^)())success
Expand Down
7 changes: 6 additions & 1 deletion MatrixSDK/Data/MXRoomMember.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,14 @@
*/
@property (nonatomic, readonly) NSString *originUserId;

/**
If the m.room.member event is the successor of a m.room.third_party_invite event,
'thirdPartyInviteToken' is the token of this event. Else, nil.
*/
@property (nonatomic, readonly) NSString *thirdPartyInviteToken;

/**
The event used to build the MXRoomMember.
// @TODO: Consider MXRoomMember as a child class of MXEvent to avoid such data duplication.
*/
@property (nonatomic, readonly) MXEvent *originalEvent;

Expand Down
1 change: 1 addition & 0 deletions MatrixSDK/Data/MXRoomMember.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ - (instancetype)initWithMXEvent:(MXEvent*)roomMemberEvent
// We ignore non mxc avatar url
_avatarUrl = ([roomMemberContent.avatarUrl hasPrefix:kMXContentUriScheme] ? roomMemberContent.avatarUrl : nil);
_membership = [MXTools membership:roomMemberContent.membership];
_thirdPartyInviteToken = roomMemberContent.thirdPartyInviteToken;
_originalEvent = roomMemberEvent;

// Set who is this member
Expand Down
31 changes: 29 additions & 2 deletions MatrixSDK/Data/MXRoomState.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#import "MXEvent.h"
#import "MXJSONModels.h"
#import "MXRoomMember.h"
#import "MXRoomThirdPartyInvite.h"
#import "MXRoomPowerLevels.h"

@class MXSession;
Expand Down Expand Up @@ -52,7 +53,12 @@
/**
A copy of the list of room members (actually MXRoomMember instances).
*/
@property (nonatomic, readonly) NSArray *members;
@property (nonatomic, readonly) NSArray<MXRoomMember*> *members;

/**
A copy of the list of third party invites (actually MXRoomThirdPartyInvite instances).
*/
@property (nonatomic, readonly) NSArray<MXRoomThirdPartyInvite*> *thirdPartyInvites;

/**
The power level of room members
Expand Down Expand Up @@ -131,7 +137,7 @@
*/
- (id)initWithRoomId:(NSString*)roomId
andMatrixSession:(MXSession*)matrixSession
andInitialSync:(MXRoomInitialSync*)initialSync
andInitialSync:(MXRoomInitialSync*)initialSync
andDirection:(BOOL)isLive;

/**
Expand All @@ -158,6 +164,27 @@
*/
- (MXRoomMember*)memberWithUserId:(NSString*)userId;

/**
Return the member who was invited by a 3pid medium with the given token.
When invited by a 3pid medium like email, the not-yet-registered-to-matrix user is indicated
in the room state by a m.room.third_party_invite event.
Once he registers, the homeserver adds a m.room.membership event to the room state.
This event then contains the token of the previous m.room.third_party_invite event.
@param thirdPartyInviteToken the m.room.third_party_invite token to look for.
@return the room member.
*/
- (MXRoomMember*)memberWithThirdPartyInviteToken:(NSString*)thirdPartyInviteToken;

/**
Return 3pid invite with the given token.
@param thirdPartyInviteToken the m.room.third_party_invite token to look for.
@return the 3pid invite.
*/
- (MXRoomThirdPartyInvite*)thirdPartyInviteWithToken:(NSString*)thirdPartyInviteToken;

/**
Return a display name for a member.
It is his displayname member or, if nil, his userId
Expand Down
68 changes: 66 additions & 2 deletions MatrixSDK/Data/MXRoomState.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,13 @@ @interface MXRoomState ()

NSMutableDictionary *stateEvents;
NSMutableDictionary *members;

/**
The third party invites. The key is the token provided by the homeserver.
*/
NSMutableDictionary<NSString*, MXRoomThirdPartyInvite*> *thirdPartyInvites;

/*
/**
Additional and optional metadata got from initialSync
*/
MXMembership membership;
Expand All @@ -49,7 +54,13 @@ @interface MXRoomState ()
The key is the user id. The value, the member name to display.
This cache is resetted when there is new room member event.
*/
NSMutableDictionary *membersNamesCache;
NSMutableDictionary<NSString*, NSString*> *membersNamesCache;

/**
Cache for [self memberWithThirdPartyInviteToken].
The key is the 3pid invite token.
*/
NSMutableDictionary<NSString*, MXRoomMember*> *membersWithThirdPartyInviteTokenCache;
}
@end

Expand All @@ -70,7 +81,9 @@ - (id)initWithRoomId:(NSString*)roomId

stateEvents = [NSMutableDictionary dictionary];
members = [NSMutableDictionary dictionary];
thirdPartyInvites = [NSMutableDictionary dictionary];
membersNamesCache = [NSMutableDictionary dictionary];
membersWithThirdPartyInviteTokenCache = [NSMutableDictionary dictionary];
}
return self;
}
Expand Down Expand Up @@ -146,6 +159,13 @@ - (NSArray *)stateEvents
{
[state addObject:roomMember.originalEvent];
}

// Third party invites are state events too
for (MXRoomThirdPartyInvite *thirdPartyInvite in self.thirdPartyInvites)
{
[state addObject:thirdPartyInvite.originalEvent];
}

return state;
}

Expand All @@ -154,6 +174,11 @@ - (NSArray *)members
return [members allValues];
}

- (NSArray<MXRoomThirdPartyInvite *> *)thirdPartyInvites
{
return [thirdPartyInvites allValues];
}

- (void)setIsPublic:(BOOL)isPublicValue
{
isPublic = isPublicValue;
Expand Down Expand Up @@ -426,6 +451,12 @@ - (void)handleStateEvent:(MXEvent*)event
// Force to use an identicon url
roomMember.avatarUrl = [mxSession.matrixRestClient urlOfIdenticon:roomMember.userId];
}

// Cache room member event that is successor of a third party invite event
if (roomMember.thirdPartyInviteToken)
{
membersWithThirdPartyInviteTokenCache[roomMember.thirdPartyInviteToken] = roomMember;
}
}
else
{
Expand All @@ -447,6 +478,25 @@ - (void)handleStateEvent:(MXEvent*)event

break;
}
case MXEventTypeRoomThirdPartyInvite:
{
// The content and the prev_content of a m.room.third_party_invite event are the same.
// So, use isLive to know if the invite must be added or removed (case of back state).
if (_isLive)
{
MXRoomThirdPartyInvite *thirdPartyInvite = [[MXRoomThirdPartyInvite alloc] initWithMXEvent:event];
if (thirdPartyInvite)
{
thirdPartyInvites[thirdPartyInvite.token] = thirdPartyInvite;
}
}
else
{
// Note: the 3pid invite token is stored in the event state key
[thirdPartyInvites removeObjectForKey:event.stateKey];
}
break;
}
case MXEventTypeRoomPowerLevels:
{
powerLevels = [MXRoomPowerLevels modelFromJSON:[self contentOfEvent:event]];
Expand Down Expand Up @@ -479,6 +529,16 @@ - (MXRoomMember*)memberWithUserId:(NSString *)userId
return members[userId];
}

- (MXRoomMember *)memberWithThirdPartyInviteToken:(NSString *)thirdPartyInviteToken
{
return membersWithThirdPartyInviteTokenCache[thirdPartyInviteToken];
}

- (MXRoomThirdPartyInvite *)thirdPartyInviteWithToken:(NSString *)thirdPartyInviteToken
{
return thirdPartyInvites[thirdPartyInviteToken];
}

- (NSString*)memberName:(NSString*)userId
{
// First, lookup in the cache
Expand Down Expand Up @@ -591,6 +651,10 @@ - (id)copyWithZone:(NSZone *)zone
// membership change (ex: "invited" -> "joined")
stateCopy->members = [[NSMutableDictionary allocWithZone:zone] initWithDictionary:members];

stateCopy->thirdPartyInvites = [[NSMutableDictionary allocWithZone:zone] initWithDictionary:thirdPartyInvites];

stateCopy->membersWithThirdPartyInviteTokenCache= [[NSMutableDictionary allocWithZone:zone] initWithDictionary:membersWithThirdPartyInviteTokenCache];

if (visibility)
{
stateCopy->visibility = [visibility copyWithZone:zone];
Expand Down
Loading

0 comments on commit 3c58501

Please sign in to comment.