Skip to content

Commit

Permalink
About dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
Ragnar Rova committed Feb 27, 2022
1 parent 8bf05a2 commit aea759f
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 48 deletions.
23 changes: 14 additions & 9 deletions OpenConnectUI2.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
17BD60E9279A2D5000C2E4D0 /* se.rrva.OpenConnectUI2.ToolX in Embed Privileged Helper */ = {isa = PBXBuildFile; fileRef = 177882B2278A384800135919 /* se.rrva.OpenConnectUI2.ToolX */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
17C337A027A5DC09005A497D /* AboutView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17C3379F27A5DC09005A497D /* AboutView.swift */; };
17C337A227A5E344005A497D /* Updater.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17C337A127A5E344005A497D /* Updater.swift */; };
17CDB73627C943DC00147E76 /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 17BD60E3279A17B000C2E4D0 /* Info.plist */; };
17D749E7278A2A29004D43CF /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17D749E6278A2A29004D43CF /* AppDelegate.swift */; };
17D749EB278A2A2A004D43CF /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 17D749EA278A2A2A004D43CF /* Assets.xcassets */; };
17D749F6278A2AD9004D43CF /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17D749F5278A2AD9004D43CF /* main.swift */; };
Expand Down Expand Up @@ -223,8 +224,8 @@
17D749E0278A2A29004D43CF /* Frameworks */,
17D749E1278A2A29004D43CF /* Resources */,
17BD60E7279A2C7000C2E4D0 /* Embed Privileged Helper */,
171023CA27C8160D00EAC415 /* Add license to plist */,
176CF4E4279C8EDF00604C6C /* Increment Build Number */,
171023CA27C8160D00EAC415 /* ShellScript */,
);
buildRules = (
);
Expand Down Expand Up @@ -278,32 +279,36 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
17CDB73627C943DC00147E76 /* Info.plist in Resources */,
17D749EB278A2A2A004D43CF /* Assets.xcassets in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
171023CA27C8160D00EAC415 /* ShellScript */ = {
171023CA27C8160D00EAC415 /* Add license to plist */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 12;
alwaysOutOfDate = 1;
buildActionMask = 8;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
name = "Add license to plist";
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
runOnlyForDeploymentPostprocessing = 1;
shellPath = /bin/sh;
shellScript = "/usr/libexec/PlistBuddy -c \"Set :license string $(cat LICENSE)\" ${INFOPLIST_FILE}\n";
};
176CF4E4279C8EDF00604C6C /* Increment Build Number */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 8;
files = (
);
Expand All @@ -318,7 +323,7 @@
);
runOnlyForDeploymentPostprocessing = 1;
shellPath = /bin/bash;
shellScript = "agvtool next-version -all && xcrun agvtool new-marketing-version \\\"1.$(agvtool what-version | sed -n 2p |tr -d ' ')\\\"\n";
shellScript = "agvtool next-version -all ; xcrun agvtool new-marketing-version \\\"1.$(agvtool what-version | sed -n 2p |tr -d ' ')\\\"\n";
};
/* End PBXShellScriptBuildPhase section */

