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() {
// 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.")
getADSettings()
}
......
......@@ -21,7 +21,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>RC2</string>
<string>RC3</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key>
......
......@@ -176,9 +176,10 @@ class LoginWindow: NSWindowController, NSWindowDelegate {
myLogger.logit(LogLevel.debug, message:"Lets try to sync the passwords, prompting user.")
let alertController = NSAlert()
// TODO: replace with localized text
alertController.messageText = "Your network and local passwords are not the same. Please enter the password for your Mac."
alertController.addButton(withTitle: "Cancel")
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: "Sync")
alertController.addButton(withTitle: "Cancel")
//alertController.addButton(withTitle: "Sync")
let localPassword = NSSecureTextField(frame: CGRect(x: 0, y: 0, width: 200, height: 24))
alertController.accessoryView = localPassword
......@@ -192,7 +193,7 @@ class LoginWindow: NSWindowController, NSWindowDelegate {
alertController.beginSheetModal(for: self.window!, completionHandler: { [unowned self] (returnCode) -> Void in
myLogger.logit(LogLevel.debug, message: "Sheet Modal completed")
if ( returnCode == NSAlertSecondButtonReturn ) {
if ( returnCode == NSAlertFirstButtonReturn ) {
let currentLocalPassword = localPassword.stringValue
let newPassword = self.Password.stringValue
let localPasswordIsCorrect = noMADUser.checkCurrentConsoleUserPassword(currentLocalPassword)
......@@ -233,6 +234,7 @@ class LoginWindow: NSWindowController, NSWindowDelegate {
myLogger.logit(LogLevel.base, message: "Error changing keychain password")
myError = "Could not change your local keychain password."
}
self.close()
} else {
myLogger.logit(.base, message:"Local sync cancelled by user.")
}
......
......@@ -56,9 +56,9 @@ class NoMADMenuController: NSObject, LoginWindowDelegate, PasswordChangeDelegate
let NoMADMenuHome = NSMenuItem()
// menu bar icons
let iconOnOn = NSImage(named: "NoMAD-statusicon-on-on")
let iconOnOff = NSImage(named: "NoMAD-statusicon-on-off")
let iconOffOff = NSImage(named: "NoMAD-statusicon-off-off")
var iconOnOn = NSImage(named: "NoMAD-statusicon-on-on")
var iconOnOff = NSImage(named: "NoMAD-statusicon-on-off")
var iconOffOff = NSImage(named: "NoMAD-statusicon-off-off")
// for delegates
let preferencesWindow = PreferencesWindow()
......@@ -88,12 +88,36 @@ class NoMADMenuController: NSObject, LoginWindowDelegate, PasswordChangeDelegate
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")!)
defaults.register(defaults: defaultPreferences as! [String : Any])
// Register for update notifications.
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()
loginWindow.delegate = self
......@@ -115,8 +139,8 @@ class NoMADMenuController: NSObject, LoginWindowDelegate, PasswordChangeDelegate
if let discoveredService = SelfServiceManager().discoverSelfService() {
selfService = discoveredService
} else {
NoMADMenuGetSoftware.isHidden = true
myLogger.logit(.info, message:"Not using Self Service.")
NoMADMenuGetSoftware.isHidden = true
myLogger.logit(.info, message:"Not using Self Service.")
}
// see if we should auto-configure
......@@ -299,19 +323,19 @@ class NoMADMenuController: NSObject, LoginWindowDelegate, PasswordChangeDelegate
caTestWait = false
}
)
while caTestWait {
RunLoop.current.run(mode: RunLoopMode.defaultRunLoopMode, before: Date.distantFuture)
}
if !caSSLTest {
let certAlertController = NSAlert()
certAlertController.messageText = "Connetion error. Please ensure SSL certificates are trusted and URL is correct for your X509 CA."
certAlertController.runModal()
let certAlertController = NSAlert()
certAlertController.messageText = "Connetion error. Please ensure SSL certificates are trusted and URL is correct for your X509 CA."
certAlertController.runModal()
} else {
let certCARequest = WindowsCATools(serverURL: certCATest, template: certTemplateTest)
certCARequest.certEnrollment()
let certCARequest = WindowsCATools(serverURL: certCATest, template: certTemplateTest)
certCARequest.certEnrollment()
}
} else {
......@@ -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
func startMenuAnimationTimer() {
menuAnimationTimer = Timer(timeInterval: 1, target: self, selector: #selector(animateMenuItem), userInfo: nil, repeats: true)
......@@ -760,10 +815,10 @@ class NoMADMenuController: NSObject, LoginWindowDelegate, PasswordChangeDelegate
} else {
defaults.set(Double(defaults.integer(forKey: Preferences.passwordExpireAlertTime) ?? 1296000), forKey: Preferences.lastPasswordWarning)
}
// remove the Get Certificate menu if not needed
// add it back in when it is needed
if defaults.string(forKey: Preferences.x509CA) == "" && self.NoMADMenuGetCertificate != nil {
self.NoMADMenu.removeItem(self.NoMADMenuGetCertificate)
self.NoMADMenu.removeItem(self.NoMADMenuGetCertificateDate)
......
......@@ -95,6 +95,7 @@ enum Preferences {
static let aDDomain = "ADDomain"
static let autoConfigure = "AutoConfigure"
static let changePasswordType = "ChangePasswordType"
static let caribouTime = "CaribouTime"
static let displayName = "DisplayName"
static let exportableKey = "ExportableKey"
static let getHelpType = "GetHelpType"
......@@ -110,6 +111,7 @@ enum Preferences {
static let lastUser = "LastUser"
static let lastPasswordWarning = "LastPasswordWarning"
static let lastPasswordExpireDate = "LastPasswordExpireDate"
static let messageLocalSync = "MessageLocalSync"
static let passwordExpireAlertTime = "PasswordExpireAlertTime"
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