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.
79 lines
2.0 KiB
Objective-C
79 lines
2.0 KiB
Objective-C
//
|
|
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
|
//
|
|
|
|
#import <SignalUtilitiesKit/TSYapDatabaseObject.h>
|
|
#import <Mantle/MTLJSONAdapter.h>
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
extern uint32_t const OWSDevicePrimaryDeviceId;
|
|
|
|
@interface OWSDeviceManager : NSObject
|
|
|
|
- (instancetype)init NS_UNAVAILABLE;
|
|
|
|
+ (instancetype)sharedManager;
|
|
|
|
- (BOOL)mayHaveLinkedDevices:(YapDatabaseConnection *)dbConnection;
|
|
- (void)setMayHaveLinkedDevices;
|
|
- (void)clearMayHaveLinkedDevices;
|
|
|
|
- (BOOL)hasReceivedSyncMessageInLastSeconds:(NSTimeInterval)intervalSeconds;
|
|
- (void)setHasReceivedSyncMessage;
|
|
|
|
@end
|
|
|
|
#pragma mark -
|
|
|
|
@interface OWSDevice : TSYapDatabaseObject <MTLJSONSerializing>
|
|
|
|
@property (nonatomic, readonly) NSInteger deviceId;
|
|
@property (nonatomic, readonly, nullable) NSString *name;
|
|
@property (nonatomic, readonly) NSDate *createdAt;
|
|
@property (nonatomic, readonly) NSDate *lastSeenAt;
|
|
|
|
+ (nullable instancetype)deviceFromJSONDictionary:(NSDictionary *)deviceAttributes error:(NSError **)error;
|
|
|
|
+ (NSArray<OWSDevice *> *)currentDevicesWithTransaction:(YapDatabaseReadTransaction *)transaction;
|
|
|
|
/**
|
|
* Set local database of devices to `devices`.
|
|
*
|
|
* This will create missing devices, update existing devices, and delete stale devices.
|
|
* @param devices Removes any existing devices, replacing them with `devices`
|
|
*
|
|
* Returns YES if any devices were added or removed.
|
|
*/
|
|
+ (BOOL)replaceAll:(NSArray<OWSDevice *> *)devices;
|
|
|
|
/**
|
|
* The id of the device currently running this application
|
|
*/
|
|
+ (uint32_t)currentDeviceId;
|
|
|
|
/**
|
|
*
|
|
* @param transaction yapTransaction
|
|
* @return
|
|
* If the user has any linked devices (apart from the device this app is running on).
|
|
*/
|
|
+ (BOOL)hasSecondaryDevicesWithTransaction:(YapDatabaseReadTransaction *)transaction;
|
|
|
|
- (NSString *)displayName;
|
|
- (BOOL)isPrimaryDevice;
|
|
|
|
/**
|
|
* Assign attributes to this device from another.
|
|
*
|
|
* @param other
|
|
* OWSDevice whose attributes to copy to this device
|
|
* @return
|
|
* YES if any values on self changed, else NO
|
|
*/
|
|
- (BOOL)updateAttributesWithDevice:(OWSDevice *)other;
|
|
|
|
@end
|
|
|
|
NS_ASSUME_NONNULL_END
|