session-ios/Signal/src/Profiles/OWSProfileManager.h

94 lines
3.1 KiB
C
Raw Normal View History

2017-07-31 20:48:43 +02:00
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import <SignalServiceKit/ProfileManagerProtocol.h>
2017-07-31 20:48:43 +02:00
NS_ASSUME_NONNULL_BEGIN
extern NSString *const kNSNotificationName_LocalProfileDidChange;
extern NSString *const kNSNotificationName_OtherUsersProfileWillChange;
extern NSString *const kNSNotificationName_OtherUsersProfileDidChange;
extern NSString *const kNSNotificationName_ProfileWhitelistDidChange;
2017-08-21 23:27:30 +02:00
extern NSString *const kNSNotificationKey_ProfileRecipientId;
extern NSString *const kNSNotificationKey_ProfileGroupId;
extern const NSUInteger kOWSProfileManager_MaxAvatarDiameter;
extern const NSUInteger kOWSProfileManager_NameDataLength;
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;
@class OWSMessageSender;
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.
@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;
#pragma mark - Local Profile
// These two methods should only be called from the main thread.
2017-08-21 17:21:23 +02:00
- (OWSAES256Key *)localProfileKey;
- (BOOL)hasLocalProfile;
- (nullable NSString *)localProfileName;
- (nullable UIImage *)localProfileAvatarImage;
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.
//
// This method should only be called from the main thread.
- (void)updateLocalProfileName:(nullable NSString *)profileName
avatarImage:(nullable UIImage *)avatarImage
success:(void (^)())successBlock
failure:(void (^)())failureBlock;
2017-08-01 16:51:01 +02:00
- (BOOL)isProfileNameTooLong:(nullable NSString *)profileName;
// The local profile state can fall out of sync with the service
// (e.g. due to a botched profile update, for example).
2017-08-29 22:31:27 +02:00
- (void)fetchLocalUsersProfile;
#pragma mark - Profile Whitelist
// These methods are for debugging.
- (void)clearProfileWhitelist;
- (void)logProfileWhitelist;
- (void)regenerateLocalProfile;
- (void)addThreadToProfileWhitelist:(TSThread *)thread;
- (BOOL)isThreadInProfileWhitelist:(TSThread *)thread;
- (BOOL)isUserInProfileWhitelist:(NSString *)recipientId;
- (void)setContactRecipientIds:(NSArray<NSString *> *)contactRecipientIds;
#pragma mark - Other User's Profiles
2017-08-21 17:21:23 +02:00
- (nullable OWSAES256Key *)profileKeyForRecipientId:(NSString *)recipientId;
- (nullable NSString *)profileNameForRecipientId:(NSString *)recipientId;
- (nullable UIImage *)profileAvatarForRecipientId:(NSString *)recipientId;
- (void)refreshProfileForRecipientId:(NSString *)recipientId;
- (void)updateProfileForRecipientId:(NSString *)recipientId
profileNameEncrypted:(nullable NSData *)profileNameEncrypted
avatarUrlPath:(nullable NSString *)avatarUrlPath;
#pragma mark - User Interface
- (void)presentAddThreadToProfileWhitelist:(TSThread *)thread
fromViewController:(UIViewController *)fromViewController
success:(void (^)())successHandler;
2017-07-31 20:48:43 +02:00
@end
NS_ASSUME_NONNULL_END