Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/release-v0.6.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
giomfo committed Mar 7, 2016
2 parents 1f24f8b + e4f4929 commit 33eb8db
Show file tree
Hide file tree
Showing 56 changed files with 2,575 additions and 2,888 deletions.
20 changes: 20 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
Changes in Matrix iOS SDK in 0.6.3 (2016-03-07)
===============================================

Improvements:
* Moving to r0 API: Replace calls to v1 and v2_alpha apis by r0, which is configurable via MXRestClient.apiPathPrefix.
* MXEventContext: Add C-S API to handle event context.
* MXEventTimeline: Created MXEventTimeline to manage a list of continuous events. MXRoom has now a liveTimeline property that manages live events and state of the room. MXEventTimeline is able to manage live events and events that will come from the event context API.
* MXEventDirection* has been renamed to MXTimelineDirection*.
* MXEventTimeline: Support backward/forward pagination around a past event.
* MXRestClient: the messagesForRoom method has been updated to conform r0 C-S API. The "to" parameter has been replaced by the "direction" parameter.
* MXRoom: Replace the inaccurate 'unreadEvents' array with a boolean flag 'hasUnreadEvents'.
* MXRoom: Add 'notificationCount' and 'highlightCount' based on the notificationCount field in /sync response.
* SDK Tests: Update and fix tests.

Bug fixes:
* Support email login.
* Room ordering: a tagged room with no order value must have higher priority than the tagged rooms with order value.
* SYIOS-208: [MXSession startWithMessagesLimit]: if defined, the limit argument is now passed to /sync request.
* SYIOS-207: Removed MXEventDirectionSync which became useless.

Changes in Matrix iOS SDK in 0.6.2 (2016-02-09)
===============================================

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.2"
s.version = "0.6.3"
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.2" }
s.source = { :git => "https://github.com/matrix-org/matrix-ios-sdk.git", :tag => "v0.6.3" }
s.source_files = "MatrixSDK", "MatrixSDK/**/*.{h,m}"
s.resources = "MatrixSDK/Data/Store/MXCoreDataStore/*.xcdatamodeld"

