Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Threema/ThreemaFramework/Business/   (Threema ©)  Datei vom 26.9.2026 mit Größe 101 kB image not shown  

SSL ContactStore.h   Sprache: C

 

#import <Foundation/Foundation.h>
#import <ThreemaFramework/UserSettings.h>

@class MediatorSyncableContacts, WorkAvailabilityStatus;

typedef NS_CLOSED_ENUM(NSInteger, ContactAcquaintanceLevel) {
    ContactAcquaintanceLevelDirect = 0,     // Contact is added manually or by sync with address book or by work directory or has a 1:1 conversation
    ContactAcquaintanceLevelGroupOrDeleted = 1       // Contact is only member of a group conversation or deleted -> contact is marked as hidden
};

NS_ASSUME_NONNULL_BEGIN

@protocol ContactStoreProtocol <NSObject>

/**
 Get contact entity for Threema identity.

 @return Contact object of type `ContactEntity`
 */

- (nullable NSObject *)contactForIdentity:(nullable NSString *)identity
    NS_SWIFT_NAME(contact(for:))
    DEPRECATED_MSG_ATTRIBUTE("Use EntityManager to load contact in the right database context");

- (void)prefetchIdentityInfo:(NSSet<NSString *> *)identities onCompletion:(void(^)(void))onCompletion onError:(void(^)(NSError *error))onError;

- (void)fetchWorkIdentities:(NSArray *)identities onCompletion:(void(^)(NSArray *foundIdentities))onCompletion onError:(void(^)(NSError *error))onError;

- (void)fetchPublicKeyForIdentity:(nullable NSString *)identity acquaintanceLevel:(ContactAcquaintanceLevel)acquaintanceLevel entityManager:(NSObject * _Nonnull)entityManagerObject ignoreBlockUnknown:(BOOL)ignoreBlockUnknown onCompletion:(void(^)(NSData * _Nullable publicKey))onCompletion onError:(nullable void(^)(NSError * _Nullable error))onError
    NS_SWIFT_NAME(fetchPublicKey(for:acquaintanceLevel:entityManager:ignoreBlockUnknown:onCompletion:onError:));

- (void)removeProfilePictureFlagForAllContacts;
- (void)removeProfilePictureRequest:(NSString *)identity;

/**
 Add contact or update as none hiden.

 @param identity Threema identity
 @param verificationLevel Int32
 @param onCompletion With parameter of type `ContactEntity` and `BOOL` (already exists)
 @param onError With parameter of type `NSError`
 */

- (void)addContactWithIdentity:(NSString *)identity verificationLevel:(int32_t)verificationLevel onCompletion:(void(^)(NSObject * _Nullable, BOOL))onCompletion onError:(nullable void(^)(NSError *))onError
    NS_SWIFT_NAME(addContact(with:verificationLevel:onCompletion:onError:));

- (void)updateContactWithIdentity:(NSString * _Nonnull)identity avatar:(NSData * _Nullable)avatar firstName:(NSString * _Nullable)firstName lastName:(NSString * _Nullable)lastName;

- (void)markContactAsDeletedWithIdentity:(nonnull NSString *)identity entityManagerObject:(nonnull NSObject *)entityManagerObject NS_SWIFT_NAME(markContactAsDeleted(identity:entityManagerObject:));

/* synchronize contacts from address book with server */
- (void)synchronizeAddressBookForceFullSync:(BOOL)forceFullSync ignoreMinimumInterval:(BOOL)ignoreMinimumInterval onCompletion:(nullable void(^)(BOOL addressBookAccessGranted))onCompletion onError:(nullable void(^)(NSError * _Nullable error))onError
    NS_SWIFT_NAME(synchronizeAddressBook(forceFullSync:ignoreMinimumInterval:onCompletion:onError:));

- (void)reflectContact:(nullable NSString *)identity NS_SWIFT_NAME(reflect(_:));

- (void)updateProfilePicture:(nullable NSString *)identity imageData:(NSData *)imageData shouldReflect:(BOOL)shouldReflect blobID:(nullable NSData *)blobID encryptionKey:(nullable NSData *)encryptionKey didFailWithError:(NSError * _Nullable * _Nullable)error;
- (void)deleteProfilePicture:(nullable NSString *)identity shouldReflect:(BOOL)shouldReflect;
- (void)removeProfilePictureFlagForIdentity:(NSString *)identity
    NS_SWIFT_NAME(removeProfilePictureFlag(for:));

