2014-11-24 09:38:23 +00:00
|
|
|
/*
|
|
|
|
Copyright 2014 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 <MatrixSDK/MatrixSDK.h>
|
|
|
|
|
|
|
|
extern NSString *const kMatrixHandlerUnsupportedMessagePrefix;
|
|
|
|
|
2015-01-05 14:11:40 +00:00
|
|
|
typedef enum : NSUInteger {
|
|
|
|
MatrixHandlerStatusLoggedOut = 0,
|
|
|
|
MatrixHandlerStatusLogged,
|
|
|
|
MatrixHandlerStatusStoreDataReady,
|
|
|
|
MatrixHandlerStatusServerSyncDone
|
|
|
|
} MatrixHandlerStatus;
|
|
|
|
|
2014-11-24 09:38:23 +00:00
|
|
|
@interface MatrixHandler : NSObject
|
|
|
|
|
2015-01-16 09:42:36 +00:00
|
|
|
@property (strong, nonatomic) dispatch_queue_t processingQueue;
|
|
|
|
|
2014-11-24 09:38:23 +00:00
|
|
|
@property (strong, nonatomic) MXRestClient *mxRestClient;
|
|
|
|
@property (strong, nonatomic) MXSession *mxSession;
|
|
|
|
|
|
|
|
@property (strong, nonatomic) NSString *homeServerURL;
|
|
|
|
@property (strong, nonatomic) NSString *homeServer;
|
|
|
|
@property (strong, nonatomic) NSString *userLogin;
|
|
|
|
@property (strong, nonatomic) NSString *userId;
|
2014-12-08 16:41:56 +00:00
|
|
|
@property (strong, nonatomic, readonly) NSString *localPartFromUserId;
|
2014-11-24 09:38:23 +00:00
|
|
|
@property (strong, nonatomic) NSString *accessToken;
|
|
|
|
|
2014-12-02 09:27:26 +00:00
|
|
|
// The type of events to display
|
|
|
|
@property (strong, nonatomic) NSArray *eventsFilterForMessages;
|
|
|
|
|
2014-11-24 09:38:23 +00:00
|
|
|
// Matrix user's settings
|
2014-12-09 17:21:39 +00:00
|
|
|
@property (nonatomic) MXPresence userPresence;
|
2014-11-24 09:38:23 +00:00
|
|
|
|
2015-01-05 14:11:40 +00:00
|
|
|
@property (nonatomic,readonly) MatrixHandlerStatus status;
|
2014-12-05 10:55:01 +00:00
|
|
|
@property (nonatomic,readonly) BOOL isResumeDone;
|
2014-12-19 10:03:09 +00:00
|
|
|
// return the MX cache size in bytes
|
|
|
|
@property (nonatomic,readonly) NSUInteger MXCacheSize;
|
2015-01-19 07:58:45 +00:00
|
|
|
// return the sum of the caches (MX cache + media cache ...) in bytes
|
2015-01-09 16:14:09 +00:00
|
|
|
@property (nonatomic,readonly) NSUInteger cachesSize;
|
2015-01-19 07:58:45 +00:00
|
|
|
// defines the min allow cache size in bytes
|
|
|
|
@property (nonatomic,readonly) NSUInteger minCachesSize;
|
|
|
|
// defines the current max caches size in bytes
|
|
|
|
@property (nonatomic,readwrite) NSUInteger currentMaxCachesSize;
|
|
|
|
// defines the max allowed caches size in bytes
|
|
|
|
@property (nonatomic,readonly) NSUInteger maxAllowedCachesSize;
|
2014-11-24 09:38:23 +00:00
|
|
|
|
|
|
|
+ (MatrixHandler *)sharedHandler;
|
|
|
|
|
2014-12-09 17:21:39 +00:00
|
|
|
- (void)pauseInBackgroundTask;
|
2014-12-05 10:55:01 +00:00
|
|
|
- (void)resume;
|
2014-11-24 09:38:23 +00:00
|
|
|
- (void)logout;
|
|
|
|
|
|
|
|
// Flush and restore Matrix data
|
2014-12-19 09:02:09 +00:00
|
|
|
- (void)forceInitialSync:(BOOL)clearCache;
|
2014-11-24 09:38:23 +00:00
|
|
|
|
2014-12-12 13:18:34 +00:00
|
|
|
- (void)enableInAppNotifications:(BOOL)isEnabled;
|
2014-11-24 09:38:23 +00:00
|
|
|
|
2014-11-27 09:50:09 +00:00
|
|
|
- (BOOL)isSupportedAttachment:(MXEvent*)event;
|
|
|
|
- (BOOL)isEmote:(MXEvent*)event;
|
2014-12-09 09:39:56 +00:00
|
|
|
|
2015-01-14 17:30:00 +00:00
|
|
|
// Return the suitable url to display the content thumbnail into the provided view size
|
|
|
|
// Note: the provided view size is supposed in points, this method will convert this size in pixels by considering screen scale
|
|
|
|
- (NSString*)thumbnailURLForContent:(NSString*)contentURI inViewSize:(CGSize)viewSize withMethod:(MXThumbnailingMethod)thumbnailingMethod;
|
|
|
|
|
2014-12-09 09:39:56 +00:00
|
|
|
// Note: the room state expected by the 3 following methods is the room state right before handling the event
|
|
|
|
- (NSString*)senderDisplayNameForEvent:(MXEvent*)event withRoomState:(MXRoomState*)roomState;
|
|
|
|
- (NSString*)senderAvatarUrlForEvent:(MXEvent*)event withRoomState:(MXRoomState*)roomState;
|
2014-11-27 09:50:09 +00:00
|
|
|
- (NSString*)displayTextForEvent:(MXEvent*)event withRoomState:(MXRoomState*)roomState inSubtitleMode:(BOOL)isSubtitle;
|
2014-11-24 09:38:23 +00:00
|
|
|
|
2014-12-18 10:01:04 +00:00
|
|
|
// search if a 1:1 conversation has been started with this member
|
2015-01-14 17:30:00 +00:00
|
|
|
- (NSString*)getRoomStartedWithMember:(MXRoomMember*)roomMember;
|
2014-12-19 14:05:21 +00:00
|
|
|
|
|
|
|
- (CGFloat)getPowerLevel:(MXRoomMember *)roomMember inRoom:(MXRoom *)room;
|
2014-12-24 15:32:24 +00:00
|
|
|
|
2015-01-09 14:58:15 +00:00
|
|
|
// return YES if the text contains a bing word
|
|
|
|
- (BOOL)containsBingWord:(NSString*)text;
|
|
|
|
|
2014-11-24 09:38:23 +00:00
|
|
|
@end
|