Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/release-v0.6.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
giomfo committed Mar 17, 2016
2 parents 33eb8db + cfba01e commit 5a56b14
Show file tree
Hide file tree
Showing 15 changed files with 152 additions and 66 deletions.
12 changes: 12 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
Changes in Matrix iOS SDK in 0.6.4 (2016-03-17)
===============================================

Improvements:
* MXRoom: Update unread events handling (ignore m.room.member events and redacted events).
* MXRoomPowerLevels: power level values are signed.
* MXStore: Retrieve the receipt for a user in a room.

Bug fixes:
* App crashes on redacted event handling.
* The account data changes are ignored (Favorites section is not refreshed correctly).

Changes in Matrix iOS SDK in 0.6.3 (2016-03-07)
===============================================

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

Expand Down
2 changes: 1 addition & 1 deletion MatrixSDK/Data/MXEventTimeline.m
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ - (void)addEvent:(MXEvent*)event direction:(MXTimelineDirection)direction fromSt
data.eventId = event.eventId;
data.ts = event.originServerTs;

[store storeReceipt:data roomId:_state.roomId];
[store storeReceipt:data inRoom:_state.roomId];
}

// Store the event
Expand Down
16 changes: 11 additions & 5 deletions MatrixSDK/Data/MXRoom.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ FOUNDATION_EXPORT NSString *const kMXRoomSyncWithLimitedTimelineNotification;

/**
Tell whether the room has unread events.
This value depends on acknowledgableEventTypes.
This value depends on unreadEventTypes.
*/
@property (nonatomic, readonly) BOOL hasUnreadEvents;

Expand All @@ -117,16 +117,21 @@ FOUNDATION_EXPORT NSString *const kMXRoomSyncWithLimitedTimelineNotification;
@property (nonatomic, readonly) NSUInteger highlightCount;

/**
* An array of event types strings (MXEventTypeString).
* By default any event type except the typing, the receipts and the presence ones.
An array of event types strings ('MXEventTypeString').
By default any event type except the typing, the receipts and the presence ones.
*/
@property (nonatomic) NSArray* acknowledgableEventTypes;

/**
The list of event types ('MXEventTypeString') considered to check the presence of some unread events.
By default [m.room.name, m.room.topic, m.room.message, m.call.invite].
*/
@property (nonatomic) NSArray* unreadEventTypes;

- (id)initWithRoomId:(NSString*)roomId andMatrixSession:(MXSession*)mxSession;

- (id)initWithRoomId:(NSString*)roomId andMatrixSession:(MXSession*)mxSession andStateEvents:(NSArray*)stateEvents andAccountData:(MXRoomAccountData*)accountData;


#pragma mark - server sync

/**
Expand Down Expand Up @@ -346,7 +351,7 @@ FOUNDATION_EXPORT NSString *const kMXRoomSyncWithLimitedTimelineNotification;
@return a MXHTTPOperation instance.
*/
- (MXHTTPOperation*)setPowerLevelOfUserWithUserID:(NSString*)userId powerLevel:(NSUInteger)powerLevel
- (MXHTTPOperation*)setPowerLevelOfUserWithUserID:(NSString*)userId powerLevel:(NSInteger)powerLevel
success:(void (^)())success
failure:(void (^)(NSError *error))failure;

Expand Down Expand Up @@ -524,6 +529,7 @@ FOUNDATION_EXPORT NSString *const kMXRoomSyncWithLimitedTimelineNotification;


#pragma mark - Utils

