Skip to content

Commit

Permalink
WIP on scenes
Browse files Browse the repository at this point in the history
  • Loading branch information
yury committed Jul 9, 2019
1 parent e4975bc commit abeda6d
Show file tree
Hide file tree
Showing 11 changed files with 239 additions and 73 deletions.
16 changes: 12 additions & 4 deletions Blink.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@
D21A3FE721943BE200269705 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = D21A3FD621943BE200269705 /* [email protected] */; };
D2334D1C21495DAE00D26AC3 /* udptunnel.m in Sources */ = {isa = PBXBuildFile; fileRef = D2334D1321495DAE00D26AC3 /* udptunnel.m */; };
D2334D1D21495DAE00D26AC3 /* host2ip.c in Sources */ = {isa = PBXBuildFile; fileRef = D2334D1421495DAE00D26AC3 /* host2ip.c */; };
D235579522CE03F00094AADB /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D235579422CE03F00094AADB /* SceneDelegate.swift */; };
D23742CA21106ADF00366359 /* bench.m in Sources */ = {isa = PBXBuildFile; fileRef = D23742C921106ADF00366359 /* bench.m */; };
D23970FF20A07B9100881637 /* prompt.cxx in Sources */ = {isa = PBXBuildFile; fileRef = D23970E820A07B9100881637 /* prompt.cxx */; };
D239710020A07B9100881637 /* conversion.cxx in Sources */ = {isa = PBXBuildFile; fileRef = D23970EC20A07B9100881637 /* conversion.cxx */; };
Expand Down Expand Up @@ -216,8 +215,10 @@
D2C21F3920FCD7B800F125E0 /* blinkCommandsDictionary.plist in Resources */ = {isa = PBXBuildFile; fileRef = D2C21F3220FCD6CD00F125E0 /* blinkCommandsDictionary.plist */; };
D2C8D30A21B544B100AC39C3 /* say.m in Sources */ = {isa = PBXBuildFile; fileRef = D2C8D30921B544B100AC39C3 /* say.m */; };
D2D0AD081FFB7A74007EC56A /* MCPSessionParameters.m in Sources */ = {isa = PBXBuildFile; fileRef = D2D0AD071FFB7A74007EC56A /* MCPSessionParameters.m */; };
D2D2BB5D22D502740015D032 /* WidgetsManager.m in Sources */ = {isa = PBXBuildFile; fileRef = D2D2BB5C22D502740015D032 /* WidgetsManager.m */; };
D2D6D78620527651003CBEC4 /* TermDevice.m in Sources */ = {isa = PBXBuildFile; fileRef = D2D6D78520527651003CBEC4 /* TermDevice.m */; };
D2D75EE021AFDA10007336B6 /* LayoutManager.m in Sources */ = {isa = PBXBuildFile; fileRef = D2D75EDF21AFDA10007336B6 /* LayoutManager.m */; };
D2DACEBB22D4FF18006620A1 /* SceneDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = D2DACEBA22D4FF18006620A1 /* SceneDelegate.m */; };
D2E4F91B20B0537D00B30F7B /* Migrator.m in Sources */ = {isa = PBXBuildFile; fileRef = D2E4F91A20B0537D00B30F7B /* Migrator.m */; };
D2EFE1F520B7FAFC0087888B /* link_files.m in Sources */ = {isa = PBXBuildFile; fileRef = D2EFE1EE20B7FAFC0087888B /* link_files.m */; };
D2F30EAD205009CD008C5F35 /* base64js.min.js in Resources */ = {isa = PBXBuildFile; fileRef = D2F30EAC205009CD008C5F35 /* base64js.min.js */; };
Expand Down Expand Up @@ -532,7 +533,6 @@
D2334D1321495DAE00D26AC3 /* udptunnel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = udptunnel.m; sourceTree = "<group>"; };
D2334D1421495DAE00D26AC3 /* host2ip.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = host2ip.c; sourceTree = "<group>"; };
D2334D1521495DAE00D26AC3 /* host2ip.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = host2ip.h; sourceTree = "<group>"; };
D235579422CE03F00094AADB /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
D235579622CE07D20094AADB /* Blink-bridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Blink-bridge.h"; sourceTree = "<group>"; };
D23742C921106ADF00366359 /* bench.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = bench.m; sourceTree = "<group>"; };
D23970E420A07B8300881637 /* replxx.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = replxx.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -665,10 +665,14 @@
D2C8D30921B544B100AC39C3 /* say.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = say.m; sourceTree = "<group>"; };
D2D0AD061FFB7A74007EC56A /* MCPSessionParameters.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MCPSessionParameters.h; sourceTree = "<group>"; };
D2D0AD071FFB7A74007EC56A /* MCPSessionParameters.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MCPSessionParameters.m; sourceTree = "<group>"; };
D2D2BB5B22D502740015D032 /* WidgetsManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WidgetsManager.h; sourceTree = "<group>"; };
D2D2BB5C22D502740015D032 /* WidgetsManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = WidgetsManager.m; sourceTree = "<group>"; };
D2D6D78420527651003CBEC4 /* TermDevice.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TermDevice.h; sourceTree = "<group>"; };
D2D6D78520527651003CBEC4 /* TermDevice.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TermDevice.m; sourceTree = "<group>"; };
D2D75EDE21AFDA10007336B6 /* LayoutManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LayoutManager.h; sourceTree = "<group>"; };
D2D75EDF21AFDA10007336B6 /* LayoutManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LayoutManager.m; sourceTree = "<group>"; };
D2DACEB922D4FF18006620A1 /* SceneDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SceneDelegate.h; sourceTree = "<group>"; };
D2DACEBA22D4FF18006620A1 /* SceneDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SceneDelegate.m; sourceTree = "<group>"; };
D2E4F91920B0537D00B30F7B /* Migrator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Migrator.h; sourceTree = "<group>"; };
D2E4F91A20B0537D00B30F7B /* Migrator.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Migrator.m; sourceTree = "<group>"; };
D2E4F92920B2BB4500B30F7B /* curl_ios_static.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = curl_ios_static.xcodeproj; path = ios_system/curl_ios_static.xcodeproj; sourceTree = "<group>"; };
Expand Down Expand Up @@ -784,8 +788,11 @@
D29568B821BE629100480A83 /* bk_getopts.c */,
D24D18C721D4CFB200239C9D /* KeyInput.h */,
D24D18C821D4CFB200239C9D /* KeyInput.m */,
D235579422CE03F00094AADB /* SceneDelegate.swift */,
D235579622CE07D20094AADB /* Blink-bridge.h */,
D2DACEB922D4FF18006620A1 /* SceneDelegate.h */,
D2DACEBA22D4FF18006620A1 /* SceneDelegate.m */,
D2D2BB5B22D502740015D032 /* WidgetsManager.h */,
D2D2BB5C22D502740015D032 /* WidgetsManager.m */,
);
path = Blink;
sourceTree = "<group>";
Expand Down Expand Up @@ -1684,6 +1691,7 @@
D240806120BC8DF800F30099 /* tool_main.c in Sources */,
D29619AD214FB5EA0070935A /* ssh-ed25519.c in Sources */,
B7D6A6291E2D43A800EDF7B0 /* BKSmartKeysConfigViewController.m in Sources */,
D2D2BB5D22D502740015D032 /* WidgetsManager.m in Sources */,
D239710420A07B9100881637 /* inputbuffer.cxx in Sources */,
D23AA645223EA3C40020FA77 /* BKXCallBackUrlConfigurationViewController.m in Sources */,
D2179F2D2136A5DC00B0850A /* GeoManager.m in Sources */,
Expand All @@ -1701,6 +1709,7 @@
07AA065D1E08B6EB008310B7 /* UserDefaultsPasscodeRepository.swift in Sources */,
B752EE2E1DFEF45300E305C8 /* BKSecurityConfigurationViewController.m in Sources */,
D2F330D420A6F1DF0074ADD7 /* clear.m in Sources */,
D2DACEBB22D4FF18006620A1 /* SceneDelegate.m in Sources */,
C94437571D8311960096F84E /* BKResource.m in Sources */,
07F670771D05EEE200C0A53C /* SSHSession.m in Sources */,
D29619AF214FB5EA0070935A /* ssh-ecdsa.c in Sources */,
Expand Down Expand Up @@ -1783,7 +1792,6 @@
C9B2E0341D6B612400B89F69 /* BKTheme.m in Sources */,
0716B5961CFFAB9300268B5B /* TermController.m in Sources */,
D29619A7214FA7D40070935A /* bcrypt-pbkdf.c in Sources */,
D235579522CE03F00094AADB /* SceneDelegate.swift in Sources */,
07AA06581E08B12E008310B7 /* PasscodeSignButton.swift in Sources */,
0716B5911CFFAB9300268B5B /* SpaceController.m in Sources */,
D239710520A07B9100881637 /* history.cxx in Sources */,
Expand Down
3 changes: 3 additions & 0 deletions Blink/AppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,7 @@

