diff --git a/modules/juce_tracktion_marketplace/marketplace/juce_TracktionMarketplaceServer.h b/modules/juce_tracktion_marketplace/marketplace/juce_TracktionMarketplaceServer.h index c7a8a26a33..996c3d9be9 100644 --- a/modules/juce_tracktion_marketplace/marketplace/juce_TracktionMarketplaceServer.h +++ b/modules/juce_tracktion_marketplace/marketplace/juce_TracktionMarketplaceServer.h @@ -68,7 +68,7 @@ public: if (args.size() != 5) { - std::cout << "Requires 5 arguments: app-name username user-email machine-numbers private-key" << std::endl + std::cout << "Requires 5 arguments: app-name user-email username machine-numbers private-key" << std::endl << " app-name: name of the product being unlocked" << std::endl << " user-email: user's email address" << std::endl << " username: name of the user. Careful not to allow any spaces!" << std::endl diff --git a/modules/juce_tracktion_marketplace/marketplace/juce_TracktionMarketplaceStatus.cpp b/modules/juce_tracktion_marketplace/marketplace/juce_TracktionMarketplaceStatus.cpp index d72c53dab1..222096d3b6 100644 --- a/modules/juce_tracktion_marketplace/marketplace/juce_TracktionMarketplaceStatus.cpp +++ b/modules/juce_tracktion_marketplace/marketplace/juce_TracktionMarketplaceStatus.cpp @@ -341,12 +341,8 @@ TracktionMarketplaceStatus::UnlockResult TracktionMarketplaceStatus::handleFaile return r; } -TracktionMarketplaceStatus::UnlockResult TracktionMarketplaceStatus::attemptWebserverUnlock (const String& email, - const String& password) +String TracktionMarketplaceStatus::readReplyFromWebserver (const String& email, const String& password) { - // This method will block while it contacts the server, so you must run it on a background thread! - jassert (! MessageManager::getInstance()->isThisTheMessageThread()); - URL url (getServerAuthenticationURL() .withParameter ("product", getMarketplaceProductID()) .withParameter ("email", email) @@ -356,7 +352,16 @@ TracktionMarketplaceStatus::UnlockResult TracktionMarketplaceStatus::attemptWebs DBG ("Trying to unlock via URL: " << url.toString (true)); - const String reply (url.readEntireTextStream()); + return url.readEntireTextStream(); +} + +TracktionMarketplaceStatus::UnlockResult TracktionMarketplaceStatus::attemptWebserverUnlock (const String& email, + const String& password) +{ + // This method will block while it contacts the server, so you must run it on a background thread! + jassert (! MessageManager::getInstance()->isThisTheMessageThread()); + + String reply (readReplyFromWebserver (email, password)); DBG ("Reply from server: " << reply); diff --git a/modules/juce_tracktion_marketplace/marketplace/juce_TracktionMarketplaceStatus.h b/modules/juce_tracktion_marketplace/marketplace/juce_TracktionMarketplaceStatus.h index 9cab90fcc8..6f58768702 100644 --- a/modules/juce_tracktion_marketplace/marketplace/juce_TracktionMarketplaceStatus.h +++ b/modules/juce_tracktion_marketplace/marketplace/juce_TracktionMarketplaceStatus.h @@ -105,6 +105,11 @@ public: /** Can be overridden if necessary, but by default returns "tracktion.com". */ virtual String getWebsiteName(); + /** The default implementation of this method will construct a URL with the default + parameters and read the reply, but for custom webserver set-ups, you may need to + override it to use more exotic methods. */ + virtual String readReplyFromWebserver (const String& email, const String& password); + //============================================================================== // The following methods can be called by your app: diff --git a/modules/juce_tracktion_marketplace/marketplace/juce_TracktionMarketplaceUnlockForm.cpp b/modules/juce_tracktion_marketplace/marketplace/juce_TracktionMarketplaceUnlockForm.cpp index 2e3c450aff..dc4749bc23 100644 --- a/modules/juce_tracktion_marketplace/marketplace/juce_TracktionMarketplaceUnlockForm.cpp +++ b/modules/juce_tracktion_marketplace/marketplace/juce_TracktionMarketplaceUnlockForm.cpp @@ -82,15 +82,15 @@ struct TracktionMarketplaceUnlockForm::OverlayComp : public Component, if (result.errorMessage.isNotEmpty()) { - AlertWindow::showMessageBox (AlertWindow::WarningIcon, - TRANS("Registration Failed"), - result.errorMessage); + AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon, + TRANS("Registration Failed"), + result.errorMessage); } else if (result.informativeMessage.isNotEmpty()) { - AlertWindow::showMessageBox (AlertWindow::InfoIcon, - TRANS("Registration Complete!"), - result.informativeMessage); + AlertWindow::showMessageBoxAsync (AlertWindow::InfoIcon, + TRANS("Registration Complete!"), + result.informativeMessage); } else if (result.urlToLaunch.isNotEmpty()) { @@ -99,7 +99,7 @@ struct TracktionMarketplaceUnlockForm::OverlayComp : public Component, } if (result.succeeded) - form.cancel(); + form.dismiss(); else delete this; } @@ -120,7 +120,8 @@ static juce_wchar getDefaultPasswordChar() noexcept } TracktionMarketplaceUnlockForm::TracktionMarketplaceUnlockForm (TracktionMarketplaceStatus& s, - const String& userInstructions) + const String& userInstructions, + bool hasCancelButton) : status (s), message (String(), userInstructions), passwordBox (String(), getDefaultPasswordChar()), @@ -139,7 +140,9 @@ TracktionMarketplaceUnlockForm::TracktionMarketplaceUnlockForm (TracktionMarketp addAndMakeVisible (emailBox); addAndMakeVisible (passwordBox); addAndMakeVisible (registerButton); - addAndMakeVisible (cancelButton); + + if (hasCancelButton) + addAndMakeVisible (cancelButton); registerButton.addListener (this); cancelButton.addListener (this); @@ -174,21 +177,31 @@ void TracktionMarketplaceUnlockForm::resized() Rectangle buttonArea (r.removeFromBottom (buttonHeight)); registerButton.changeWidthToFitText (buttonHeight); cancelButton.changeWidthToFitText (buttonHeight); + const int gap = 20; - buttonArea = buttonArea.withSizeKeepingCentre (registerButton.getWidth() + gap + cancelButton.getWidth(), buttonHeight); + buttonArea = buttonArea.withSizeKeepingCentre (registerButton.getWidth() + + (cancelButton.isVisible() ? gap + cancelButton.getWidth() : 0), + buttonHeight); registerButton.setBounds (buttonArea.removeFromLeft (registerButton.getWidth())); buttonArea.removeFromLeft (gap); cancelButton.setBounds (buttonArea); r.removeFromBottom (20); + // (force use of a default system font to make sure it has the password blob character) + Font font (Font::getDefaultTypefaceForFont (Font (Font::getDefaultSansSerifFontName(), + Font::getDefaultStyle(), + 5.0f))); + const int boxHeight = 24; passwordBox.setBounds (r.removeFromBottom (boxHeight)); passwordBox.setInputRestrictions (64); + passwordBox.setFont (font); r.removeFromBottom (30); emailBox.setBounds (r.removeFromBottom (boxHeight)); - passwordBox.setInputRestrictions (256); + emailBox.setInputRestrictions (512); + emailBox.setFont (font); r.removeFromBottom (30); @@ -225,7 +238,7 @@ void TracktionMarketplaceUnlockForm::buttonClicked (Button* b) if (b == ®isterButton) attemptRegistration(); else if (b == &cancelButton) - cancel(); + dismiss(); } void TracktionMarketplaceUnlockForm::attemptRegistration() @@ -252,7 +265,7 @@ void TracktionMarketplaceUnlockForm::attemptRegistration() } } -void TracktionMarketplaceUnlockForm::cancel() +void TracktionMarketplaceUnlockForm::dismiss() { delete this; } diff --git a/modules/juce_tracktion_marketplace/marketplace/juce_TracktionMarketplaceUnlockForm.h b/modules/juce_tracktion_marketplace/marketplace/juce_TracktionMarketplaceUnlockForm.h index f229a12623..5cddaa348a 100644 --- a/modules/juce_tracktion_marketplace/marketplace/juce_TracktionMarketplaceUnlockForm.h +++ b/modules/juce_tracktion_marketplace/marketplace/juce_TracktionMarketplaceUnlockForm.h @@ -49,11 +49,18 @@ public: The userInstructions will be displayed above the email and password boxes. */ TracktionMarketplaceUnlockForm (TracktionMarketplaceStatus&, - const String& userInstructions); + const String& userInstructions, + bool hasCancelButton = true); /** Destructor. */ ~TracktionMarketplaceUnlockForm(); + /** This is called when the form is dismissed (either cancelled or when registration + succeeds). + By default it will delete this, but you can override it to do other things. + */ + virtual void dismiss(); + /** @internal */ void paint (Graphics&) override; /** @internal */ @@ -75,7 +82,6 @@ private: void buttonClicked (Button*) override; void attemptRegistration(); - void cancel(); void showBubbleMessage (const String&, Component&); JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TracktionMarketplaceUnlockForm)