2017-07-31 20:48:43 +02:00
|
|
|
//
|
|
|
|
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
|
|
|
//
|
|
|
|
|
2017-08-02 19:12:26 +02:00
|
|
|
#import <SignalServiceKit/ProfileManagerProtocol.h>
|
|
|
|
|
2017-07-31 20:48:43 +02:00
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
2017-07-31 23:49:52 +02:00
|
|
|
extern NSString *const kNSNotificationName_LocalProfileDidChange;
|
2017-08-02 15:27:29 +02:00
|
|
|
extern NSString *const kNSNotificationName_OtherUsersProfileDidChange;
|
2017-08-01 19:53:51 +02:00
|
|
|
|
2017-08-15 17:37:12 +02:00
|
|
|
extern const NSUInteger kOWSProfileManager_MaxAvatarWidth;
|
|
|
|
|
2017-08-03 18:05:53 +02:00
|
|
|
@class TSThread;
|
2017-08-14 17:31:43 +02:00
|
|
|
@class OWSAES128Key;
|
2017-08-03 18:05:53 +02:00
|
|
|
|
2017-07-31 20:48:43 +02:00
|
|
|
// This class can be safely accessed and used from any thread.
|
2017-08-02 19:12:26 +02:00
|
|
|
@interface OWSProfileManager : NSObject <ProfileManagerProtocol>
|
2017-07-31 20:48:43 +02:00
|
|
|
|
|
|
|
- (instancetype)init NS_UNAVAILABLE;
|
|
|
|
|
|
|
|
+ (instancetype)sharedManager;
|
|
|
|
|
2017-08-04 16:32:00 +02:00
|
|
|
- (void)resetProfileStorage;
|
2017-08-03 19:39:34 +02:00
|
|
|
|
2017-08-01 18:52:15 +02:00
|
|
|
#pragma mark - Local Profile
|
|
|
|
|
2017-08-02 16:36:54 +02:00
|
|
|
// These two methods should only be called from the main thread.
|
2017-08-14 17:31:43 +02:00
|
|
|
- (OWSAES128Key *)localProfileKey;
|
2017-08-03 23:43:21 +02:00
|
|
|
- (BOOL)hasLocalProfile;
|
2017-08-02 18:03:06 +02:00
|
|
|
- (nullable NSString *)localProfileName;
|
|
|
|
- (nullable UIImage *)localProfileAvatarImage;
|
2017-07-31 23:49:52 +02:00
|
|
|
|
2017-08-01 16:51:01 +02:00
|
|
|
// This method is used to update the "local profile" state on the client
|
|
|
|
// and the service. Client state is only updated if service state is
|
|
|
|
// successfully updated.
|
2017-08-02 16:36:54 +02:00
|
|
|
//
|
|
|
|
// This method should only be called from the main thread.
|
|
|
|
- (void)updateLocalProfileName:(nullable NSString *)profileName
|
|
|
|
avatarImage:(nullable UIImage *)avatarImage
|
2017-08-01 17:31:00 +02:00
|
|
|
success:(void (^)())successBlock
|
|
|
|
failure:(void (^)())failureBlock;
|
2017-08-01 16:51:01 +02:00
|
|
|
|
2017-08-01 18:52:15 +02:00
|
|
|
#pragma mark - Profile Whitelist
|
|
|
|
|
2017-08-03 23:43:21 +02:00
|
|
|
- (void)addThreadToProfileWhitelist:(TSThread *)thread;
|
2017-08-01 18:52:15 +02:00
|
|
|
|
2017-08-03 23:43:21 +02:00
|
|
|
- (BOOL)isThreadInProfileWhitelist:(TSThread *)thread;
|
2017-08-01 18:52:15 +02:00
|
|
|
|
2017-08-03 23:43:21 +02:00
|
|
|
- (BOOL)isUserInProfileWhitelist:(NSString *)recipientId;
|
2017-08-01 20:56:53 +02:00
|
|
|
|
2017-08-01 19:53:51 +02:00
|
|
|
- (void)setContactRecipientIds:(NSArray<NSString *> *)contactRecipientIds;
|
|
|
|
|
2017-08-02 15:27:29 +02:00
|
|
|
#pragma mark - Other User's Profiles
|
2017-08-01 18:52:15 +02:00
|
|
|
|
2017-08-14 17:31:43 +02:00
|
|
|
- (nullable OWSAES128Key *)profileKeyForRecipientId:(NSString *)recipientId;
|
2017-08-01 18:52:15 +02:00
|
|
|
|
2017-08-02 15:27:29 +02:00
|
|
|
- (nullable NSString *)profileNameForRecipientId:(NSString *)recipientId;
|
|
|
|
|
|
|
|
- (nullable UIImage *)profileAvatarForRecipientId:(NSString *)recipientId;
|
|
|
|
|
2017-08-15 18:49:27 +02:00
|
|
|
// Reads raw avatar data from disk if available. Uncached, so shouldn't be used frequently,
|
|
|
|
// but useful to get the raw image data for populating cnContact.imageData without lossily re-encoding.
|
|
|
|
- (nullable NSData *)profileAvatarDataForRecipientId:(NSString *)recipientId;
|
|
|
|
|
2017-08-02 18:03:06 +02:00
|
|
|
- (void)refreshProfileForRecipientId:(NSString *)recipientId;
|
2017-08-02 16:36:54 +02:00
|
|
|
|
2017-08-03 17:13:40 +02:00
|
|
|
- (void)updateProfileForRecipientId:(NSString *)recipientId
|
2017-08-14 17:31:43 +02:00
|
|
|
profileNameEncrypted:(nullable NSData *)profileNameEncrypted
|
2017-08-14 20:51:51 +02:00
|
|
|
avatarUrlPath:(nullable NSString *)avatarUrlPath;
|
2017-08-03 17:13:40 +02:00
|
|
|
|
2017-07-31 20:48:43 +02:00
|
|
|
@end
|
|
|
|
|
|
|
|
NS_ASSUME_NONNULL_END
|