Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
AppList: Used LSCopyDisplayNameForURL
  • Loading branch information
authored and committed Apr 14, 2010
1 parent 54cbc49 commit 62c1831
Show file tree
Hide file tree
Showing 10 changed files with 163 additions and 20 deletions.
4 changes: 3 additions & 1 deletion AppList/AppListAppDelegate.m
Expand Up @@ -21,6 +21,7 @@ - (id) init
if (self != nil) {
self.appList = [NSMutableArray array];

/*
// TEST
ApplicationEntry* entry;
Expand All @@ -35,6 +36,7 @@ - (id) init
entry = [[[ApplicationEntry alloc] init] autorelease];
entry.name = @"APPLICATION-3";
[self.appList addObject:entry];
*/
}
return self;
}
Expand Down Expand Up @@ -92,7 +94,7 @@ - (BOOL)tableView:(NSTableView *)aTableView acceptDrop:(id <NSDraggingInfo>)info
for (NSString* filename in filenames) {
ApplicationEntry* entry = [[[ApplicationEntry alloc] init] autorelease];
entry.path = filename;
entry.name = [filename lastPathComponent];
// entry.name = [filename lastPathComponent];
[arrayController_ insertObject:entry atArrangedObjectIndex:row];
}

Expand Down
13 changes: 13 additions & 0 deletions AppList/ApplicationEntry.m
Expand Up @@ -13,4 +13,17 @@ @implementation ApplicationEntry

@synthesize name, path, icon;

-(void)setPath:(NSString *)aPath
{
[aPath retain];
[path release];
path = aPath;

LSCopyDisplayNameForURL((CFURLRef)[NSURL fileURLWithPath:path], (CFStringRef *)&name);

if (!name) {
name = @"(not found)";
}
}

@end
23 changes: 17 additions & 6 deletions AppList/English.lproj/MainMenu.xib
Expand Up @@ -12,7 +12,6 @@
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="536"/>
<integer value="29"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
Expand Down Expand Up @@ -1315,6 +1314,9 @@
</object>
<string key="NSName">_NSMainMenu</string>
</object>
<object class="NSCustomObject" id="755631768">
<string key="NSClassName">NSFontManager</string>
</object>
<object class="NSWindowTemplate" id="972006081">
<int key="NSWindowStyleMask">15</int>
<int key="NSWindowBacking">2</int>
Expand Down Expand Up @@ -1344,19 +1346,22 @@
<int key="NSvFlags">256</int>
<string key="NSFrameSize">{367, 190}</string>
<reference key="NSSuperview" ref="70107259"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTableHeaderView" key="NSHeaderView" id="84217362">
<reference key="NSNextResponder" ref="940491372"/>
<int key="NSvFlags">256</int>
<string key="NSFrameSize">{367, 17}</string>
<reference key="NSSuperview" ref="940491372"/>
<reference key="NSWindow"/>
<reference key="NSTableView" ref="118153432"/>
</object>
<object class="_NSCornerView" key="NSCornerView" id="1023461112">
<reference key="NSNextResponder" ref="738471903"/>
<int key="NSvFlags">-2147483392</int>
<string key="NSFrame">{{224, 0}, {16, 17}}</string>
<reference key="NSSuperview" ref="738471903"/>
<reference key="NSWindow"/>
</object>
<object class="NSMutableArray" key="NSTableColumns">
<bool key="EncodedWithXMLCoder">YES</bool>
Expand Down Expand Up @@ -1446,6 +1451,7 @@
</object>
<string key="NSFrame">{{1, 17}, {367, 190}}</string>
<reference key="NSSuperview" ref="738471903"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="118153432"/>
<reference key="NSDocView" ref="118153432"/>
<reference key="NSBGColor" ref="208638811"/>
Expand All @@ -1456,6 +1462,7 @@
<int key="NSvFlags">-2147483392</int>
<string key="NSFrame">{{224, 17}, {15, 102}}</string>
<reference key="NSSuperview" ref="738471903"/>
<reference key="NSWindow"/>
<reference key="NSTarget" ref="738471903"/>
<string key="NSAction">_doScroller:</string>
<double key="NSPercent">0.99476438760757446</double>
Expand All @@ -1465,6 +1472,7 @@
<int key="NSvFlags">-2147483392</int>
<string key="NSFrame">{{-100, -100}, {367, 15}}</string>
<reference key="NSSuperview" ref="738471903"/>
<reference key="NSWindow"/>
<int key="NSsFlags">1</int>
<reference key="NSTarget" ref="738471903"/>
<string key="NSAction">_doScroller:</string>
Expand All @@ -1479,6 +1487,7 @@
</object>
<string key="NSFrame">{{1, 0}, {367, 17}}</string>
<reference key="NSSuperview" ref="738471903"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="84217362"/>
<reference key="NSDocView" ref="84217362"/>
<reference key="NSBGColor" ref="208638811"/>
Expand All @@ -1488,6 +1497,7 @@
</object>
<string key="NSFrame">{{20, 48}, {369, 208}}</string>
<reference key="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="70107259"/>
<int key="NSsFlags">530</int>
<reference key="NSVScroller" ref="994067818"/>
Expand All @@ -1502,6 +1512,7 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{17, 264}, {416, 17}}</string>
<reference key="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="664973123">
<int key="NSCellFlags">68288064</int>
Expand All @@ -1523,6 +1534,7 @@
<int key="NSvFlags">260</int>
<string key="NSFrame">{{20, 19}, {23, 22}}</string>
<reference key="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="594828877">
<int key="NSCellFlags">-2080244224</int>
Expand All @@ -1547,6 +1559,7 @@
<int key="NSvFlags">260</int>
<string key="NSFrame">{{42, 19}, {23, 22}}</string>
<reference key="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="138229259">
<int key="NSCellFlags">-2080244224</int>
Expand All @@ -1569,16 +1582,14 @@
</object>
<string key="NSFrameSize">{409, 301}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
</object>
<string key="NSScreenRect">{{0, 0}, {1920, 1178}}</string>
<string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string>
</object>
<object class="NSCustomObject" id="976324537">
<string key="NSClassName">AppListAppDelegate</string>
</object>
<object class="NSCustomObject" id="755631768">
<string key="NSClassName">NSFontManager</string>
</object>
<object class="NSArrayController" id="170240774">
<object class="NSMutableArray" key="NSDeclaredKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
Expand Down Expand Up @@ -3918,9 +3929,9 @@
<integer value="1"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
<string>{{612, 523}, {409, 301}}</string>
<string>{{345, 509}, {409, 301}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{612, 523}, {409, 301}}</string>
<string>{{345, 509}, {409, 301}}</string>
<integer value="1"/>
<string>{{33, 99}, {480, 360}}</string>
<string>{3.40282e+38, 3.40282e+38}</string>
Expand Down
2 changes: 1 addition & 1 deletion KeychainSample2/AccountManager.h
Expand Up @@ -16,5 +16,5 @@
+ (AccountManager*)sharedManager;
- (BOOL)setPasswordToLoginAccount:(LoginAccount*)loginAccount;
- (BOOL)storeLoginAccount:(LoginAccount*)loginAccount;

