diff --git a/TINU-Bridging-Header.h b/TINU-Bridging-Header.h new file mode 100644 index 0000000..f6a4c5b --- /dev/null +++ b/TINU-Bridging-Header.h @@ -0,0 +1,5 @@ +// +// Use this file to import your target's public headers that you would like to expose to Swift. +// + +//Unused header file diff --git a/TINU.xcodeproj/project.pbxproj b/TINU.xcodeproj/project.pbxproj new file mode 100644 index 0000000..9d4e345 --- /dev/null +++ b/TINU.xcodeproj/project.pbxproj @@ -0,0 +1,690 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + C60D39B01F5E136500D94834 /* Part.swift in Sources */ = {isa = PBXBuildFile; fileRef = C60D39AF1F5E136500D94834 /* Part.swift */; }; + C60D39B21F5E4AFC00D94834 /* ContactsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C60D39B11F5E4AFC00D94834 /* ContactsViewController.swift */; }; + C60D39B41F5EB47000D94834 /* ContactsWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C60D39B31F5EB47000D94834 /* ContactsWindowController.swift */; }; + C60D48CD1F585F7F00ABF26E /* MainCreationFinished.swift in Sources */ = {isa = PBXBuildFile; fileRef = C60D48CC1F585F7F00ABF26E /* MainCreationFinished.swift */; }; + C621CFA71F4F6A6500CC6D5B /* MainWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C621CFA61F4F6A6500CC6D5B /* MainWindowController.swift */; }; + C621CFAC1F4F7DF400CC6D5B /* DriveObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = C621CFAB1F4F7DF400CC6D5B /* DriveObject.swift */; }; + C64E56371F51D917007B8CEE /* ChoseAppViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C64E56361F51D917007B8CEE /* ChoseAppViewController.swift */; }; + C64E56391F51E79C007B8CEE /* ConfirmViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C64E56381F51E79C007B8CEE /* ConfirmViewController.swift */; }; + C64E563B1F522854007B8CEE /* InstallingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C64E563A1F522854007B8CEE /* InstallingViewController.swift */; }; + C6553A911F5F7CEA0048965D /* LicenseViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6553A901F5F7CEA0048965D /* LicenseViewController.swift */; }; + C6553A931F5F83770048965D /* License.rtf in Resources */ = {isa = PBXBuildFile; fileRef = C6553A921F5F83770048965D /* License.rtf */; }; + C65AA61F1F4F497A00C43223 /* SharedInstances.swift in Sources */ = {isa = PBXBuildFile; fileRef = C65AA61E1F4F497A00C43223 /* SharedInstances.swift */; }; + C65AA6211F4F4C0400C43223 /* InfoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C65AA6201F4F4C0400C43223 /* InfoViewController.swift */; }; + C65AA6241F4F4C3400C43223 /* ChoseDriveViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C65AA6221F4F4C3400C43223 /* ChoseDriveViewController.swift */; }; + C65B5EFD1F7201D10061F1A3 /* DebugScript.sh in Resources */ = {isa = PBXBuildFile; fileRef = C65B5EFB1F71FAB10061F1A3 /* DebugScript.sh */; }; + C65B5EFF1F72099F0061F1A3 /* ScriptsManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = C65B5EFE1F72099F0061F1A3 /* ScriptsManager.swift */; }; + C65B5F031F720D680061F1A3 /* SudoManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = C65B5F021F720D680061F1A3 /* SudoManager.swift */; }; + C691BFEE1F6DEEA800589EF8 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C691BFED1F6DEEA800589EF8 /* Assets.xcassets */; }; + C691BFF01F6DFBDB00589EF8 /* TestingVariables.swift in Sources */ = {isa = PBXBuildFile; fileRef = C691BFEF1F6DFBDB00589EF8 /* TestingVariables.swift */; }; + C6DF04661F4F33C500D200B1 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6DF04651F4F33C500D200B1 /* AppDelegate.swift */; }; + C6DF046D1F4F33C500D200B1 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C6DF046B1F4F33C500D200B1 /* Main.storyboard */; }; + C6DF04781F4F33C500D200B1 /* TINUTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6DF04771F4F33C500D200B1 /* TINUTests.swift */; }; + C6DF04831F4F33C500D200B1 /* TINUUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6DF04821F4F33C500D200B1 /* TINUUITests.swift */; }; + DD01EBED1F71B6BF00C94D9B /* LogWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD01EBEC1F71B6BF00C94D9B /* LogWindowController.swift */; }; + DD01EBEF1F71BD2A00C94D9B /* LogManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD01EBEE1F71BD2A00C94D9B /* LogManager.swift */; }; + DD01EBF11F71BFE600C94D9B /* LogViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD01EBF01F71BFE600C94D9B /* LogViewController.swift */; }; + DDDCF67C1F63330B00CF7FE4 /* CreditsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDDCF67B1F63330B00CF7FE4 /* CreditsViewController.swift */; }; + DDDCF67E1F63338F00CF7FE4 /* CreditsWindwController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDDCF67D1F63338F00CF7FE4 /* CreditsWindwController.swift */; }; + DDDF14641F6730DA00953634 /* SharedVariables.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDDF14631F6730DA00953634 /* SharedVariables.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + C6DF04741F4F33C500D200B1 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = C6DF045A1F4F33C500D200B1 /* Project object */; + proxyType = 1; + remoteGlobalIDString = C6DF04611F4F33C500D200B1; + remoteInfo = TINU; + }; + C6DF047F1F4F33C500D200B1 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = C6DF045A1F4F33C500D200B1 /* Project object */; + proxyType = 1; + remoteGlobalIDString = C6DF04611F4F33C500D200B1; + remoteInfo = TINU; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + C60D39AF1F5E136500D94834 /* Part.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Part.swift; sourceTree = ""; }; + C60D39B11F5E4AFC00D94834 /* ContactsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ContactsViewController.swift; sourceTree = ""; }; + C60D39B31F5EB47000D94834 /* ContactsWindowController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ContactsWindowController.swift; sourceTree = ""; }; + C60D48CC1F585F7F00ABF26E /* MainCreationFinished.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainCreationFinished.swift; sourceTree = ""; }; + C621CFA61F4F6A6500CC6D5B /* MainWindowController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainWindowController.swift; sourceTree = ""; }; + C621CFAB1F4F7DF400CC6D5B /* DriveObject.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DriveObject.swift; sourceTree = ""; }; + C64E56361F51D917007B8CEE /* ChoseAppViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChoseAppViewController.swift; sourceTree = ""; }; + C64E56381F51E79C007B8CEE /* ConfirmViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConfirmViewController.swift; sourceTree = ""; }; + C64E563A1F522854007B8CEE /* InstallingViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InstallingViewController.swift; sourceTree = ""; }; + C64E563F1F52786F007B8CEE /* TINU-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "TINU-Bridging-Header.h"; sourceTree = ""; }; + C6553A901F5F7CEA0048965D /* LicenseViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LicenseViewController.swift; sourceTree = ""; }; + C6553A921F5F83770048965D /* License.rtf */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.rtf; path = License.rtf; sourceTree = ""; }; + C65AA61E1F4F497A00C43223 /* SharedInstances.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SharedInstances.swift; sourceTree = ""; }; + C65AA6201F4F4C0400C43223 /* InfoViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InfoViewController.swift; sourceTree = ""; }; + C65AA6221F4F4C3400C43223 /* ChoseDriveViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChoseDriveViewController.swift; sourceTree = ""; }; + C65B5EFB1F71FAB10061F1A3 /* DebugScript.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = DebugScript.sh; sourceTree = ""; }; + C65B5EFE1F72099F0061F1A3 /* ScriptsManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScriptsManager.swift; sourceTree = ""; }; + C65B5F021F720D680061F1A3 /* SudoManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SudoManager.swift; sourceTree = ""; }; + C691BFED1F6DEEA800589EF8 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + C691BFEF1F6DFBDB00589EF8 /* TestingVariables.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestingVariables.swift; sourceTree = ""; }; + C6DF04621F4F33C500D200B1 /* TINU.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TINU.app; sourceTree = BUILT_PRODUCTS_DIR; }; + C6DF04651F4F33C500D200B1 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + C6DF046C1F4F33C500D200B1 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + C6DF046E1F4F33C500D200B1 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + C6DF04731F4F33C500D200B1 /* TINUTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = TINUTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + C6DF04771F4F33C500D200B1 /* TINUTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TINUTests.swift; sourceTree = ""; }; + C6DF04791F4F33C500D200B1 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + C6DF047E1F4F33C500D200B1 /* TINUUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = TINUUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + C6DF04821F4F33C500D200B1 /* TINUUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TINUUITests.swift; sourceTree = ""; }; + C6DF04841F4F33C500D200B1 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + DD01EBEC1F71B6BF00C94D9B /* LogWindowController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LogWindowController.swift; sourceTree = ""; }; + DD01EBEE1F71BD2A00C94D9B /* LogManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LogManager.swift; sourceTree = ""; }; + DD01EBF01F71BFE600C94D9B /* LogViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LogViewController.swift; sourceTree = ""; }; + DDDCF67B1F63330B00CF7FE4 /* CreditsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CreditsViewController.swift; sourceTree = ""; }; + DDDCF67D1F63338F00CF7FE4 /* CreditsWindwController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CreditsWindwController.swift; sourceTree = ""; }; + DDDF14631F6730DA00953634 /* SharedVariables.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SharedVariables.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + C6DF045F1F4F33C500D200B1 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + C6DF04701F4F33C500D200B1 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + C6DF047B1F4F33C500D200B1 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + C60D39B51F5EB48000D94834 /* WindowsControllers */ = { + isa = PBXGroup; + children = ( + C621CFA61F4F6A6500CC6D5B /* MainWindowController.swift */, + C60D39B31F5EB47000D94834 /* ContactsWindowController.swift */, + DDDCF67D1F63338F00CF7FE4 /* CreditsWindwController.swift */, + DD01EBEC1F71B6BF00C94D9B /* LogWindowController.swift */, + ); + name = WindowsControllers; + sourceTree = ""; + }; + C60D39B61F5EB4A000D94834 /* OtherCode */ = { + isa = PBXGroup; + children = ( + DD01EBEA1F71A73700C94D9B /* CustomClasses */, + DD01EBEB1F71A75B00C94D9B /* SharedCode */, + ); + name = OtherCode; + sourceTree = ""; + }; + C60D39B71F5EB4C800D94834 /* ViewControllers */ = { + isa = PBXGroup; + children = ( + C60D39B11F5E4AFC00D94834 /* ContactsViewController.swift */, + DDDCF67B1F63330B00CF7FE4 /* CreditsViewController.swift */, + C65AA6201F4F4C0400C43223 /* InfoViewController.swift */, + C6553A901F5F7CEA0048965D /* LicenseViewController.swift */, + C65AA6221F4F4C3400C43223 /* ChoseDriveViewController.swift */, + C64E56361F51D917007B8CEE /* ChoseAppViewController.swift */, + C64E56381F51E79C007B8CEE /* ConfirmViewController.swift */, + C64E563A1F522854007B8CEE /* InstallingViewController.swift */, + C60D48CC1F585F7F00ABF26E /* MainCreationFinished.swift */, + DD01EBF01F71BFE600C94D9B /* LogViewController.swift */, + ); + name = ViewControllers; + sourceTree = ""; + }; + C6553A941F5F83DC0048965D /* Resources */ = { + isa = PBXGroup; + children = ( + C6553A921F5F83770048965D /* License.rtf */, + C65B5EFB1F71FAB10061F1A3 /* DebugScript.sh */, + ); + name = Resources; + sourceTree = ""; + }; + C6DF04591F4F33C500D200B1 = { + isa = PBXGroup; + children = ( + C64E563F1F52786F007B8CEE /* TINU-Bridging-Header.h */, + C6DF04641F4F33C500D200B1 /* TINU */, + C6DF04761F4F33C500D200B1 /* TINUTests */, + C6DF04811F4F33C500D200B1 /* TINUUITests */, + C6DF04631F4F33C500D200B1 /* Products */, + ); + sourceTree = ""; + }; + C6DF04631F4F33C500D200B1 /* Products */ = { + isa = PBXGroup; + children = ( + C6DF04621F4F33C500D200B1 /* TINU.app */, + C6DF04731F4F33C500D200B1 /* TINUTests.xctest */, + C6DF047E1F4F33C500D200B1 /* TINUUITests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + C6DF04641F4F33C500D200B1 /* TINU */ = { + isa = PBXGroup; + children = ( + C6DF046E1F4F33C500D200B1 /* Info.plist */, + C691BFED1F6DEEA800589EF8 /* Assets.xcassets */, + C6DF046B1F4F33C500D200B1 /* Main.storyboard */, + C6DF04651F4F33C500D200B1 /* AppDelegate.swift */, + C6553A941F5F83DC0048965D /* Resources */, + C60D39B51F5EB48000D94834 /* WindowsControllers */, + C60D39B71F5EB4C800D94834 /* ViewControllers */, + C60D39B61F5EB4A000D94834 /* OtherCode */, + ); + path = TINU; + sourceTree = ""; + }; + C6DF04761F4F33C500D200B1 /* TINUTests */ = { + isa = PBXGroup; + children = ( + C6DF04771F4F33C500D200B1 /* TINUTests.swift */, + C6DF04791F4F33C500D200B1 /* Info.plist */, + ); + path = TINUTests; + sourceTree = ""; + }; + C6DF04811F4F33C500D200B1 /* TINUUITests */ = { + isa = PBXGroup; + children = ( + C6DF04821F4F33C500D200B1 /* TINUUITests.swift */, + C6DF04841F4F33C500D200B1 /* Info.plist */, + ); + path = TINUUITests; + sourceTree = ""; + }; + DD01EBEA1F71A73700C94D9B /* CustomClasses */ = { + isa = PBXGroup; + children = ( + C621CFAB1F4F7DF400CC6D5B /* DriveObject.swift */, + C60D39AF1F5E136500D94834 /* Part.swift */, + ); + name = CustomClasses; + sourceTree = ""; + }; + DD01EBEB1F71A75B00C94D9B /* SharedCode */ = { + isa = PBXGroup; + children = ( + C691BFEF1F6DFBDB00589EF8 /* TestingVariables.swift */, + DDDF14631F6730DA00953634 /* SharedVariables.swift */, + C65AA61E1F4F497A00C43223 /* SharedInstances.swift */, + DD01EBEE1F71BD2A00C94D9B /* LogManager.swift */, + C65B5EFE1F72099F0061F1A3 /* ScriptsManager.swift */, + C65B5F021F720D680061F1A3 /* SudoManager.swift */, + ); + name = SharedCode; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + C6DF04611F4F33C500D200B1 /* TINU */ = { + isa = PBXNativeTarget; + buildConfigurationList = C6DF04871F4F33C500D200B1 /* Build configuration list for PBXNativeTarget "TINU" */; + buildPhases = ( + C6DF045E1F4F33C500D200B1 /* Sources */, + C6DF045F1F4F33C500D200B1 /* Frameworks */, + C6DF04601F4F33C500D200B1 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = TINU; + productName = TINU; + productReference = C6DF04621F4F33C500D200B1 /* TINU.app */; + productType = "com.apple.product-type.application"; + }; + C6DF04721F4F33C500D200B1 /* TINUTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = C6DF048A1F4F33C500D200B1 /* Build configuration list for PBXNativeTarget "TINUTests" */; + buildPhases = ( + C6DF046F1F4F33C500D200B1 /* Sources */, + C6DF04701F4F33C500D200B1 /* Frameworks */, + C6DF04711F4F33C500D200B1 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + C6DF04751F4F33C500D200B1 /* PBXTargetDependency */, + ); + name = TINUTests; + productName = TINUTests; + productReference = C6DF04731F4F33C500D200B1 /* TINUTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; + C6DF047D1F4F33C500D200B1 /* TINUUITests */ = { + isa = PBXNativeTarget; + buildConfigurationList = C6DF048D1F4F33C500D200B1 /* Build configuration list for PBXNativeTarget "TINUUITests" */; + buildPhases = ( + C6DF047A1F4F33C500D200B1 /* Sources */, + C6DF047B1F4F33C500D200B1 /* Frameworks */, + C6DF047C1F4F33C500D200B1 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + C6DF04801F4F33C500D200B1 /* PBXTargetDependency */, + ); + name = TINUUITests; + productName = TINUUITests; + productReference = C6DF047E1F4F33C500D200B1 /* TINUUITests.xctest */; + productType = "com.apple.product-type.bundle.ui-testing"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + C6DF045A1F4F33C500D200B1 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0830; + LastUpgradeCheck = 0830; + ORGANIZATIONNAME = "Pietro Caruso"; + TargetAttributes = { + C6DF04611F4F33C500D200B1 = { + CreatedOnToolsVersion = 8.3.1; + LastSwiftMigration = 0900; + ProvisioningStyle = Manual; + }; + C6DF04721F4F33C500D200B1 = { + CreatedOnToolsVersion = 8.3.1; + DevelopmentTeam = 9RSH5734GY; + LastSwiftMigration = 0900; + ProvisioningStyle = Automatic; + TestTargetID = C6DF04611F4F33C500D200B1; + }; + C6DF047D1F4F33C500D200B1 = { + CreatedOnToolsVersion = 8.3.1; + DevelopmentTeam = 9RSH5734GY; + LastSwiftMigration = 0900; + ProvisioningStyle = Automatic; + TestTargetID = C6DF04611F4F33C500D200B1; + }; + }; + }; + buildConfigurationList = C6DF045D1F4F33C500D200B1 /* Build configuration list for PBXProject "TINU" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = C6DF04591F4F33C500D200B1; + productRefGroup = C6DF04631F4F33C500D200B1 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + C6DF04611F4F33C500D200B1 /* TINU */, + C6DF04721F4F33C500D200B1 /* TINUTests */, + C6DF047D1F4F33C500D200B1 /* TINUUITests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + C6DF04601F4F33C500D200B1 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + C65B5EFD1F7201D10061F1A3 /* DebugScript.sh in Resources */, + C6DF046D1F4F33C500D200B1 /* Main.storyboard in Resources */, + C691BFEE1F6DEEA800589EF8 /* Assets.xcassets in Resources */, + C6553A931F5F83770048965D /* License.rtf in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + C6DF04711F4F33C500D200B1 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + C6DF047C1F4F33C500D200B1 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + C6DF045E1F4F33C500D200B1 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + C621CFA71F4F6A6500CC6D5B /* MainWindowController.swift in Sources */, + C621CFAC1F4F7DF400CC6D5B /* DriveObject.swift in Sources */, + DDDCF67E1F63338F00CF7FE4 /* CreditsWindwController.swift in Sources */, + C65AA61F1F4F497A00C43223 /* SharedInstances.swift in Sources */, + C691BFF01F6DFBDB00589EF8 /* TestingVariables.swift in Sources */, + C64E56391F51E79C007B8CEE /* ConfirmViewController.swift in Sources */, + C65B5F031F720D680061F1A3 /* SudoManager.swift in Sources */, + DDDCF67C1F63330B00CF7FE4 /* CreditsViewController.swift in Sources */, + C65AA6211F4F4C0400C43223 /* InfoViewController.swift in Sources */, + C60D39B21F5E4AFC00D94834 /* ContactsViewController.swift in Sources */, + DDDF14641F6730DA00953634 /* SharedVariables.swift in Sources */, + C65B5EFF1F72099F0061F1A3 /* ScriptsManager.swift in Sources */, + C60D39B01F5E136500D94834 /* Part.swift in Sources */, + C60D48CD1F585F7F00ABF26E /* MainCreationFinished.swift in Sources */, + DD01EBF11F71BFE600C94D9B /* LogViewController.swift in Sources */, + C64E56371F51D917007B8CEE /* ChoseAppViewController.swift in Sources */, + C60D39B41F5EB47000D94834 /* ContactsWindowController.swift in Sources */, + C64E563B1F522854007B8CEE /* InstallingViewController.swift in Sources */, + C65AA6241F4F4C3400C43223 /* ChoseDriveViewController.swift in Sources */, + DD01EBEF1F71BD2A00C94D9B /* LogManager.swift in Sources */, + DD01EBED1F71B6BF00C94D9B /* LogWindowController.swift in Sources */, + C6553A911F5F7CEA0048965D /* LicenseViewController.swift in Sources */, + C6DF04661F4F33C500D200B1 /* AppDelegate.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + C6DF046F1F4F33C500D200B1 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + C6DF04781F4F33C500D200B1 /* TINUTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + C6DF047A1F4F33C500D200B1 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + C6DF04831F4F33C500D200B1 /* TINUUITests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + C6DF04751F4F33C500D200B1 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = C6DF04611F4F33C500D200B1 /* TINU */; + targetProxy = C6DF04741F4F33C500D200B1 /* PBXContainerItemProxy */; + }; + C6DF04801F4F33C500D200B1 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = C6DF04611F4F33C500D200B1 /* TINU */; + targetProxy = C6DF047F1F4F33C500D200B1 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + C6DF046B1F4F33C500D200B1 /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + C6DF046C1F4F33C500D200B1 /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + C6DF04851F4F33C500D200B1 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "Developer ID Application"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.10; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + C6DF04861F4F33C500D200B1 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "Developer ID Application"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.10; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + }; + name = Release; + }; + C6DF04881F4F33C500D200B1 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_IDENTITY = "Developer ID Application"; + COMBINE_HIDPI_IMAGES = YES; + DEVELOPMENT_TEAM = ""; + INFOPLIST_FILE = TINU/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; + MACOSX_DEPLOYMENT_TARGET = 10.10; + PRODUCT_BUNDLE_IDENTIFIER = org.pietrocaruso.TINU; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE = ""; + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_OBJC_BRIDGING_HEADER = "TINU-Bridging-Header.h"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 3.0; + }; + name = Debug; + }; + C6DF04891F4F33C500D200B1 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_IDENTITY = "Developer ID Application"; + COMBINE_HIDPI_IMAGES = YES; + DEVELOPMENT_TEAM = ""; + INFOPLIST_FILE = TINU/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; + MACOSX_DEPLOYMENT_TARGET = 10.10; + PRODUCT_BUNDLE_IDENTIFIER = org.pietrocaruso.TINU; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE = ""; + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_OBJC_BRIDGING_HEADER = "TINU-Bridging-Header.h"; + SWIFT_VERSION = 3.0; + }; + name = Release; + }; + C6DF048B1F4F33C500D200B1 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + BUNDLE_LOADER = "$(TEST_HOST)"; + COMBINE_HIDPI_IMAGES = YES; + DEVELOPMENT_TEAM = 9RSH5734GY; + INFOPLIST_FILE = TINUTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = org.pietrocaruso.TINUTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TINU.app/Contents/MacOS/TINU"; + }; + name = Debug; + }; + C6DF048C1F4F33C500D200B1 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + BUNDLE_LOADER = "$(TEST_HOST)"; + COMBINE_HIDPI_IMAGES = YES; + DEVELOPMENT_TEAM = 9RSH5734GY; + INFOPLIST_FILE = TINUTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = org.pietrocaruso.TINUTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TINU.app/Contents/MacOS/TINU"; + }; + name = Release; + }; + C6DF048E1F4F33C500D200B1 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + COMBINE_HIDPI_IMAGES = YES; + DEVELOPMENT_TEAM = 9RSH5734GY; + INFOPLIST_FILE = TINUUITests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = org.pietrocaruso.TINUUITests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; + TEST_TARGET_NAME = TINU; + }; + name = Debug; + }; + C6DF048F1F4F33C500D200B1 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + COMBINE_HIDPI_IMAGES = YES; + DEVELOPMENT_TEAM = 9RSH5734GY; + INFOPLIST_FILE = TINUUITests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = org.pietrocaruso.TINUUITests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; + TEST_TARGET_NAME = TINU; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + C6DF045D1F4F33C500D200B1 /* Build configuration list for PBXProject "TINU" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C6DF04851F4F33C500D200B1 /* Debug */, + C6DF04861F4F33C500D200B1 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + C6DF04871F4F33C500D200B1 /* Build configuration list for PBXNativeTarget "TINU" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C6DF04881F4F33C500D200B1 /* Debug */, + C6DF04891F4F33C500D200B1 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + C6DF048A1F4F33C500D200B1 /* Build configuration list for PBXNativeTarget "TINUTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C6DF048B1F4F33C500D200B1 /* Debug */, + C6DF048C1F4F33C500D200B1 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + C6DF048D1F4F33C500D200B1 /* Build configuration list for PBXNativeTarget "TINUUITests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C6DF048E1F4F33C500D200B1 /* Debug */, + C6DF048F1F4F33C500D200B1 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = C6DF045A1F4F33C500D200B1 /* Project object */; +} diff --git a/TINU.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/TINU.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..557d1ba --- /dev/null +++ b/TINU.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/TINU/.DS_Store b/TINU/.DS_Store new file mode 100644 index 0000000..8963e96 Binary files /dev/null and b/TINU/.DS_Store differ diff --git a/TINU/AppDelegate.swift b/TINU/AppDelegate.swift new file mode 100644 index 0000000..7dfbe66 --- /dev/null +++ b/TINU/AppDelegate.swift @@ -0,0 +1,163 @@ +// +// AppDelegate.swift +// TINU +// +// Created by Pietro Caruso on 24/08/17. +// Copyright © 2017 Pietro Caruso. All rights reserved. +// + +import Cocoa + +@NSApplicationMain +class AppDelegate: NSObject, NSApplicationDelegate { + @IBOutlet weak var verboseItem: NSMenuItem! + @IBOutlet weak var verboseItemSpace: NSMenuItem! + + func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { + return true + } + + func applicationShouldTerminate(_ sender: NSApplication) -> NSApplicationTerminateReply { + if sharedIsPreCreationInProgress{ + msgBox("You can't quit now", "You can't quit from TINU now, wait for the format to end or press the cancel button on the windows that asks for the password, and then quit if you want", .informational) + return NSApplicationTerminateReply.terminateCancel + } + + + if sharedIsCreationInProgress{ + if !dialogYesNo(question: "Installer creation in progress in progess", text: "The installer creation is inprogress do you want to quit?", style: .warning){ + if let i = sharedWindow.contentViewController as? InstallingViewController{ + i.stop() + } + }else{ + return NSApplicationTerminateReply.terminateCancel + } + } + erasePassword() + return NSApplicationTerminateReply.terminateNow + } + + @IBOutlet weak var QuitMenuButton: NSMenuItem! + + func applicationDidFinishLaunching(_ aNotification: Notification) { + // Insert code here to initialize your application + //checkUser() + //checkAppMode() + + if Bundle.main.url(forResource: "DebugScript", withExtension: "sh") == nil || sharedIsOnRecovery{ + verboseItem.isHidden = true + verboseItemSpace.isHidden = true + if !sharedIsOnRecovery{ + print("Verbose mode script not present") + }else{ + print("Verbose mode not usable under recovery") + } + }else{ + verboseItem.isHidden = false + verboseItemSpace.isHidden = false + print("Verbose mode script present") + } + + } + + func applicationWillTerminate(_ aNotification: Notification) { + // Insert code here to tear down your application + + if sharedIsCreationInProgress{ + if let i = sharedWindow.contentViewController as? InstallingViewController{ + i.stop() + } + } + } + @IBAction func OpenGithub(_ sender: Any) { + if let checkURL = NSURL(string: "https://github.com/ITzTravelInTime/TINU") { + if NSWorkspace.shared().open(checkURL as URL) { + print("url successfully opened: " + String(describing: checkURL)) + } + } else { + print("invalid url") + } + } + + @IBAction func InsanelyMacThread(_ sender: Any) { + if let checkURL = NSURL(string: "http://www.insanelymac.com/forum/topic/326959-tinu-the-macos-installer-creator-app-mac-app/") { + if NSWorkspace.shared().open(checkURL as URL) { + print("url successfully opened: " + String(describing: checkURL)) + } + } else { + print("invalid url") + } + } + + private var secondWindowController: ContactsWindowController? + + @IBAction func openContacts(_ sender: Any) { + //open here a window with all the contacts inside + + if secondWindowController == nil { + secondWindowController = ContactsWindowController() + } + + secondWindowController?.showWindow(self) + + } + + private var creditsWindowController: CreditsWindowController? + + @IBAction func openCredits(_ sender: Any) { + //open here a window with all the credits inside + + if creditsWindowController == nil { + creditsWindowController = CreditsWindowController() + } + + creditsWindowController?.showWindow(self) + + } + + @IBAction func VoodooTSCSyncConfigurator(_ sender: Any) { + if let checkURL = NSURL(string: "http://www.insanelymac.com/forum/files/file/744-voodootscsync-configurator/") { + if NSWorkspace.shared().open(checkURL as URL) { + print("url successfully opened: " + String(describing: checkURL)) + } + } else { + print("invalid url") + } + } + + @IBAction func openVerbose(_ sender: Any) { + if !sharedIsCreationInProgress{ + if let f = Bundle.main.url(forResource: "DebugScript", withExtension: "sh"){ + if !sharedIsOnRecovery{ + print("Trying to fix script permitions") + if let e = getErrWithSudo(cmd: "chmod -R 771 \"" + f.path + "\""){ + if e == "" || e == "Password:\n" || e == "Password:" { + print("Script permitions fixed with success") + print("Restarting app with log in the terminal") + NSWorkspace.shared().openFile(f.path, withApplication: "Terminal") + NSApplication.shared().terminate(self) + }else{ + print("Script permitions fix failed") + print("Application not opened: " + e) + } + }else{ + + } + }else{ + //recovery special mode + print("Restarting app with log in the terminal") + NSWorkspace.shared().openFile(f.path, withApplication: "Terminal") + NSApplication.shared().terminate(self) + } + + }else{ + + } + }else{ + msgBox("You can't switch mode now", "The macOS install media creation process is currenly running, please cancel the operation or wait the end of the operation before switching mode", .warning) + } + } + + +} + diff --git a/TINU/Assets.xcassets/AppIcon.appiconset/21100949_475187179526802_1743676795_n-1024.png b/TINU/Assets.xcassets/AppIcon.appiconset/21100949_475187179526802_1743676795_n-1024.png new file mode 100644 index 0000000..1fa1219 Binary files /dev/null and b/TINU/Assets.xcassets/AppIcon.appiconset/21100949_475187179526802_1743676795_n-1024.png differ diff --git a/TINU/Assets.xcassets/AppIcon.appiconset/21100949_475187179526802_1743676795_n-128.png b/TINU/Assets.xcassets/AppIcon.appiconset/21100949_475187179526802_1743676795_n-128.png new file mode 100644 index 0000000..79332ed Binary files /dev/null and b/TINU/Assets.xcassets/AppIcon.appiconset/21100949_475187179526802_1743676795_n-128.png differ diff --git a/TINU/Assets.xcassets/AppIcon.appiconset/21100949_475187179526802_1743676795_n-16.png b/TINU/Assets.xcassets/AppIcon.appiconset/21100949_475187179526802_1743676795_n-16.png new file mode 100644 index 0000000..42e72cb Binary files /dev/null and b/TINU/Assets.xcassets/AppIcon.appiconset/21100949_475187179526802_1743676795_n-16.png differ diff --git a/TINU/Assets.xcassets/AppIcon.appiconset/21100949_475187179526802_1743676795_n-256.png b/TINU/Assets.xcassets/AppIcon.appiconset/21100949_475187179526802_1743676795_n-256.png new file mode 100644 index 0000000..75867dc Binary files /dev/null and b/TINU/Assets.xcassets/AppIcon.appiconset/21100949_475187179526802_1743676795_n-256.png differ diff --git a/TINU/Assets.xcassets/AppIcon.appiconset/21100949_475187179526802_1743676795_n-32.png b/TINU/Assets.xcassets/AppIcon.appiconset/21100949_475187179526802_1743676795_n-32.png new file mode 100644 index 0000000..cda5207 Binary files /dev/null and b/TINU/Assets.xcassets/AppIcon.appiconset/21100949_475187179526802_1743676795_n-32.png differ diff --git a/TINU/Assets.xcassets/AppIcon.appiconset/21100949_475187179526802_1743676795_n-512.png b/TINU/Assets.xcassets/AppIcon.appiconset/21100949_475187179526802_1743676795_n-512.png new file mode 100644 index 0000000..485781b Binary files /dev/null and b/TINU/Assets.xcassets/AppIcon.appiconset/21100949_475187179526802_1743676795_n-512.png differ diff --git a/TINU/Assets.xcassets/AppIcon.appiconset/21100949_475187179526802_1743676795_n-64.png b/TINU/Assets.xcassets/AppIcon.appiconset/21100949_475187179526802_1743676795_n-64.png new file mode 100644 index 0000000..eac1a3c Binary files /dev/null and b/TINU/Assets.xcassets/AppIcon.appiconset/21100949_475187179526802_1743676795_n-64.png differ diff --git a/TINU/Assets.xcassets/AppIcon.appiconset/Contents.json b/TINU/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..0da6bc8 --- /dev/null +++ b/TINU/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,68 @@ +{ + "images" : [ + { + "size" : "16x16", + "idiom" : "mac", + "filename" : "21100949_475187179526802_1743676795_n-16.png", + "scale" : "1x" + }, + { + "size" : "16x16", + "idiom" : "mac", + "filename" : "21100949_475187179526802_1743676795_n-32.png", + "scale" : "2x" + }, + { + "size" : "32x32", + "idiom" : "mac", + "filename" : "21100949_475187179526802_1743676795_n-32.png", + "scale" : "1x" + }, + { + "size" : "32x32", + "idiom" : "mac", + "filename" : "21100949_475187179526802_1743676795_n-64.png", + "scale" : "2x" + }, + { + "size" : "128x128", + "idiom" : "mac", + "filename" : "21100949_475187179526802_1743676795_n-128.png", + "scale" : "1x" + }, + { + "size" : "128x128", + "idiom" : "mac", + "filename" : "21100949_475187179526802_1743676795_n-256.png", + "scale" : "2x" + }, + { + "size" : "256x256", + "idiom" : "mac", + "filename" : "21100949_475187179526802_1743676795_n-256.png", + "scale" : "1x" + }, + { + "size" : "256x256", + "idiom" : "mac", + "filename" : "21100949_475187179526802_1743676795_n-512.png", + "scale" : "2x" + }, + { + "size" : "512x512", + "idiom" : "mac", + "filename" : "21100949_475187179526802_1743676795_n-512.png", + "scale" : "1x" + }, + { + "size" : "512x512", + "idiom" : "mac", + "filename" : "21100949_475187179526802_1743676795_n-1024.png", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/TINU/Assets.xcassets/Contents.json b/TINU/Assets.xcassets/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/TINU/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/TINU/Assets.xcassets/check-1.imageset/Contents.json b/TINU/Assets.xcassets/check-1.imageset/Contents.json new file mode 100644 index 0000000..e57fdb5 --- /dev/null +++ b/TINU/Assets.xcassets/check-1.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "check.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/TINU/Assets.xcassets/check-1.imageset/check.png b/TINU/Assets.xcassets/check-1.imageset/check.png new file mode 100644 index 0000000..d5986b4 Binary files /dev/null and b/TINU/Assets.xcassets/check-1.imageset/check.png differ diff --git a/TINU/Assets.xcassets/check.imageset/Contents.json b/TINU/Assets.xcassets/check.imageset/Contents.json new file mode 100644 index 0000000..e57fdb5 --- /dev/null +++ b/TINU/Assets.xcassets/check.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "check.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/TINU/Assets.xcassets/check.imageset/check.png b/TINU/Assets.xcassets/check.imageset/check.png new file mode 100644 index 0000000..d5986b4 Binary files /dev/null and b/TINU/Assets.xcassets/check.imageset/check.png differ diff --git a/TINU/Assets.xcassets/logo.imageset/Contents.json b/TINU/Assets.xcassets/logo.imageset/Contents.json new file mode 100644 index 0000000..8463aca --- /dev/null +++ b/TINU/Assets.xcassets/logo.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "logo.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/TINU/Assets.xcassets/logo.imageset/logo.png b/TINU/Assets.xcassets/logo.imageset/logo.png new file mode 100644 index 0000000..39c9553 Binary files /dev/null and b/TINU/Assets.xcassets/logo.imageset/logo.png differ diff --git a/TINU/Assets.xcassets/uncheck.imageset/Contents.json b/TINU/Assets.xcassets/uncheck.imageset/Contents.json new file mode 100644 index 0000000..2d76bb7 --- /dev/null +++ b/TINU/Assets.xcassets/uncheck.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "uncheck.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/TINU/Assets.xcassets/uncheck.imageset/uncheck.png b/TINU/Assets.xcassets/uncheck.imageset/uncheck.png new file mode 100644 index 0000000..60ef1ff Binary files /dev/null and b/TINU/Assets.xcassets/uncheck.imageset/uncheck.png differ diff --git a/TINU/Assets.xcassets/warning.imageset/Contents.json b/TINU/Assets.xcassets/warning.imageset/Contents.json new file mode 100644 index 0000000..6669f58 --- /dev/null +++ b/TINU/Assets.xcassets/warning.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "warning-2.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/TINU/Assets.xcassets/warning.imageset/warning-2.png b/TINU/Assets.xcassets/warning.imageset/warning-2.png new file mode 100644 index 0000000..87bfe86 Binary files /dev/null and b/TINU/Assets.xcassets/warning.imageset/warning-2.png differ diff --git a/TINU/Base.lproj/Main.storyboard b/TINU/Base.lproj/Main.storyboard new file mode 100644 index 0000000..1809580 --- /dev/null +++ b/TINU/Base.lproj/Main.storyboard @@ -0,0 +1,1363 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + If you go ahead, this will erase the drive you selected, and all the data on it will be lost and replaced with the macOS installer, if you are sure, continue at your own risk. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This is a tool that helps you to create a macOS install media.
Before starting you need:

 - At least an 8 GB USB Flash Drive
 - A copy of the macOS installer app (Mavericks or more recent version) in your mac in your /Applications folder or in the root of a storage device connected to the computer
 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/TINU/ChoseAppViewController.swift b/TINU/ChoseAppViewController.swift new file mode 100644 index 0000000..9c8f355 --- /dev/null +++ b/TINU/ChoseAppViewController.swift @@ -0,0 +1,215 @@ +// +// ChoseAppViewController.swift +// TINU +// +// Created by Pietro Caruso on 26/08/17. +// Copyright © 2017 Pietro Caruso. All rights reserved. +// + +import Cocoa + +class ChoseAppViewController: NSViewController { + @IBOutlet weak var background: NSVisualEffectView! + + private var empty: Bool = false{ + didSet{ + scoller.frame = CGRect.init(x: 20, y: scoller.frame.origin.y, width: self.view.frame.width - 40, height: scoller.frame.height) + if self.empty{ + scoller.drawsBackground = false + scoller.borderType = .noBorder + ok.title = "Quit" + ok.isEnabled = true + }else{ + if sharedUseVibrant && !sharedIsOnRecovery { + scoller.drawsBackground = false + scoller.borderType = .noBorder + scoller.frame = CGRect.init(x: 0, y: scoller.frame.origin.y, width: self.view.frame.width, height: scoller.frame.height) + }else{ + scoller.drawsBackground = true + scoller.borderType = .bezelBorder + } + ok.title = "Next" + ok.isEnabled = false + } + } + } + + @IBOutlet weak var ok: NSButton! + + @IBOutlet weak var spinner: NSProgressIndicator! + + private var ps: Bool! + //private var fs: Bool! + + @IBAction func goBack(_ sender: Any) { + let _ = openSubstituteWindow(windowStoryboardID: "ChoseDrive", sender: self) + } + + @IBAction func next(_ sender: Any) { + if !empty{ + sharedVolumeNeedsPartitionMethodChange = ps + //sharedVolumeNeedsFormat = fs + let _ = openSubstituteWindow(windowStoryboardID: "Confirm", sender: sender) + }else{ + NSApplication.shared().terminate(self) + } + } + @IBAction func refreshPressed(_ sender: Any) { + loadApps() + } + + @IBOutlet weak var scoller: NSScrollView! + + override func viewDidLoad() { + super.viewDidLoad() + // Do view setup here. + if sharedIsOnRecovery || !sharedUseVibrant { + background.isHidden = true + } + + loadApps() + } + + private func loadApps(){ + print(sharedVolumeNeedsPartitionMethodChange) + //print(sharedVolumeNeedsFormat) + + ps = sharedVolumeNeedsPartitionMethodChange + //fs = sharedVolumeNeedsFormat + + scoller.isHidden = true + spinner.isHidden = false + spinner.startAnimation(self) + + print("--- Apps detection started") + scoller.documentView = NSView(frame: scoller.frame) + scoller.hasHorizontalScroller = false + + var tot: CGFloat = 10 + + sharedApp = nil + + //here loads drives + //let keys: [URLResourceKey] = [.volumeNameKey, .volumeIsRemovableKey] + + var drives = [DriveObject]() + + ok.isEnabled = false + + var dirs = [String]() + + DispatchQueue.global(qos: .userInitiated).async { + let fm = FileManager.default + + var documentsUrls = [URL?]() + + if !sharedIsOnRecovery{ + documentsUrls = [fm.urls(for: .applicationDirectory, in: .systemDomainMask).first, fm.urls(for: .desktopDirectory, in: .userDomainMask).first, fm.urls(for: .downloadsDirectory, in: .userDomainMask).first, fm.urls(for: .documentDirectory, in: .userDomainMask).first] + } + + for d in FileManager.default.mountedVolumeURLs(includingResourceValuesForKeys: [URLResourceKey.isVolumeKey], options: [.skipHiddenVolumes])!{ + let p = d.path + if p != getDriveNameFromBSDID(sharedBSDDrive){ + + documentsUrls.append(d) + + var isDir : ObjCBool = false + if FileManager.default.fileExists(atPath: p + "/Applications", isDirectory: &isDir){ + if isDir.boolValue && d.path != "/"{ + documentsUrls.append(URL(fileURLWithPath: p + "/Applications")) + } + } + + } + } + + //documentsUrls += [URL(fileURLWithPath: "/Volumes/Image Volume", isDirectory: true)] + + print("This contains the urls for the paths in witch we will try find the installation apps") + print(documentsUrls) + print("Starting installation apps scan ...") + + + do { + for dd in documentsUrls{ + if let d = dd{ + print("Scanning for usable apps in \(d.path)") + let fileNames = try FileManager.default.contentsOfDirectory(at: d, includingPropertiesForKeys: nil, options: []).filter{ $0.pathExtension == "app" }.map{ $0.path } + for f in fileNames{ + if FileManager.default.fileExists(atPath: f + "/Contents/Resources/" + sharedExecutableName) && !dirs.contains(f){ + print("An new app that contains the createinstallmedia has been found") + DispatchQueue.main.sync { + dirs.append(f) + + let drive = DriveObject(frame: NSRect(x: tot, y: 20, width: 130, height: 150)) + drive.frame.origin.y = (self.scoller.frame.height - 20) / 2 - drive.frame.height / 2 + drive.isApp = true + drive.applicationPath = f + print(" App path is " + f) + drive.image.image = NSWorkspace.shared().icon(forFile: f)//NSImage(named: "logo.png") + drive.volume.stringValue = FileManager.default.displayName(atPath: f) + print(" App name is " + drive.volume.stringValue) + drives.append(drive) + tot += 130 + } + } + } + } + } + + } catch let error as NSError { + print(error.localizedDescription) + } + + + print("Apps scanning finished, \(dirs.count) app/s found") + + print("--- App detection complete") + + var content = NSView(frame: NSRect(x: 0, y: 0, width: tot, height: self.scoller.frame.size.height - 20)) + + DispatchQueue.main.sync { + self.scoller.hasHorizontalScroller = true + self.scoller.hasVerticalScroller = false + + var res = (dirs.count == 0) + + //just to test the screen when there are no apps found + if simulateNoUsableApps{ + res = true + } + + self.empty = res + + if res { + //fail :( + print("No usable installation apps where found!") + let label = NSTextField(frame: self.scoller.frame) + label.stringValue = "No usable macOS installer apps found" + label.frame.size.width -= 10 + label.alignment = .center + label.isEditable = false + label.isBordered = false + label.font = NSFont.systemFont(ofSize: 20) + label.frame.origin = CGPoint(x: 0, y: (self.scoller.frame.size.height / 2) - 15) + label.frame.size.height = 30 + label.drawsBackground = false + content = NSView(frame: NSRect(x: 0, y: 0, width: self.scoller.frame.size.width - 10, height: self.scoller.frame.size.height - 10)) + content.addSubview(label) + self.scoller.hasHorizontalScroller = false + }else{ + for d in drives.reversed(){ + content.addSubview(d) + } + } + self.scoller.documentView = content + + self.spinner.stopAnimation(self) + self.spinner.isHidden = true + self.scoller.isHidden = false + } + + } + } + +} diff --git a/TINU/ChoseDriveViewController.swift b/TINU/ChoseDriveViewController.swift new file mode 100644 index 0000000..81de356 --- /dev/null +++ b/TINU/ChoseDriveViewController.swift @@ -0,0 +1,526 @@ +// +// ChoseDriveViewController.swift +// TINU +// +// Created by Pietro Caruso on 24/08/17. +// Copyright © 2017 Pietro Caruso. All rights reserved. +// + +import Cocoa + +class ChoseDriveViewController: NSViewController { + @IBOutlet weak var scoller: NSScrollView! + @IBOutlet weak var ok: NSButton! + @IBOutlet weak var spinner: NSProgressIndicator! + @IBOutlet weak var background: NSVisualEffectView! + + private var empty: Bool = false{ + didSet{ + scoller.frame = CGRect.init(x: 20, y: scoller.frame.origin.y, width: self.view.frame.width - 40, height: scoller.frame.height) + if self.empty{ + scoller.drawsBackground = false + scoller.borderType = .noBorder + ok.title = "Quit" + ok.isEnabled = true + }else{ + if sharedUseVibrant && !sharedIsOnRecovery { + scoller.drawsBackground = false + scoller.borderType = .noBorder + scoller.frame = CGRect.init(x: 0, y: scoller.frame.origin.y, width: self.view.frame.width, height: scoller.frame.height) + }else{ + scoller.drawsBackground = true + scoller.borderType = .bezelBorder + } + + ok.title = "Next" + ok.isEnabled = false + } + } + } + + @IBAction func refresh(_ sender: Any) { + updateDrives() + } + + override func viewDidLoad() { + super.viewDidLoad() + // Do view setup here. + if sharedIsOnRecovery || !sharedUseVibrant { + background.isHidden = true + } + + updateDrives() + } + + private func updateDrives(){ + self.scoller.isHidden = true + self.spinner.isHidden = false + self.spinner.startAnimation(self) + + print("--- Detectin usable drives and volumes") + scoller.documentView = NSView() + + ok.isEnabled = false + + var tot: CGFloat = 10 + + sharedVolume = nil + sharedBSDDrive = nil + + //sharedVolumeNeedsFormat = nil + sharedVolumeNeedsPartitionMethodChange = nil + + //here loads drives + //let keys: [URLResourceKey] = [.volumeNameKey, .volumeIsRemovableKey] + + var drives = [DriveObject]() + + self.ok.isEnabled = false + + //this code just does the parsing of the diskutil list command + DispatchQueue.global(qos: .userInitiated).async { + + let (output, _, _) = runCommand(cmd: "/bin/sh", args: ["-c", "diskutil list"]) + + //print(output) + //print(error) + //print(status) + + var drvs = [Part]() + var currentDrv: Part! + + var otherFS = "Apple_HFS" + + if #available(OSX 10.13, *){ + print("We are on High Sierra or a more recent version of mac, let's activate APFS support") + otherFS = "APFS" + } + + for i in output{ + var c = i.components(separatedBy: CharacterSet.whitespacesAndNewlines).split(separator: "") + //print(c) + if !c.isEmpty{ + if let d = c.first?.first{ + if d.contains("/dev/disk"){ + currentDrv = Part() + print("Scanning new drive") + continue + } + } + c.remove(at: 0) + + if let f = c.first?.first{ + if f == "TYPE" || f.isEmpty { + continue + }else if f == "Apple_Boot" || f == "Apple_CoreStorage" || f == "Apple_partition_map" /*|| f == "Linux" || f == "Linux_Swap"*/{ + print(" volume not usable") + continue + }else if f == "GUID_partition_scheme"{ + currentDrv.partScheme = "GUID_partition_scheme" + print(" this drive is guid") + }else if f == "FDisk_partition_scheme"{ + currentDrv.partScheme = "FDisk_partition_scheme" + print(" this drive is not guid: MBR") + + if !self.checkDriveSize(c, true){ + currentDrv.partScheme = "" + continue + } + + }else if f == "Apple_partition_scheme"{ + + currentDrv.partScheme = "Apple_partition_scheme" + print(" this drive is not guid: Apple") + + if !self.checkDriveSize(c, true){ + currentDrv.partScheme = "" + continue + } + }else if f == "EFI"{ + if c.first?.count == 2{ + var cc = c.first! + cc.remove(at: cc.startIndex) + if cc.first == "EFI"{ + currentDrv.hasEFI = true + print(" this drive has an efi partition") + } + } + }else{ + if currentDrv.partScheme.isEmpty{ + print(" this drive is not usable") + continue + } + + let drv = currentDrv.copy() + + drv.bsdName += (c.last?.last)! + + if currentDrv.partScheme == "GUID_partition_scheme"{ + if !self.checkDriveSize(c, false) { + continue + } + } + + c.remove(at: c.count - 1) + + print(" this volume will be added:") + if f == "Apple_HFS"{ + drv.fileSystem = "HFS+" + print(" volume File System is HFS") + }else if f == otherFS{ + drv.fileSystem = "APFS" + print(" volume File System is APFS") + }else{ + drv.fileSystem = "Other" + print(" volume File System is not HFS+ or APFS") + } + + //print(" volume capacity is: \(sz) MB") + print(" volume BSD name is: " + drv.bsdName) + + if c.count == 1{ + var d = c.first! + c.remove(at: 0) + d.remove(at: d.startIndex) + //print(d) + d.remove(at: d.endIndex - 1) + d.remove(at: d.endIndex - 1) + c.append(d) + }else{ + c.remove(at: c.count - 1) + var d = c.first! + c.remove(at: 0) + d.remove(at: d.startIndex) + c.append(d) + } + + if let cc = c.first{ + for ccc in cc{ + + drv.name += ccc + " " + } + if !drv.name.isEmpty{ + drv.name.characters.removeLast(1) + }else{ + continue + } + } + + + drv.path += drv.name + + if drv.name.contains("...") || !FileManager.default.fileExists(atPath: drv.path){ + print(" volume needs a fix for it's name") + if let path = getDriveNameFromBSDID(drv.bsdName){ + drv.path = path + drv.name = FileManager.default.displayName(atPath: path) + } + } + + print(" volume name is " + drv.name) + + let drive = DriveObject(frame: NSRect(x: tot, y: 20, width: 130, height: 150)) + drive.frame.origin.y = (self.scoller.frame.height - 20) / 2 - drive.frame.height / 2 + drive.isApp = false + drive.volumePath = drv.path + drive.image.image = NSWorkspace.shared().icon(forFile: drv.path)//NSImage(named: "logo.png") + drive.volume.stringValue = drv.name + drive.volumeBSD = drv.bsdName + drive.part = drv + + drives.append(drive) + drvs.append(drv) + tot += 130 + } + }else{ + continue + } + } + } + /* + if i.contains("GUID_partition_scheme"){ + currentDrv.partScheme = "GUID_partition_scheme" + print(" this drive is guid") + }else if i.contains("FDisk_partition_scheme"){ + currentDrv.partScheme = "FDisk_partition_scheme" + print(" this drive is not guid: MBR") + }else if (i.contains("Apple_partition_scheme") || i.contains("Apple_partition_map")){ + if currentDrv.partScheme.isEmpty{ + currentDrv.partScheme = "Apple_partition_scheme" + print(" this drive is not guid: Apple") + } + }else if i.contains("/dev/disk"){ + currentDrv = Part() + print("Scanning new drive") + }else if i.contains("EFI EFI"){ + currentDrv.hasEFI = true + print(" this drive has an efi partition") + }else{ + if currentDrv.partScheme.isEmpty{ + continue + } + + if !c.isEmpty{ + + //if (i.contains("Apple_HFS")) || i.contains(otherFS) || (i.contains("DOS_FAT_32")) || (i.contains("Microsoft Basic Data")) || (i.contains("Windows_NTFS")){ + + /*if !currentDrv.hasEFI{ + print(" this drive has not an efi partition") + }*/ + let drv = currentDrv.copy() + + if f == "TYPE" || f == "Apple_Boot" || f == "Apple_CoreStorage" || f.isEmpty{ + continue + }else if f == "Apple_HFS"{ + drv.fileSystem = "HFS+" + print(" volume File System is HFS") + }else if f == otherFS{ + drv.fileSystem = "APFS" + print(" volume File System is APFS") + }else{ + drv.fileSystem = "Other" + print(" volume File System is not HFS+ or APFS") + } + + print(" this volume will be added:") + + drv.bsdName += (c.last?.last)! + print(" volume BSD name is: " + drv.bsdName) + + c.remove(at: c.count - 1) + if c.count == 1{ + var d = c.first! + c.remove(at: 0) + d.remove(at: d.startIndex) + //print(d) + d.remove(at: d.endIndex - 1) + d.remove(at: d.endIndex - 1) + c.append(d) + }else{ + c.remove(at: c.count - 1) + var d = c.first! + c.remove(at: 0) + d.remove(at: d.startIndex) + c.append(d) + } + + if let cc = c.first{ + for ccc in cc{ + + drv.name += ccc + " " + } + drv.name.characters.removeLast(1) + } + + drv.path += drv.name + + if drv.name.contains("...") || !FileManager.default.fileExists(atPath: drv.path){ + print(" volume needs a fix for it's name") + if let path = getDriveNameFromBSDID(drv.bsdName){ + drv.path = path + drv.name = FileManager.default.displayName(atPath: path) + } + } + + print(" volume name is " + drv.name) + + let drive = DriveObject(frame: NSRect(x: tot, y: 10, width: 150, height: 170)) + drive.isApp = false + drive.volumePath = drv.path + drive.image.image = NSWorkspace.shared().icon(forFile: drv.path)//NSImage(named: "logo.png") + drive.volume.stringValue = drv.name + drive.volumeBSD = drv.bsdName + drive.part = drv + + drives.append(drive) + drvs.append(drv) + tot += 160 + */ + //} + //} + /* + if let urls = FileManager().mountedVolumeURLs(includingResourceValuesForKeys: keys, options: []) { + for url in urls { + let components = url.pathComponents + if components.count > 1 + && components[1] == "Volumes" + { + + for v in drvs{ + + let n = components[2] + if n == v.name{ + let drive = DriveObject(frame: NSRect(x: tot, y: 20, width: 130, height: 170)) + drive.volumePath = "/Volumes/" + n + drive.image.image = NSWorkspace.shared().icon(forFile: "/Volumes/" + n)//NSImage(named: "logo.png") + + + drive.volume.stringValue = n + + drives.append(drive) + + tot += 140 + + + + } + } + } + } + }else{ + + }*/ + + //drvs.removeAll() + + DispatchQueue.main.sync { + var content = NSView(frame: NSRect(x: 0, y: 0, width: tot, height: self.scoller.frame.size.height - 20)) + content.backgroundColor = NSColor.white.withAlphaComponent(0) + + + self.scoller.hasVerticalScroller = false + self.scoller.hasHorizontalScroller = true + + var res = (drvs.count == 0) + + //this is just to test if there are no usable drives + if simulateNoUsableDrives { + res = true + } + + self.empty = res + + if res{ + print("No usable drives found!") + //fail :( + let label = NSTextField(frame: self.scoller.frame) + label.frame.size.width -= 10 + label.stringValue = "No usable drives or devices found" + label.alignment = .center + label.isEditable = false + label.isBordered = false + label.font = NSFont.systemFont(ofSize: 20) + label.frame.origin = CGPoint(x: 0, y: (self.scoller.frame.size.height / 2) - 15) + label.drawsBackground = false + label.frame.size.height = 30 + content = NSView(frame: NSRect(x: 0, y: 0, width: self.scoller.frame.size.width - 10, height: self.scoller.frame.size.height - 10)) + content.addSubview(label) + + self.scoller.hasHorizontalScroller = false + }else{ + var temp: CGFloat = 10 + for d in drives.reversed(){ + d.frame.origin.x = temp + temp += d.frame.width + content.addSubview(d) + } + } + self.scoller.documentView = content + self.scoller.isHidden = false + self.spinner.isHidden = true + self.spinner.stopAnimation(self) + + } + } + } + + @IBAction func goBack(_ sender: Any) { + if showLicense{ + let _ = openSubstituteWindow(windowStoryboardID: "License", sender: self) + }else{ + let _ = openSubstituteWindow(windowStoryboardID: "Info", sender: self) + } + } + + @IBAction func next(_ sender: Any) { + if !empty{ + if sharedVolumeNeedsPartitionMethodChange != nil /*&& sharedVolumeNeedsFormat != nil*/{ + /* + if sharedVolumeNeedsFormat{ + if dialogOKCancel(question: "Format the volume?", text: "This volume will be erased to be used to create a macOS install media, this will permanently erase all the data on it, do you want to continue?", style: .warning){ + return + } + }else*/ if sharedVolumeNeedsPartitionMethodChange{ + if dialogOKCancel(question: "Format the drive?", text: "This drive needs to be formatted to be used to craete a macOS install media, all the data in it will be erased, do you want ot continue?", style: .warning){ + return + } + } + } + let _ = openSubstituteWindow(windowStoryboardID: "ChoseApp", sender: self) + }else{ + NSApplication.shared().terminate(sender) + } + } + + private func checkDriveSize(_ cc: [ArraySlice], _ isDrive: Bool) -> Bool{ + var c = cc + + c.remove(at: c.count - 1) + + var sz: Float = 0 + + if c.count == 1{ + let f: String = (c.last?.last!)! + var cl = c.last! + cl.remove(at: cl.index(before: cl.endIndex)) + let ff: String = cl.last! + + c.removeAll() + + c.append([ff, f]) + + } + + if var n = c.last?.first{ + if isDrive{ + n.characters.remove(at: n.startIndex) + }else{ + let s = String(describing: n.characters.first) + if s == "*" || s == "+"{ + print(" volume size is not fixed, skipping it") + return false + } + } + + if let s = Float(n){ + sz = s + } + } + + if let n = c.last?.last{ + if n == "KB"{ + sz /= 1024 + }else if n == "GB"{ + sz *= 1024 + }else if n == "TB"{ + sz *= 1024 * 1024 + }else if n != "MB"{ + if isDrive{ + print(" this drive has a size unit unkown, skipping this drive") + }else{ + print(" volume size unit unkown, skipping this volume") + } + return false + } + } + + var minSize: Float = 7000 + if sharedInstallMac{ + minSize = 20000 + } + + if sz <= minSize{ + if isDrive{ + print(" this drive is too small to be used for a macOS installer, skipping this drive") + }else{ + print(" this volume too small for a macOS installer") + } + return false + } + + return true + } + +} + + diff --git a/TINU/ConfirmViewController.swift b/TINU/ConfirmViewController.swift new file mode 100644 index 0000000..754420e --- /dev/null +++ b/TINU/ConfirmViewController.swift @@ -0,0 +1,146 @@ +// +// ConfirmViewController.swift +// TINU +// +// Created by Pietro Caruso on 26/08/17. +// Copyright © 2017 Pietro Caruso. All rights reserved. +// + +import Cocoa + +class ConfirmViewController: NSViewController { + + @IBOutlet weak var driveName: NSTextField! + @IBOutlet weak var driveImage: NSImageView! + + @IBOutlet weak var appImage: NSImageView! + @IBOutlet weak var appName: NSTextField! + @IBOutlet weak var warning: NSImageView! + @IBOutlet weak var background: NSVisualEffectView! + + var notDone = false + + private var ps: Bool! + //private var fs: Bool! + + override func viewDidLoad() { + super.viewDidLoad() + // Do view setup here. + + if sharedIsOnRecovery || !sharedUseVibrant { + background.isHidden = true + } + + print(sharedVolumeNeedsPartitionMethodChange) + //print(sharedVolumeNeedsFormat) + + ps = sharedVolumeNeedsPartitionMethodChange + //fs = sharedVolumeNeedsFormat + + if let w = sharedWindow{ + w.isClosingEnabled = true + w.isMiniaturizeEnaled = true + } + + if let a = NSApplication.shared().delegate as? AppDelegate{ + a.QuitMenuButton.isEnabled = true + } + + notDone = false + + if let sa = sharedApp{ + print(sa) + appImage.image = NSWorkspace.shared().icon(forFile: sa) + appName.stringValue = FileManager.default.displayName(atPath: sa) + print("Installation app that will be used is: " + sa) + }else{ + notDone = true + } + + + + if let sv = sharedVolume{ + print(sv) + var sr = sv + + + if !FileManager.default.fileExists(atPath: sv){ + if let sb = sharedBSDDrive{ + + sr = getDriveNameFromBSDID(sb) + sharedVolume = sr + + print("corrected the name of the target volume" + sr) + }else{ + notDone = true + } + } + + driveImage.image = NSWorkspace.shared().icon(forFile: sr) + driveName.stringValue = FileManager.default.displayName(atPath: sr) + + print("The target volume is: " + sr) + }else{ + notDone = true + } + + //just to simulate a failure to get data for the drive and the app + if simulateConfirmGetDataFail{ + notDone = true + } + + if notDone { + print("Couldn't get valid info about the installation app and/or the drive") + //yes.isEnabled = false + + yes.title = "Quit" + info.isHidden = true + + driveName.isHidden = true + driveImage.isHidden = true + + appImage.isHidden = true + appName.isHidden = true + + titleLabel.stringValue = "Impossible to create the macOS install meadia" + + let label = NSTextField(frame: NSRect(x: titleLabel.frame.origin.x, y: self.view.frame.size.height / 2 - 15, width: titleLabel.frame.size.width, height: 30)) + label.isEditable = false + label.isBordered = false + label.font = NSFont.systemFont(ofSize: 25) + label.stringValue = "There was an error while getting app and drive data 🙁" + label.alignment = .center + label.isSelectable = false + label.drawsBackground = false + + self.warning.isHidden = true + + self.view.addSubview(label) + }else{ + print("Everything is ready to start the installer creation process") + } + + } + @IBOutlet weak var info: NSTextField! + @IBOutlet weak var yes: NSButton! + @IBOutlet weak var titleLabel: NSTextField! + + @IBAction func goBack(_ sender: Any) { + sharedVolumeNeedsPartitionMethodChange = ps + //sharedVolumeNeedsFormat = fs + let _ = openSubstituteWindow(windowStoryboardID: "ChoseApp", sender: sender) + } + + @IBAction func install(_ sender: Any) { + sharedVolumeNeedsPartitionMethodChange = ps + //sharedVolumeNeedsFormat = fs + if notDone{ + NSApp.terminate(sender) + return + } + + let _ = openSubstituteWindow(windowStoryboardID: "Install", sender: sender) + + } + +} diff --git a/TINU/ContactsViewController.swift b/TINU/ContactsViewController.swift new file mode 100644 index 0000000..1417760 --- /dev/null +++ b/TINU/ContactsViewController.swift @@ -0,0 +1,28 @@ +// +// ContactsViewController.swift +// TINU +// +// Created by Pietro Caruso on 05/09/17. +// Copyright © 2017 Pietro Caruso. All rights reserved. +// + +import Cocoa + +class ContactsViewController: NSViewController { + @IBOutlet weak var background: NSVisualEffectView! + + override func viewDidLoad() { + super.viewDidLoad() + // Do view setup here. + if sharedIsOnRecovery || !sharedUseVibrant { + background.isHidden = true + } + } + + @IBAction func closeWindow(_ sender: Any) { + if let w = self.window{ + w.close() + } + } + +} diff --git a/TINU/ContactsWindowController.swift b/TINU/ContactsWindowController.swift new file mode 100644 index 0000000..61504d9 --- /dev/null +++ b/TINU/ContactsWindowController.swift @@ -0,0 +1,37 @@ +// +// ContactsWindowController.swift +// TINU +// +// Created by Pietro Caruso on 05/09/17. +// Copyright © 2017 Pietro Caruso. All rights reserved. +// + +import Cocoa + +class ContactsWindowController: NSWindowController { + + override func windowDidLoad() { + super.windowDidLoad() + //sets window + self.window?.isFullScreenEnaled = false + self.window?.title = sharedWindowTitlePrefix + ": Contact us" + + if sharedUseVibrant && !sharedIsOnRecovery { + self.window?.titleVisibility = .hidden + self.window?.titlebarAppearsTransparent = true + self.window?.styleMask.insert(.fullSizeContentView) + self.window?.isMovableByWindowBackground = true + + if sharedTestingMode{ + self.window?.titleVisibility = .visible + } + } + } + + convenience init() { + //creates an instace of the window + self.init(window: (sharedStoryboard.instantiateController(withIdentifier: "Contacts") as! NSWindowController).window) + //self.init(windowNibName: "ContactsWindowController") + } + +} diff --git a/TINU/CreditsViewController.swift b/TINU/CreditsViewController.swift new file mode 100644 index 0000000..2120c08 --- /dev/null +++ b/TINU/CreditsViewController.swift @@ -0,0 +1,30 @@ +// +// CreditsViewController.swift +// TINU +// +// Created by ITzTravelInTime on 08/09/17. +// Copyright © 2017 Pietro Caruso. All rights reserved. +// + +import Foundation +import Cocoa + +class CreditsViewController: NSViewController { + + @IBOutlet weak var background: NSVisualEffectView! + + override func viewDidLoad() { + super.viewDidLoad() + // Do view setup here. + if sharedIsOnRecovery || !sharedUseVibrant { + background.isHidden = true + } + } + + @IBAction func closeWindow(_ sender: Any) { + if let w = self.window{ + w.close() + } + } + +} diff --git a/TINU/CreditsWindwController.swift b/TINU/CreditsWindwController.swift new file mode 100644 index 0000000..b9f9007 --- /dev/null +++ b/TINU/CreditsWindwController.swift @@ -0,0 +1,37 @@ +// +// CreditsWindwController.swift +// TINU +// +// Created by ITzTravelInTime on 08/09/17. +// Copyright © 2017 Pietro Caruso. All rights reserved. +// + +import Cocoa + +class CreditsWindowController: NSWindowController { + + override func windowDidLoad() { + super.windowDidLoad() + //sets the window + self.window?.isFullScreenEnaled = false + self.window?.title = sharedWindowTitlePrefix + ": Credits" + + if sharedUseVibrant && !sharedIsOnRecovery { + self.window?.titleVisibility = .hidden + self.window?.titlebarAppearsTransparent = true + self.window?.styleMask.insert(.fullSizeContentView) + self.window?.isMovableByWindowBackground = true + + if sharedTestingMode{ + self.window?.titleVisibility = .visible + } + } + } + + convenience init() { + //creates an istance of the window + self.init(window: (sharedStoryboard.instantiateController(withIdentifier: "Credits") as! NSWindowController).window) + //self.init(windowNibName: "ContactsWindowController") + } + +} diff --git a/TINU/DebugScript.sh b/TINU/DebugScript.sh new file mode 100755 index 0000000..c9b8696 --- /dev/null +++ b/TINU/DebugScript.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +# DebugScript.sh +# TINU +# +# Created by Pietro Caruso on 20/09/17. +# Copyright © 2017 Pietro Caruso. All rights reserved. +echo "Staring running TINU in log mode" +"$(dirname "$(dirname "$0")")/MacOS/TINU" diff --git a/TINU/DriveObject.swift b/TINU/DriveObject.swift new file mode 100644 index 0000000..d363b5a --- /dev/null +++ b/TINU/DriveObject.swift @@ -0,0 +1,120 @@ +// +// DriveObject.swift +// TINU +// +// Created by Pietro Caruso on 24/08/17. +// Copyright © 2017 Pietro Caruso. All rights reserved. +// + +import Foundation +import Cocoa + +class DriveObject: NSView { + + override init(frame: NSRect){ + super.init(frame: frame) + + //self.borderColor = NSColor.red.cgColor + //self.backgroundColor = NSColor.blue + self.layer?.cornerRadius = 15 + + image = NSImageView(frame: NSRect(x: 5, y: 40, width: self.frame.size.width - 10, height: self.frame.size.height - 50)) + image.isEditable = false + image.imageAlignment = .alignCenter + image.imageScaling = .scaleProportionallyUpOrDown + self.addSubview(image) + + volume = NSTextField(frame: NSRect(x: 5, y: -5, width: self.frame.size.width - 10, height: 40)) + volume.font = NSFont.boldSystemFont(ofSize: 10) + volume.stringValue = "" + volume.isEditable = false + volume.isBordered = false + volume.alignment = .center + volume.backgroundColor = NSColor.white.withAlphaComponent(0) + + //volume.isSelectable = false + self.addSubview(volume) + } + + required init?(coder: NSCoder) { + super.init(coder: coder) + } + + public var isApp = false + + public var volumePath = "" + public var volumeBSD = "" + public var applicationPath = "" + + public var part: Part! + + var image = NSImageView() + var volume = NSTextField() + + override func draw(_ dirtyRect: NSRect) { + super.draw(dirtyRect) + + // Drawing code here. + //self.setDefaultAspect() + } + + override func mouseDown(with event: NSEvent) { + + for c in (self.superview?.subviews)!{ + if let d = c as? DriveObject{ + d.setDefaultAspect() + } + } + + setSelectedAspect() + + if !isApp{ + //sharedVolumeNeedsFormat = nil + sharedVolumeNeedsPartitionMethodChange = nil + + if part != nil{ + if part.partScheme != "GUID_partition_scheme" || !part.hasEFI{ + sharedVolumeNeedsPartitionMethodChange = true + /*}else{ + sharedVolumeNeedsPartitionMethodChange = false*/ + } + + /* + if part.fileSystem == "Other" && !sharedVolumeNeedsPartitionMethodChange{ + sharedVolumeNeedsFormat = true + }else{ + sharedVolumeNeedsFormat = false + }*/ + } + + sharedVolume = volumePath + sharedBSDDrive = volumeBSD + Swift.print("The volume that the user has selected is: " + volumePath) + if let s = self.window?.contentViewController as? ChoseDriveViewController{ + s.ok.isEnabled = true + } + }else{ + sharedApp = applicationPath + Swift.print("The application that the user has selected is: " + applicationPath) + if let s = self.window?.contentViewController as? ChoseAppViewController{ + s.ok.isEnabled = true + } + } + + } + + public func setDefaultAspect(){ + //self.layer?.backgroundColor = NSColor.white.withAlphaComponent(0).cgColor + self.backgroundColor = NSColor.white.withAlphaComponent(0) + volume.textColor = NSColor.black + + } + + public func setSelectedAspect(){ + //self.layer?.backgroundColor = NSColor.blue.cgColor + self.backgroundColor = NSColor.blue + volume.textColor = NSColor.white + self.layer?.cornerRadius = 15 + } + +} diff --git a/TINU/Info.plist b/TINU/Info.plist new file mode 100644 index 0000000..9dc27fd --- /dev/null +++ b/TINU/Info.plist @@ -0,0 +1,34 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIconFile + + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 PUBLIC + CFBundleVersion + 20 + LSApplicationCategoryType + public.app-category.utilities + LSMinimumSystemVersion + $(MACOSX_DEPLOYMENT_TARGET) + NSHumanReadableCopyright + Copyright © 2017 Pietro Caruso (ITzTravelInTime). All rights reserved. Please do not redistribuite. + NSMainStoryboardFile + Main + NSPrincipalClass + NSApplication + + diff --git a/TINU/InfoViewController.swift b/TINU/InfoViewController.swift new file mode 100644 index 0000000..e9c27a8 --- /dev/null +++ b/TINU/InfoViewController.swift @@ -0,0 +1,32 @@ +// +// InfoViewController.swift +// TINU +// +// Created by Pietro Caruso on 24/08/17. +// Copyright © 2017 Pietro Caruso. All rights reserved. +// + +import Cocoa + +//the first screen of the app, it has just some labels and a button +class InfoViewController: NSViewController { + @IBOutlet weak var background: NSVisualEffectView! + override func viewDidLoad() { + super.viewDidLoad() + // Do view setup here. + sharedStoryboard = self.storyboard + + if sharedIsOnRecovery || !sharedUseVibrant { + background.isHidden = true + } + } + + @IBAction func ok(_ sender: Any) { + if showLicense{ + let _ = openSubstituteWindow(windowStoryboardID: "License", sender: self) + }else{ + let _ = openSubstituteWindow(windowStoryboardID: "ChoseDrive", sender: self) + } + } + +} diff --git a/TINU/InstallingViewController.swift b/TINU/InstallingViewController.swift new file mode 100644 index 0000000..52560bb --- /dev/null +++ b/TINU/InstallingViewController.swift @@ -0,0 +1,843 @@ +// +// InstallingViewController.swift +// TINU +// +// Created by Pietro Caruso on 27/08/17. +// Copyright © 2017 Pietro Caruso. All rights reserved. +// + +import Cocoa +import SecurityFoundation + +class InstallingViewController: NSViewController{ + @IBOutlet weak var driveName: NSTextField! + @IBOutlet weak var driveImage: NSImageView! + + @IBOutlet weak var appImage: NSImageView! + @IBOutlet weak var appName: NSTextField! + + @IBOutlet weak var spinner: NSProgressIndicator! + + @IBOutlet var logText: NSTextView! + + @IBOutlet weak var logView: NSScrollView! + + @IBOutlet weak var cancelButton: NSButton! + + @IBOutlet weak var background: NSVisualEffectView! + + //variables used to check the sucess of the authentication + private var osStatus: OSStatus = 0 + private var osStatus2: OSStatus = 0 + //references we need to free the permitions later + private var authRef2: AuthorizationRef? + private var authFlags = AuthorizationFlags([]) + + //timer to trace the process + private var timer = Timer() + + private var pid = Int32() + private var output : [String] = [] + private var error : [String] = [] + + override func viewDidLoad() { + super.viewDidLoad() + // Do view setup here. + + //if we are into the recoverry we don't need fancy graphics + if sharedIsOnRecovery || !sharedUseVibrant { + background.isHidden = true + } + + //disable the close button of the window + + if let w = sharedWindow{ + w.isMiniaturizeEnaled = false + w.isClosingEnabled = false + w.canHide = false + } + + + /*if let a = NSApplication.shared().delegate as? AppDelegate{ + a.QuitMenuButton.isEnabled = false + }*/ + + //just prints some separators to allow me to see where this windows opens in the output + print("****************************") + print("* CREATION PROCESS STARTED *") + print("****************************") + + + print("macOS install media creation window opened") + //this code checks if the app and the drive provided are correct + var notDone = false + + if let sa = sharedApp{ + print(sa) + appImage.image = NSWorkspace.shared().icon(forFile: sa) + appName.stringValue = FileManager.default.displayName(atPath: sa) + print("Installer app that will be used is: " + sa) + }else{ + notDone = true + } + + if let sv = sharedVolume{ + print(sv) + var sr = sv + + + if !FileManager.default.fileExists(atPath: sv){ + if let sb = sharedBSDDrive{ + + sr = getDriveNameFromBSDID(sb) + sharedVolume = sr + print("Corrected the name of the target volume" + sr) + }else{ + notDone = true + } + } + + driveImage.image = NSWorkspace.shared().icon(forFile: sr) + driveName.stringValue = FileManager.default.displayName(atPath: sr) + print("The target volume is: " + sr) + }else{ + notDone = true + } + + //used to simulate a fail to gett drive or app data + if simulateInstallGetDataFail{ + notDone = true + } + + //if it can't get usable drive and app information, it goes back to the previuos window + if notDone { + print("Couldn't get valid info about the installer app and/or the drive") + //temporary dialong util a soulution for the go back in the view controller problem is solved + if !dialogYesNo(question: "Quit the app?", text: "There was an error while trying to get drive or installer app data, do you want to quit the app?", style: .critical){ + NSApplication.shared().terminate(self) + }else{ + sharedWindow.contentViewController?.openSubstituteWindow(windowStoryboardID: "Confirm", sender: self.view) + } + }else{ + print("Everything is ready to start the macOS install media creation process") + + spinner.startAnimation(self) + + //calls the install function to start the installer creation process + install() + } + } + + public func install(){ + cancelButton.isEnabled = false + + //to have an usable UI during the install we need to use a parallel thread + DispatchQueue.global(qos: .background).async { + //just to avoid problems, the log function in this thred is called inside the Ui thread + DispatchQueue.main.async { + log("Starting installer creation process ...") + log("Asking for user authentication ...") + } + + sharedIsPreCreationInProgress = true + + //gets the bundle becase it's needed when asking for the password + let b = Bundle.main + //if we are not in the reoot user in rcovery mode, we just skip that + if !sharedIsOnRecovery{ + //asks for authentication using the apis + + var authRef: AuthorizationRef? = nil + + self.osStatus = AuthorizationCreate(nil, nil, self.authFlags, &authRef) + var myItems = [ + AuthorizationItem(name: b.bundleIdentifier! + ".sudo", valueLength: 0, value: nil, flags: 0), + AuthorizationItem(name: b.bundleIdentifier! + ".createinstallmedia", valueLength: 0, value: nil, flags: 0) + ] + var myRights = AuthorizationRights(count: UInt32(myItems.count), items: &myItems) + let myFlags : AuthorizationFlags = [.interactionAllowed, .extendRights, .destroyRights, .preAuthorize] + + self.osStatus2 = AuthorizationCreate(&myRights, nil, myFlags, &self.authRef2) + } + + //simulates an uthentication fail or cancel + if simulateFirstAuthCancel{ + self.osStatus = 1 + self.osStatus2 = 1 + } + + //checks if the authentication is sucessfoul + if self.osStatus == 0 && self.osStatus2 == 0{ + DispatchQueue.main.async { + log("User successfully authenticated") + } + + //format skip testing + if simulateFormatSkip{ + sharedVolumeNeedsPartitionMethodChange = nil + //sharedVolumeNeedsFormat = nil + } + + // variables used to determinate if the format was sucessfoul + var didChangePS = true + //var didChangeFS = true + + //chck if volume needs to be formatted, in particular if it needs to be repartitioned and completely erased + if let s = sharedVolumeNeedsPartitionMethodChange { + if s{ + + DispatchQueue.main.async { + log("Starting volume partition scheme change") + } + //we set this to false just in case of failure + didChangePS = false + + //this code gets the bsd name of the drive from the bsd name of the partition selcted + var tmpBSDName = "" + var ns = 0 + + for cc in sharedBSDDrive.characters{ + let c = String(cc) + if c.lowercased() == "s"{ + ns += 1 + } + if ns == 1{ + if let _ = Int(c){ + tmpBSDName += c + } + } + } + var out: String! + + //let nm = URL.init(fileURLWithPath: sharedVolume, isDirectory: true).lastPathComponent + //this is the command used to erase the disk and create on just one partition with the GUID table + let cmd = "diskutil eraseDisk JHFS+ " + "Installer" + " /dev/disk" + tmpBSDName + + DispatchQueue.main.async { + log("Formatting disk and change partition scheme with the command:") + log(" " + cmd) + } + + //gets the output of the format script + out = getOutWithSudo(cmd: cmd) + + //out is nil only if the authentication has failed + if out == nil{ + DispatchQueue.main.async { + self.freeAuth() + + log("Get password failed") + self.goBack() + return + } + }else{ + //output separated in parts + let c = out.components(separatedBy: "\n") + //the text we are looking for + let finishedMark = "Finished erase on disk" + //checks if the erase has been completed with success + if c[c.count - 2].contains(finishedMark) || c.last!.contains(finishedMark){ + //we can set this boolean to true because the process has been successfoul + didChangePS = true + //setup variables for the \createinstall media, the target partition is always the second partition into the drive, the first one is the EFI partition + sharedBSDDrive = "/dev/disk" + tmpBSDName + "s2" + sharedVolume = getDriveNameFromBSDID(sharedBSDDrive) + + DispatchQueue.main.async { + if let name = sharedVolume{ + self.driveImage.image = NSWorkspace.shared().icon(forFile: name) + self.driveName.stringValue = FileManager.default.displayName(atPath: name) + } + + log("Volume partition scheme changed with sucess") + } + }else{ + //the format has failed, so the boolean is false and a screen with installer creation failed will be displayed + DispatchQueue.main.async { + log("Volume partition scheme change fail: ") + log(" Format script output: \n" + out) + } + } + } + + } + } + + //the format code is ignored for now because createinstallmedia can do it by itself, but just in case it's needed it's keeped here + /* + if let s = sharedVolumeNeedsFormat { + if s{ + DispatchQueue.main.async { + self.log("Starting volume file system format") + } + didChangeFS = false + //format file system here + + var out: String! + let cmd = "diskutil eraseVolume JHFS+ Installer " + sharedBSDDrive + + DispatchQueue.main.async { + self.log("Formatting volume with the command:") + self.log(" " + cmd) + } + + out = self.getOutWithSudo(cmd: cmd) + + //out is nil only if the authentication has failed + if out == nil{ + + //since into the recovery we do not need the spacial authorization, we just free it when running on a normal mac os environment + if !sharedIsOnRecovery{ + //we no longer need the special authorization, so it is freed + if AuthorizationFree(authRef2!, authFlags) == 0{ + DispatchQueue.main.async { + log("AutorizationFree executed successfully") + } + }else{ + DispatchQueue.main.async { + log("AutorizationFree failed") + } + } + } + DispatchQueue.main.async { + log("Get password failed") + self.goBack() + return + } + }else{ + + if out.components(separatedBy: "\n").last!.contains("Finished erase on disk"){ + didChangeFS = true + sharedVolume = getDriveNameFromBSDID(sharedBSDDrive) + DispatchQueue.main.async { + if let name = sharedVolume{ + self.driveImage.image = NSWorkspace.shared().icon(forFile: name) + self.driveName.stringValue = FileManager.default.displayName(atPath: name) + } + + log("Volume formatted with sucess") + } + }else{ + DispatchQueue.main.async { + self.log("Volume format failed: ") + self.log(" Format script output: " + out) + } + } + } + } + } + */ + + //this code simulates when the format has failed + if simulateFormatFail{ + didChangePS = false + //didChangeFS = false + } + + //if the drive has benn successfully formatted, procede + if /*didChangeFS &&*/ didChangePS{ + //adds the \ before the spaces in the string of the installer app's path, because it's needed for the scripts + var path = "" + for ii in sharedApp.characters{ + let i = String(ii) + if i == " "{ + path += "\\ " + }else{ + path += i + } + + } + + DispatchQueue.main.async { + log("The application that will be used to create the installer is: " + sharedApp) + } + + //adds the \ before the spaces in the string of the selected drive's path, because it's needed for the scripts + var drv = "" + for ii in sharedVolume.characters{ + let i = String(ii) + if i == " "{ + drv += "\\ " + }else{ + drv += i + } + } + DispatchQueue.main.async { + log("The target drive is: " + sharedVolume) + } + //this strting is used to define the main command to use, then the prefix is added + var mainCMD = path + "/Contents/Resources/" + sharedExecutableName + " --volume " + drv + " --applicationpath " + path + + //if tinu have to create a mac os installation on the selected drive (experimental, not used bacause it does not seems to work) + if sharedInstallMac{ + + ///Volumes/Image\ Volume/Install\ macOS\ High\ Sierra.app/Contents/Resources/startosinstall --volume /Volumes/MAC --converttoapfs NO + mainCMD += " --agreetolicense --converttoapfs NO;exit;" + }else{ + //we are just on the standard createinstallmedia, so let's add what is missing + mainCMD += " --nointeraction;exit;" + } + + //this code is used to simulate results of createinstll media, saves time hen tesing the fial screen + if let scf = simulateCreateinstallmediaFail{ + if !scf{ + mainCMD = "echo \"done test\"" + }else{ + mainCMD = "echo \"failed test\"" + } + } + + DispatchQueue.main.async { + //logs the performed script and takes care of hiding the password + log("The script that will be performed is: " + mainCMD) + log("Installer creation started, waiting for createinstallmedia to finish ...") + } + + //sets to tru this booler that tells to the rest of the app if the creation of the installer is active + sharedIsCreationInProgress = true + + //run the script with sudo permitions and then analyze the outputs + if let r = startCommandWithSudo(cmd: "/bin/sh", args: ["-c", mainCMD]){ + sharedIsPreCreationInProgress = false + + //assign processes variables + process = r.process + errorPipe = r.errorPipe + outputPipe = r.outputPipe + + + DispatchQueue.main.sync { + //cancel button and the close button can be restored + self.cancelButton.isEnabled = true + + if let ww = sharedWindow{ + //ww.isMiniaturizeEnaled = false + ww.isClosingEnabled = true + //ww.canHide = false + } + + self.timer.invalidate() + self.timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(self.checkProcessFinished(_:)), userInfo: nil, repeats: true) + } + + //code used if the timer is not used + //r.process.waitUntilExit() + + //install is finished, so we call this function + //self.installFinished() + + //old code, still keeped here as a backup + //now this code is executed only when the script finishes it's execution + //now the installer creation process has finished running, so our boolean must be false now + + /*sharedIsCreationInProgress = false + + let outdata = r.outputPipe.fileHandleForReading.readDataToEndOfFile() + if var string = String(data: outdata, encoding: .utf8) { + string = string.trimmingCharacters(in: .newlines) + self.output = string.components(separatedBy: "\n") + } + + let errdata = r.errorPipe.fileHandleForReading.readDataToEndOfFile() + if var string = String(data: errdata, encoding: .utf8) { + string = string.trimmingCharacters(in: .newlines) + self.error = string.components(separatedBy: "\n") + } + + //now we do not need the password anymore + erasePassword() + + //since into the recovery we do not need the spacial authorization, we just free it when running on a normal mac os environment + if !sharedIsOnRecovery{ + //we no longer need the special authorization, so it is freed + if AuthorizationFree(authRef2!, authFlags) == 0{ + DispatchQueue.main.async { + log("AutorizationFree executed successfully") + } + }else{ + DispatchQueue.main.async { + log("AutorizationFree failed") + } + } + } + + var rc = r.process.terminationStatus + + if simulateAbnormalExitcode{ + rc = 1 + } + + + DispatchQueue.main.async { + + //if there is a not normal code it will be logged + log("Installer creation finished, createinstallmedia has finished") + if rc != 0{ + log("Createinstallmedia exit code produced: \n \(rc)") + } + + log("Createinstallmedia output produced: ") + //logs the output of the process + for o in self.output{ + log(" " + o) + } + + if !self.error.isEmpty{ + if !((self.error.first?.contains("Erasing Disk: 0%... 10%... 20%... 30%...100%..."))! && self.error.first == self.error.last){ + log("Createinstallmedia error/s produced: ") + //logs the errors produced by the process + if !self.error.isEmpty{ + for o in self.error{ + log(" " + o) + } + }else{ + log(" No errors found") + } + } + } + + //now we checks if the installer creation has been completed sucessfully + if (self.output.last?.uppercased().contains("DONE"))!{ + //here createinstall media succedes in creating the installer + log("Installer created successfully!") + //ok the installer creation has been completed with sucess, so it sets up the final widnow and then it's showed up + self.goToFinalScreen(title: "macOS install media created successfully", success: true) + }else if (self.error.last?.contains("A error occurred erasing the disk."))! { + //here createinstall media failed to create the installer, bacuse of a format failure + log("Installer creation failed, createinstallmedia returned an error while formatting the installer, please, erase this dirve with disk utility and retry") + //the installer creation has failed, so it does setup the final windows to show the failure an the error and then it's called + self.goToFinalScreen(title: "macOS install media creation failed to format the target drive, check the log for details", success: false) + }else if (self.error.last?.contains("does not appear to be a valid OS installer application"))!{ + //here createinstall media failed to create the installer, bacuse of the downloaded app not being a valid one + log("Installer creation failed, createinstallmedia returned an error about the app yoiu are using, please, check your mac instalaltion app and if needed download it again") + //showing tp the installer screen + self.goToFinalScreen(title: "macOS install media creation failed to beacuse of a bad macOS application, check the log for details", success: false) + }else{ + //shows different screen basing on the erros + if rc == 0{ + //here createinstall media failed to create the installer + log("Installer creation failed, createinstallmedia returned an error while creating the installer, please, erase this dirve with disk utility and retry") + //the installer creation has failed, so it does setup the final windows to show the failure an the error and then it's called + self.goToFinalScreen(title: "macOS install media creation failed, check the log for details", success: false) + }else{ + //process exite with a not nomal exit code + log("macOS install media creation exited with a not normal exit code") + self.goToFinalScreen(title: "macOS install media creation exited with not normal code, check the log for details", success: false) + } + } + }*/ + + return + }else{ + //here the second authentication is failed, so we come back to the previus screen, but we need to release permitions + self.freeAuth() + + //now the installer creation process has finished running, so our boolean must be false now + sharedIsCreationInProgress = false + + DispatchQueue.main.async { + log("Get password failed") + self.goBack() + return + } + + } + }else{ + //here the format script to erase the drive has failed, we also need to realse permitions here + + self.freeAuth() + + DispatchQueue.main.sync { + log("Installer creation failed, drive format or partition table changement failed, please erase this drive manually with disk utility and then retry") + //the driver format has failed, so it does setup the final windows to show the failure an the error and then it's called + self.goToFinalScreen(title: "macOS install media creation failed to format the target drive, check the log for details", success: false) + return + } + } + }else{ + //the user does not gives the authentication, so we came back to previous window + DispatchQueue.main.sync { + log("Authentication aborted") + self.goBack() + return + } + } + } + } + + //unused, still work in progress + + var seconds: UInt64 = 0 + //function that checks if the process has finished + @objc func checkProcessFinished(_ sender: AnyObject){ + seconds += 1 + print(String(seconds) + " seconds passed from start") + DispatchQueue.global(qos: .background).async{ + //log("Checking createinstallmedia status check: \(self.seconds) seconds passed") + /*if let string = String(data: outputPipe.fileHandleForReading.readDataToEndOfFile(), encoding: .utf8) { + DispatchQueue.main.async { + log(string.trimmingCharacters(in: .newlines)) + } + }*/ + /* + if let string = String(data: errorPipe.fileHandleForReading.readDataToEndOfFile(), encoding: .utf8) { + log(string.trimmingCharacters(in: .newlines)) + }*/ + + + if !process.isRunning{ + sharedIsCreationInProgress = false + DispatchQueue.main.async { + log("macOS install media creation took " + String(self.seconds) + " seconds to finish") + self.timer.invalidate() + self.installFinished() + } + } + } + } + + private func installFinished(){ + //now the installer creation process has finished running, so our boolean must be false now + sharedIsCreationInProgress = false + + //we have finished, so the controls opf the window are restored + if let w = sharedWindow{ + w.isMiniaturizeEnaled = true + w.isClosingEnabled = true + w.canHide = true + } + + //this code get's the output of teh process + let outdata = outputPipe.fileHandleForReading.readDataToEndOfFile() + if var string = String(data: outdata, encoding: .utf8) { + string = string.trimmingCharacters(in: .newlines) + self.output = string.components(separatedBy: "\n") + } + + //this code gets the errors of the process + let errdata = errorPipe.fileHandleForReading.readDataToEndOfFile() + if var string = String(data: errdata, encoding: .utf8) { + string = string.trimmingCharacters(in: .newlines) + self.error = string.components(separatedBy: "\n") + } + + //now we do not need the password anymore + erasePassword() + + //the process is finished, so authentication is no longer needed + freeAuth() + + //gets the termination status for comparison + var rc = process.terminationStatus + + //code used to test if the process has exited with an abnormal code + if simulateAbnormalExitcode{ + rc = 1 + } + + //if there is a not normal code it will be logged + log("macOS install media creation finished, createinstallmedia has finished") + + //if the exit code produced is not normal, it's logged + if rc != 0{ + log("macOS install media creation exit code produced: \n \(rc)") + } + + log("macOS install media creation output produced: ") + //logs the output of the process + for o in self.output{ + log(" " + o) + } + + //if the output is empty opr if it's just the standard output of the creation process, it's not logged + if !self.error.isEmpty{ + if !((self.error.first?.contains("Erasing Disk: 0%... 10%... 20%... 30%...100%..."))! && self.error.first == self.error.last){ + log("macOS install media creation error/s produced: ") + //logs the errors produced by the process + for o in self.error{ + log(" " + o) + } + } + } + + //now we checks if the installer creation has been completed sucessfully + if (self.output.last?.uppercased().contains("DONE"))!{ + + //here createinstall media succedes in creating the installer + log("macOS install media created successfully!") + + //ok the installer creation has been completed with sucess, so it sets up the final widnow and then it's showed up + self.goToFinalScreen(title: "macOS install media created successfully", success: true) + + }else if (self.error.last?.contains("A error occurred erasing the disk."))! || (self.output.last?.contains("A error occurred erasing the disk."))! { + + //here createinstall media failed to create the installer, bacuse of a format failure + log("macOS install media creation failed, createinstallmedia returned an error while formatting the installer, please, erase this dirve with disk utility and retry") + + //the installer creation has failed, so it does setup the final windows to show the failure an the error and then it's called + self.goToFinalScreen(title: "macOS install media creation failed to format the target drive, check the log for details", success: false) + + }else if (self.error.last?.contains("does not appear to be a valid OS installer application"))! || (self.error.last?.contains("does not appear to be a valid OS installer application"))! { + + //here createinstall media failed to create the installer, bacuse of the downloaded app not being a valid one + log("macOS install media creation failed, createinstallmedia returned an error about the app yoiu are using, please, check your mac instalaltion app and if needed download it again") + + //showing tp the installer screen + self.goToFinalScreen(title: "macOS install media creation failed to beacuse of a bad macOS application, check the log for details", success: false) + + }else{ + //shows different screen basing on the erros + if rc == 0{ + + //here createinstall media failed to create the installer + log("macOS install media creation failed, createinstallmedia returned an error while creating the installer, please, erase this dirve with disk utility and retry") + + //the installer creation has failed, so it does setup the final windows to show the failure an the error and then it's called + self.goToFinalScreen(title: "macOS install media creation failed, check the log for details", success: false) + + }else{ + + //process exite with a not nomal exit code + log("macOS install media creation exited with a not normal exit code") + + self.goToFinalScreen(title: "macOS install media creation exited with not normal code, check the log for details", success: false) + + } + } + } + + //this functrion frees the auth from apis + private func freeAuth(){ + //free auth is called only when the processes are finished, so let's make them false + sharedIsPreCreationInProgress = false + sharedIsCreationInProgress = false + + //since into the recovery we do not need the spacial authorization, we just free it when running on a normal mac os environment + if !sharedIsOnRecovery{ + + if authRef2 != nil{ + //we no longer need the special authorization, so it is freed + if AuthorizationFree(authRef2!, authFlags) == 0{ + DispatchQueue.main.async { + log("AutorizationFree executed successfully") + } + }else{ + DispatchQueue.main.async { + log("AutorizationFree failed") + } + } + } + } + } + + private func goToFinalScreen(title: String, success: Bool){ + //this code opens the final window + sharedIsPreCreationInProgress = false + sharedIsCreationInProgress = false + sharedTitle = title + sharedIsOk = success + spinner.isHidden = true + spinner.stopAnimation(self) + let _ = self.openSubstituteWindow(windowStoryboardID: "MainDone", sender: self) + } + + private func goBack(){ + //this code opens the previus window + sharedIsPreCreationInProgress = false + sharedIsCreationInProgress = false + spinner.isHidden = true + spinner.stopAnimation(self) + let _ = self.openSubstituteWindow(windowStoryboardID: "Confirm", sender: self) + } + + @IBAction func cancel(_ sender: Any) { + //displays a dialog to check if the user is sure that he/she wants to stop the installer creation + if !dialogYesNo(question: "Stop the process?", text: "Do you want to abort the Installer cration process?", style: .informational){ + + //if the user wnat to exit from the installer creation, this function is called and it does stop the createinstallmedia process + stop() + + //now the installer cration is stopped, so we come back to the previous window + goBack() + } + } + + //this function gets the pid of the createinstallmedia and then stops it, it does runs sudo using the password stored in memory + public func stop(){ + //if the installer creation is not in progress, we do not need to stop it + if !sharedIsCreationInProgress{ + return + } + + //if the installer pre creation is in progress, we don't have to stop createinstallmedia + if sharedIsPreCreationInProgress{ + return + } + + //get the name of the executable + let word = sharedExecutableName + //try to get the pid for the executable + let cpid = getOut(cmd: "ps -Ac -o pid,comm | awk '/^ *[0-9]+ " + word + "$/ {print $1}'") + log("createinstllmedia is on pid: " + cpid) + //checks if the script has returned a pid + if cpid != ""{ + //this code trys to kill the executable, but it does require sudo on an user environment + if let out = getOutWithSudo(cmd: "kill " + cpid){ + //just to see if the operation succedes + if out != "" && out != "Password:"{ + //kill just failed here + log(out) + }else{ + //we have finished, so the password is erased + erasePassword() + + //just tell to the rest of the app that the installer creation is no longer running + sharedIsCreationInProgress = false + + //dispose timer, bacause it's no longer needed + timer.invalidate() + + //auth is no longer needed + freeAuth() + } + }else{ + //if !dialogYesNo(question: "Stop the process?", text: "Do you want to abort the Installer cration process?", style: .informational){ + stop() + //}else{ + //return + //} + } + }else{ + log("Can't get the pid for " + word + " or " + word + " already killed") + } + } + + //shows the log window + @IBAction func showLog(_ sender: Any) { + /*if let b = sender as? NSButton{ + if logView.isHidden{ + b.title = "Hide log" + }else{ + b.title = "Show log" + } + } + + logView.isHidden = !logView.isHidden + */ + + if logWindow == nil { + logWindow = LogWindowController() + } + + logWindow!.showWindow(self) + } + + + //just to be sure, if the view does disappear the installer creation is stopped + override func viewWillDisappear() { + if sharedIsCreationInProgress{ + stop() + } + } + +} diff --git a/TINU/License.rtf b/TINU/License.rtf new file mode 100644 index 0000000..cff5cdf --- /dev/null +++ b/TINU/License.rtf @@ -0,0 +1,683 @@ +{\rtf1\ansi\ansicpg1252\cocoartf1504\cocoasubrtf830 +{\fonttbl\f0\fmodern\fcharset0 Courier;} +{\colortbl;\red255\green255\blue255;\red0\green0\blue0;} +{\*\expandedcolortbl;;\cssrgb\c0\c0\c0;} +\paperw12240\paperh15840\margl1440\margr1440\vieww9000\viewh8400\viewkind0 +\deftab720 +\pard\pardeftab720\partightenfactor0 + +\f0\fs26 \cf0 \expnd0\expndtw0\kerning0 + GNU GENERAL PUBLIC LICENSE\ + Version 3, 29 June 2007\ +\ + Copyright (C) 2007 Free Software Foundation, Inc. \ + Everyone is permitted to copy and distribute verbatim copies\ + of this license document, but changing it is not allowed.\ +\ + Preamble\ +\ + The GNU General Public License is a free, copyleft license for\ +software and other kinds of works.\ +\ + The licenses for most software and other practical works are designed\ +to take away your freedom to share and change the works. By contrast,\ +the GNU General Public License is intended to guarantee your freedom to\ +share and change all versions of a program--to make sure it remains free\ +software for all its users. We, the Free Software Foundation, use the\ +GNU General Public License for most of our software; it applies also to\ +any other work released this way by its authors. You can apply it to\ +your programs, too.\ +\ + When we speak of free software, we are referring to freedom, not\ +price. Our General Public Licenses are designed to make sure that you\ +have the freedom to distribute copies of free software (and charge for\ +them if you wish), that you receive source code or can get it if you\ +want it, that you can change the software or use pieces of it in new\ +free programs, and that you know you can do these things.\ +\ + To protect your rights, we need to prevent others from denying you\ +these rights or asking you to surrender the rights. Therefore, you have\ +certain responsibilities if you distribute copies of the software, or if\ +you modify it: responsibilities to respect the freedom of others.\ +\ + For example, if you distribute copies of such a program, whether\ +gratis or for a fee, you must pass on to the recipients the same\ +freedoms that you received. You must make sure that they, too, receive\ +or can get the source code. And you must show them these terms so they\ +know their rights.\ +\ + Developers that use the GNU GPL protect your rights with two steps:\ +(1) assert copyright on the software, and (2) offer you this License\ +giving you legal permission to copy, distribute and/or modify it.\ +\ + For the developers' and authors' protection, the GPL clearly explains\ +that there is no warranty for this free software. For both users' and\ +authors' sake, the GPL requires that modified versions be marked as\ +changed, so that their problems will not be attributed erroneously to\ +authors of previous versions.\ +\ + Some devices are designed to deny users access to install or run\ +modified versions of the software inside them, although the manufacturer\ +can do so. This is fundamentally incompatible with the aim of\ +protecting users' freedom to change the software. The systematic\ +pattern of such abuse occurs in the area of products for individuals to\ +use, which is precisely where it is most unacceptable. Therefore, we\ +have designed this version of the GPL to prohibit the practice for those\ +products. If such problems arise substantially in other domains, we\ +stand ready to extend this provision to those domains in future versions\ +of the GPL, as needed to protect the freedom of users.\ +\ + Finally, every program is threatened constantly by software patents.\ +States should not allow patents to restrict development and use of\ +software on general-purpose computers, but in those that do, we wish to\ +avoid the special danger that patents applied to a free program could\ +make it effectively proprietary. To prevent this, the GPL assures that\ +patents cannot be used to render the program non-free.\ +\ + The precise terms and conditions for copying, distribution and\ +modification follow.\ +\ + TERMS AND CONDITIONS\ +\ + 0. Definitions.\ +\ + "This License" refers to version 3 of the GNU General Public License.\ +\ + "Copyright" also means copyright-like laws that apply to other kinds of\ +works, such as semiconductor masks.\ +\ + "The Program" refers to any copyrightable work licensed under this\ +License. Each licensee is addressed as "you". "Licensees" and\ +"recipients" may be individuals or organizations.\ +\ + To "modify" a work means to copy from or adapt all or part of the work\ +in a fashion requiring copyright permission, other than the making of an\ +exact copy. The resulting work is called a "modified version" of the\ +earlier work or a work "based on" the earlier work.\ +\ + A "covered work" means either the unmodified Program or a work based\ +on the Program.\ +\ + To "propagate" a work means to do anything with it that, without\ +permission, would make you directly or secondarily liable for\ +infringement under applicable copyright law, except executing it on a\ +computer or modifying a private copy. Propagation includes copying,\ +distribution (with or without modification), making available to the\ +public, and in some countries other activities as well.\ +\ + To "convey" a work means any kind of propagation that enables other\ +parties to make or receive copies. Mere interaction with a user through\ +a computer network, with no transfer of a copy, is not conveying.\ +\ + An interactive user interface displays "Appropriate Legal Notices"\ +to the extent that it includes a convenient and prominently visible\ +feature that (1) displays an appropriate copyright notice, and (2)\ +tells the user that there is no warranty for the work (except to the\ +extent that warranties are provided), that licensees may convey the\ +work under this License, and how to view a copy of this License. If\ +the interface presents a list of user commands or options, such as a\ +menu, a prominent item in the list meets this criterion.\ +\ + 1. Source Code.\ +\ + The "source code" for a work means the preferred form of the work\ +for making modifications to it. "Object code" means any non-source\ +form of a work.\ +\ + A "Standard Interface" means an interface that either is an official\ +standard defined by a recognized standards body, or, in the case of\ +interfaces specified for a particular programming language, one that\ +is widely used among developers working in that language.\ +\ + The "System Libraries" of an executable work include anything, other\ +than the work as a whole, that (a) is included in the normal form of\ +packaging a Major Component, but which is not part of that Major\ +Component, and (b) serves only to enable use of the work with that\ +Major Component, or to implement a Standard Interface for which an\ +implementation is available to the public in source code form. A\ +"Major Component", in this context, means a major essential component\ +(kernel, window system, and so on) of the specific operating system\ +(if any) on which the executable work runs, or a compiler used to\ +produce the work, or an object code interpreter used to run it.\ +\ + The "Corresponding Source" for a work in object code form means all\ +the source code needed to generate, install, and (for an executable\ +work) run the object code and to modify the work, including scripts to\ +control those activities. However, it does not include the work's\ +System Libraries, or general-purpose tools or generally available free\ +programs which are used unmodified in performing those activities but\ +which are not part of the work. For example, Corresponding Source\ +includes interface definition files associated with source files for\ +the work, and the source code for shared libraries and dynamically\ +linked subprograms that the work is specifically designed to require,\ +such as by intimate data communication or control flow between those\ +subprograms and other parts of the work.\ +\ + The Corresponding Source need not include anything that users\ +can regenerate automatically from other parts of the Corresponding\ +Source.\ +\ + The Corresponding Source for a work in source code form is that\ +same work.\ +\ + 2. Basic Permissions.\ +\ + All rights granted under this License are granted for the term of\ +copyright on the Program, and are irrevocable provided the stated\ +conditions are met. This License explicitly affirms your unlimited\ +permission to run the unmodified Program. The output from running a\ +covered work is covered by this License only if the output, given its\ +content, constitutes a covered work. This License acknowledges your\ +rights of fair use or other equivalent, as provided by copyright law.\ +\ + You may make, run and propagate covered works that you do not\ +convey, without conditions so long as your license otherwise remains\ +in force. You may convey covered works to others for the sole purpose\ +of having them make modifications exclusively for you, or provide you\ +with facilities for running those works, provided that you comply with\ +the terms of this License in conveying all material for which you do\ +not control copyright. Those thus making or running the covered works\ +for you must do so exclusively on your behalf, under your direction\ +and control, on terms that prohibit them from making any copies of\ +your copyrighted material outside their relationship with you.\ +\ + Conveying under any other circumstances is permitted solely under\ +the conditions stated below. Sublicensing is not allowed; section 10\ +makes it unnecessary.\ +\ + 3. Protecting Users' Legal Rights From Anti-Circumvention Law.\ +\ + No covered work shall be deemed part of an effective technological\ +measure under any applicable law fulfilling obligations under article\ +11 of the WIPO copyright treaty adopted on 20 December 1996, or\ +similar laws prohibiting or restricting circumvention of such\ +measures.\ +\ + When you convey a covered work, you waive any legal power to forbid\ +circumvention of technological measures to the extent such circumvention\ +is effected by exercising rights under this License with respect to\ +the covered work, and you disclaim any intention to limit operation or\ +modification of the work as a means of enforcing, against the work's\ +users, your or third parties' legal rights to forbid circumvention of\ +technological measures.\ +\ + 4. Conveying Verbatim Copies.\ +\ + You may convey verbatim copies of the Program's source code as you\ +receive it, in any medium, provided that you conspicuously and\ +appropriately publish on each copy an appropriate copyright notice;\ +keep intact all notices stating that this License and any\ +non-permissive terms added in accord with section 7 apply to the code;\ +keep intact all notices of the absence of any warranty; and give all\ +recipients a copy of this License along with the Program.\ +\ + You may charge any price or no price for each copy that you convey,\ +and you may offer support or warranty protection for a fee.\ +\ + 5. Conveying Modified Source Versions.\ +\ + You may convey a work based on the Program, or the modifications to\ +produce it from the Program, in the form of source code under the\ +terms of section 4, provided that you also meet all of these conditions:\ +\ + a) The work must carry prominent notices stating that you modified\ + it, and giving a relevant date.\ +\ + b) The work must carry prominent notices stating that it is\ + released under this License and any conditions added under section\ + 7. This requirement modifies the requirement in section 4 to\ + "keep intact all notices".\ +\ + c) You must license the entire work, as a whole, under this\ + License to anyone who comes into possession of a copy. This\ + License will therefore apply, along with any applicable section 7\ + additional terms, to the whole of the work, and all its parts,\ + regardless of how they are packaged. This License gives no\ + permission to license the work in any other way, but it does not\ + invalidate such permission if you have separately received it.\ +\ + d) If the work has interactive user interfaces, each must display\ + Appropriate Legal Notices; however, if the Program has interactive\ + interfaces that do not display Appropriate Legal Notices, your\ + work need not make them do so.\ +\ + A compilation of a covered work with other separate and independent\ +works, which are not by their nature extensions of the covered work,\ +and which are not combined with it such as to form a larger program,\ +in or on a volume of a storage or distribution medium, is called an\ +"aggregate" if the compilation and its resulting copyright are not\ +used to limit the access or legal rights of the compilation's users\ +beyond what the individual works permit. Inclusion of a covered work\ +in an aggregate does not cause this License to apply to the other\ +parts of the aggregate.\ +\ + 6. Conveying Non-Source Forms.\ +\ + You may convey a covered work in object code form under the terms\ +of sections 4 and 5, provided that you also convey the\ +machine-readable Corresponding Source under the terms of this License,\ +in one of these ways:\ +\ + a) Convey the object code in, or embodied in, a physical product\ + (including a physical distribution medium), accompanied by the\ + Corresponding Source fixed on a durable physical medium\ + customarily used for software interchange.\ +\ + b) Convey the object code in, or embodied in, a physical product\ + (including a physical distribution medium), accompanied by a\ + written offer, valid for at least three years and valid for as\ + long as you offer spare parts or customer support for that product\ + model, to give anyone who possesses the object code either (1) a\ + copy of the Corresponding Source for all the software in the\ + product that is covered by this License, on a durable physical\ + medium customarily used for software interchange, for a price no\ + more than your reasonable cost of physically performing this\ + conveying of source, or (2) access to copy the\ + Corresponding Source from a network server at no charge.\ +\ + c) Convey individual copies of the object code with a copy of the\ + written offer to provide the Corresponding Source. This\ + alternative is allowed only occasionally and noncommercially, and\ + only if you received the object code with such an offer, in accord\ + with subsection 6b.\ +\ + d) Convey the object code by offering access from a designated\ + place (gratis or for a charge), and offer equivalent access to the\ + Corresponding Source in the same way through the same place at no\ + further charge. You need not require recipients to copy the\ + Corresponding Source along with the object code. If the place to\ + copy the object code is a network server, the Corresponding Source\ + may be on a different server (operated by you or a third party)\ + that supports equivalent copying facilities, provided you maintain\ + clear directions next to the object code saying where to find the\ + Corresponding Source. Regardless of what server hosts the\ + Corresponding Source, you remain obligated to ensure that it is\ + available for as long as needed to satisfy these requirements.\ +\ + e) Convey the object code using peer-to-peer transmission, provided\ + you inform other peers where the object code and Corresponding\ + Source of the work are being offered to the general public at no\ + charge under subsection 6d.\ +\ + A separable portion of the object code, whose source code is excluded\ +from the Corresponding Source as a System Library, need not be\ +included in conveying the object code work.\ +\ + A "User Product" is either (1) a "consumer product", which means any\ +tangible personal property which is normally used for personal, family,\ +or household purposes, or (2) anything designed or sold for incorporation\ +into a dwelling. In determining whether a product is a consumer product,\ +doubtful cases shall be resolved in favor of coverage. For a particular\ +product received by a particular user, "normally used" refers to a\ +typical or common use of that class of product, regardless of the status\ +of the particular user or of the way in which the particular user\ +actually uses, or expects or is expected to use, the product. A product\ +is a consumer product regardless of whether the product has substantial\ +commercial, industrial or non-consumer uses, unless such uses represent\ +the only significant mode of use of the product.\ +\ + "Installation Information" for a User Product means any methods,\ +procedures, authorization keys, or other information required to install\ +and execute modified versions of a covered work in that User Product from\ +a modified version of its Corresponding Source. The information must\ +suffice to ensure that the continued functioning of the modified object\ +code is in no case prevented or interfered with solely because\ +modification has been made.\ +\ + If you convey an object code work under this section in, or with, or\ +specifically for use in, a User Product, and the conveying occurs as\ +part of a transaction in which the right of possession and use of the\ +User Product is transferred to the recipient in perpetuity or for a\ +fixed term (regardless of how the transaction is characterized), the\ +Corresponding Source conveyed under this section must be accompanied\ +by the Installation Information. But this requirement does not apply\ +if neither you nor any third party retains the ability to install\ +modified object code on the User Product (for example, the work has\ +been installed in ROM).\ +\ + The requirement to provide Installation Information does not include a\ +requirement to continue to provide support service, warranty, or updates\ +for a work that has been modified or installed by the recipient, or for\ +the User Product in which it has been modified or installed. Access to a\ +network may be denied when the modification itself materially and\ +adversely affects the operation of the network or violates the rules and\ +protocols for communication across the network.\ +\ + Corresponding Source conveyed, and Installation Information provided,\ +in accord with this section must be in a format that is publicly\ +documented (and with an implementation available to the public in\ +source code form), and must require no special password or key for\ +unpacking, reading or copying.\ +\ + 7. Additional Terms.\ +\ + "Additional permissions" are terms that supplement the terms of this\ +License by making exceptions from one or more of its conditions.\ +Additional permissions that are applicable to the entire Program shall\ +be treated as though they were included in this License, to the extent\ +that they are valid under applicable law. If additional permissions\ +apply only to part of the Program, that part may be used separately\ +under those permissions, but the entire Program remains governed by\ +this License without regard to the additional permissions.\ +\ + When you convey a copy of a covered work, you may at your option\ +remove any additional permissions from that copy, or from any part of\ +it. (Additional permissions may be written to require their own\ +removal in certain cases when you modify the work.) You may place\ +additional permissions on material, added by you to a covered work,\ +for which you have or can give appropriate copyright permission.\ +\ + Notwithstanding any other provision of this License, for material you\ +add to a covered work, you may (if authorized by the copyright holders of\ +that material) supplement the terms of this License with terms:\ +\ + a) Disclaiming warranty or limiting liability differently from the\ + terms of sections 15 and 16 of this License; or\ +\ + b) Requiring preservation of specified reasonable legal notices or\ + author attributions in that material or in the Appropriate Legal\ + Notices displayed by works containing it; or\ +\ + c) Prohibiting misrepresentation of the origin of that material, or\ + requiring that modified versions of such material be marked in\ + reasonable ways as different from the original version; or\ +\ + d) Limiting the use for publicity purposes of names of licensors or\ + authors of the material; or\ +\ + e) Declining to grant rights under trademark law for use of some\ + trade names, trademarks, or service marks; or\ +\ + f) Requiring indemnification of licensors and authors of that\ + material by anyone who conveys the material (or modified versions of\ + it) with contractual assumptions of liability to the recipient, for\ + any liability that these contractual assumptions directly impose on\ + those licensors and authors.\ +\ + All other non-permissive additional terms are considered "further\ +restrictions" within the meaning of section 10. If the Program as you\ +received it, or any part of it, contains a notice stating that it is\ +governed by this License along with a term that is a further\ +restriction, you may remove that term. If a license document contains\ +a further restriction but permits relicensing or conveying under this\ +License, you may add to a covered work material governed by the terms\ +of that license document, provided that the further restriction does\ +not survive such relicensing or conveying.\ +\ + If you add terms to a covered work in accord with this section, you\ +must place, in the relevant source files, a statement of the\ +additional terms that apply to those files, or a notice indicating\ +where to find the applicable terms.\ +\ + Additional terms, permissive or non-permissive, may be stated in the\ +form of a separately written license, or stated as exceptions;\ +the above requirements apply either way.\ +\ + 8. Termination.\ +\ + You may not propagate or modify a covered work except as expressly\ +provided under this License. Any attempt otherwise to propagate or\ +modify it is void, and will automatically terminate your rights under\ +this License (including any patent licenses granted under the third\ +paragraph of section 11).\ +\ + However, if you cease all violation of this License, then your\ +license from a particular copyright holder is reinstated (a)\ +provisionally, unless and until the copyright holder explicitly and\ +finally terminates your license, and (b) permanently, if the copyright\ +holder fails to notify you of the violation by some reasonable means\ +prior to 60 days after the cessation.\ +\ + Moreover, your license from a particular copyright holder is\ +reinstated permanently if the copyright holder notifies you of the\ +violation by some reasonable means, this is the first time you have\ +received notice of violation of this License (for any work) from that\ +copyright holder, and you cure the violation prior to 30 days after\ +your receipt of the notice.\ +\ + Termination of your rights under this section does not terminate the\ +licenses of parties who have received copies or rights from you under\ +this License. If your rights have been terminated and not permanently\ +reinstated, you do not qualify to receive new licenses for the same\ +material under section 10.\ +\ + 9. Acceptance Not Required for Having Copies.\ +\ + You are not required to accept this License in order to receive or\ +run a copy of the Program. Ancillary propagation of a covered work\ +occurring solely as a consequence of using peer-to-peer transmission\ +to receive a copy likewise does not require acceptance. However,\ +nothing other than this License grants you permission to propagate or\ +modify any covered work. These actions infringe copyright if you do\ +not accept this License. Therefore, by modifying or propagating a\ +covered work, you indicate your acceptance of this License to do so.\ +\ + 10. Automatic Licensing of Downstream Recipients.\ +\ + Each time you convey a covered work, the recipient automatically\ +receives a license from the original licensors, to run, modify and\ +propagate that work, subject to this License. You are not responsible\ +for enforcing compliance by third parties with this License.\ +\ + An "entity transaction" is a transaction transferring control of an\ +organization, or substantially all assets of one, or subdividing an\ +organization, or merging organizations. If propagation of a covered\ +work results from an entity transaction, each party to that\ +transaction who receives a copy of the work also receives whatever\ +licenses to the work the party's predecessor in interest had or could\ +give under the previous paragraph, plus a right to possession of the\ +Corresponding Source of the work from the predecessor in interest, if\ +the predecessor has it or can get it with reasonable efforts.\ +\ + You may not impose any further restrictions on the exercise of the\ +rights granted or affirmed under this License. For example, you may\ +not impose a license fee, royalty, or other charge for exercise of\ +rights granted under this License, and you may not initiate litigation\ +(including a cross-claim or counterclaim in a lawsuit) alleging that\ +any patent claim is infringed by making, using, selling, offering for\ +sale, or importing the Program or any portion of it.\ +\ + 11. Patents.\ +\ + A "contributor" is a copyright holder who authorizes use under this\ +License of the Program or a work on which the Program is based. The\ +work thus licensed is called the contributor's "contributor version".\ +\ + A contributor's "essential patent claims" are all patent claims\ +owned or controlled by the contributor, whether already acquired or\ +hereafter acquired, that would be infringed by some manner, permitted\ +by this License, of making, using, or selling its contributor version,\ +but do not include claims that would be infringed only as a\ +consequence of further modification of the contributor version. For\ +purposes of this definition, "control" includes the right to grant\ +patent sublicenses in a manner consistent with the requirements of\ +this License.\ +\ + Each contributor grants you a non-exclusive, worldwide, royalty-free\ +patent license under the contributor's essential patent claims, to\ +make, use, sell, offer for sale, import and otherwise run, modify and\ +propagate the contents of its contributor version.\ +\ + In the following three paragraphs, a "patent license" is any express\ +agreement or commitment, however denominated, not to enforce a patent\ +(such as an express permission to practice a patent or covenant not to\ +sue for patent infringement). To "grant" such a patent license to a\ +party means to make such an agreement or commitment not to enforce a\ +patent against the party.\ +\ + If you convey a covered work, knowingly relying on a patent license,\ +and the Corresponding Source of the work is not available for anyone\ +to copy, free of charge and under the terms of this License, through a\ +publicly available network server or other readily accessible means,\ +then you must either (1) cause the Corresponding Source to be so\ +available, or (2) arrange to deprive yourself of the benefit of the\ +patent license for this particular work, or (3) arrange, in a manner\ +consistent with the requirements of this License, to extend the patent\ +license to downstream recipients. "Knowingly relying" means you have\ +actual knowledge that, but for the patent license, your conveying the\ +covered work in a country, or your recipient's use of the covered work\ +in a country, would infringe one or more identifiable patents in that\ +country that you have reason to believe are valid.\ +\ + If, pursuant to or in connection with a single transaction or\ +arrangement, you convey, or propagate by procuring conveyance of, a\ +covered work, and grant a patent license to some of the parties\ +receiving the covered work authorizing them to use, propagate, modify\ +or convey a specific copy of the covered work, then the patent license\ +you grant is automatically extended to all recipients of the covered\ +work and works based on it.\ +\ + A patent license is "discriminatory" if it does not include within\ +the scope of its coverage, prohibits the exercise of, or is\ +conditioned on the non-exercise of one or more of the rights that are\ +specifically granted under this License. You may not convey a covered\ +work if you are a party to an arrangement with a third party that is\ +in the business of distributing software, under which you make payment\ +to the third party based on the extent of your activity of conveying\ +the work, and under which the third party grants, to any of the\ +parties who would receive the covered work from you, a discriminatory\ +patent license (a) in connection with copies of the covered work\ +conveyed by you (or copies made from those copies), or (b) primarily\ +for and in connection with specific products or compilations that\ +contain the covered work, unless you entered into that arrangement,\ +or that patent license was granted, prior to 28 March 2007.\ +\ + Nothing in this License shall be construed as excluding or limiting\ +any implied license or other defenses to infringement that may\ +otherwise be available to you under applicable patent law.\ +\ + 12. No Surrender of Others' Freedom.\ +\ + If conditions are imposed on you (whether by court order, agreement or\ +otherwise) that contradict the conditions of this License, they do not\ +excuse you from the conditions of this License. If you cannot convey a\ +covered work so as to satisfy simultaneously your obligations under this\ +License and any other pertinent obligations, then as a consequence you may\ +not convey it at all. For example, if you agree to terms that obligate you\ +to collect a royalty for further conveying from those to whom you convey\ +the Program, the only way you could satisfy both those terms and this\ +License would be to refrain entirely from conveying the Program.\ +\ + 13. Use with the GNU Affero General Public License.\ +\ + Notwithstanding any other provision of this License, you have\ +permission to link or combine any covered work with a work licensed\ +under version 3 of the GNU Affero General Public License into a single\ +combined work, and to convey the resulting work. The terms of this\ +License will continue to apply to the part which is the covered work,\ +but the special requirements of the GNU Affero General Public License,\ +section 13, concerning interaction through a network will apply to the\ +combination as such.\ +\ + 14. Revised Versions of this License.\ +\ + The Free Software Foundation may publish revised and/or new versions of\ +the GNU General Public License from time to time. Such new versions will\ +be similar in spirit to the present version, but may differ in detail to\ +address new problems or concerns.\ +\ + Each version is given a distinguishing version number. If the\ +Program specifies that a certain numbered version of the GNU General\ +Public License "or any later version" applies to it, you have the\ +option of following the terms and conditions either of that numbered\ +version or of any later version published by the Free Software\ +Foundation. If the Program does not specify a version number of the\ +GNU General Public License, you may choose any version ever published\ +by the Free Software Foundation.\ +\ + If the Program specifies that a proxy can decide which future\ +versions of the GNU General Public License can be used, that proxy's\ +public statement of acceptance of a version permanently authorizes you\ +to choose that version for the Program.\ +\ + Later license versions may give you additional or different\ +permissions. However, no additional obligations are imposed on any\ +author or copyright holder as a result of your choosing to follow a\ +later version.\ +\ + 15. Disclaimer of Warranty.\ +\ + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\ +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\ +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY\ +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\ +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\ +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\ +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\ +ALL NECESSARY SERVICING, REPAIR OR CORRECTION.\ +\ + 16. Limitation of Liability.\ +\ + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\ +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\ +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\ +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\ +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\ +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\ +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\ +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\ +SUCH DAMAGES.\ +\ + 17. Interpretation of Sections 15 and 16.\ +\ + If the disclaimer of warranty and limitation of liability provided\ +above cannot be given local legal effect according to their terms,\ +reviewing courts shall apply local law that most closely approximates\ +an absolute waiver of all civil liability in connection with the\ +Program, unless a warranty or assumption of liability accompanies a\ +copy of the Program in return for a fee.\ +\ + END OF TERMS AND CONDITIONS\ +\ + How to Apply These Terms to Your New Programs\ +\ + If you develop a new program, and you want it to be of the greatest\ +possible use to the public, the best way to achieve this is to make it\ +free software which everyone can redistribute and change under these terms.\ +\ + To do so, attach the following notices to the program. It is safest\ +to attach them to the start of each source file to most effectively\ +state the exclusion of warranty; and each file should have at least\ +the "copyright" line and a pointer to where the full notice is found.\ +\ + \ + Copyright (C) \ +\ + This program is free software: you can redistribute it and/or modify\ + it under the terms of the GNU General Public License as published by\ + the Free Software Foundation, either version 3 of the License, or\ + (at your option) any later version.\ +\ + This program is distributed in the hope that it will be useful,\ + but WITHOUT ANY WARRANTY; without even the implied warranty of\ + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\ + GNU General Public License for more details.\ +\ + You should have received a copy of the GNU General Public License\ + along with this program. If not, see .\ +\ +Also add information on how to contact you by electronic and paper mail.\ +\ + If the program does terminal interaction, make it output a short\ +notice like this when it starts in an interactive mode:\ +\ + Copyright (C) \ + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\ + This is free software, and you are welcome to redistribute it\ + under certain conditions; type `show c' for details.\ +\ +The hypothetical commands `show w' and `show c' should show the appropriate\ +parts of the General Public License. Of course, your program's commands\ +might be different; for a GUI interface, you would use an "about box".\ +\ + You should also get your employer (if you work as a programmer) or school,\ +if any, to sign a "copyright disclaimer" for the program, if necessary.\ +For more information on this, and how to apply and follow the GNU GPL, see\ +.\ +\ + The GNU General Public License does not permit incorporating your program\ +into proprietary programs. If your program is a subroutine library, you\ +may consider it more useful to permit linking proprietary applications with\ +the library. If this is what you want to do, use the GNU Lesser General\ +Public License instead of this License. But first, please read\ +.} \ No newline at end of file diff --git a/TINU/LicenseViewController.swift b/TINU/LicenseViewController.swift new file mode 100644 index 0000000..e16c99c --- /dev/null +++ b/TINU/LicenseViewController.swift @@ -0,0 +1,90 @@ +// +// LicenseViewController.swift +// TINU +// +// Created by Pietro Caruso on 06/09/17. +// Copyright © 2017 Pietro Caruso. All rights reserved. +// + +import Cocoa + +class LicenseViewController: NSViewController { + + @IBOutlet weak var continueButton: NSButton! + + @IBOutlet var licenseField: NSTextView! + + @IBOutlet weak var spinner: NSProgressIndicator! + + @IBOutlet weak var scroller: NSScrollView! + + @IBOutlet weak var background: NSVisualEffectView! + + override func viewDidLoad() { + super.viewDidLoad() + + if sharedIsOnRecovery || !sharedUseVibrant { + background.isHidden = true + } + + if sharedUseVibrant && !sharedIsOnRecovery{ + scroller.frame = CGRect.init(x: 0, y: scroller.frame.origin.y, width: self.view.frame.width, height: scroller.frame.height) + scroller.borderType = .noBorder + //scroller.drawsBackground = false + }else{ + scroller.frame = CGRect.init(x: 20, y: scroller.frame.origin.y, width: self.view.frame.width - 40, height: scroller.frame.height) + scroller.borderType = .bezelBorder + //scroller.drawsBackground = true + } + + spinner.isHidden = false + spinner.startAnimation(self) + scroller.isHidden = true + + DispatchQueue.global(qos: .userInitiated).async { + + + if let rtfPath = Bundle.main.url(forResource: "License", withExtension: "rtf") { + do { + let attributedStringWithRtf:NSAttributedString = try NSAttributedString(url: rtfPath, options: [NSDocumentTypeDocumentAttribute:NSRTFTextDocumentType], documentAttributes: nil) + DispatchQueue.main.sync { + self.licenseField.text = attributedStringWithRtf.string + + self.spinner.isHidden = true + self.spinner.stopAnimation(self) + self.scroller.isHidden = false + } + + } catch let error { + print("Get license error, skipping: \(error)") + DispatchQueue.main.sync { + let _ = self.openSubstituteWindow(windowStoryboardID: "ChoseDrive", sender: self) + } + } + }else{ + print("Get license error, skipping: license file not found") + DispatchQueue.main.sync { + let _ = self.openSubstituteWindow(windowStoryboardID: "ChoseDrive", sender: self) + } + } + } + } + + @IBAction func readedChanged(_ sender: Any) { + if let s = sender as? NSButton{ + if s.state == 1{ + continueButton.isEnabled = true + }else{ + continueButton.isEnabled = false + } + } + } + + @IBAction func continuePressed(_ sender: Any) { + let _ = openSubstituteWindow(windowStoryboardID: "ChoseDrive", sender: sender) + } + + @IBAction func backPressed(_ sender: Any) { + let _ = openSubstituteWindow(windowStoryboardID: "Info", sender: sender) + } +} diff --git a/TINU/LogManager.swift b/TINU/LogManager.swift new file mode 100644 index 0000000..5bd10de --- /dev/null +++ b/TINU/LogManager.swift @@ -0,0 +1,51 @@ +// +// LogManager.swift +// TINU +// +// Created by ITzTravelInTime on 19/09/17. +// Copyright © 2017 Pietro Caruso. All rights reserved. +// + +import Foundation + +fileprivate var logs = [String]() +fileprivate var hasBeenUpdated = false + +public func log(_ log: String){ + print(log) + logs.append(log) + + hasBeenUpdated = true +} + +public func readLog() -> String!{ + if !hasBeenUpdated{ + return nil + }else{ + var ret = "" + for i in logs{ + ret += i + "\n" + } + hasBeenUpdated = false + return ret + } +} + +public func readLatestLog() -> String!{ + if !logs.isEmpty{ + return logs.last + } + return nil +} + +public func clearLog(){ + logs = [] + hasBeenUpdated = false + if let lw = logWindow{ + if (lw.window?.isVisible)!{ + hasBeenUpdated = true + } + } +} + +var logWindow: LogWindowController! diff --git a/TINU/LogViewController.swift b/TINU/LogViewController.swift new file mode 100644 index 0000000..c93fd75 --- /dev/null +++ b/TINU/LogViewController.swift @@ -0,0 +1,54 @@ +// +// LogViewController.swift +// TINU +// +// Created by ITzTravelInTime on 19/09/17. +// Copyright © 2017 Pietro Caruso. All rights reserved. +// + +import Cocoa + +class LogViewController: NSViewController { + @IBOutlet weak var background: NSVisualEffectView! + + @IBOutlet var text: NSTextView! + + var timer: Timer! + override func viewDidLoad() { + super.viewDidLoad() + // Do view setup here. + + if sharedIsOnRecovery || !sharedUseVibrant { + background.isHidden = true + } + + } + + override func viewDidAppear() { + super.viewDidAppear() + timer = Timer.scheduledTimer(timeInterval: 0.2, target: self, selector: #selector(self.updateLog(_:)), userInfo: nil, repeats: true) + } + + @IBAction func Close(_ sender: Any) { + timer.invalidate() + self.window.close() + } + + override func viewWillDisappear() { + super.viewWillDisappear() + timer.invalidate() + } + + @objc func updateLog(_ sender: AnyObject){ + //print("Log updated") + if let l = readLog(){ + text.text = l + } + } + + @IBAction func copyLog(_ sender: Any) { + let pasteBoard = NSPasteboard.general() + pasteBoard.clearContents() + pasteBoard.writeObjects([text.text as NSString]) + } +} diff --git a/TINU/LogWindowController.swift b/TINU/LogWindowController.swift new file mode 100644 index 0000000..f8176a1 --- /dev/null +++ b/TINU/LogWindowController.swift @@ -0,0 +1,39 @@ +// +// LogWindow.swift +// TINU +// +// Created by ITzTravelInTime on 19/09/17. +// Copyright © 2017 Pietro Caruso. All rights reserved. +// + +import Foundation + +import Cocoa + +class LogWindowController: NSWindowController { + + override func windowDidLoad() { + super.windowDidLoad() + //sets window + self.window?.isFullScreenEnaled = false + self.window?.title = sharedWindowTitlePrefix + ": Log" + + if sharedUseVibrant && !sharedIsOnRecovery { + self.window?.titleVisibility = .hidden + self.window?.titlebarAppearsTransparent = true + self.window?.styleMask.insert(.fullSizeContentView) + self.window?.isMovableByWindowBackground = true + + if sharedTestingMode{ + self.window?.titleVisibility = .visible + } + } + } + + convenience init() { + //creates an instace of the window + self.init(window: (sharedStoryboard.instantiateController(withIdentifier: "Log") as! NSWindowController).window) + //self.init(windowNibName: "ContactsWindowController") + } + +} diff --git a/TINU/MainCreationFinished.swift b/TINU/MainCreationFinished.swift new file mode 100644 index 0000000..6bf9f13 --- /dev/null +++ b/TINU/MainCreationFinished.swift @@ -0,0 +1,110 @@ +// +// MainCreationFinished.swift +// TINU +// +// Created by Pietro Caruso on 31/08/17. +// Copyright © 2017 Pietro Caruso. All rights reserved. +// + +import Foundation +import Cocoa + +class MainCreationFinishedViewController: NSViewController{ + @IBOutlet weak var myTitle: NSTextField! + + @IBOutlet weak var image: NSImageView! + + @IBOutlet weak var exitButton: NSButton! + + @IBOutlet weak var continueButton: NSButton! + + @IBOutlet weak var background: NSVisualEffectView! + + @IBOutlet weak var log: NSScrollView! + override func viewDidLoad() { + super.viewDidLoad() + + if sharedIsOnRecovery || !sharedUseVibrant { + background.isHidden = true + } + + if let w = sharedWindow{ + w.isClosingEnabled = true + w.isMiniaturizeEnaled = true + } + + if let a = NSApplication.shared().delegate as? AppDelegate{ + a.QuitMenuButton.isEnabled = true + } + + myTitle.stringValue = sharedTitle + + let notification = NSUserNotification() + if !sharedIsOk{ + image.image = NSImage(named: "uncheck") + exitButton.title = "Quit" + continueButton.title = "Retry" + continueButton.isEnabled = true + + notification.title = "macOS install media creation failed" + notification.informativeText = "The creation process of the macOS install media has failed, see log for more details" + + notification.contentImage = NSImage(named: "uncheck") + }else{ + image.image = NSImage(named: "check") + exitButton.title = "Quit" + continueButton.title = "Create another installer" + continueButton.isEnabled = true + continueButton.isHidden = false + + notification.title = "macOS install media creation finished" + notification.informativeText = "The creation process of your macOS install media has been completed with success" + notification.contentImage = NSImage(named: "check") + } + + + + notification.soundName = NSUserNotificationDefaultSoundName + NSUserNotificationCenter.default.deliver(notification) + } + + @IBAction func exit(_ sender: Any) { + NSApplication.shared().terminate(self) + } + + @IBAction func goNext(_ sender: Any) { + //if !sharedIsOk { + clearLog() + + let _ = openSubstituteWindow(windowStoryboardID: "Info", sender: self) + //} + } + + @IBAction func checkLog(_ sender: Any) { + /* + if let b = sender as? NSButton{ + + if self.log.isHidden{ + b.title = "Hide Log" + image.frame.size = NSSize(width: image.frame.size.width, height: image.frame.size.height - log.frame.size.height - 8) + image.frame.origin = NSPoint(x: image.frame.origin.x, y: log.frame.origin.y + log.frame.size.height + 8) + + }else{ + b.title = "Show Log" + + image.frame.size = NSSize(width: image.frame.size.width, height: image.frame.origin.y - log.frame.origin.y + image.frame.size.height) + image.frame.origin = NSPoint(x: image.frame.origin.x, y: log.frame.origin.y) + } + } + + log.isHidden = !log.isHidden + */ + if logWindow == nil { + logWindow = LogWindowController() + } + + logWindow!.showWindow(self) + } + +} + diff --git a/TINU/MainWindowController.swift b/TINU/MainWindowController.swift new file mode 100644 index 0000000..8f2f668 --- /dev/null +++ b/TINU/MainWindowController.swift @@ -0,0 +1,82 @@ +// +// mainWindowController.swift +// TINU +// +// Created by Pietro Caruso on 05/05/17. +// Copyright © 2017 Pietro Caruso. All rights reserved. +// + +import Cocoa + +//this class maages the window +class mainWindowController: NSWindowController, NSWindowDelegate { + + 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. + window?.delegate = self + + window?.toolbar = NSApplication.shared().windows[0].toolbar + + sharedWindow = self.window + + checkAppMode() + + checkUser() + + if sharedUseVibrant && !sharedIsOnRecovery { + self.window?.titleVisibility = .hidden + self.window?.titlebarAppearsTransparent = true + self.window?.styleMask.insert(.fullSizeContentView) + self.window?.isMovableByWindowBackground = true + } + + if sharedTestingMode{ + self.window?.title = sharedWindowTitlePrefix + if sharedUseVibrant && !sharedIsOnRecovery { + self.window?.titleVisibility = .visible + } + } + + + } + + + func makeStandard(){ + //self.window?.isResizable = true + + self.window?.exitFullScreen() + + self.window?.isFullScreenEnaled = false + + } + + func makeEditable(){ + //self.window?.isResizable = false + + self.window?.makeFullScreen() + + self.window?.isFullScreenEnaled = true + } + + public func windowWillClose(_ notification: Notification){ + NSApplication.shared().terminate(self) + } + + func windowShouldClose(_ sender: Any) -> Bool { + if sharedIsCreationInProgress{ + + if !dialogYesNo(question: "Stop the process?", text: "Do you want to abort the Installer cration process?", style: .informational){ + if let w = self.contentViewController as? InstallingViewController{ + w.stop() + return true + } + } + } + return true + } + +} + +var sharedWindow: NSWindow! diff --git a/TINU/Part.swift b/TINU/Part.swift new file mode 100644 index 0000000..7e7bf90 --- /dev/null +++ b/TINU/Part.swift @@ -0,0 +1,47 @@ +// +// Part.swift +// TINU +// +// Created by Pietro Caruso on 05/09/17. +// Copyright © 2017 Pietro Caruso. All rights reserved. +// + +import Cocoa + +//this is just a simple class that represents a drive +public class Part{ + var bsdName: String + var name: String + var path: String + var fileSystem: String + var partScheme: String + var hasEFI: Bool + var totSize: Float + + public init(){ + bsdName = "/dev/" + name = "" + path = "/Volumes/" + fileSystem = "" + partScheme = "" + hasEFI = false + totSize = 0 + } + + public init(partitionBSDName: String, partitionName: String, partitionPath: String, partitionFileSystem: String, partitionScheme: String, partitionHasEFI: Bool, partitionSize: Float){ + bsdName = partitionBSDName + name = partitionName + path = partitionPath + fileSystem = partitionFileSystem + partScheme = partitionScheme + hasEFI = partitionHasEFI + totSize = partitionSize + } + + public func copy() -> Part{ + return Part(partitionBSDName: bsdName, partitionName: name, partitionPath: path, partitionFileSystem: fileSystem, partitionScheme: partScheme, partitionHasEFI: hasEFI, partitionSize: totSize) + } + + + +} diff --git a/TINU/ScriptsManager.swift b/TINU/ScriptsManager.swift new file mode 100644 index 0000000..706ad2f --- /dev/null +++ b/TINU/ScriptsManager.swift @@ -0,0 +1,81 @@ +// +// ScriptsManager.swift +// TINU +// +// Created by Pietro Caruso on 20/09/17. +// Copyright © 2017 Pietro Caruso. All rights reserved. +// + +import Foundation + +public func startCommand(cmd : String, args : [String]) -> (process: Process, errorPipe: Pipe, outputPipe: Pipe) { + let task = Process() + let outpipe = Pipe() + let errpipe = Pipe() + + //stars a process object and then return the outputs + task.launchPath = cmd + task.arguments = args + task.standardOutput = outpipe + task.standardError = errpipe + task.launch() + + return (task, errpipe, outpipe) +} + +public func runCommand(cmd : String, args : [String]) -> (output: [String], error: [String], exitCode: Int32) { + var output : [String] = [] + var error : [String] = [] + var status = Int32() + //runs a process object and then return the outputs + + let p = startCommand(cmd: cmd, args: args) + + p.process.waitUntilExit() + let outdata = p.outputPipe.fileHandleForReading.readDataToEndOfFile() + if var string = String(data: outdata, encoding: .utf8) { + string = string.trimmingCharacters(in: .newlines) + output = string.components(separatedBy: "\n") + } + + let errdata = p.errorPipe.fileHandleForReading.readDataToEndOfFile() + if var string = String(data: errdata, encoding: .utf8) { + string = string.trimmingCharacters(in: .newlines) + error = string.components(separatedBy: "\n") + } + + status = p.process.terminationStatus + + return (output, error, status) +} + +fileprivate func getOutSimply(cmd: String, isErr: Bool) -> String{ + //ths function runs a command on the sh shell and it does return the output or the error produced + var ret = [String]() + + if isErr{ + ret = runCommand(cmd: "/bin/sh", args: ["-c", cmd]).error + }else{ + ret = runCommand(cmd: "/bin/sh", args: ["-c", cmd]).output + } + + var rett = "" + for r in ret{ + rett += r + "\n" + } + if !rett.isEmpty{ + rett.characters.removeLast() + } + + return rett +} + +public func getErr(cmd: String) -> String{ + //ths function runs a command on the sh shell and it does return the error output + return getOutSimply(cmd: cmd, isErr: true) +} + +public func getOut(cmd: String) -> String{ + //ths function runs a command on the sh shell and it does return the output + return getOutSimply(cmd: cmd, isErr: false) +} diff --git a/TINU/SharedInstances.swift b/TINU/SharedInstances.swift new file mode 100644 index 0000000..83021a2 --- /dev/null +++ b/TINU/SharedInstances.swift @@ -0,0 +1,261 @@ +// +// SharedInstances.swift +// TINU +// +// Created by Pietro Caruso on 24/08/17. +// Copyright © 2017 Pietro Caruso. All rights reserved. +// + +import Foundation +import AppKit + +//this file just contains some usefoul extensions and methos for the UI + +extension NSViewController{ + public func openSubstituteWindow(windowStoryboardID: String, sender: Any){ + + let tempPos = self.view.window?.frame.origin + + let viewController: NSViewController? = storyboard?.instantiateController(withIdentifier: windowStoryboardID) as? NSViewController + + if viewController != nil{ + //presentViewControllerAsModalWindow(viewController!) + + //self.dismiss(sender) + //self.view.window?.windowController?.close() + + if self.view.window != nil{ + self.view.window?.contentViewController = viewController + + self.view.window?.contentView = viewController?.view + + if tempPos != nil{ + self.view.window?.setFrameOrigin(tempPos!) + } + + self.view.exitFullScreenMode(options: nil) + + self.dismiss(self) + }else{ + // :-( + } + }else{ + // :-( + } + } + + public func exportOptions(enabled: Bool){ + if enabled{ + if let _ = NSApplication.shared().delegate as? AppDelegate{ + //setup menu while windows canges + } + } + } + + public var window: NSWindow!{ + get{ + return self.view.window + } + } + + +} + +extension NSWindow{ + public var isClosingEnabled: Bool{ + set{ + if newValue{ + self.styleMask.insert(.closable) + self.standardWindowButton(.closeButton)?.isEnabled = true + }else{ + self.styleMask.remove(.closable) + self.standardWindowButton(.closeButton)?.isEnabled = false + } + } + get{ + return self.styleMask.contains(.closable) && (self.standardWindowButton(.closeButton)?.isEnabled)! + } + } + + public func exitFullScreen(){ + if self.styleMask.contains(.fullScreen){ + self.toggleFullScreen(false) + } + } + + public func makeFullScreen(){ + if self.styleMask.contains(.fullScreen) == false{ + self.toggleFullScreen(true) + } + } + + public var isFullScreenEnaled: Bool{ + set{ + if newValue{ + self.styleMask.insert(.resizable) + self.standardWindowButton(.zoomButton)?.isEnabled = true + }else{ + self.styleMask.remove([.resizable]) + self.standardWindowButton(.zoomButton)?.isEnabled = false + } + } + get{ + return self.styleMask.contains(.resizable) && (self.standardWindowButton(.zoomButton)?.isEnabled)! + } + } + + public var isMiniaturizeEnaled: Bool{ + set{ + if newValue{ + self.styleMask.insert(.miniaturizable) + self.standardWindowButton(.miniaturizeButton)?.isEnabled = true + }else{ + self.styleMask.remove([.miniaturizable]) + self.standardWindowButton(.miniaturizeButton)?.isEnabled = false + } + } + get{ + return self.styleMask.contains(.miniaturizable) && (self.standardWindowButton(.miniaturizeButton)?.isEnabled)! + } + } +} + +extension NSTextView{ + public var text: String{ + set{ + self.string = newValue + } + get{ + if let s = self.string{ + return s + }else{ + return "" + } + } + } +} + +extension NSView { + + var backgroundColor: NSColor? { + get { + if let colorRef = self.layer?.backgroundColor { + return NSColor(cgColor: colorRef) + } else { + return nil + } + } + set { + self.wantsLayer = true + self.layer?.backgroundColor = newValue?.cgColor + } + } +} + +extension String{ + public func copy()-> String{ + return String(self.characters) + } +} + +@IBDesignable +class HyperTextField: NSTextField { + @IBInspectable var href: String = "" + + override func awakeFromNib() { + super.awakeFromNib() + + let attributes: [String: AnyObject] = [ + NSForegroundColorAttributeName: NSColor.blue + ,NSUnderlineStyleAttributeName: NSUnderlineStyle.styleSingle.rawValue as AnyObject, NSCursorAttributeName: NSCursor.pointingHand() + ] + self.attributedStringValue = NSAttributedString(string: self.stringValue, attributes: attributes) + + } + + override func mouseDown(with event: NSEvent) { + NSWorkspace.shared().open(URL(string: self.href)!) + } +} + +public func checkAppMode(){ + var inoffensive = false + + if simulateCreateinstallmediaFail != nil{ + inoffensive = true + print("Inoffensive mode on") + } + + if simulateFormatFail || simulateFormatSkip || simulateNoUsableApps || simulateNoUsableDrives || simulateFirstAuthCancel || simulateAbnormalExitcode || simulateSecondAuthCancel || simulateConfirmGetDataFail || inoffensive { + sharedTestingMode = true + print("This copy of tinu is running in a testing mode") + }else{ + sharedTestingMode = false + } +} + +public func checkUser(){ + let u = NSUserName() + if !FileManager.default.fileExists(atPath: "/usr/bin/sudo") && u == "root"{ + print("Running on the root user on a mac os recovery") + sharedIsOnRecovery = true + }else{ + print("Running on this user: " + u) + } +} + +public func msgBox(_ title: String,_ text: String,_ style: NSAlertStyle){ + let a = NSAlert() + a.messageText = title + a.informativeText = text + a.alertStyle = style + a.runModal() +} + +public func dialogOKCancel(question: String, text: String, style: NSAlertStyle) -> Bool { + let myPopup: NSAlert = NSAlert() + myPopup.messageText = question + myPopup.informativeText = text + myPopup.alertStyle = style + myPopup.addButton(withTitle: "OK") + myPopup.addButton(withTitle: "Cancel") + let res = myPopup.runModal() + if res == NSAlertFirstButtonReturn { + return false + } + return true +} + +public func dialogYesNo(question: String, text: String, style: NSAlertStyle) -> Bool { + let myPopup: NSAlert = NSAlert() + myPopup.messageText = question + myPopup.informativeText = text + myPopup.alertStyle = style + myPopup.addButton(withTitle: "Yes") + myPopup.addButton(withTitle: "No") + let res = myPopup.runModal() + if res == NSAlertFirstButtonReturn { + return false + } + return true +} + +public func getDriveNameFromBSDID(_ id: String) -> String!{ + if let session = DASessionCreate(kCFAllocatorDefault) { + + let mountedVolumes = FileManager.default.mountedVolumeURLs(includingResourceValuesForKeys: [], options: [])! + for volume in mountedVolumes { + if let disk = DADiskCreateFromVolumePath(kCFAllocatorDefault, session, volume as CFURL) { + if let bsd = DADiskGetBSDName(disk){ + if let bsdName = String.init(utf8String: bsd) { + if "/dev/" + bsdName == id{ + return volume.path + } + } + } + } + } + } + + return nil +} diff --git a/TINU/SharedVariables.swift b/TINU/SharedVariables.swift new file mode 100644 index 0000000..c6a7841 --- /dev/null +++ b/TINU/SharedVariables.swift @@ -0,0 +1,75 @@ +// +// SharedVariables.swift +// TINU +// +// Created by ITzTravelInTime on 11/09/17. +// Copyright © 2017 Pietro Caruso. All rights reserved. +// + +import AppKit + +//REQUIRED TO LET THE APP TO WORK PROPERLY +//here there are all the variables that are accessible in all the app to determinate the status of the app and what it is doing + +//this variable is a storyboard that is used to instanciate some windows +public var sharedStoryboard: NSStoryboard! +//sets if the license window has to be show +public var showLicense = true +//this varible tells if the app is running on a recovery/installer mode mac +public var sharedIsOnRecovery = false + +//just some shared variables to setup the final result window +public var sharedIsOk = false +public var sharedMessage = "" +public var sharedTitle = "" + +//this variable stells if the pre-creation is in progress +public var sharedIsPreCreationInProgress = false + +//this tells to the rest of the app if the creation of the installer is in execution +public var sharedIsCreationInProgress = false + +//this variable is the drive or partition that the user has selected +public var sharedVolume: String! +//this variable is the bsd name of the drive or partition currently selected by the user +public var sharedBSDDrive: String! +//this is the path of the mac os installer application that the user has selected +public var sharedApp: String! +//this varable tells to the app if the selected volume or drive needs to be reformatted using hfs+ (deprecated) +//public var sharedVolumeNeedsFormat: Bool! +//this variable tells to the app if the selected drive needs to be formatted using GUID partition method +public var sharedVolumeNeedsPartitionMethodChange: Bool! + +//this variable tells to the app to install macos on the targetvolume using the target app (experimental, to keep disabled at the moment because it does not seems to work) +public var sharedInstallMac: Bool = false + +//this variable returns the name of the current executable used by the app +public var sharedExecutableName: String{ + get{ + if sharedInstallMac{ + return "startosinstall" + } + return "createinstallmedia" + } +} + +//this variable is used to determinate if the interface must use the vibrant look, it will not be enabled if the apop is used in a mac os installer or recovery, because the effects without graphics acceleration will cause only lagg +public var sharedUseVibrant = false + +//this is used to determinate if the app is running in testing mode +public var sharedTestingMode = false + +//this gives the prefix for the window title +public var sharedWindowTitlePrefix: String{ + get{ + if sharedTestingMode{ + return "TINU (testing version)" + } + return "TINU" + } +} + +//variables used to manage the creation process +public var process = Process() +public var errorPipe = Pipe() +public var outputPipe = Pipe() diff --git a/TINU/SudoManager.swift b/TINU/SudoManager.swift new file mode 100644 index 0000000..5350324 --- /dev/null +++ b/TINU/SudoManager.swift @@ -0,0 +1,200 @@ +// +// File.swift +// TINU +// +// Created by Pietro Caruso on 20/09/17. +// Copyright © 2017 Pietro Caruso. All rights reserved. +// + +import Foundation + +fileprivate class SudoManager{ + //this variable stores the password, and yes, i agree with you, this is not a safe way to do that, but i can't ask the passowrd to the user a lot of times, if you have a better idea to store the passowrd contact me, i think that it vould be something like the keychain, just remember that the poassord has to be converted into a string format tha could be used with sudo in a command string + fileprivate var pass: String! + //this is function the gets the password that needs to be used in the scripts + fileprivate var text = "TINU needs again the password (Your account must have a password that is not empty):" + fileprivate func askForPassword() -> String!{ + //if we are into the recovery we do not need the password + if sharedIsOnRecovery{ + return "" + } + log("Asking for password") + //asks for the password using a dialog window created with the apple script + let p = getOut(cmd: "echo \"$(osascript -e 'Tell application \"System Events\" to display dialog \"" + text + "\" default answer \"\" with hidden answer' -e 'text returned of result' 2>/dev/null)\"") + //if the user does press the cancel button on the dialog window the output is an empty string so we come back to the previuous window + if p == "" || p == "\n"{ + //aborted + log("Get password aborted") + return nil + } + + //the user typed a password, so we check it using the checkPassword function + if !checkPassword(p){ + log("passord not correct") + text = "The password is not correct, enter it again (Your account must have a password that is not empty):" + //if the password is not correct the function recursively calls his self to ask it again + return askForPassword() + } + text = "TINU needs again the password (Your account must have a password that is not empty):" + + //eveything is ok and the password is returned + return p + } + + //this function checks a given password passed by argument + fileprivate func checkPassword(_ password: String!) -> Bool{ + if password == nil{ + return false + } + + if password.isEmpty{ + return false + } + //we check if it's correct by trying to call sudo with that password and reading the output + return !(getErr(cmd: "echo \"" + password + "\" | sudo -S echo \"correct\"").contains("Password:Sorry, try again.")) + } + + //this function uses the checkPassword function to determinate if the stored password is correct + fileprivate func checkPasswordStored() -> Bool{ + return checkPassword(pass) + } + + //this function return the prefix to use when performing commands that needs sudo + fileprivate func getSudoPrefix() -> String!{ + var prefix = "" + //checks if we are not on recovery, if yes, the command must use sudo + if !sharedIsOnRecovery{ + //just checks the password, for the sudo + if !checkPasswordStored(){ + pass = askForPassword() + if pass == nil{ + return nil + } + } + //puts the prefix in the sudo command + prefix = "echo \"" + pass + "\" | sudo -S " + } + + return prefix + } + + //used to erase the password when it's no longer needed + fileprivate func erasePassword(){ + pass = nil + } +} + +fileprivate var sm = SudoManager() +//shared functions for sensible tasks +public func erasePassword(){ + sm.erasePassword() + //not necessary, but it's done just to for safety + sm = SudoManager() +} + +//this functions executes commands using sudo, if needed, they are there becuse the functions that will use the password are fileprivate, this because we need to protect the password +public func getErrWithSudo(cmd: String) -> String!{ + if let p = sm.getSudoPrefix(){ + //ths function runs a command on the sh shell and it does return the error output + return getErr(cmd: p + cmd) + }else{ + return nil + } +} + +public func getOutWithSudo(cmd: String) -> String!{ + if let p = sm.getSudoPrefix(){ + //ths function runs a command on the sh shell and it does return the output + return getOut(cmd: p + cmd) + }else{ + return nil + } +} + +public func runCommandWithSudo(cmd : String, args : [String]) -> (output: [String], error: [String], exitCode: Int32)! { + if sharedIsOnRecovery{ + return runCommand(cmd: cmd, args: args) + } + + if let p = sm.getSudoPrefix(){ + log("Password got with success") + var arg = [String]() + var isc = false + for i in 0...args.count - 1{ + let a = args[i] + if i == 0{ + if a == "-c"{ + isc = true + arg.append(a) + }else{ + arg.append(p + a) + } + }else if i == 1 && isc{ + arg.append(p + a) + }else{ + arg.append(a) + } + } + + /*if sharedIsPreCreationInProgress{ + if let w = sharedWindow.contentViewController as? InstallingViewController{ + w.cancelButton.isEnabled = true + + if let ww = sharedWindow{ + //w.isMiniaturizeEnaled = false + ww.isClosingEnabled = true + //ww.canHide = false + } + } + }*/ + + return runCommand(cmd: cmd, args: arg) + }else{ + return nil + } + +} + +public func startCommandWithSudo(cmd : String, args : [String]) -> (process: Process, errorPipe: Pipe, outputPipe: Pipe)! { + if sharedIsOnRecovery{ + return startCommand(cmd: cmd, args: args) + } + + if let p = sm.getSudoPrefix(){ + log("Password got with success") + var arg = [String]() + var isc = false + for i in 0...args.count - 1{ + let a = args[i] + if i == 0{ + if a == "-c"{ + isc = true + arg.append(a) + }else{ + arg.append(p + a) + } + }else if i == 1 && isc{ + arg.append(p + a) + }else{ + arg.append(a) + } + } + + + /*if sharedIsPreCreationInProgress{ + if let w = sharedWindow.contentViewController as? InstallingViewController{ + w.cancelButton.isEnabled = true + + if let ww = sharedWindow{ + //w.isMiniaturizeEnaled = false + ww.isClosingEnabled = true + //ww.canHide = false + } + } + }*/ + return startCommand(cmd: cmd, args: arg) + }else{ + return nil + } + +} diff --git a/TINU/TestingVariables.swift b/TINU/TestingVariables.swift new file mode 100644 index 0000000..750e18f --- /dev/null +++ b/TINU/TestingVariables.swift @@ -0,0 +1,45 @@ +// +// TestingVariables.swift +// TINU +// +// Created by Pietro Caruso on 17/09/17. +// Copyright © 2017 Pietro Caruso. All rights reserved. +// + +import Foundation + +//those variables are used to simulate some scenarios to test the different screens and error messages + +//this variable tells to the app to simulate a scenario when there were no drives found +public let simulateNoUsableDrives = false +//this variable tells to the application to simulate a situation when there wehere no mac os installer apps found +public let simulateNoUsableApps = false +//this variable tells to the appliation to simulate a situation when the confirm windows fails to get the drive and app data +public let simulateConfirmGetDataFail = false + +//testing variables for the installer creation screen + +//this varable tells to the app to simulate asituation in which the the install window fails to get the drive and app data +public let simulateInstallGetDataFail = false + +//this tells to simulate a cancel into the first auth step +public let simulateFirstAuthCancel = false + +//this tells to simulate a cancel into the second auth step +public let simulateSecondAuthCancel = false + +//this variable tell to the app to not format the drive chosen if it needs to be formatted +public var simulateFormatSkip = false + +//this tells to simulate a failure of the drive format code +public let simulateFormatFail = false + +//this tells to simulate a createinstall media failure or success, if it is nil it will perform createinstallmedia as usual. +//Here is what happens for each of the possible values: +// - false: simulate installer creation success +// - true: simulate installer creation fail +// - nil: (default) executes createinstallmedia as usual +public let simulateCreateinstallmediaFail: Bool! = nil + +//this tells to the application to simule an abnormal opcode result after execution of the scripts +public var simulateAbnormalExitcode = false diff --git a/TINUTests/.DS_Store b/TINUTests/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/TINUTests/.DS_Store differ diff --git a/TINUTests/Info.plist b/TINUTests/Info.plist new file mode 100644 index 0000000..6c6c23c --- /dev/null +++ b/TINUTests/Info.plist @@ -0,0 +1,22 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + + diff --git a/TINUTests/TINUTests.swift b/TINUTests/TINUTests.swift new file mode 100644 index 0000000..7538189 --- /dev/null +++ b/TINUTests/TINUTests.swift @@ -0,0 +1,36 @@ +// +// TINUTests.swift +// TINUTests +// +// Created by Pietro Caruso on 24/08/17. +// Copyright © 2017 Pietro Caruso. All rights reserved. +// + +import XCTest +@testable import TINU + +class TINUTests: XCTestCase { + + override func setUp() { + super.setUp() + // Put setup code here. This method is called before the invocation of each test method in the class. + } + + override func tearDown() { + // Put teardown code here. This method is called after the invocation of each test method in the class. + super.tearDown() + } + + func testExample() { + // This is an example of a functional test case. + // Use XCTAssert and related functions to verify your tests produce the correct results. + } + + func testPerformanceExample() { + // This is an example of a performance test case. + self.measure { + // Put the code you want to measure the time of here. + } + } + +} diff --git a/TINUUITests/Info.plist b/TINUUITests/Info.plist new file mode 100644 index 0000000..6c6c23c --- /dev/null +++ b/TINUUITests/Info.plist @@ -0,0 +1,22 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + + diff --git a/TINUUITests/TINUUITests.swift b/TINUUITests/TINUUITests.swift new file mode 100644 index 0000000..42233bd --- /dev/null +++ b/TINUUITests/TINUUITests.swift @@ -0,0 +1,36 @@ +// +// TINUUITests.swift +// TINUUITests +// +// Created by Pietro Caruso on 24/08/17. +// Copyright © 2017 Pietro Caruso. All rights reserved. +// + +import XCTest + +class TINUUITests: XCTestCase { + + override func setUp() { + super.setUp() + + // Put setup code here. This method is called before the invocation of each test method in the class. + + // In UI tests it is usually best to stop immediately when a failure occurs. + continueAfterFailure = false + // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. + XCUIApplication().launch() + + // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. + } + + override func tearDown() { + // Put teardown code here. This method is called after the invocation of each test method in the class. + super.tearDown() + } + + func testExample() { + // Use recording to get started writing UI tests. + // Use XCTAssert and related functions to verify your tests produce the correct results. + } + +}