2014-10-02 15:02:47 +00:00
|
|
|
/*
|
|
|
|
Copyright 2014 OpenMarket Ltd
|
2017-04-07 09:52:53 +00:00
|
|
|
Copyright 2017 Vector Creations Ltd
|
2020-04-14 12:54:36 +00:00
|
|
|
|
2014-10-02 15:02:47 +00:00
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
2020-04-14 12:54:36 +00:00
|
|
|
|
2014-10-02 15:02:47 +00:00
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#import <UIKit/UIKit.h>
|
2015-04-02 09:33:41 +00:00
|
|
|
#import <MatrixKit/MatrixKit.h>
|
2014-10-02 15:02:47 +00:00
|
|
|
|
2017-03-23 16:48:05 +00:00
|
|
|
#import "MasterTabBarController.h"
|
2017-08-11 12:18:10 +00:00
|
|
|
#import "JitsiViewController.h"
|
2015-12-22 14:42:53 +00:00
|
|
|
|
2017-04-07 09:52:53 +00:00
|
|
|
#import "RageShakeManager.h"
|
2018-06-27 07:55:06 +00:00
|
|
|
#import "Analytics.h"
|
2017-04-07 09:52:53 +00:00
|
|
|
|
2019-01-11 09:32:56 +00:00
|
|
|
#import "ThemeService.h"
|
2020-04-28 16:52:03 +00:00
|
|
|
#import "UniversalLink.h"
|
2017-04-07 09:52:53 +00:00
|
|
|
|
2020-07-29 08:03:37 +00:00
|
|
|
@protocol Configurable;
|
2020-09-04 11:17:01 +00:00
|
|
|
@protocol LegacyAppDelegateDelegate;
|
2020-12-02 20:17:06 +00:00
|
|
|
@class CallBar;
|
2021-03-18 23:57:58 +00:00
|
|
|
@class CallPresenter;
|
2020-07-29 08:03:37 +00:00
|
|
|
|
2016-05-19 15:22:29 +00:00
|
|
|
#pragma mark - Notifications
|
|
|
|
/**
|
|
|
|
Posted when the user taps the clock status bar.
|
|
|
|
*/
|
|
|
|
extern NSString *const kAppDelegateDidTapStatusBarNotification;
|
|
|
|
|
2016-08-11 08:38:10 +00:00
|
|
|
/**
|
|
|
|
Posted when the property 'isOffline' has changed. This property is related to the network reachability status.
|
|
|
|
*/
|
|
|
|
extern NSString *const kAppDelegateNetworkStatusDidChangeNotification;
|
|
|
|
|
2019-09-10 17:34:40 +00:00
|
|
|
extern NSString *const AppDelegateDidValidateEmailNotification;
|
|
|
|
extern NSString *const AppDelegateDidValidateEmailNotificationSIDKey;
|
|
|
|
extern NSString *const AppDelegateDidValidateEmailNotificationClientSecretKey;
|
|
|
|
|
2020-04-28 16:52:03 +00:00
|
|
|
/**
|
|
|
|
Posted when the property 'lastHandledUniversalLink' has changed. Notification object and userInfo will be nil.
|
|
|
|
*/
|
|
|
|
extern NSString *const AppDelegateUniversalLinkDidChangeNotification;
|
|
|
|
|
2020-12-01 10:41:31 +00:00
|
|
|
@interface LegacyAppDelegate : UIResponder <
|
|
|
|
UIApplicationDelegate,
|
|
|
|
UISplitViewControllerDelegate,
|
2021-03-19 14:33:07 +00:00
|
|
|
UINavigationControllerDelegate
|
|
|
|
>
|
2015-11-17 23:15:52 +00:00
|
|
|
{
|
2015-10-20 08:19:21 +00:00
|
|
|
// background sync management
|
|
|
|
void (^_completionHandler)(UIBackgroundFetchResult);
|
2014-12-12 09:49:15 +00:00
|
|
|
}
|
2014-10-02 15:02:47 +00:00
|
|
|
|
2020-09-04 11:17:01 +00:00
|
|
|
@property (weak, nonatomic) id<LegacyAppDelegateDelegate> delegate;
|
|
|
|
|
2015-12-22 14:42:53 +00:00
|
|
|
/**
|
|
|
|
Application main view controller
|
|
|
|
*/
|
2017-03-23 16:48:05 +00:00
|
|
|
@property (nonatomic, readonly) MasterTabBarController *masterTabBarController;
|
2015-12-22 14:42:53 +00:00
|
|
|
|
2014-10-03 17:26:39 +00:00
|
|
|
@property (strong, nonatomic) UIWindow *window;
|
2014-10-02 15:02:47 +00:00
|
|
|
|
2017-07-14 14:41:25 +00:00
|
|
|
@property (strong, nonatomic) UIAlertController *errorNotification;
|
2014-10-31 17:54:32 +00:00
|
|
|
|
2015-02-04 17:18:38 +00:00
|
|
|
@property (strong, nonatomic) NSString *appVersion;
|
|
|
|
@property (strong, nonatomic) NSString *build;
|
|
|
|
|
2015-02-02 15:43:47 +00:00
|
|
|
@property (nonatomic) BOOL isAppForeground;
|
2015-02-18 16:40:55 +00:00
|
|
|
@property (nonatomic) BOOL isOffline;
|
2020-10-01 09:45:10 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Last navigated room's identifier from a push notification.
|
|
|
|
*/
|
|
|
|
// TODO: This property is introduced to fix #3672. Remove it when a better solution revealed to the problem.
|
2020-09-23 13:53:00 +00:00
|
|
|
@property (nonatomic, copy) NSString *lastNavigatedRoomIdFromPush;
|
2015-02-02 15:43:47 +00:00
|
|
|
|
2020-04-28 15:31:49 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Let the AppDelegate handle and display self verification requests.
|
2020-08-25 16:48:09 +00:00
|
|
|
Default is YES.
|
2020-04-28 15:31:49 +00:00
|
|
|
*/
|
|
|
|
@property (nonatomic) BOOL handleSelfVerificationRequest;
|
|
|
|
|
2017-03-14 16:25:46 +00:00
|
|
|
/**
|
|
|
|
The navigation controller of the master view controller of the main split view controller.
|
|
|
|
*/
|
2017-03-23 16:48:05 +00:00
|
|
|
@property (nonatomic, readonly) UINavigationController *masterNavigationController;
|
2017-03-14 16:25:46 +00:00
|
|
|
/**
|
|
|
|
The navigation controller of the detail view controller of the main split view controller (may be nil).
|
|
|
|
*/
|
2016-06-21 19:47:20 +00:00
|
|
|
@property (nonatomic, readonly) UINavigationController *secondaryNavigationController;
|
2015-11-27 12:29:40 +00:00
|
|
|
|
2015-11-17 23:15:52 +00:00
|
|
|
// Associated matrix sessions (empty by default).
|
|
|
|
@property (nonatomic, readonly) NSArray *mxSessions;
|
|
|
|
|
|
|
|
// Current selected room id. nil if no room is presently visible.
|
|
|
|
@property (strong, nonatomic) NSString *visibleRoomId;
|
|
|
|
|
2020-04-28 16:52:03 +00:00
|
|
|
/**
|
|
|
|
Last handled universal link (url will be formatted for several hash keys).
|
|
|
|
*/
|
|
|
|
@property (nonatomic, readonly) UniversalLink *lastHandledUniversalLink;
|
|
|
|
|
2018-04-08 14:00:33 +00:00
|
|
|
// New message sound id.
|
|
|
|
@property (nonatomic, readonly) SystemSoundID messageSound;
|
|
|
|
|
2020-07-29 08:03:37 +00:00
|
|
|
// Build Settings
|
|
|
|
@property (nonatomic, readonly) id<Configurable> configuration;
|
|
|
|
|
2021-03-18 23:57:58 +00:00
|
|
|
/**
|
|
|
|
Call presenter instance. May be nil unless at least one session initialized.
|
|
|
|
*/
|
|
|
|
@property (nonatomic, strong, readonly) CallPresenter *callPresenter;
|
|
|
|
|
2020-08-31 17:22:37 +00:00
|
|
|
+ (instancetype)theDelegate;
|
2014-10-08 12:14:12 +00:00
|
|
|
|
2020-04-30 12:43:08 +00:00
|
|
|
#pragma mark - Push Notifications
|
|
|
|
|
|
|
|
/**
|
|
|
|
Perform registration for remote notifications.
|
|
|
|
|
|
|
|
@param completion the block to be executed when registration finished.
|
|
|
|
*/
|
2020-08-31 17:22:37 +00:00
|
|
|
- (void)registerForRemoteNotificationsWithCompletion:(void (^)(NSError *))completion;
|
2020-04-30 12:43:08 +00:00
|
|
|
|
2015-11-17 23:15:52 +00:00
|
|
|
#pragma mark - Application layout handling
|
2015-06-02 12:55:10 +00:00
|
|
|
|
2019-01-05 02:28:03 +00:00
|
|
|
- (void)restoreInitialDisplay:(void (^)(void))completion;
|
2015-11-17 23:15:52 +00:00
|
|
|
|
2017-12-21 16:19:36 +00:00
|
|
|
/**
|
|
|
|
Replace the secondary view controller of the split view controller (if any) with the default empty details view controller.
|
|
|
|
*/
|
|
|
|
- (void)restoreEmptyDetailsViewController;
|
|
|
|
|
2017-07-14 14:41:25 +00:00
|
|
|
- (UIAlertController*)showErrorAsAlert:(NSError*)error;
|
2019-01-17 16:46:49 +00:00
|
|
|
- (UIAlertController*)showAlertWithTitle:(NSString*)title message:(NSString*)message;
|
2015-11-17 23:15:52 +00:00
|
|
|
|
|
|
|
#pragma mark - Matrix Sessions handling
|
|
|
|
|
2015-11-20 13:47:38 +00:00
|
|
|
// Add a matrix session.
|
2015-11-17 23:15:52 +00:00
|
|
|
- (void)addMatrixSession:(MXSession*)mxSession;
|
|
|
|
|
|
|
|
// Remove a matrix session.
|
|
|
|
- (void)removeMatrixSession:(MXSession*)mxSession;
|
2014-12-12 09:49:15 +00:00
|
|
|
|
2016-08-26 14:12:46 +00:00
|
|
|
// Mark all messages as read in the running matrix sessions.
|
|
|
|
- (void)markAllMessagesAsRead;
|
|
|
|
|
2015-11-17 23:15:52 +00:00
|
|
|
// Reload all running matrix sessions
|
2015-04-30 14:19:12 +00:00
|
|
|
- (void)reloadMatrixSessions:(BOOL)clearCache;
|
|
|
|
|
2018-04-17 19:39:31 +00:00
|
|
|
/**
|
|
|
|
Log out all the accounts after asking for a potential confirmation.
|
|
|
|
Show the authentication screen on successful logout.
|
2020-04-14 12:54:36 +00:00
|
|
|
|
2018-04-17 19:39:31 +00:00
|
|
|
@param askConfirmation tell whether a confirmation is required before logging out.
|
|
|
|
@param completion the block to execute at the end of the operation.
|
|
|
|
*/
|
|
|
|
- (void)logoutWithConfirmation:(BOOL)askConfirmation completion:(void (^)(BOOL isLoggedOut))completion;
|
2014-10-08 16:55:26 +00:00
|
|
|
|
2018-05-30 15:04:58 +00:00
|
|
|
/**
|
|
|
|
Log out all the accounts without confirmation.
|
|
|
|
Show the authentication screen on successful logout.
|
2020-04-14 12:54:36 +00:00
|
|
|
|
2019-04-20 02:17:34 +00:00
|
|
|
@param sendLogoutRequest Indicate whether send logout request to homeserver.
|
2018-05-30 15:04:58 +00:00
|
|
|
@param completion the block to execute at the end of the operation.
|
|
|
|
*/
|
2018-06-01 14:07:42 +00:00
|
|
|
- (void)logoutSendingRequestServer:(BOOL)sendLogoutServerRequest
|
|
|
|
completion:(void (^)(BOOL isLoggedOut))completion;
|
|
|
|
|
2020-01-14 20:47:16 +00:00
|
|
|
/**
|
|
|
|
Present incoming key verification request to accept.
|
|
|
|
|
|
|
|
@param incomingKeyVerificationRequest The incoming key verification request.
|
|
|
|
@param The matrix session.
|
|
|
|
@return Indicate NO if the key verification screen could not be presented.
|
|
|
|
*/
|
|
|
|
- (BOOL)presentIncomingKeyVerificationRequest:(MXKeyVerificationRequest*)incomingKeyVerificationRequest
|
|
|
|
inSession:(MXSession*)session;
|
2018-05-30 15:04:58 +00:00
|
|
|
|
2020-01-30 17:05:41 +00:00
|
|
|
- (BOOL)presentUserVerificationForRoomMember:(MXRoomMember*)roomMember session:(MXSession*)mxSession;
|
2020-01-30 16:59:42 +00:00
|
|
|
|
2020-04-23 09:58:19 +00:00
|
|
|
- (BOOL)presentCompleteSecurityForSession:(MXSession*)mxSession;
|
2020-08-11 18:18:13 +00:00
|
|
|
|
|
|
|
- (void)configureCallManagerIfRequiredForSession:(MXSession *)mxSession;
|
2020-04-23 09:58:19 +00:00
|
|
|
|
2020-09-24 09:37:24 +00:00
|
|
|
- (void)authenticationDidComplete;
|
|
|
|
|
2015-11-17 23:15:52 +00:00
|
|
|
#pragma mark - Matrix Accounts handling
|
2014-10-08 12:14:12 +00:00
|
|
|
|
2015-11-17 23:15:52 +00:00
|
|
|
- (void)selectMatrixAccount:(void (^)(MXKAccount *selectedAccount))onSelection;
|
|
|
|
|
|
|
|
#pragma mark - Matrix Room handling
|
|
|
|
|
2019-04-08 11:32:46 +00:00
|
|
|
// Show a room and jump to the given event if event id is not nil otherwise go to last messages.
|
2019-04-29 12:22:01 +00:00
|
|
|
- (void)showRoom:(NSString*)roomId andEventId:(NSString*)eventId withMatrixSession:(MXSession*)mxSession restoreInitialDisplay:(BOOL)restoreInitialDisplay completion:(void (^)(void))completion;
|
|
|
|
|
|
|
|
- (void)showRoom:(NSString*)roomId andEventId:(NSString*)eventId withMatrixSession:(MXSession*)mxSession restoreInitialDisplay:(BOOL)restoreInitialDisplay;
|
2019-04-08 11:32:46 +00:00
|
|
|
|
2016-04-07 15:38:19 +00:00
|
|
|
- (void)showRoom:(NSString*)roomId andEventId:(NSString*)eventId withMatrixSession:(MXSession*)mxSession;
|
2015-11-17 23:15:52 +00:00
|
|
|
|
2016-11-02 13:32:02 +00:00
|
|
|
// Creates a new direct chat with the provided user id
|
|
|
|
- (void)createDirectChatWithUserId:(NSString*)userId completion:(void (^)(void))completion;
|
2015-05-04 12:49:30 +00:00
|
|
|
|
2016-11-02 16:54:28 +00:00
|
|
|
// Reopen an existing direct room with this userId or creates a new one (if it doesn't exist)
|
|
|
|
- (void)startDirectChatWithUserId:(NSString*)userId completion:(void (^)(void))completion;
|
|
|
|
|
2016-04-18 15:53:30 +00:00
|
|
|
/**
|
|
|
|
Process the fragment part of a vector.im link.
|
2020-04-14 12:54:36 +00:00
|
|
|
|
2016-04-18 15:53:30 +00:00
|
|
|
@param fragment the fragment part of the universal link.
|
|
|
|
@return YES in case of processing success.
|
|
|
|
*/
|
|
|
|
- (BOOL)handleUniversalLinkFragment:(NSString*)fragment;
|
|
|
|
|
2021-05-04 08:41:02 +00:00
|
|
|
/**
|
|
|
|
Process the fragment part of a vector.im link.
|
|
|
|
|
|
|
|
@param fragment the fragment part of the universal link.
|
|
|
|
@param universalLinkURL the unprocessed the universal link URL (optional).
|
|
|
|
@return YES in case of processing success.
|
|
|
|
*/
|
|
|
|
- (BOOL)handleUniversalLinkFragment:(NSString*)fragment fromURL:(NSURL*)universalLinkURL;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Process the URL of a vector.im link.
|
|
|
|
|
|
|
|
@param universalLinkURL the universal link URL.
|
|
|
|
@return YES in case of processing success.
|
|
|
|
*/
|
|
|
|
- (BOOL)handleUniversalLinkURL:(NSURL*)universalLinkURL;
|
|
|
|
|
2017-08-11 12:18:10 +00:00
|
|
|
#pragma mark - Jitsi call
|
|
|
|
|
|
|
|
/**
|
|
|
|
Open the Jitsi view controller from a widget.
|
2020-04-14 12:54:36 +00:00
|
|
|
|
2017-08-11 12:18:10 +00:00
|
|
|
@param jitsiWidget the jitsi widget.
|
|
|
|
@param video to indicate voice or video call.
|
|
|
|
*/
|
|
|
|
- (void)displayJitsiViewControllerWithWidget:(Widget*)jitsiWidget andVideo:(BOOL)video;
|
|
|
|
|
|
|
|
/**
|
|
|
|
The current Jitsi view controller being displayed.
|
|
|
|
*/
|
|
|
|
@property (nonatomic, readonly) JitsiViewController *jitsiViewController;
|
|
|
|
|
2016-08-08 16:40:22 +00:00
|
|
|
#pragma mark - Call status handling
|
|
|
|
|
2016-09-02 20:21:02 +00:00
|
|
|
/**
|
|
|
|
Call status window displayed when user goes back to app during a call.
|
|
|
|
*/
|
|
|
|
@property (nonatomic, readonly) UIWindow* callStatusBarWindow;
|
2020-12-02 20:17:06 +00:00
|
|
|
@property (nonatomic, readonly) CallBar* callBar;
|
2016-09-02 20:21:02 +00:00
|
|
|
|
2020-07-10 19:28:57 +00:00
|
|
|
#pragma mark - App version management
|
|
|
|
|
|
|
|
/**
|
|
|
|
Check for app version related informations to display
|
|
|
|
*/
|
|
|
|
- (void)checkAppVersion;
|
|
|
|
|
2021-01-07 13:38:27 +00:00
|
|
|
#pragma mark - Authentication
|
|
|
|
|
|
|
|
/// When SSO login succeeded, when SFSafariViewController is used, continue login with success parameters.
|
|
|
|
/// @param loginToken The login token provided when SSO succeeded.
|
|
|
|
/// @param txnId transaction id generated during SSO page presentation.
|
|
|
|
/// returns YES if the SSO login can be continued.
|
|
|
|
- (BOOL)continueSSOLoginWithToken:(NSString*)loginToken txnId:(NSString*)txnId;
|
|
|
|
|
2014-10-02 15:02:47 +00:00
|
|
|
@end
|
2020-09-04 11:17:01 +00:00
|
|
|
|
|
|
|
@protocol LegacyAppDelegateDelegate <NSObject>
|
|
|
|
|
|
|
|
- (void)legacyAppDelegate:(LegacyAppDelegate*)legacyAppDelegate wantsToPopToHomeViewControllerAnimated:(BOOL)animated completion:(void (^)(void))completion;
|
|
|
|
- (void)legacyAppDelegateRestoreEmptyDetailsViewController:(LegacyAppDelegate*)legacyAppDelegate;
|
|
|
|
|
|
|
|
@end
|