Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 7ba41b6

Browse files
committed
[[ Addons ]] Check if external is licensed via addons
This patch checks if the external is licensed via an addon rather than edition. If the external name contains `.` then it is assumed to be a full addon name and checked directly. If not it may be a livecode addon and will be checked against `com.livecode.external.<name>`
1 parent 16f64b9 commit 7ba41b6

File tree

3 files changed

+42
-3
lines changed

3 files changed

+42
-3
lines changed

engine/src/externalv1.cpp

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2808,6 +2808,37 @@ static MCExternalError MCExternalInterfaceQuery(MCExternalInterfaceQueryTag op,
28082808

28092809
MCExternalError MCExternalLicenseCheckEdition(unsigned int p_options, unsigned int p_min_edition)
28102810
{
2811+
MCAutoStringRef t_key;
2812+
2813+
uint32_t t_index;
2814+
if (MCCStringFirstIndexOf(s_current_external->GetName(), '.', t_index))
2815+
{
2816+
if (!MCStringCreateWithCString(s_current_external->GetName(), &t_key))
2817+
{
2818+
return kMCExternalErrorFailed;
2819+
}
2820+
}
2821+
else
2822+
{
2823+
if (!MCStringFormat(&t_key, "com.livecode.external.%s", s_current_external->GetName()))
2824+
{
2825+
return kMCExternalErrorFailed;
2826+
}
2827+
}
2828+
2829+
MCNewAutoNameRef t_key_as_nameref;
2830+
if (!MCNameCreate(*t_key, &t_key_as_nameref))
2831+
{
2832+
return kMCExternalErrorFailed;
2833+
}
2834+
2835+
MCAutoValueRef t_value;
2836+
if (MClicenseparameters . addons != nil &&
2837+
MCArrayFetchValue(MClicenseparameters . addons, false, *t_key_as_nameref, &t_value))
2838+
{
2839+
return kMCExternalErrorNone;
2840+
}
2841+
28112842
unsigned int t_current_edition;
28122843
switch(MClicenseparameters . license_class)
28132844
{
@@ -2819,7 +2850,11 @@ MCExternalError MCExternalLicenseCheckEdition(unsigned int p_options, unsigned i
28192850
t_current_edition = kMCExternalLicenseTypeCommunity;
28202851
break;
28212852

2822-
case kMCLicenseClassEvaluation:
2853+
case kMCLicenseClassCommunityPlus:
2854+
t_current_edition = kMCExternalLicenseTypeCommunityPlus;
2855+
break;
2856+
2857+
case kMCLicenseClassEvaluation:
28232858
case kMCLicenseClassCommercial:
28242859
t_current_edition = kMCExternalLicenseTypeIndy;
28252860
break;
@@ -2834,7 +2869,8 @@ MCExternalError MCExternalLicenseCheckEdition(unsigned int p_options, unsigned i
28342869
break;
28352870
}
28362871

2837-
if (t_current_edition < p_min_edition)
2872+
if (kMCExternalLicenseTypeNone == p_min_edition ||
2873+
t_current_edition < p_min_edition)
28382874
{
28392875
s_current_external -> SetWasLicensed(false);
28402876
return kMCExternalErrorUnlicensed;

engine/src/externalv1.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,8 @@ enum MCExternalLicenseType
303303
{
304304
kMCExternalLicenseTypeNone = 0,
305305
kMCExternalLicenseTypeCommunity = 1000,
306-
kMCExternalLicenseTypeIndy = 2000,
306+
kMCExternalLicenseTypeCommunityPlus = 1500,
307+
kMCExternalLicenseTypeIndy = 2000,
307308
kMCExternalLicenseTypeBusiness = 3000,
308309
};
309310

lcidlc/include/LiveCode.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,9 @@ enum
426426

427427
enum
428428
{
429+
kLCLicenseEditionNone = 0,
429430
kLCLicenseEditionCommunity = 1000,
431+
kLCLicenseEditionCommunityPlus = 1500,
430432
kLCLicenseEditionIndy = 2000,
431433
kLCLicenseEditionBusiness = 3000,
432434
};

0 commit comments

Comments
 (0)