5 * Created by Kent Sutherland on Sun May 16 2004.
6 * Copyright (c) 2004 __MyCompanyName__. All rights reserved.
10 #import "ITLoginItem.h"
13 BOOL ITSetLaunchApplicationOnLogin(NSString *path, BOOL flag)
15 NSUserDefaults *df = [NSUserDefaults standardUserDefaults];
16 NSMutableDictionary *loginwindow;
17 NSMutableArray *loginarray;
22 ITDebugLog(@"Set if MenuPrefs launches at login to %i.", flag);
24 loginwindow = [[df persistentDomainForName:@"loginwindow"] mutableCopy];
25 loginarray = [loginwindow objectForKey:@"AutoLaunchedApplicationDictionary"];
27 //Create the alias data
28 FSMakeRefWithPath([path UTF8String], &fileRef);
29 FSNewAlias(NULL, &fileRef, &alias);
30 aliasData = [NSData dataWithBytes:&alias length:sizeof(alias)];
33 NSDictionary *itemDict = [NSDictionary dictionaryWithObjectsAndKeys:
34 [[NSBundle mainBundle] bundlePath], @"Path",
35 [NSNumber numberWithInt:0], @"Hide",
36 aliasData, @"AliasData", nil, nil];
37 [loginarray addObject:itemDict];
40 for (i = 0; i < [loginarray count]; i++) {
41 NSDictionary *tempDict = [loginarray objectAtIndex:i];
42 if ([[[tempDict objectForKey:@"Path"] lastPathComponent] isEqualToString:[[[NSBundle mainBundle] bundlePath] lastPathComponent]]) {
43 [loginarray removeObjectAtIndex:i];
48 [df setPersistentDomain:loginwindow forName:@"loginwindow"];
50 [loginwindow release];