Skip to content

Commit

Permalink
Cordova project diff
Browse files Browse the repository at this point in the history
This commit shows the edits we make to the standard Cordova project.
We obtain the diff by reversing the rsync call.
  • Loading branch information
fortuna committed Dec 15, 2022
1 parent 08f6c37 commit a9318f5
Show file tree
Hide file tree
Showing 10 changed files with 344 additions and 1,383 deletions.
504 changes: 94 additions & 410 deletions src/cordova/apple/xcode/ios/Outline.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

49 changes: 16 additions & 33 deletions src/cordova/apple/xcode/ios/Outline/Outline-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,70 +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>CFBundleShortVersionString</key>
<string>1.9.0</string>
<key>CFBundleVersion</key>
<string>35</string>
<key>CFBundleDevelopmentRegion</key>
<string>English</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>1.9.0</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>1.9.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<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>
707 changes: 104 additions & 603 deletions src/cordova/apple/xcode/macos/Outline.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

205 changes: 36 additions & 169 deletions src/cordova/apple/xcode/macos/Outline/Classes/AppDelegate.m
Original file line number Diff line number Diff line change
@@ -1,190 +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;

@interface AppDelegate()
@property (strong, nonatomic) NSStatusItem *statusItem;
@property (strong, nonatomic) NSPopover *popover;
@property (strong, nonatomic) EventMonitor *eventMonitor;
@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:OutlinePlugin.kVpnConnectedNotification
object:nil
queue:nil
usingBlock:^(NSNotification * _Nonnull note) {
[self setAppIcon:@"StatusBarButtonImageConnected"];
}];
[NSNotificationCenter.defaultCenter addObserverForName:OutlinePlugin.kVpnDisconnectedNotification
object:nil
queue:nil
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:CDVMacOsUrlHandler.kCDVHandleOpenURLNotification 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.contentViewController = [[NSViewController alloc] initWithNibName:@"MainViewController"
bundle:[NSBundle mainBundle]];
self.popover.contentViewController.view = self.window.contentView;
// Monitor clicks outside the popover in order to close it.
NSEventMask eventMask = NSEventMaskLeftMouseDown|NSEventMaskRightMouseDown;
self.eventMonitor = [[EventMonitor alloc] initWithMask:eventMask handler:^(NSEvent* event) {
if (self.popover.isShown) {
[self closePopover];
}
}];
- (void) applicationDidFinishLaunching:(NSNotification*)aNotification
{

if ([self wasStartedByLauncherApp]) {
[OutlineVpn.shared startLastSuccessfulTunnel:^(enum ErrorCode errorCode) {
if (errorCode != ErrorCodeNoError) {
NSLog(@"Failed to auto-connect the VPN on startup.");
}
}];
} else {
[self showPopover];
}
[self setAppLauncherEnabled:true]; // Enable app launcher to start on boot.
}

- (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:OutlinePlugin.kAppQuitNotification
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];
}
}

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

- (void)showPopover {
[self.popover showRelativeToRect:self.statusItem.button.bounds
ofView:self.statusItem.button
preferredEdge:NSRectEdgeMinY];
[self.eventMonitor start];
// 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;
}

#pragma mark - Launcher

// Enables or disables the embedded app launcher as a login item.
- (void)setAppLauncherEnabled:(bool)enabled {
NSString *launcherBundleId = [self getLauncherBundleId];
if (launcherBundleId == nil) {
return;
}
if (!SMLoginItemSetEnabled((__bridge CFStringRef) launcherBundleId, enabled)) {
return NSLog(@"Failed to %@ launcher %@", enabled ? @"enable" : @"disable", launcherBundleId);
}
}

// Returns the embedded launcher application's bundle ID.
- (NSString *)getLauncherBundleId {
static NSString *kAppLauncherName = @"launcher";
NSString *bundleId = NSBundle.mainBundle.bundleIdentifier;
if (bundleId == nil) {
NSLog(@"Failed to retrieve the application's bundle ID");
return nil;
}
return [[NSString alloc] initWithFormat:@"%@.%@", bundleId, kAppLauncherName];
}

// Returns whether the app was started by the embedded launcher app by inspecting the launch event.
- (bool)wasStartedByLauncherApp {
NSAppleEventDescriptor *descriptor = [[NSAppleEventManager sharedAppleEventManager]
currentAppleEvent];
if (descriptor == nil) {
return false;
}
NSAppleEventDescriptor *launcherDescriptor = [descriptor paramDescriptorForKeyword:keyAEPropData];
if (launcherDescriptor == nil) {
return false;
}
NSString *launcherBundleId = [self getLauncherBundleId];
if (launcherBundleId == nil) {
return false;
[self.window makeKeyAndOrderFront:self];
}
return [launcherBundleId isEqual:launcherDescriptor.stringValue];
return YES;
}

@end
Loading

0 comments on commit a9318f5

Please sign in to comment.