- (BOOL)deleteLoginAccount:(LoginAccount*)loginAccount;
@end
40 changes: 40 additions & 0 deletions KeychainSample2/AccountManager.m
Expand Up @@ -125,4 +125,44 @@ -(BOOL)setPasswordToLoginAccount:(LoginAccount*)loginAccount
}

}

- (BOOL)deleteLoginAccount:(LoginAccount*)loginAccount
{
OSStatus status;

const char *serviceNameUTF8 = [loginAccount.serviceName UTF8String];
const char *loginIdUTF8 = [loginAccount.loginId UTF8String];

SecKeychainItemRef itemRef = nil;

status = SecKeychainFindGenericPassword(NULL,
strlen(serviceNameUTF8),
serviceNameUTF8,
strlen(loginIdUTF8),
loginIdUTF8,
NULL,
NULL,
&itemRef);

if (status == errSecSuccess) {
status = SecKeychainItemDelete(itemRef);

if (status == errSecSuccess) {
return YES;
} else {
NSLog(@"ERROR:SecKeychainItemDelete");
return NO;
}

} else {
NSLog(@"ERROR:SecKeychainFindGenericPassword:%d", status);
return NO;
}

if (itemRef) {
CFRelease(itemRef);
}

}

@end
2 changes: 2 additions & 0 deletions KeychainSample2/AuthenticationWindowController.h
Expand Up @@ -33,6 +33,8 @@

-(BOOL)getLoginAccount:(LoginAccount*)loginAccount;

-(BOOL)deleteLoginAccount:(LoginAccount*)loginAccount;

-(IBAction)login:(id)sender;
-(IBAction)cancel:(id)cancel;
@end
Expand Down
5 changes: 5 additions & 0 deletions KeychainSample2/AuthenticationWindowController.m
Expand Up @@ -121,4 +121,9 @@ -(IBAction)cancel:(id)cancel
[NSApp stopModal];
}

-(BOOL)deleteLoginAccount:(LoginAccount*)loginAccount
{
return [[AccountManager sharedManager] deleteLoginAccount:loginAccount];
}

@end

0 comments on commit 62c1831

Please sign in to comment.