Browse Source

made it look nicer, made it possible for you to replace the 'downloaded' payloads with different files and it will still proceed after a stern warning if you decide to.

Kevin Bradley 6 years ago
parent
commit
7c3a46efa8

+ 4 - 0
nitoTV4Installer.xcodeproj/project.pbxproj

@@ -7,6 +7,7 @@
 	objects = {
 
 /* Begin PBXBuildFile section */
+		3277C688201F0E680023E0EA /* front.png in Resources */ = {isa = PBXBuildFile; fileRef = 3277C687201F0B280023E0EA /* front.png */; };
 		32D633E42019876B00D091A0 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 32D633E32019876B00D091A0 /* AppDelegate.m */; };
 		32D633E62019876B00D091A0 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 32D633E52019876B00D091A0 /* Assets.xcassets */; };
 		32D633E92019876B00D091A0 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 32D633E72019876B00D091A0 /* MainMenu.xib */; };
@@ -24,6 +25,7 @@
 /* End PBXBuildFile section */
 
 /* Begin PBXFileReference section */
+		3277C687201F0B280023E0EA /* front.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = front.png; sourceTree = "<group>"; };
 		32D633DF2019876B00D091A0 /* nitoTV4Installer.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = nitoTV4Installer.app; sourceTree = BUILT_PRODUCTS_DIR; };
 		32D633E22019876B00D091A0 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
 		32D633E32019876B00D091A0 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
@@ -104,6 +106,7 @@
 				32D6340D201989CA00D091A0 /* nitoTV4Installer.pch */,
 				32D633E52019876B00D091A0 /* Assets.xcassets */,
 				32D633E72019876B00D091A0 /* MainMenu.xib */,
+				3277C687201F0B280023E0EA /* front.png */,
 				32D633EA2019876B00D091A0 /* Info.plist */,
 				32D633EB2019876B00D091A0 /* main.m */,
 				32D633ED2019876B00D091A0 /* nitoTV4Installer.entitlements */,
@@ -220,6 +223,7 @@
 			files = (
 				32D633E62019876B00D091A0 /* Assets.xcassets in Resources */,
 				32D633E92019876B00D091A0 /* MainMenu.xib in Resources */,
+				3277C688201F0E680023E0EA /* front.png in Resources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

BIN
nitoTV4Installer.zip


+ 78 - 27
nitoTV4Installer/AppDelegate.m

@@ -88,7 +88,36 @@ static NSString *appleTVAddress = nil;
     
 }
 
-- (void)downloadFile:(NSString *)thePayload
+- (void)downloadFile:(NSString *)thePayload toLocation:(NSString *)downloadLocation
+{
+    statusLabel.stringValue = [NSString stringWithFormat:@"Downloading: %@...", thePayload.lastPathComponent];
+    
+    //get the stream we want to download
+    
+    
+    
+    [downloadFile downloadFileWithURL:[NSURL URLWithString:thePayload] toLocation:downloadLocation progress:^(double percentComplete) {
+        
+        [self setDownloadProgress:percentComplete];
+        
+    } completed:^(NSString *downloadedFile) {
+        //[self hideProgress];
+        self.downloading = false;
+        
+        [self setDownloadProgress:0];
+        statusLabel.stringValue = [NSString stringWithFormat:@"Uploading file %@....", downloadedFile.lastPathComponent];
+        
+        
+        [self handleDownloadFile:downloadedFile];
+        
+        
+        
+        //[self uploadFile:downloadedFile];
+        
+    }];
+}
+
+- (void)processFile:(NSString *)thePayload
 {
     //we're already downloading, cancel
     //TODO: make downloading NSOperation/NSOperationQueue based
@@ -128,7 +157,49 @@ static NSString *appleTVAddress = nil;
             default:
                 break;
         }
-       if( [self verifyChecksum:hash onFile:downloadLocation])
+        
+        
+        BOOL verify = [self verifyChecksum:hash onFile:downloadLocation];
+        
+        if (!verify)
+        {
+            NSLog(@"invalid selection");
+            NSAlert *alert = [NSAlert alertWithMessageText:@"This payload does not match our checksum, if you did not modify the payload you should not proceed any further! Otherwise press continue."
+                                             defaultButton:@"Cancel"
+                                           alternateButton:@"Continue"
+                                               otherButton:@"Download Again"
+                                 informativeTextWithFormat:@""];
+            
+            alert.alertStyle = NSCriticalAlertStyle;
+            NSInteger button = [alert runModal];
+            
+            switch (button) {
+                    
+                    case NSAlertAlternateReturn:
+                    
+                        [self handleDownloadFile:downloadLocation];
+                    break;
+                    
+                    case NSAlertOtherReturn:
+                    
+                        [self downloadFile:thePayload toLocation:downloadLocation];
+                    break;
+                    
+                    case NSAlertDefaultReturn:
+                    self.mainButton.enabled = YES;
+                    break;
+                    
+                default:
+                    break;
+            }
+        
+        
+        } else {
+             [self handleDownloadFile:downloadLocation];
+        }
+        
+        /*
+       if ([self verifyChecksum:hash onFile:downloadLocation])
        {
            NSLog(@"file validated!");
            
@@ -137,31 +208,9 @@ static NSString *appleTVAddress = nil;
            //completion(true);
            
        }
+         */
     }
