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