session-ios/SignalUtilitiesKit/To Do/OWSProfileManager.h

69 lines
2.2 KiB
C
Raw Normal View History

2017-07-31 20:48:43 +02: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-07-31 20:48:43 +02:00
NS_ASSUME_NONNULL_BEGIN
extern NSString *const kNSNotificationName_ProfileWhitelistDidChange;
extern NSString *const kNSNotificationName_ProfileKeyDidChange;
extern const NSUInteger kOWSProfileManager_NameDataLength;
extern const NSUInteger kOWSProfileManager_MaxAvatarDiameter;
2017-08-15 17:37:12 +02:00
2017-08-21 17:21:23 +02:00
@class OWSAES256Key;
@class OWSMessageSender;
2018-09-17 15:27:58 +02:00
@class OWSPrimaryStorage;
@class TSNetworkManager;
@class TSThread;
@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.
@interface OWSProfileManager : NSObject <ProfileManagerProtocol>
2017-07-31 20:48:43 +02:00
- (instancetype)init NS_UNAVAILABLE;
- (instancetype)initWithPrimaryStorage:(OWSPrimaryStorage *)primaryStorage;
2018-09-17 15:27:58 +02:00
2017-07-31 20:48:43 +02:00
+ (instancetype)sharedManager;
#pragma mark - Local Profile
// 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.
- (BOOL)hasLocalProfile;
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
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
- (BOOL)isProfileNameTooLong:(nullable NSString *)profileName;
- (void)regenerateLocalProfile;
2021-02-26 05:56:41 +01:00
#pragma mark - Other Users' Profiles
- (nullable UIImage *)profileAvatarForRecipientId:(NSString *)recipientId;
2018-05-10 03:10:23 +02:00
- (nullable NSData *)profileAvatarDataForRecipientId:(NSString *)recipientId;
- (void)updateProfileForRecipientId:(NSString *)recipientId
profileNameEncrypted:(nullable NSData *)profileNameEncrypted
avatarUrlPath:(nullable NSString *)avatarUrlPath;
2021-02-23 00:56:16 +01:00
#pragma mark - Other
- (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