mirror of
https://github.com/textmate/textmate.git
synced 2026-04-28 03:00:34 -04:00
Limit public API to the LicenseManager singleton
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
#import <OakFoundation/OakFoundation.h>
|
||||
#import <OakFoundation/NSString Additions.h>
|
||||
#import <BundlesManager/BundlesManager.h>
|
||||
#import <license/license.h>
|
||||
#import <license/LicenseManager.h>
|
||||
#import <ns/ns.h>
|
||||
|
||||
@@ -48,18 +47,7 @@ static NSData* Digest (NSString* someString)
|
||||
|
||||
- (NSString*)licensees
|
||||
{
|
||||
if(!licensees)
|
||||
{
|
||||
for(auto owner : license::find_all())
|
||||
{
|
||||
if(license::is_valid(license::decode(license::find(owner)), owner))
|
||||
{
|
||||
licensees = [NSString stringWithCxxString:owner];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return licensees;
|
||||
return LicenseManager.sharedInstance.owner;
|
||||
}
|
||||
|
||||
- (void)addLicense
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
#import <regexp/glob.h>
|
||||
#import <network/tbz.h>
|
||||
#import <ns/ns.h>
|
||||
#import <license/license.h>
|
||||
#import <license/LicenseManager.h>
|
||||
#import <settings/settings.h>
|
||||
#import <oak/debug.h>
|
||||
@@ -164,11 +163,8 @@ BOOL HasDocumentWindow (NSArray* windows)
|
||||
if([currentDate laterDate:warningDate] == warningDate)
|
||||
return (void)[NSTimer scheduledTimerWithTimeInterval:7 * kSecondsPerDay target:self selector:@selector(checkExpirationDate:) userInfo:nil repeats:NO];
|
||||
|
||||
for(auto owner : license::find_all())
|
||||
{
|
||||
if(license::is_valid(license::decode(license::find(owner)), owner))
|
||||
return;
|
||||
}
|
||||
if(LicenseManager.sharedInstance.owner != nil)
|
||||
return;
|
||||
|
||||
if([currentDate laterDate:expirationDate] == currentDate)
|
||||
{
|
||||
|
||||
@@ -3,4 +3,5 @@
|
||||
PUBLIC @interface LicenseManager : NSObject
|
||||
+ (instancetype)sharedInstance;
|
||||
- (void)showAddLicenseWindow:(id)sender;
|
||||
@property (nonatomic, readonly) NSString* owner;
|
||||
@end
|
||||
|
||||
@@ -12,6 +12,9 @@
|
||||
@end
|
||||
|
||||
@interface LicenseManager ()
|
||||
{
|
||||
id _owner;
|
||||
}
|
||||
- (BOOL)addLicense:(License*)license;
|
||||
@end
|
||||
|
||||
@@ -214,6 +217,23 @@ static NSTextField* OakCreateTextField ()
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSString*)owner
|
||||
{
|
||||
if(_owner == nil)
|
||||
{
|
||||
_owner = [NSNull null];
|
||||
for(auto owner : license::find_all())
|
||||
{
|
||||
if(license::is_valid(license::decode(license::find(owner)), owner))
|
||||
{
|
||||
_owner = to_ns(owner);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return _owner != [NSNull null] ? _owner : nil;
|
||||
}
|
||||
|
||||
- (BOOL)addLicense:(License*)info
|
||||
{
|
||||
if(info.isValid == NO)
|
||||
@@ -222,6 +242,7 @@ static NSTextField* OakCreateTextField ()
|
||||
std::string error = "Unknown error.";
|
||||
if(license::add(to_s([info.owner stringByTrimmingCharactersInSet:NSCharacterSet.whitespaceAndNewlineCharacterSet]), to_s(info.licenseAsBase32), &error))
|
||||
{
|
||||
_owner = info.owner;
|
||||
[self removeAllRegisterButtons:self];
|
||||
NSRunAlertPanel(@"License Added to Keychain", @"Thanks for your support!", @"Continue", nil, nil);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
SOURCES = src/*.{cc,mm}
|
||||
EXPORT = src/{license,keychain,LicenseManager}.h
|
||||
EXPORT = src/LicenseManager.h
|
||||
LINK += crash text cf ns OakAppKit OakFoundation
|
||||
CXX_FLAGS += -I"$libressl_prefix/include"
|
||||
LN_FLAGS += -Wl,-U,__Z15revoked_serialsv
|
||||
|
||||
Reference in New Issue
Block a user