diff --git a/shadowsocks-csharp/Controller/GfwListUpdater.cs b/shadowsocks-csharp/Controller/GfwListUpdater.cs index 77be9c03..4cf77293 100644 --- a/shadowsocks-csharp/Controller/GfwListUpdater.cs +++ b/shadowsocks-csharp/Controller/GfwListUpdater.cs @@ -16,10 +16,20 @@ namespace Shadowsocks.Controller private static string PAC_FILE = PACServer.PAC_FILE; - public event EventHandler UpdateCompleted; + public event EventHandler UpdateCompleted; public event ErrorEventHandler Error; + public class ResultEventArgs : EventArgs + { + public bool Success; + + public ResultEventArgs(bool success) + { + this.Success = success; + } + } + private void http_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { try @@ -28,10 +38,19 @@ namespace Shadowsocks.Controller string abpContent = Utils.UnGzip(Resources.abp_js); abpContent = abpContent.Replace("__RULES__", SimpleJson.SimpleJson.SerializeObject(lines)); + if (File.Exists(PAC_FILE)) + { + string original = File.ReadAllText(PAC_FILE, Encoding.UTF8); + if (original == abpContent) + { + UpdateCompleted(this, new ResultEventArgs(false)); + return; + } + } File.WriteAllText(PAC_FILE, abpContent, Encoding.UTF8); if (UpdateCompleted != null) { - UpdateCompleted(this, new EventArgs()); + UpdateCompleted(this, new ResultEventArgs(true)); } } catch (Exception ex) diff --git a/shadowsocks-csharp/Controller/ShadowsocksController.cs b/shadowsocks-csharp/Controller/ShadowsocksController.cs index 4e343c96..203417c2 100755 --- a/shadowsocks-csharp/Controller/ShadowsocksController.cs +++ b/shadowsocks-csharp/Controller/ShadowsocksController.cs @@ -39,7 +39,7 @@ namespace Shadowsocks.Controller // when user clicked Edit PAC, and PAC file has already created public event EventHandler PACFileReadyToOpen; - public event EventHandler UpdatePACFromGFWListCompleted; + public event EventHandler UpdatePACFromGFWListCompleted; public event ErrorEventHandler UpdatePACFromGFWListError; @@ -282,7 +282,7 @@ namespace Shadowsocks.Controller UpdateSystemProxy(); } - private void pacServer_PACUpdateCompleted(object sender, EventArgs e) + private void pacServer_PACUpdateCompleted(object sender, GFWListUpdater.ResultEventArgs e) { if (UpdatePACFromGFWListCompleted != null) UpdatePACFromGFWListCompleted(this, e); diff --git a/shadowsocks-csharp/Data/cn.txt b/shadowsocks-csharp/Data/cn.txt index 51ac217d..f398b048 100644 --- a/shadowsocks-csharp/Data/cn.txt +++ b/shadowsocks-csharp/Data/cn.txt @@ -43,6 +43,7 @@ System Proxy Disabled=系统代理未启用 Update PAC from GFWList=从 GFWList 更新 PAC Failed to update PAC file =更新 PAC 文件失败 PAC updated=更新 PAC 成功 +No updates found. Please report to GFWList if you have problems with it.=未发现更新。如有问题请提交给 GFWList。 No QRCode found. Try to zoom in or move it to the center of the screen.=找不到二维码,尝试把它放大或者移动到靠近屏幕中间的位置 Failed to decode QRCode=无法解析二维码 Failed to update registry=无法修改注册表 diff --git a/shadowsocks-csharp/View/MenuViewController.cs b/shadowsocks-csharp/View/MenuViewController.cs index 6b897603..9fe9fcd3 100755 --- a/shadowsocks-csharp/View/MenuViewController.cs +++ b/shadowsocks-csharp/View/MenuViewController.cs @@ -207,9 +207,10 @@ namespace Shadowsocks.View Logging.LogUsefulException(e.GetException()); } - void controller_UpdatePACFromGFWListCompleted(object sender, EventArgs e) + void controller_UpdatePACFromGFWListCompleted(object sender, GFWListUpdater.ResultEventArgs e) { - ShowBalloonTip(I18N.GetString("Shadowsocks"), I18N.GetString("PAC updated"), ToolTipIcon.Info, 1000); + string result = e.Success ? I18N.GetString("PAC updated") : I18N.GetString("No updates found. Please report to GFWList if you have problems with it."); + ShowBalloonTip(I18N.GetString("Shadowsocks"), result, ToolTipIcon.Info, 1000); } void updateChecker_NewVersionFound(object sender, EventArgs e)