-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Expand file tree
/
Copy pathOTRAccount.h
More file actions
132 lines (107 loc) · 4.91 KB
/
OTRAccount.h
File metadata and controls
132 lines (107 loc) · 4.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
//
// OTRAccount.h
// Off the Record
//
// Created by David Chiles on 3/28/14.
// Copyright (c) 2014 Chris Ballinger. All rights reserved.
//
@import UIKit;
#import "OTRYapDatabaseObject.h"
#import "OTRProtocol.h"
#import "OTRUserInfoProfile.h"
typedef NS_ENUM(int, OTRAccountType) {
OTRAccountTypeNone = 0,
OTRAccountTypeFacebook = 1, // deprecated
OTRAccountTypeGoogleTalk = 2,
OTRAccountTypeJabber = 3,
OTRAccountTypeAIM = 4, // deprecated
OTRAccountTypeXMPPTor = 5
};
typedef NS_ENUM(int, OTRFingerprintType) {
OTRFingerprintTypeNone = 0,
OTRFingerprintTypeOTR = 1,
OTRFingerprintTypeAxolotl = 2,
OTRFingerprintTypeGPG = 3
};
NS_ASSUME_NONNULL_BEGIN
extern NSString *const OTRAimImageName;
extern NSString *const OTRGoogleTalkImageName;
extern NSString *const OTRXMPPImageName;
extern NSString *const OTRXMPPTorImageName;
@interface OTRAccount : OTRYapDatabaseObject <OTRUserInfoProfile>
@property (nonatomic, strong) NSString *username;
@property (nonatomic, readonly) OTRAccountType accountType;
@property (nonatomic, strong) NSString *displayName;
/** Setting rememberPassword to false will remove keychain passwords */
@property (nonatomic) BOOL rememberPassword;
@property (nonatomic) BOOL autologin;
@property (nonatomic, readonly) BOOL isArchived;
/** Whether or not user would like to auto fetch media messages */
@property (nonatomic, readwrite) BOOL disableAutomaticURLFetching;
@property (nonatomic, readwrite) BOOL certificatePinning;
/**
* Setting this value does a comparison of against the previously value
* to invalidate the OTRImages cache.
*/
@property (nonatomic, strong, nullable) NSData *avatarData;
/**
* To remove the keychain password, you must explicitly call removeKeychainPassword
* instead of setting empty string or nil
*/
@property (nonatomic, strong, nullable) NSString *password;
/** Removes the account password from keychain */
- (BOOL) removeKeychainPassword:(NSError**)error;
/** Will return nil if accountType does not match class type. @see accountClassForAccountType: */
- (nullable instancetype)initWithUsername:(NSString*)username
accountType:(OTRAccountType)accountType NS_DESIGNATED_INITIALIZER;
/** Will return a concrete subclass of OTRAccount. @see accountClassForAccountType: */
+ (nullable __kindof OTRAccount*)accountWithUsername:(NSString*)username
accountType:(OTRAccountType)accountType;
/** Not available, use designated initializer */
- (instancetype) init NS_UNAVAILABLE;
/**
The current or generated avatar image either from avatarData or the initials from displayName or username
@return An UIImage from the OTRImages NSCache
*/
- (UIImage *)avatarImage;
/** Image for XMPP logo, etc */
- (nullable UIImage *)accountImage;
/** Returns concrete subclass of OTRAccount corresponding to OTRAccountType */
+ (nullable Class) accountClassForAccountType:(OTRAccountType)accountType;
- (OTRProtocolType)protocolType;
/** Must implement in subclass to return class implementing id<OTRProtocol> */
- (Class)protocolClass;
- (NSString *)protocolTypeString;
- (NSArray <__kindof OTRBuddy *>*)allBuddiesWithTransaction:(YapDatabaseReadTransaction *)transaction;
+ (NSArray <OTRAccount *>*)allAccountsWithUsername:(NSString *)username transaction:(YapDatabaseReadTransaction*)transaction;
+ (NSArray <OTRAccount *>*)allAccountsWithTransaction:(YapDatabaseReadTransaction*)transaction;
+ (NSUInteger) numberOfAccountsWithTransaction:(YapDatabaseReadTransaction*)transaction;
+ (nullable OTRAccount*) accountForThread:(id<OTRThreadOwner>)thread transaction:(YapDatabaseReadTransaction*)transaction;
/**
Remove all accounts with account type using a read/write transaction
@param accountType the account type to remove
@param transaction a readwrite yap transaction
@return the number of accounts removed
*/
+ (NSUInteger)removeAllAccountsOfType:(OTRAccountType)accountType inTransaction:(YapDatabaseReadWriteTransaction *)transaction;
#pragma mark Fingerprints
/**
* Returns the full share URL invite link for this account. Optionally includes fingerprints of various key types.
*
* @param fingerprintTypes (optional) include a NSSet of boxed of OTRFingerprintType values
* @param completion called on main queue with shareURL, or potentially nil if there's an error during link generation.
*/
- (void) generateShareURLWithFingerprintTypes:(NSSet <NSNumber*> *)fingerprintTypes
completion:(void (^)(NSURL* _Nullable shareURL, NSError* _Nullable error))completionBlock;
/**
* Returns string representation of OTRFingerprintType
*
* - "otr" for OTRFingerprintTypeOTR
* - "omemo" for OTRFingerprintTypeAxolotl
* - "gpg" for OTRFingerprintTypeGPG
*
* @return String representation of OTRFingerprintType
*/
+ (nullable NSString*) fingerprintStringTypeForFingerprintType:(OTRFingerprintType)fingerprintType;
@end
NS_ASSUME_NONNULL_END