-    
-    statusLabel.stringValue = [NSString stringWithFormat:@"Downloading: %@...", thePayload.lastPathComponent];
-    
-    //get the stream we want to download
-    
-    [downloadFile downloadFileWithURL:[NSURL URLWithString:thePayload] toLocation:downloadLocation progress:^(double percentComplete) {
-        
-        [self setDownloadProgress:percentComplete];
-        
-    } completed:^(NSString *downloadedFile) {
-        //[self hideProgress];
-        self.downloading = false;
-        
-        [self setDownloadProgress:0];
-        statusLabel.stringValue = [NSString stringWithFormat:@"Uploading file %@....", downloadedFile.lastPathComponent];
-        
-        
-        [self handleDownloadFile:downloadedFile];
-        
-        
-        
-        //[self uploadFile:downloadedFile];
-        
-    }];
+
     
 }
 
@@ -698,7 +747,9 @@ static NSString *appleTVAddress = nil;
             
           //  NSLog(@"were already bootstrapped!");
         //} else {
-            [self downloadFile:bootstrapPath];
+        
+        [self processFile:bootstrapPath];
+        // [self downloadFile:bootstrapPath];
        // }
        //
         //[self downloadSyslogAndShow:YES];

+ 21 - 13
nitoTV4Installer/Base.lproj/MainMenu.xib

@@ -690,21 +690,21 @@
                     </menu>
                 </menuItem>
             </items>
-            <point key="canvasLocation" x="127" y="415"/>
+            <point key="canvasLocation" x="88" y="-99"/>
         </menu>
-        <window title="nitoTV4Installer" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" id="QvC-M9-y7g">
-            <windowStyleMask key="styleMask" titled="YES" miniaturizable="YES"/>
+        <window allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" id="QvC-M9-y7g">
+            <windowStyleMask key="styleMask" titled="YES" miniaturizable="YES" texturedBackground="YES"/>
             <windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
-            <rect key="contentRect" x="335" y="390" width="442" height="235"/>
+            <rect key="contentRect" x="335" y="390" width="300" height="290"/>
             <rect key="screenRect" x="0.0" y="0.0" width="1920" height="1177"/>
             <view key="contentView" wantsLayer="YES" id="EiT-Mj-1SZ">
-                <rect key="frame" x="0.0" y="0.0" width="442" height="235"/>
+                <rect key="frame" x="0.0" y="0.0" width="300" height="290"/>
                 <autoresizingMask key="autoresizingMask"/>
                 <subviews>
                     <popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="fTc-TT-leC">
-                        <rect key="frame" x="89" y="167" width="234" height="26"/>
+                        <rect key="frame" x="34" y="181" width="234" height="26"/>
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
-                        <popUpButtonCell key="cell" type="push" title="Item 1" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="qTn-1Y-yTu" id="jYa-Xg-NVI">
+                        <popUpButtonCell key="cell" type="push" title="Item 1" bezelStyle="rounded" alignment="center" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="qTn-1Y-yTu" id="jYa-Xg-NVI">
                             <behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
                             <font key="font" metaFont="menu"/>
                             <menu key="menu" id="can-0J-0Wk">
@@ -722,7 +722,7 @@
                         </connections>
                     </popUpButton>
                     <button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="OHh-hg-rQh">
-                        <rect key="frame" x="142" y="44" width="127" height="32"/>
+                        <rect key="frame" x="88" y="27" width="127" height="32"/>
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                         <buttonCell key="cell" type="push" title="Install Payload" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="BEr-UM-Nwz">
                             <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
@@ -734,22 +734,30 @@
                         </connections>
                     </button>
                     <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="rmB-Fy-pOd">
-                        <rect key="frame" x="73" y="135" width="264" height="17"/>
+                        <rect key="frame" x="18" y="149" width="264" height="17"/>
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                         <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="center" id="hH5-bI-NQ4">
-                            <font key="font" metaFont="system"/>
+                            <font key="font" metaFont="system" size="14"/>
                             <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
                             <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
                         </textFieldCell>
                     </textField>
-                    <progressIndicator wantsLayer="YES" horizontalHuggingPriority="750" verticalHuggingPriority="750" fixedFrame="YES" maxValue="100" displayedWhenStopped="NO" bezeled="NO" indeterminate="YES" controlSize="small" style="spinning" translatesAutoresizingMaskIntoConstraints="NO" id="foy-RA-rvh">
-                        <rect key="frame" x="195" y="101" width="16" height="16"/>
+                    <imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="5gk-Db-p0P">
+                        <rect key="frame" x="87" y="223" width="126" height="62"/>
+                        <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+                        <imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyUpOrDown" image="front" id="xCj-Lf-8ff"/>
+                    </imageView>
+                    <progressIndicator wantsLayer="YES" horizontalHuggingPriority="750" verticalHuggingPriority="750" fixedFrame="YES" maxValue="100" displayedWhenStopped="NO" bezeled="NO" indeterminate="YES" style="spinning" translatesAutoresizingMaskIntoConstraints="NO" id="foy-RA-rvh">
+                        <rect key="frame" x="134" y="93" width="32" height="32"/>
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                     </progressIndicator>
                 </subviews>
             </view>
-            <point key="canvasLocation" x="120" y="215.5"/>
+            <point key="canvasLocation" x="23" y="216"/>
         </window>
         <userDefaultsController representsSharedInstance="YES" id="cE9-50-YeO"/>
     </objects>
+    <resources>
+        <image name="front" width="211" height="128"/>
+    </resources>
 </document>

BIN
nitoTV4Installer/front.png