Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DO NOT MERGE] This is what we rsync into the Apple Cordova project in 2024 #2120

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
787 changes: 57 additions & 730 deletions client/src/cordova/apple/xcode/ios/Outline.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 13 additions & 36 deletions client/src/cordova/apple/xcode/ios/Outline/Outline-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,76 +2,53 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleAllowMixedLocalizations</key>
<true/>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<string>en_US</string>
<key>CFBundleDisplayName</key>
<string>Outline</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIcons</key>
<dict/>
<key>CFBundleIcons~ipad</key>
<dict/>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.0.0-debug</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>ss</string>
<string>ssconf</string>
</array>
</dict>
</array>
<key>CFBundleVersion</key>
<string>0</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<string>0.0.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>LSUIElement</key>
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>NSMainNibFile</key>
<string></string>
<string/>
<key>NSMainNibFile~ipad</key>
<string></string>
<string/>
<key>UILaunchStoryboardName</key>
<string>CDVLaunchScreen</string>
<key>UIRequiresFullScreen</key>
<true/>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
</dict>
</plist>
</plist>

Large diffs are not rendered by default.

162 changes: 36 additions & 126 deletions client/src/cordova/apple/xcode/macos/Outline/Classes/AppDelegate.m
Original file line number Diff line number Diff line change
@@ -1,147 +1,57 @@
// Copyright 2018 The Outline Authors
//
// 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
//
// 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.
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you 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

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 "AppDelegate.h"
#import "Outline-Swift.h"

@import ServiceManagement;
@import OutlineNotification;
@import CocoaLumberjack;

#ifdef DEBUG
const DDLogLevel ddLogLevel = DDLogLevelDebug;
#else
const DDLogLevel ddLogLevel = DDLogLevelInfo;
#endif

@interface AppDelegate()
@property (strong, nonatomic) NSStatusItem *statusItem;
@property (strong, nonatomic) NSPopover *popover;
@property bool isSystemShuttingDown;
@end
#import "MainViewController.h"

@implementation AppDelegate

@synthesize window;

- (id)init {
self = [super init];
return self;
}

#pragma mark - Lifecycle
@synthesize window;

- (void)applicationDidStartLaunching:(NSNotification*)aNotification {
- (id)init
{
self = [super init];
return self;
}

- (void)applicationWillFinishLaunching:(NSNotification *)aNotification {
[[NSAppleEventManager sharedAppleEventManager]
setEventHandler:self
andSelector:@selector(handleURLEvent:withReplyEvent:)
forEventClass:kInternetEventClass
andEventID:kAEGetURL];
// Don't ever show the default Cordova window, as we will display its content view in a popover.
[self.window close];

[NSWorkspace.sharedWorkspace.notificationCenter
addObserverForName:NSWorkspaceWillPowerOffNotification
object:nil
queue:nil
usingBlock:^(NSNotification *_Nonnull n) {
self.isSystemShuttingDown = YES;
}];
[NSNotificationCenter.defaultCenter addObserverForName:NSNotification.kVpnConnected
object:nil
queue:[NSOperationQueue mainQueue]
usingBlock:^(NSNotification * _Nonnull note) {
[self setAppIcon:@"StatusBarButtonImageConnected"];
}];
[NSNotificationCenter.defaultCenter addObserverForName:NSNotification.kVpnDisconnected
object:nil
queue:[NSOperationQueue mainQueue]
usingBlock:^(NSNotification * _Nonnull note) {
[self setAppIcon:@"StatusBarButtonImage"];
}];
- (void) applicationDidStartLaunching:(NSNotification*) aNotification
{
}

- (void)handleURLEvent:(NSAppleEventDescriptor*)event
withReplyEvent:(NSAppleEventDescriptor*)replyEvent {
NSString *url = [[event paramDescriptorForKeyword:keyDirectObject] stringValue];
[[NSNotificationCenter defaultCenter]
postNotificationName:NSNotification.kHandleUrl object:url];
if (!self.popover.isShown) {
[self showPopover];
}
- (void) applicationWillFinishLaunching:(NSNotification*)aNotification
{
}

- (void)applicationDidFinishLaunching:(NSNotification*)aNotification {
self.statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:NSSquareStatusItemLength];
self.statusItem.button.action = @selector(togglePopover);
[self setAppIcon:@"StatusBarButtonImage"];
self.popover = [[NSPopover alloc] init];
self.popover.behavior = NSPopoverBehaviorTransient;
self.popover.contentViewController = [[NSViewController alloc] initWithNibName:@"MainViewController"
bundle:[NSBundle mainBundle]];
self.popover.contentViewController.view = self.window.contentView;
- (void) applicationDidFinishLaunching:(NSNotification*)aNotification
{

// The rendering of the popover is relative to the app's status item in the status bar.
// Even though we've already created the status bar above, the popover is being created
// before the status item has been rendered in the UI. This causes the initial popover
// load to be "floating" and ends up aligned at the bottom of the screen. For this initial
// load we add a small artificial delay to prevent that from happening.
double delayInSeconds = 0.5;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
[self showPopover];
});
}

- (void)applicationWillTerminate:(NSNotification *)notification {
if (!self.isSystemShuttingDown) {
// Don't post a quit notification if the system is shutting down so the VPN is not stopped
// and it auto-connects on startup.
[[NSNotificationCenter defaultCenter] postNotificationName:NSNotification.kAppQuit
object:nil];
}
}

#pragma mark - Popover

- (void)togglePopover {
if (self.popover.isShown) {
[self closePopover];
- (BOOL)applicationShouldHandleReopen:(NSApplication *)app hasVisibleWindows:(BOOL)visibleWindows
{
if (visibleWindows) {
[self.window orderFront:self];
} else {
[self showPopover];
[self.window makeKeyAndOrderFront:self];
}
}

- (void)closePopover {
[self.popover close];
}

- (void)showPopover {
[self.popover showRelativeToRect:self.statusItem.button.bounds
ofView:self.statusItem.button
preferredEdge:NSRectEdgeMinY];
// Activate the application in order to focus the popover.
[[NSRunningApplication currentApplication]
activateWithOptions:NSApplicationActivateIgnoringOtherApps];
}

- (void)setAppIcon:(NSString *)imageName {
self.statusItem.button.image = [NSImage imageNamed:imageName];
self.statusItem.button.image.template = YES;
return YES;
}

@end
Loading
Loading