5 // Created by Matthew L. Judy on Tue Aug 19 2003.
6 // Copyright (c) 2003 iThink Software. All rights reserved.
9 #import "MTBlingController.h"
10 #import "MTeSerialNumber.h"
11 #import "MainController.h"
13 #define APP_SUPPORT_PATH_STRING [@"~/Library/Application Support/MenuTunes/" stringByExpandingTildeInPath]
14 #define LICENSE_PATH_STRING [APP_SUPPORT_PATH_STRING stringByAppendingString:@"/.license"]
17 @interface MTBlingController (Private)
22 @implementation MTBlingController
37 - (void)_FIVERSKATES {}
41 if ( ( self = [super init] ) ) {
51 window = [MTShizzleWindow sharedWindowForSender:self];
53 [NSApp activateIgnoringOtherApps:YES];
55 [window orderFrontRegardless];
56 [window makeKeyWindow];
57 // [window setLevel:NSStatusWindowLevel];
60 - (void)showPanelIfNeeded
62 if ( ! (checkDone == 2475) ) {
63 if ( ! ([self checkKeyFile] == 7465) ) {
71 - (void)goToTheStore:(id)sender
73 [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://store.eSellerate.net/s.asp?s=STR090894476"]];
76 - (void)registerLater:(id)sender
78 [window orderOut:self];
79 if ([[NSDate date] timeIntervalSinceDate:[[MainController sharedController] getBlingTime]] >= 604800) {
80 [NSApp terminate:nil];
84 - (void)verifyKey:(id)sender
86 NSString *o = [window owner];
87 NSString *k = [window key];
89 MTeSerialNumber *s = [[[MTeSerialNumber alloc] initWithSerialNumber:k
92 publisher:@"04611"] autorelease];
93 if ( ([s isValid] == ITeSerialNumberIsValid) && ( [[[s infoDictionary] objectForKey:@"appIdentifier"] isEqualToString:@"MT"] ) ) {
95 NSFileManager *fm = [NSFileManager defaultManager];
97 if ( ! [fm fileExistsAtPath:APP_SUPPORT_PATH_STRING] ) {
98 [fm createDirectoryAtPath:APP_SUPPORT_PATH_STRING attributes:nil];
101 [[NSDictionary dictionaryWithObjectsAndKeys:
104 nil] writeToFile:LICENSE_PATH_STRING atomically:YES];
108 NSBeginInformationalAlertSheet(NSLocalizedString(@"validated_title", @"Validated Title"),
109 @"Thank You!", nil, nil,
112 @selector(finishValidSheet:returnCode:contextInfo:),
115 NSLocalizedString(@"validated_msg", @"Validated Message"));
119 NSBeginAlertSheet(NSLocalizedString(@"failed_title", @"Failed Title"),
120 @"Try Again", nil, nil,
124 NSLocalizedString(@"failed_msg", @"Failed Message"));
126 [[MainController sharedController] blingTime];
131 NSString *p = LICENSE_PATH_STRING;
132 MTeSerialNumber *k = [[[MTeSerialNumber alloc] initWithContentsOfFile:p
134 publisher:@"04611"] autorelease];
135 if ( k && ([k isValid] == ITeSerialNumberIsValid) && ( [[[k infoDictionary] objectForKey:@"appIdentifier"] isEqualToString:@"MT"] )) {
138 [[NSFileManager defaultManager] removeFileAtPath:p handler:nil];
146 if ( ! (checkDone == 2475) ) {
147 if ( ! ([self checkKeyFile] == 7465) ) {
156 - (void)finishValidSheet:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo
158 [window orderOut:self];