1
0
mirror of https://github.com/arsenetar/dupeguru.git synced 2026-01-23 07:01:39 +00:00

Removed fairware

This commit is contained in:
Virgil Dupras
2013-11-30 17:54:40 -05:00
parent 42be49da83
commit 01403a3f92
42 changed files with 18 additions and 1465 deletions

View File

@@ -14,8 +14,6 @@ http://www.hardcoded.net/licenses/bsd_license
NSTextField *titleTextField;
NSTextField *versionTextField;
NSTextField *copyrightTextField;
NSTextField *registeredTextField;
NSButton *registerButton;
PyBaseApp *app;
}

View File

@@ -1,19 +0,0 @@
/*
Copyright 2013 Hardcoded Software (http://www.hardcoded.net)
This software is licensed under the "BSD" License as described in the "LICENSE" file,
which should be included with this package. The terms are also available at
http://www.hardcoded.net/licenses/bsd_license
*/
#import <Cocoa/Cocoa.h>
#import "HSFairwareProtocol.h"
@interface HSFairware : NSObject <HSFairwareProtocol>
{
NSInteger appId;
NSString *name;
BOOL registered;
}
- (id)initWithAppId:(NSInteger)aAppId name:(NSString *)aName;
@end

View File

@@ -1,150 +0,0 @@
/*
Copyright 2013 Hardcoded Software (http://www.hardcoded.net)
This software is licensed under the "BSD" License as described in the "LICENSE" file,
which should be included with this package. The terms are also available at
http://www.hardcoded.net/licenses/bsd_license
*/
#import "HSFairware.h"
#import <CommonCrypto/CommonDigest.h>
#import "HSFairwareReminder.h"
#import "Dialogs.h"
#import "Utils.h"
NSString* md5str(NSString *source)
{
const char *cSource = [source UTF8String];
unsigned char result[16];
CC_MD5(cSource, strlen(cSource), result);
return fmt(@"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
result[0], result[1], result[2], result[3], result[4], result[5], result[6], result[7],
result[8], result[9], result[10], result[11], result[12], result[13], result[14], result[15]
);
}
BOOL validateCode(NSString *code, NSString *email, NSInteger appId)
{
if ([code length] != 32) {
return NO;
}
NSInteger i;
for (i=0; i<=100; i++) {
NSString *blob = fmt(@"%i%@%iaybabtu", appId, email, i);
if ([md5str(blob) isEqualTo:code]) {
return YES;
}
}
return NO;
}
NSString* normalizeString(NSString *str)
{
return [[str stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] lowercaseString];
}
@implementation HSFairware
- (id)initWithAppId:(NSInteger)aAppId name:(NSString *)aName;
{
self = [super init];
appId = aAppId;
name = [aName retain];
registered = NO;
return self;
}
- (void)dealloc
{
[name release];
[super dealloc];
}
/* Private */
- (void)setRegistrationCode:(NSString *)aCode email:(NSString *)aEmail
{
registered = validateCode(aCode, aEmail, appId);
}
/* Public */
- (void)initialRegistrationSetup
{
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
NSString *code = [ud stringForKey:@"RegistrationCode"];
NSString *email = [ud stringForKey:@"RegistrationEmail"];
if (code && email) {
[self setRegistrationCode:code email:email];
}
if (!registered) {
BOOL fairwareMode = [ud boolForKey:@"FairwareMode"];
if (!fairwareMode) {
NSString *prompt = @"%@ is fairware, which means \"open source software developed "
"with expectation of fair contributions from users\". It's a very interesting "
"concept, but one year of fairware has shown that most people just want to know "
"how much it costs and not be bothered with theories about intellectual property."
"\n\n"
"So I won't bother you and will be very straightforward: You can try %@ for "
"free but you have to buy it in order to use it without limitations. In demo mode, "
"%@ will show this dialog on startup."
"\n\n"
"So it's as simple as this. If you're curious about fairware, however, I encourage "
"you to read more about it by clicking on the \"Fairware?\" button.";
[HSFairwareReminder showDemoNagWithApp:self prompt:fmt(prompt, name, name, name)];
}
}
}
- (NSString *)appName
{
return name;
}
- (NSString *)appLongName
{
return name;
}
- (BOOL)isRegistered
{
return registered;
}
- (BOOL)setRegisteredCode:(NSString *)code andEmail:(NSString *)email
{
code = normalizeString(code);
email = normalizeString(email);
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
if (([code isEqualTo:@"fairware"]) || ([email isEqualTo:@"fairware"])) {
[ud setBool:YES forKey:@"FairwareMode"];
[Dialogs showMessage:@"Fairware mode enabled."];
return YES;
}
[self setRegistrationCode:code email:email];
if (registered) {
[ud setObject:code forKey:@"RegistrationCode"];
[ud setObject:email forKey:@"RegistrationEmail"];
[Dialogs showMessage:@"Your code is valid, thanks!"];
return YES;
}
else {
[Dialogs showMessage:@"Your code is invalid. Make sure that you wrote the good code. Also "
"make sure that the e-mail you gave is the same as the e-mail you used for your purchase."];
return NO;
}
}
- (void)contribute
{
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://open.hardcoded.net/contribute/"]];
}
- (void)buy
{
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://www.hardcoded.net/purchase.htm"]];
}
- (void)aboutFairware
{
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://open.hardcoded.net/about/"]];
}
@end

