|
|
|
//
|
|
|
|
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import <SignalServiceKit/TSYapDatabaseObject.h>
|
|
|
|
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
|
|
|
typedef void (^OWSUserProfileCompletion)(void);
|
|
|
|
|
|
|
|
@class OWSAES256Key;
|
|
|
|
|
|
|
|
extern NSString *const kNSNotificationName_LocalProfileDidChange;
|
|
|
|
extern NSString *const kNSNotificationName_OtherUsersProfileWillChange;
|
|
|
|
extern NSString *const kNSNotificationName_OtherUsersProfileDidChange;
|
|
|
|
|
|
|
|
extern NSString *const kNSNotificationKey_ProfileRecipientId;
|
|
|
|
extern NSString *const kNSNotificationKey_ProfileGroupId;
|
|
|
|
|
|
|
|
extern NSString *const kLocalProfileUniqueId;
|
|
|
|
|
|
|
|
// This class should be completely thread-safe.
|
|
|
|
@interface OWSUserProfile : TSYapDatabaseObject
|
|
|
|
|
|
|
|
@property (atomic, readonly) NSString *recipientId;
|
|
|
|
@property (atomic, readonly, nullable) OWSAES256Key *profileKey;
|
|
|
|
@property (atomic, readonly, nullable) NSString *profileName;
|
|
|
|
@property (atomic, readonly, nullable) NSString *avatarUrlPath;
|
|
|
|
// This filename is relative to OWSProfileManager.profileAvatarsDirPath.
|
|
|
|
@property (atomic, readonly, nullable) NSString *avatarFileName;
|
|
|
|
|
|
|
|
// This should reflect when either:
|
|
|
|
//
|
|
|
|
// * The last successful update finished.
|
|
|
|
// * The current in-flight update began.
|
|
|
|
@property (atomic, readonly, nullable) NSDate *lastUpdateDate;
|
|
|
|
|
|
|
|
- (instancetype)init NS_UNAVAILABLE;
|
|
|
|
|
|
|
|
+ (OWSUserProfile *)getOrBuildUserProfileForRecipientId:(NSString *)recipientId
|
|
|
|
dbConnection:(YapDatabaseConnection *)dbConnection;
|
|
|
|
|
|
|
|
#pragma mark - Update With... Methods
|
|
|
|
|
|
|
|
- (void)updateWithProfileName:(nullable NSString *)profileName
|
|
|
|
profileKey:(OWSAES256Key *)profileKey
|
|
|
|
avatarUrlPath:(nullable NSString *)avatarUrlPath
|
|
|
|
avatarFileName:(nullable NSString *)avatarFileName
|
|
|
|
dbConnection:(YapDatabaseConnection *)dbConnection
|
|
|
|
completion:(nullable OWSUserProfileCompletion)completion;
|
|
|
|
|
|
|
|
- (void)updateWithProfileName:(nullable NSString *)profileName
|
|
|
|
avatarUrlPath:(nullable NSString *)avatarUrlPath
|
|
|
|
avatarFileName:(nullable NSString *)avatarFileName
|
|
|
|
dbConnection:(YapDatabaseConnection *)dbConnection
|
|
|
|
completion:(nullable OWSUserProfileCompletion)completion;
|
|
|
|
|
|
|
|
- (void)updateWithProfileName:(nullable NSString *)profileName
|
|
|
|
avatarUrlPath:(nullable NSString *)avatarUrlPath
|
|
|
|
avatarFileName:(nullable NSString *)avatarFileName
|
|
|
|
lastUpdateDate:(nullable NSDate *)lastUpdateDate
|
|
|
|
dbConnection:(YapDatabaseConnection *)dbConnection
|
|
|
|
completion:(nullable OWSUserProfileCompletion)completion;
|
|
|
|
|
|
|
|
- (void)updateWithProfileName:(nullable NSString *)profileName
|
|
|
|
avatarUrlPath:(nullable NSString *)avatarUrlPath
|
|
|
|
lastUpdateDate:(nullable NSDate *)lastUpdateDate
|
|
|
|
dbConnection:(YapDatabaseConnection *)dbConnection
|
|
|
|
completion:(nullable OWSUserProfileCompletion)completion;
|
|
|
|
|
|
|
|
- (void)updateWithAvatarUrlPath:(nullable NSString *)avatarUrlPath
|
|
|
|
avatarFileName:(nullable NSString *)avatarFileName
|
|
|
|
dbConnection:(YapDatabaseConnection *)dbConnection
|
|
|
|
completion:(nullable OWSUserProfileCompletion)completion;
|
|
|
|
|
|
|
|
- (void)updateWithAvatarFileName:(nullable NSString *)avatarFileName
|
|
|
|
dbConnection:(YapDatabaseConnection *)dbConnection
|
|
|
|
completion:(nullable OWSUserProfileCompletion)completion;
|
|
|
|
|
|
|
|
- (void)updateWithLastUpdateDate:(nullable NSDate *)lastUpdateDate
|
|
|
|
dbConnection:(YapDatabaseConnection *)dbConnection
|
|
|
|
completion:(nullable OWSUserProfileCompletion)completion;
|
|
|
|
|
|
|
|
- (void)clearWithProfileKey:(OWSAES256Key *)profileKey
|
|
|
|
dbConnection:(YapDatabaseConnection *)dbConnection
|
|
|
|
completion:(nullable OWSUserProfileCompletion)completion;
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
NS_ASSUME_NONNULL_END
|