/// Update state, type and feature mask of all valid contacts
/// - Parameters:
///   - ignoreInterval: Force the update and ignore the refresh interval
///   - onCompletion: Called when update has completed
///   - onError: Called when something failed
- (void)updateStatusForAllContactsIgnoreInterval:(BOOL)ignoreInterval onCompletion:(nonnull void(^)(void))onCompletion onError:(nonnull void(^)(NSError * _Nonnull error))onError;

- (void)updateAllContacts;

/// Reset all custom read receipts. If multi-device is enabled this is also reflected
- (void)resetCustomReadReceipts;

/**
 Mark contact identity as work contact, adding identities to `UserSettings.workIdentities`.

 @param identities: Identities of contacts to mark as work contact
 @param contactSyncer: Contact synchronizer for multi device
 */

- (void)addAsWorkWithIdentities:(NSOrderedSet *)identities contactSyncer:(nullable MediatorSyncableContacts *)mediatorSyncableContacts
    NS_SWIFT_NAME(addAsWork(identities:contactSyncer:));

/**
 Set new instance of EntityManager, its needed in Notification Extension after reset of database context.
 */

- (void)resetEntityManager;

/** Add or update work contact, if multi device activated contact will be synced.

 @param identity Identity of the contact (will be not validated)
 @param publicKey Public key it corresponds with the identity (will be not validated)
 @param firstname First name of the contact
 @param lastname Last name of the contact
 @param csi NSString
 @param jobTitle NSString
 @param department NSString
 @param acquaintanceLevel Is `group` contact will be marked as hidden
 @param onCompletion With parameter of type `ContactEntity` as result of added/updated contact
 @param onError With parameter of type `NSError`
 */

- (void)addWorkContactAndUpdateFeatureMaskWithIdentity:(nonnull NSString *)identity
                                             publicKey:(nonnull NSData *)publicKey
                                             firstname:(nullable NSString *)firstname
                                              lastname:(nullable NSString *)lastname
                                                   csi:(nullable NSString *)csi
                                              jobTitle:(nullable NSString *)jobTitle
                                            department:(nullable NSString *)department
                                     acquaintanceLevel:(ContactAcquaintanceLevel)acquaintanceLevel
                                workAvailabilityStatus:(nullable WorkAvailabilityStatus *) workAvailabilityStatus
                                          onCompletion:(nonnull void(^)(NSObject * nonnull))onCompletion
                                               onError:(nonnull void(^)(NSError * nonnull))onError
    NS_SWIFT_NAME(addWorkContact(with:publicKey:firstname:lastname:csi:jobTitle:department:acquaintanceLevel:workAvailabilityStatus:onCompletion:onError:));

@end

@interface ContactStore : NSObject <ContactStoreProtocol>

+ (ContactStore *)sharedContactStore;
- (instancetype) __unavailable init;

#if DEBUG
- (instancetype)initWithUserSettings:(id<UserSettingsProtocol>)userSettingsProtocol entityManager:(NSObject *)entityManagerObject;
#endif

@property (nonatomic, strong, readonly, nonnull) dispatch_queue_t syncContactsQueue;

/** Add or update contact, if multi device activated contact will be synced.

 @param identity Identity of the contact (will be not validated)
 @param publicKey Public key it corresponds with the identity (will be not validated)
 @param cnContactId NSString
 @param verificationLevel Int32
 @param state NSNumber
 @param type NSNumber
 @param featureMask NSNumber
 @param acquaintanceLevel Is `group` contact will be marked as hidden
 @param alerts BOOL
 @param onCompletion With parameter of type `ContactEntity` as result or nil
 */

- (void)addContactWithIdentity:(nullable NSString *)identity publicKey:(nullable NSData *)publicKey cnContactId:(nullable NSString *)cnContactId verificationLevel:(int32_t)verificationLevel state:(nullable NSNumber *)state type:(nullable NSNumber *)type featureMask:(nullable NSNumber *)featureMask acquaintanceLevel:(ContactAcquaintanceLevel)acquaintanceLevel alerts:(BOOL)alerts onCompletion:(nonnull void(^)(NSObject * nullable))onCompletion
    NS_SWIFT_NAME(addContact(with:publicKey:cnContactID:verificationLevel:state:type:featureMask:acquaintanceLevel:alerts:onCompletion:));

