EntityFetcher.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. // _____ _
  2. // |_ _| |_ _ _ ___ ___ _ __ __ _
  3. // | | | ' \| '_/ -_) -_) ' \/ _` |_
  4. // |_| |_||_|_| \___\___|_|_|_\__,_(_)
  5. //
  6. // Threema iOS Client
  7. // Copyright (c) 2014-2020 Threema GmbH
  8. //
  9. // This program is free software: you can redistribute it and/or modify
  10. // it under the terms of the GNU Affero General Public License, version 3,
  11. // as published by the Free Software Foundation.
  12. //
  13. // This program is distributed in the hope that it will be useful,
  14. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. // GNU Affero General Public License for more details.
  17. //
  18. // You should have received a copy of the GNU Affero General Public License
  19. // along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. #import <Foundation/Foundation.h>
  21. #import "Conversation.h"
  22. #import "Ballot.h"
  23. #import "AbstractMessage.h"
  24. #import "AbstractGroupMessage.h"
  25. #import "Group.h"
  26. #import "LastGroupSyncRequest.h"
  27. #import "WebClientSession.h"
  28. #import "RequestedConversation.h"
  29. #import "LastLoadedMessageIndex.h"
  30. #import "RequestedThumbnail.h"
  31. typedef enum : NSUInteger {
  32. ContactsAll,
  33. ContactsNoGateway,
  34. ContactsGatewayOnly,
  35. ContactsNoEchoEcho,
  36. ContactsNoGatewayNoEchoecho,
  37. } ContactTypes;
  38. typedef enum : NSUInteger {
  39. ContactListContacts,
  40. ContactListWork,
  41. ContactListContactsAndWork
  42. } ContactList;
  43. @interface EntityFetcher : NSObject
  44. - (instancetype)init NS_UNAVAILABLE;
  45. - (instancetype)initWith:(NSManagedObjectContext *) managedObjectContext;
  46. - (id)getManagedObjectById:(NSManagedObjectID *)objectID;
  47. - (BaseMessage *)ownMessageWithId:(NSData *)messageId;
  48. - (BaseMessage *)messageWithId:(NSData *)messageId;
  49. - (BaseMessage *)messageWithId:(NSData *)messageId conversation:(Conversation *)conversation;
  50. - (NSArray *)quoteMessagesContaining:(NSString *)searchText message:(BaseMessage *)message inConversation:(Conversation *)conversation;
  51. - (NSArray *)messagesContaining:(NSString *)searchText inConversation:(Conversation *)conversation;
  52. - (NSArray *)textMessagesContaining:(NSString *)searchText inConversation:(Conversation *)conversation fetchLimit:(NSInteger)fetchLimit;
  53. - (Contact *)contactForId:(NSString *)identity;
  54. - (Contact *)contactForId:(NSString *)identity error:(NSError **)error;
  55. - (NSArray *)allContacts;
  56. - (NSArray *)contactsFilteredByWords:(NSArray *)searchWords;
  57. - (NSArray *)contactsFilteredByWords:(NSArray *)searchWords forContactTypes:(ContactTypes)types list:(ContactList)contactList members:(NSMutableSet *)members;
  58. - (NSArray *)allGroupConversations;
  59. - (NSArray *)allGatewayContacts;
  60. - (NSArray *)contactsWithVerificationLevel:(NSInteger)verificationLevel;
  61. - (NSArray *)contactsWithFeatureMaskNil;
  62. - (NSArray *)groupConversationsFilteredByWords:(NSArray *)searchWords;
  63. - (NSArray *)groupConversationsForContact:(Contact *)contact;
  64. - (NSArray *)allConversations;
  65. - (NSArray *)allConversationsSorted;
  66. - (NSArray *)conversationsWithNegativeUnreadMessageCount;
  67. - (NSString *)displayNameForContactId:(NSString *)identity;
  68. - (Conversation *)conversationForGroupId:(NSData *)groupId;
  69. - (Conversation *)conversationForContact:(Contact *)contact;
  70. - (Conversation *)conversationForIdentity:(NSString *)identity;
  71. - (NSArray *)conversationsForMember:(Contact *)contact;
  72. - (Conversation *)conversationForGroupMessage:(AbstractGroupMessage *)message;
  73. - (Ballot *)ballotForBallotId:(NSData *)ballotId;
  74. - (BallotChoice *)ballotChoiceForBallotId:(NSData *)ballotId choiceId:(NSNumber *)choiceId;
  75. - (BOOL)isMessageAlreadyInDb:(AbstractMessage *)message;
  76. - (BOOL)isNonceAlreadyInDb:(AbstractMessage *)message;
  77. - (Group *)groupForGroupId:(NSData *)groupId groupCreator:(NSString *)groupCreator;
  78. - (Group *)groupForConversation:(Conversation *)conversation;
  79. - (LastGroupSyncRequest *)lastGroupSyncRequestFor:(NSData *)groupId groupCreator:(NSString *)groupCreator sinceDate:(NSDate *)sinceDate;
  80. - (NSFetchRequest *)fetchRequestForEntity:(NSString *)entityName;
  81. - (NSArray *)executeFetchRequest:(NSFetchRequest *)fetchRequest;
  82. - (NSInteger)executeCountFetchRequest:(NSFetchRequest *)fetchRequest;
  83. - (NSInteger)countBallotsForConversation:(Conversation *)conversation;
  84. - (NSInteger)countOpenBallotsForConversation:(Conversation *)conversation;
  85. - (NSArray *)imageMessagesForConversation:(Conversation *)conversation;
  86. - (NSArray *)videoMessagesForConversation:(Conversation *)conversation;
  87. - (NSArray *)fileMessagesForConversation:(Conversation *)conversation;
  88. - (NSArray *)fileMessagesWOStickersForConversation:(Conversation *)conversation;
  89. - (NSInteger)countMediaMessagesForConversation:(Conversation *)conversation;
  90. - (NSFetchedResultsController *)fetchedResultsControllerForContactTypes:(ContactTypes)types list:(ContactList)contactList members:(NSMutableSet *)members;
  91. - (NSFetchedResultsController *)fetchedResultsControllerForGroups;
  92. - (NSFetchedResultsController *)fetchedResultsControllerForConversations;
  93. - (NSFetchedResultsController *)fetchedResultsControllerForWebClientSessions;
  94. - (Tag *)tagForName:(NSString *)name;
  95. - (WebClientSession *)webClientSessionForInitiatorPermanentPublicKeyHash:(NSString *)hash;
  96. - (WebClientSession *)webClientSessionForPrivateKey:(NSData *)privateKey;
  97. - (WebClientSession *)activeWebClientSession;
  98. - (NSArray *)allWebClientSessions;
  99. - (NSArray *)allActiveWebClientSessions;
  100. - (NSArray *)allNotPermanentWebClientSessions;
  101. @end