Skip to content

Commit

Permalink
Switching some more auxiliary files to ARC. Minor code updates and cl…
Browse files Browse the repository at this point in the history
…eanup. Removal of some dead code.
  • Loading branch information
VladimirTechMan committed May 23, 2014
1 parent 2a0ea0e commit 64f6845
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 261 deletions.
12 changes: 3 additions & 9 deletions ControlPlane.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
7CA6847717947E2200563601 /* LaptopLidEvidenceSource.m in Sources */ = {isa = PBXBuildFile; fileRef = 7CA6847617947E2200563601 /* LaptopLidEvidenceSource.m */; settings = {COMPILER_FLAGS = "-fobjc-arc"; }; };
7CFF034917246B770098990F /* SearchDomainRule.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7CFF034B17246B770098990F /* SearchDomainRule.xib */; };
7CFF035A172471DD0098990F /* ServerAddressRule.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7CFF035C172471DD0098990F /* ServerAddressRule.xib */; };
8D01634F0C029913004AD8DB /* DNDArrayController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D01634D0C029913004AD8DB /* DNDArrayController.m */; };
8D11072D0486CEB800E47090 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; };
8D11072D0486CEB800E47090 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; settings = {ATTRIBUTES = (); COMPILER_FLAGS = "-fobjc-arc"; }; };
8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; };
8D1493F70C824B6D00D29FE8 /* BonjourEvidenceSource.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D1493F50C824B6D00D29FE8 /* BonjourEvidenceSource.m */; settings = {COMPILER_FLAGS = "-fobjc-arc"; }; };
8D185DC60BF428CF00A06B03 /* AdvancedPrefs.png in Resources */ = {isa = PBXBuildFile; fileRef = 8D185DC50BF428CF00A06B03 /* AdvancedPrefs.png */; };
Expand Down Expand Up @@ -68,7 +67,7 @@
8D90E51F0B71C4C9007D39FD /* CPController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D90E51E0B71C4C9007D39FD /* CPController.m */; };
8D91F17D0C47148200D9FC0F /* USBEvidenceSource.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D35A34D0BBBA0CB006ACBB0 /* USBEvidenceSource.m */; };
8D9AE3790BE0D11800D4D4E4 /* plus-arrow.png in Resources */ = {isa = PBXBuildFile; fileRef = 8D9AE3780BE0D11800D4D4E4 /* plus-arrow.png */; };
8D9AE3A60BE0DA7E00D4D4E4 /* PopButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D9AE3A40BE0DA7E00D4D4E4 /* PopButton.m */; };
8D9AE3A60BE0DA7E00D4D4E4 /* PopButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D9AE3A40BE0DA7E00D4D4E4 /* PopButton.m */; settings = {COMPILER_FLAGS = "-fobjc-arc"; }; };
8DA2F4150CE8630200F92D4D /* DesktopBackgroundAction.m in Sources */ = {isa = PBXBuildFile; fileRef = 8DA2F4130CE8630200F92D4D /* DesktopBackgroundAction.m */; };
8DB1EF240C6C60A300586F84 /* MailIMAPServerAction.m in Sources */ = {isa = PBXBuildFile; fileRef = 8DB1EF220C6C60A300586F84 /* MailIMAPServerAction.m */; };
8DB8917C0BB89BD8005347C2 /* oui.txt in Resources */ = {isa = PBXBuildFile; fileRef = 8DB8917B0BB89BD8005347C2 /* oui.txt */; };
Expand Down Expand Up @@ -106,7 +105,7 @@
DA312CA3156DD42E009C1389 /* BWQuincyUI.m in Sources */ = {isa = PBXBuildFile; fileRef = DA312CA2156DD42E009C1389 /* BWQuincyUI.m */; };
DA41954D151C17F000FF7BA0 /* ActionSubmenuItem.m in Sources */ = {isa = PBXBuildFile; fileRef = DA41954C151C17F000FF7BA0 /* ActionSubmenuItem.m */; };
DA4411A514EE03C9005E7B3B /* MapKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA4411A414EE03C9005E7B3B /* MapKit.framework */; };
DA461C0C14C33E3C0019594A /* NSString+ShellScriptHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = DA461C0B14C33E3B0019594A /* NSString+ShellScriptHelper.m */; };
DA461C0C14C33E3C0019594A /* NSString+ShellScriptHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = DA461C0B14C33E3B0019594A /* NSString+ShellScriptHelper.m */; settings = {COMPILER_FLAGS = "-fobjc-arc"; }; };
DA49AF6C14C3E0AB00D03D6A /* TogglePrinterSharingAction.m in Sources */ = {isa = PBXBuildFile; fileRef = DA49AF6B14C3E0AB00D03D6A /* TogglePrinterSharingAction.m */; };
DA4A629313E2546800CE976F /* ControlPlane Help in Resources */ = {isa = PBXBuildFile; fileRef = DA4A629213E2546800CE976F /* ControlPlane Help */; };
DA4A629513E25C9D00CE976F /* Credits.html in Resources */ = {isa = PBXBuildFile; fileRef = DA4A629413E25C9D00CE976F /* Credits.html */; };
Expand Down Expand Up @@ -365,8 +364,6 @@
7CFF0360172472980098990F /* pt-PT */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = "pt-PT"; path = "pt-PT.lproj/ServerAddressRule.xib"; sourceTree = "<group>"; };
7CFF0361172472990098990F /* pt-BR */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = "pt-BR"; path = "pt-BR.lproj/ServerAddressRule.xib"; sourceTree = "<group>"; };
7CFF03621724729A0098990F /* it */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = it; path = it.lproj/ServerAddressRule.xib; sourceTree = "<group>"; };
8D01634C0C029913004AD8DB /* DNDArrayController.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = DNDArrayController.h; path = Source/DNDArrayController.h; sourceTree = "<group>"; };
8D01634D0C029913004AD8DB /* DNDArrayController.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = DNDArrayController.m; path = Source/DNDArrayController.m; sourceTree = "<group>"; };
8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
8D1493F40C824B6D00D29FE8 /* BonjourEvidenceSource.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; fileEncoding = 30; name = BonjourEvidenceSource.h; path = Source/BonjourEvidenceSource.h; sourceTree = "<group>"; };
8D1493F50C824B6D00D29FE8 /* BonjourEvidenceSource.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = BonjourEvidenceSource.m; path = Source/BonjourEvidenceSource.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -921,8 +918,6 @@
children = (
8D447DF60C3E65CF00DAB17A /* ContextSelectionButton.h */,
8D447DF70C3E65CF00DAB17A /* ContextSelectionButton.m */,
8D01634C0C029913004AD8DB /* DNDArrayController.h */,
8D01634D0C029913004AD8DB /* DNDArrayController.m */,
8D9AE3A30BE0DA7E00D4D4E4 /* PopButton.h */,
8D9AE3A40BE0DA7E00D4D4E4 /* PopButton.m */,
8D38B6690C49D50200290F47 /* SliderWithValue.h */,
Expand Down Expand Up @@ -1497,7 +1492,6 @@
8D9AE3A60BE0DA7E00D4D4E4 /* PopButton.m in Sources */,
8D75A6200BE6F68B0069DF3F /* ToggleBluetoothAction.m in Sources */,
8D649BA50BE8033A00716059 /* ToggleWiFiAction.m in Sources */,
8D01634F0C029913004AD8DB /* DNDArrayController.m in Sources */,
8DC4E7FD0C178917007E7E41 /* MuteAction.m in Sources */,
8DC4E8000C17891D007E7E41 /* MailSMTPServerAction.m in Sources */,
DA07C11018FE04A3008FE8B5 /* ContextEvidenceSource.m in Sources */,
Expand Down
4 changes: 1 addition & 3 deletions Source/ContextSelectionButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
#import "ContextsDataSource.h"


