Skip to content
This repository has been archived by the owner on Sep 4, 2018. It is now read-only.

Add proxy support and "Force HTTPS for GitHub" setting #272

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Alcatraz.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
8AD5249F174102F9008B451F /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 8AD524A2174102F9008B451F /* Localizable.strings */; };
8ADC22341A2AD5B800DB7BCA /* ATZPreviewImageButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 8ADC22331A2AD5B800DB7BCA /* ATZPreviewImageButton.m */; };
8AF670C919C2DE8A00E1C168 /* ATZSegmentedControl.m in Sources */ = {isa = PBXBuildFile; fileRef = 8AF670C819C2DE8A00E1C168 /* ATZSegmentedControl.m */; };
FF9ED6C11AFE8670000EF0DF /* ATZConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = FF9ED6C01AFE8670000EF0DF /* ATZConfig.m */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand Down Expand Up @@ -179,6 +180,8 @@
8ADC22331A2AD5B800DB7BCA /* ATZPreviewImageButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ATZPreviewImageButton.m; path = Views/ATZPreviewImageButton.m; sourceTree = "<group>"; };
8AF670C719C2DE8A00E1C168 /* ATZSegmentedControl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ATZSegmentedControl.h; path = Views/ATZSegmentedControl.h; sourceTree = "<group>"; };
8AF670C819C2DE8A00E1C168 /* ATZSegmentedControl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ATZSegmentedControl.m; path = Views/ATZSegmentedControl.m; sourceTree = "<group>"; };
FF9ED6BF1AFE8670000EF0DF /* ATZConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ATZConfig.h; sourceTree = "<group>"; };
FF9ED6C01AFE8670000EF0DF /* ATZConfig.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ATZConfig.m; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -349,6 +352,8 @@
8917DA131726B63B00F0B2D2 /* ATZDownloader.m */,
8917DA141726B63B00F0B2D2 /* ATZGit.h */,
8917DA151726B63B00F0B2D2 /* ATZGit.m */,
FF9ED6BF1AFE8670000EF0DF /* ATZConfig.h */,
FF9ED6C01AFE8670000EF0DF /* ATZConfig.m */,
8917DA161726B63B00F0B2D2 /* ATZShell.h */,
8917DA171726B63B00F0B2D2 /* ATZShell.m */,
89B4F2BC172FF5AC001FD2E3 /* ATZPBXProjParser.h */,
Expand Down Expand Up @@ -527,6 +532,7 @@
8AA0F57A19C2210600556AAF /* ATZFillableButton.m in Sources */,
8917DA191726B63B00F0B2D2 /* ATZGit.m in Sources */,
8917DA1A1726B63B00F0B2D2 /* ATZShell.m in Sources */,
FF9ED6C11AFE8670000EF0DF /* ATZConfig.m in Sources */,
89B4F2BE172FF5AC001FD2E3 /* ATZPBXProjParser.m in Sources */,
8A133EE319C235FD0068FCB9 /* ATZPackageListTableCellView.m in Sources */,
8A1732A81A2694BB002033D6 /* NSColor+Alcatraz.m in Sources */,
Expand Down
27 changes: 21 additions & 6 deletions Alcatraz/ATZPluginWindowController.xib
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6254" systemVersion="14B25" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="7706" systemVersion="14E46" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6254"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="7706"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="ATZPluginWindowController">
<connections>
<outlet property="forceHttpsForGitHubMenuItem" destination="pfq-fO-C8c" id="rSh-Lt-sYV"/>
<outlet property="installationStateSegmentedControl" destination="reu-CB-C0i" id="Dsc-6U-bwl"/>
<outlet property="packageTypeSegmentedControl" destination="Wxk-Va-YMt" id="Kp4-mR-1VM"/>
<outlet property="previewImageView" destination="47h-q5-ax2" id="hgU-Rw-Txf"/>
Expand All @@ -23,7 +24,7 @@
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES" unifiedTitleAndToolbar="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="196" y="240" width="545" height="449"/>
<rect key="screenRect" x="0.0" y="0.0" width="1280" height="777"/>
<rect key="screenRect" x="0.0" y="0.0" width="1920" height="1177"/>
<view key="contentView" id="EiT-Mj-1SZ">
<rect key="frame" x="0.0" y="0.0" width="545" height="449"/>
<autoresizingMask key="autoresizingMask"/>
Expand Down Expand Up @@ -90,9 +91,10 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" selectionHighlightStyle="none" columnReordering="NO" multipleSelection="NO" emptySelection="NO" autosaveColumns="NO" typeSelect="NO" rowSizeStyle="automatic" viewBased="YES" id="Xmj-hd-CPE">
<rect key="frame" x="0.0" y="0.0" width="545" height="0.0"/>
<autoresizingMask key="autoresizingMask"/>
<size key="intercellSpacing" width="3" height="2"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
<color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
<tableColumns>
<tableColumn editable="NO" width="542" minWidth="40" maxWidth="1000" id="JR1-SH-OCh">
Expand Down Expand Up @@ -189,7 +191,7 @@
<popUpButtonCell key="cell" type="roundTextured" bezelStyle="texturedRounded" imagePosition="below" alignment="center" lineBreakMode="truncatingTail" borderStyle="border" imageScaling="proportionallyDown" inset="2" pullsDown="YES" arrowPosition="noArrow" preferredEdge="maxY" altersStateOfSelectedItem="NO" id="GAy-JH-6Fr">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="menu"/>
<menu key="menu" showsStateColumn="NO" id="gCj-Sg-VLj">
<menu key="menu" id="gCj-Sg-VLj">
<items>
<menuItem image="NSActionTemplate" hidden="YES" id="Mki-6q-Srm"/>
<menuItem title="Reload Packages" id="FEX-wb-X1U">
Expand All @@ -209,6 +211,19 @@
<action selector="updatePackageRepoPath:" target="-2" id="Cp9-H4-4ZG"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="hKt-1w-8NR"/>
<menuItem title="Set HTTP Proxy" id="imq-85-s9N">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="updateSetHttpProxy:" target="-2" id="qSA-Wr-sfm"/>
</connections>
</menuItem>
<menuItem title="Force HTTPS for GitHub" id="pfq-fO-C8c">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="updateForceHttpsForGitHub:" target="-2" id="Nsf-VU-IIy"/>
</connections>
</menuItem>
</items>
</menu>
</popUpButtonCell>
Expand All @@ -228,7 +243,7 @@
<windowStyleMask key="styleMask" titled="YES" closable="YES" resizable="YES" utility="YES" HUD="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="139" y="81" width="276" height="378"/>
<rect key="screenRect" x="0.0" y="0.0" width="1280" height="777"/>
<rect key="screenRect" x="0.0" y="0.0" width="1920" height="1177"/>
<view key="contentView" id="WQe-dv-pdE">
<rect key="frame" x="0.0" y="0.0" width="276" height="378"/>
<autoresizingMask key="autoresizingMask"/>
Expand Down
12 changes: 6 additions & 6 deletions Alcatraz/Alcatraz-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@
<string>640F884E-CE55-4B40-87C0-8869546CAB7A</string>
<string>992275C1-432A-4CF7-B659-D84ED6D42D3F</string>
<string>A16FF353-8441-459E-A50C-B071F53F51B7</string>
<string>9F75337B-21B4-4ADC-B558-F9CADF7073A7</string>
<string>992275C1-432A-4CF7-B659-D84ED6D42D3F</string>
<string>E969541F-E6F9-4D25-8158-72DC3545A6C6</string>
<string>8DC44374-2B35-4C57-A6FE-2AD66A36AAD9</string>
<string>AABB7188-E14E-4433-AD3B-5CD791EAD9A3</string>
<string>7FDF5C7A-131F-4ABB-9EDC-8C5F8F0B8A90</string>
<string>9F75337B-21B4-4ADC-B558-F9CADF7073A7</string>
<string>992275C1-432A-4CF7-B659-D84ED6D42D3F</string>
<string>E969541F-E6F9-4D25-8158-72DC3545A6C6</string>
<string>8DC44374-2B35-4C57-A6FE-2AD66A36AAD9</string>
<string>AABB7188-E14E-4433-AD3B-5CD791EAD9A3</string>
<string>7FDF5C7A-131F-4ABB-9EDC-8C5F8F0B8A90</string>
</array>
<key>XC4Compatible</key>
<true/>
Expand Down
38 changes: 31 additions & 7 deletions Alcatraz/Controllers/ATZPluginWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
// THE SOFTWARE.

