Merge branch 'release/1.3.2'

This commit is contained in:
Charlie Qiu
2016-11-01 11:36:46 +08:00
16 changed files with 100 additions and 103 deletions

View File

@ -8,13 +8,13 @@ Next Generation of [ShadowsocksX](https://github.com/shadowsocks/shadowsocks-iOS
## Why? ## Why?
It's hard to maintain the original implement. There are too many unused code in it. It's hard to maintain the original implementation as there is too much unused code in it.
It also embed ss-local source. It's crazy to maintain depandences of ss-local. It also embeds the ss-local source. It's crazy to maintain dependencies of ss-local.
So it's hard to update ss-local version. So it's hard to update the ss-local version.
Now I just copy the ss-local from home brew. Run ss-local executable as a Launch Agent in background. Now I just copied the ss-local from homebrew. Run ss-local executable as a Launch Agent in the background.
Serve pac js file as a file url. So there are only some souce code related to GUI left. Serve PAC js file as a file URL. So there is only some source code related to GUI left.
Then I rewrite the GUI code by swift. Then I will rewrite the GUI code in Swift.
## Requirements ## Requirements
@ -34,27 +34,27 @@ From [here](https://github.com/shadowsocks/ShadowsocksX-NG/releases/)
## Fetures ## Fetures
- Use ss-local from shadowsocks-libev 2.4.6 - Use ss-local from shadowsocks-libev 2.4.6
- Update PAC by download GFW List from github. - Update PAC by download GFW List from GitHub.
- Show QRCode for current server profile. - Show QRCode for current server profile.
- Scan QRCode from screen. - Scan QRCode from screen.
- Auto launch at login. - Auto launch at login.
- User rules for PAC. - User rules for PAC.
- Support OTA - Support OTA
- An advance preferences panel to configure: - An advanced preferences panel to configure:
- Local socks5 listen address. - Local socks5 listen address.
- Local socks5 listen port. - Local socks5 listen port.
- Local socks5 timeout. - Local socks5 timeout.
- If enable UDP relay. - If enable UDP relay.
- GFW List url. - GFW List URL.
- Manual spesify network service profiles which would be configure the proxy. - Manual specify network service profiles which would be configure the proxy.
- Could reorder shadowsocks profiles by drag & drop in servers preferences panel. - Could reorder shadowsocks profiles by drag & drop in servers preferences panel.
## Different from orignal ShadowsocksX ## Different from orignal ShadowsocksX
Run ss-local as backgroud service through launchd, not in app process. Run ss-local as a background service through launchd, not as an in-app process.
So after you quit the app, the ss-local maybe is still running. So after you quit the app, the ss-local maybe be still running.
Add a manual mode which won't configure the system proxy settings. Added a manual mode which won't configure the system proxy settings.
Then you could configure your apps to use socks5 proxy manual. Then you could configure your apps to use socks5 proxy manual.
## Contributing ## Contributing
@ -69,5 +69,5 @@ ref: [GitFlow](http://nvie.com/posts/a-successful-git-branching-model/)
## License ## License
The project is released under the terms of GPLv3. The project is released under the terms of the GPLv3.

View File

@ -30,9 +30,6 @@
9B3FFF291D08A1DF0019A709 /* user-rule.txt in Resources */ = {isa = PBXBuildFile; fileRef = 9B3FFF281D08A1DF0019A709 /* user-rule.txt */; }; 9B3FFF291D08A1DF0019A709 /* user-rule.txt in Resources */ = {isa = PBXBuildFile; fileRef = 9B3FFF281D08A1DF0019A709 /* user-rule.txt */; };
9B3FFF321D08CEE40019A709 /* SWBQRCodeWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B3FFF311D08CEE40019A709 /* SWBQRCodeWindowController.m */; }; 9B3FFF321D08CEE40019A709 /* SWBQRCodeWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B3FFF311D08CEE40019A709 /* SWBQRCodeWindowController.m */; };
9B3FFF341D08CEF70019A709 /* SWBQRCodeWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 9B3FFF331D08CEF70019A709 /* SWBQRCodeWindowController.xib */; }; 9B3FFF341D08CEF70019A709 /* SWBQRCodeWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 9B3FFF331D08CEF70019A709 /* SWBQRCodeWindowController.xib */; };
9B3FFF381D08CF110019A709 /* jquery.min.js in Resources */ = {isa = PBXBuildFile; fileRef = 9B3FFF351D08CF110019A709 /* jquery.min.js */; };
9B3FFF391D08CF110019A709 /* qrcode.min.js in Resources */ = {isa = PBXBuildFile; fileRef = 9B3FFF361D08CF110019A709 /* qrcode.min.js */; };
9B3FFF3A1D08CF110019A709 /* qrcode.htm in Resources */ = {isa = PBXBuildFile; fileRef = 9B3FFF371D08CF110019A709 /* qrcode.htm */; };
9B3FFF3E1D08D9910019A709 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9B3FFF3D1D08D9910019A709 /* SystemConfiguration.framework */; }; 9B3FFF3E1D08D9910019A709 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9B3FFF3D1D08D9910019A709 /* SystemConfiguration.framework */; };
9B3FFF471D09CD3B0019A709 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B3FFF461D09CD3B0019A709 /* main.m */; }; 9B3FFF471D09CD3B0019A709 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B3FFF461D09CD3B0019A709 /* main.m */; };
9B3FFF4C1D09D8F70019A709 /* install_helper.sh in Resources */ = {isa = PBXBuildFile; fileRef = 9B3FFF4B1D09D8F70019A709 /* install_helper.sh */; }; 9B3FFF4C1D09D8F70019A709 /* install_helper.sh in Resources */ = {isa = PBXBuildFile; fileRef = 9B3FFF4B1D09D8F70019A709 /* install_helper.sh */; };
@ -140,9 +137,6 @@
9B3FFF301D08CEE40019A709 /* SWBQRCodeWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SWBQRCodeWindowController.h; sourceTree = "<group>"; }; 9B3FFF301D08CEE40019A709 /* SWBQRCodeWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SWBQRCodeWindowController.h; sourceTree = "<group>"; };
9B3FFF311D08CEE40019A709 /* SWBQRCodeWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SWBQRCodeWindowController.m; sourceTree = "<group>"; }; 9B3FFF311D08CEE40019A709 /* SWBQRCodeWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SWBQRCodeWindowController.m; sourceTree = "<group>"; };
9B3FFF331D08CEF70019A709 /* SWBQRCodeWindowController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = SWBQRCodeWindowController.xib; sourceTree = "<group>"; }; 9B3FFF331D08CEF70019A709 /* SWBQRCodeWindowController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = SWBQRCodeWindowController.xib; sourceTree = "<group>"; };
9B3FFF351D08CF110019A709 /* jquery.min.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = jquery.min.js; sourceTree = "<group>"; };
9B3FFF361D08CF110019A709 /* qrcode.min.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = qrcode.min.js; sourceTree = "<group>"; };
9B3FFF371D08CF110019A709 /* qrcode.htm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = qrcode.htm; sourceTree = "<group>"; };
9B3FFF3B1D08D93B0019A709 /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; }; 9B3FFF3B1D08D93B0019A709 /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; };
9B3FFF3D1D08D9910019A709 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; }; 9B3FFF3D1D08D9910019A709 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; };
9B3FFF441D09CD3B0019A709 /* proxy_conf_helper */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = proxy_conf_helper; sourceTree = BUILT_PRODUCTS_DIR; }; 9B3FFF441D09CD3B0019A709 /* proxy_conf_helper */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = proxy_conf_helper; sourceTree = BUILT_PRODUCTS_DIR; };
@ -241,9 +235,6 @@
9BE8FBBD1D0B1FB900CAFD01 /* libcrypto.1.0.0.dylib */, 9BE8FBBD1D0B1FB900CAFD01 /* libcrypto.1.0.0.dylib */,
9B172A6C1D0ADDDD00B87B9A /* Localizable.strings */, 9B172A6C1D0ADDDD00B87B9A /* Localizable.strings */,
9B3FFF4B1D09D8F70019A709 /* install_helper.sh */, 9B3FFF4B1D09D8F70019A709 /* install_helper.sh */,
9B3FFF351D08CF110019A709 /* jquery.min.js */,
9B3FFF361D08CF110019A709 /* qrcode.min.js */,
9B3FFF371D08CF110019A709 /* qrcode.htm */,
9B3FFF281D08A1DF0019A709 /* user-rule.txt */, 9B3FFF281D08A1DF0019A709 /* user-rule.txt */,
9B3FFF261D0898EB0019A709 /* gfwlist.txt */, 9B3FFF261D0898EB0019A709 /* gfwlist.txt */,
9B3FFF221D088E8D0019A709 /* abp.js */, 9B3FFF221D088E8D0019A709 /* abp.js */,
@ -489,8 +480,6 @@
C6D429971DA75988002A5711 /* stop_privoxy.sh in Resources */, C6D429971DA75988002A5711 /* stop_privoxy.sh in Resources */,
C8E42A6E1D4F2CAF0074C7EA /* UserRulesController.xib in Resources */, C8E42A6E1D4F2CAF0074C7EA /* UserRulesController.xib in Resources */,
9BEEF06A1D04D4D500FC52B3 /* start_ss_local.sh in Resources */, 9BEEF06A1D04D4D500FC52B3 /* start_ss_local.sh in Resources */,
9B3FFF391D08CF110019A709 /* qrcode.min.js in Resources */,
9B3FFF3A1D08CF110019A709 /* qrcode.htm in Resources */,
C6D429941DA75988002A5711 /* privoxy in Resources */, C6D429941DA75988002A5711 /* privoxy in Resources */,
C6D429991DA76FBC002A5711 /* privoxy.config.example in Resources */, C6D429991DA76FBC002A5711 /* privoxy.config.example in Resources */,
9BEEF06B1D04D4D500FC52B3 /* stop_ss_local.sh in Resources */, 9BEEF06B1D04D4D500FC52B3 /* stop_ss_local.sh in Resources */,
@ -501,7 +490,6 @@
C6D429951DA75988002A5711 /* reload_conf_privoxy.sh in Resources */, C6D429951DA75988002A5711 /* reload_conf_privoxy.sh in Resources */,
9B0BFFEB1D0460A70040E62B /* Assets.xcassets in Resources */, 9B0BFFEB1D0460A70040E62B /* Assets.xcassets in Resources */,
9B2491B71D0ACC3E003BBECC /* AdvPreferencesWindowController.xib in Resources */, 9B2491B71D0ACC3E003BBECC /* AdvPreferencesWindowController.xib in Resources */,
9B3FFF381D08CF110019A709 /* jquery.min.js in Resources */,
9B3FFF271D0898EB0019A709 /* gfwlist.txt in Resources */, 9B3FFF271D0898EB0019A709 /* gfwlist.txt in Resources */,
C6D429931DA75988002A5711 /* install_privoxy.sh in Resources */, C6D429931DA75988002A5711 /* install_privoxy.sh in Resources */,
9BC70EDC1D2E3E3100EDA4CA /* Localizable.strings in Resources */, 9BC70EDC1D2E3E3100EDA4CA /* Localizable.strings in Resources */,

