diff --git a/extras/Projucer/Source/Application/jucer_Application.cpp b/extras/Projucer/Source/Application/jucer_Application.cpp index 28412fe48b..efa3d3dcab 100644 --- a/extras/Projucer/Source/Application/jucer_Application.cpp +++ b/extras/Projucer/Source/Application/jucer_Application.cpp @@ -511,11 +511,11 @@ void ProjucerApplication::getCommandInfo (CommandID commandID, ApplicationComman break; case CommandIDs::loginLogout: - result.setInfo (ProjucerLicences::getInstance()->isLoggedIn() - ? String ("Sign out ") + ProjucerLicences::getInstance()->getLoginName() + result.setInfo (ProjucerLicenses::getInstance()->isLoggedIn() + ? String ("Sign out ") + ProjucerLicenses::getInstance()->getLoginName() : String ("Sign in..."), "Log out of your JUCE account", CommandCategories::general, 0); - result.setActive (ProjucerLicences::getInstance()->isDLLPresent()); + result.setActive (ProjucerLicenses::getInstance()->isDLLPresent()); break; default: @@ -711,7 +711,7 @@ void ProjucerApplication::hideLoginForm() void ProjucerApplication::showLoginForm() { - if (ProjucerLicences::getInstance()->isDLLPresent()) + if (ProjucerLicenses::getInstance()->isDLLPresent()) { jassert (MessageManager::getInstance()->isThisTheMessageThread()); @@ -739,7 +739,7 @@ void ProjucerApplication::showLoginForm() void ProjucerApplication::showLoginFormAsyncIfNotTriedRecently() { - if (ProjucerLicences::getInstance()->isDLLPresent()) + if (ProjucerLicenses::getInstance()->isDLLPresent()) { Time lastLoginAttempt (getGlobalProperties().getValue ("lastLoginAttemptTime").getIntValue() * (int64) 1000); @@ -756,7 +756,7 @@ void ProjucerApplication::timerCallback() { stopTimer(); - if (! ProjucerLicences::getInstance()->isLoggedIn()) + if (! ProjucerLicenses::getInstance()->isLoggedIn()) showLoginForm(); } @@ -770,7 +770,7 @@ void ProjucerApplication::updateAllBuildTabs() //============================================================================== void ProjucerApplication::loginOrLogout() { - ProjucerLicences& status = *ProjucerLicences::getInstance(); + ProjucerLicenses& status = *ProjucerLicenses::getInstance(); if (status.isLoggedIn()) status.logout(); @@ -783,7 +783,7 @@ void ProjucerApplication::loginOrLogout() bool ProjucerApplication::checkEULA() { if (currentEULAHasBeenAcceptedPreviously() - || ! ProjucerLicences::getInstance()->isDLLPresent()) + || ! ProjucerLicenses::getInstance()->isDLLPresent()) return true; ScopedPointer eulaDialogue (new EULADialogue()); diff --git a/extras/Projucer/Source/Application/jucer_LoginForm.h b/extras/Projucer/Source/Application/jucer_LoginForm.h index 29c856edbe..abde4df1e2 100644 --- a/extras/Projucer/Source/Application/jucer_LoginForm.h +++ b/extras/Projucer/Source/Application/jucer_LoginForm.h @@ -27,9 +27,9 @@ class LoginForm : public Component, - public ButtonListener, + private ButtonListener, private TextEditor::Listener, - private ProjucerLicences::LoginCallback + private ProjucerLicenses::LoginCallback { public: LoginForm() @@ -56,7 +56,7 @@ public: initialiseTextField (userIDEditor, userIDLabel); addAndMakeVisible (userIDEditor); - String userName = ProjucerLicences::getInstance()->getLoginName(); + String userName = ProjucerLicenses::getInstance()->getLoginName(); userIDEditor.setText (userName.isEmpty() ? getLastUserName() : userName); initialiseLabel (errorLabel, Font::plain, ProjucerDialogLookAndFeel::getErrorTextColour()); @@ -223,7 +223,7 @@ private: errorLabel.setVisible (false); spinner.setVisible (true); - ProjucerLicences::getInstance()->login (loginName, password, rememberLogin, this); + ProjucerLicenses::getInstance()->login (loginName, password, rememberLogin, this); } void registerButtonClicked() diff --git a/extras/Projucer/Source/Application/jucer_Main.cpp b/extras/Projucer/Source/Application/jucer_Main.cpp index 4be597c043..e8ec70a6cc 100644 --- a/extras/Projucer/Source/Application/jucer_Main.cpp +++ b/extras/Projucer/Source/Application/jucer_Main.cpp @@ -48,7 +48,7 @@ #include "../LiveBuildEngine/projucer_CompileEngineServer.h" #include "jucer_ProjucerLicenses.h" -juce_ImplementSingleton (ProjucerLicences); +juce_ImplementSingleton (ProjucerLicenses); struct ProjucerAppClasses { diff --git a/extras/Projucer/Source/Application/jucer_ProjucerLicenses.h b/extras/Projucer/Source/Application/jucer_ProjucerLicenses.h index f06ce4e895..8902433a19 100644 --- a/extras/Projucer/Source/Application/jucer_ProjucerLicenses.h +++ b/extras/Projucer/Source/Application/jucer_ProjucerLicenses.h @@ -1,23 +1,40 @@ /* - ============================================================================== - Copyright 2015 by Raw Material Software Ltd. - ============================================================================== -*/ + ============================================================================== + This file is part of the JUCE library. + Copyright (c) 2015 - ROLI Ltd. + + Permission is granted to use this software under the terms of either: + a) the GPL v2 (or any later version) + b) the Affero GPL v3 + + Details of these licenses can be found at: www.gnu.org/licenses + + JUCE is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + ------------------------------------------------------------------------------ + + To release a closed-source product which uses JUCE, commercial licenses are + available: visit www.juce.com for more information. + + ============================================================================== +*/ #ifndef PROJUCER_PROJUCERLICENSES_H_INCLUDED #define PROJUCER_PROJUCERLICENSES_H_INCLUDED //============================================================================== -struct ProjucerLicences : private DeletedAtShutdown +struct ProjucerLicenses : private DeletedAtShutdown { - ProjucerLicences() + ProjucerLicenses() { dll.initialise (crashCallback, quitCallback, false); } - juce_DeclareSingleton (ProjucerLicences, false); + juce_DeclareSingleton (ProjucerLicenses, false); //============================================================================== struct LoginCallback @@ -103,7 +120,7 @@ private: static void staticCallbackFunction (void* userInfo, const char* errorMessage, const char* username, const char* apiKey) { - static_cast (userInfo)->callbackFunction (errorMessage, username, apiKey); + static_cast (userInfo)->callbackFunction (errorMessage, username, apiKey); } static void crashCallback (const char*) {} diff --git a/extras/Projucer/Source/Project/jucer_ProjectContentComponent.cpp b/extras/Projucer/Source/Project/jucer_ProjectContentComponent.cpp index d51a37a1d4..1ea94cb73f 100644 --- a/extras/Projucer/Source/Project/jucer_ProjectContentComponent.cpp +++ b/extras/Projucer/Source/Project/jucer_ProjectContentComponent.cpp @@ -354,9 +354,9 @@ struct BuildTabComponent : public ConcertinaPanel struct ProjucerDisabledComp : public Component, private Button::Listener { - ProjucerDisabledComp (String message, bool canLogin, bool requirePurchase = false, + ProjucerDisabledComp (String message, bool loggedIn, bool canLogin, bool requirePurchase = false, const String& loginName = String()) - : isPurchaseButton (requirePurchase) + : isLoggedIn (loggedIn), isPurchaseButton (requirePurchase) { infoLabel.setColour (Label::textColourId, findColour (mainBackgroundColourId).contrasting (0.7f)); infoLabel.setJustificationType (Justification::centred); @@ -404,7 +404,7 @@ struct ProjucerDisabledComp : public Component, } else if (btn == signOutButton.get()) { - ProjucerLicences::getInstance()->logout(); + ProjucerLicenses::getInstance()->logout(); ProjucerApplication::getApp().updateAllBuildTabs(); } } @@ -412,7 +412,7 @@ struct ProjucerDisabledComp : public Component, Label infoLabel { "info", String() }; TextButton loginButton { "Log-in..." }; ScopedPointer signOutButton; - bool isPurchaseButton; + bool isLoggedIn, isPurchaseButton; }; struct EnableBuildComp : public Component @@ -449,11 +449,11 @@ Component* ProjectContentComponent::createBuildTab (CompileEngineChildProcess* c #if JUCE_WINDOWS ignoreUnused (child); return new ProjucerDisabledComp ("Windows support is still under development - " - "please check for updates at www.juce.com!", false); + "please check for updates at www.juce.com!", false, false); #elif JUCE_LINUX ignoreUnused (child); return new ProjucerDisabledComp ("Linux support is still under development - " - "please check for updates at www.juce.com!", false); + "please check for updates at www.juce.com!", false, false); #else if (child != nullptr) { @@ -462,7 +462,7 @@ Component* ProjectContentComponent::createBuildTab (CompileEngineChildProcess* c return new BuildTabComponent (child, new ProjucerAppClasses::ErrorListComp (child->errorList)); } - auto& unlockStatus = *ProjucerLicences::getInstance(); + auto& unlockStatus = *ProjucerLicenses::getInstance(); if (unlockStatus.hasLiveCodingLicence() && project != nullptr @@ -474,7 +474,7 @@ Component* ProjectContentComponent::createBuildTab (CompileEngineChildProcess* c + newLine + "Your account " + unlockStatus.getLoginName().quoted() + " does not have an asscociated JUCE Pro license:", - true, true, unlockStatus.getLoginName()); + true, true, true, unlockStatus.getLoginName()); if (! unlockStatus.isDLLPresent()) return new ProjucerDisabledComp (String ("The live-building DLL is missing!") + newLine @@ -482,10 +482,12 @@ Component* ProjectContentComponent::createBuildTab (CompileEngineChildProcess* c + "To enable the compiler, you'll need to install the missing DLL " + CompileEngineDLL::getDLLName().quoted() + newLine + newLine - + "Visit the JUCE website/forum for more help on getting and installing the DLL!", false); + + "Visit the JUCE website/forum for more help on getting and installing the DLL!", + false, false); return new ProjucerDisabledComp ("The Projucer's live-build features are currently disabled!\n\n" - "To enable them, you'll need to log-in with your JUCE account details:", true, false); + "To enable them, you'll need to log-in with your JUCE account details:", + false, true, false); #endif } @@ -494,14 +496,24 @@ BuildTabComponent* findBuildTab (const TabbedComponent& tabs) return dynamic_cast (tabs.getTabContentComponent (2)); } -bool ProjectContentComponent::isBuildTabShowing() const +bool ProjectContentComponent::isBuildTabEnabled() const { return findBuildTab (treeViewTabs) != nullptr; } -bool ProjectContentComponent::isLoggedInTabShowing() const +bool ProjectContentComponent::isBuildTabSuitableForLoggedInUser() const { - return isBuildTabShowing() || dynamic_cast (treeViewTabs.getTabContentComponent (2)) != nullptr; + return isBuildTabEnabled() + || isBuildTabLoggedInWithoutLicense() + || dynamic_cast (treeViewTabs.getTabContentComponent (2)) != nullptr; +} + +bool ProjectContentComponent::isBuildTabLoggedInWithoutLicense() const +{ + if (auto* c = dynamic_cast (treeViewTabs.getTabContentComponent (2))) + return c->isLoggedIn; + + return false; } void ProjectContentComponent::createProjectTabs() @@ -1355,16 +1367,16 @@ bool ProjectContentComponent::isBuildEnabled() const { return project != nullptr && ! LiveBuildProjectSettings::isBuildDisabled (*project) - && ProjucerLicences::getInstance()->hasLiveCodingLicence() - && ProjucerLicences::getInstance()->isLoggedIn(); + && ProjucerLicenses::getInstance()->hasLiveCodingLicence() + && ProjucerLicenses::getInstance()->isLoggedIn(); } void ProjectContentComponent::refreshTabsIfBuildStatusChanged() { if (project != nullptr && (treeViewTabs.getNumTabs() < 3 - || isBuildEnabled() != isBuildTabShowing() - || ProjucerLicences::getInstance()->isLoggedIn() != isLoggedInTabShowing())) + || isBuildEnabled() != isBuildTabEnabled() + || ProjucerLicenses::getInstance()->isLoggedIn() != isBuildTabSuitableForLoggedInUser())) rebuildProjectTabs(); } @@ -1493,7 +1505,7 @@ void ProjectContentComponent::handleMissingSystemHeaders() deleteProjectTabs(); createProjectTabs(); - ProjucerDisabledComp* buildTab = new ProjucerDisabledComp (tabMessage, false); + ProjucerDisabledComp* buildTab = new ProjucerDisabledComp (tabMessage, false, false); treeViewTabs.addTab ("Build", Colours::transparentBlack, buildTab, true); showBuildTab(); diff --git a/extras/Projucer/Source/Project/jucer_ProjectContentComponent.h b/extras/Projucer/Source/Project/jucer_ProjectContentComponent.h index e5ef09929a..f87eab6274 100644 --- a/extras/Projucer/Source/Project/jucer_ProjectContentComponent.h +++ b/extras/Projucer/Source/Project/jucer_ProjectContentComponent.h @@ -110,8 +110,7 @@ public: void killChildProcess(); void cleanAll(); void handleMissingSystemHeaders(); - bool isBuildTabShowing() const; - bool isLoggedInTabShowing() const; + bool isBuildTabEnabled() const; void setBuildEnabled (bool); bool isBuildEnabled() const; bool areWarningsEnabled() const; @@ -162,6 +161,8 @@ private: void updateWarningState(); void launchApp(); void killApp(); + bool isBuildTabSuitableForLoggedInUser() const; + bool isBuildTabLoggedInWithoutLicense() const; ReferenceCountedObjectPtr getChildProcess();