mirror of https://github.com/oxen-io/session-ios
				
				
				
			
			You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
	
	
		
			97 lines
		
	
	
		
			4.0 KiB
		
	
	
	
		
			C
		
	
		
		
			
		
	
	
			97 lines
		
	
	
		
			4.0 KiB
		
	
	
	
		
			C
		
	
| 
											8 years ago
										 | //
 | ||
| 
											8 years ago
										 | //  Copyright (c) 2018 Open Whisper Systems. All rights reserved.
 | ||
| 
											8 years ago
										 | //
 | ||
|  | 
 | ||
| 
											5 years ago
										 | #import <SessionUtilitiesKit/TSYapDatabaseObject.h>
 | ||
| 
											8 years ago
										 | 
 | ||
|  | NS_ASSUME_NONNULL_BEGIN | ||
|  | 
 | ||
|  | typedef void (^OWSUserProfileCompletion)(void); | ||
|  | 
 | ||
|  | @class OWSAES256Key; | ||
|  | 
 | ||
| 
											8 years ago
										 | 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; | ||
|  | 
 | ||
| 
											8 years ago
										 | extern NSString *const kLocalProfileUniqueId; | ||
|  | 
 | ||
|  | // This class should be completely thread-safe.
 | ||
| 
											8 years ago
										 | //
 | ||
|  | // It is critical for coherency that all DB operations for this
 | ||
|  | // class should be done on OWSProfileManager's dbConnection.
 | ||
| 
											8 years ago
										 | @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; | ||
|  | 
 | ||
|  | - (instancetype)init NS_UNAVAILABLE; | ||
|  | 
 | ||
|  | + (OWSUserProfile *)getOrBuildUserProfileForRecipientId:(NSString *)recipientId | ||
|  |                                            dbConnection:(YapDatabaseConnection *)dbConnection; | ||
|  | 
 | ||
| 
											7 years ago
										 | + (OWSUserProfile *)getOrBuildUserProfileForRecipientId:(NSString *)recipientId transaction:(YapDatabaseReadWriteTransaction *)transaction; | ||
| 
											7 years ago
										 | 
 | ||
| 
											8 years ago
										 | + (BOOL)localUserProfileExists:(YapDatabaseConnection *)dbConnection; | ||
|  | 
 | ||
| 
											8 years ago
										 | #pragma mark - Update With... Methods
 | ||
|  | 
 | ||
| 
											7 years ago
										 | - (void)updateWithProfileName:(nullable NSString *)profileName | ||
|  |                 avatarUrlPath:(nullable NSString *)avatarUrlPath | ||
|  |                avatarFileName:(nullable NSString *)avatarFileName | ||
|  |                   transaction:(YapDatabaseReadWriteTransaction *)transaction | ||
|  |                    completion:(nullable OWSUserProfileCompletion)completion; | ||
|  | 
 | ||
| 
											8 years ago
										 | - (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 | ||
|  |                  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; | ||
|  | 
 | ||
| 
											7 years ago
										 | - (void)updateWithProfileKey:(OWSAES256Key *)profileKey | ||
|  |                 dbConnection:(YapDatabaseConnection *)dbConnection | ||
|  |                   completion:(nullable OWSUserProfileCompletion)completion; | ||
|  | 
 | ||
| 
											6 years ago
										 | - (void)updateWithProfileKey:(OWSAES256Key *)profileKey | ||
|  |                  transaction:(YapDatabaseReadWriteTransaction *)transaction | ||
|  |                   completion:(nullable OWSUserProfileCompletion)completion; | ||
|  | 
 | ||
| 
											8 years ago
										 | - (void)clearWithProfileKey:(OWSAES256Key *)profileKey | ||
|  |                dbConnection:(YapDatabaseConnection *)dbConnection | ||
|  |                  completion:(nullable OWSUserProfileCompletion)completion; | ||
|  | 
 | ||
| 
											7 years ago
										 | #pragma mark - Profile Avatars Directory
 | ||
|  | 
 | ||
|  | + (NSString *)profileAvatarFilepathWithFilename:(NSString *)filename; | ||
|  | + (nullable NSError *)migrateToSharedData; | ||
| 
											7 years ago
										 | + (NSString *)legacyProfileAvatarsDirPath; | ||
|  | + (NSString *)sharedDataProfileAvatarsDirPath; | ||
| 
											7 years ago
										 | + (NSString *)profileAvatarsDirPath; | ||
|  | + (void)resetProfileStorage; | ||
| 
											7 years ago
										 | + (NSSet<NSString *> *)allProfileAvatarFilePaths; | ||
| 
											7 years ago
										 | 
 | ||
| 
											8 years ago
										 | @end | ||
|  | 
 | ||
|  | NS_ASSUME_NONNULL_END |