#import <Cocoa/Cocoa.h>
#import "ATZConfig.h"

#import "ATZPluginWindowController.h"
#import "ATZDownloader.h"
Expand Down Expand Up @@ -146,24 +147,47 @@ - (IBAction)reloadPackages:(id)sender {
}];
}

- (IBAction)updatePackageRepoPath:(id)sender {
// present dialog with text field, update repo path, redownload package list
- (IBAction)updateForceHttpsForGitHub:(NSMenuItem *)sender {
sender.state = !sender.state;
[ATZConfig setForceHttps:sender.state];
}

- (NSAlert *)createAlert:(NSString *)messageText {
NSAlert *alert = [NSAlert new];
alert.messageText = [Alcatraz localizedStringForKey:@"change-path.message"];
alert.messageText = [Alcatraz localizedStringForKey:messageText];
[alert addButtonWithTitle:[Alcatraz localizedStringForKey:@"actions.save"]];
[alert addButtonWithTitle:[Alcatraz localizedStringForKey:@"actions.cancel"]];
return alert;
}

- (IBAction)updateSetHttpProxy:(id)sender {
NSAlert *alert = [self createAlert:@"change-http-proxy.message"];
NSTextField *input = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 500, 24)];
input.stringValue = [ATZConfig httpProxy];
alert.accessoryView = input;