View File

@ -172,8 +172,6 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
StopSSLocal() StopSSLocal()
StopPrivoxy() StopPrivoxy()
ProxyConfHelper.disableProxy() ProxyConfHelper.disableProxy()
let defaults = UserDefaults.standard
defaults.set(false, forKey: "ShadowsocksOn")
} }
func applyConfig() { func applyConfig() {

View File

@ -12,7 +12,7 @@
</customObject> </customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/> <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/> <customObject id="-3" userLabel="Application" customClass="NSObject"/>
<window title="Advance Preferences" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" animationBehavior="default" id="F0z-JX-Cv5"> <window title="Advanced Preferences" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" animationBehavior="default" id="F0z-JX-Cv5">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES"/> <windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES"/>
<rect key="contentRect" x="562" y="415" width="480" height="345"/> <rect key="contentRect" x="562" y="415" width="480" height="345"/>
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1027"/> <rect key="screenRect" x="0.0" y="0.0" width="1680" height="1027"/>

View File

@ -11,7 +11,7 @@
<window title="HTTP Proxy Preferences" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" showsToolbarButton="NO" frameAutosaveName="" animationBehavior="default" id="vS3-DL-Nq3"> <window title="HTTP Proxy Preferences" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" showsToolbarButton="NO" frameAutosaveName="" animationBehavior="default" id="vS3-DL-Nq3">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/> <windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<rect key="contentRect" x="109" y="131" width="209" height="197"/> <rect key="contentRect" x="109" y="131" width="209" height="197"/>
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1027"/> <rect key="screenRect" x="0.0" y="0.0" width="1920" height="1057"/>
<view key="contentView" id="Qef-Mj-9z1"> <view key="contentView" id="Qef-Mj-9z1">
<rect key="frame" x="0.0" y="0.0" width="209" height="197"/> <rect key="frame" x="0.0" y="0.0" width="209" height="197"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
@ -60,7 +60,11 @@
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell> </textFieldCell>
<connections> <connections>
<binding destination="Adn-6l-wm4" name="value" keyPath="values.LocalHTTP.ListenAddress" id="YV3-cX-xGk"/> <binding destination="Adn-6l-wm4" name="value" keyPath="values.LocalHTTP.ListenAddress" id="TLb-4n-tsg">
<dictionary key="options">
<bool key="NSContinuouslyUpdatesValue" value="YES"/>
</dictionary>
</binding>
</connections> </connections>
</textField> </textField>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="lD1-xm-Qy3"> <textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="lD1-xm-Qy3">
@ -71,7 +75,11 @@
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell> </textFieldCell>
<connections> <connections>
<binding destination="Adn-6l-wm4" name="value" keyPath="values.LocalHTTP.ListenPort" id="URg-d3-2U6"/> <binding destination="Adn-6l-wm4" name="value" keyPath="values.LocalHTTP.ListenPort" id="bVc-jE-7Ve">
<dictionary key="options">
<bool key="NSContinuouslyUpdatesValue" value="YES"/>
</dictionary>
</binding>
<outlet property="formatter" destination="ji3-e7-HNW" id="xWV-vJ-7eq"/> <outlet property="formatter" destination="ji3-e7-HNW" id="xWV-vJ-7eq"/>
</connections> </connections>
</textField> </textField>

View File

@ -79,13 +79,13 @@
</connections> </connections>
</menuItem> </menuItem>
<menuItem isSeparatorItem="YES" id="bMX-qn-Qwi"/> <menuItem isSeparatorItem="YES" id="bMX-qn-Qwi"/>
<menuItem title="Show Running Mode On Status Bar" id="CCV-hX-fVA"> <menuItem title="Show Running Mode In Status Bar" id="CCV-hX-fVA">
<modifierMask key="keyEquivalentModifierMask"/> <modifierMask key="keyEquivalentModifierMask"/>
<connections> <connections>
<action selector="showRunningMode:" target="Voe-Tx-rLC" id="PxO-ut-PEx"/> <action selector="showRunningMode:" target="Voe-Tx-rLC" id="PxO-ut-PEx"/>
</connections> </connections>
</menuItem> </menuItem>
<menuItem title="Advance Proxy Preference..." id="sbx-yz-3lO"> <menuItem title="Advanced Proxy Preferences..." id="sbx-yz-3lO">
<modifierMask key="keyEquivalentModifierMask"/> <modifierMask key="keyEquivalentModifierMask"/>
<connections> <connections>
<action selector="editProxyPreferences:" target="Voe-Tx-rLC" id="Jji-Ea-Sy8"/> <action selector="editProxyPreferences:" target="Voe-Tx-rLC" id="Jji-Ea-Sy8"/>
@ -120,13 +120,13 @@
</items> </items>
</menu> </menu>
</menuItem> </menuItem>
<menuItem title="Advance Preference ..." id="bZ3-fy-34d"> <menuItem title="Advanced Preferences ..." id="bZ3-fy-34d">
<modifierMask key="keyEquivalentModifierMask"/> <modifierMask key="keyEquivalentModifierMask"/>
<connections> <connections>
<action selector="editAdvPreferences:" target="Voe-Tx-rLC" id="mEF-XS-HJE"/> <action selector="editAdvPreferences:" target="Voe-Tx-rLC" id="mEF-XS-HJE"/>
</connections> </connections>
</menuItem> </menuItem>
<menuItem title="HTTP Proxy Preference ..." id="uEp-Gz-cu0"> <menuItem title="HTTP Proxy Preferences ..." id="uEp-Gz-cu0">
<modifierMask key="keyEquivalentModifierMask"/> <modifierMask key="keyEquivalentModifierMask"/>
<connections> <connections>
<action selector="editHTTPPreferences:" target="Voe-Tx-rLC" id="tkC-e3-PH9"/> <action selector="editHTTPPreferences:" target="Voe-Tx-rLC" id="tkC-e3-PH9"/>

View File

@ -13,7 +13,7 @@
</customObject> </customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/> <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/> <customObject id="-3" userLabel="Application" customClass="NSObject"/>
<window title="Advance Proxy Preferences" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" animationBehavior="default" id="F0z-JX-Cv5"> <window title="Advanced Proxy Preferences" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" animationBehavior="default" id="F0z-JX-Cv5">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/> <windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<rect key="contentRect" x="503" y="308" width="298" height="311"/> <rect key="contentRect" x="503" y="308" width="298" height="311"/>
<rect key="screenRect" x="0.0" y="0.0" width="1440" height="877"/> <rect key="screenRect" x="0.0" y="0.0" width="1440" height="877"/>

View File

@ -17,7 +17,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>APPL</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>1.3.1</string> <string>1.3.2</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleURLTypes</key> <key>CFBundleURLTypes</key>

View File

@ -139,12 +139,14 @@ FSEventStreamRef fsEventStream;
NSMutableArray* args = [@[@"--mode", @"global", @"--port" NSMutableArray* args = [@[@"--mode", @"global", @"--port"
, [NSString stringWithFormat:@"%lu", (unsigned long)port]]mutableCopy]; , [NSString stringWithFormat:@"%lu", (unsigned long)port]]mutableCopy];
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"LocalHTTPOn"] && [[NSUserDefaults standardUserDefaults] boolForKey:@"LocalHTTP.FollowGlobel"]) { // Because issue #106 https://github.com/shadowsocks/ShadowsocksX-NG/issues/106
NSUInteger privoxyPort = [[NSUserDefaults standardUserDefaults]integerForKey:@"LocalHTTP.ListenPort"]; // Comment below out.
// if ([[NSUserDefaults standardUserDefaults] boolForKey:@"LocalHTTPOn"] && [[NSUserDefaults standardUserDefaults] boolForKey:@"LocalHTTP.FollowGlobel"]) {
[args addObject:@"--privoxy-port"]; // NSUInteger privoxyPort = [[NSUserDefaults standardUserDefaults]integerForKey:@"LocalHTTP.ListenPort"];
[args addObject:[NSString stringWithFormat:@"%lu", (unsigned long)privoxyPort]]; //
} // [args addObject:@"--privoxy-port"];
// [args addObject:[NSString stringWithFormat:@"%lu", (unsigned long)privoxyPort]];
// }
[self addArguments4ManualSpecifyNetworkServices:args]; [self addArguments4ManualSpecifyNetworkServices:args];
[self callHelper:args]; [self callHelper:args];

