5 * Created by Kent Sutherland on Mon May 17 2004.
6 * Copyright (c) 2004 __MyCompanyName__. All rights reserved.
10 #import "ITLoginItem.h"
13 void ITSetApplicationLaunchOnLogin(NSString *path, BOOL flag)
15 if ( (flag && ITDoesApplicationLaunchOnLogin(path)) || ![[NSFileManager defaultManager] fileExistsAtPath:path] ) {
18 NSUserDefaults *df = [NSUserDefaults standardUserDefaults];
19 NSMutableDictionary *loginwindow;
20 NSMutableArray *loginarray;
22 ITDebugLog(@"Set if \"%@\" launches at login to %i.", path, flag);
24 loginwindow = [[df persistentDomainForName:@"loginwindow"] mutableCopy];
25 loginarray = [[loginwindow objectForKey:@"AutoLaunchedApplicationDictionary"] mutableCopy];
31 FSPathMakeRef([path UTF8String], &fileRef, NULL);
32 FSNewAlias(NULL, &fileRef, &alias);
33 aliasData = [NSData dataWithBytes:&alias length:GetHandleSize((Handle)alias)];*/
35 if (!loginarray) { //If there is no loginarray of autolaunch items, create one
36 loginarray = [[[NSMutableArray alloc] init] autorelease];
38 NSDictionary *itemDict = [NSDictionary dictionaryWithObjectsAndKeys:
39 [[NSBundle mainBundle] bundlePath], @"Path",
40 [NSNumber numberWithInt:0], @"Hide",
41 [NSData data], @"AliasData", nil, nil];
42 [loginarray addObject:itemDict];
45 for (i = 0; i < [loginarray count]; i++) {
46 NSDictionary *tempDict = [loginarray objectAtIndex:i];
47 if ([[[tempDict objectForKey:@"Path"] lastPathComponent] isEqualToString:[path lastPathComponent]]) {
48 [loginarray removeObjectAtIndex:i];
53 [loginwindow setObject:loginarray forKey:@"AutoLaunchedApplicationDictionary"];
54 [df setPersistentDomain:loginwindow forName:@"loginwindow"];
56 [loginwindow release];
60 BOOL ITDoesApplicationLaunchOnLogin(NSString *path)
62 NSUserDefaults *df = [NSUserDefaults standardUserDefaults];
63 NSDictionary *loginwindow;
64 NSMutableArray *loginarray;
65 NSEnumerator *loginEnum;
67 ITDebugLog(@"Checking if \"%@\" launches at login.", path);
69 loginwindow = [df persistentDomainForName:@"loginwindow"];
70 loginarray = [loginwindow objectForKey:@"AutoLaunchedApplicationDictionary"];
72 loginEnum = [loginarray objectEnumerator];
73 while ( (anItem = [loginEnum nextObject]) ) {
74 if ( [[[anItem objectForKey:@"Path"] lastPathComponent] isEqualToString:[path lastPathComponent]] ) {