-- (void)setBlingTime:(NSDate*)date
-{
- NSMutableDictionary *globalPrefs;
- [df synchronize];
- globalPrefs = [[df persistentDomainForName:@".GlobalPreferences"] mutableCopy];
- if (date) {
- [globalPrefs setObject:date forKey:@"ITMTTrialStart"];
- [globalPrefs setObject:[NSNumber numberWithInt:MT_CURRENT_VERSION] forKey:@"ITMTTrialVers"];
- } else {
- [globalPrefs removeObjectForKey:@"ITMTTrialStart"];
- [globalPrefs removeObjectForKey:@"ITMTTrialVers"];
- }
- [df setPersistentDomain:globalPrefs forName:@".GlobalPreferences"];
- [df synchronize];
- [globalPrefs release];
-}
-
-- (NSDate*)getBlingTime
-{
- [df synchronize];
- return [[df persistentDomainForName:@".GlobalPreferences"] objectForKey:@"ITMTTrialStart"];
-}
-
-- (void)blingTime
-{
- NSDate *now = [NSDate date];
- if (![self blingBling]) {
- if ( (! [self getBlingTime] ) || ([now timeIntervalSinceDate:[self getBlingTime]] < 0) ) {
- [self setBlingTime:now];
- } else if ([[[df persistentDomainForName:@".GlobalPreferences"] objectForKey:@"ITMTTrialVers"] intValue] < MT_CURRENT_VERSION) {
- if ([now timeIntervalSinceDate:[self getBlingTime]] >= 345600) {
- [self setBlingTime:[now addTimeInterval:-259200]];
- } else {
- NSMutableDictionary *globalPrefs;
- [df synchronize];
- globalPrefs = [[df persistentDomainForName:@".GlobalPreferences"] mutableCopy];
- [globalPrefs setObject:[NSNumber numberWithInt:MT_CURRENT_VERSION] forKey:@"ITMTTrialVers"];
- [df setPersistentDomain:globalPrefs forName:@".GlobalPreferences"];
- [df synchronize];
- [globalPrefs release];
- }
- }
-
- if ( ([now timeIntervalSinceDate:[self getBlingTime]] >= 604800) && (blinged != YES) ) {
- blinged = YES;
- [statusItem setEnabled:NO];
- [[ITHotKeyCenter sharedCenter] setEnabled:NO];
- if ([refreshTimer isValid]) {
- [refreshTimer invalidate];
- [refreshTimer release];
- refreshTimer = nil;
- }
- [statusWindowController showRegistrationQueryWindow];
- }
- } else {
- if (blinged) {
- [statusItem setEnabled:YES];
- [[ITHotKeyCenter sharedCenter] setEnabled:YES];
- if (_needsPolling && ![refreshTimer isValid]) {
- [refreshTimer release];
- refreshTimer = [[NSTimer scheduledTimerWithTimeInterval:([networkController isConnectedToServer] ? 10.0 : 0.5)
- target:self
- selector:@selector(timerUpdate)
- userInfo:nil
- repeats:YES] retain];
- }
- blinged = NO;
- }
- [self setBlingTime:nil];
- }
-}
-
-- (void)blingNow
-{
- [bling showPanel];
-}
-
-- (BOOL)blingBling
-{
- if ( ! ([bling checkDone] == 2475) ) {
- return NO;
- } else {
- return YES;
- }
-}
-