@property (strong, nonatomic) UIWindow *window;

- (void)startMonitoringForSuspending;
- (void)cancelApplicationSuspend;

@end
37 changes: 3 additions & 34 deletions Blink/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
#import <ios_system/ios_system.h>
#include <libssh/callbacks.h>
#include "xcall.h"
#include "Blink-swift.h"


@import CloudKit;
Expand Down Expand Up @@ -130,13 +129,8 @@ - (BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:
}

- (UISceneConfiguration *)application:(UIApplication *)application configurationForConnectingSceneSession:(UISceneSession *)connectingSceneSession options:(UISceneConnectionOptions *)options {
UISceneConfiguration *configuration = [[UISceneConfiguration alloc]
initWithName:@"main" sessionRole:connectingSceneSession.configuration.role];

configuration.delegateClass = [SceneDelegate class];
//configuration.sceneClass = [Scene class];

return configuration;
return [UISceneConfiguration configurationWithName:@"main" sessionRole:connectingSceneSession.role];
}

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
Expand Down Expand Up @@ -174,22 +168,7 @@ - (void)applicationWillTerminate:(UIApplication *)application
[self _suspendApplicationOnWillTerminate];
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
if (_suspendedMode) {
[[ScreenController shared] resume];
}

[self _cancelApplicationSuspend];
}


