From 9ed1eb08e6703b2a16f449bc2a2c4b3e4d7e92cd Mon Sep 17 00:00:00 2001 From: qinyuhang Date: Sun, 8 Jan 2017 21:10:50 +0800 Subject: [PATCH] sync ssr-local for protocol method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 支持协议参数,为单端口多用户做好准备 2. 支持Group参数,可用于分组节点列表 --- ShadowsocksX-NG/AppDelegate.swift | 29 +++++ .../PreferencesWindowController.xib | 114 ++++++++++-------- ShadowsocksX-NG/Info.plist | 4 +- ShadowsocksX-NG/LaunchAgentUtils.swift | 2 +- .../PreferencesWindowController.swift | 2 + ShadowsocksX-NG/ServerProfile.swift | 17 ++- ShadowsocksX-NG/ServerProfileManager.swift | 13 +- ShadowsocksX-NG/Utils.m | 8 +- ShadowsocksX-NG/install_ss_local.sh | 2 +- ShadowsocksX-NG/ss-local | Bin 2406504 -> 2418656 bytes .../PreferencesWindowController.strings | 2 + 11 files changed, 134 insertions(+), 59 deletions(-) diff --git a/ShadowsocksX-NG/AppDelegate.swift b/ShadowsocksX-NG/AppDelegate.swift index e9a32af..3d71dda 100644 --- a/ShadowsocksX-NG/AppDelegate.swift +++ b/ShadowsocksX-NG/AppDelegate.swift @@ -648,8 +648,37 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele if !p.isValid() { item.isEnabled = false } + item.action = #selector(AppDelegate.selectServer) + if !p.ssrGroup.isEmpty { + if((serversMenuItem.submenu?.item(withTitle: p.ssrGroup)) == nil){ + let groupSubmenu = NSMenu() + let groupSubmenuItem = NSMenuItem() + groupSubmenuItem.title = p.ssrGroup +//if i == 2 {// to delete + serversMenuItem.submenu?.addItem(groupSubmenuItem) + serversMenuItem.submenu?.setSubmenu(groupSubmenu, for: groupSubmenuItem) + if mgr.activeProfileId == p.uuid { + item.state = 1 + groupSubmenuItem.state = 1 + } + groupSubmenuItem.submenu?.addItem(item) + i += 1 + continue +//}// to delete + } + else{ + if mgr.activeProfileId == p.uuid { + item.state = 1 + serversMenuItem.submenu?.item(withTitle: p.ssrGroup)?.state = 1 + } + serversMenuItem.submenu?.item(withTitle: p.ssrGroup)?.submenu?.addItem(item) + i += 1 + continue + } + } + serversMenuItem.submenu?.addItem(item) i += 1 } diff --git a/ShadowsocksX-NG/Base.lproj/PreferencesWindowController.xib b/ShadowsocksX-NG/Base.lproj/PreferencesWindowController.xib index 449da60..59e89a2 100644 --- a/ShadowsocksX-NG/Base.lproj/PreferencesWindowController.xib +++ b/ShadowsocksX-NG/Base.lproj/PreferencesWindowController.xib @@ -1,8 +1,10 @@ - - + + - + + + @@ -13,6 +15,7 @@ + @@ -30,20 +33,20 @@ - - + + - + - + - + - + @@ -78,7 +81,6 @@ - - + - + - + @@ -104,7 +106,7 @@ - + @@ -115,7 +117,7 @@ - + @@ -132,7 +134,7 @@ - + @@ -140,7 +142,7 @@ - + @@ -148,7 +150,7 @@ - + @@ -159,7 +161,7 @@ - + @@ -167,7 +169,7 @@ - + @@ -175,7 +177,7 @@ - + @@ -183,7 +185,7 @@ - + @@ -208,7 +210,7 @@ - + @@ -219,7 +221,7 @@ - + @@ -227,7 +229,7 @@ - + @@ -235,7 +237,7 @@ - + @@ -243,7 +245,7 @@ - + @@ -251,7 +253,7 @@ - + @@ -259,7 +261,7 @@ - + @@ -267,7 +269,7 @@ - + @@ -275,21 +277,39 @@ - + + + + + + + + + + + + + + + + + - + + + @@ -302,13 +322,16 @@ + + + @@ -326,7 +349,7 @@ - + @@ -341,8 +364,6 @@ - - - - + + - +