ContactStore.h 4.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. // _____ _
  2. // |_ _| |_ _ _ ___ ___ _ __ __ _
  3. // | | | ' \| '_/ -_) -_) ' \/ _` |_
  4. // |_| |_||_|_| \___\___|_|_|_\__,_(_)
  5. //
  6. // Threema iOS Client
  7. // Copyright (c) 2012-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. @class Contact;
  22. @interface ContactStore : NSObject
  23. + (ContactStore*)sharedContactStore;
  24. - (void)fetchPublicKeyForIdentity:(NSString*)identity onCompletion:(void(^)(NSData *publicKey))onCompletion onError:(void(^)(NSError *error))onError;
  25. - (void)prefetchIdentityInfo:(NSSet*)identities onCompletion:(void(^)(void))onCompletion onError:(void(^)(NSError *error))onError;
  26. - (Contact*)contactForIdentity:(NSString *)identity;
  27. /* The following function must be run on the main queue! */
  28. - (void)addContactWithIdentity:(NSString*)identity verificationLevel:(int32_t)verificationLevel onCompletion:(void(^)(Contact *contact, BOOL alreadyExists))onCompletion onError:(void(^)(NSError *error))onError;
  29. - (Contact*)addContactWithIdentity:(NSString*)identity publicKey:(NSData*)publicKey cnContactId:(NSString *)cnContactId verificationLevel:(int32_t)verificationLevel featureMask:(NSNumber *)featureMask alerts:(BOOL)alerts;
  30. - (Contact*)addContactWithIdentity:(NSString*)identity publicKey:(NSData*)publicKey cnContactId:(NSString *)cnContactId verificationLevel:(int32_t)verificationLevel state:(NSNumber *)state type:(NSNumber *)type featureMask:(NSNumber *)featureMask alerts:(BOOL)alerts;
  31. - (Contact *)addWorkContactWithIdentity:(NSString *)identity publicKey:(NSData*)publicKey firstname:(NSString *)firstname lastname:(NSString *)lastname;
  32. - (void)updateContact:(Contact*)contact;
  33. - (void)linkContact:(Contact *)contact toCnContactId:(NSString *)cnContactId;
  34. - (void)unlinkContact:(Contact*)contact;
  35. - (void)upgradeContact:(Contact*)contact toVerificationLevel:(int)verificationLevel;
  36. - (void)setWorkContact:(Contact *)contact workContact:(BOOL)workContact;
  37. - (void)updateProfilePicture:(Contact *)contact imageData:(NSData *)imageData didFailWithError:(NSError **)error;
  38. - (void)deleteProfilePicture:(Contact *)contact;
  39. - (void)removeProfilePictureFlagForAllContacts;
  40. - (void)removeProfilePictureFlagForContact:(NSString *)identity;
  41. /* manage profile picture request list */
  42. - (BOOL)existsProfilePictureRequest:(NSString *)identity;
  43. - (void)removeProfilePictureRequest:(NSString *)identity;
  44. /* synchronize contacts from address book with server */
  45. - (void)synchronizeAddressBookForceFullSync:(BOOL)forceFullSync onCompletion:(void(^)(BOOL addressBookAccessGranted))onCompletion onError:(void(^)(NSError *error))onError;
  46. - (void)synchronizeAddressBookForceFullSync:(BOOL)forceFullSync ignoreMinimumInterval:(BOOL)ignoreMinimumInterval onCompletion:(void(^)(BOOL addressBookAccessGranted))onCompletion onError:(void(^)(NSError *error))onError;
  47. - (void)updateAllContacts;
  48. - (void)updateFeatureMasksForContacts:(NSArray *)contacts onCompletion:(void(^)(void))onCompletion onError:(void(^)(NSError *error))onError;
  49. - (void)updateFeatureMasksForIdentities:(NSArray *)identities onCompletion:(void(^)(void))onCompletion onError:(void(^)(NSError *error))onError;
  50. - (void)linkedIdentities:(NSString*)email mobileNo:(NSString*)mobileNo onCompletion:(void(^)(NSArray *identities))onCompletion;
  51. - (NSArray*)allIdentities;
  52. - (NSArray *)contactsWithVerificationLevel:(NSInteger)verificationLevel;
  53. - (NSArray *)contactsWithFeatureMaskNil;
  54. - (NSArray *)allContacts;
  55. - (void)updateAllContactsToCNContact;
  56. - (void)cnContactAskAccessEmailsForContact:(Contact *)contact completionHandler:(void (^)(BOOL granted, NSArray *array))completionHandler;
  57. - (void)cnContactAskAccessPhoneNumbersForContact:(Contact *)contact completionHandler:(void (^)(BOOL granted, NSArray *array))completionHandler;
  58. - (NSArray *)cnContactEmailsForContact:(Contact *)contact;
  59. - (NSArray *)cnContactPhoneNumbersForContact:(Contact *)contact;
  60. @end