diff --git a/MatrixSDK/Data/MXRoomSummary.h b/MatrixSDK/Data/MXRoomSummary.h index 4930be9f42..e3972ed5d4 100644 --- a/MatrixSDK/Data/MXRoomSummary.h +++ b/MatrixSDK/Data/MXRoomSummary.h @@ -213,6 +213,11 @@ FOUNDATION_EXPORT NSUInteger const MXRoomSummaryPaginationChunkSize; */ @property (nonatomic) BOOL isConferenceUserRoom; +/** + Flag indicating if the room is a sip soom with at least one sip participant. + */ +@property (nonatomic) BOOL isSipCallRoom; + /** Indicate whether this room should be hidden from the user. */ diff --git a/MatrixSDK/Data/MXRoomSummary.m b/MatrixSDK/Data/MXRoomSummary.m index a091e2eb1c..8bd5956b0f 100644 --- a/MatrixSDK/Data/MXRoomSummary.m +++ b/MatrixSDK/Data/MXRoomSummary.m @@ -234,6 +234,7 @@ - (void)updateWith:(id)summary _membershipTransitionState = summary.membershipTransitionState; _membersCount = summary.membersCount; _isConferenceUserRoom = summary.isConferenceUserRoom; + _isSipCallRoom = summary.isSipCallRoom; _hiddenFromUser = summary.hiddenFromUser; _storedHash = summary.storedHash; _lastMessage = summary.lastMessage; @@ -948,6 +949,7 @@ - (instancetype)initWithCoder:(NSCoder *)aDecoder _membershipTransitionState = [MXRoomSummary membershipTransitionStateForMembership:_membership]; _membersCount = [aDecoder decodeObjectForKey:@"membersCount"]; _isConferenceUserRoom = [(NSNumber*)[aDecoder decodeObjectForKey:@"isConferenceUserRoom"] boolValue]; + _isSipCallRoom = [(NSNumber*)[aDecoder decodeObjectForKey:@"isSipCallRoom"] boolValue]; _others = [aDecoder decodeObjectForKey:@"others"]; _isEncrypted = [aDecoder decodeBoolForKey:@"isEncrypted"]; @@ -995,6 +997,7 @@ - (void)encodeWithCoder:(NSCoder *)aCoder [aCoder encodeInteger:(NSInteger)_membership forKey:@"membership"]; [aCoder encodeObject:_membersCount forKey:@"membersCount"]; [aCoder encodeObject:@(_isConferenceUserRoom) forKey:@"isConferenceUserRoom"]; + [aCoder encodeObject:@(_isSipCallRoom) forKey:@"isSipCallRoom"]; [aCoder encodeObject:_others forKey:@"others"]; [aCoder encodeBool:_isEncrypted forKey:@"isEncrypted"]; @@ -1098,7 +1101,10 @@ - (MXRoomSummaryDataTypes)calculateDataTypes { result |= MXRoomSummaryDataTypesConferenceUser; } - + if (self.isSipCallRoom) + { + result |= MXRoomSummaryDataTypesSipCall; + } return result; } diff --git a/MatrixSDK/Data/MXRoomSummaryDataTypes.h b/MatrixSDK/Data/MXRoomSummaryDataTypes.h index ca4e989eb1..ef21637211 100644 --- a/MatrixSDK/Data/MXRoomSummaryDataTypes.h +++ b/MatrixSDK/Data/MXRoomSummaryDataTypes.h @@ -26,7 +26,8 @@ typedef NS_OPTIONS(NSInteger, MXRoomSummaryDataTypes) MXRoomSummaryDataTypesServerNotice = 1 << 4, MXRoomSummaryDataTypesHidden = 1 << 5, MXRoomSummaryDataTypesSpace = 1 << 6, - MXRoomSummaryDataTypesConferenceUser = 1 << 7 + MXRoomSummaryDataTypesConferenceUser = 1 << 7, + MXRoomSummaryDataTypesSipCall = 1 << 8 }; #endif /* MXRoomSummaryDataTypes_h */ diff --git a/MatrixSDK/Data/MXRoomSummaryProtocol.h b/MatrixSDK/Data/MXRoomSummaryProtocol.h index b3666febd3..923a511db2 100644 --- a/MatrixSDK/Data/MXRoomSummaryProtocol.h +++ b/MatrixSDK/Data/MXRoomSummaryProtocol.h @@ -76,6 +76,9 @@ NS_ASSUME_NONNULL_BEGIN /// displayed to the end user. @property (nonatomic, readonly) BOOL isConferenceUserRoom; +/// Flag indicating if the room is a sip soom with at least one sip participant. +@property (nonatomic, readonly) BOOL isSipCallRoom; + /// Indicate whether this room should be hidden from the user. @property (nonatomic, readonly) BOOL hiddenFromUser; diff --git a/MatrixSDK/Data/MXRoomSummaryUpdater.m b/MatrixSDK/Data/MXRoomSummaryUpdater.m index 124c4fc4f0..04c872978f 100644 --- a/MatrixSDK/Data/MXRoomSummaryUpdater.m +++ b/MatrixSDK/Data/MXRoomSummaryUpdater.m @@ -265,6 +265,13 @@ - (BOOL)session:(MXSession *)session updateRoomSummary:(MXRoomSummary *)summary summary.isConferenceUserRoom = roomState.isConferenceUserRoom; updated = YES; } + + BOOL isSipCallRoom = [self shouldListAsSipCallRoom:roomState]; + if (summary.isSipCallRoom != isSipCallRoom) + { + summary.isSipCallRoom = isSipCallRoom; + updated = YES; + } } if (summary.membership == MXMembershipInvite) @@ -714,6 +721,19 @@ - (BOOL)updateSummaryMemberCount:(MXRoomSummary *)summary session:(MXSession *)s return otherMembers; } +- (BOOL)shouldListAsSipCallRoom:(MXRoomState*)roomState +{ + for (MXRoomMember *member in roomState.members.members) + { + if ([member.userId hasPrefix:@"@_sip_sip="]) + { + return YES; + } + } + + return NO; +} + - (BOOL)shouldHideRoomWithRoomTypeString:(NSString*)roomTypeString { BOOL hiddenFromUser = NO; diff --git a/changelog.d/1396.feature b/changelog.d/1396.feature new file mode 100644 index 0000000000..3fa87533ae --- /dev/null +++ b/changelog.d/1396.feature @@ -0,0 +1 @@ +Add support for bridged users and rooms with bridged users.