@interface ContextSelectionButton : NSPopUpButton {
ContextsDataSource *contextsDataSource;
}
@interface ContextSelectionButton : NSPopUpButton

- (void)setContextsDataSource:(ContextsDataSource *)dataSource;

Expand Down
22 changes: 4 additions & 18 deletions Source/ContextSelectionButton.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,8 @@

#import "ContextSelectionButton.h"


@interface ContextSelectionButton (Private)

- (void)selectionChanged:(NSNotification *)notification;

@end

@implementation ContextSelectionButton

- (id)init
{
if (!(self = [super init]))
return nil;

contextsDataSource = nil;

return self;
@implementation ContextSelectionButton {
ContextsDataSource *contextsDataSource;
}

- (void)setSelectedObject:(id)arg
Expand Down Expand Up @@ -55,8 +40,9 @@ - (void)contextsChanged:(NSNotification *)notification
object:[self menu]];
}
[self setMenu:[contextsDataSource hierarchicalMenu]];
if (lastUUID)
if (lastUUID != nil) {
[self selectItemAtIndex:[self indexOfItemWithRepresentedObject:lastUUID]];
}
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(selectionChanged:)
name:NSMenuDidSendActionNotification
Expand Down
25 changes: 0 additions & 25 deletions Source/DNDArrayController.h