View File

@@ -1,33 +0,0 @@
/*
Copyright 2013 Hardcoded Software (http://www.hardcoded.net)
This software is licensed under the "BSD" License as described in the "LICENSE" file,
which should be included with this package. The terms are also available at
http://www.hardcoded.net/licenses/bsd_license
*/
#import <Cocoa/Cocoa.h>
#import "PyFairware.h"
@interface HSFairwareAboutBox : NSWindowController
{
NSTextField *titleTextField;
NSTextField *versionTextField;
NSTextField *copyrightTextField;
NSTextField *registeredTextField;
NSButton *registerButton;
PyFairware *app;
}
@property (readwrite, retain) NSTextField *titleTextField;
@property (readwrite, retain) NSTextField *versionTextField;
@property (readwrite, retain) NSTextField *copyrightTextField;
@property (readwrite, retain) NSTextField *registeredTextField;
@property (readwrite, retain) NSButton *registerButton;
- (id)initWithApp:(PyFairware *)app;
- (void)updateFields;
- (void)showRegisterDialog;
@end

View File

@@ -1,60 +0,0 @@
/*
Copyright 2013 Hardcoded Software (http://www.hardcoded.net)
This software is licensed under the "BSD" License as described in the "LICENSE" file,
which should be included with this package. The terms are also available at
http://www.hardcoded.net/licenses/bsd_license
*/
#import "HSFairwareAboutBox.h"
#import "HSFairwareAboutBox_UI.h"
#import "HSFairwareReminder.h"
@implementation HSFairwareAboutBox
@synthesize titleTextField;
@synthesize versionTextField;
@synthesize copyrightTextField;
@synthesize registeredTextField;
@synthesize registerButton;
- (id)initWithApp:(PyFairware *)aApp
{
self = [super initWithWindow:nil];
[self setWindow:createHSFairwareAboutBox_UI(self)];
app = [aApp retain];
[self updateFields];
return self;
}
- (void)dealloc
{
[app release];
[super dealloc];
}
- (void)updateFields
{
[titleTextField setStringValue:[app appLongName]];
NSString *version = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"];
[versionTextField setStringValue:[NSString stringWithFormat:@"Version: %@",version]];
NSString *copyright = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSHumanReadableCopyright"];
[copyrightTextField setStringValue:copyright];
if ([app isRegistered]) {
[registeredTextField setHidden:NO];
[registerButton setHidden:YES];
}
else {
[registeredTextField setHidden:YES];
[registerButton setHidden:NO];
}
}
- (void)showRegisterDialog
{
HSFairwareReminder *fr = [[HSFairwareReminder alloc] initWithApp:app];
[fr enterCode];
[fr release];
[self updateFields];
}
@end

View File

@@ -1,20 +0,0 @@
/*
Copyright 2013 Hardcoded Software (http://www.hardcoded.net)
This software is licensed under the "BSD" License as described in the "LICENSE" file,
which should be included with this package. The terms are also available at
http://www.hardcoded.net/licenses/bsd_license
*/
#import <Cocoa/Cocoa.h>
@protocol HSFairwareProtocol
- (void)initialRegistrationSetup;
- (NSString *)appName;
- (NSString *)appLongName;
- (BOOL)isRegistered;
- (BOOL)setRegisteredCode:(NSString *)code andEmail:(NSString *)email;
- (void)contribute;
- (void)buy;
- (void)aboutFairware;
@end

