mirror of https://github.com/oxen-io/session-ios
				
				
				
			
			You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
	
	
		
			91 lines
		
	
	
		
			3.9 KiB
		
	
	
	
		
			C
		
	
		
		
			
		
	
	
			91 lines
		
	
	
		
			3.9 KiB
		
	
	
	
		
			C
		
	
| 
											9 years ago
										 | //
 | ||
|  | //  Copyright (c) 2017 Open Whisper Systems. All rights reserved.
 | ||
|  | //
 | ||
|  | 
 | ||
| 
											8 years ago
										 | #import <SignalServiceKit/Contact.h>
 | ||
| 
											9 years ago
										 | #import <SignalServiceKit/ContactsManagerProtocol.h>
 | ||
| 
											12 years ago
										 | 
 | ||
| 
											9 years ago
										 | NS_ASSUME_NONNULL_BEGIN | ||
| 
											12 years ago
										 | 
 | ||
| 
											9 years ago
										 | extern NSString *const OWSContactsManagerSignalAccountsDidChangeNotification; | ||
| 
											9 years ago
										 | 
 | ||
| 
											8 years ago
										 | @class ImageCache; | ||
| 
											8 years ago
										 | @class SignalAccount; | ||
|  | @class UIFont; | ||
| 
											10 years ago
										 | 
 | ||
| 
											9 years ago
										 | /**
 | ||
|  |  * Get latest Signal contacts, and be notified when they change. | ||
|  |  */ | ||
| 
											9 years ago
										 | @interface OWSContactsManager : NSObject <ContactsManagerProtocol> | ||
| 
											12 years ago
										 | 
 | ||
| 
											8 years ago
										 | #pragma mark - Setup
 | ||
|  | 
 | ||
|  | - (void)startObserving; | ||
|  | 
 | ||
|  | #pragma mark - Accessors
 | ||
|  | 
 | ||
| 
											8 years ago
										 | @property (nonnull, readonly) ImageCache *avatarCache; | ||
| 
											9 years ago
										 | 
 | ||
| 
											8 years ago
										 | @property (atomic, readonly) NSArray<Contact *> *allContacts; | ||
|  | 
 | ||
| 
											9 years ago
										 | @property (atomic, readonly) NSDictionary<NSString *, Contact *> *allContactsMap; | ||
|  | 
 | ||
| 
											8 years ago
										 | // order of the signalAccounts array respects the systems contact sorting preference
 | ||
| 
											9 years ago
										 | @property (atomic, readonly) NSArray<SignalAccount *> *signalAccounts; | ||
| 
											9 years ago
										 | - (nullable SignalAccount *)signalAccountForRecipientId:(NSString *)recipientId; | ||
| 
											8 years ago
										 | - (BOOL)hasSignalAccountForRecipientId:(NSString *)recipientId; | ||
| 
											9 years ago
										 | 
 | ||
| 
											8 years ago
										 | - (void)loadSignalAccountsFromCache; | ||
| 
											9 years ago
										 | #pragma mark - System Contact Fetching
 | ||
|  | 
 | ||
| 
											9 years ago
										 | // Must call `requestSystemContactsOnce` before accessing this method
 | ||
|  | @property (nonatomic, readonly) BOOL isSystemContactsAuthorized; | ||
| 
											8 years ago
										 | @property (nonatomic, readonly) BOOL systemContactsHaveBeenRequestedAtLeastOnce; | ||
| 
											9 years ago
										 | 
 | ||
| 
											9 years ago
										 | @property (nonatomic, readonly) BOOL supportsContactEditing; | ||
|  | 
 | ||
| 
											9 years ago
										 | // Request systems contacts and start syncing changes. The user will see an alert
 | ||
|  | // if they haven't previously.
 | ||
| 
											9 years ago
										 | - (void)requestSystemContactsOnce; | ||
