The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

109 lines
3.6KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2015 - ROLI Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. #ifndef JUCER_AUTOUPDATER_H_INCLUDED
  18. #define JUCER_AUTOUPDATER_H_INCLUDED
  19. class UpdaterDialogModalCallback;
  20. //==============================================================================
  21. class LatestVersionChecker : private Thread,
  22. private Timer
  23. {
  24. public:
  25. struct JuceVersionTriple
  26. {
  27. JuceVersionTriple();
  28. JuceVersionTriple (int juceVersionNumber);
  29. JuceVersionTriple (int majorInt, int minorInt, int buildNumber);
  30. static bool fromString (const String& versionString, JuceVersionTriple& result);
  31. String toString() const;
  32. bool operator> (const JuceVersionTriple& b) const noexcept;
  33. int major, minor, build;
  34. };
  35. //==============================================================================
  36. struct JuceServerLocationsAndKeys
  37. {
  38. const char* updateSeverHostname;
  39. const char* publicAPIKey;
  40. int apiVersion;
  41. const char* updatePath;
  42. };
  43. //==============================================================================
  44. LatestVersionChecker();
  45. ~LatestVersionChecker();
  46. static String getOSString();
  47. URL getLatestVersionURL (String& headers, const String& path) const;
  48. URL getLatestVersionURL (String& headers) const;
  49. void checkForNewVersion();
  50. bool processResult (var reply, const String& downloadPath);
  51. bool askUserAboutNewVersion (const JuceVersionTriple& version,
  52. const String& releaseNotes,
  53. URL& newVersionToDownload,
  54. const String& extraHeaders);
  55. void askUserForLocationToDownload (URL& newVersionToDownload, const String& extraHeaders);
  56. static bool isZipFolder (const File&);
  57. virtual Result performUpdate (const MemoryBlock& data, File& targetFolder);
  58. protected:
  59. const JuceServerLocationsAndKeys& getJuceServerURLsAndKeys() const;
  60. int getProductVersionNumber() const;
  61. const char* getProductName() const;
  62. bool allowCustomLocation() const;
  63. private:
  64. //==============================================================================
  65. friend class UpdaterDialogModalCallback;
  66. // callbacks
  67. void timerCallback() override;
  68. void run() override;
  69. void modalStateFinished (int result,
  70. URL& newVersionToDownload,
  71. const String& extraHeaders,
  72. File appParentFolder);
  73. int statusCode;
  74. var jsonReply;
  75. bool hasAttemptedToReadWebsite;
  76. String newRelativeDownloadPath;
  77. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LatestVersionChecker)
  78. };
  79. #endif // JUCER_AUTOUPDATER_H_INCLUDED