Skip to content

Commit 6a0073a

Browse files
committed
Add VersionChecker
1 parent 8b11480 commit 6a0073a

File tree

6 files changed

+76
-195
lines changed

6 files changed

+76
-195
lines changed

shadowsocks-csharp/Controller/UpdateChecker.cs

-151
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
using SimpleJson;
2+
using System;
3+
using System.Collections;
4+
using System.Collections.Generic;
5+
using System.Net;
6+
using System.Reflection;
7+
using System.Text;
8+
using System.Text.RegularExpressions;
9+
using System.Threading.Tasks;
10+
using System.Xml;
11+
12+
namespace Shadowsocks.Controller
13+
{
14+
public class VersionChecker
15+
{
16+
private const string UpdateURL = "https://api.github.com/repos/MrChenChen/shadowsocks-windows-fix_polarssl/releases/latest";
17+
18+
public static string GetCurrentVersionNumber()
19+
{
20+
return Assembly.GetExecutingAssembly().GetName().Version.ToString();
21+
}
22+
23+
public void VersionCheck()
24+
{
25+
Task.Factory.StartNew(() =>
26+
{
27+
WebClient http = new WebClient();
28+
29+
http.Encoding = Encoding.UTF8;
30+
31+
http.DownloadStringCompleted += Http_DownloadStringCompleted; ;
32+
33+
http.DownloadStringAsync(new Uri(UpdateURL));
34+
35+
});
36+
}
37+
38+
private void Http_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
39+
{
40+
if (e.Error == null)
41+
{
42+
JsonObject jsonObject = (JsonObject)SimpleJson.SimpleJson.DeserializeObject(e.Result);
43+
44+
45+
}
46+
47+
}
48+
49+
50+
}
51+
}

shadowsocks-csharp/Properties/AssemblyInfo.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// 控制。更改这些属性值可修改
77
// 与程序集关联的信息。
88
[assembly: AssemblyTitle("Shadowsocks")]
9-
[assembly: AssemblyDescription("")]
9+
[assembly: AssemblyDescription("Managed by MrChenchen 2015")]
1010
[assembly: AssemblyConfiguration("")]
1111
[assembly: AssemblyCompany("")]
1212
[assembly: AssemblyProduct("Shadowsocks")]
@@ -32,5 +32,4 @@
3232
// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值,
3333
// 方法是按如下所示使用“*”:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("2.0.7")]
36-
// [assembly: AssemblyFileVersion("2.0.0")]
35+
[assembly: AssemblyVersion("1.0.0")]

shadowsocks-csharp/View/ConfigForm.Designer.cs

+7-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

shadowsocks-csharp/View/ConfigForm.cs

+15-33
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,20 @@
1313
using Microsoft.Win32;
1414
using System.Runtime.InteropServices;
1515
using System.IO;
16-
16+
using System.Net;
1717

1818
namespace Shadowsocks.View
1919
{
2020

2121
public partial class ConfigForm : Form
2222
{
23-
const string Version = "1.0";
24-
2523

2624
private ShadowsocksController controller;
27-
private UpdateChecker updateChecker;
2825

2926
private List<string> m_list_ads = new List<string>();
3027

28+
private VersionChecker mUpdater = new VersionChecker();
29+
3130
// this is a copy of configuration that we are working on
3231
private Configuration _modifiedConfiguration;
3332
private int _oldSelectedIndex = -1;
@@ -38,6 +37,7 @@ public partial class ConfigForm : Form
3837
public ConfigForm(ShadowsocksController controller)
3938
{
4039
InitializeComponent();
40+
4141
LoadTrayIcon();
4242

4343
m_settings = Properties.Settings.Default;
@@ -50,8 +50,6 @@ public ConfigForm(ShadowsocksController controller)
5050
controller.PACFileReadyToOpen += controller_PACFileReadyToOpen;
5151
controller.ShareOverLANStatusChanged += controller_ShareOverLANStatusChanged;
5252

53-
this.updateChecker = new UpdateChecker();
54-
//updateChecker.NewVersionFound += updateChecker_NewVersionFound;
5553

5654
LoadCurrentConfiguration();
5755

@@ -73,8 +71,12 @@ public ConfigForm(ShadowsocksController controller)
7371
}
7472

7573

76-
if (tempAutoCheckUpdate)
77-
CheckUpdate();
74+
//if (tempAutoCheckUpdate)
75+
//CheckUpdate();
76+
77+
//mUpdater.VersionCheck();
78+
79+
7880

7981
}
8082

@@ -127,20 +129,6 @@ void controller_PACFileReadyToOpen(object sender, ShadowsocksController.PathEven
127129
System.Diagnostics.Process.Start("explorer.exe", argument);
128130
}
129131

130-
void updateChecker_NewVersionFound(object sender, EventArgs e)
131-
{
132-
notifyIcon1.BalloonTipTitle = "Shadowsocks " + updateChecker.LatestVersionNumber + " Update Found";
133-
notifyIcon1.BalloonTipText = "Click here to download";
134-
notifyIcon1.BalloonTipIcon = ToolTipIcon.Info;
135-
notifyIcon1.BalloonTipClicked += notifyIcon1_BalloonTipClicked;
136-
notifyIcon1.ShowBalloonTip(5000);
137-
_isFirstRun = false;
138-
}
139-
140-
void notifyIcon1_BalloonTipClicked(object sender, EventArgs e)
141-
{
142-
Process.Start(updateChecker.LatestVersionURL);
143-
}
144132

145133

146134
private void ShowWindow()
@@ -258,14 +246,17 @@ private void UpdateServersMenu()
258246
}
259247
}
260248
string Startuplnkname;
249+
261250
private void ConfigForm_Load(object sender, EventArgs e)
262251
{
263252
Startuplnkname = Shadowsocks._3rd.CreateDesktopShort.StartupPath + "\\" + System.IO.Path.GetFileName(Application.ExecutablePath).Replace(".exe", ".lnk").Replace(".EXE", ".lnk");
264253

265254
checkBoxAutoRun.Checked = File.Exists(Startuplnkname);
266255

267256
GetPassWord.m_mainform = this;
257+
268258
CheckForIllegalCrossThreadCalls = false;
259+
269260
if (!controller.GetConfiguration().isDefault)
270261
{
271262
//this.Opacity = 0;
@@ -796,25 +787,16 @@ private void buttonDel_Click(object sender, EventArgs e)
796787
}
797788

798789

799-
void CheckUpdate()
800-
{
801-
Task.Factory.StartNew(() =>
802-
{
803-
804-
805790

806791

807-
});
808-
}
809-
810792
/// <summary>
811793
/// 手动更新
812794
/// </summary>
813795
/// <param name="sender"></param>
814796
/// <param name="e"></param>
815797
private void menuItemStartCheckUpdate_Click(object sender, EventArgs e)
816798
{
817-
CheckUpdate();
799+
//CheckUpdate();
818800
}
819801

820802
public bool tempAutoCheckUpdate = true;
@@ -834,7 +816,7 @@ private void menuItem7_Click(object sender, EventArgs e)
834816

835817
FileInfo file = new FileInfo(path);
836818

837-
System.Diagnostics.Process.Start("explorer.exe", file.DirectoryName);
819+
Process.Start("explorer.exe", file.DirectoryName);
838820

839821
}
840822

0 commit comments

Comments
 (0)