View File

@ -9,9 +9,9 @@
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#import <WebKit/WebKit.h> #import <WebKit/WebKit.h>
@interface SWBQRCodeWindowController : NSWindowController <WebFrameLoadDelegate> @interface SWBQRCodeWindowController : NSWindowController
@property (nonatomic, strong) IBOutlet WebView *webView;
@property (nonatomic, copy) NSString *qrCode; @property (nonatomic, copy) NSString *qrCode;
@property (nonatomic, weak) NSImageView *imageView;
@end @end

View File

@ -7,6 +7,7 @@
// //
#import "SWBQRCodeWindowController.h" #import "SWBQRCodeWindowController.h"
@import CoreImage;
@interface SWBQRCodeWindowController () @interface SWBQRCodeWindowController ()
@ -18,18 +19,56 @@
[super windowDidLoad]; [super windowDidLoad];
// Implement this method to handle any initialization after your window controller's window has been loaded from its nib file. // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
[self.webView.mainFrame loadRequest:[NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"qrcode" withExtension:@"htm"]]]; [self setQRCode:self.qrCode];
self.webView.frameLoadDelegate = self;
} }
-(void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame { - (void)setQRCode:(NSString*) qrCode {
if (self.qrCode) { CGImageRef cgImgRef = [self createQRImageForString:qrCode size:CGSizeMake(250, 250)];
[self.webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"genCode('%@')", _qrCode]];
} NSImage *image = [[NSImage alloc]initWithCGImage:cgImgRef size:CGSizeMake(250, 250)];
self.imageView.image = image;
} }
-(void)dealloc { - (CGImageRef)createQRImageForString:(NSString *)string size:(CGSize)size {
self.webView.frameLoadDelegate = nil; // Setup the QR filter with our string
CIFilter *filter = [CIFilter filterWithName:@"CIQRCodeGenerator"];
[filter setDefaults];
NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding];
[filter setValue:data forKey:@"inputMessage"];
CIImage *image = [filter valueForKey:@"outputImage"];
// Calculate the size of the generated image and the scale for the desired image size
CGRect extent = CGRectIntegral(image.extent);
CGFloat scale = MIN(size.width / CGRectGetWidth(extent), size.height / CGRectGetHeight(extent));
// Since CoreImage nicely interpolates, we need to create a bitmap image that we'll draw into
// a bitmap context at the desired size;
size_t width = CGRectGetWidth(extent) * scale;
size_t height = CGRectGetHeight(extent) * scale;
CGColorSpaceRef cs = CGColorSpaceCreateDeviceGray();
CGContextRef bitmapRef = CGBitmapContextCreate(nil, width, height, 8, 0, cs, (CGBitmapInfo)kCGImageAlphaNone);
#if TARGET_OS_IPHONE
CIContext *context = [CIContext contextWithOptions:nil];
#else
CIContext *context = [CIContext contextWithCGContext:bitmapRef options:nil];
#endif
CGImageRef bitmapImage = [context createCGImage:image fromRect:extent];
CGContextSetInterpolationQuality(bitmapRef, kCGInterpolationNone);
CGContextScaleCTM(bitmapRef, scale, scale);
CGContextDrawImage(bitmapRef, extent, bitmapImage);
// Create an image with the contents of our bitmap
CGImageRef scaledImage = CGBitmapContextCreateImage(bitmapRef);
// Cleanup
CGContextRelease(bitmapRef);
CGImageRelease(bitmapImage);
return scaledImage;
} }
@end @end