| 
											9 years ago
										 | - (void)requestSystemContactsOnceWithCompletion:(void (^_Nullable)(NSError *_Nullable error))completion; | ||
| 
											9 years ago
										 | 
 | ||
|  | // Ensure's the app has the latest contacts, but won't prompt the user for contact
 | ||
|  | // access if they haven't granted it.
 | ||
| 
											8 years ago
										 | - (void)fetchSystemContactsOnceIfAlreadyAuthorized; | ||
| 
											8 years ago
										 | 
 | ||
| 
											8 years ago
										 | // This variant will fetch system contacts if contact access has already been granted,
 | ||
| 
											8 years ago
										 | // but not prompt for contact access. Also, it will always notify delegates, even if
 | ||
| 
											8 years ago
										 | // contacts haven't changed, and will clear out any stale cached SignalAccounts
 | ||
| 
											8 years ago
										 | - (void)userRequestedSystemContactsRefreshWithCompletion:(void (^)(NSError *_Nullable error))completionHandler; | ||
| 
											10 years ago
										 | 
 | ||
| 
											9 years ago
										 | #pragma mark - Util
 | ||
|  | 
 | ||
| 
											8 years ago
										 | - (BOOL)hasNameInSystemContactsForRecipientId:(NSString *)recipientId; | ||
| 
											9 years ago
										 | - (NSString *)displayNameForPhoneIdentifier:(nullable NSString *)identifier; | ||
| 
											9 years ago
										 | - (NSString *)displayNameForSignalAccount:(SignalAccount *)signalAccount; | ||
| 
											8 years ago
										 | 
 | ||
| 
											8 years ago
										 | /**
 | ||
|  |  * Used for sorting, respects system contacts name sort order preference. | ||
|  |  */ | ||
|  | - (NSString *)comparableNameForSignalAccount:(SignalAccount *)signalAccount; | ||
|  | 
 | ||
| 
											8 years ago
										 | // Generally we prefer the formattedProfileName over the raw profileName so as to
 | ||
|  | // distinguish a profile name apart from a name pulled from the system's contacts.
 | ||
|  | // This helps clarify when the remote person chooses a potentially confusing profile name.
 | ||
| 
											8 years ago
										 | - (nullable NSString *)formattedProfileNameForRecipientId:(NSString *)recipientId; | ||
| 
											8 years ago
										 | - (nullable NSString *)profileNameForRecipientId:(NSString *)recipientId; | ||
|  | - (nullable NSString *)nameFromSystemContactsForRecipientId:(NSString *)recipientId; | ||
| 
											8 years ago
										 | - (NSString *)stringForConversationTitleWithPhoneIdentifier:(NSString *)recipientId; | ||
| 
											8 years ago
										 | 
 | ||
| 
											9 years ago
										 | - (nullable UIImage *)imageForPhoneIdentifier:(nullable NSString *)identifier; | ||
| 
											9 years ago
										 | - (NSAttributedString *)formattedDisplayNameForSignalAccount:(SignalAccount *)signalAccount font:(UIFont *_Nonnull)font; | ||
| 
											9 years ago
										 | - (NSAttributedString *)formattedFullNameForRecipientId:(NSString *)recipientId font:(UIFont *)font; | ||
| 
											8 years ago
										 | - (NSString *)contactOrProfileNameForPhoneIdentifier:(NSString *)recipientId; | ||
|  | - (NSAttributedString *)attributedContactOrProfileNameForPhoneIdentifier:(NSString *)recipientId; | ||
| 
											8 years ago
										 | - (NSAttributedString *)attributedStringForConversationTitleWithPhoneIdentifier:(NSString *)recipientId | ||
|  |                                                                     primaryFont:(UIFont *)primaryFont | ||
|  |                                                                   secondaryFont:(UIFont *)secondaryFont; | ||
| 
											12 years ago
										 | @end | ||
| 
											9 years ago
										 | 
 | ||
|  | NS_ASSUME_NONNULL_END |