Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
twocanoes committed Dec 12, 2023
1 parent 2181442 commit a5aca79
Show file tree
Hide file tree
Showing 13 changed files with 150 additions and 36 deletions.
2 changes: 1 addition & 1 deletion XCreds/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, DSQueryable {

mainController = MainController.init()
mainController?.run()
mainMenu.statusBarItem.menu = mainMenu.mainMenu
sharedMainMenu.statusBarItem.menu = sharedMainMenu.mainMenu

}

Expand Down
19 changes: 19 additions & 0 deletions XCreds/DesktopLoginWindowController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// DesktopLoginWindow.swift
// XCreds
//
// Created by Timothy Perfitt on 12/11/23.
//

import Cocoa

class DesktopLoginWindowController: NSWindowController {
@IBOutlet var webViewController: WebViewController!

override func windowDidLoad() {
super.windowDidLoad()

// Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
}

}
17 changes: 10 additions & 7 deletions XCreds/WebView.xib → XCreds/DesktopLoginWindowController.xib
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="WebViewController" customModule="XCreds" customModuleProvider="target">
<customObject id="-2" userLabel="File's Owner" customClass="DesktopLoginWindowController" customModule="XCreds" customModuleProvider="target">
<connections>
<outlet property="refreshTitleTextField" destination="YnV-QC-aTR" id="X1r-3u-usj"/>
<outlet property="webView" destination="p1x-1L-05D" id="hJN-Xq-dh8"/>
<outlet property="window" destination="KxT-zM-Vnn" id="v4i-bY-4eE"/>
<outlet property="webViewController" destination="L0G-9E-ng8" id="0zI-ce-IjA"/>
<outlet property="window" destination="KxT-zM-Vnn" id="iFX-Nl-XcT"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
Expand All @@ -31,9 +30,6 @@
<audiovisualMediaTypes key="mediaTypesRequiringUserActionForPlayback" none="YES"/>
<wkPreferences key="preferences" javaScriptCanOpenWindowsAutomatically="NO"/>
</wkWebViewConfiguration>
<connections>
<outlet property="UIDelegate" destination="-2" id="Qhy-Dl-wsg"/>
</connections>
</wkWebView>
<textField focusRingType="none" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="YnV-QC-aTR">
<rect key="frame" x="0.0" y="562" width="628" height="50"/>
Expand All @@ -60,5 +56,12 @@
</view>
<point key="canvasLocation" x="250" y="297.5"/>
</window>
<viewController id="L0G-9E-ng8" customClass="WebViewController" customModule="XCreds" customModuleProvider="target">
<connections>
<outlet property="refreshTitleTextField" destination="YnV-QC-aTR" id="llX-y9-ZSG"/>
<outlet property="view" destination="2LH-tE-efn" id="wro-LJ-uq7"/>
<outlet property="webView" destination="p1x-1L-05D" id="d7f-o6-H5S"/>
</connections>
</viewController>
</objects>
</document>
2 changes: 1 addition & 1 deletion XCreds/MainController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class MainController: NSObject, NoMADUserSessionDelegate {
}
if let refreshToken = tokens.refreshToken, refreshToken.count>0 {
// Mark()
mainMenu.statusBarItem.button?.image=NSImage(named: "xcreds menu icon check")
sharedMainMenu.statusBarItem.button?.image=NSImage(named: "xcreds menu icon check")
}
let localAccountAndPassword = self.localAccountAndPassword()
if var localPassword=localAccountAndPassword.1{
Expand Down
19 changes: 15 additions & 4 deletions XCreds/MainMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,15 @@ import Foundation
import Cocoa

// needs to be a singleton so it doesn't get reaped
let mainMenu = MainMenu()
let sharedMainMenu = MainMenu()

class ViewController: NSViewController {
var myName: String = "ViewController"

override func loadView() {
view = NSView()
}
}

class MainMenu: NSObject, NSMenuDelegate {

Expand All @@ -18,19 +26,22 @@ class MainMenu: NSObject, NSMenuDelegate {
var menuBuilt: Date? // last time menu was built
var updateStatus = "Starting Up..."
var signedIn = false

var mainWindow:NSWindow!
var windowController: DesktopLoginWindowController!

let statusBarItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength)

// windows

var webView: WebViewController?
var webViewController: WebViewController?
var prefsWindow: PreferencesWindowController?
var aboutWindowController: AboutWindowController?

override init() {
mainMenu = NSMenu()
super.init()
buildMenu()
windowController = DesktopLoginWindowController(windowNibName: "DesktopLoginWindowController")
print(windowController)
self.statusBarItem.menu = mainMenu
self.statusBarItem.button?.image=NSImage(named: "xcreds menu icon")
mainMenu.delegate = self
Expand Down
33 changes: 22 additions & 11 deletions XCreds/MenuItems.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ class AboutMenuItem: NSMenuItem {

@objc func doAction() {

if mainMenu.aboutWindowController == nil {
mainMenu.aboutWindowController = AboutWindowController()
if sharedMainMenu.aboutWindowController == nil {
sharedMainMenu.aboutWindowController = AboutWindowController()
}
mainMenu.aboutWindowController?.window!.forceToFrontAndFocus(nil)
sharedMainMenu.aboutWindowController?.window!.forceToFrontAndFocus(nil)
NSApp.activate(ignoringOtherApps: true)


Expand Down Expand Up @@ -74,7 +74,7 @@ class SignInMenuItem: NSMenuItem {

override var title: String {
get {
if mainMenu.signedIn==true {
if sharedMainMenu.signedIn==true {
return "Refresh..."
}
else {
Expand All @@ -99,11 +99,22 @@ class SignInMenuItem: NSMenuItem {
@objc func doAction() {

if DefaultsOverride.standardOverride.value(forKey: PrefKeys.discoveryURL.rawValue) != nil && DefaultsOverride.standardOverride.value(forKey: PrefKeys.clientID.rawValue) != nil {
if (mainMenu.webView==nil){
mainMenu.webView = WebViewController()
}
// if (sharedMainMenu.webViewController==nil){
// windowController = DesktopLoginWindowController(windowNibName: "DesktopLoginWindowController")
//
//// sharedMainMenu.windowController=NSWindowController(windowNibName: "WebView")
//// sharedMainMenu.webViewController = sharedMainMenu.windowController
//
//
// }
//
let view = sharedMainMenu.windowController.webViewController.view
sharedMainMenu.windowController.window!.contentView?.addSubview(view)
// sharedMainMenu.windowController.showWindow(self)

sharedMainMenu.windowController.window!.makeKeyAndOrderFront(self)
// mainMenu.webView?.window!.forceToFrontAndFocus(nil)
// mainMenu.webView?.loadPage()
sharedMainMenu.webViewController?.loadPage()
}
else {
if DefaultsOverride.standardOverride.bool(forKey: PrefKeys.shouldShowPreferencesOnStart.rawValue)==true{
Expand Down Expand Up @@ -133,10 +144,10 @@ class PrefsMenuItem: NSMenuItem {
}

@objc func doAction() {
if mainMenu.prefsWindow == nil {
mainMenu.prefsWindow = PreferencesWindowController()
if sharedMainMenu.prefsWindow == nil {
sharedMainMenu.prefsWindow = PreferencesWindowController()
}
mainMenu.prefsWindow?.window!.forceToFrontAndFocus(nil)
sharedMainMenu.prefsWindow?.window!.forceToFrontAndFocus(nil)
}
}
class CheckTokenMenuItem: NSMenuItem {
Expand Down
4 changes: 2 additions & 2 deletions XCreds/PreferencesWindowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ class PreferencesWindowController: NSWindowController {
let _ = keychainUtil.findAndDelete(serviceName:"xcreds",accountName:PrefKeys.refreshToken.rawValue)


mainMenu.signedIn=false
mainMenu.buildMenu()
sharedMainMenu.signedIn=false
sharedMainMenu.buildMenu()
}

}
4 changes: 2 additions & 2 deletions XCreds/ScheduleManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ class ScheduleManager {
NotifyManager.shared.sendMessage(message: "Password unchanged")
}
DispatchQueue.main.async {
mainMenu.signedIn=true
mainMenu.buildMenu()
sharedMainMenu.signedIn=true
sharedMainMenu.buildMenu()
}


Expand Down
7 changes: 3 additions & 4 deletions XCreds/WebViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,16 @@ import OIDCLite

class WebViewController: NSViewController {

// @objc override var windowNibName: NSNib.Name {
// return NSNib.Name("WebView")
// }


@IBOutlet weak var refreshTitleTextField: NSTextField?
@IBOutlet weak var webView: WKWebView!
@IBOutlet weak var cancelButton: NSButton!

var password:String?

override class func awakeFromNib() {

}
func loadPage() {
TCSLogWithMark("Clearing cookies")
webView.cleanAllCookies()
Expand Down
1 change: 1 addition & 0 deletions XCredsLoginPlugIn/LoginWindow/ControlsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ class ControlsViewController: NSViewController {
return key
}
override func awakeFromNib() {
TCSLogWithMark()
super.awakeFromNib()
let licenseState = LicenseChecker().currentLicenseState()
NSEvent.addLocalMonitorForEvents(matching: .flagsChanged, handler: commandKey(evt:))
Expand Down
12 changes: 8 additions & 4 deletions xCreds.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
7632E3A12873497C00E37923 /* LogShim.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7632E3A02873497C00E37923 /* LogShim.swift */; };
7632E3A2287357CC00E37923 /* TokenManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76EE06AB27FD1D92009E0F3A /* TokenManager.swift */; };
7632E3A32873581100E37923 /* KeychainUtil.swift in Sources */ = {isa = PBXBuildFile; fileRef = 767116B2284B045800CCD6FF /* KeychainUtil.swift */; };
76342E5A2B282653007D4F29 /* DesktopLoginWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76342E592B282653007D4F29 /* DesktopLoginWindowController.swift */; };
764D8126284BC1C300B3EE54 /* PromptForLocalPasswordWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 764D8124284BC1C300B3EE54 /* PromptForLocalPasswordWindowController.swift */; };
764D8127284BC1C300B3EE54 /* LoginPasswordWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 764D8125284BC1C300B3EE54 /* LoginPasswordWindowController.xib */; };
764D8129284BCAB100B3EE54 /* Window+Shake.swift in Sources */ = {isa = PBXBuildFile; fileRef = 764D8128284BCAB100B3EE54 /* Window+Shake.swift */; };
Expand Down Expand Up @@ -183,7 +184,7 @@
76EE06AC27FD1D92009E0F3A /* TokenManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76EE06AB27FD1D92009E0F3A /* TokenManager.swift */; };
76EE06AE27FD1DC3009E0F3A /* PrefKeys.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76EE06AD27FD1DC3009E0F3A /* PrefKeys.swift */; };
76EE06B027FD1DD8009E0F3A /* Window+ForceToFront.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76EE06AF27FD1DD8009E0F3A /* Window+ForceToFront.swift */; };
76EE06B227FD1E24009E0F3A /* WebView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 76EE06B127FD1E24009E0F3A /* WebView.xib */; };
76EE06B227FD1E24009E0F3A /* DesktopLoginWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 76EE06B127FD1E24009E0F3A /* DesktopLoginWindowController.xib */; };
76EE06B627FD1E79009E0F3A /* PreferencesWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 76EE06B527FD1E79009E0F3A /* PreferencesWindow.xib */; };
76EE06B827FD1EB7009E0F3A /* PreferencesWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76EE06B727FD1EB7009E0F3A /* PreferencesWindowController.swift */; };
76EE06C227FD1F50009E0F3A /* MainMenu.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76EE06C127FD1F50009E0F3A /* MainMenu.swift */; };
Expand Down Expand Up @@ -317,6 +318,7 @@
7632909B2876673500CF8857 /* DataExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DataExtension.swift; sourceTree = "<group>"; };
7632E39E287347C100E37923 /* XCredsKeychainAdd.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = XCredsKeychainAdd.swift; sourceTree = "<group>"; };
7632E3A02873497C00E37923 /* LogShim.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = LogShim.swift; path = Mechanisms/LogShim.swift; sourceTree = "<group>"; };
76342E592B282653007D4F29 /* DesktopLoginWindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DesktopLoginWindowController.swift; sourceTree = "<group>"; };
764D8124284BC1C300B3EE54 /* PromptForLocalPasswordWindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PromptForLocalPasswordWindowController.swift; sourceTree = "<group>"; };
764D8125284BC1C300B3EE54 /* LoginPasswordWindowController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = LoginPasswordWindowController.xib; sourceTree = "<group>"; };
764D8128284BCAB100B3EE54 /* Window+Shake.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Window+Shake.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -428,7 +430,7 @@
76EE06AB27FD1D92009E0F3A /* TokenManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TokenManager.swift; sourceTree = "<group>"; };
76EE06AD27FD1DC3009E0F3A /* PrefKeys.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrefKeys.swift; sourceTree = "<group>"; };
76EE06AF27FD1DD8009E0F3A /* Window+ForceToFront.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Window+ForceToFront.swift"; sourceTree = "<group>"; };
76EE06B127FD1E24009E0F3A /* WebView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = WebView.xib; sourceTree = "<group>"; };
76EE06B127FD1E24009E0F3A /* DesktopLoginWindowController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = DesktopLoginWindowController.xib; sourceTree = "<group>"; };
76EE06B327FD1E5F009E0F3A /* WebViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebViewController.swift; sourceTree = "<group>"; };
76EE06B527FD1E79009E0F3A /* PreferencesWindow.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = PreferencesWindow.xib; sourceTree = "<group>"; };
76EE06B727FD1EB7009E0F3A /* PreferencesWindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreferencesWindowController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -749,7 +751,8 @@
76EE06AD27FD1DC3009E0F3A /* PrefKeys.swift */,
764D8128284BCAB100B3EE54 /* Window+Shake.swift */,
767B939B2A28279E0038935E /* View+Shake.swift */,
76EE06B127FD1E24009E0F3A /* WebView.xib */,
76EE06B127FD1E24009E0F3A /* DesktopLoginWindowController.xib */,
76342E592B282653007D4F29 /* DesktopLoginWindowController.swift */,
76EE06B327FD1E5F009E0F3A /* WebViewController.swift */,
766355E4287148C1002E3867 /* Tokens.swift */,
7681FEC62A4C8BC800F91CD1 /* AboutWindow.xib */,
Expand Down Expand Up @@ -1044,7 +1047,7 @@
764D8127284BC1C300B3EE54 /* LoginPasswordWindowController.xib in Resources */,
76EE06A327FD1D01009E0F3A /* MainMenu.xib in Resources */,
76D1756A2B23C28700E64A62 /* MainLoginWindowController.xib in Resources */,
76EE06B227FD1E24009E0F3A /* WebView.xib in Resources */,
76EE06B227FD1E24009E0F3A /* DesktopLoginWindowController.xib in Resources */,
7681FEC92A4CFEA200F91CD1 /* com.twocanoes.xcreds.plist in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -1204,6 +1207,7 @@
76EE06AC27FD1D92009E0F3A /* TokenManager.swift in Sources */,
76B882B229CCFDBA00BB8186 /* NSData+HexString.m in Sources */,
76E9CE702A0DC6E30060220C /* TCSLoginWindowUtilities.m in Sources */,
76342E5A2B282653007D4F29 /* DesktopLoginWindowController.swift in Sources */,
76D7ADFE284EB18600332EBC /* NSFileManager+TCSRealHomeFolder.m in Sources */,
76EECD0428753C7F00483C66 /* String+Base64URLEncoded.swift in Sources */,
766355DC287133C7002E3867 /* WebViewController.swift in Sources */,
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,70 @@
uuid = "94C20054-8AB3-42DB-93A7-A3026166D6FC"
type = "1"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "7A8AE847-14B5-438F-99D9-897A3EE79F99"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "XCreds/Window+ForceToFront.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "15"
endingLineNumber = "15"
landmarkName = "forceToFrontAndFocus(_:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "3927DE86-D0FE-4553-A215-8756132597C9"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "XCreds/AppDelegate.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "64"
endingLineNumber = "64"
landmarkName = "screenLocked(_:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "4EDA2515-2418-4507-8683-EB3A303BA768"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "XCreds/WebViewController.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "26"
endingLineNumber = "26"
landmarkName = "loadPage()"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "11BEB74C-40AB-4C0B-91AE-282487C2B5A2"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "XCreds/MenuItems.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "111"
endingLineNumber = "111"
landmarkName = "doAction()"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>

0 comments on commit a5aca79

Please sign in to comment.