//- (void)applicationDidEnterBackground:(UIApplication *)application
//{
// [self _startMonitoringForSuspending];
//}

- (void)_startMonitoringForSuspending
- (void)startMonitoringForSuspending
{
if (_suspendedMode) {
return;
Expand All @@ -214,22 +193,12 @@ - (void)_startMonitoringForSuspending
repeats:NO];
}

//- (BOOL)application:(UIApplication *)application shouldSaveApplicationState:(nonnull NSCoder *)coder
//{
// return YES;
//}
//
//- (BOOL)application:(UIApplication *)application shouldRestoreApplicationState:(nonnull NSCoder *)coder
//{
// return YES;
//}

- (void) application:(UIApplication *)application didDecodeRestorableStateWithCoder:(NSCoder *)coder
{
[[ScreenController shared] finishRestoring];
}

- (void)_cancelApplicationSuspend
- (void)cancelApplicationSuspend
{
[_suspendTimer invalidate];
_suspendedMode = NO;
Expand Down
12 changes: 12 additions & 0 deletions Blink/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,18 @@
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<true/>
<key>UISceneConfigurations</key>
<dict>
<key>UIWindowSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneDelegateClassName</key>
<string>SceneDelegate</string>
<key>UISceneConfigurationName</key>
<string>main</string>
</dict>
</array>
</dict>
</dict>
<key>UIBackgroundModes</key>
<array>
Expand Down
41 changes: 41 additions & 0 deletions Blink/SceneDelegate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//////////////////////////////////////////////////////////////////////////////////
//
// B L I N K
//
// Copyright (C) 2016-2019 Blink Mobile Shell Project
//
// This file is part of Blink.
//
// Blink is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Blink is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Blink. If not, see <http://www.gnu.org/licenses/>.
//
// In addition, Blink is also subject to certain additional terms under
// GNU GPL version 3 section 7.
//
// You should have received a copy of these additional terms immediately
// following the terms and conditions of the GNU General Public License
// which accompanied the Blink Source Code. If not, see
// <http://www.github.com/blinksh/blink>.
//
////////////////////////////////////////////////////////////////////////////////


#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

@interface SceneDelegate : UIResponder<UIWindowSceneDelegate>

@end

NS_ASSUME_NONNULL_END
63 changes: 31 additions & 32 deletions Blink/SceneDelegate.swift → Blink/SceneDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,41 +30,40 @@
////////////////////////////////////////////////////////////////////////////////


import UIKit
#import "SceneDelegate.h"
#import "SpaceController.h"
#import "AppDelegate.h"

open class SceneDelegate: UIResponder, UIWindowSceneDelegate {
public var window: UIWindow? = nil
@implementation SceneDelegate {
UIWindow *_window;
}

public func scene(
_ scene: UIScene,
willConnectTo session: UISceneSession,
options connectionOptions: UIScene.ConnectionOptions) {

guard
let windowScene = scene as? UIWindowScene else {
return
}

let activity = session.stateRestorationActivity

let ctrl = SpaceController()
ctrl.restorationIdentifier = "SpaceController"
window = UIWindow(windowScene: windowScene)
window?.rootViewController = ctrl
window?.makeKeyAndVisible()
}
- (void)scene:(UIScene *)scene
willConnectToSession:(UISceneSession *)session
options:(UISceneConnectionOptions *)connectionOptions {

open override func restoreUserActivityState(_ activity: NSUserActivity) {

}
UIWindowScene *winScene = (UIWindowScene *)scene;

open override func updateUserActivityState(_ activity: NSUserActivity) {

}
UIWindow *window = [[UIWindow alloc] initWithWindowScene:winScene];
window.rootViewController = [[SpaceController alloc] init];
[window makeKeyAndVisible];
_window = window;
}

- (void)sceneDidEnterBackground:(UIScene *)scene {
AppDelegate *appDelegate = (AppDelegate *)UIApplication.sharedApplication.delegate;

// TODO: check if we are last active scene here
[appDelegate startMonitoringForSuspending];
}

- (void)sceneWillEnterForeground:(UIScene *)scene {

public func stateRestorationActivity(for scene: UIScene) -> NSUserActivity? {
// return scene.userActivity
let activity = NSUserActivity(activityType: "BlinkStateRestoration")
return activity
}
}


- (NSUserActivity *)stateRestorationActivityForScene:(UIScene *)scene {
return [[NSUserActivity alloc] initWithActivityType:@"state.restoration.activity"];
}

@end
6 changes: 5 additions & 1 deletion Blink/SpaceController.m
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,8 @@ - (void)removeCurrentSpace {
return;
}

[[WidgetsManager shared] unRegisterWidget:self.currentTerm];

NSInteger numViewports = [_viewports count];

__weak typeof(self) weakSelf = self;
Expand Down Expand Up @@ -565,7 +567,9 @@ - (void)_createShellWithUserActivity:(NSUserActivity *) userActivity
animated:(BOOL)animated
completion:(void (^)(BOOL finished))completion
{
TermController *term = [[TermController alloc] init];
TermController *term = [[TermController alloc] initWithWidgetID:sessionStateKey];
[[WidgetsManager shared] registerWidget:term];

term.sessionStateKey = sessionStateKey;
term.delegate = self;
term.userActivity = userActivity;
Expand Down
6 changes: 5 additions & 1 deletion Blink/TermController.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#import "TermDevice.h"
#import "MCPSessionParameters.h"
#import "StateManager.h"
#import "WidgetsManager.h"

extern NSString * const BKUserActivityTypeCommandLine;
extern NSString * const BKUserActivityCommandLineKey;
Expand All @@ -48,14 +49,17 @@ extern NSString * const BKUserActivityCommandLineKey;

@end

@interface TermController : UIViewController<SecureRestoration>
@interface TermController : UIViewController<SecureRestoration, WidgetProtocol>

@property (readonly, strong, nonatomic) TermDevice *termDevice;
@property (weak) id<TermControlDelegate> delegate;
@property (strong, nonatomic) NSString* activityKey;
@property (strong) NSString* sessionStateKey;
@property (strong) MCPSessionParameters *sessionParameters;
@property (strong, nonatomic) UIColor *bgColor;

- (instancetype)initWithWidgetID:(NSString *)widgetID;

- (void)lockLayout;
- (void)unlockLayout;
- (void)terminate;
Expand Down
12 changes: 11 additions & 1 deletion Blink/TermController.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
NSString * const BKUserActivityCommandLineKey = @"com.blink.cmdline.key";


@interface TermController () <SessionDelegate, TermDeviceDelegate>
@interface TermController () <SessionDelegate, TermDeviceDelegate, WidgetProtocol>
@end

@implementation TermController {
Expand All @@ -54,6 +54,16 @@ @implementation TermController {
TermView *_termView;
}

@synthesize widgetID;

- (instancetype)initWithWidgetID:(NSString *)widgetID {
self = [super init];
if (self) {
self.widgetID = widgetID ?: [NSProcessInfo.processInfo globallyUniqueString];
}
return self;
}

- (void)loadView
{
[super loadView];
Expand Down
Loading

0 comments on commit abeda6d

Please sign in to comment.