NCChatController.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /**
  2. * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
  3. * SPDX-License-Identifier: GPL-3.0-or-later
  4. */
  5. #import <Foundation/Foundation.h>
  6. #import "NCChatMessage.h"
  7. typedef void (^UpdateHistoryInBackgroundCompletionBlock)(NSError *error);
  8. typedef void (^GetMessagesContextCompletionBlock)(NSArray<NCChatMessage *> * _Nullable messages);
  9. @class NCRoom;
  10. extern NSString * const NCChatControllerDidReceiveInitialChatHistoryNotification;
  11. extern NSString * const NCChatControllerDidReceiveInitialChatHistoryOfflineNotification;;
  12. extern NSString * const NCChatControllerDidReceiveChatHistoryNotification;
  13. extern NSString * const NCChatControllerDidReceiveChatMessagesNotification;
  14. extern NSString * const NCChatControllerDidSendChatMessageNotification;
  15. extern NSString * const NCChatControllerDidReceiveChatBlockedNotification;
  16. extern NSString * const NCChatControllerDidReceiveNewerCommonReadMessageNotification;
  17. extern NSString * const NCChatControllerDidReceiveUpdateMessageNotification;
  18. extern NSString * const NCChatControllerDidReceiveHistoryClearedNotification;
  19. extern NSString * const NCChatControllerDidReceiveCallStartedMessageNotification;
  20. extern NSString * const NCChatControllerDidReceiveCallEndedMessageNotification;
  21. extern NSString * const NCChatControllerDidReceiveMessagesInBackgroundNotification;
  22. @interface NCChatController : NSObject
  23. @property (nonatomic, strong) NCRoom *room;
  24. @property (nonatomic, assign) BOOL hasReceivedMessagesFromServer;
  25. - (instancetype)initForRoom:(NCRoom *)room;
  26. - (void)sendChatMessage:(NSString *)message replyTo:(NSInteger)replyTo referenceId:(NSString *)referenceId silently:(BOOL)silently;
  27. - (void)sendChatMessage:(NCChatMessage *)message;
  28. - (NSArray<NCChatMessage *> * _Nonnull)getTemporaryMessages;
  29. - (void)getInitialChatHistory;
  30. - (void)getInitialChatHistoryForOfflineMode;
  31. - (void)getHistoryBatchFromMessagesId:(NSInteger)messageId;
  32. - (void)getHistoryBatchOfflineFromMessagesId:(NSInteger)messageId;
  33. - (BOOL)hasOlderStoredMessagesThanMessageId:(NSInteger)messageId;
  34. - (void)checkForNewMessagesFromMessageId:(NSInteger)messageId;
  35. - (void)updateHistoryInBackgroundWithCompletionBlock:(UpdateHistoryInBackgroundCompletionBlock)block;
  36. - (void)startReceivingNewChatMessages;
  37. - (void)stopReceivingNewChatMessages;
  38. - (void)stopChatController;
  39. - (void)clearHistoryAndResetChatController;
  40. - (void)removeExpiredMessages;
  41. - (BOOL)hasHistoryFromMessageId:(NSInteger)messageId;
  42. - (void)storeMessages:(NSArray *)messages withRealm:(RLMRealm *)realm;
  43. - (void)getMessageContextForMessageId:(NSInteger)messageId withLimit:(NSInteger)limit withCompletionBlock:(GetMessagesContextCompletionBlock)block;
  44. @end