View File

@@ -1,46 +0,0 @@
/*
Copyright 2013 Hardcoded Software (http://www.hardcoded.net)
This software is licensed under the "BSD" License as described in the "LICENSE" file,
which should be included with this package. The terms are also available at
http://www.hardcoded.net/licenses/bsd_license
*/
#import <Cocoa/Cocoa.h>
#import "HSFairwareProtocol.h"
@interface HSFairwareReminder : NSObject
{
NSWindow *codePanel;
NSTextField *codePromptTextField;
NSTextField *codeTextField;
NSTextField *emailTextField;
NSWindow *demoNagPanel;
NSTextField *demoPromptTextField;
id <HSFairwareProtocol> app;
}
@property (readwrite, retain) NSWindow *codePanel;
@property (readwrite, retain) NSTextField *codePromptTextField;
@property (readwrite, retain) NSTextField *codeTextField;
@property (readwrite, retain) NSTextField *emailTextField;
@property (readwrite, retain) NSWindow *demoNagPanel;
@property (readwrite, retain) NSTextField *demoPromptTextField;
//Show nag only if needed
+ (BOOL)showDemoNagWithApp:(id <HSFairwareProtocol>)app prompt:(NSString *)prompt;
- (id)initWithApp:(id <HSFairwareProtocol>)app;
- (void)contribute;
- (void)buy;
- (void)moreInfo;
- (void)cancelCode;
- (void)showEnterCode;
- (void)submitCode;
- (void)closeDialog;
- (BOOL)showNagPanel:(NSWindow *)panel; //YES: The code has been sucessfully submitted NO: The use wan't to try the demo.
- (BOOL)showDemoNagPanelWithPrompt:(NSString *)prompt;
- (NSInteger)enterCode; //returns the modal code.
@end

View File

@@ -1,115 +0,0 @@
/*
Copyright 2013 Hardcoded Software (http://www.hardcoded.net)
This software is licensed under the "BSD" License as described in the "LICENSE" file,
which should be included with this package. The terms are also available at
http://www.hardcoded.net/licenses/bsd_license
*/
#import "HSFairwareReminder.h"
#import "HSDemoReminder_UI.h"
#import "HSEnterCode_UI.h"
#import "Dialogs.h"
#import "Utils.h"
@implementation HSFairwareReminder
@synthesize codePanel;
@synthesize codePromptTextField;
@synthesize codeTextField;
@synthesize emailTextField;
@synthesize demoNagPanel;
@synthesize demoPromptTextField;
+ (BOOL)showDemoNagWithApp:(id <HSFairwareProtocol>)app prompt:(NSString *)prompt
{
HSFairwareReminder *fr = [[HSFairwareReminder alloc] initWithApp:app];
BOOL r = [fr showDemoNagPanelWithPrompt:prompt];
[fr release];
return r;
}
- (id)initWithApp:(id <HSFairwareProtocol>)aApp
{
self = [super init];
app = aApp;
[self setDemoNagPanel:createHSDemoReminder_UI(self)];
[self setCodePanel:createHSEnterCode_UI(self)];
[codePanel update];
[codePromptTextField setStringValue:fmt([codePromptTextField stringValue],[app appName])];
return self;
}
- (void)contribute
{
[app contribute];
}
- (void)buy
{
[app buy];
}
- (void)moreInfo
{
[app aboutFairware];
}
- (void)cancelCode
{
[codePanel close];
[NSApp stopModalWithCode:NSCancelButton];
}
- (void)showEnterCode
{
[demoNagPanel close];
[NSApp stopModalWithCode:NSOKButton];
}
- (void)submitCode
{
NSString *code = [codeTextField stringValue];
NSString *email = [emailTextField stringValue];
if ([app setRegisteredCode:code andEmail:email]) {
[codePanel close];
[NSApp stopModalWithCode:NSOKButton];
}
}
- (void)closeDialog
{
[demoNagPanel close];
[NSApp stopModalWithCode:NSCancelButton];
}
- (BOOL)showNagPanel:(NSWindow *)panel;
{
NSInteger r;
while (YES) {
r = [NSApp runModalForWindow:panel];
if (r == NSOKButton) {
r = [self enterCode];
if (r == NSOKButton) {
return YES;
}
}
else {
return NO;
}
}
}
- (BOOL)showDemoNagPanelWithPrompt:(NSString *)prompt
{
[demoNagPanel setTitle:fmt([demoNagPanel title],[app appName])];
[demoPromptTextField setStringValue:prompt];
return [self showNagPanel:demoNagPanel];
}
- (NSInteger)enterCode
{
return [NSApp runModalForWindow:codePanel];
}
@end

