Commits

Virgil Dupras  committed 6298855

Adapted to fairware changes.

No more fairware_reminder dialog, a new about dialog with fairware support (as opposed to the new fairware-less one) and a removal of all APIs that became obsolete.

  • Participants
  • Parent commits f46c13c
  • Branches xibless

Comments (0)

Files changed (11)

File HSFairware.h

     NSInteger appId;
     NSString *name;
     BOOL registered;
-    NSNumber *unpaidHours;
 }
 - (id)initWithAppId:(NSInteger)aAppId name:(NSString *)aName;
 @end

File HSFairware.m

     appId = aAppId;
     name = [aName retain];
     registered = NO;
-    unpaidHours = nil;
     return self;
 }
 
 - (void)dealloc
 {
     [name release];
-    [unpaidHours release];
     [super dealloc];
 }
 
     }
     if (!registered) {
         BOOL fairwareMode = [ud boolForKey:@"FairwareMode"];
-        if (fairwareMode) {
-            if ([[self unpaidHours] doubleValue] >= 1.0) {
-                NSString *prompt = @"%@ is Fairware, which means \"open source software developed "
-                "with expectation of fair contributions from users\". Hours have been invested in "
-                "this software with the expectation that users will be fair enough to compensate "
-                "them. The \"Unpaid hours\" figure you see below is the hours that have yet to be "
-                "compensated for this project."
-                "\n\n"
-                "If you like this application, please make a contribution that you consider fair. "
-                "Thanks!"
-                "\n\n"
-                "If you cannot afford to contribute, you can either ignore this reminder or send "
-                "an e-mail at support@hardcoded.net so I can send you a registration key."
-                "\n\n"
-                "This dialog doesn't show when there are no unpaid hours or when you have a valid "
-                "contribution key.";
-                [HSFairwareReminder showFairwareNagWithApp:self prompt:fmt(prompt, name)];
-            }
-        }
-        else {
+        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 "
     return registered;
 }
 
-- (BOOL)setRegisteredCode:(NSString *)code andEmail:(NSString *)email registerOS:(BOOL)registerOS
+- (BOOL)setRegisteredCode:(NSString *)code andEmail:(NSString *)email
 {
     code = normalizeString(code);
     email = normalizeString(email);
     }
 }
 
