<commit_before>/*
 Copyright 2017 OpenMarket Ltd
 Copyright 2017 Vector Creations 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 "MXJSONModels.h"
#import "MXHTTPOperation.h"
#import "MXRoomMembersCount.h"
#import "MXEnumConstants.h"

@class MXSession, MXRoom, MXRoomState, MXEvent;


/**
 Posted when a room summary has changed.
 
 Note that MXRoom.summary data is handled after MXRoom.liveTimeline and MXRoom.state.
 That means that MXRoom.summary may not be up-to-date on events forecasted by 
 [MXRoom.liveTimeline listenToEvents] blocks.
 
 You must check for `kMXRoomSummaryDidChangeNotification` to get up-to-date MXRoom.summary.
 
 The notification object is the concerned room summary, nil when the change concerns all the room summaries.
 */
FOUNDATION_EXPORT NSString *const kMXRoomSummaryDidChangeNotification;


/**
 `MXRoomSummary` exposes and caches data for a room.

 Data is updated on every incoming events in the room through the
 roomSummaryUpdateDelegate object of the MXSession instance.

 By default MXSession uses a default implementation of MXRoomSummaryUpdating, MXRoomSummaryUpdater.
 But the application is free to provide its own so that, for example, in the case
 where the room has no displayname, the app can format the display name with a
 different manner.

 At any time, the application can also change the value as long as it is done on the
 main thread.
 
 `MXRoomSummary` contains several kinds of data:

     * Room state data:
       This is data provided by room state events but it is cached to avoid to 
       recompute everything everytime from the state events.
       Ex: the displayname of the room.

     * Last message data:
       This is lastMessageEventId plus the string or/and attributed string computed for
       this last message event.

     * Business logic data:
       This is data that is used internally by the sdk.
 
     * Other data:
       Other information shared between the sdk and sdk user.
 */
@interface MXRoomSummary : NSObject <NSCoding>

/**
 The Matrix id of the room.
 */
@property (nonatomic, readonly) NSString *roomId;

/**
 The related matrix session.
 */
@property (nonatomic, readonly) MXSession *mxSession;

/**
 Shortcut to the corresponding room.
 */
@property (nonatomic, readonly) MXRoom *room;

/**
 Create a `MXRoomSummary` instance.

 @param roomId the id of the room.
 @param mxSession the session to use.
 @return the new instance.
 */
- (instancetype)initWithRoomId:(NSString*)roomId andMatrixSession:(MXSession*)mxSession;

/**
 Dispose any resources and listener.
 */
- (void)destroy;

/**
 Set the Matrix session.

 Must be used for MXRoomSummary instance loaded from the store.

 @param mxSession the session to use.
 */
- (void)setMatrixSession:(MXSession*)mxSession;

/**
 Save room summary data.
 
 This method must be called when data is modified outside the `MXRoomSummaryUpdating` callbacks.
 It will generate a `kMXRoomSummaryDidChangeNotification`.
 
 @param commit YES to force flush it to the store. Use NO when a more
                global [MXStore commit] will happen. This optimises IO.
 */
- (void)save:(BOOL)commit;

#pragma mark - Data related to room state

/**
 The Matrix content URI of the room avatar.
 */
@property (nonatomic) NSString *avatar;

/**
 The computed display name of the room.
 */
@property (nonatomic) NSString *displayname;

/**
 The topic of the room.
 */
@property (nonatomic) NSString *topic;

/**
 The membership state of the logged in user for this room.
 */
@property (nonatomic) MXMembership membership;

/**
 Room members counts.
 */
@property (nonatomic) MXRoomMembersCount *membersCount;

/**
 Reset data related to room state.
 
 It recomputes every data related to the room state from the current room state.
 */
- (void)resetRoomStateData;


#pragma mark - Data related to the last message

/**
 The last message event id.
 */
@property (nonatomic, readonly) NSString *lastMessageEventId;

/**
 The last message server timestamp.
 */
@property (nonatomic, readonly) uint64_t lastMessageOriginServerTs;