View File

@@ -302,37 +302,3 @@ class PyBaseApp(PyGUIObject):
def show_message(self, msg):
self.callback.showMessage_(msg)
class FairwareView(BaseAppView):
def setupAsRegistered(self): pass
def showDemoNagWithPrompt_(self, prompt: str): pass
class PyFairware(PyBaseApp):
FOLLOW_PROTOCOLS = ['HSFairwareProtocol']
def initialRegistrationSetup(self):
self.model.initial_registration_setup()
def isRegistered(self) -> bool:
return self.model.registered
def setRegisteredCode_andEmail_(self, code: str, email: str) -> bool:
return self.model.set_registration(code, email, False)
def contribute(self):
self.model.contribute()
def buy(self):
self.model.buy()
def aboutFairware(self):
self.model.about_fairware()
#--- Python --> Cocoa
@dontwrap
def setup_as_registered(self):
self.callback.setupAsRegistered()
@dontwrap
def show_demo_nag(self, prompt):
self.callback.showDemoNagWithPrompt_(prompt)

View File

@@ -1,32 +0,0 @@
ownerclass = 'HSFairwareReminder'
ownerimport = 'HSFairwareReminder.h'
result = Window(528, 253, "%@ is Fairware")
result.canClose = False
result.canResize = False
result.canMinimize = False
demoPromptLabel = Label(result, NLSTR("<demo prompt>"))
tryButton = Button(result, "Try")
enterKeyButton = Button(result, "Enter Key")
buyButton = Button(result, "Buy")
fairwareButton = Button(result, "Fairware?")
owner.demoPromptTextField = demoPromptLabel
result.initialFirstResponder = tryButton
demoPromptLabel.font = Font(FontFamily.Label, FontSize.SmallControl)
tryButton.action = Action(owner, 'closeDialog')
tryButton.keyEquivalent = "\\r"
enterKeyButton.action = Action(owner, 'showEnterCode')
buyButton.action = Action(owner, 'buy')
fairwareButton.action = Action(owner, 'moreInfo')
for button in (tryButton, enterKeyButton, buyButton, fairwareButton):
button.width = 113
demoPromptLabel.height = 185
demoPromptLabel.packToCorner(Pack.UpperLeft)
demoPromptLabel.fill(Pack.Right)
tryButton.packRelativeTo(demoPromptLabel, Pack.Below, Pack.Left)
enterKeyButton.packRelativeTo(tryButton, Pack.Right, Pack.Middle)
buyButton.packRelativeTo(enterKeyButton, Pack.Right, Pack.Middle)
fairwareButton.packRelativeTo(buyButton, Pack.Right, Pack.Middle)

View File