if ([alert runModal] == NSAlertFirstButtonReturn) {
NSLog(@"Proxy set to: %@", input.stringValue);
[ATZConfig setHttpProxy:input.stringValue];
}
}


- (IBAction)updatePackageRepoPath:(id)sender {
// present dialog with text field, update repo path, redownload package list
NSAlert *alert = [self createAlert:@"change-path.message"];
NSTextField *input = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 500, 24)];
input.stringValue = [ATZDownloader packageRepoPath];
input.stringValue = [ATZConfig packageRepoPath];
alert.accessoryView = input;

if ([alert runModal] == NSAlertFirstButtonReturn && ![input.stringValue isEqualToString:[ATZDownloader packageRepoPath]]) {
[ATZDownloader setPackagesRepoPath:input.stringValue];
if ([alert runModal] == NSAlertFirstButtonReturn && ![input.stringValue isEqualToString:[ATZConfig packageRepoPath]]) {
[ATZConfig setPackagesRepoPath:input.stringValue];
[self reloadPackages:nil];
}
}

- (IBAction)resetPackageRepoPath:(id)sender {
[ATZDownloader resetPackageRepoPath];
[ATZConfig resetPackageRepoPath];
[self reloadPackages:nil];
}

Expand Down
42 changes: 42 additions & 0 deletions Alcatraz/Helpers/ATZConfig.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//
// ATZConfig.h
// Alcatraz
//
// Created by Max on 09/05/15.
// Copyright (c) 2013 Marin Usalj | supermar.in
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#import <Foundation/Foundation.h>

@interface ATZConfig : NSObject

+ (NSString *)packageRepoPath;
+ (void)setPackagesRepoPath:(NSString *)path;
+ (void)resetPackageRepoPath;

+ (NSString *)httpProxy;
+ (void)setHttpProxy:(NSString *)path;
+ (void)resetHttpProxy;

+ (BOOL)forceHttps;
+ (void)setForceHttps:(BOOL)httpOnly;
+ (void)resetForceHttps;

@end
94 changes: 94 additions & 0 deletions Alcatraz/Helpers/ATZConfig.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
//
// ATZConfig.m
// Alcatraz
//
// Created by Max on 09/05/15.
// Copyright (c) 2013 Marin Usalj | supermar.in
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#import "ATZConfig.h"

static NSString *const ATZ_HTTP_PROXY_KEY = @"ATZGitHttpProxy";
static NSString *const ATZ_FORCE_HTTPS_KEY = @"ATZForceHttps";
static NSString *const ATZ_REPO_KEY = @"ATZRepoPath";
static NSString *const ATZ_DEFAULT_REPO_PATH = @"https://raw.github.com/supermarin/alcatraz-packages/master/packages.json";

@implementation ATZConfig

#pragma mark - Package Repo

+ (NSString *)packageRepoPath {
NSString *path = [[NSUserDefaults standardUserDefaults] stringForKey:ATZ_REPO_KEY];
if (!path) {
path = ATZ_DEFAULT_REPO_PATH;
}

return path;
}

+ (void)resetPackageRepoPath {
[[NSUserDefaults standardUserDefaults] removeObjectForKey:ATZ_REPO_KEY];
}

+ (void)setPackagesRepoPath:(NSString *)path {
[[NSUserDefaults standardUserDefaults] setObject:path forKey:ATZ_REPO_KEY];
}

#pragma mark - Http Proxy

+ (NSString *)httpProxy {
NSString *proxy = [[NSUserDefaults standardUserDefaults] stringForKey:ATZ_HTTP_PROXY_KEY];

if (!proxy) {
proxy = @"";
}

return proxy;
}

+ (void)resetHttpProxy {
[[NSUserDefaults standardUserDefaults] removeObjectForKey:ATZ_HTTP_PROXY_KEY];
}

+ (void)setHttpProxy:(NSString *)proxy {
[[NSUserDefaults standardUserDefaults] setObject:proxy forKey:ATZ_HTTP_PROXY_KEY];
}

#pragma mark - Http Only

+ (BOOL)forceHttps {
BOOL forceHttps = [[NSUserDefaults standardUserDefaults] boolForKey:ATZ_FORCE_HTTPS_KEY];

if (!forceHttps) {
forceHttps = NO;
}

return forceHttps;
}

+ (void)resetForceHttps {
[[NSUserDefaults standardUserDefaults] removeObjectForKey:ATZ_FORCE_HTTPS_KEY];
}

+ (void)setForceHttps:(BOOL)forceHttps {
[[NSUserDefaults standardUserDefaults] setBool:forceHttps forKey:ATZ_FORCE_HTTPS_KEY];
}

@end
Loading