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-25 18:39:27 +02:00
|
|
|
extern NSString *const kNSNotificationName_OtherUsersProfileWillChange;
|
2017-08-02 15:27:29 +02:00
|
|
|
extern NSString *const kNSNotificationName_OtherUsersProfileDidChange;
|
2017-08-17 00:09:47 +02:00
|
|
|
extern NSString *const kNSNotificationName_ProfileWhitelistDidChange;
|
2017-08-21 23:27:30 +02:00
|
|
|
extern NSString *const kNSNotificationKey_ProfileRecipientId;
|
|
|
|
extern NSString *const kNSNotificationKey_ProfileGroupId;
|
2017-08-01 19:53:51 +02:00
|
|
|
|
2017-08-15 21:40:46 +02:00
|
|
|
extern const NSUInteger kOWSProfileManager_MaxAvatarDiameter;
|
2017-08-15 17:37:12 +02:00
|
|
|
|
2017-08-03 18:05:53 +02:00
|
|
|
@class TSThread;
|
2017-08-21 17:21:23 +02:00
|
|
|
@class OWSAES256Key;
|
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-21 17:21:23 +02:00
|
|
|
- (OWSAES256Key *)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-16 21:32:56 +02:00
|
|
|
#ifdef DEBUG
|
|
|
|
// These methods are for debugging.
|
|
|
|
- (void)clearProfileWhitelist;
|
|
|
|
- (void)logProfileWhitelist;
|
2017-08-24 17:27:36 +02:00
|
|
|
- (void)regenerateLocalProfile;
|
2017-08-16 21:32:56 +02:00
|
|
|
#endif
|
|
|
|
|
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-21 17:21:23 +02:00
|
|
|
- (nullable OWSAES256Key *)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-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
|