This file was deleted.

141 changes: 0 additions & 141 deletions Source/DNDArrayController.m

This file was deleted.

34 changes: 19 additions & 15 deletions Source/NSString+ShellScriptHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

@implementation NSString (ShellScriptHelper)

- (NSMutableArray *) interpreterFromFile {
- (NSMutableArray *) interpreterFromFile
{
NSError *readFileError;

// get lines
Expand All @@ -21,18 +22,18 @@ - (NSMutableArray *) interpreterFromFile {
NSArray *fileLines = [fileContents componentsSeparatedByString:@"\n"];

// get the shebang line
if (fileLines.count == 0)
if (fileLines.count == 0) {
return nil;
}

NSString *firstLine = [fileLines objectAtIndex: 0];
firstLine = [firstLine stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSString *firstLine = fileLines[0];
firstLine = [firstLine stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];

// check first line while handling a special case where the first line is :
if ([firstLine rangeOfString: @"#!"].location == NSNotFound && ![firstLine isEqualToString:@":"])
if ([firstLine rangeOfString: @"#!"].location == NSNotFound && ![firstLine isEqualToString:@":"]) {
return nil;
}



NSMutableArray *args = nil;

// TRIVIA, first check if the file starts with a colon. Apparently
Expand All @@ -42,31 +43,34 @@ - (NSMutableArray *) interpreterFromFile {
}
else {
// split shebang and it's parameters
args = [[[firstLine componentsSeparatedByString: @" "] mutableCopy] autorelease];
args = [[firstLine componentsSeparatedByString:@" "] mutableCopy];
[args removeObject: @""];
}


// remove shebang characterss #!
if ([[args objectAtIndex: 0] length] > 2)
[args replaceObjectAtIndex: 0
withObject: [[args objectAtIndex: 0] substringFromIndex: 2]];
if ([args[0] length] > 2) {
[args replaceObjectAtIndex:0 withObject:[args[0] substringFromIndex:2]];
}
// or there might have been a space between #! and the interpreter
// so the first item in args is just '#!'
else
[args removeObjectAtIndex: 0];
else {
[args removeObjectAtIndex:0];
}

return args;

}

- (NSString *) interpreterFromExtension {
- (NSString *) interpreterFromExtension
{
NSString *app, *extension;
NSString *result = @"/bin/bash";

// Get the file type of the script
if (![NSWorkspace.sharedWorkspace getInfoForFile: self application: &app type: &extension])
if (![NSWorkspace.sharedWorkspace getInfoForFile: self application: &app type: &extension]) {
return result;
}
extension = extension.lowercaseString;

// check type
Expand Down
10 changes: 4 additions & 6 deletions Source/PopButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@
//
// Created by David Symonds on 26/04/07.
//
// Modified by VladimirTechMan (Vladimir Beloborodov) on 22 May 2014.
//

@interface PopButton : NSButton

@interface PopButton : NSButton {
NSMenu *menu;
}

- (NSMenu *)menu;
- (void)setMenu:(NSMenu *)theMenu;
@property (nonatomic,strong) NSMenu *menu;

@end
Loading

0 comments on commit 64f6845

Please sign in to comment.