Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions LaunchAtLoginController.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ @implementation LaunchAtLoginController

void sharedFileListDidChange(LSSharedFileListRef inList, void *context)
{
LaunchAtLoginController *self = (id) context;
LaunchAtLoginController *self = (__bridge id) context;
[self willChangeValueForKey:StartAtLoginKey];
[self didChangeValueForKey:StartAtLoginKey];
}
Expand All @@ -46,19 +46,18 @@ void sharedFileListDidChange(LSSharedFileListRef inList, void *context)

- (id) init
{
[super init];
self = [super init];
loginItems = LSSharedFileListCreate(NULL, kLSSharedFileListSessionLoginItems, NULL);
LSSharedFileListAddObserver(loginItems, CFRunLoopGetMain(),
(CFStringRef)NSDefaultRunLoopMode, sharedFileListDidChange, self);
(CFStringRef)NSDefaultRunLoopMode, sharedFileListDidChange, (voidPtr)CFBridgingRetain(self));
return self;
}

- (void) dealloc
{
LSSharedFileListRemoveObserver(loginItems, CFRunLoopGetMain(),
(CFStringRef)NSDefaultRunLoopMode, sharedFileListDidChange, self);
(CFStringRef)NSDefaultRunLoopMode, sharedFileListDidChange, (__bridge void *)(self));
CFRelease(loginItems);
[super dealloc];
}

#pragma mark Launch List Control
Expand All @@ -68,13 +67,14 @@ - (LSSharedFileListItemRef) findItemWithURL: (NSURL*) wantedURL inFileList: (LSS
if (wantedURL == NULL || fileList == NULL)
return NULL;

NSArray *listSnapshot = [NSMakeCollectable(LSSharedFileListCopySnapshot(fileList, NULL)) autorelease];
NSArray *listSnapshot = (__bridge NSArray *)(LSSharedFileListCopySnapshot(fileList, NULL));
for (id itemObject in listSnapshot) {
LSSharedFileListItemRef item = (LSSharedFileListItemRef) itemObject;
LSSharedFileListItemRef item = (__bridge LSSharedFileListItemRef) itemObject;
UInt32 resolutionFlags = kLSSharedFileListNoUserInteraction | kLSSharedFileListDoNotMountVolumes;
CFURLRef currentItemURL = NULL;
LSSharedFileListItemResolve(item, resolutionFlags, &currentItemURL, NULL);
if (currentItemURL && CFEqual(currentItemURL, wantedURL)) {
if (currentItemURL && CFEqual(currentItemURL, (__bridge CFTypeRef)(wantedURL)))
{
CFRelease(currentItemURL);
return item;
}
Expand All @@ -95,7 +95,7 @@ - (void) setLaunchAtLogin: (BOOL) enabled forURL: (NSURL*) itemURL
LSSharedFileListItemRef appItem = [self findItemWithURL:itemURL inFileList:loginItems];
if (enabled && !appItem) {
LSSharedFileListInsertItemURL(loginItems, kLSSharedFileListItemBeforeFirst,
NULL, NULL, (CFURLRef)itemURL, NULL, NULL);
NULL, NULL, (__bridge CFURLRef)itemURL, NULL, NULL);
} else if (!enabled && appItem)
LSSharedFileListItemRemove(loginItems, appItem);
}
Expand Down