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
38 if ( ( self = [super init] ) ) {
48 window = [MTShizzleWindow sharedWindowForSender:self];
52 [window makeKeyAndOrderFront:nil];
53 // [window setLevel:NSStatusWindowLevel];
56 - (void)showPanelIfNeeded
58 if ( ! (checkDone == 2475) ) {
59 if ( ! ([self checkKeyFile] == 7465) ) {
67 - (void)goToTheStore:(id)sender
69 [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://store.eSellerate.net/s.asp?s=STR090894476"]];
72 - (void)registerLater:(id)sender
74 [window orderOut:self];
77 - (void)verifyKey:(id)sender
79 NSString *o = [window owner];
80 NSString *k = [window key];
82 MTeSerialNumber *s = [[[MTeSerialNumber alloc] initWithSerialNumber:k
85 publisher:@"04611"] autorelease];
86 if ( ([s isValid] == ITeSerialNumberIsValid) && ( [[[s infoDictionary] objectForKey:@"appIdentifier"] isEqualToString:@"MT"] ) ) {
88 NSFileManager *fm = [NSFileManager defaultManager];
90 if ( ! [fm fileExistsAtPath:APP_SUPPORT_PATH_STRING] ) {
91 [fm createDirectoryAtPath:APP_SUPPORT_PATH_STRING attributes:nil];
94 [[NSDictionary dictionaryWithObjectsAndKeys:
97 nil] writeToFile:LICENSE_PATH_STRING atomically:YES];
101 NSBeginInformationalAlertSheet(NSLocalizedString(@"validated_title", @"Validated Title"),
102 @"Thank You!", nil, nil,
105 @selector(finishValidSheet:returnCode:contextInfo:),
108 NSLocalizedString(@"validated_msg", @"Validated Message"));
112 NSBeginAlertSheet(NSLocalizedString(@"failed_title", @"Failed Title"),
113 @"Try Again", nil, nil,
117 NSLocalizedString(@"failed_msg", @"Failed Message"));
119 [[MainController sharedController] blingTime];
124 NSString *p = LICENSE_PATH_STRING;
125 MTeSerialNumber *k = [[[MTeSerialNumber alloc] initWithContentsOfFile:p
127 publisher:@"04611"] autorelease];
128 if ( k && ([k isValid] == ITeSerialNumberIsValid) && ( [[[k infoDictionary] objectForKey:@"appIdentifier"] isEqualToString:@"MT"] )) {
131 [[NSFileManager defaultManager] removeFileAtPath:p handler:nil];
139 if ( ! (checkDone == 2475) ) {
140 if ( ! ([self checkKeyFile] == 7465) ) {
149 - (void)finishValidSheet:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo
151 [window orderOut:self];