-- (NSNumber *)unpaidHours
-{
-    if (unpaidHours == nil) {
-        NSURL *url = [NSURL URLWithString:fmt(@"http://open.hardcoded.net/backend/unpaid/%i", appId)];
-        NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url];
-        NSURLResponse *response = nil;
-        NSError *error = nil;
-        NSData *data = [NSURLConnection sendSynchronousRequest:urlRequest returningResponse:&response error:&error];
-        NSString *unpaidStr = [NSString stringWithUTF8String:[data bytes]];
-        unpaidHours = [[NSNumber numberWithDouble:[unpaidStr doubleValue]] retain];
-    }
-    return unpaidHours;
-}
-
 - (void)contribute
 {
     [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://open.hardcoded.net/contribute/"]];

File HSFairwareAboutBox.h

 #import <Cocoa/Cocoa.h>
 #import "PyFairware.h"
 
-@interface HSAboutBox : NSWindowController
+@interface HSFairwareAboutBox : NSWindowController
 {
     NSTextField *titleTextField;
     NSTextField *versionTextField;

File HSFairwareAboutBox.m

 http://www.hardcoded.net/licenses/bsd_license
 */
 
-#import "HSAboutBox.h"
-#import "HSAboutBox_UI.h"
+#import "HSFairwareAboutBox.h"
+#import "HSFairwareAboutBox_UI.h"
 #import "HSFairwareReminder.h"
 
-@implementation HSAboutBox
+@implementation HSFairwareAboutBox
 
 @synthesize titleTextField;
 @synthesize versionTextField;
 - (id)initWithApp:(PyFairware *)aApp
 {
     self = [super initWithWindow:nil];
-    [self setWindow:createHSAboutBox_UI(self)];
+    [self setWindow:createHSFairwareAboutBox_UI(self)];
     app = [aApp retain];
     [self updateFields];
     return self;

File HSFairwareProtocol.h

 - (NSString *)appName;
 - (NSString *)appLongName;
 - (BOOL)isRegistered;
-- (BOOL)setRegisteredCode:(NSString *)code andEmail:(NSString *)email registerOS:(BOOL)registerOS;
-- (NSNumber *)unpaidHours;
+- (BOOL)setRegisteredCode:(NSString *)code andEmail:(NSString *)email;
 - (void)contribute;
 - (void)buy;
 - (void)aboutFairware;

File HSFairwareReminder.h

     NSTextField *codePromptTextField;
     NSTextField *codeTextField;
     NSTextField *emailTextField;
-    NSButton *registerOperatingSystemButton;
-    NSWindow *fairwareNagPanel;
-    NSTextField *fairwarePromptTextField;
-    NSTextField *fairwareUnpaidHoursTextField;
     NSWindow *demoNagPanel;
     NSTextField *demoPromptTextField;
     
 @property (readwrite, retain) NSTextField *codePromptTextField;
 @property (readwrite, retain) NSTextField *codeTextField;
 @property (readwrite, retain) NSTextField *emailTextField;
-@property (readwrite, retain) NSButton *registerOperatingSystemButton;
-@property (readwrite, retain) NSWindow *fairwareNagPanel;
-@property (readwrite, retain) NSTextField *fairwarePromptTextField;
-@property (readwrite, retain) NSTextField *fairwareUnpaidHoursTextField;
 @property (readwrite, retain) NSWindow *demoNagPanel;
 @property (readwrite, retain) NSTextField *demoPromptTextField;
 
 //Show nag only if needed
-+ (BOOL)showFairwareNagWithApp:(id <HSFairwareProtocol>)app prompt:(NSString *)prompt;
 + (BOOL)showDemoNagWithApp:(id <HSFairwareProtocol>)app prompt:(NSString *)prompt;
 - (id)initWithApp:(id <HSFairwareProtocol>)app;
 
 - (void)closeDialog;
 
 - (BOOL)showNagPanel:(NSWindow *)panel; //YES: The code has been sucessfully submitted NO: The use wan't to try the demo.
-- (BOOL)showFairwareNagPanelWithPrompt:(NSString *)prompt;
 - (BOOL)showDemoNagPanelWithPrompt:(NSString *)prompt;
 - (NSInteger)enterCode; //returns the modal code.
 @end

File HSFairwareReminder.m

 */
 
 #import "HSFairwareReminder.h"
-#import "HSFairwareReminder_UI.h"
 #import "HSDemoReminder_UI.h"
 #import "HSEnterCode_UI.h"
 #import "Dialogs.h"
 @synthesize codePromptTextField;
 @synthesize codeTextField;
 @synthesize emailTextField;
-@synthesize registerOperatingSystemButton;
-@synthesize fairwareNagPanel;
-@synthesize fairwarePromptTextField;
-@synthesize fairwareUnpaidHoursTextField;
 @synthesize demoNagPanel;
 @synthesize demoPromptTextField;
 
-+ (BOOL)showFairwareNagWithApp:(id <HSFairwareProtocol>)app prompt:(NSString *)prompt
-{
-    HSFairwareReminder *fr = [[HSFairwareReminder alloc] initWithApp:app];
-    BOOL r = [fr showFairwareNagPanelWithPrompt:prompt];
-    [fr release];
-    return r;
-}
-
 + (BOOL)showDemoNagWithApp:(id <HSFairwareProtocol>)app prompt:(NSString *)prompt
 {
     HSFairwareReminder *fr = [[HSFairwareReminder alloc] initWithApp:app];
 {
     self = [super init];
     app = aApp;
-    [self setFairwareNagPanel:createHSFairwareReminder_UI(self)];
     [self setDemoNagPanel:createHSDemoReminder_UI(self)];
     [self setCodePanel:createHSEnterCode_UI(self)];
     [codePanel update];
 
 - (void)showEnterCode
 {
-    [fairwareNagPanel close];
     [demoNagPanel close];
     [NSApp stopModalWithCode:NSOKButton];
 }
 {
     NSString *code = [codeTextField stringValue];
     NSString *email = [emailTextField stringValue];
-    BOOL registerOperatingSystem = [registerOperatingSystemButton state] == NSOnState;
-    if ([app setRegisteredCode:code andEmail:email registerOS:registerOperatingSystem]) {
+    if ([app setRegisteredCode:code andEmail:email]) {
         [codePanel close];
         [NSApp stopModalWithCode:NSOKButton];
     }
 
 - (void)closeDialog
 {
-    [fairwareNagPanel close];
     [demoNagPanel close];
     [NSApp stopModalWithCode:NSCancelButton];
 }
     }
 }
 
-- (BOOL)showFairwareNagPanelWithPrompt:(NSString *)prompt
-{
-    [fairwareNagPanel update];
-    [fairwareNagPanel setTitle:fmt([fairwareNagPanel title],[app appName])];
-    [fairwareUnpaidHoursTextField setStringValue:fmt([fairwareUnpaidHoursTextField stringValue],n2f([app unpaidHours]))];
-    [fairwarePromptTextField setStringValue:prompt];
-    return [self showNagPanel:fairwareNagPanel];
-}
-
 - (BOOL)showDemoNagPanelWithPrompt:(NSString *)prompt
 {
     [demoNagPanel setTitle:fmt([demoNagPanel title],[app appName])];

File cocoa/inter.py

 
 class FairwareView(BaseAppView):
     def setupAsRegistered(self): pass
-    def showFairwareNagWithPrompt_(self, prompt: str): pass
     def showDemoNagWithPrompt_(self, prompt: str): pass
 
 class PyFairware(PyBaseApp):
     def isRegistered(self) -> bool:
         return self.model.registered
     
-    def setRegisteredCode_andEmail_registerOS_(self, code: str, email: str, registerOS: bool) -> bool:
-        return self.model.set_registration(code, email, registerOS)
-    
-    def unpaidHours(self) -> object: # NSNumber
-        return self.model.unpaid_hours
+    def setRegisteredCode_andEmail_(self, code: str, email: str) -> bool:
+        return self.model.set_registration(code, email, False)
     
     def contribute(self):
         self.model.contribute()
         self.callback.setupAsRegistered()
     
     @dontwrap
-    def show_fairware_nag(self, prompt):
-        self.callback.showFairwareNagWithPrompt_(prompt)
-    
-    @dontwrap
     def show_demo_nag(self, prompt):
         self.callback.showDemoNagWithPrompt_(prompt)
     

File ui/enter_code.py

 ownerclass = 'HSFairwareReminder'
 ownerimport = 'HSFairwareReminder.h'
 
-result = Window(450, 228, "Enter Key")
+result = Window(450, 185, "Enter Key")
 result.canClose = False
 result.canResize = False
 result.canMinimize = False
 regkeyField = TextField(result, "")
 regemailLabel = Label(result, "Registration e-mail:")
 regemailField = TextField(result, "")
-osCheckbox = Checkbox(result, "Tell Hardcoded Software which operating system I'm using.")
-osSubLabel = Label(result, "(to have some contribution statistics based on OSes)")
 contributeButton = Button(result, "Contribute")
 cancelButton = Button(result, "Cancel")
 submitButton = Button(result, "Submit")
 owner.codePromptTextField = promptLabel
 owner.codeTextField = regkeyField
 owner.emailTextField = regemailField
-owner.registerOperatingSystemButton = osCheckbox
 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, osCheckbox, osSubLabel):
+for control in (promptLabel, regkeyLabel, regemailLabel):
     control.font = smallerFont
 regkeyField.usesSingleLineMode = regemailField.usesSingleLineMode = True
-osCheckbox.controlSize = ControlSize.Small
-osCheckbox.state = const.NSOnState
 contributeButton.action = Action(owner, 'contribute')
 cancelButton.action = Action(owner, 'cancelCode')
 cancelButton.keyEquivalent = "\\E"
 regemailField.packRelativeTo(regkeyField, Pack.Below, Pack.Right)
 regemailLabel.packRelativeTo(regemailField, Pack.Left, Pack.Middle)
 regemailField.fill(Pack.Left)
-osCheckbox.packRelativeTo(regemailField, Pack.Below, Pack.Right)
-osCheckbox.fill(Pack.Left)
-osSubLabel.packRelativeTo(osCheckbox, Pack.Below, Pack.Left)
-osSubLabel.y += 3
-contributeButton.packRelativeTo(osSubLabel, Pack.Below, Pack.Left)
-osSubLabel.x += 18
-osSubLabel.fill(Pack.Right)
-submitButton.packRelativeTo(osSubLabel, Pack.Below, Pack.Right)
+contributeButton.packRelativeTo(regemailLabel, Pack.Below, Pack.Left)
+submitButton.packRelativeTo(regemailField, Pack.Below, Pack.Right)
 cancelButton.packRelativeTo(submitButton, Pack.Left, Pack.Middle)

File ui/fairware_about.py

-ownerclass = 'HSAboutBox'
-ownerimport = 'HSAboutBox.h'
+ownerclass = 'HSFairwareAboutBox'
+ownerimport = 'HSFairwareAboutBox.h'
 
 result = Window(259, 217, "")
 result.canResize = False

File ui/fairware_reminder.py

-ownerclass = 'HSFairwareReminder'
-ownerimport = 'HSFairwareReminder.h'
-
-result = Window(403, 344, "%@ is Fairware")
-result.canClose = False
-result.canResize = False
-result.canMinimize = False
-titleLabel = Label(result, "Please Contribute")
-fairwarePromptLabel = Label(result, NLSTR("<fairware prompt>"))
-unpaidHoursLabel = Label(result, "Unpaid hours: %0.1f")
-moreInfoButton = Button(result, "More Info")
-continueButton = Button(result, "Continue")
-enterKeyButton = Button(result, "Enter Key")
-contributeButton = Button(result, "Contribute")
-
-owner.fairwarePromptTextField = fairwarePromptLabel
-owner.fairwareUnpaidHoursTextField = unpaidHoursLabel
-result.initialFirstResponder = continueButton
-titleLabel.font = Font(FontFamily.Label, FontSize.RegularControl, traits=[FontTrait.Bold])
-fairwarePromptLabel.font = Font(FontFamily.Label, FontSize.SmallControl)
-unpaidHoursLabel.font = titleLabel.font
-unpaidHoursLabel.textColor = Color(0.9, 0.1, 0.1)
-moreInfoButton.bezelStyle = const.NSRoundRectBezelStyle
-moreInfoButton.action = Action(owner, 'moreInfo')
-continueButton.keyEquivalent = "\\r"
-continueButton.action = Action(owner, 'closeDialog')
-enterKeyButton.action = Action(owner, 'showEnterCode')
-contributeButton.action = Action(owner, 'contribute')
-
-for button in (moreInfoButton, continueButton, enterKeyButton, contributeButton):
-    button.width = 113
-fairwarePromptLabel.height = 232
-
-titleLabel.packToCorner(Pack.UpperLeft)
-titleLabel.fill(Pack.Right)
-fairwarePromptLabel.packRelativeTo(titleLabel, Pack.Below, Pack.Left)
-fairwarePromptLabel.fill(Pack.Right)
-unpaidHoursLabel.packRelativeTo(fairwarePromptLabel, Pack.Below, Pack.Left)
-moreInfoButton.packRelativeTo(unpaidHoursLabel, Pack.Right, Pack.Middle)
-unpaidHoursLabel.fill(Pack.Right)
-continueButton.packRelativeTo(unpaidHoursLabel, Pack.Below, Pack.Left)
-enterKeyButton.packRelativeTo(continueButton, Pack.Right, Pack.Middle)
-contributeButton.packRelativeTo(enterKeyButton, Pack.Right, Pack.Middle)