ACT Advanced Combat Tracker - MMORPG Log Parser Paypal
underwater

Make your hosted plugin auto-update

  1. public void InitPlugin(TabPage pluginScreenSpace, Label pluginStatusText)
  2. {
  3.     ActGlobals.oFormActMain.UpdateCheckClicked += new FormActMain.NullDelegate(oFormActMain_UpdateCheckClicked);
  4.     if (ActGlobals.oFormActMain.GetAutomaticUpdatesAllowed())   // If ACT is set to automatically check for updates, check for updates to the plugin
  5.         new Thread(new ThreadStart(oFormActMain_UpdateCheckClicked)).Start();   // If we don't put this on a separate thread, web latency will delay the plugin init phase
  6. }
  7.  
  8. public void DeInitPlugin()
  9. {
  10.     ActGlobals.oFormActMain.UpdateCheckClicked -= oFormActMain_UpdateCheckClicked;
  11. }
  12.  
  13. void oFormActMain_UpdateCheckClicked()
  14. {
  15.     int pluginId = 46;    // This ID must be the same ID used on ACT's website.  
  16.     try
  17.     {
  18.         DateTime localDate = ActGlobals.oFormActMain.PluginGetSelfDateUtc(this);
  19.         DateTime remoteDate = ActGlobals.oFormActMain.PluginGetRemoteDateUtc(pluginId);
  20.         if (localDate.AddHours(2) < remoteDate)
  21.         {
  22.             DialogResult result = MessageBox.Show("There is an updated version of the EQ2 English Parsing Plugin.  Update it now?\n\n(If there is an update to ACT, you should click No and update ACT first.)", "New Version", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
  23.             if (result == DialogResult.Yes)
  24.             {
  25.                 FileInfo updatedFile = ActGlobals.oFormActMain.PluginDownload(pluginId);
  26.                 ActPluginData pluginData = ActGlobals.oFormActMain.PluginGetSelfData(this);
  27.                 pluginData.pluginFile.Delete();
  28.                 updatedFile.MoveTo(pluginData.pluginFile.FullName);
  29.                 ThreadInvokes.CheckboxSetChecked(ActGlobals.oFormActMain, pluginData.cbEnabled, false);
  30.                 Application.DoEvents();
  31.                 ThreadInvokes.CheckboxSetChecked(ActGlobals.oFormActMain, pluginData.cbEnabled, true);
  32.             }
  33.         }
  34.     }
  35.     catch (Exception ex)
  36.     {
  37.         ActGlobals.oFormActMain.WriteExceptionLog(ex, "Plugin Update Check");
  38.     }
  39. }
  40.  

Summary:

If you have a plugin hosted on ACT's website, you can use this code to enable easy auto-updating.  Just upload a new version of your plugin to the website and this will do the rest.


HTML5 Powered with CSS3 / Styling, Graphics, 3D & Effects, and Semantics
Softpedia Clean Award
Random Background