Statistics
| Branch: | Tag: | Revision:

chatsecureios / ChatSecure / Classes / Controllers / XMPP / OTRXMPPManager.h @ a4bb25f6

History | View | Annotate | Download (4.82 KB)

1
//
2
//  OTRXMPPManager.h
3
//  Off the Record
4
//
5
//  Created by Chris Ballinger on 9/7/11.
6
//  Copyright (c) 2011 Chris Ballinger. All rights reserved.
7
//
8
//  This file is part of ChatSecure.
9
//
10
//  ChatSecure is free software: you can redistribute it and/or modify
11
//  it under the terms of the GNU General Public License as published by
12
//  the Free Software Foundation, either version 3 of the License, or
13
//  (at your option) any later version.
14
//
15
//  ChatSecure is distributed in the hope that it will be useful,
16
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
17
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
//  GNU General Public License for more details.
19
//
20
//  You should have received a copy of the GNU General Public License
21
//  along with ChatSecure.  If not, see <http://www.gnu.org/licenses/>.
22

    
23
@import Foundation;
24
@import UIKit;
25
@import XMPPFramework;
26
#import "OTRXMPPBuddy.h"
27
#import "OTRIncomingMessage.h"
28
#import "OTROutgoingMessage.h"
29
#import "OTRProtocol.h"
30
#import "OTRConstants.h"
31
#import "OTRServerCapabilities.h"
32
#import "OTRXMPPRoomManager.h"
33

    
34
@class OTRXMPPAccount;
35
@class OTROMEMOSignalCoordinator;
36
@class XMPPPushModule, ServerCheck, FileTransferManager;
37

    
38
NS_ASSUME_NONNULL_BEGIN
39
@interface OTRXMPPManager : NSObject <XMPPRosterDelegate, XMPPStreamDelegate, NSFetchedResultsControllerDelegate, OTRProtocol>
40

    
41
@property (nonatomic, strong, readonly) OTRXMPPAccount *account;
42

    
43
@property (nonatomic, strong, readonly) XMPPRoster *xmppRoster;
44
@property (nonatomic, strong, readonly) XMPPCapabilities *xmppCapabilities;
45
@property (nonatomic, strong, readonly) OTRXMPPRoomManager *roomManager;
46
@property (nonatomic, strong, nullable) OTROMEMOSignalCoordinator *omemoSignalCoordinator;
47
@property (nonatomic, strong, readonly) OTRServerCapabilities *serverCapabilities;
48
@property (nonatomic, strong, readonly) XMPPPushModule *xmppPushModule;
49
@property (nonatomic, strong, readonly) ServerCheck *serverCheck;
50
@property (nonatomic, strong, readonly) FileTransferManager *fileTransferManager;
51

    
52
/** Useful for showing error messages related to connection, like SSL certs. Only safe for access from main queue. */
53
@property (nonatomic, readonly, nullable) NSError *lastConnectionError;
54

    
55
/** Call this if you want to register a new account on a compatible server */
56
- (BOOL)startRegisteringNewAccount;
57

    
58

    
59
//Chat State
60
- (void)sendChatState:(OTRChatState)chatState withBuddyID:(NSString *)buddyUniqueId;
61
- (void)restartPausedChatStateTimerForBuddyObjectID:(NSString *)buddyUniqueId;
62
- (void)restartInactiveChatStateTimerForBuddyObjectID:(NSString *)buddyUniqueId;
63
- (void)invalidatePausedChatStateTimerForBuddyUniqueId:(NSString *)buddyUniqueId;
64
- (void)sendPausedChatState:(NSTimer *)timer;
65
- (void)sendInactiveChatState:(NSTimer *)timer;
66
- (NSTimer *)inactiveChatStateTimerForBuddyObjectID:(NSString *)buddyUniqueId;
67
- (NSTimer *)pausedChatStateTimerForBuddyObjectID:(NSString *)buddyUniqueId;
68

    
69
// Delivery receipts
70
- (void) sendDeliveryReceiptForMessage:(OTRIncomingMessage*)message;
71

    
72
/**
73
 This updates the avatar for this managers account. It is async and will call the completion block immediately if newImage is nil.
74
 The best way to check for changes is to listen for Yap Database changes on the account object. 
75
 The completion block is called once the image is uploaded and the server responds.
76
 */
77
- (void)setAvatar:(UIImage *)newImage completion:(void (^ _Nullable)(BOOL success))completion;
78

    
79
/** Force a vCard update (by manipulating pixel values in the avatar image)
80
 */
81
- (void)forcevCardUpdateWithCompletion:(void (^)(BOOL success))completion;
82

    
83
- (void)changePassword:(NSString *)newPassword completion:(void (^)(BOOL,NSError*))completion;
84

    
85
/** Will try to send a probe to fetch last seen. If buddy is still pendingApproval it will retry subscription request. */
86
- (void) sendPresenceProbeForBuddy:(OTRXMPPBuddy*)buddy;
87

    
88
/** Will send an away presence with your last idle timestamp */
89
- (void) goAway;
90

    
91
/** Will send an available presence */
92
- (void) goOnline;
93

    
94
/** Enqueues a message to be sent by message queue */
95
- (void) enqueueMessage:(id<OTRMessageProtocol>)message;
96

    
97
/** Enqueues an array of messages to be sent by message queue */
98
- (void) enqueueMessages:(NSArray<id<OTRMessageProtocol>>*)messages;
99

    
100
@end
101

    
102

    
103
/**
104
 This notification is sent every time there is a change in the login status and if it goes 'backwards' there
105
 should be an error or a user initiated disconnect.
106
 
107
 @{
108
 OTRXMPPOldLoginStatusKey : @(OTRLoginStatus)
109
 OTRXMPPNewLoginStatusKey : @(OTRLoginStatus)
110
 OTRXMPPLoginErrorKey     : NSError*
111
 }
112
 */
113
extern NSString *const OTRXMPPLoginStatusNotificationName;
114
extern NSString *const OTRXMPPOldLoginStatusKey;
115
extern NSString *const OTRXMPPNewLoginStatusKey;
116
extern NSString *const OTRXMPPLoginErrorKey;
117
extern NSString *const OTRXMPPRegisterSucceededNotificationName;
118
extern NSString *const OTRXMPPRegisterFailedNotificationName;
119

    
120
NS_ASSUME_NONNULL_END