| @@ -174,7 +174,8 @@ void ProjucerApplication::handleAsyncUpdate() | |||
| MenuBarModel::setMacMainMenu (menuModel.get(), &extraAppleMenuItems); //, "Open Recent"); | |||
| #endif | |||
| versionChecker.reset (new LatestVersionChecker()); | |||
| if (getGlobalProperties().getValue (Ids::dontQueryForUpdate, {}).isEmpty()) | |||
| LatestVersionCheckerAndUpdater::getInstance()->checkForNewVersion (false); | |||
| if (licenseController != nullptr) | |||
| { | |||
| @@ -217,7 +218,6 @@ void ProjucerApplication::shutdown() | |||
| Logger::writeToLog ("Server shutdown cleanly"); | |||
| } | |||
| versionChecker.reset(); | |||
| utf8Window.reset(); | |||
| svgPathWindow.reset(); | |||
| aboutWindow.reset(); | |||
| @@ -438,6 +438,7 @@ void ProjucerApplication::createFileMenu (PopupMenu& menu) | |||
| #if ! JUCE_MAC | |||
| menu.addCommandItem (commandManager.get(), CommandIDs::showAboutWindow); | |||
| menu.addCommandItem (commandManager.get(), CommandIDs::showAppUsageWindow); | |||
| menu.addCommandItem (commandManager.get(), CommandIDs::checkForNewVersion); | |||
| menu.addCommandItem (commandManager.get(), CommandIDs::showGlobalPathsWindow); | |||
| menu.addSeparator(); | |||
| menu.addCommandItem (commandManager.get(), StandardApplicationCommandIDs::quit); | |||
| @@ -589,6 +590,7 @@ void ProjucerApplication::createExtraAppleMenuItems (PopupMenu& menu) | |||
| { | |||
| menu.addCommandItem (commandManager.get(), CommandIDs::showAboutWindow); | |||
| menu.addCommandItem (commandManager.get(), CommandIDs::showAppUsageWindow); | |||
| menu.addCommandItem (commandManager.get(), CommandIDs::checkForNewVersion); | |||
| menu.addSeparator(); | |||
| menu.addCommandItem (commandManager.get(), CommandIDs::showGlobalPathsWindow); | |||
| } | |||
| @@ -1000,6 +1002,7 @@ void ProjucerApplication::getAllCommands (Array <CommandID>& commands) | |||
| CommandIDs::showSVGPathTool, | |||
| CommandIDs::showAboutWindow, | |||
| CommandIDs::showAppUsageWindow, | |||
| CommandIDs::checkForNewVersion, | |||
| CommandIDs::showForum, | |||
| CommandIDs::showAPIModules, | |||
| CommandIDs::showAPIClasses, | |||
| @@ -1090,6 +1093,10 @@ void ProjucerApplication::getCommandInfo (CommandID commandID, ApplicationComman | |||
| result.setInfo ("Application Usage Data", "Shows the application usage data agreement window", CommandCategories::general, 0); | |||
| break; | |||
| case CommandIDs::checkForNewVersion: | |||
| result.setInfo ("Check for New Version...", "Checks the web server for a new version of JUCE", CommandCategories::general, 0); | |||
| break; | |||
| case CommandIDs::showForum: | |||
| result.setInfo ("JUCE Community Forum", "Shows the JUCE community forum in a browser", CommandCategories::general, 0); | |||
| break; | |||
| @@ -1149,6 +1156,7 @@ bool ProjucerApplication::perform (const InvocationInfo& info) | |||
| case CommandIDs::showGlobalPathsWindow: showPathsWindow (false); break; | |||
| case CommandIDs::showAboutWindow: showAboutWindow(); break; | |||
| case CommandIDs::showAppUsageWindow: showApplicationUsageDataAgreementPopup(); break; | |||
| case CommandIDs::checkForNewVersion: LatestVersionCheckerAndUpdater::getInstance()->checkForNewVersion (true); break; | |||
| case CommandIDs::showForum: launchForumBrowser(); break; | |||
| case CommandIDs::showAPIModules: launchModulesBrowser(); break; | |||
| case CommandIDs::showAPIClasses: launchClassesBrowser(); break; | |||
| @@ -123,7 +123,6 @@ public: | |||
| void launchTutorialsBrowser(); | |||
| void updateAllBuildTabs(); | |||
| LatestVersionChecker* createVersionChecker() const; | |||
| //============================================================================== | |||
| void licenseStateChanged (const LicenseState&) override; | |||
| @@ -196,7 +195,6 @@ private: | |||
| //============================================================================== | |||
| void* server = nullptr; | |||
| std::unique_ptr<LatestVersionChecker> versionChecker; | |||
| TooltipWindow tooltipWindow; | |||
| AvailableModuleList jucePathModuleList, userPathsModuleList; | |||
| @@ -26,81 +26,35 @@ | |||
| #pragma once | |||
| class UpdaterDialogModalCallback; | |||
| class DownloadAndInstallThread; | |||
| //============================================================================== | |||
| class LatestVersionChecker : private Thread, | |||
| private Timer | |||
| class LatestVersionCheckerAndUpdater : public DeletedAtShutdown, | |||
| private Thread | |||
| { | |||
| public: | |||
| struct JuceVersionTriple | |||
| { | |||
| JuceVersionTriple(); | |||
| JuceVersionTriple (int juceVersionNumber); | |||
| JuceVersionTriple (int majorInt, int minorInt, int buildNumber); | |||
| LatestVersionCheckerAndUpdater(); | |||
| ~LatestVersionCheckerAndUpdater() override; | |||
| static bool fromString (const String& versionString, JuceVersionTriple& result); | |||
| String toString() const; | |||
| bool operator> (const JuceVersionTriple& b) const noexcept; | |||
| int major, minor, build; | |||
| }; | |||
| //============================================================================== | |||
| struct JuceServerLocationsAndKeys | |||
| { | |||
| const char* updateSeverHostname; | |||
| const char* publicAPIKey; | |||
| int apiVersion; | |||
| const char* updatePath; | |||
| }; | |||
| void checkForNewVersion (bool showAlerts); | |||
| //============================================================================== | |||
| LatestVersionChecker(); | |||
| ~LatestVersionChecker() override; | |||
| static String getOSString(); | |||
| URL getLatestVersionURL (String& headers, const String& path) const; | |||
| URL getLatestVersionURL (String& headers) const; | |||
| void checkForNewVersion(); | |||
| bool processResult (var reply, const String& downloadPath); | |||
| bool askUserAboutNewVersion (const JuceVersionTriple& version, | |||
| const String& releaseNotes, | |||
| URL& newVersionToDownload, | |||
| const String& extraHeaders); | |||
| void askUserForLocationToDownload (URL& newVersionToDownload, const String& extraHeaders); | |||
| static bool isZipFolder (const File&); | |||
| virtual Result performUpdate (const MemoryBlock& data, File& targetFolder); | |||
| protected: | |||
| const JuceServerLocationsAndKeys& getJuceServerURLsAndKeys() const; | |||
| int getProductVersionNumber() const; | |||
| const char* getProductName() const; | |||
| bool allowCustomLocation() const; | |||
| JUCE_DECLARE_SINGLETON_SINGLETHREADED_MINIMAL (LatestVersionCheckerAndUpdater) | |||
| private: | |||
| //============================================================================== | |||
| friend class UpdaterDialogModalCallback; | |||
| // callbacks | |||
| void timerCallback() override; | |||
| void run() override; | |||
| void modalStateFinished (int result, | |||
| URL& newVersionToDownload, | |||
| const String& extraHeaders, | |||
| File appParentFolder); | |||
| void queryUpdateServer(); | |||
| void processResult(); | |||
| void askUserAboutNewVersion (const String&, const String&); | |||
| void askUserForLocationToDownload(); | |||
| void downloadAndInstall (const File&); | |||
| int statusCode; | |||
| //============================================================================== | |||
| bool showAlertWindows = false; | |||
| int statusCode = 0; | |||
| String relativeDownloadPath; | |||
| var jsonReply; | |||
| bool hasAttemptedToReadWebsite; | |||
| String newRelativeDownloadPath; | |||
| JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LatestVersionChecker) | |||
| std::unique_ptr<DownloadAndInstallThread> installer; | |||
| std::unique_ptr<Component> dialogWindow; | |||
| }; | |||
| @@ -56,6 +56,7 @@ namespace CommandIDs | |||
| showSVGPathTool = 0x300023, | |||
| showAboutWindow = 0x300024, | |||
| showAppUsageWindow = 0x300025, | |||
| checkForNewVersion = 0x300026, | |||
| showProjectSettings = 0x300030, | |||
| showProjectTab = 0x300031, | |||
| @@ -351,6 +351,7 @@ namespace Ids | |||
| DECLARE_ID (projectLineFeed); | |||
| DECLARE_ID (compilerFlagSchemes); | |||
| DECLARE_ID (compilerFlagScheme); | |||
| DECLARE_ID (dontQueryForUpdate); | |||
| const Identifier ID ("id"); | |||
| const Identifier ID_uppercase ("ID"); | |||