-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
it will poll the github latest release url once per week and will replace the help icon on main window corner with a shiny yellow New icon that when clicked will display current and latest version number prompting the user to upgrade. it is disabled by default. to enable you have to check a checkbox in settings . user may also manually initiate the update check proccess.
- Loading branch information
Showing
14 changed files
with
270 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Net; | ||
using System.Text; | ||
using System.Windows.Forms; | ||
using System.Windows.Forms.VisualStyles; | ||
using BrowserSelect.Properties; | ||
|
||
namespace BrowserSelect | ||
{ | ||
class UpdateChecker | ||
{ | ||
public String CVer => current_version; | ||
public String LVer => last_version; | ||
public Boolean Checked => init; | ||
public Boolean Updated => new_version(); | ||
|
||
private string current_version = "x"; | ||
private string last_version = "x"; | ||
private bool init = false; | ||
|
||
public void check() | ||
{ | ||
if (new_version()) | ||
Settings.Default.last_version = last_version; | ||
if (Settings.Default.check_update != "nope") | ||
Settings.Default.check_update = Program.time().ToString(); | ||
Settings.Default.Save(); | ||
} | ||
string get_last_version() | ||
{ | ||
// request to releases/latest redirects the user to /releases/tag. | ||
// since tag is the version number we can get latest version from Location header | ||
// and make a HEAD request instead of get to save bandwidth | ||
var req = (HttpWebRequest)WebRequest.Create("https://github.com/zumoshi/BrowserSelect/releases/latest"); | ||
req.Method = "HEAD"; | ||
req.AllowAutoRedirect = false; | ||
using (var res = req.GetResponse()) | ||
{ | ||
return res.Headers["Location"].Split('/').Last(); | ||
} | ||
} | ||
|
||
void get_versions() | ||
{ | ||
try | ||
{ | ||
last_version = get_last_version(); | ||
current_version = ((Func<String, String>)((x) => x.Substring(0, x.Length - 2)))(Application.ProductVersion); | ||
init = true; | ||
} | ||
catch (Exception) { } | ||
} | ||
|
||
bool new_version() | ||
{ | ||
if (!init) | ||
get_versions(); | ||
return last_version != current_version; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.