Permalink
Browse files

- Added Authentication removal after use

- Modified icon image file names and types
- Removed jpg versions of icon files
  • Loading branch information...
1 parent d6fdffd commit 7ab1c2a4f30a55cc1f430898a7315bdbe38bdc5b @mmetzger committed Sep 11, 2008
Showing with 67 additions and 70 deletions.
  1. +1 −0 AppController.h
  2. +30 −12 AppController.m
  3. +28 −50 English.lproj/MainMenu.xib
  4. +8 −8 EyePatch.xcodeproj/project.pbxproj
  5. BIN eyepatch.gif
View
@@ -16,6 +16,7 @@
NSArray *files;
IBOutlet NSMenu *theMenu;
NSMenuItem *statusMenuItem;
+ NSMenuItem *actionMenuItem;
}
- (IBAction)updateiSightStatus:(id)sender;
View
@@ -18,6 +18,7 @@ - (void)dealloc
[statusItem release];
[enabledMenuIcon release];
[disabledMenuIcon release];
+ [actionMenuItem release];
[files release];
[super dealloc];
}
@@ -31,8 +32,8 @@ - (void)awakeFromNib
// Load the icons from the bundle resources
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
- NSString *enabledIconPath = [bundle pathForResource:@"eyeicon1" ofType:@"jpg"];
- NSString *disabledIconPath = [bundle pathForResource:@"eyepatch" ofType:@"jpg"];
+ NSString *enabledIconPath = [bundle pathForResource:@"eyeicon" ofType:@"gif"];
+ NSString *disabledIconPath = [bundle pathForResource:@"eyepatch" ofType:@"gif"];
enabledMenuIcon = [[NSImage alloc] initWithContentsOfFile:enabledIconPath];
disabledMenuIcon = [[NSImage alloc] initWithContentsOfFile:disabledIconPath];
@@ -50,16 +51,25 @@ - (void)awakeFromNib
[statusItem setToolTip:@"iSightStatus"];
[statusItem setMenu:theMenu];
- statusMenuItem = [[NSMenuItem alloc] initWithTitle:@"Unknown"
- action:@selector(updateiSightStatus:) keyEquivalent:@""];
+
+ // Menu item for the state of the iSight Camera
+ statusMenuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""];
[statusMenuItem setTarget:self];
- [theMenu insertItem:statusMenuItem atIndex:1];
+
+ [theMenu insertItem:statusMenuItem atIndex:0];
+
+ // Menu item for the appropriate action to use on the iSight Camera (enable or disable)
+ actionMenuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""];
+ [actionMenuItem setTarget:self];
+
+ [theMenu insertItem:actionMenuItem atIndex:2];
+
[self updateiSightStatus:nil];
}
-- (void)changeiSightPermissions:(NSArray *)fileList :(NSString *)permissionString
+- (void)changeiSightPermissions:(NSArray *)fileList permissions:(NSString *)permissionString
{
// This is all pretty ugly and doesn't really work the way I want it to. This is currently using the AuthorizationCreate / AuthorizationExecuteWithPrivileges which is not recommended for
@@ -107,7 +117,7 @@ - (void)changeiSightPermissions:(NSArray *)fileList :(NSString *)permissionStrin
}
else
{
- NSLog(@"Already authorized");
+ NSLog(@"Already authorized - Should not hit this state as authorization is dropped immediately after completeing method call");
status = noErr;
}
@@ -141,7 +151,10 @@ - (void)changeiSightPermissions:(NSArray *)fileList :(NSString *)permissionStrin
}
}
- // Need to add a bit of error handling
+ // Free the Authorization Credentials
+ NSLog(@"Dropping privileged authorization");
+ AuthorizationFree(authorizationRef, kAuthorizationFlagDefaults);
+ authorizationRef = NULL;
}
@@ -150,7 +163,7 @@ - (IBAction)enableiSight:(id)sender
NSLog(@"In Enable iSight");
// Change permissions to the unix equivalent of -r-xr--r--
- [self changeiSightPermissions:files :@"0544"];
+ [self changeiSightPermissions:files permissions:@"0544"];
NSLog(@"Task finished - updating status");
@@ -162,7 +175,7 @@ - (IBAction)disableiSight:(id)sender
NSLog(@"In Disable iSight");
// Change permissions to the unix equivalent of ----------
- [self changeiSightPermissions:files :@"0000"];
+ [self changeiSightPermissions:files permissions:@"0000"];
NSLog(@"Task finished - updating status");
@@ -205,12 +218,17 @@ - (IBAction)updateiSightStatus:(id)sender
// Modify status icon items based on iSight state
if (isCameraEnabled)
{
- [statusMenuItem setTitle:[NSString stringWithString:@"Enabled"]];
+ [statusMenuItem setTitle:[NSString stringWithString:@"iSight Status: Enabled"]];
[statusItem setImage:enabledMenuIcon];
+ [actionMenuItem setTitle:[NSString stringWithString:@"Disable iSight"]];
+ [actionMenuItem setAction:@selector(disableiSight:)];
} else {
- [statusMenuItem setTitle:[NSString stringWithString:@"Disabled"]];
+ [statusMenuItem setTitle:[NSString stringWithString:@"iSight Status: Disabled"]];
[statusItem setImage:disabledMenuIcon];
+ [actionMenuItem setTitle:[NSString stringWithString:@"Enable iSight"]];
+ [actionMenuItem setAction:@selector(enableiSight:)];
}
}
+
@end
View
@@ -33,48 +33,42 @@
<string key="NSClassName">AppController</string>
</object>
<object class="NSMenu" id="760847401">
- <string key="NSTitle"/>
+ <string key="NSTitle">EyePatch</string>
<object class="NSMutableArray" key="NSMenuItems">
<bool key="EncodedWithXMLCoder">YES</bool>
- <object class="NSMenuItem" id="350910882">
+ <object class="NSMenuItem" id="194272979">
<reference key="NSMenu" ref="760847401"/>
- <string key="NSTitle">iSight Status:</string>
+ <bool key="NSIsDisabled">YES</bool>
+ <bool key="NSIsSeparator">YES</bool>
+ <string key="NSTitle"/>
<string key="NSKeyEquiv"/>
<int key="NSMnemonicLoc">2147483647</int>
- <object class="NSCustomResource" key="NSOnImage" id="525246906">
+ <object class="NSCustomResource" key="NSOnImage" id="660068614">
<string key="NSClassName">NSImage</string>
<string key="NSResourceName">NSMenuCheckmark</string>
</object>
- <object class="NSCustomResource" key="NSMixedImage" id="300531476">
+ <object class="NSCustomResource" key="NSMixedImage" id="476506641">
<string key="NSClassName">NSImage</string>
<string key="NSResourceName">NSMenuMixedState</string>
</object>
</object>
- <object class="NSMenuItem" id="194272979">
+ <object class="NSMenuItem" id="89455839">
<reference key="NSMenu" ref="760847401"/>
<bool key="NSIsDisabled">YES</bool>
<bool key="NSIsSeparator">YES</bool>
<string key="NSTitle"/>
<string key="NSKeyEquiv"/>
<int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="525246906"/>
- <reference key="NSMixedImage" ref="300531476"/>
+ <reference key="NSOnImage" ref="660068614"/>
+ <reference key="NSMixedImage" ref="476506641"/>
</object>
- <object class="NSMenuItem" id="554635635">
+ <object class="NSMenuItem" id="95376699">
<reference key="NSMenu" ref="760847401"/>
- <string key="NSTitle">Enable iSight</string>
+ <string key="NSTitle">Quit EyePatch</string>
<string key="NSKeyEquiv"/>
<int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="525246906"/>
- <reference key="NSMixedImage" ref="300531476"/>
- </object>
- <object class="NSMenuItem" id="1059191180">
- <reference key="NSMenu" ref="760847401"/>
- <string key="NSTitle">Disable iSight</string>
- <string key="NSKeyEquiv"/>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="525246906"/>
- <reference key="NSMixedImage" ref="300531476"/>
+ <reference key="NSOnImage" ref="660068614"/>
+ <reference key="NSMixedImage" ref="476506641"/>
</object>
</object>
</object>
@@ -92,19 +86,11 @@
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
- <string key="label">enableiSight:</string>
- <reference key="source" ref="565493053"/>
- <reference key="destination" ref="554635635"/>
+ <string key="label">terminate:</string>
+ <reference key="source" ref="1050"/>
+ <reference key="destination" ref="95376699"/>
</object>
- <int key="connectionID">459</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">disableiSight:</string>
- <reference key="source" ref="565493053"/>
- <reference key="destination" ref="1059191180"/>
- </object>
- <int key="connectionID">460</int>
+ <int key="connectionID">463</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
@@ -151,31 +137,25 @@
<reference key="object" ref="760847401"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
- <reference ref="350910882"/>
<reference ref="194272979"/>
- <reference ref="554635635"/>
- <reference ref="1059191180"/>
+ <reference ref="95376699"/>
+ <reference ref="89455839"/>
</object>
<reference key="parent" ref="1049"/>
</object>
- <object class="IBObjectRecord">
- <int key="objectID">452</int>
- <reference key="object" ref="350910882"/>
- <reference key="parent" ref="760847401"/>
- </object>
<object class="IBObjectRecord">
<int key="objectID">455</int>
<reference key="object" ref="194272979"/>
<reference key="parent" ref="760847401"/>
</object>
<object class="IBObjectRecord">
- <int key="objectID">457</int>
- <reference key="object" ref="554635635"/>
+ <int key="objectID">461</int>
+ <reference key="object" ref="95376699"/>
<reference key="parent" ref="760847401"/>
</object>
<object class="IBObjectRecord">
- <int key="objectID">458</int>
- <reference key="object" ref="1059191180"/>
+ <int key="objectID">462</int>
+ <reference key="object" ref="89455839"/>
<reference key="parent" ref="760847401"/>
</object>
</object>
@@ -190,19 +170,17 @@
<string>450.IBPluginDependency</string>
<string>451.IBEditorWindowLastContentRect</string>
<string>451.IBPluginDependency</string>
- <string>452.IBPluginDependency</string>
<string>455.IBPluginDependency</string>
- <string>457.IBPluginDependency</string>
- <string>458.IBPluginDependency</string>
+ <string>461.IBPluginDependency</string>
+ <string>462.IBPluginDependency</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilderKit</string>
<string>com.apple.InterfaceBuilderKit</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{871, 393}, {148, 73}}</string>
- <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>{{783, 580}, {148, 43}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -229,7 +207,7 @@
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">460</int>
+ <int key="maxID">466</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -8,9 +8,9 @@
/* Begin PBXBuildFile section */
000FFC070E74E85E00063F63 /* AppController.m in Sources */ = {isa = PBXBuildFile; fileRef = 000FFC060E74E85E00063F63 /* AppController.m */; };
- 000FFC150E74ED4400063F63 /* eyeicon1.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 000FFC140E74ED4400063F63 /* eyeicon1.jpg */; };
- 000FFC170E74ED5500063F63 /* eyepatch.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 000FFC160E74ED5500063F63 /* eyepatch.jpg */; };
000FFDBB0E779BA000063F63 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 000FFDBA0E779BA000063F63 /* Security.framework */; };
+ 00219A670E7997C40074224E /* eyeicon.gif in Resources */ = {isa = PBXBuildFile; fileRef = 00219A660E7997C40074224E /* eyeicon.gif */; };
+ 00219A6E0E799C890074224E /* eyepatch.gif in Resources */ = {isa = PBXBuildFile; fileRef = 00219A6D0E799C890074224E /* eyepatch.gif */; };
1DDD58160DA1D0A300B32029 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1DDD58140DA1D0A300B32029 /* MainMenu.xib */; };
8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; };
8D11072D0486CEB800E47090 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; };
@@ -20,9 +20,9 @@
/* Begin PBXFileReference section */
000FFC050E74E85E00063F63 /* AppController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppController.h; sourceTree = "<group>"; };
000FFC060E74E85E00063F63 /* AppController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppController.m; sourceTree = "<group>"; };
- 000FFC140E74ED4400063F63 /* eyeicon1.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = eyeicon1.jpg; sourceTree = "<group>"; };
- 000FFC160E74ED5500063F63 /* eyepatch.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = eyepatch.jpg; sourceTree = "<group>"; };
000FFDBA0E779BA000063F63 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = /System/Library/Frameworks/Security.framework; sourceTree = "<absolute>"; };
+ 00219A660E7997C40074224E /* eyeicon.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = eyeicon.gif; sourceTree = "<group>"; };
+ 00219A6D0E799C890074224E /* eyepatch.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = eyepatch.gif; sourceTree = "<group>"; };
089C165DFE840E0CC02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
13E42FB307B3F0F600E4EEF1 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = "<absolute>"; };
@@ -108,8 +108,8 @@
29B97317FDCFA39411CA2CEA /* Resources */ = {
isa = PBXGroup;
children = (
- 000FFC160E74ED5500063F63 /* eyepatch.jpg */,
- 000FFC140E74ED4400063F63 /* eyeicon1.jpg */,
+ 00219A6D0E799C890074224E /* eyepatch.gif */,
+ 00219A660E7997C40074224E /* eyeicon.gif */,
8D1107310486CEB800E47090 /* Info.plist */,
089C165CFE840E0CC02AAC07 /* InfoPlist.strings */,
1DDD58140DA1D0A300B32029 /* MainMenu.xib */,
@@ -171,8 +171,8 @@
files = (
8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */,
1DDD58160DA1D0A300B32029 /* MainMenu.xib in Resources */,
- 000FFC150E74ED4400063F63 /* eyeicon1.jpg in Resources */,
- 000FFC170E74ED5500063F63 /* eyepatch.jpg in Resources */,
+ 00219A670E7997C40074224E /* eyeicon.gif in Resources */,
+ 00219A6E0E799C890074224E /* eyepatch.gif in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7ab1c2a

Please sign in to comment.