Expand Down
12 changes: 12 additions & 0 deletions MatrixSDK.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
323E0C581A2F6E7D00A31D73 /* MXRoomPowerLevels.m in Sources */ = {isa = PBXBuildFile; fileRef = 323E0C561A2F6E7D00A31D73 /* MXRoomPowerLevels.m */; };
323E0C5B1A306D7A00A31D73 /* MXEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 323E0C591A306D7A00A31D73 /* MXEvent.h */; };
323E0C5C1A306D7A00A31D73 /* MXEvent.m in Sources */ = {isa = PBXBuildFile; fileRef = 323E0C5A1A306D7A00A31D73 /* MXEvent.m */; };
323EF7471C7CB4C7000DC98C /* MXEventTimelineTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 323EF7461C7CB4C7000DC98C /* MXEventTimelineTests.m */; };
324095221AFA432F00D81C97 /* MXCallStackCall.h in Headers */ = {isa = PBXBuildFile; fileRef = 3240951E1AFA432F00D81C97 /* MXCallStackCall.h */; };
3245A7501AF7B2930001D8A7 /* MXCall.h in Headers */ = {isa = PBXBuildFile; fileRef = 3245A74C1AF7B2930001D8A7 /* MXCall.h */; };
3245A7511AF7B2930001D8A7 /* MXCall.m in Sources */ = {isa = PBXBuildFile; fileRef = 3245A74D1AF7B2930001D8A7 /* MXCall.m */; };
Expand All @@ -62,6 +63,8 @@
32481A841C03572900782AD3 /* MXRoomAccountData.h in Headers */ = {isa = PBXBuildFile; fileRef = 32481A821C03572900782AD3 /* MXRoomAccountData.h */; };
32481A851C03572900782AD3 /* MXRoomAccountData.m in Sources */ = {isa = PBXBuildFile; fileRef = 32481A831C03572900782AD3 /* MXRoomAccountData.m */; };
325653831A2E14ED00CC0423 /* MXStoreTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 325653821A2E14ED00CC0423 /* MXStoreTests.m */; };
326056851C76FDF2009D44AD /* MXEventTimeline.h in Headers */ = {isa = PBXBuildFile; fileRef = 326056831C76FDF1009D44AD /* MXEventTimeline.h */; };
326056861C76FDF2009D44AD /* MXEventTimeline.m in Sources */ = {isa = PBXBuildFile; fileRef = 326056841C76FDF1009D44AD /* MXEventTimeline.m */; };
3264E2A21BDF8D1500F89A86 /* MXCoreDataRoomState.h in Headers */ = {isa = PBXBuildFile; fileRef = 3264E29E1BDF8D1500F89A86 /* MXCoreDataRoomState.h */; };
3264E2A31BDF8D1500F89A86 /* MXCoreDataRoomState.m in Sources */ = {isa = PBXBuildFile; fileRef = 3264E29F1BDF8D1500F89A86 /* MXCoreDataRoomState.m */; };
3264E2A41BDF8D1500F89A86 /* MXCoreDataRoomState+CoreDataProperties.h in Headers */ = {isa = PBXBuildFile; fileRef = 3264E2A01BDF8D1500F89A86 /* MXCoreDataRoomState+CoreDataProperties.h */; };
Expand Down Expand Up @@ -198,6 +201,7 @@
323E0C561A2F6E7D00A31D73 /* MXRoomPowerLevels.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MXRoomPowerLevels.m; sourceTree = "<group>"; };
323E0C591A306D7A00A31D73 /* MXEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MXEvent.h; sourceTree = "<group>"; };
323E0C5A1A306D7A00A31D73 /* MXEvent.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MXEvent.m; sourceTree = "<group>"; };
323EF7461C7CB4C7000DC98C /* MXEventTimelineTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MXEventTimelineTests.m; sourceTree = "<group>"; };
3240951E1AFA432F00D81C97 /* MXCallStackCall.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MXCallStackCall.h; sourceTree = "<group>"; };
3245A74C1AF7B2930001D8A7 /* MXCall.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MXCall.h; sourceTree = "<group>"; };
3245A74D1AF7B2930001D8A7 /* MXCall.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MXCall.m; sourceTree = "<group>"; };
Expand All @@ -207,6 +211,8 @@
32481A821C03572900782AD3 /* MXRoomAccountData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MXRoomAccountData.h; sourceTree = "<group>"; };
32481A831C03572900782AD3 /* MXRoomAccountData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MXRoomAccountData.m; sourceTree = "<group>"; };
325653821A2E14ED00CC0423 /* MXStoreTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MXStoreTests.m; sourceTree = "<group>"; };
326056831C76FDF1009D44AD /* MXEventTimeline.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MXEventTimeline.h; sourceTree = "<group>"; };
326056841C76FDF1009D44AD /* MXEventTimeline.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MXEventTimeline.m; sourceTree = "<group>"; };
3264E29E1BDF8D1500F89A86 /* MXCoreDataRoomState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MXCoreDataRoomState.h; sourceTree = "<group>"; };
3264E29F1BDF8D1500F89A86 /* MXCoreDataRoomState.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MXCoreDataRoomState.m; sourceTree = "<group>"; };
3264E2A01BDF8D1500F89A86 /* MXCoreDataRoomState+CoreDataProperties.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MXCoreDataRoomState+CoreDataProperties.h"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -325,6 +331,8 @@
32481A831C03572900782AD3 /* MXRoomAccountData.m */,
3220093619EFA4C9008DE41D /* MXEventListener.h */,
3220093719EFA4C9008DE41D /* MXEventListener.m */,
326056831C76FDF1009D44AD /* MXEventTimeline.h */,
326056841C76FDF1009D44AD /* MXEventTimeline.m */,
3220094319EFBF30008DE41D /* MXSessionEventListener.h */,
3220094419EFBF30008DE41D /* MXSessionEventListener.m */,
329FB1731A0A3A1600A5E88E /* MXRoomMember.h */,
Expand Down Expand Up @@ -514,6 +522,7 @@
32C6F93919DD814400EA4E9C /* MatrixSDKTests */ = {
isa = PBXGroup;
children = (
323EF7461C7CB4C7000DC98C /* MXEventTimelineTests.m */,
326D1EF41BFC79300030947B /* MXPushRuleTests.m */,
329571941B024D2B00ABB3BA /* Mocks */,
327E37B81A977810007F026F /* MXLoggerTests.m */,
Expand Down Expand Up @@ -644,6 +653,7 @@
320DFDE019DD99B60068622A /* MXSession.h in Headers */,
324095221AFA432F00D81C97 /* MXCallStackCall.h in Headers */,
3233606F1A403A0D0071A488 /* MXFileStore.h in Headers */,
326056851C76FDF2009D44AD /* MXEventTimeline.h in Headers */,
327137271A24D50A00DB6757 /* MXMyUser.h in Headers */,
3220093819EFA4C9008DE41D /* MXEventListener.h in Headers */,
71DE22E11BC7C51200284153 /* MXReceiptData.h in Headers */,
Expand Down Expand Up @@ -802,6 +812,7 @@
329FB1761A0A3A1600A5E88E /* MXRoomMember.m in Sources */,
323360701A403A0D0071A488 /* MXFileStore.m in Sources */,
32D7767E1A27860600FC4AA2 /* MXMemoryStore.m in Sources */,
326056861C76FDF2009D44AD /* MXEventTimeline.m in Sources */,
323B2B011BCE9B6700B11F34 /* MXCoreDataEvent.m in Sources */,
3265CB391A14C43E00E24B2F /* MXRoomState.m in Sources */,
323B2AD01BCD3EF000B11F34 /* MXCoreDataStore.m in Sources */,
Expand Down Expand Up @@ -866,6 +877,7 @@
32FCAB4D19E578860049C555 /* MXRestClientTests.m in Sources */,
329FB17C1A0A963700A5E88E /* MXRoomMemberTests.m in Sources */,
3246BDC51A1A0789000A7D62 /* MXRoomStateDynamicTests.m in Sources */,
323EF7471C7CB4C7000DC98C /* MXEventTimelineTests.m in Sources */,
32169AA21BD4D1B00077868B /* MXCoreDataStore.xcdatamodeld in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
5 changes: 3 additions & 2 deletions MatrixSDK/Data/MXEventListener.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#import <Foundation/Foundation.h>

#import "MXEvent.h"
#import "MXEventTimeline.h"

/**
Block called when an event of the registered types has been handled by the Matrix SDK.
Expand All @@ -26,7 +27,7 @@
@param customObject additional contect for the event. In case of room event, customObject is a
RoomState instance.
*/
typedef void (^MXOnEvent)(MXEvent *event, MXEventDirection direction, id customObject);
typedef void (^MXOnEvent)(MXEvent *event, MXTimelineDirection direction, id customObject);

/**
The `MXEventListener` class stores information about a listener to MXEvents that
Expand All @@ -46,7 +47,7 @@ typedef void (^MXOnEvent)(MXEvent *event, MXEventDirection direction, id customO
@param event the new event.
@param direction the origin of the event.
*/
- (void)notify:(MXEvent*)event direction:(MXEventDirection)direction andCustomObject:(id)customObject;
- (void)notify:(MXEvent*)event direction:(MXTimelineDirection)direction andCustomObject:(id)customObject;

@property (nonatomic, readonly) id sender;
@property (nonatomic, readonly) NSArray* eventTypes;
Expand Down
2 changes: 1 addition & 1 deletion MatrixSDK/Data/MXEventListener.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ -(instancetype)initWithSender:(id)sender
return self;
}

- (void)notify:(MXEvent*)event direction:(MXEventDirection)direction andCustomObject:(id)customObject
- (void)notify:(MXEvent*)event direction:(MXTimelineDirection)direction andCustomObject:(id)customObject
{
// Check if the event match with eventTypes
BOOL match = NO;
Expand Down
235 changes: 235 additions & 0 deletions MatrixSDK/Data/MXEventTimeline.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,235 @@
/*
Copyright 2016 OpenMarket 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 "MXEvent.h"
#import "MXJSONModels.h"
#import "MXRoomState.h"
#import "MXHTTPOperation.h"

/**
The direction of an event in the timeline.
*/
typedef enum : NSUInteger
{
// Forwards when the event is added to the end of the timeline.
// These events come from the /sync stream or from forwards pagination.
MXTimelineDirectionForwards,

// Backwards when the event is added to the start of the timeline.
// These events come from a back pagination.
MXTimelineDirectionBackwards
} MXTimelineDirection;

/**
Prefix used to build fake invite event.
*/
FOUNDATION_EXPORT NSString *const kMXRoomInviteStateEventIdPrefix;

/**
Block called when an event of the registered types has been handled in the timeline.
This is a specialisation of the `MXOnEvent` block.
@param event the new event.
@param direction the origin of the event.
@param roomState the room state right before the event.
*/
typedef void (^MXOnRoomEvent)(MXEvent *event, MXTimelineDirection direction, MXRoomState *roomState);

@class MXRoom;


/**
A `MXEventTimeline` instance represents a contiguous sequence of events in a room.
There are two kinds of timeline:
- live timelines: they receive live events from the events stream. You can paginate
backwards but not forwards.
All (live or backwards) events they receive are stored in the store of the current
MXSession.
- past timelines: they start in the past from an `initialEventId`. They are filled
with events on calls of [MXEventTimeline paginate] in backwards or forwards direction.
Events are stored in a in-memory store (MXMemoryStore) (@TODO: To be confirmed once they will be implemented). So, they are not permanent.
*/
@interface MXEventTimeline : NSObject

/**
The initial event id used to initialise the timeline.
Nil in case of live timeline.
*/
@property (nonatomic, readonly) NSString *initialEventId;

/**
Indicate if this timeline is a live one.
*/
@property (nonatomic, readonly) BOOL isLiveTimeline;

/**
The state of the room at the top most recent event of the timeline.
*/
@property (nonatomic, readonly) MXRoomState *state;


#pragma mark - Initialisation
/**
Create a timeline instance for a room.
@param room the room associated to the timeline
@param initialEventId the initial event for the timeline. A nil value will create a live timeline.
@return a MXEventTimeline instance.
*/
- (id)initWithRoom:(MXRoom*)room andInitialEventId:(NSString*)initialEventId;

/**
Initialise the room evenTimeline state.
@param stateEvents the state event.
*/
- (void)initialiseState:(NSArray<MXEvent*> *)stateEvents;

/**
Release RAM memory used by the timeline.
*/
- (void)destroy;


#pragma mark - Pagination
/**
Check if this timelime can be extended.
This returns true if we either have more events, or if we have a pagination
token which means we can paginate in that direction. It does not necessarily
mean that there are more events available in that direction at this time.
canPaginate in forward direction has no meaning for a live timeline.
@param direction MXTimelineDirectionBackwards to check if we can paginate backwards.
MXTimelineDirectionForwards to check if we can go forwards.
@return true if we can paginate in the given direction.
*/
- (BOOL)canPaginate:(MXTimelineDirection)direction;

/**
Reset the pagination so that future calls to paginate start from the most recent
event of the timeline.
*/
- (void)resetPagination;

/**
Reset the pagination timelime and start loading the context around its `initialEventId`.
The retrieved (backwards and forwards) events will be sent to registered listeners.
@param limit the maximum number of messages to get around the initial event.
@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*)resetPaginationAroundInitialEventWithLimit:(NSUInteger)limit
success:(void(^)())success
failure:(void (^)(NSError *error))failure;

/**
Get more messages.
The retrieved events will be sent to registered listeners.
Note it is not possible to paginate forwards on a live timeline.
@param numItems the number of items to get.
@param direction `MXTimelineDirectionForwards` or `MXTimelineDirectionBackwards`
@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 homeserver is required.
*/
- (MXHTTPOperation*)paginate:(NSUInteger)numItems
direction:(MXTimelineDirection)direction
onlyFromStore:(BOOL)onlyFromStore
complete:(void (^)())complete
failure:(void (^)(NSError *error))failure;

/**
Get the number of messages we can still back paginate from the store.
It provides the count of events available without making a request to the home server.
@return the count of remaining messages in store.
*/
- (NSUInteger)remainingMessagesForBackPaginationInStore;


#pragma mark - Server sync
/**
For live timeline, update data according to the received /sync response.
@param roomSync information to sync the room with the home server data
*/
- (void)handleJoinedRoomSync:(MXRoomSync*)roomSync;

/**
For live timeline, update invited room state according to the received /sync response.
@param invitedRoom information to update the room state.
*/
- (void)handleInvitedRoomSync:(MXInvitedRoomSync *)invitedRoomSync;


#pragma mark - Events listeners
/**
Register a listener to events of this timeline.
@param onEvent the block that will called once a new event has been handled.
@return a reference to use to unregister the listener
*/
- (id)listenToEvents:(MXOnRoomEvent)onEvent;

/**
Register a listener for some types of events.
@param types an array of event types strings (MXEventTypeString) to listen to.
@param onEvent the block that will called once a new event has been handled.
@return a reference to use to unregister the listener
*/
- (id)listenToEventsOfTypes:(NSArray*)types onEvent:(MXOnRoomEvent)onEvent;

/**
Unregister a listener.
@param listener the reference of the listener to remove.
*/
- (void)removeListener:(id)listener;

/**
Unregister all listeners.
*/
- (void)removeAllListeners;

/**
Notifiy all listeners of the timeline about the given event.
@param event the event to notify.
@param the event direction.
*/
- (void)notifyListeners:(MXEvent*)event direction:(MXTimelineDirection)direction;

@end
Loading

0 comments on commit 33eb8db

Please sign in to comment.