2017-07-31 20:48:43 +02:00
|
|
|
//
|
2018-02-20 23:37:14 +01:00
|
|
|
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
2017-07-31 20:48:43 +02:00
|
|
|
//
|
|
|
|
|
2020-11-25 06:15:16 +01:00
|
|
|
#import <SessionMessagingKit/ProfileManagerProtocol.h>
|
2017-08-02 19:12:26 +02:00
|
|
|
|
2017-07-31 20:48:43 +02:00
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
2017-08-17 00:09:47 +02:00
|
|
|
extern NSString *const kNSNotificationName_ProfileWhitelistDidChange;
|
2018-10-12 17:51:17 +02:00
|
|
|
extern NSString *const kNSNotificationName_ProfileKeyDidChange;
|
2017-08-01 19:53:51 +02:00
|
|
|
|
2017-09-01 20:52:17 +02:00
|
|
|
extern const NSUInteger kOWSProfileManager_NameDataLength;
|
2017-09-01 22:49:03 +02:00
|
|
|
extern const NSUInteger kOWSProfileManager_MaxAvatarDiameter;
|
2017-08-15 17:37:12 +02:00
|
|
|
|
2017-08-21 17:21:23 +02:00
|
|
|
@class OWSAES256Key;
|
2017-08-28 22:45:24 +02:00
|
|
|
@class OWSMessageSender;
|
2018-09-17 15:27:58 +02:00
|
|
|
@class OWSPrimaryStorage;
|
|
|
|
@class TSNetworkManager;
|
2017-09-25 18:38:35 +02:00
|
|
|
@class TSThread;
|
2019-05-28 05:04:32 +02:00
|
|
|
@class YapDatabaseReadWriteTransaction;
|
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;
|
|
|
|
|
2018-10-10 14:55:20 +02:00
|
|
|
- (instancetype)initWithPrimaryStorage:(OWSPrimaryStorage *)primaryStorage;
|
2018-09-17 15:27:58 +02:00
|
|
|
|
2017-07-31 20:48:43 +02:00
|
|
|
+ (instancetype)sharedManager;
|
|
|
|
|
2017-08-01 18:52:15 +02:00
|
|
|
#pragma mark - Local Profile
|
|
|
|
|
2017-12-08 20:43:11 +01:00
|
|
|
// localUserProfileExists is true if there is _ANY_ local profile.
|
|
|
|
- (BOOL)localProfileExists;
|
2017-12-11 18:37:47 +01:00
|
|
|
// hasLocalProfile is true if there is a local profile with a name or avatar.
|
2017-08-03 23:43:21 +02:00
|
|
|
- (BOOL)hasLocalProfile;
|
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-11-08 20:04:51 +01:00
|
|
|
success:(void (^)(void))successBlock
|
2020-02-17 06:46:13 +01:00
|
|
|
failure:(void (^)(NSError *))failureBlock
|
|
|
|
requiresSync:(BOOL)requiresSync;
|
2017-08-01 16:51:01 +02:00
|
|
|
|
2017-08-25 00:02:33 +02:00
|
|
|
- (BOOL)isProfileNameTooLong:(nullable NSString *)profileName;
|
|
|
|
|
2017-08-24 17:27:36 +02:00
|
|
|
- (void)regenerateLocalProfile;
|
2017-08-16 21:32:56 +02:00
|
|
|
|
2021-02-26 05:56:41 +01:00
|
|
|
#pragma mark - Other Users' Profiles
|
2017-08-02 15:27:29 +02:00
|
|
|
|
|
|
|
- (nullable UIImage *)profileAvatarForRecipientId:(NSString *)recipientId;
|
2018-05-10 03:10:23 +02:00
|
|
|
- (nullable NSData *)profileAvatarDataForRecipientId:(NSString *)recipientId;
|
2017-08-02 15:27:29 +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
|
|
|
|
2021-02-23 00:56:16 +01:00
|
|
|
#pragma mark - Other
|
|
|
|
|
2021-07-22 06:41:27 +02:00
|
|
|
- (void)downloadAvatarForUserProfile:(SNContact *)contact;
|
2021-02-23 00:56:16 +01:00
|
|
|
|
2017-07-31 20:48:43 +02:00
|
|
|
@end
|
|
|
|
|
|
|
|
NS_ASSUME_NONNULL_END
|