/**
Comparator to use to order array of rooms by their lastest originServerTs value.
Expand Down
21 changes: 15 additions & 6 deletions MatrixSDK/Data/MXRoom.m
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ - (id)initWithRoomId:(NSString *)roomId andMatrixSession:(MXSession *)mxSession2
kMXEventTypeStringCallAnswer,
kMXEventTypeStringCallHangup
];

_unreadEventTypes = @[kMXEventTypeStringRoomName,
kMXEventTypeStringRoomTopic,
kMXEventTypeStringRoomMessage,
kMXEventTypeStringCallInvite
];
}

return self;
Expand All @@ -77,7 +83,10 @@ - (id)initWithRoomId:(NSString *)roomId andMatrixSession:(MXSession *)mxSession2
@autoreleasepool
{
[_liveTimeline initialiseState:stateEvents];
_accountData = accountData;

// Report the provided accountData.
// Allocate a new instance if none, in order to handle room tag events for this room.
_accountData = accountData ? accountData : [[MXRoomAccountData alloc] init];
}
}
return self;
Expand Down Expand Up @@ -281,7 +290,7 @@ - (MXHTTPOperation*)unbanUser:(NSString*)userId
return [mxSession.matrixRestClient unbanUser:userId inRoom:self.state.roomId success:success failure:failure];
}

- (MXHTTPOperation*)setPowerLevelOfUserWithUserID:(NSString *)userId powerLevel:(NSUInteger)powerLevel
- (MXHTTPOperation*)setPowerLevelOfUserWithUserID:(NSString *)userId powerLevel:(NSInteger)powerLevel
success:(void (^)())success
failure:(void (^)(NSError *))failure
{
Expand All @@ -290,7 +299,7 @@ - (MXHTTPOperation*)setPowerLevelOfUserWithUserID:(NSString *)userId powerLevel:
NSMutableDictionary *newPowerLevelsEventContent = [NSMutableDictionary dictionaryWithDictionary:self.state.powerLevels.JSONDictionary];

NSMutableDictionary *newPowerLevelsEventContentUsers = [NSMutableDictionary dictionaryWithDictionary:newPowerLevelsEventContent[@"users"]];
newPowerLevelsEventContentUsers[userId] = [NSNumber numberWithUnsignedInteger:powerLevel];
newPowerLevelsEventContentUsers[userId] = [NSNumber numberWithInteger:powerLevel];

newPowerLevelsEventContent[@"users"] = newPowerLevelsEventContentUsers;

Expand Down Expand Up @@ -467,7 +476,7 @@ - (BOOL)handleReceiptEvent:(MXEvent *)event direction:(MXTimelineDirection)direc
data.eventId = eventId;
data.ts = ((NSNumber*)[params objectForKey:@"ts"]).longLongValue;

managedEvents |= [mxSession.store storeReceipt:data roomId:self.state.roomId];
managedEvents |= [mxSession.store storeReceipt:data inRoom:self.state.roomId];
}
}
}
Expand Down Expand Up @@ -495,7 +504,7 @@ - (BOOL)acknowledgeLatestEvent:(BOOL)sendReceipt;
data.eventId = event.eventId;
data.ts = (uint64_t) ([[NSDate date] timeIntervalSince1970] * 1000);

if ([mxSession.store storeReceipt:data roomId:self.state.roomId])
if ([mxSession.store storeReceipt:data inRoom:self.state.roomId])
{
if ([mxSession.store respondsToSelector:@selector(commit)])
{
Expand All @@ -521,7 +530,7 @@ - (BOOL)acknowledgeLatestEvent:(BOOL)sendReceipt;
- (BOOL)hasUnreadEvents
{
// Check for unread events in store
return [mxSession.store hasUnreadEvents:self.state.roomId withTypeIn:_acknowledgableEventTypes];
return [mxSession.store hasUnreadEvents:self.state.roomId withTypeIn:_unreadEventTypes];
}

- (NSArray*)getEventReceipts:(NSString*)eventId sorted:(BOOL)sort
Expand Down
12 changes: 9 additions & 3 deletions MatrixSDK/Data/MXRoomState.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ @interface MXRoomState ()
/**
Maximum power level observed in power level list
*/
NSUInteger maxPowerLevel;
NSInteger maxPowerLevel;

