diff --git a/CloverApp/Clover.xcodeproj/project.pbxproj b/CloverApp/Clover.xcodeproj/project.pbxproj index b1cfb4f84..9008c795a 100644 --- a/CloverApp/Clover.xcodeproj/project.pbxproj +++ b/CloverApp/Clover.xcodeproj/project.pbxproj @@ -1309,7 +1309,7 @@ CODE_SIGN_IDENTITY = "-"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 1.21; + CURRENT_PROJECT_VERSION = 1.22; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Clover/Frameworks", @@ -1336,7 +1336,7 @@ "$(PROJECT_DIR)/Clover/Library", "$(PROJECT_DIR)", ); - MARKETING_VERSION = 1.21; + MARKETING_VERSION = 1.22; OTHER_LDFLAGS = ""; PRODUCT_BUNDLE_IDENTIFIER = org.slice.Clover; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -1357,7 +1357,7 @@ CODE_SIGN_IDENTITY = "-"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 1.21; + CURRENT_PROJECT_VERSION = 1.22; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Clover/Frameworks", @@ -1383,7 +1383,7 @@ "$(PROJECT_DIR)/Clover/Library", "$(PROJECT_DIR)", ); - MARKETING_VERSION = 1.21; + MARKETING_VERSION = 1.22; OTHER_LDFLAGS = ""; PRODUCT_BUNDLE_IDENTIFIER = org.slice.Clover; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/CloverApp/Clover/AppDelegate.swift b/CloverApp/Clover/AppDelegate.swift index 863a4def8..bd166182b 100644 --- a/CloverApp/Clover/AppDelegate.swift +++ b/CloverApp/Clover/AppDelegate.swift @@ -37,6 +37,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSPopoverDelegate { var daSession : DASession? = nil var daContext : UnsafeMutablePointer = UnsafeMutablePointer.allocate(capacity: 1) + //MARK: deinit deinit { if (self.daSession != nil) { DASessionUnscheduleFromRunLoop(self.daSession!, @@ -47,6 +48,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSPopoverDelegate { self.daContext.deallocate() } + //MARK: Applicatin Delegate func applicationDidBecomeActive(_ notification: Notification) { // print("applicationDidBecomeActive") } @@ -143,7 +145,16 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSPopoverDelegate { } CFRunLoopRun() } + + //MARK: Disks obeservation call back + @objc func reFreshDisksList() { + (self.settingsWC?.contentViewController as? SettingsViewController)?.searchDisks() + (self.settingsWC?.contentViewController as? SettingsViewController)?.searchESPDisks() + (self.installerWC?.contentViewController as? InstallerViewController)?.populateTargets() + (self.installerOutWC?.contentViewController as? InstallerOutViewController)?.populateTargets() + } + //MARK: Documents func applicationShouldOpenUntitledFile(_ sender: NSApplication) -> Bool { if !self.havefinishLaunching { if let files : NSArray = UDs.value(forKey: "Docs") as? NSArray { @@ -155,6 +166,22 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSPopoverDelegate { return false } + //MARK: Activation Policy + func setActivationPolicy() { + let documents = NSDocumentController.shared.documents + var showDock : Bool = documents.count > 1 + + if !showDock { + showDock = AppSD.installerWC != nil || AppSD.installerOutWC != nil || AppSD.themeManagerWC != nil + } + + NSApp.setActivationPolicy(showDock ? .regular : .accessory) + if showDock { + NSApp.activate(ignoringOtherApps: true) + } + } + + //MARK: Popover @objc func showPopover(_ sender: Any?) { if (self.popover == nil) { self.popover = NSPopover() @@ -178,7 +205,6 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSPopoverDelegate { self.popover?.show(relativeTo: v.bounds, of: v, preferredEdge: NSRectEdge.maxY) } } - //NSApp.activate(ignoringOtherApps: true) } } @@ -186,14 +212,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSPopoverDelegate { return true } - @objc func reFreshDisksList() { - (self.settingsWC?.contentViewController as? SettingsViewController)?.searchDisks() - (self.settingsWC?.contentViewController as? SettingsViewController)?.searchESPDisks() - (self.installerWC?.contentViewController as? InstallerViewController)?.populateTargets() - (self.installerOutWC?.contentViewController as? InstallerOutViewController)?.populateTargets() - } - - + //MARK: App termination func applicationShouldTerminate(_ sender: NSApplication) -> NSApplication.TerminateReply { return self.isInstalling ? .terminateLater : .terminateNow } diff --git a/CloverApp/Clover/Installer/Base.lproj/Installer.xib b/CloverApp/Clover/Installer/Base.lproj/Installer.xib index 490540782..9a0606a5f 100644 --- a/CloverApp/Clover/Installer/Base.lproj/Installer.xib +++ b/CloverApp/Clover/Installer/Base.lproj/Installer.xib @@ -1,8 +1,8 @@ - + - + @@ -153,17 +153,17 @@ - + - + - - + + - + @@ -182,13 +182,13 @@ - + - + - + @@ -229,7 +229,7 @@ - + @@ -245,7 +245,7 @@ - + @@ -256,7 +256,7 @@ - + diff --git a/CloverApp/Clover/Installer/Installer.swift b/CloverApp/Clover/Installer/Installer.swift index 577e148a3..fa986a8c3 100644 --- a/CloverApp/Clover/Installer/Installer.swift +++ b/CloverApp/Clover/Installer/Installer.swift @@ -33,6 +33,7 @@ final class InstallerWindowController: NSWindowController, NSWindowDelegate { self.window = nil self.close() AppSD.installerWC = nil // remove a strong reference + AppSD.setActivationPolicy() return true } @@ -570,6 +571,11 @@ final class InstallerViewController: NSViewController { } task.terminationHandler = { t in + DispatchQueue.main.async { + self.view.window?.level = .floating + self.view.window?.makeKeyAndOrderFront(nil) + self.view.window?.level = .normal + } if t.terminationStatus == 0 { if isMountPoint(path: disk) { DispatchQueue.main.async { @@ -578,24 +584,17 @@ final class InstallerViewController: NSViewController { self.setPreferences(for: self.targetVol) } } - DispatchQueue.main.async { - self.view.window?.makeKeyAndOrderFront(nil) - self.view.window?.level = .floating - self.view.window?.level = .normal - } } else { NSSound.beep() DispatchQueue.main.async { if #available(OSX 10.11, *) { self.driversCollection.reloadData() - self.view.window?.makeKeyAndOrderFront(nil) - self.view.window?.level = .floating - self.view.window?.level = .normal } } } } task.launch() + }) } else { self.targetVol = getMountPoint(from: disk) ?? "" @@ -756,9 +755,10 @@ final class InstallerViewController: NSViewController { func post(text: String, add: Bool, color: NSColor?, scroll: Bool) { //let attributes = self.infoText.textStorage?.attributes(at: 0, effectiveRange: nil) let textColor = (color == nil) ? NSColor.controlTextColor : color! - let attributes = [/*NSAttributedString.Key.font: font,*/ NSAttributedString.Key.foregroundColor: textColor] - - let astr = NSAttributedString(string: text, attributes: attributes) + let font = NSFont.userFixedPitchFont(ofSize: 11) + let attributes = [NSAttributedString.Key.font: font, NSAttributedString.Key.foregroundColor: textColor] + + let astr = NSAttributedString(string: text, attributes: attributes as [NSAttributedString.Key : Any]) if add { self.infoText.textStorage?.append(astr) } else { @@ -882,48 +882,46 @@ final class InstallerViewController: NSViewController { let revIn = findCloverRevision(at: self.targetVol.addPath("EFI")) ?? "0000" let mediaName = getMediaName(from: getBSDParent(of: disk) ?? "") ?? "NoName" let backUpPath = NSHomeDirectory().addPath("Desktop/CloverBackUp/\(mediaName)/r\(revIn)_\(now)/EFI") - if #available(OSX 10.10, *) { - DispatchQueue.global(qos: .userInteractive).async { - do { - if !fm.fileExists(atPath: backUpPath.deletingLastPath) { - try fm.createDirectory(atPath: backUpPath.deletingLastPath, - withIntermediateDirectories: true, - attributes: nil) - } - try fm.copyItem(atPath: self.targetVol.addPath("EFI"), - toPath: backUpPath) - //post(text: "backup made at '\(backUpPath)'.\n", add: true, color: nil, scroll: false) - Cloverapp.setValue(backUpPath, forKey: "BackUpPath") - self.installClover(disk: disk, settingDict: Cloverapp) - } catch { - DispatchQueue.main.async { - self.post(text: "The backup failed:\n", add: true, color: nil, scroll: false) - self.post(text: error.localizedDescription, add: false, color: nil, scroll: false) - AppSD.isInstalling = false - self.installButton.isEnabled = true - self.spinner.stopAnimation(nil) - } + + DispatchQueue.global(priority: .background).async(execute: { () -> Void in + do { + if !fm.fileExists(atPath: backUpPath.deletingLastPath) { + try fm.createDirectory(atPath: backUpPath.deletingLastPath, + withIntermediateDirectories: true, + attributes: nil) + } + try fm.copyItem(atPath: self.targetVol.addPath("EFI"), + toPath: backUpPath) + //post(text: "backup made at '\(backUpPath)'.\n", add: true, color: nil, scroll: false) + Cloverapp.setValue(backUpPath, forKey: "BackUpPath") + self.installClover(disk: disk, settingDict: Cloverapp) + } catch { + DispatchQueue.main.async { + self.post(text: "The backup failed:\n", add: true, color: nil, scroll: false) + self.post(text: error.localizedDescription, add: false, color: nil, scroll: false) + AppSD.isInstalling = false + self.installButton.isEnabled = true + self.spinner.stopAnimation(nil) } } - } - + }) } else { - if #available(OSX 10.10, *) { - DispatchQueue.global(qos: .userInteractive).async { - self.installClover(disk: disk, settingDict: Cloverapp) - } - } + DispatchQueue.global(priority: .background).async(execute: { () -> Void in + self.installClover(disk: disk, settingDict: Cloverapp) + }) } } func installClover(disk: String, settingDict : NSDictionary) { - self.post(text: "Installation begin..\n", add: true, color: nil, scroll: false) + run(cmd: "LC_ALL=C /usr/sbin/diskutil list > /tmp/diskutil.List") + DispatchQueue.main.async { + self.post(text: "Installation begin..\n", add: true, color: nil, scroll: false) + } if !isMountPoint(path: self.targetVol) { DispatchQueue.main.async { NSSound.beep() self.post(text: "Can't find target volume, installation aborted.", add: true, color: nil, scroll: false) } - return } @@ -944,11 +942,6 @@ final class InstallerViewController: NSViewController { DispatchQueue.main.async { self.spinner.startAnimation(nil) self.installButton.isEnabled = false - self.view.window?.level = .floating // just a hack to keep window in front momentarily - } - - DispatchQueue.main.asyncAfter(deadline: .now() + 6.0) { - self.view.window?.level = .normal } let task = Process() @@ -972,18 +965,12 @@ final class InstallerViewController: NSViewController { if data.count > 0 { let output = String(decoding: data, as: UTF8.self) DispatchQueue.main.async { - if self.view.window?.level != .normal { - self.view.window?.level = .normal - } - self.post(text: "\n" + output, add: true, color: nil, scroll: true) } fh.waitForDataInBackgroundAndNotify() - } else { - NotificationCenter.default.removeObserver(op1 as Any) } } @@ -994,6 +981,9 @@ final class InstallerViewController: NSViewController { NotificationCenter.default.removeObserver(op2 as Any) let success = (task.terminationStatus == 0) DispatchQueue.main.async { + self.view.window?.level = .floating + self.view.window?.makeKeyAndOrderFront(nil) + self.view.window?.level = .normal let message = success ? "Installation succeded".locale : "Installation failed".locale self.post(text: "\n\(message).", add: true, color: nil, scroll: true) @@ -1016,6 +1006,7 @@ final class InstallerViewController: NSViewController { self.setPreferences(for: self.targetVol) } } + NotificationCenter.default.removeObserver(op1 as Any) } task.launch() diff --git a/CloverApp/Clover/Installer/InstallerOutline.swift b/CloverApp/Clover/Installer/InstallerOutline.swift index 270e25316..6d75292bf 100644 --- a/CloverApp/Clover/Installer/InstallerOutline.swift +++ b/CloverApp/Clover/Installer/InstallerOutline.swift @@ -31,6 +31,7 @@ final class InstallerOutWindowController: NSWindowController, NSWindowDelegate { self.window = nil self.close() AppSD.installerWC = nil // remove a strong reference + AppSD.setActivationPolicy() return true } @@ -515,6 +516,12 @@ final class InstallerOutViewController: NSViewController { } task.terminationHandler = { t in + DispatchQueue.main.async { + self.view.window?.level = .floating + self.view.window?.makeKeyAndOrderFront(nil) + self.view.window?.level = .normal + } + if t.terminationStatus == 0 { if isMountPoint(path: disk) { DispatchQueue.main.async { @@ -523,19 +530,11 @@ final class InstallerOutViewController: NSViewController { self.setPreferences(for: self.targetVol) } } - DispatchQueue.main.async { - self.view.window?.makeKeyAndOrderFront(nil) - self.view.window?.level = .floating - self.view.window?.level = .normal - } } else { NSSound.beep() DispatchQueue.main.async { self.driversOutline.reloadData() self.expandAllSections() - self.view.window?.makeKeyAndOrderFront(nil) - self.view.window?.level = .floating - self.view.window?.level = .normal } } } @@ -696,11 +695,11 @@ final class InstallerOutViewController: NSViewController { // MARK: Post text func post(text: String, add: Bool, color: NSColor?, scroll: Bool) { - //let attributes = self.infoText.textStorage?.attributes(at: 0, effectiveRange: nil) let textColor = (color == nil) ? NSColor.controlTextColor : color! - let attributes = [/*NSAttributedString.Key.font: font,*/ NSAttributedString.Key.foregroundColor: textColor] + let font = NSFont.userFixedPitchFont(ofSize: 11) + let attributes = [NSAttributedString.Key.font: font, NSAttributedString.Key.foregroundColor: textColor] - let astr = NSAttributedString(string: text, attributes: attributes) + let astr = NSAttributedString(string: text, attributes: attributes as [NSAttributedString.Key : Any]) //DispatchQueue.global(qos: .background).async { DispatchQueue.main.async { if add { @@ -817,31 +816,40 @@ final class InstallerOutViewController: NSViewController { let mediaName = getMediaName(from: getBSDParent(of: disk) ?? "") ?? "NoName" let backUpPath = NSHomeDirectory().addPath("Desktop/CloverBackUp/\(mediaName)/r\(revIn)_\(now)/EFI") - do { - if !fm.fileExists(atPath: backUpPath.deletingLastPath) { - try fm.createDirectory(atPath: backUpPath.deletingLastPath, - withIntermediateDirectories: true, - attributes: nil) + DispatchQueue.global(priority: .background).async(execute: { () -> Void in + do { + if !fm.fileExists(atPath: backUpPath.deletingLastPath) { + try fm.createDirectory(atPath: backUpPath.deletingLastPath, + withIntermediateDirectories: true, + attributes: nil) + } + try fm.copyItem(atPath: self.targetVol.addPath("EFI"), + toPath: backUpPath) + //post(text: "backup made at '\(backUpPath)'.\n", add: true, color: nil, scroll: false) + Cloverapp.setValue(backUpPath, forKey: "BackUpPath") + self.installClover(disk: disk, settingDict: Cloverapp) + } catch { + self.post(text: "The backup failed:\n", add: true, color: nil, scroll: false) + self.post(text: error.localizedDescription, add: false, color: nil, scroll: false) } - try fm.copyItem(atPath: self.targetVol.addPath("EFI"), - toPath: backUpPath) - //post(text: "backup made at '\(backUpPath)'.\n", add: true, color: nil, scroll: false) - Cloverapp.setValue(backUpPath, forKey: "BackUpPath") - self.installClover(disk: disk, settingDict: Cloverapp) - } catch { - post(text: "The backup failed:\n", add: true, color: nil, scroll: false) - post(text: error.localizedDescription, add: false, color: nil, scroll: false) - } + }) } else { - self.installClover(disk: disk, settingDict: Cloverapp) + DispatchQueue.global(priority: .background).async(execute: { () -> Void in + self.installClover(disk: disk, settingDict: Cloverapp) + }) } } func installClover(disk: String, settingDict : NSDictionary) { - self.post(text: "Installation begin..\n", add: true, color: nil, scroll: false) + run(cmd: "LC_ALL=C /usr/sbin/diskutil list > /tmp/diskutil.List") + DispatchQueue.main.async { + self.post(text: "Installation begin..\n", add: true, color: nil, scroll: false) + } if !isMountPoint(path: self.targetVol) { - NSSound.beep() - self.post(text: "Can't find target volume, installation aborted.", add: true, color: nil, scroll: false) + DispatchQueue.main.async { + NSSound.beep() + self.post(text: "Can't find target volume, installation aborted.", add: true, color: nil, scroll: false) + } return } @@ -857,46 +865,47 @@ final class InstallerOutViewController: NSViewController { try? fm.removeItem(atPath: "/tmp/Cloverapp") if settingDict.write(toFile: "/tmp/Cloverapp", atomically: false) { - self.installButton.isEnabled = false - AppSD.isInstalling = true - self.spinner.startAnimation(nil) - - self.view.window?.level = .floating // just a hack to keep window in front momentarily - DispatchQueue.main.asyncAfter(deadline: .now() + 6.0) { - self.view.window?.level = .normal - } - let helperPath = Bundle.main.executablePath!.deletingLastPath.addPath("CloverDaemonNew") - - let script = "do shell script \"'\(helperPath)' --CLOVER\" with administrator privileges" - var err : NSDictionary? = nil - let result : NSAppleEventDescriptor = NSAppleScript(source: script)!.executeAndReturnError(&err) - - self.post(text: result.stringValue ?? "", add: false, color: nil, scroll: true) - self.spinner.stopAnimation(nil) - let message = (err == nil) ? "Installation succeded".locale : "Installation failed".locale - self.post(text: "\n\(message).", add: true, color: nil, scroll: true) - - let alert = NSAlert() - alert.messageText = message - if #available(OSX 10.10, *) { - alert.informativeText = (err == nil) ? "😀" : "😱" - } - alert.alertStyle = (err == nil) ? .informational : .critical - alert.addButton(withTitle: "Close".locale) - alert.beginSheetModal(for: self.view.window!) { (reponse) in + DispatchQueue.main.async { + self.installButton.isEnabled = false + AppSD.isInstalling = true + self.spinner.startAnimation(nil) + let helperPath = Bundle.main.executablePath!.deletingLastPath.addPath("CloverDaemonNew") + + let script = "do shell script \"'\(helperPath)' --CLOVER\" with administrator privileges" + var err : NSDictionary? = nil + let result : NSAppleEventDescriptor = NSAppleScript(source: script)!.executeAndReturnError(&err) + + self.post(text: result.stringValue ?? "", add: false, color: nil, scroll: true) + self.spinner.stopAnimation(nil) + let message = (err == nil) ? "Installation succeded".locale : "Installation failed".locale + self.post(text: "\n\(message).", add: true, color: nil, scroll: true) + + let alert = NSAlert() + alert.messageText = message + if #available(OSX 10.10, *) { + alert.informativeText = (err == nil) ? "😀" : "😱" + } + alert.alertStyle = (err == nil) ? .informational : .critical + alert.addButton(withTitle: "Close".locale) + alert.beginSheetModal(for: self.view.window!) { (reponse) in + + } + AppSD.isInstalling = false + self.installButton.isEnabled = true + self.spinner.stopAnimation(nil) + if isMountPoint(path: self.targetVol) { + self.targetVol = getMountPoint(from: disk) ?? "" + } + AppSD.reFreshDisksList() + self.setPreferences(for: self.targetVol) } - AppSD.isInstalling = false - self.installButton.isEnabled = true - self.spinner.stopAnimation(nil) - if isMountPoint(path: self.targetVol) { - self.targetVol = getMountPoint(from: disk) ?? "" - } - AppSD.reFreshDisksList() - self.setPreferences(for: self.targetVol) + } else { - NSSound.beep() - self.post(text: "Can't write temporary files, installation aborted.", add: true, color: nil, scroll: false) + DispatchQueue.main.async { + NSSound.beep() + self.post(text: "Can't write temporary files, installation aborted.", add: true, color: nil, scroll: false) + } } } } diff --git a/CloverApp/Clover/Plist Editor/Document.swift b/CloverApp/Clover/Plist Editor/Document.swift index aaa943cc3..80fe24bf5 100644 --- a/CloverApp/Clover/Plist Editor/Document.swift +++ b/CloverApp/Clover/Plist Editor/Document.swift @@ -56,10 +56,7 @@ final class Document: NSDocument { override func removeWindowController(_ windowController: NSWindowController) { super.removeWindowController(windowController) - let documents = NSDocumentController.shared.documents - if documents.count == 1 { - NSApp.setActivationPolicy(.accessory) - } + AppSD.setActivationPolicy() } override func makeWindowControllers() { diff --git a/CloverApp/Clover/Plist Editor/PE_Utils.swift b/CloverApp/Clover/Plist Editor/PE_Utils.swift index 9221fcb35..1f9465c94 100644 --- a/CloverApp/Clover/Plist Editor/PE_Utils.swift +++ b/CloverApp/Clover/Plist Editor/PE_Utils.swift @@ -132,6 +132,7 @@ func loadPlist(at path: String) { dc.openDocument(withContentsOf: URL(fileURLWithPath: path), display: true) { (document, documentWasAlreadyOpen, error) in if error != nil { + AppSD.setActivationPolicy() print(error!.localizedDescription) NSSound.beep() } else { @@ -141,10 +142,6 @@ func loadPlist(at path: String) { } } } else { - // check if a document is opened some where - if NSDocumentController.shared.documents.count == 0 { - NSApp.setActivationPolicy(.accessory) - } // Use reccomended programs (hope) to avoid Text Edit var success = NSWorkspace.shared.openFile(path, withApplication: "PlistEdit Pro") if !success { @@ -158,5 +155,6 @@ func loadPlist(at path: String) { if !success { // open the directory path success = NSWorkspace.shared.openFile(path.deletingLastPath) } + AppSD.setActivationPolicy() } } diff --git a/CloverApp/Clover/SettingsView.swift b/CloverApp/Clover/SettingsView.swift index c7c1a8c91..3eac6f3e5 100644 --- a/CloverApp/Clover/SettingsView.swift +++ b/CloverApp/Clover/SettingsView.swift @@ -634,11 +634,8 @@ final class SettingsViewController: AppSD.themeManagerWC = ThemeManagerWC.loadFromNib() } AppSD.themeManagerWC?.showWindow(self) - - AppSD.themeManagerWC?.window?.level = .floating AppSD.themeManagerWC?.window?.makeKeyAndOrderFront(nil) - NSApp.activate(ignoringOtherApps: true) - AppSD.themeManagerWC?.window?.level = .normal + AppSD.setActivationPolicy() } } @@ -757,17 +754,14 @@ final class SettingsViewController: // make the app regular NSApp.setActivationPolicy(.regular) - + NSApp.activate(ignoringOtherApps: true) op.begin { (result) in if result == .OK { if let path = op.url?.path { loadPlist(at: path) // this will make the app regular again in 10.11+ } } else { - // check if a document is opened some where - if NSDocumentController.shared.documents.count == 0 { - NSApp.setActivationPolicy(.accessory) - } + AppSD.setActivationPolicy() } } } @@ -855,20 +849,16 @@ final class SettingsViewController: } AppSD.installerWC?.showWindow(self) - AppSD.installerWC?.window?.level = .floating AppSD.installerWC?.window?.makeKeyAndOrderFront(nil) - NSApp.activate(ignoringOtherApps: true) - AppSD.installerWC?.window?.level = .normal + AppSD.setActivationPolicy() } else { if (AppSD.installerOutWC == nil) { AppSD.installerOutWC = InstallerOutWindowController.loadFromNib() } AppSD.installerOutWC?.showWindow(self) - AppSD.installerOutWC?.window?.level = .floating AppSD.installerOutWC?.window?.makeKeyAndOrderFront(nil) - NSApp.activate(ignoringOtherApps: true) - AppSD.installerOutWC?.window?.level = .normal + AppSD.setActivationPolicy() } } } diff --git a/CloverApp/Clover/ThemeManager/ThemeManagerVC.swift b/CloverApp/Clover/ThemeManager/ThemeManagerVC.swift index dd5cdc191..298f3acaf 100644 --- a/CloverApp/Clover/ThemeManager/ThemeManagerVC.swift +++ b/CloverApp/Clover/ThemeManager/ThemeManagerVC.swift @@ -66,8 +66,6 @@ NSComboBoxDataSource { super.viewDidLoad() } self.loaded = true - - self.view.window?.title = self.view.window!.title.locale let settingVC = AppSD.settingsWC?.contentViewController as? SettingsViewController settingVC?.themeUserCBox.isEnabled = false @@ -760,7 +758,6 @@ NSComboBoxDataSource { if let disk = sender?.selectedItem?.representedObject as? String { if !isMountPoint(path: disk) { self.installButton.isEnabled = false - self.view.window?.level = .floating DispatchQueue.global(priority: .background).async(execute: { () -> Void in let cmd = "diskutil mount \(disk)" let msg = String(format: "Clover wants to mount %@", disk) @@ -777,6 +774,11 @@ NSComboBoxDataSource { } task.terminationHandler = { t in + DispatchQueue.main.async { + self.view.window?.level = .floating + self.view.window?.makeKeyAndOrderFront(nil) + self.view.window?.level = .normal + } if t.terminationStatus == 0 { if isMountPoint(path: disk) { DispatchQueue.main.async { @@ -787,17 +789,11 @@ NSComboBoxDataSource { } DispatchQueue.main.async { self.installButton.isEnabled = true - self.view.window?.makeKeyAndOrderFront(nil) - self.view.window?.level = .floating - self.view.window?.level = .normal } } else { DispatchQueue.main.async { NSSound.beep() self.installButton.isEnabled = true - self.view.window?.makeKeyAndOrderFront(nil) - self.view.window?.level = .floating - self.view.window?.level = .normal self.showInstalledThemes(self.installedThemesCheckBox) } } @@ -866,6 +862,7 @@ final class ThemeManagerWC: NSWindowController, NSWindowDelegate { self.window = nil self.close() AppSD.themeManagerWC = nil // remove a strong reference + AppSD.setActivationPolicy() return true } } diff --git a/CloverApp/CloverDaemonNew/CloverDaemonNew/BootInstaller.swift b/CloverApp/CloverDaemonNew/CloverDaemonNew/BootInstaller.swift index b1505d6d9..904eff4f3 100644 --- a/CloverApp/CloverDaemonNew/CloverDaemonNew/BootInstaller.swift +++ b/CloverApp/CloverDaemonNew/CloverDaemonNew/BootInstaller.swift @@ -11,6 +11,7 @@ import Foundation final class Installer: NSObject { let ktempLogPath = "/tmp/cltmplog" + let kDiskUtilListPath = "/tmp/diskutil.List" private var realTime : Bool = true private var gTargetVolume : String? = nil @@ -33,6 +34,7 @@ final class Installer: NSObject { } t.arguments = ["-c", "rm -rf /tmp/Clover* && rm -f /tmp/boot0* && rm -f /tmp/boot1*"] t.launch() + t.waitUntilExit() } private func saveLog() { @@ -185,7 +187,6 @@ final class Installer: NSObject { // MARK: Install func install() { - let df = DateFormatter() df.locale = Locale(identifier: "en_US") df.dateFormat = "yyyy-MM-dd hh:mm:ss" @@ -219,7 +220,7 @@ final class Installer: NSObject { let alt : Bool = (CloverappDict["alt"] as? NSNumber)?.boolValue ?? false - log("\(version) (v\(daemonVersion)), \(now)") + log("\(version) (installer library v\(daemonVersion)), \(now)") log("macOS \(ProcessInfo().operatingSystemVersionString)") log("SELF = \(CommandLine.arguments[0])") if geteuid() != 0 { @@ -318,14 +319,25 @@ final class Installer: NSObject { } if (boot2 != nil) { + log("Installation type: BIOS") log("boot2: \(boot2!)") preferences.setValue(boot2!, forKey: "boot2") boot2Path = CloverV2.addPath("Bootloaders/x64").addPath(boot2!) if !fm.fileExists(atPath: boot2Path!) { exit("Error: cannot found \"\(boot2!)\".") } + } else { + log("Installation type: UEFI") } + if let dlist = try? String(contentsOfFile: kDiskUtilListPath) { + log("\n\n\(dlist)\n") + } + + if fm.fileExists(atPath: kDiskUtilListPath) { + try? fm.removeItem(atPath: kDiskUtilListPath) + } + // MARK: Create Directories createDirectory(at: targetVol.addPath("EFI/CLOVER"), attr: attributes, exitOnError: true) createDirectory(at: targetVol.addPath("EFI/BOOT"), attr: attributes, exitOnError: true) @@ -452,7 +464,7 @@ final class Installer: NSObject { } catch { } for d in docs { - if d.fileExtension == "efi" { + if !d.hasPrefix(".") { var a : [FileAttributeKey: Any]? = nil do { a = try fm.attributesOfItem(atPath: cv2docs.addPath(d)) @@ -605,8 +617,6 @@ final class Installer: NSObject { let output = String(decoding: data, as: UTF8.self) self.log(output) fh.waitForDataInBackgroundAndNotify() - } else { - NotificationCenter.default.removeObserver(op1 as Any) } } @@ -618,7 +628,7 @@ final class Installer: NSObject { if task.terminationStatus != 0 { self.exit("Error: failed installing boot sectors.") } - + NotificationCenter.default.removeObserver(op1 as Any) } task.launch() @@ -654,9 +664,11 @@ final class Installer: NSObject { } task.arguments = [ "umount", "force", disk ] task.launch() + task.waitUntilExit() } cleanUp() } + Darwin.exit(EXIT_SUCCESS) // ------------- end } diff --git a/CloverApp/CloverDaemonNew/CloverDaemonNew/main.swift b/CloverApp/CloverDaemonNew/CloverDaemonNew/main.swift index 9dd22df64..4dc648c25 100644 --- a/CloverApp/CloverDaemonNew/CloverDaemonNew/main.swift +++ b/CloverApp/CloverDaemonNew/CloverDaemonNew/main.swift @@ -8,7 +8,7 @@ import Foundation -let daemonVersion = "1.1.4" +let daemonVersion = "1.1.5" let fm = FileManager.default diff --git a/CloverApp/bootsectors-install b/CloverApp/bootsectors-install index a56992360..7eabc2d2a 100755 --- a/CloverApp/bootsectors-install +++ b/CloverApp/bootsectors-install @@ -40,7 +40,7 @@ fi } echo -echo "Installing boot sectors (version of Wed 30 Dec 2019, 20:01)" +echo "Installing boot sectors (version of Wed 13 May 2020, 15:49)" echo echo "disk: ${disk}" echo "bootdev: ${bootdev}" @@ -94,8 +94,6 @@ if [[ "${rootdisk}" == "${disk}" ]]; then keepmounted=1 fi -echo -LC_ALL=C /usr/sbin/diskutil list echo # hfs can cause a panic writing boot sectors if journaled