Expand Down Expand Up @@ -387,7 +392,7 @@
CODE_SIGN_INJECT_BASE_ENTITLEMENTS = NO;
CODE_SIGN_STYLE = Automatic;
CREATE_INFOPLIST_SECTION_IN_BINARY = YES;
CURRENT_PROJECT_VERSION = 615;
CURRENT_PROJECT_VERSION = 635;
DEVELOPMENT_TEAM = 3563RJWBQP;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = "ToolX/Info-Debug.plist";
Expand Down Expand Up @@ -420,7 +425,7 @@
CODE_SIGN_INJECT_BASE_ENTITLEMENTS = NO;
CODE_SIGN_STYLE = Automatic;
CREATE_INFOPLIST_SECTION_IN_BINARY = YES;
CURRENT_PROJECT_VERSION = 615;
CURRENT_PROJECT_VERSION = 635;
DEVELOPMENT_TEAM = 3563RJWBQP;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = ToolX/Info.plist;
Expand Down Expand Up @@ -569,7 +574,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 615;
CURRENT_PROJECT_VERSION = 635;
DEVELOPMENT_TEAM = 3563RJWBQP;
ENABLE_HARDENED_RUNTIME = YES;
GENERATE_INFOPLIST_FILE = YES;
Expand Down Expand Up @@ -602,7 +607,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 615;
CURRENT_PROJECT_VERSION = 635;
DEVELOPMENT_TEAM = 3563RJWBQP;
ENABLE_HARDENED_RUNTIME = YES;
GENERATE_INFOPLIST_FILE = YES;
Expand Down
87 changes: 57 additions & 30 deletions OpenConnectUI2/AboutView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,55 +16,82 @@ class AboutViewVisibility: ObservableObject {
struct AboutView: View {
@EnvironmentObject private var visibility: AboutViewVisibility
var body: some View {
VStack(spacing: 16) {
VStack {
if !visibility.showLicense {
AboutView2().environmentObject(visibility)
FirstAboutView().environmentObject(visibility)
}
if visibility.showLicense {
Spacer()
LicenseView().environmentObject(visibility)
Spacer()
}
}.frame(minWidth: 400, maxWidth: .infinity, minHeight: 400, maxHeight: 400)
}.frame(minWidth: 600, maxWidth: .infinity, minHeight: 400, maxHeight: 400)
}
}

struct AboutView2: View {
struct FirstAboutView: View {
@EnvironmentObject private var visibility: AboutViewVisibility

let version = String(
describing: Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion").unsafelyUnwrapped)

var body: some View {
Text(
"""
**OpenConnectUI2 version \(version)**
VStack(alignment: .center, spacing: 30) {
Spacer()
Text("OpenConnectUI2").font(.largeTitle)
HStack(alignment: .top, spacing: 20) {
VStack {
appImage().padding(10)
Text("version \(version)")
}
aboutText

A Mac OSX UI for [OpenConnect VPN client](https://www.infradead.org/openconnect/)
}
Button(action: {
visibility.showLicense = true
}) {
Text("License")

Standing on the shoulders of giants:
}
Spacer()
}

Thank you to the OpenConnect authors for the vpn client
}

OpenConnect questions:
}

[http://www.infradead.org/openconnect/mail.html](http://www.infradead.org/openconnect/mail.html)
let version = String(
describing: Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion").unsafelyUnwrapped)

Copyright © 2022 Ragnar Rova
let aboutText = Text(
"""
A Mac OSX UI for [OpenConnect VPN client](https://www.infradead.org/openconnect/)
[Source code on GitHub](https://github.com/rrva/openconnectui2)
"""
).multilineTextAlignment(.center).padding(16)
Button(action: {
visibility.showLicense = true
}) {
Text("License")
}.padding(16)
}
Standing on the shoulders of giants:
struct AboutView_Previews: PreviewProvider {
static var previews: some View {
AboutView()
}
}
Thank you to the OpenConnect authors for the vpn client!
For OpenConnect questions please go to:
[http://www.infradead.org/openconnect/mail.html](http://www.infradead.org/openconnect/mail.html)
[Source code on GitHub](https://github.com/rrva/openconnectui2)
© 2022 Ragnar Rova
"""
)

func appIconImageRep() -> NSImageRep {
let appIconPath = Bundle.main.path(forResource: "AppIcon", ofType: "icns")!
let appIcon = NSImage(contentsOfFile: appIconPath)
let images = appIcon!.representations.sorted(by: { (a: NSImageRep, b: NSImageRep) -> Bool in
return a.pixelsHigh < b.pixelsHigh
})
return images[images.endIndex - 1]

}

let bestImage = appIconImageRep()

func appImage() -> Image {
let image: NSImage = NSImage(size: bestImage.size)
image.addRepresentation(bestImage)
return Image(nsImage: image)
}
1 change: 1 addition & 0 deletions OpenConnectUI2/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
@objc func didTapConnect() {
let host = prefsView.getUserSettings().host
let adUserName = prefsView.getUserSettings().username

if adUserName == "" || host == "" {
if prefsWindowController == nil {
prefsWindowController = WindowController(hostedView: PrefsView(logger: logger))
Expand Down
4 changes: 3 additions & 1 deletion OpenConnectUI2/Info-Debug.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
<plist version="1.0">
<dict>
<key>CFBundleShortVersionString</key>
<string>"1.615"</string>
<string>"1.635"</string>
<key>CFBundleVersion</key>
<string>635</string>
<key>LSUIElement</key>
<true/>
<key>SMPrivilegedExecutables</key>
Expand Down
6 changes: 3 additions & 3 deletions OpenConnectUI2/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleIdentifier</key>
<string></string>
<key>CFBundleShortVersionString</key>
<string>"1.615"</string>
<string>"1.635"</string>
<key>CFBundleVersion</key>
<string>635</string>
<key>LSUIElement</key>
<true/>
<key>SMPrivilegedExecutables</key>
Expand Down
3 changes: 3 additions & 0 deletions OpenConnectUI2/main.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import Cocoa
import Foundation
import Network
import SwiftUI

func main() {

let app = NSApplication.shared

let authorized = DispatchSemaphore(value: 1)
Expand Down
4 changes: 2 additions & 2 deletions ToolX/Info-Debug.plist
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
<string>identifier &quot;se.rrva.OpenConnectUI2&quot; and anchor apple generic and certificate leaf[subject.CN] = &quot;Apple Development: [email protected] (U34QC433V8)&quot; and certificate 1[field.1.2.840.113635.100.6.2.1] /* exists */</string>
</array>
<key>CFBundleVersion</key>
<string>615</string>
<string>635</string>
<key>CFBundleShortVersionString</key>
<string>"1.615"</string>
<string>"1.635"</string>
</dict>
</plist>
6 changes: 3 additions & 3 deletions ToolX/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
<key>CFBundleName</key>
<string>ToolX</string>
<key>CFBundleShortVersionString</key>
<string>"1.615"</string>
<string>"1.635"</string>
<key>CFBundleVersion</key>
<string>615</string>
<string>635</string>
<key>SMAuthorizedClients</key>
<array>
<string>anchor apple generic and identifier "se.rrva.OpenConnectUI2" and (certificate leaf[field.1.2.840.113635.100.6.1.9] /* exists */ or certificate 1[field.1.2.840.113635.100.6.2.6] /* exists */ and certificate leaf[field.1.2.840.113635.100.6.1.13] /* exists */ and certificate leaf[subject.OU] = "3563RJWBQP")</string>
<string>anchor apple generic and identifier &quot;se.rrva.OpenConnectUI2&quot; and (certificate leaf[field.1.2.840.113635.100.6.1.9] /* exists */ or certificate 1[field.1.2.840.113635.100.6.2.6] /* exists */ and certificate leaf[field.1.2.840.113635.100.6.1.13] /* exists */ and certificate leaf[subject.OU] = &quot;3563RJWBQP&quot;)</string>
</array>
</dict>
</plist>

0 comments on commit aea759f

Please sign in to comment.