@@ -1,52 +0,0 @@
ownerclass = 'HSFairwareReminder'
ownerimport = 'HSFairwareReminder.h'
result = Window(450, 185, "Enter Key")
result.canClose = False
result.canResize = False
result.canMinimize = False
titleLabel = Label(result, "Enter your key")
promptLabel = Label(result, "Type the key you received when you contributed to %@, as well as the e-mail used as a reference for the purchase.")
regkeyLabel = Label(result, "Registration key:")
regkeyField = TextField(result, "")
regemailLabel = Label(result, "Registration e-mail:")
regemailField = TextField(result, "")
contributeButton = Button(result, "Contribute")
cancelButton = Button(result, "Cancel")
submitButton = Button(result, "Submit")
owner.codePromptTextField = promptLabel
owner.codeTextField = regkeyField
owner.emailTextField = regemailField
result.initialFirstResponder = regkeyField
titleLabel.font = Font(FontFamily.Label, FontSize.RegularControl, traits=[FontTrait.Bold])
smallerFont = Font(FontFamily.Label, FontSize.SmallControl)
for control in (promptLabel, regkeyLabel, regemailLabel):
control.font = smallerFont
regkeyField.usesSingleLineMode = regemailField.usesSingleLineMode = True
contributeButton.action = Action(owner, 'contribute')
cancelButton.action = Action(owner, 'cancelCode')
cancelButton.keyEquivalent = "\\E"
submitButton.action = Action(owner, 'submitCode')
submitButton.keyEquivalent = "\\r"
for button in (contributeButton, cancelButton, submitButton):
button.width = 100
regkeyLabel.width = 128
regemailLabel.width = 128
promptLabel.height = 32
titleLabel.packToCorner(Pack.UpperLeft)
titleLabel.fill(Pack.Right)
promptLabel.packRelativeTo(titleLabel, Pack.Below, Pack.Left)
promptLabel.fill(Pack.Right)
regkeyField.packRelativeTo(promptLabel, Pack.Below, Pack.Right)
regkeyLabel.packRelativeTo(regkeyField, Pack.Left, Pack.Middle)
regkeyField.fill(Pack.Left)
regemailField.packRelativeTo(regkeyField, Pack.Below, Pack.Right)
regemailLabel.packRelativeTo(regemailField, Pack.Left, Pack.Middle)
regemailField.fill(Pack.Left)
contributeButton.packRelativeTo(regemailLabel, Pack.Below, Pack.Left)
submitButton.packRelativeTo(regemailField, Pack.Below, Pack.Right)
cancelButton.packRelativeTo(submitButton, Pack.Left, Pack.Middle)

View File

@@ -1,46 +0,0 @@
ownerclass = 'HSFairwareAboutBox'
ownerimport = 'HSFairwareAboutBox.h'
result = Window(259, 217, "")
result.canResize = False
result.canMinimize = False
image = ImageView(result, "NSApplicationIcon")
titleLabel = Label(result, NLSTR("AppTitle"))
versionLabel = Label(result, NLSTR("AppVersion"))
copyrightLabel = Label(result, NLSTR("AppCopyright"))
registeredLabel = Label(result, "This app is registered, thanks!")
registerButton = Button(result, "Register")
owner.window = result
owner.titleTextField = titleLabel
owner.versionTextField = versionLabel
owner.copyrightTextField = copyrightLabel
owner.registeredTextField = registeredLabel
owner.registerButton = registerButton
for label in (titleLabel, versionLabel, copyrightLabel, registeredLabel):
label.alignment = const.NSCenterTextAlignment
titleLabel.font = Font(FontFamily.Label, FontSize.RegularControl, traits=[FontTrait.Bold])
for label in (versionLabel, copyrightLabel, registeredLabel):
label.font = Font(FontFamily.Label, FontSize.SmallControl)
label.height = 14
registerButton.bezelStyle = const.NSRoundRectBezelStyle
registerButton.action = Action(owner, 'showRegisterDialog')
image.height = 96
image.packToCorner(Pack.UpperLeft)
image.y = result.height - 10 - image.height
image.fill(Pack.Right)
image.setAnchor(Pack.UpperLeft, growX=True)
titleLabel.packRelativeTo(image, Pack.Below, Pack.Left)
titleLabel.fill(Pack.Right)
titleLabel.setAnchor(Pack.UpperLeft, growX=True)
versionLabel.packRelativeTo(titleLabel, Pack.Below, Pack.Left)
versionLabel.fill(Pack.Right)
versionLabel.setAnchor(Pack.UpperLeft, growX=True)
copyrightLabel.packRelativeTo(versionLabel, Pack.Below, Pack.Left)
copyrightLabel.fill(Pack.Right)
copyrightLabel.setAnchor(Pack.UpperLeft, growX=True)
registeredLabel.packRelativeTo(copyrightLabel, Pack.Below, Pack.Left)
registeredLabel.fill(Pack.Right)
registeredLabel.setAnchor(Pack.UpperLeft, growX=True)
registerButton.packRelativeTo(copyrightLabel, Pack.Below, Pack.Middle)