CheckForUpdatesPostInit.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. function postInit() {
  2. if (RSettings.hasQuitFlag()) {
  3. return;
  4. }
  5. var appWin = RMainWindowQt.getMainWindow();
  6. // check for updates at startup:
  7. if (RSettings.getBoolValue("CheckForUpdates/AutoCheckUpdates", false)===true &&
  8. appWin.property("CheckForUpdates/Handled")!==true) {
  9. // disable check in case check would crash app (macOS, Qt 5.8.0, QTBUG-56747):
  10. RSettings.setValue("CheckForUpdates/AutoCheckUpdates", false);
  11. RSettings.getQSettings().sync();
  12. qDebug("checking for updates...");
  13. include("CheckForUpdates.js");
  14. var html = download(CheckForUpdates.getUrl(), 3000);
  15. // re-enable check if no crash occurred:
  16. RSettings.setValue("CheckForUpdates/AutoCheckUpdates", true);
  17. RSettings.getQSettings().sync();
  18. if (html.indexOf("<title>Up To Date</title>")!==-1) {
  19. qDebug("no updates available");
  20. }
  21. else if (html.indexOf("<title>Update Available</title>")!=-1) {
  22. qDebug("updates available");
  23. var action = RGuiAction.getByScriptFile("scripts/Help/CheckForUpdates/CheckForUpdates.js");
  24. if (!isNull(action)) {
  25. action.slotTrigger();
  26. }
  27. }
  28. }
  29. }