| 681 | | - (void)checkForScreenSaver:(id)object |
|---|
| 682 | | { |
|---|
| 683 | | NSAutoreleasePool *pool; |
|---|
| 684 | | NSTask *task; |
|---|
| 685 | | NSPipe *thePipe; |
|---|
| 686 | | NSString *theOutput; |
|---|
| 687 | | int interval; |
|---|
| 688 | | |
|---|
| 689 | | while(1) |
|---|
| 690 | | { |
|---|
| 691 | | pool = [[NSAutoreleasePool alloc] init]; |
|---|
| 692 | | |
|---|
| 693 | | if(([[NSUserDefaults standardUserDefaults] integerForKey:OnScreensaverString] > 1) |
|---|
| 694 | | && ([[NSFileManager defaultManager] isExecutableFileAtPath:@"/bin/ps"])) |
|---|
| 695 | | { |
|---|
| 696 | | task = [[[NSTask alloc] init] autorelease]; |
|---|
| 697 | | thePipe = [[[NSPipe alloc] init] autorelease]; |
|---|
| 698 | | |
|---|
| 699 | | [task setLaunchPath:@"/bin/ps"]; |
|---|
| 700 | | [task setArguments:[NSArray arrayWithObject:@"wxo command"]]; |
|---|
| 701 | | [task setStandardOutput:thePipe]; |
|---|
| 702 | | |
|---|
| 703 | | [task launch]; |
|---|
| 704 | | [task waitUntilExit]; |
|---|
| 705 | | |
|---|
| 706 | | /* Put the data from thePipe to theOutput. */ |
|---|
| 707 | | theOutput = [[[NSString alloc] initWithData:[[thePipe fileHandleForReading] readDataToEndOfFile] encoding:NSASCIIStringEncoding] autorelease]; |
|---|
| 708 | | |
|---|
| 709 | | if ([theOutput rangeOfString:@"ScreenSaverEngine.app"].location != NSNotFound) |
|---|
| 710 | | { |
|---|
| 711 | | if((([[NSUserDefaults standardUserDefaults] integerForKey:OnScreensaverString] == 2) |
|---|
| 712 | | || ([[NSUserDefaults standardUserDefaults] integerForKey:OnScreensaverString] == 4)) |
|---|
| 713 | | && ([[agent keysOnAgent] count] > 0)) |
|---|
| 714 | | { |
|---|
| 715 | | [object removeKeysFromAgent:nil]; |
|---|
| 716 | | } |
|---|
| 717 | | |
|---|
| 718 | | if(([[NSUserDefaults standardUserDefaults] integerForKey:OnScreensaverString] == 3) |
|---|
| 719 | | || ([[NSUserDefaults standardUserDefaults] integerForKey:OnScreensaverString] == 4)) |
|---|
| 720 | | { |
|---|
| 721 | | SecKeychainLockAll(); |
|---|
| 722 | | } |
|---|
| 723 | | |
|---|
| 724 | | } |
|---|
| 725 | | } |
|---|
| 726 | | |
|---|
| 727 | | interval = [[NSUserDefaults standardUserDefaults] integerForKey:CheckScreensaverIntervalString]; |
|---|
| 728 | | |
|---|
| 729 | | if(interval < 5) |
|---|
| 730 | | { |
|---|
| 731 | | interval = 5; |
|---|
| 732 | | } |
|---|
| 733 | | |
|---|
| 734 | | if(interval > 100) |
|---|
| 735 | | { |
|---|
| 736 | | interval = 100; |
|---|
| 737 | | } |
|---|
| 738 | | |
|---|
| 739 | | sleep(interval); |
|---|
| 740 | | [pool release]; |
|---|
| 741 | | } |
|---|
| | 681 | - (void)onScreenSaver:(NSNotification *)notification |
|---|
| | 682 | { |
|---|
| | 683 | if((([[NSUserDefaults standardUserDefaults] integerForKey:OnScreensaverString] == 2) |
|---|
| | 684 | || ([[NSUserDefaults standardUserDefaults] integerForKey:OnScreensaverString] == 4)) |
|---|
| | 685 | && ([[agent keysOnAgent] count] > 0)) |
|---|
| | 686 | { |
|---|
| | 687 | [self removeKeysFromAgent:nil]; |
|---|
| | 688 | } |
|---|
| | 689 | |
|---|
| | 690 | if(([[NSUserDefaults standardUserDefaults] integerForKey:OnScreensaverString] == 3) |
|---|
| | 691 | || ([[NSUserDefaults standardUserDefaults] integerForKey:OnScreensaverString] == 4)) |
|---|
| | 692 | { |
|---|
| | 693 | SecKeychainLockAll(); |
|---|
| | 694 | } |
|---|
| | 695 | |
|---|