- (nullable NSString *)addWorkContactWithIdentity:(nonnull NSString *)identity
                                        publicKey:(nonnull NSData *)publicKey
                                        firstname:(nullable NSString *)firstname
                                         lastname:(nullable NSString *)lastname
                                              csi:(nullable NSString *)csi
                                         jobTitle:(nullable NSString *)jobTitle
                                       department:(nullable NSString *)department
                                      featureMask:(nullable NSNumber *)featureMask
                                acquaintanceLevel:(ContactAcquaintanceLevel)acquaintanceLevel
                           workAvailabilityStatus:(nullable WorkAvailabilityStatus *) workAvailabilityStatus
                                    entityManager:(NSObject * _Nonnull)entityManagerObject
                                    contactSyncer:(nullable MediatorSyncableContacts *)mediatorSyncableContacts
    NS_SWIFT_NAME(addWorkContact(with:publicKey:firstname:lastname:csi:jobTitle:department:featureMask:acquaintanceLevel:workAvailabilityStatus:entityManager:contactSyncer:));

- (void)resetImportedStatus;

/**
 Link contact.

 @param contactObject Contact object of type `ContactEntity`
 @param cnContactId NSString
 */

- (void)linkContact:(nonnull NSObject *)contactObject toCnContactId:(NSString *)cnContactId
    NS_SWIFT_NAME(link(_:toCnContactID:));

/**
 Unlink contact.

 @param contactObject Contact object of type `ContactEntity`
 */

- (void)unlinkContact:(nonnull NSObject *)contactObject
    NS_SWIFT_NAME(unlink(_:));

/**
 Upgrade verfication level of the contact.

 @param contactObject Contact object of type `ContactEntity`
 @param verificationLevel Int32
 */

- (void)upgradeContact:(nonnull NSObject *)contactObject toVerificationLevel:(int32_t)verificationLevel
    NS_SWIFT_NAME(upgrade(_:toVerificationLevel:));

- (void)updateNickname:(nonnull NSString *)identity nickname:(NSString *)nickname;

/* manage profile picture request list */
- (BOOL)existsProfilePictureRequestForIdentity:(nullable NSString *)identity
    NS_SWIFT_NAME(existsProfilePictureRequest(for:));

/* synchronize contacts from address book with server */
- (void)synchronizeAddressBookForceFullSync:(BOOL)forceFullSync onCompletion:(nullable void(^)(BOOL addressBookAccessGranted))onCompletion onError:(nullable void(^)(NSError * _Nullable error))onError
    NS_SWIFT_NAME(synchronizeAddressBook(forceFullSync:onCompletion:onError:));

+ (void)linkedIdentitiesForEmail:(NSString *)email AndMobileNo:(NSString *)mobileNo onCompletion:(void(^)(NSArray *identities))onCompletion
    NS_SWIFT_NAME(linkedIdentities(for:and:onCompletion:));

- (nullable NSArray *)allIdentities DEPRECATED_MSG_ATTRIBUTE("Use `contactIdentities` on `EntityFetcher` instead");
- (nullable NSArray<NSString *> *)contactsWithFeatureMaskNil;
- (nullable NSArray *)allContacts;

/**
 Get address book email addresses of the contact.

 @param contactObject Contact object of type `ContactEntity`
 */

- (nullable NSArray<NSDictionary<NSString *, NSString *> *> *)cnContactEmailsForContact:(NSObject *)contactObject NS_SWIFT_NAME(cnContactEmails(for:));

/**
 Get address book phone numbers of the contact.

 @param contactObject Contact object of type `ContactEntity`
 */

- (nullable NSArray<NSDictionary<NSString *, NSString *> *> *)cnContactPhoneNumbersForContact:(NSObject *)contactObject NS_SWIFT_NAME(cnContactPhoneNumbers(for:));

@end

NS_ASSUME_NONNULL_END

Messung
CHZG
100909695

¤ Dauer der Verarbeitung: 0.26 Sekunden  (vorverarbeitet am  2026-11-23) ¤

*Bot Zugriff