| @@ -511,11 +511,11 @@ void ProjucerApplication::getCommandInfo (CommandID commandID, ApplicationComman | |||||
| break; | break; | ||||
| case CommandIDs::loginLogout: | 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..."), | : String ("Sign in..."), | ||||
| "Log out of your JUCE account", CommandCategories::general, 0); | "Log out of your JUCE account", CommandCategories::general, 0); | ||||
| result.setActive (ProjucerLicences::getInstance()->isDLLPresent()); | |||||
| result.setActive (ProjucerLicenses::getInstance()->isDLLPresent()); | |||||
| break; | break; | ||||
| default: | default: | ||||
| @@ -711,7 +711,7 @@ void ProjucerApplication::hideLoginForm() | |||||
| void ProjucerApplication::showLoginForm() | void ProjucerApplication::showLoginForm() | ||||
| { | { | ||||
| if (ProjucerLicences::getInstance()->isDLLPresent()) | |||||
| if (ProjucerLicenses::getInstance()->isDLLPresent()) | |||||
| { | { | ||||
| jassert (MessageManager::getInstance()->isThisTheMessageThread()); | jassert (MessageManager::getInstance()->isThisTheMessageThread()); | ||||
| @@ -739,7 +739,7 @@ void ProjucerApplication::showLoginForm() | |||||
| void ProjucerApplication::showLoginFormAsyncIfNotTriedRecently() | void ProjucerApplication::showLoginFormAsyncIfNotTriedRecently() | ||||
| { | { | ||||
| if (ProjucerLicences::getInstance()->isDLLPresent()) | |||||
| if (ProjucerLicenses::getInstance()->isDLLPresent()) | |||||
| { | { | ||||
| Time lastLoginAttempt (getGlobalProperties().getValue ("lastLoginAttemptTime").getIntValue() * (int64) 1000); | Time lastLoginAttempt (getGlobalProperties().getValue ("lastLoginAttemptTime").getIntValue() * (int64) 1000); | ||||
| @@ -756,7 +756,7 @@ void ProjucerApplication::timerCallback() | |||||
| { | { | ||||
| stopTimer(); | stopTimer(); | ||||
| if (! ProjucerLicences::getInstance()->isLoggedIn()) | |||||
| if (! ProjucerLicenses::getInstance()->isLoggedIn()) | |||||
| showLoginForm(); | showLoginForm(); | ||||
| } | } | ||||
| @@ -770,7 +770,7 @@ void ProjucerApplication::updateAllBuildTabs() | |||||
| //============================================================================== | //============================================================================== | ||||
| void ProjucerApplication::loginOrLogout() | void ProjucerApplication::loginOrLogout() | ||||
| { | { | ||||
| ProjucerLicences& status = *ProjucerLicences::getInstance(); | |||||
| ProjucerLicenses& status = *ProjucerLicenses::getInstance(); | |||||
| if (status.isLoggedIn()) | if (status.isLoggedIn()) | ||||
| status.logout(); | status.logout(); | ||||
| @@ -783,7 +783,7 @@ void ProjucerApplication::loginOrLogout() | |||||
| bool ProjucerApplication::checkEULA() | bool ProjucerApplication::checkEULA() | ||||
| { | { | ||||
| if (currentEULAHasBeenAcceptedPreviously() | if (currentEULAHasBeenAcceptedPreviously() | ||||
| || ! ProjucerLicences::getInstance()->isDLLPresent()) | |||||
| || ! ProjucerLicenses::getInstance()->isDLLPresent()) | |||||
| return true; | return true; | ||||
| ScopedPointer<AlertWindow> eulaDialogue (new EULADialogue()); | ScopedPointer<AlertWindow> eulaDialogue (new EULADialogue()); | ||||
| @@ -27,9 +27,9 @@ | |||||
| class LoginForm : public Component, | class LoginForm : public Component, | ||||
| public ButtonListener, | |||||
| private ButtonListener, | |||||
| private TextEditor::Listener, | private TextEditor::Listener, | ||||
| private ProjucerLicences::LoginCallback | |||||
| private ProjucerLicenses::LoginCallback | |||||
| { | { | ||||
| public: | public: | ||||
| LoginForm() | LoginForm() | ||||
| @@ -56,7 +56,7 @@ public: | |||||
| initialiseTextField (userIDEditor, userIDLabel); | initialiseTextField (userIDEditor, userIDLabel); | ||||
| addAndMakeVisible (userIDEditor); | addAndMakeVisible (userIDEditor); | ||||
| String userName = ProjucerLicences::getInstance()->getLoginName(); | |||||
| String userName = ProjucerLicenses::getInstance()->getLoginName(); | |||||
| userIDEditor.setText (userName.isEmpty() ? getLastUserName() : userName); | userIDEditor.setText (userName.isEmpty() ? getLastUserName() : userName); | ||||
| initialiseLabel (errorLabel, Font::plain, ProjucerDialogLookAndFeel::getErrorTextColour()); | initialiseLabel (errorLabel, Font::plain, ProjucerDialogLookAndFeel::getErrorTextColour()); | ||||
| @@ -223,7 +223,7 @@ private: | |||||
| errorLabel.setVisible (false); | errorLabel.setVisible (false); | ||||
| spinner.setVisible (true); | spinner.setVisible (true); | ||||
| ProjucerLicences::getInstance()->login (loginName, password, rememberLogin, this); | |||||
| ProjucerLicenses::getInstance()->login (loginName, password, rememberLogin, this); | |||||
| } | } | ||||
| void registerButtonClicked() | void registerButtonClicked() | ||||
| @@ -48,7 +48,7 @@ | |||||
| #include "../LiveBuildEngine/projucer_CompileEngineServer.h" | #include "../LiveBuildEngine/projucer_CompileEngineServer.h" | ||||
| #include "jucer_ProjucerLicenses.h" | #include "jucer_ProjucerLicenses.h" | ||||
| juce_ImplementSingleton (ProjucerLicences); | |||||
| juce_ImplementSingleton (ProjucerLicenses); | |||||
| struct ProjucerAppClasses | struct ProjucerAppClasses | ||||
| { | { | ||||
| @@ -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 | #ifndef PROJUCER_PROJUCERLICENSES_H_INCLUDED | ||||
| #define PROJUCER_PROJUCERLICENSES_H_INCLUDED | #define PROJUCER_PROJUCERLICENSES_H_INCLUDED | ||||
| //============================================================================== | //============================================================================== | ||||
| struct ProjucerLicences : private DeletedAtShutdown | |||||
| struct ProjucerLicenses : private DeletedAtShutdown | |||||
| { | { | ||||
| ProjucerLicences() | |||||
| ProjucerLicenses() | |||||
| { | { | ||||
| dll.initialise (crashCallback, quitCallback, false); | dll.initialise (crashCallback, quitCallback, false); | ||||
| } | } | ||||
| juce_DeclareSingleton (ProjucerLicences, false); | |||||
| juce_DeclareSingleton (ProjucerLicenses, false); | |||||
| //============================================================================== | //============================================================================== | ||||
| struct LoginCallback | struct LoginCallback | ||||
| @@ -103,7 +120,7 @@ private: | |||||
| static void staticCallbackFunction (void* userInfo, const char* errorMessage, const char* username, const char* apiKey) | static void staticCallbackFunction (void* userInfo, const char* errorMessage, const char* username, const char* apiKey) | ||||
| { | { | ||||
| static_cast<ProjucerLicences*> (userInfo)->callbackFunction (errorMessage, username, apiKey); | |||||
| static_cast<ProjucerLicenses*> (userInfo)->callbackFunction (errorMessage, username, apiKey); | |||||
| } | } | ||||
| static void crashCallback (const char*) {} | static void crashCallback (const char*) {} | ||||
| @@ -354,9 +354,9 @@ struct BuildTabComponent : public ConcertinaPanel | |||||
| struct ProjucerDisabledComp : public Component, | struct ProjucerDisabledComp : public Component, | ||||
| private Button::Listener | 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()) | const String& loginName = String()) | ||||
| : isPurchaseButton (requirePurchase) | |||||
| : isLoggedIn (loggedIn), isPurchaseButton (requirePurchase) | |||||
| { | { | ||||
| infoLabel.setColour (Label::textColourId, findColour (mainBackgroundColourId).contrasting (0.7f)); | infoLabel.setColour (Label::textColourId, findColour (mainBackgroundColourId).contrasting (0.7f)); | ||||
| infoLabel.setJustificationType (Justification::centred); | infoLabel.setJustificationType (Justification::centred); | ||||
| @@ -404,7 +404,7 @@ struct ProjucerDisabledComp : public Component, | |||||
| } | } | ||||
| else if (btn == signOutButton.get()) | else if (btn == signOutButton.get()) | ||||
| { | { | ||||
| ProjucerLicences::getInstance()->logout(); | |||||
| ProjucerLicenses::getInstance()->logout(); | |||||
| ProjucerApplication::getApp().updateAllBuildTabs(); | ProjucerApplication::getApp().updateAllBuildTabs(); | ||||
| } | } | ||||
| } | } | ||||
| @@ -412,7 +412,7 @@ struct ProjucerDisabledComp : public Component, | |||||
| Label infoLabel { "info", String() }; | Label infoLabel { "info", String() }; | ||||
| TextButton loginButton { "Log-in..." }; | TextButton loginButton { "Log-in..." }; | ||||
| ScopedPointer<TextButton> signOutButton; | ScopedPointer<TextButton> signOutButton; | ||||
| bool isPurchaseButton; | |||||
| bool isLoggedIn, isPurchaseButton; | |||||
| }; | }; | ||||
| struct EnableBuildComp : public Component | struct EnableBuildComp : public Component | ||||
| @@ -449,11 +449,11 @@ Component* ProjectContentComponent::createBuildTab (CompileEngineChildProcess* c | |||||
| #if JUCE_WINDOWS | #if JUCE_WINDOWS | ||||
| ignoreUnused (child); | ignoreUnused (child); | ||||
| return new ProjucerDisabledComp ("Windows support is still under development - " | 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 | #elif JUCE_LINUX | ||||
| ignoreUnused (child); | ignoreUnused (child); | ||||
| return new ProjucerDisabledComp ("Linux support is still under development - " | 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 | #else | ||||
| if (child != nullptr) | if (child != nullptr) | ||||
| { | { | ||||
| @@ -462,7 +462,7 @@ Component* ProjectContentComponent::createBuildTab (CompileEngineChildProcess* c | |||||
| return new BuildTabComponent (child, new ProjucerAppClasses::ErrorListComp (child->errorList)); | return new BuildTabComponent (child, new ProjucerAppClasses::ErrorListComp (child->errorList)); | ||||
| } | } | ||||
| auto& unlockStatus = *ProjucerLicences::getInstance(); | |||||
| auto& unlockStatus = *ProjucerLicenses::getInstance(); | |||||
| if (unlockStatus.hasLiveCodingLicence() | if (unlockStatus.hasLiveCodingLicence() | ||||
| && project != nullptr | && project != nullptr | ||||
| @@ -474,7 +474,7 @@ Component* ProjectContentComponent::createBuildTab (CompileEngineChildProcess* c | |||||
| + newLine | + newLine | ||||
| + "Your account " + unlockStatus.getLoginName().quoted() | + "Your account " + unlockStatus.getLoginName().quoted() | ||||
| + " does not have an asscociated JUCE Pro license:", | + " does not have an asscociated JUCE Pro license:", | ||||
| true, true, unlockStatus.getLoginName()); | |||||
| true, true, true, unlockStatus.getLoginName()); | |||||
| if (! unlockStatus.isDLLPresent()) | if (! unlockStatus.isDLLPresent()) | ||||
| return new ProjucerDisabledComp (String ("The live-building DLL is missing!") + newLine | 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 " | + "To enable the compiler, you'll need to install the missing DLL " | ||||
| + CompileEngineDLL::getDLLName().quoted() + newLine | + CompileEngineDLL::getDLLName().quoted() + newLine | ||||
| + 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" | 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 | #endif | ||||
| } | } | ||||
| @@ -494,14 +496,24 @@ BuildTabComponent* findBuildTab (const TabbedComponent& tabs) | |||||
| return dynamic_cast<BuildTabComponent*> (tabs.getTabContentComponent (2)); | return dynamic_cast<BuildTabComponent*> (tabs.getTabContentComponent (2)); | ||||
| } | } | ||||
| bool ProjectContentComponent::isBuildTabShowing() const | |||||
| bool ProjectContentComponent::isBuildTabEnabled() const | |||||
| { | { | ||||
| return findBuildTab (treeViewTabs) != nullptr; | return findBuildTab (treeViewTabs) != nullptr; | ||||
| } | } | ||||
| bool ProjectContentComponent::isLoggedInTabShowing() const | |||||
| bool ProjectContentComponent::isBuildTabSuitableForLoggedInUser() const | |||||
| { | { | ||||
| return isBuildTabShowing() || dynamic_cast<EnableBuildComp*> (treeViewTabs.getTabContentComponent (2)) != nullptr; | |||||
| return isBuildTabEnabled() | |||||
| || isBuildTabLoggedInWithoutLicense() | |||||
| || dynamic_cast<EnableBuildComp*> (treeViewTabs.getTabContentComponent (2)) != nullptr; | |||||
| } | |||||
| bool ProjectContentComponent::isBuildTabLoggedInWithoutLicense() const | |||||
| { | |||||
| if (auto* c = dynamic_cast<ProjucerDisabledComp*> (treeViewTabs.getTabContentComponent (2))) | |||||
| return c->isLoggedIn; | |||||
| return false; | |||||
| } | } | ||||
| void ProjectContentComponent::createProjectTabs() | void ProjectContentComponent::createProjectTabs() | ||||
| @@ -1355,16 +1367,16 @@ bool ProjectContentComponent::isBuildEnabled() const | |||||
| { | { | ||||
| return project != nullptr | return project != nullptr | ||||
| && ! LiveBuildProjectSettings::isBuildDisabled (*project) | && ! LiveBuildProjectSettings::isBuildDisabled (*project) | ||||
| && ProjucerLicences::getInstance()->hasLiveCodingLicence() | |||||
| && ProjucerLicences::getInstance()->isLoggedIn(); | |||||
| && ProjucerLicenses::getInstance()->hasLiveCodingLicence() | |||||
| && ProjucerLicenses::getInstance()->isLoggedIn(); | |||||
| } | } | ||||
| void ProjectContentComponent::refreshTabsIfBuildStatusChanged() | void ProjectContentComponent::refreshTabsIfBuildStatusChanged() | ||||
| { | { | ||||
| if (project != nullptr | if (project != nullptr | ||||
| && (treeViewTabs.getNumTabs() < 3 | && (treeViewTabs.getNumTabs() < 3 | ||||
| || isBuildEnabled() != isBuildTabShowing() | |||||
| || ProjucerLicences::getInstance()->isLoggedIn() != isLoggedInTabShowing())) | |||||
| || isBuildEnabled() != isBuildTabEnabled() | |||||
| || ProjucerLicenses::getInstance()->isLoggedIn() != isBuildTabSuitableForLoggedInUser())) | |||||
| rebuildProjectTabs(); | rebuildProjectTabs(); | ||||
| } | } | ||||
| @@ -1493,7 +1505,7 @@ void ProjectContentComponent::handleMissingSystemHeaders() | |||||
| deleteProjectTabs(); | deleteProjectTabs(); | ||||
| createProjectTabs(); | createProjectTabs(); | ||||
| ProjucerDisabledComp* buildTab = new ProjucerDisabledComp (tabMessage, false); | |||||
| ProjucerDisabledComp* buildTab = new ProjucerDisabledComp (tabMessage, false, false); | |||||
| treeViewTabs.addTab ("Build", Colours::transparentBlack, buildTab, true); | treeViewTabs.addTab ("Build", Colours::transparentBlack, buildTab, true); | ||||
| showBuildTab(); | showBuildTab(); | ||||
| @@ -110,8 +110,7 @@ public: | |||||
| void killChildProcess(); | void killChildProcess(); | ||||
| void cleanAll(); | void cleanAll(); | ||||
| void handleMissingSystemHeaders(); | void handleMissingSystemHeaders(); | ||||
| bool isBuildTabShowing() const; | |||||
| bool isLoggedInTabShowing() const; | |||||
| bool isBuildTabEnabled() const; | |||||
| void setBuildEnabled (bool); | void setBuildEnabled (bool); | ||||
| bool isBuildEnabled() const; | bool isBuildEnabled() const; | ||||
| bool areWarningsEnabled() const; | bool areWarningsEnabled() const; | ||||
| @@ -162,6 +161,8 @@ private: | |||||
| void updateWarningState(); | void updateWarningState(); | ||||
| void launchApp(); | void launchApp(); | ||||
| void killApp(); | void killApp(); | ||||
| bool isBuildTabSuitableForLoggedInUser() const; | |||||
| bool isBuildTabLoggedInWithoutLicense() const; | |||||
| ReferenceCountedObjectPtr<CompileEngineChildProcess> getChildProcess(); | ReferenceCountedObjectPtr<CompileEngineChildProcess> getChildProcess(); | ||||