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.

85 lines
2.4KB

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