/**
Disambiguate members names in big rooms takes time. So, cache computed data.
Expand Down Expand Up @@ -469,8 +469,8 @@ - (void)handleStateEvent:(MXEvent*)event
NSArray *array = powerLevels.users.allValues;
for (NSNumber *powerLevel in array)
{
NSUInteger level = 0;
MXJSONModelSetUInteger(level, powerLevel);
NSInteger level = 0;
MXJSONModelSetInteger(level, powerLevel);
if (level > maxPowerLevel)
{
maxPowerLevel = level;
Expand Down Expand Up @@ -505,6 +505,12 @@ - (MXRoomThirdPartyInvite *)thirdPartyInviteWithToken:(NSString *)thirdPartyInvi

- (NSString*)memberName:(NSString*)userId
{
// Sanity check
if (!userId.length)
{
return nil;
}

// First, lookup in the cache
NSString *displayName = membersNamesCache[userId];

Expand Down
8 changes: 7 additions & 1 deletion MatrixSDK/Data/Store/MXCoreDataStore/MXCoreDataStore.m
Original file line number Diff line number Diff line change
Expand Up @@ -330,12 +330,18 @@ - (NSArray*)getEventReceipts:(NSString*)roomId eventId:(NSString*)eventId sorted
return nil;
}

- (BOOL)storeReceipt:(MXReceiptData*)receipt roomId:(NSString*)roomId
- (BOOL)storeReceipt:(MXReceiptData*)receipt inRoom:(NSString*)roomId
{
// TODO
return NO;
}

- (MXReceiptData *)getReceiptInRoom:(NSString*)roomId forUserId:(NSString*)userId
{
// TODO
return nil;
}

- (BOOL)hasUnreadEvents:(NSString*)roomId withTypeIn:(NSArray*)types
{
// TODO
Expand Down
5 changes: 3 additions & 2 deletions MatrixSDK/Data/Store/MXFileStore/MXFileStore.m
Original file line number Diff line number Diff line change
Expand Up @@ -835,9 +835,10 @@ - (void)saveMetaData
* @param receipt The event
* @param roomId The roomId
*/
- (BOOL)storeReceipt:(MXReceiptData*)receipt roomId:(NSString*)roomId
- (BOOL)storeReceipt:(MXReceiptData*)receipt inRoom:(NSString*)roomId
{
if ([super storeReceipt:receipt roomId:roomId]) {
if ([super storeReceipt:receipt inRoom:roomId])
{
if (NSNotFound == [roomsToCommitForReceipts indexOfObject:roomId])
{
[roomsToCommitForReceipts addObject:roomId];
Expand Down
30 changes: 28 additions & 2 deletions MatrixSDK/Data/Store/MXMemoryStore/MXMemoryStore.m
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ - (NSArray*)getEventReceipts:(NSString*)roomId eventId:(NSString*)eventId sorted
return receipts;
}

- (BOOL)storeReceipt:(MXReceiptData*)receipt roomId:(NSString*)roomId
- (BOOL)storeReceipt:(MXReceiptData*)receipt inRoom:(NSString*)roomId
{
NSMutableDictionary* receiptsByUserId = [receiptsByRoomId objectForKey:roomId];

Expand All @@ -220,6 +220,23 @@ - (BOOL)storeReceipt:(MXReceiptData*)receipt roomId:(NSString*)roomId
return false;
}

- (MXReceiptData *)getReceiptInRoom:(NSString*)roomId forUserId:(NSString*)userId
{
MXMemoryRoomStore* store = [roomStores valueForKey:roomId];
NSMutableDictionary* receipsByUserId = [receiptsByRoomId objectForKey:roomId];

if (store && receipsByUserId)
{
MXReceiptData* data = [receipsByUserId objectForKey:userId];
if (data)
{
return [data copy];
}
}

return nil;
}

- (BOOL)hasUnreadEvents:(NSString*)roomId withTypeIn:(NSArray*)types
{
MXMemoryRoomStore* store = [roomStores valueForKey:roomId];
Expand All @@ -233,7 +250,16 @@ - (BOOL)hasUnreadEvents:(NSString*)roomId withTypeIn:(NSArray*)types
{
// Check the current stored events (by ignoring oneself events)
NSArray *array = [store eventsAfter:data.eventId except:credentials.userId withTypeIn:[NSSet setWithArray:types]];
return (array.count != 0);

// Check whether these unread events have not been redacted.
for (MXEvent *event in array)
{
if (event.redactedBecause == nil)
{
// There is at least one unread event - Done
return YES;
}
}
}
}

Expand Down
7 changes: 6 additions & 1 deletion MatrixSDK/Data/Store/MXNoStore/MXNoStore.m
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,16 @@ - (NSArray*)getEventReceipts:(NSString*)roomId eventId:(NSString*)eventId sorted
return nil;
}

- (BOOL)storeReceipt:(MXReceiptData*)receipt roomId:(NSString*)roomId
- (BOOL)storeReceipt:(MXReceiptData*)receipt inRoom:(NSString*)roomId
{
return NO;
}

- (MXReceiptData *)getReceiptInRoom:(NSString*)roomId forUserId:(NSString*)userId
{
return nil;
}

- (BOOL)hasUnreadEvents:(NSString*)roomId withTypeIn:(NSArray*)types
{
return NO;
Expand Down
42 changes: 27 additions & 15 deletions MatrixSDK/Data/Store/MXStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,28 +172,40 @@


/**
* Returns the receipts list for an event in a dedicated room.
* if sort is set to YES, they are sorted from the latest to the oldest ones.
* @param roomId The room Id.
* @param eventId The event Id.
* @param sort to sort them from the latest to the oldest
* @return the receipts for an event in a dedicated room.
Returns the receipts list for an event in a dedicated room.
if sort is set to YES, they are sorted from the latest to the oldest ones.
@param roomId The room Id.
@param eventId The event Id.
@param sort to sort them from the latest to the oldest
@return the receipts for an event in a dedicated room.
*/
- (NSArray*)getEventReceipts:(NSString*)roomId eventId:(NSString*)eventId sorted:(BOOL)sort;

/**
* Store the receipt for an user in a room
* @param receipt The event
* @param roomId The roomId
* @return true if the receipt has been stored
Store the receipt for a user in a room
@param receipt The event
@param roomId The roomId
@return true if the receipt has been stored
*/
- (BOOL)storeReceipt:(MXReceiptData*)receipt roomId:(NSString*)roomId;
- (BOOL)storeReceipt:(MXReceiptData*)receipt inRoom:(NSString*)roomId;

/**
* Check whether a room has some unread events.
* @param roomId the room id.
* @param types an array of event types strings (MXEventTypeString).
* @return YES if at least one stored event has its type listed in provided array.
Retrieve the receipt for a user in a room
@param roomId The roomId
@param userId The user identifier
@return the current stored receipt (nil by default).
*/
- (MXReceiptData *)getReceiptInRoom:(NSString*)roomId forUserId:(NSString*)userId;

/**
Check whether a room has some unread events.
@param roomId the room id.
@param types an array of event types strings (MXEventTypeString).
@return YES if at least one stored event has its type listed in provided array.
*/
- (BOOL)hasUnreadEvents:(NSString*)roomId withTypeIn:(NSArray*)types;

Expand Down
Loading

0 comments on commit 5a56b14

Please sign in to comment.