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.

92 lines
2.7KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2022 - Raw Material Software Limited
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. By using JUCE, you agree to the terms of both the JUCE 7 End-User License
  8. Agreement and JUCE Privacy Policy.
  9. End User License Agreement: www.juce.com/juce-7-licence
  10. Privacy Policy: www.juce.com/juce-privacy-policy
  11. Or: You may also use this code under the terms of the GPL v3 (see
  12. www.gnu.org/licenses).
  13. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  14. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  15. DISCLAIMED.
  16. ==============================================================================
  17. */
  18. #pragma once
  19. //==============================================================================
  20. struct LicenseState
  21. {
  22. enum class Type
  23. {
  24. none,
  25. gpl,
  26. personal,
  27. educational,
  28. indie,
  29. pro
  30. };
  31. LicenseState() = default;
  32. LicenseState (Type t, int v, String user, String token)
  33. : type (t), version (v), username (user), authToken (token)
  34. {
  35. }
  36. bool operator== (const LicenseState& other) const noexcept
  37. {
  38. return type == other.type
  39. && version == other.version
  40. && username == other.username
  41. && authToken == other.authToken;
  42. }
  43. bool operator != (const LicenseState& other) const noexcept
  44. {
  45. return ! operator== (other);
  46. }
  47. bool isSignedIn() const noexcept { return isGPL() || (version > 0 && username.isNotEmpty()); }
  48. bool isOldLicense() const noexcept { return isSignedIn() && version < projucerMajorVersion; }
  49. bool isGPL() const noexcept { return type == Type::gpl; }
  50. bool canUnlockFullFeatures() const noexcept
  51. {
  52. return isGPL() || (isSignedIn() && ! isOldLicense() && (type == Type::indie || type == Type::pro));
  53. }
  54. String getLicenseTypeString() const
  55. {
  56. switch (type)
  57. {
  58. case Type::none: return "No license";
  59. case Type::gpl: return "GPL";
  60. case Type::personal: return "Personal";
  61. case Type::educational: return "Educational";
  62. case Type::indie: return "Indie";
  63. case Type::pro: return "Pro";
  64. default: break;
  65. };
  66. jassertfalse;
  67. return {};
  68. }
  69. Type type = Type::none;
  70. int version = -1;
  71. String username, authToken;
  72. };