View File

@ -1,13 +1,13 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="10117" systemVersion="15G31" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES"> <document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11201" systemVersion="16A323" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies> <dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="10117"/> <deployment identifier="macosx"/>
<plugIn identifier="com.apple.WebKitIBPlugin" version="10117"/> <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11201"/>
</dependencies> </dependencies>
<objects> <objects>
<customObject id="-2" userLabel="File's Owner" customClass="SWBQRCodeWindowController"> <customObject id="-2" userLabel="File's Owner" customClass="SWBQRCodeWindowController">
<connections> <connections>
<outlet property="webView" destination="ojI-LR-jEw" id="bpE-vv-uIe"/> <outlet property="imageView" destination="yRy-QH-TEe" id="aa5-Ri-k04"/>
<outlet property="window" destination="QvC-M9-y7g" id="HLy-eJ-5RD"/> <outlet property="window" destination="QvC-M9-y7g" id="HLy-eJ-5RD"/>
</connections> </connections>
</customObject> </customObject>
@ -16,24 +16,17 @@
<window title="QR Code" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" restorable="NO" oneShot="NO" animationBehavior="default" id="QvC-M9-y7g"> <window title="QR Code" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" restorable="NO" oneShot="NO" animationBehavior="default" id="QvC-M9-y7g">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES"/> <windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES"/>
<rect key="contentRect" x="566" y="456" width="250" height="250"/> <rect key="contentRect" x="566" y="456" width="250" height="250"/>
<rect key="screenRect" x="0.0" y="0.0" width="1440" height="877"/> <rect key="screenRect" x="0.0" y="0.0" width="1680" height="1027"/>
<view key="contentView" id="EiT-Mj-1SZ"> <view key="contentView" id="EiT-Mj-1SZ">
<rect key="frame" x="0.0" y="0.0" width="250" height="250"/> <rect key="frame" x="0.0" y="0.0" width="250" height="250"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<subviews> <subviews>
<webView translatesAutoresizingMaskIntoConstraints="NO" id="ojI-LR-jEw"> <imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="yRy-QH-TEe">
<rect key="frame" x="0.0" y="0.0" width="250" height="250"/> <rect key="frame" x="0.0" y="0.0" width="250" height="250"/>
<webPreferences key="preferences" defaultFontSize="12" defaultFixedFontSize="12"> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<nil key="identifier"/> <imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" id="iAJ-tw-LNU"/>
</webPreferences> </imageView>
</webView>
</subviews> </subviews>
<constraints>
<constraint firstAttribute="trailing" secondItem="ojI-LR-jEw" secondAttribute="trailing" id="ImJ-r1-FF9"/>
<constraint firstAttribute="bottom" secondItem="ojI-LR-jEw" secondAttribute="bottom" id="LQv-2G-kyf"/>
<constraint firstItem="ojI-LR-jEw" firstAttribute="leading" secondItem="EiT-Mj-1SZ" secondAttribute="leading" id="kok-J1-X08"/>
<constraint firstItem="ojI-LR-jEw" firstAttribute="top" secondItem="EiT-Mj-1SZ" secondAttribute="top" id="voV-aN-Ggt"/>
</constraints>
</view> </view>
</window> </window>
</objects> </objects>

File diff suppressed because one or more lines are too long

View File

@ -1,28 +0,0 @@
<!doctype html>
<script src="jquery.min.js">
</script>
<script src="qrcode.min.js">
</script>
<style>
body {
padding: 10px;
margin: 0;
}
#qrcode {
width:230px;
height:230px;
}
</style>
<div id="qrcode"></div>
<script type="text/javascript">
function genCode(code) {
new QRCode("qrcode", {
text: code,
width: 230,
height: 230,
colorDark : "#000000",
colorLight : "#ffffff",
correctLevel : QRCode.CorrectLevel.H
});
}
</script>

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,5 @@
/* Class = "NSWindow"; title = "Advance Proxy Preferences"; ObjectID = "F0z-JX-Cv5"; */ /* Class = "NSWindow"; title = "Advanced Proxy Preferences"; ObjectID = "F0z-JX-Cv5"; */
"F0z-JX-Cv5.title" = "高级代理设置"; "F0z-JX-Cv5.title" = "高级代理设置";
/* Class = "NSButtonCell"; title = "Auto Configure"; ObjectID = "FLv-D9-CRw"; */ /* Class = "NSButtonCell"; title = "Auto Configure"; ObjectID = "FLv-D9-CRw"; */