Commit 88d809e7 authored by Joel Rennich's avatar Joel Rennich

Merge branch 'Dark-Mode' into 'Experimental'

Dark mode, password sync and other things

See merge request !41
parents d348822c b1a58bb1
{
"images" : [
{
"idiom" : "universal",
"filename" : "NoMAD RudolphArtboard 116.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "NoMAD RudolphArtboard 124.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "NoMAD RudolphArtboard 132.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "NoMAD RudolphArtboard 116.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "NoMAD RudolphArtboard 124.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "NoMAD RudolphArtboard 132.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "NoMADArtboard 116.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "NoMADArtboard 124.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "NoMADArtboard 132.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "NoMADArtboard 116.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "NoMADArtboard 124.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "NoMADArtboard 132.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "NoMAD-LogoAlternate No Check 16.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "NoMAD-LogoAlternate No Check 24.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "NoMAD-LogoAlternate No Check 32.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "NoMAD-LogoAlternate 16.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "NoMAD-LogoAlternate 24.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "NoMAD-LogoAlternate 32.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
...@@ -49,7 +49,7 @@ public func setDefaults() { ...@@ -49,7 +49,7 @@ public func setDefaults() {
// if no defaults are set for ADDomain look to see if we're bound and use that // if no defaults are set for ADDomain look to see if we're bound and use that
if defaults.string(forKey: Preferences.aDDomain) != "" { if defaults.string(forKey: Preferences.aDDomain) == "" {
myLogger.logit(.info, message: "No AD Domain set, determining if the machine is bound.") myLogger.logit(.info, message: "No AD Domain set, determining if the machine is bound.")
getADSettings() getADSettings()
} }
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>RC2</string> <string>RC3</string>
<key>LSApplicationCategoryType</key> <key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string> <string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key> <key>LSMinimumSystemVersion</key>
......
...@@ -176,9 +176,10 @@ class LoginWindow: NSWindowController, NSWindowDelegate { ...@@ -176,9 +176,10 @@ class LoginWindow: NSWindowController, NSWindowDelegate {
myLogger.logit(LogLevel.debug, message:"Lets try to sync the passwords, prompting user.") myLogger.logit(LogLevel.debug, message:"Lets try to sync the passwords, prompting user.")
let alertController = NSAlert() let alertController = NSAlert()
// TODO: replace with localized text // TODO: replace with localized text
alertController.messageText = "Your network and local passwords are not the same. Please enter the password for your Mac." alertController.messageText = (defaults.string(forKey: Preferences.messageLocalSync) ?? "Your network and local passwords are not the same. Please enter the password for your Mac.")
alertController.addButton(withTitle: "Cancel")
alertController.addButton(withTitle: "Sync") alertController.addButton(withTitle: "Sync")
alertController.addButton(withTitle: "Cancel")
//alertController.addButton(withTitle: "Sync")
let localPassword = NSSecureTextField(frame: CGRect(x: 0, y: 0, width: 200, height: 24)) let localPassword = NSSecureTextField(frame: CGRect(x: 0, y: 0, width: 200, height: 24))
alertController.accessoryView = localPassword alertController.accessoryView = localPassword
...@@ -192,7 +193,7 @@ class LoginWindow: NSWindowController, NSWindowDelegate { ...@@ -192,7 +193,7 @@ class LoginWindow: NSWindowController, NSWindowDelegate {
alertController.beginSheetModal(for: self.window!, completionHandler: { [unowned self] (returnCode) -> Void in alertController.beginSheetModal(for: self.window!, completionHandler: { [unowned self] (returnCode) -> Void in
myLogger.logit(LogLevel.debug, message: "Sheet Modal completed") myLogger.logit(LogLevel.debug, message: "Sheet Modal completed")
if ( returnCode == NSAlertSecondButtonReturn ) { if ( returnCode == NSAlertFirstButtonReturn ) {
let currentLocalPassword = localPassword.stringValue let currentLocalPassword = localPassword.stringValue
let newPassword = self.Password.stringValue let newPassword = self.Password.stringValue
let localPasswordIsCorrect = noMADUser.checkCurrentConsoleUserPassword(currentLocalPassword) let localPasswordIsCorrect = noMADUser.checkCurrentConsoleUserPassword(currentLocalPassword)
...@@ -233,6 +234,7 @@ class LoginWindow: NSWindowController, NSWindowDelegate { ...@@ -233,6 +234,7 @@ class LoginWindow: NSWindowController, NSWindowDelegate {
myLogger.logit(LogLevel.base, message: "Error changing keychain password") myLogger.logit(LogLevel.base, message: "Error changing keychain password")
myError = "Could not change your local keychain password." myError = "Could not change your local keychain password."
} }
self.close()
} else { } else {
myLogger.logit(.base, message:"Local sync cancelled by user.") myLogger.logit(.base, message:"Local sync cancelled by user.")
} }
......
...@@ -56,9 +56,9 @@ class NoMADMenuController: NSObject, LoginWindowDelegate, PasswordChangeDelegate ...@@ -56,9 +56,9 @@ class NoMADMenuController: NSObject, LoginWindowDelegate, PasswordChangeDelegate
let NoMADMenuHome = NSMenuItem() let NoMADMenuHome = NSMenuItem()
// menu bar icons // menu bar icons
let iconOnOn = NSImage(named: "NoMAD-statusicon-on-on") var iconOnOn = NSImage(named: "NoMAD-statusicon-on-on")
let iconOnOff = NSImage(named: "NoMAD-statusicon-on-off") var iconOnOff = NSImage(named: "NoMAD-statusicon-on-off")
let iconOffOff = NSImage(named: "NoMAD-statusicon-off-off") var iconOffOff = NSImage(named: "NoMAD-statusicon-off-off")
// for delegates // for delegates
let preferencesWindow = PreferencesWindow() let preferencesWindow = PreferencesWindow()
...@@ -88,12 +88,36 @@ class NoMADMenuController: NSObject, LoginWindowDelegate, PasswordChangeDelegate ...@@ -88,12 +88,36 @@ class NoMADMenuController: NSObject, LoginWindowDelegate, PasswordChangeDelegate
myLogger.logit(.base, message:"---Starting NoMAD---") myLogger.logit(.base, message:"---Starting NoMAD---")
// check for Dark Mode
if UserDefaults.standard.persistentDomain(forName: UserDefaults.globalDomain)?["AppleInterfaceStyle"] == nil {
if !defaults.bool(forKey: Preferences.caribouTime) {
iconOnOn = NSImage(named: "NoMAD-statusicon-on-on")
iconOnOff = NSImage(named: "NoMAD-statusicon-on-off")
iconOffOff = NSImage(named: "NoMAD-statusicon-off-off")
} else {
iconOnOn = NSImage(named: "NoMAD-Caribou-on")
iconOffOff = NSImage(named: "NoMAD-Caribou-off")
}
} else {
if !defaults.bool(forKey: Preferences.caribouTime) {
iconOnOn = NSImage(named: "NoMAD-LogoAlternate-on")
//iconOnOff = NSImage(named: "NoMAD-statusicon-on-off")
iconOffOff = NSImage(named: "NoMAD-LogoAlternate-off")
} else {
iconOnOn = NSImage(named: "NoMAD-Caribou-dark-on")
iconOffOff = NSImage(named: "NoMAD-Caribou-dark-off")
}
}
let defaultPreferences = NSDictionary(contentsOf: Bundle.main.url(forResource: "DefaultPreferences", withExtension: "plist")!) let defaultPreferences = NSDictionary(contentsOf: Bundle.main.url(forResource: "DefaultPreferences", withExtension: "plist")!)
defaults.register(defaults: defaultPreferences as! [String : Any]) defaults.register(defaults: defaultPreferences as! [String : Any])
// Register for update notifications. // Register for update notifications.
NotificationCenter.default.addObserver(self, selector: #selector(doTheNeedfull), name: NSNotification.Name(rawValue: "updateNow"), object: nil) NotificationCenter.default.addObserver(self, selector: #selector(doTheNeedfull), name: NSNotification.Name(rawValue: "updateNow"), object: nil)
DistributedNotificationCenter.default.addObserver(self, selector: #selector(interfaceModeChanged), name: NSNotification.Name(rawValue: "AppleInterfaceThemeChangedNotification"), object: nil)
startMenuAnimationTimer() startMenuAnimationTimer()
loginWindow.delegate = self loginWindow.delegate = self
...@@ -115,8 +139,8 @@ class NoMADMenuController: NSObject, LoginWindowDelegate, PasswordChangeDelegate ...@@ -115,8 +139,8 @@ class NoMADMenuController: NSObject, LoginWindowDelegate, PasswordChangeDelegate
if let discoveredService = SelfServiceManager().discoverSelfService() { if let discoveredService = SelfServiceManager().discoverSelfService() {
selfService = discoveredService selfService = discoveredService
} else { } else {
NoMADMenuGetSoftware.isHidden = true NoMADMenuGetSoftware.isHidden = true
myLogger.logit(.info, message:"Not using Self Service.") myLogger.logit(.info, message:"Not using Self Service.")
} }
// see if we should auto-configure // see if we should auto-configure
...@@ -299,19 +323,19 @@ class NoMADMenuController: NSObject, LoginWindowDelegate, PasswordChangeDelegate ...@@ -299,19 +323,19 @@ class NoMADMenuController: NSObject, LoginWindowDelegate, PasswordChangeDelegate
caTestWait = false caTestWait = false
} }
) )
while caTestWait { while caTestWait {
RunLoop.current.run(mode: RunLoopMode.defaultRunLoopMode, before: Date.distantFuture) RunLoop.current.run(mode: RunLoopMode.defaultRunLoopMode, before: Date.distantFuture)
} }
if !caSSLTest { if !caSSLTest {
let certAlertController = NSAlert() let certAlertController = NSAlert()
certAlertController.messageText = "Connetion error. Please ensure SSL certificates are trusted and URL is correct for your X509 CA." certAlertController.messageText = "Connetion error. Please ensure SSL certificates are trusted and URL is correct for your X509 CA."
certAlertController.runModal() certAlertController.runModal()
} else { } else {
let certCARequest = WindowsCATools(serverURL: certCATest, template: certTemplateTest) let certCARequest = WindowsCATools(serverURL: certCATest, template: certTemplateTest)
certCARequest.certEnrollment() certCARequest.certEnrollment()
} }
} else { } else {
...@@ -539,6 +563,37 @@ class NoMADMenuController: NSObject, LoginWindowDelegate, PasswordChangeDelegate ...@@ -539,6 +563,37 @@ class NoMADMenuController: NSObject, LoginWindowDelegate, PasswordChangeDelegate
} }
} }
// change the menu item if it's dark
func interfaceModeChanged() {
if UserDefaults.standard.persistentDomain(forName: UserDefaults.globalDomain)?["AppleInterfaceStyle"] == nil {
if !defaults.bool(forKey: Preferences.caribouTime) {
iconOnOn = NSImage(named: "NoMAD-statusicon-on-on")
iconOnOff = NSImage(named: "NoMAD-statusicon-on-off")
iconOffOff = NSImage(named: "NoMAD-statusicon-off-off")
} else {
iconOnOn = NSImage(named: "NoMAD-Caribou-on")
iconOffOff = NSImage(named: "NoMAD-Caribou-off")
}
} else {
if !defaults.bool(forKey: Preferences.caribouTime) {
iconOnOn = NSImage(named: "NoMAD-LogoAlternate-on")
//iconOnOff = NSImage(named: "NoMAD-statusicon-on-off")
iconOffOff = NSImage(named: "NoMAD-LogoAlternate-off")
} else {
iconOnOn = NSImage(named: "NoMAD-Caribou-dark-on")
iconOffOff = NSImage(named: "NoMAD-Caribou-dark-off")
}
}
if self.userInformation.status == "Connected" {
self.statusItem.image = self.iconOnOff
} else if self.userInformation.status == "Logged In" && self.userInformation.myLDAPServers.tickets.state {
self.statusItem.image = self.iconOnOn
} else {
self.statusItem.image = self.iconOffOff
}
}
// function to start the menu throbbing // function to start the menu throbbing
func startMenuAnimationTimer() { func startMenuAnimationTimer() {
menuAnimationTimer = Timer(timeInterval: 1, target: self, selector: #selector(animateMenuItem), userInfo: nil, repeats: true) menuAnimationTimer = Timer(timeInterval: 1, target: self, selector: #selector(animateMenuItem), userInfo: nil, repeats: true)
...@@ -760,10 +815,10 @@ class NoMADMenuController: NSObject, LoginWindowDelegate, PasswordChangeDelegate ...@@ -760,10 +815,10 @@ class NoMADMenuController: NSObject, LoginWindowDelegate, PasswordChangeDelegate
} else { } else {
defaults.set(Double(defaults.integer(forKey: Preferences.passwordExpireAlertTime) ?? 1296000), forKey: Preferences.lastPasswordWarning) defaults.set(Double(defaults.integer(forKey: Preferences.passwordExpireAlertTime) ?? 1296000), forKey: Preferences.lastPasswordWarning)
} }
// remove the Get Certificate menu if not needed // remove the Get Certificate menu if not needed
// add it back in when it is needed // add it back in when it is needed
if defaults.string(forKey: Preferences.x509CA) == "" && self.NoMADMenuGetCertificate != nil { if defaults.string(forKey: Preferences.x509CA) == "" && self.NoMADMenuGetCertificate != nil {
self.NoMADMenu.removeItem(self.NoMADMenuGetCertificate) self.NoMADMenu.removeItem(self.NoMADMenuGetCertificate)
self.NoMADMenu.removeItem(self.NoMADMenuGetCertificateDate) self.NoMADMenu.removeItem(self.NoMADMenuGetCertificateDate)
......
...@@ -95,6 +95,7 @@ enum Preferences { ...@@ -95,6 +95,7 @@ enum Preferences {
static let aDDomain = "ADDomain" static let aDDomain = "ADDomain"
static let autoConfigure = "AutoConfigure" static let autoConfigure = "AutoConfigure"
static let changePasswordType = "ChangePasswordType" static let changePasswordType = "ChangePasswordType"
static let caribouTime = "CaribouTime"
static let displayName = "DisplayName" static let displayName = "DisplayName"
static let exportableKey = "ExportableKey" static let exportableKey = "ExportableKey"
static let getHelpType = "GetHelpType" static let getHelpType = "GetHelpType"
...@@ -110,6 +111,7 @@ enum Preferences { ...@@ -110,6 +111,7 @@ enum Preferences {
static let lastUser = "LastUser" static let lastUser = "LastUser"
static let lastPasswordWarning = "LastPasswordWarning" static let lastPasswordWarning = "LastPasswordWarning"
static let lastPasswordExpireDate = "LastPasswordExpireDate" static let lastPasswordExpireDate = "LastPasswordExpireDate"
static let messageLocalSync = "MessageLocalSync"
static let passwordExpireAlertTime = "PasswordExpireAlertTime" static let passwordExpireAlertTime = "PasswordExpireAlertTime"
static let passwordChangeOptions = "PasswordChangeOptions" static let passwordChangeOptions = "PasswordChangeOptions"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment