Skip to content

Commit d5603f8

Browse files
committed
Automatic update functionality added...
1 parent 4c96be0 commit d5603f8

File tree

10 files changed

+97
-9
lines changed

10 files changed

+97
-9
lines changed

FlashDevelop/Dialogs/UpdateDialog.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public class UpdateDialog : Form
2222
private System.Windows.Forms.Button downloadButton;
2323
private System.ComponentModel.BackgroundWorker worker;
2424
private String URL = "http://www.flashdevelop.org/latest.txt";
25+
private static Boolean silentCheck = false;
2526

2627
public UpdateDialog()
2728
{
@@ -200,28 +201,32 @@ private void WorkerCompleted(Object sender, RunWorkerCompletedEventArgs e)
200201
String info = TextHelper.GetString("Info.UpdateCheckFailed");
201202
String formatted = String.Format(info, "\n\n");
202203
this.infoLabel.Text = formatted;
204+
if (silentCheck) this.Close();
203205
}
204206
else if (this.updateInfo.NeedsUpdate)
205207
{
206208
this.downloadButton.Enabled = true;
207209
String info = TextHelper.GetString("Info.UpdateAvailable");
208210
String formatted = String.Format(info, "\n\n", this.updateInfo.UserVersion, this.updateInfo.ServerVersion);
209211
this.infoLabel.Text = formatted;
212+
if (silentCheck) this.ShowDialog();
210213
}
211214
else if (!this.updateInfo.NeedsUpdate)
212215
{
213216
String info = TextHelper.GetString("Info.NoUpdateAvailable");
214217
this.infoLabel.Text = info;
218+
if (silentCheck) this.Close();
215219
}
216220
}
217221

218222
/// <summary>
219223
/// Shows the update dialog
220224
/// </summary>
221-
public static new void Show()
225+
public static void Show(Boolean silent)
222226
{
227+
silentCheck = silent;
223228
UpdateDialog updateDialog = new UpdateDialog();
224-
updateDialog.ShowDialog();
229+
if (!silentCheck) updateDialog.ShowDialog();
225230
}
226231

227232
#endregion

FlashDevelop/MainForm.cs

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -862,6 +862,41 @@ public void InitializeProcessRunner()
862862
this.processRunner.Error += ProcessError;
863863
}
864864

865+
/// <summary>
866+
/// Checks for updates in specified schedule
867+
/// </summary>
868+
public void CheckForUpdates()
869+
{
870+
try
871+
{
872+
DateTime last = new DateTime(this.appSettings.LastUpdateCheck);
873+
TimeSpan elapsed = DateTime.UtcNow.Subtract(last);
874+
switch (this.appSettings.CheckForUpdates)
875+
{
876+
case UpdateInterval.Weekly:
877+
{
878+
if (elapsed.TotalDays >= 7)
879+
{
880+
this.appSettings.LastUpdateCheck = DateTime.UtcNow.Ticks;
881+
UpdateDialog.Show(true);
882+
}
883+
break;
884+
}
885+
case UpdateInterval.Monthly:
886+
{
887+
if (elapsed.TotalDays >= 30)
888+
{
889+
this.appSettings.LastUpdateCheck = DateTime.UtcNow.Ticks;
890+
UpdateDialog.Show(true);
891+
}
892+
break;
893+
}
894+
default: break;
895+
}
896+
}
897+
catch { /* NO ERRORS PLEASE */ }
898+
}
899+
865900
/// <summary>
866901
/// Initializes the window position and size
867902
/// </summary>
@@ -1157,6 +1192,10 @@ private void OnMainFormLoad(Object sender, System.EventArgs e)
11571192
* Initialize window and continue layout
11581193
*/
11591194
this.InitializeWindow();
1195+
/**
1196+
* Check for updates when needed
1197+
*/
1198+
this.CheckForUpdates();
11601199
}
11611200

11621201
/// <summary>
@@ -2987,7 +3026,7 @@ public void ShowArguments(Object sender, System.EventArgs e)
29873026
/// </summary>
29883027
public void CheckUpdates(Object sender, System.EventArgs e)
29893028
{
2990-
UpdateDialog.Show();
3029+
UpdateDialog.Show(false);
29913030
}
29923031

29933032
/// <summary>

FlashDevelop/Settings/Accessors.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,15 @@ public Boolean EnsureLastLineEnd
717717

718718
#region State
719719

720+
[DisplayName("Check For Updates")]
721+
[LocalizedCategory("FlashDevelop.Category.State")]
722+
[LocalizedDescription("FlashDevelop.Description.CheckForUpdates")]
723+
public UpdateInterval CheckForUpdates
724+
{
725+
get { return this.checkForUpdates; }
726+
set { this.checkForUpdates = value; }
727+
}
728+
720729
[DisplayName("Latest Startup Command")]
721730
[LocalizedCategory("FlashDevelop.Category.State")]
722731
[LocalizedDescription("FlashDevelop.Description.LatestCommand")]
@@ -912,6 +921,16 @@ public String CustomProjectsDir
912921

