--- /dev/null
+// \r
+// Radegast Metaverse Client\r
+// Copyright (c) 2009, Radegast Development Team\r
+// All rights reserved.\r
+// \r
+// Redistribution and use in source and binary forms, with or without\r
+// modification, are permitted provided that the following conditions are met:\r
+// \r
+// * Redistributions of source code must retain the above copyright notice,\r
+// this list of conditions and the following disclaimer.\r
+// * Redistributions in binary form must reproduce the above copyright\r
+// notice, this list of conditions and the following disclaimer in the\r
+// documentation and/or other materials provided with the distribution.\r
+// * Neither the name of the application "Radegast", nor the names of its\r
+// contributors may be used to endorse or promote products derived from\r
+// this software without specific prior written permission.\r
+// \r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\r
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\r
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\r
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+//\r
+// $Id: RadegastInstance.cs 234 2009-09-13 12:45:52Z logicmoo $\r
+//\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+using System.Reflection;\r
+using System.Net;\r
+using OpenMetaverse;\r
+using OpenMetaverse.StructuredData;\r
+using System.Threading;\r
+\r
+namespace Radegast\r
+{\r
+ public class UpdateChecker : IDisposable\r
+ {\r
+ public AssemblyName MyAssembly;\r
+\r
+ public delegate void UpdateInfoCallback(object sender, UpdateCheckerArgs e);\r
+\r
+ public event UpdateInfoCallback OnUpdateInfoReceived;\r
+\r
+ private WebClient client;\r
+\r
+ public UpdateChecker()\r
+ {\r
+ MyAssembly = Assembly.GetExecutingAssembly().GetName();\r
+ }\r
+\r
+ public void Dispose()\r
+ {\r
+ if (client != null)\r
+ {\r
+ client.Dispose();\r
+ client = null;\r
+ }\r
+ }\r
+\r
+ public void StartCheck()\r
+ {\r
+ if (client == null)\r
+ {\r
+ client = new WebClient();\r
+ client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(OnDownloadStringCompleted);\r
+ }\r
+\r
+ ThreadPool.QueueUserWorkItem((object state) =>\r
+ {\r
+ client.DownloadStringAsync(new Uri(Properties.Resources.UpdateCheckUri));\r
+ }\r
+ );\r
+ }\r
+\r
+ private void OnDownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)\r
+ {\r
+ if (e.Error != null)\r
+ {\r
+ Logger.Log("Failed fetching updatede information: ", Helpers.LogLevel.Warning, e.Error);\r
+ FireCallback(new UpdateCheckerArgs() { Success = false });\r
+ }\r
+ else\r
+ {\r
+ try\r
+ {\r
+ OSDMap upd = OSDParser.DeserializeJson(e.Result) as OSDMap;\r
+ UpdateInfo inf = new UpdateInfo()\r
+ {\r
+ Error = upd["Error"].AsBoolean(),\r
+ ErrMessage = upd["ErrMessage"].AsString(),\r
+ CurrentVersion = upd["CurrentVersion"].AsString(),\r
+ DownloadSite = upd["DownloadSite"].AsString(),\r
+ DisplayMOTD = upd["DisplayMOTD"].AsBoolean(),\r
+ MOTD = upd["MOTD"].AsString()\r
+ };\r
+ FireCallback(new UpdateCheckerArgs() { Success = !inf.Error, Info = inf });\r
+ }\r
+ catch (Exception ex)\r
+ {\r
+ Logger.Log("Failed decoding updatede information: ", Helpers.LogLevel.Warning, ex);\r
+ FireCallback(new UpdateCheckerArgs() { Success = false });\r
+ }\r
+ }\r
+ }\r
+\r
+ private void FireCallback(UpdateCheckerArgs e)\r
+ {\r
+ if (OnUpdateInfoReceived != null)\r
+ {\r
+ try { OnUpdateInfoReceived(this, e); }\r
+ catch { }\r
+ }\r
+ }\r
+ }\r
+\r
+ public class UpdateInfo\r
+ {\r
+ public bool Error { get; set; }\r
+ public string ErrMessage { get; set; }\r
+ public string CurrentVersion { get; set; }\r
+ public string DownloadSite { get; set; }\r
+ public bool DisplayMOTD { get; set; }\r
+ public string MOTD { get; set; }\r
+ }\r
+\r
+ public class UpdateCheckerArgs : EventArgs\r
+ {\r
+ public bool Success { get; set; }\r
+ public UpdateInfo Info { get; set; }\r
+ }\r
+\r
+}\r
this.toolStripContainer1 = new System.Windows.Forms.ToolStripContainer();\r
this.pnlDialog = new System.Windows.Forms.Panel();\r
this.timerWorldClock = new System.Windows.Forms.Timer(this.components);\r
+ this.toolStripMenuItem6 = new System.Windows.Forms.ToolStripSeparator();\r
+ this.checkForUpdatesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();\r
this.toolStrip1.SuspendLayout();\r
this.statusStrip1.SuspendLayout();\r
this.toolStripContainer1.TopToolStripPanel.SuspendLayout();\r
this.tbtnHelp.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;\r
this.tbtnHelp.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {\r
this.reportBugsToolStripMenuItem,\r
+ this.checkForUpdatesToolStripMenuItem,\r
+ this.toolStripMenuItem6,\r
this.aboutRadegastToolStripMenuItem});\r
this.tbtnHelp.Image = ((System.Drawing.Image)(resources.GetObject("tbtnHelp.Image")));\r
this.tbtnHelp.ImageTransparentColor = System.Drawing.Color.Magenta;\r
this.timerWorldClock.Interval = 1000;\r
this.timerWorldClock.Tick += new System.EventHandler(this.timerWorldClock_Tick);\r
// \r
+ // toolStripMenuItem6\r
+ // \r
+ this.toolStripMenuItem6.Name = "toolStripMenuItem6";\r
+ this.toolStripMenuItem6.Size = new System.Drawing.Size(200, 6);\r
+ // \r
+ // checkForUpdatesToolStripMenuItem\r
+ // \r
+ this.checkForUpdatesToolStripMenuItem.Name = "checkForUpdatesToolStripMenuItem";\r
+ this.checkForUpdatesToolStripMenuItem.Size = new System.Drawing.Size(203, 22);\r
+ this.checkForUpdatesToolStripMenuItem.Text = "Check for Updates...";\r
+ this.checkForUpdatesToolStripMenuItem.Click += new System.EventHandler(this.checkForUpdatesToolStripMenuItem_Click);\r
+ // \r
// frmMain\r
// \r
this.AutoSavePosition = true;\r
private System.Windows.Forms.ToolStripDropDownButton tbtnHelp;\r
private System.Windows.Forms.ToolStripMenuItem reportBugsToolStripMenuItem;\r
private System.Windows.Forms.ToolStripMenuItem aboutRadegastToolStripMenuItem;\r
+ private System.Windows.Forms.ToolStripSeparator toolStripMenuItem6;\r
+ private System.Windows.Forms.ToolStripMenuItem checkForUpdatesToolStripMenuItem;\r
}\r
}\r
\r
<PropertyGroup>\r
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>\r
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>\r
- <ProductVersion>9.0.21022</ProductVersion>\r
+ <ProductVersion>9.0.30729</ProductVersion>\r
<SchemaVersion>2.0</SchemaVersion>\r
<ProjectGuid>{A6D955CD-1F55-459F-A7AD-01E591404989}</ProjectGuid>\r
<OutputType>WinExe</OutputType>\r
<Compile Include="Core\Types\TransparentLabel.cs">\r
<SubType>Component</SubType>\r
</Compile>\r
+ <Compile Include="Core\Updater\UpdateChecker.cs" />\r
<Compile Include="FormFlash.cs" />\r
<Compile Include="GUI\Consoles\AnimDetail.cs">\r
<SubType>UserControl</SubType>\r
<None Include="openjpeg-dotnet.dll">\r
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>\r
</None>\r
- <None Include="assemblies\fmodex-dotnet.dll" />\r
<None Include="fmodex.dll">\r
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>\r
</None>\r
+ <None Include="assemblies\fmodex-dotnet.dll">\r
+ </None>\r
<Content Include="openmetaverse_data\avatar_lad.xml">\r
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>\r
</Content>\r