/**
 Indicates if the last message is encrypted.<commit_msg>[MXRoomSummary] Add boolean property to indicate if the room should be hidden from user.<commit_after>/*
 Copyright 2017 OpenMarket Ltd
 Copyright 2017 Vector Creations 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 "MXJSONModels.h"
#import "MXHTTPOperation.h"
#import "MXRoomMembersCount.h"
#import "MXEnumConstants.h"

@class MXSession, MXRoom, MXRoomState, MXEvent;


/**
 Posted when a room summary has changed.
 
 Note that MXRoom.summary data is handled after MXRoom.liveTimeline and MXRoom.state.
 That means that MXRoom.summary may not be up-to-date on events forecasted by 
 [MXRoom.liveTimeline listenToEvents] blocks.
 
 You must check for `kMXRoomSummaryDidChangeNotification` to get up-to-date MXRoom.summary.
 
 The notification object is the concerned room summary, nil when the change concerns all the room summaries.
 */
FOUNDATION_EXPORT NSString *const kMXRoomSummaryDidChangeNotification;


/**
 `MXRoomSummary` exposes and caches data for a room.

 Data is updated on every incoming events in the room through the
 roomSummaryUpdateDelegate object of the MXSession instance.

 By default MXSession uses a default implementation of MXRoomSummaryUpdating, MXRoomSummaryUpdater.
 But the application is free to provide its own so that, for example, in the case
 where the room has no displayname, the app can format the display name with a
 different manner.

 At any time, the application can also change the value as long as it is done on the
 main thread.
 
 `MXRoomSummary` contains several kinds of data:

     * Room state data:
       This is data provided by room state events but it is cached to avoid to 
       recompute everything everytime from the state events.
       Ex: the displayname of the room.

     * Last message data:
       This is lastMessageEventId plus the string or/and attributed string computed for
       this last message event.

     * Business logic data:
       This is data that is used internally by the sdk.
 
     * Other data:
       Other information shared between the sdk and sdk user.
 */
@interface MXRoomSummary : NSObject <NSCoding>

/**
 The Matrix id of the room.
 */
@property (nonatomic, readonly) NSString *roomId;

/**
 The related matrix session.
 */
@property (nonatomic, readonly) MXSession *mxSession;

/**
 Shortcut to the corresponding room.
 */
@property (nonatomic, readonly) MXRoom *room;

/**
 Create a `MXRoomSummary` instance.

 @param roomId the id of the room.
 @param mxSession the session to use.
 @return the new instance.
 */
- (instancetype)initWithRoomId:(NSString*)roomId andMatrixSession:(MXSession*)mxSession;

/**
 Dispose any resources and listener.
 */
- (void)destroy;

/**
 Set the Matrix session.

 Must be used for MXRoomSummary instance loaded from the store.

 @param mxSession the session to use.
 */
- (void)setMatrixSession:(MXSession*)mxSession;

/**
 Save room summary data.
 
 This method must be called when data is modified outside the `MXRoomSummaryUpdating` callbacks.
 It will generate a `kMXRoomSummaryDidChangeNotification`.
 
 @param commit YES to force flush it to the store. Use NO when a more
                global [MXStore commit] will happen. This optimises IO.
 */
- (void)save:(BOOL)commit;

#pragma mark - Data related to room state

/**
 The Matrix content URI of the room avatar.
 */
@property (nonatomic) NSString *avatar;

/**
 The computed display name of the room.
 */
@property (nonatomic) NSString *displayname;

/**
 The topic of the room.
 */
@property (nonatomic) NSString *topic;

/**
 The membership state of the logged in user for this room.
 */
@property (nonatomic) MXMembership membership;

/**
 Room members counts.
 */
@property (nonatomic) MXRoomMembersCount *membersCount;

/**
 Indicate whether this room should be hidden from the user.
 */
@property (nonatomic) BOOL hideFromUser;

/**
 Reset data related to room state.
 
 It recomputes every data related to the room state from the current room state.
 */
- (void)resetRoomStateData;


#pragma mark - Data related to the last message

/**
 The last message event id.
 */
@property (nonatomic, readonly) NSString *lastMessageEventId;

/**
 The last message server timestamp.
 */
@property (nonatomic, readonly) uint64_t lastMessageOriginServerTs;

/**
 Indicates if the last message is encrypted.
{'fraction_non_alphanumeric': 0.07161691804661956, 'fraction_numerical': 0.0029532749709946207, 'mean_word_length': 3.880082346886258, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6486557', 'n_tokens_mistral': 2622, 'n_tokens_neox': 2483, 'n_words': 1186}