913922
#endregion
914923

924+
#region Hidden
925+
926+
[Browsable(false)]
927+
public Int64 LastUpdateCheck
928+
{
929+
get { return this.lastUpdateCheck; }
930+
set { this.lastUpdateCheck = value; }
931+
}
932+
933+
#endregion
915934
}
916935

917936
}

FlashDevelop/Settings/Properties.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,12 @@ public partial class SettingObject : ISettings
9090
private Boolean viewModifiedLines = false;
9191
private Boolean wrapText = false;
9292
private FormWindowState windowState = FormWindowState.Maximized;
93-
private Point windowPosition = new Point(
94-
Screen.PrimaryScreen.WorkingArea.Left + 100,
95-
Screen.PrimaryScreen.WorkingArea.Top + 70);
96-
private Size windowSize = new Size(
97-
Screen.PrimaryScreen.WorkingArea.Right - 200,
98-
Screen.PrimaryScreen.WorkingArea.Bottom - 140);
93+
private Point windowPosition = new Point(Screen.PrimaryScreen.WorkingArea.Left + 100, Screen.PrimaryScreen.WorkingArea.Top + 70);
94+
private Size windowSize = new Size(Screen.PrimaryScreen.WorkingArea.Right - 200, Screen.PrimaryScreen.WorkingArea.Bottom - 140);
95+
private UpdateInterval checkForUpdates = UpdateInterval.Monthly;
9996
private Int32 uiHoverDelay = 500;
10097
private Int32 uiDisplayDelay = 100;
98+
private Int64 lastUpdateCheck = 0;
10199
private Boolean uiShowDetails = false;
102100
private Boolean uiAutoFilterList = true;
103101
private Boolean uiEnableAutoHide = true;

PluginCore/PluginCore/Enumerators.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ public enum EventType : long
4545
AppChanges = 34359738368 // NotifyEvent
4646
}
4747

48+
public enum UpdateInterval
49+
{
50+
Never = -1,
51+
Monthly = 0,
52+
Weekly = 1
53+
}
54+
4855
public enum SessionType
4956
{
5057
Startup = 0,

PluginCore/PluginCore/Resources/de_DE.resX

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5844,4 +5844,8 @@ Eigene Sprachumgebungen müssen eine Erweiterung der Standard-Sprachumgebung sei
58445844
<value>Use tags which do not format inside setting.</value>
58455845
<comment>Added after 4.7.1</comment>
58465846
</data>
5847+
<data name="FlashDevelop.Description.CheckForUpdates" xml:space="preserve">
5848+
<value>Sets how often FlashDevelop checks for updates.</value>
5849+
<comment>Added after 4.7.1</comment>
5850+
</data>
58475851
</root>

PluginCore/PluginCore/Resources/en_US.resX

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5851,4 +5851,8 @@ Custom locales must be an extension of a default locale, e.g. en-US.</value>
58515851
<value>Use tags which do not format inside setting.</value>
58525852
<comment>Added after 4.7.1</comment>
58535853
</data>
5854+
<data name="FlashDevelop.Description.CheckForUpdates" xml:space="preserve">
5855+
<value>Sets how often FlashDevelop checks for updates.</value>
5856+
<comment>Added after 4.7.1</comment>
5857+
</data>
58545858
</root>

PluginCore/PluginCore/Resources/eu_ES.resX

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5841,4 +5841,8 @@ Lokalizazio pertsonalizatuek lehenetsiaren luzapen bat izan behar dute, adb. en-
58415841
<value>Use tags which do not format inside setting.</value>
58425842
<comment>Added after 4.7.1</comment>
58435843
</data>
5844+
<data name="FlashDevelop.Description.CheckForUpdates" xml:space="preserve">
5845+
<value>Sets how often FlashDevelop checks for updates.</value>
5846+
<comment>Added after 4.7.1</comment>
5847+
</data>
58445848
</root>

PluginCore/PluginCore/Resources/ja_JP.resX

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5906,4 +5906,8 @@ UseData:"</value>
59065906
<value>Use tags which do not format inside setting.</value>
59075907
<comment>Added after 4.7.1</comment>
59085908
</data>
5909+
<data name="FlashDevelop.Description.CheckForUpdates" xml:space="preserve">
5910+
<value>Sets how often FlashDevelop checks for updates.</value>
5911+
<comment>Added after 4.7.1</comment>
5912+
</data>
59095913
</root>

PluginCore/PluginCore/Resources/zh_CN.resx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5854,4 +5854,8 @@
58545854
<value>Use tags which do not format inside setting.</value>
58555855
<comment>Added after 4.7.1</comment>
58565856
</data>
5857+
<data name="FlashDevelop.Description.CheckForUpdates" xml:space="preserve">
5858+
<value>Sets how often FlashDevelop checks for updates.</value>
5859+
<comment>Added after 4.7.1</comment>
5860+
</data>
58575861
</root>

0 commit comments

Comments
 (0)