Skip to content

Commit

Permalink
Sandboxing start at login (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
codler committed Aug 14, 2012
1 parent 4885e5e commit dfc2e6b
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 4 deletions.
81 changes: 81 additions & 0 deletions Battery Time Remaining.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,42 @@
28833BB215D7D4FF00741727 /* Readme.md in Resources */ = {isa = PBXBuildFile; fileRef = 28833BB115D7D4FF00741727 /* Readme.md */; };
28833BB415D7D61100741727 /* build_version in Resources */ = {isa = PBXBuildFile; fileRef = 28833BB315D7D61100741727 /* build_version */; };
28BA61A815D1B12500EDB674 /* icon.icns in Resources */ = {isa = PBXBuildFile; fileRef = 28BA61A715D1B12500EDB674 /* icon.icns */; };
28FEDA5E15DA5C9D00320B72 /* ServiceManagement.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 28FEDA5D15DA5C9D00320B72 /* ServiceManagement.framework */; };
28FEDA6E15DA5ECA00320B72 /* LaunchAtLoginHelper.app in CopyFiles */ = {isa = PBXBuildFile; fileRef = 28FEDA6B15DA5EB200320B72 /* LaunchAtLoginHelper.app */; };
28FEDA6F15DA5F8C00320B72 /* LLManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 28FEDA6315DA5EB200320B72 /* LLManager.m */; };
D58C7EF815CD7C6100C07E0C /* StartAtLoginHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = D58C7EF715CD7C6100C07E0C /* StartAtLoginHelper.m */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
28FEDA6A15DA5EB200320B72 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 28FEDA5F15DA5EB200320B72 /* LaunchAtLoginHelper.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 734C379415414CE200994189;
remoteInfo = LaunchAtLoginHelper;
};
28FEDA6C15DA5EC200320B72 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 28FEDA5F15DA5EB200320B72 /* LaunchAtLoginHelper.xcodeproj */;
proxyType = 1;
remoteGlobalIDString = 734C379315414CE200994189;
remoteInfo = LaunchAtLoginHelper;
};
/* End PBXContainerItemProxy section */

/* Begin PBXCopyFilesBuildPhase section */
28FEDA5B15DA5B5900320B72 /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = Contents/Library/LoginItems;
dstSubfolderSpec = 1;
files = (
28FEDA6E15DA5ECA00320B72 /* LaunchAtLoginHelper.app in CopyFiles */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
2841C7DC15C91CC100F4F15F /* Battery Time Remaining.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Battery Time Remaining.app"; sourceTree = BUILT_PRODUCTS_DIR; };
2841C7E015C91CC100F4F15F /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
Expand All @@ -40,6 +73,11 @@
28833BB315D7D61100741727 /* build_version */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = build_version; sourceTree = SOURCE_ROOT; };
28BA61A715D1B12500EDB674 /* icon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; name = icon.icns; path = ../icon.icns; sourceTree = "<group>"; };
28BA61A915D1B63300EDB674 /* Battery Time Remaining.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = "Battery Time Remaining.entitlements"; sourceTree = "<group>"; };
28FEDA5D15DA5C9D00320B72 /* ServiceManagement.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ServiceManagement.framework; path = System/Library/Frameworks/ServiceManagement.framework; sourceTree = SDKROOT; };
28FEDA5F15DA5EB200320B72 /* LaunchAtLoginHelper.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = LaunchAtLoginHelper.xcodeproj; path = LaunchAtLoginHelper/LaunchAtLoginHelper.xcodeproj; sourceTree = "<group>"; };
28FEDA6215DA5EB200320B72 /* LLManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = LLManager.h; path = ../LaunchAtLoginHelper/LLManager.h; sourceTree = "<group>"; };
28FEDA6315DA5EB200320B72 /* LLManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = LLManager.m; path = ../LaunchAtLoginHelper/LLManager.m; sourceTree = "<group>"; };
28FEDA6415DA5EB200320B72 /* LLStrings.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = LLStrings.h; path = ../LaunchAtLoginHelper/LLStrings.h; sourceTree = "<group>"; };
D58C7EF615CD7C6100C07E0C /* StartAtLoginHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StartAtLoginHelper.h; sourceTree = "<group>"; };
D58C7EF715CD7C6100C07E0C /* StartAtLoginHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = StartAtLoginHelper.m; sourceTree = "<group>"; };
/* End PBXFileReference section */
Expand All @@ -49,6 +87,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
28FEDA5E15DA5C9D00320B72 /* ServiceManagement.framework in Frameworks */,
2841C7FE15C91CEF00F4F15F /* IOKit.framework in Frameworks */,
2841C7E115C91CC100F4F15F /* Cocoa.framework in Frameworks */,
);
Expand All @@ -60,6 +99,7 @@
2841C7D115C91CC100F4F15F = {
isa = PBXGroup;
children = (
28FEDA5F15DA5EB200320B72 /* LaunchAtLoginHelper.xcodeproj */,
2841C7E615C91CC100F4F15F /* Battery Time Remaining */,
2841C7DF15C91CC100F4F15F /* Frameworks */,
2841C7DD15C91CC100F4F15F /* Products */,
Expand All @@ -77,6 +117,7 @@
2841C7DF15C91CC100F4F15F /* Frameworks */ = {
isa = PBXGroup;
children = (
28FEDA5D15DA5C9D00320B72 /* ServiceManagement.framework */,
2841C7FD15C91CEF00F4F15F /* IOKit.framework */,
2841C7E015C91CC100F4F15F /* Cocoa.framework */,
2841C7E215C91CC100F4F15F /* Other Frameworks */,
Expand All @@ -97,6 +138,9 @@
2841C7E615C91CC100F4F15F /* Battery Time Remaining */ = {
isa = PBXGroup;
children = (
28FEDA6215DA5EB200320B72 /* LLManager.h */,
28FEDA6315DA5EB200320B72 /* LLManager.m */,
28FEDA6415DA5EB200320B72 /* LLStrings.h */,
2841C7F215C91CC100F4F15F /* AppDelegate.h */,
2841C7F315C91CC100F4F15F /* AppDelegate.m */,
28833BAC15D7B90B00741727 /* HttpGet.h */,
Expand Down Expand Up @@ -124,6 +168,14 @@
name = "Supporting Files";
sourceTree = "<group>";
};
28FEDA6015DA5EB200320B72 /* Products */ = {
isa = PBXGroup;
children = (
28FEDA6B15DA5EB200320B72 /* LaunchAtLoginHelper.app */,
);
name = Products;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand All @@ -134,10 +186,12 @@
2841C7D815C91CC100F4F15F /* Sources */,
2841C7D915C91CC100F4F15F /* Frameworks */,
2841C7DA15C91CC100F4F15F /* Resources */,
28FEDA5B15DA5B5900320B72 /* CopyFiles */,
);
buildRules = (
);
dependencies = (
28FEDA6D15DA5EC200320B72 /* PBXTargetDependency */,
);
name = "Battery Time Remaining";
productName = "Battery Time Remaining";
Expand All @@ -163,13 +217,29 @@
mainGroup = 2841C7D115C91CC100F4F15F;
productRefGroup = 2841C7DD15C91CC100F4F15F /* Products */;
projectDirPath = "";
projectReferences = (
{
ProductGroup = 28FEDA6015DA5EB200320B72 /* Products */;
ProjectRef = 28FEDA5F15DA5EB200320B72 /* LaunchAtLoginHelper.xcodeproj */;
},
);
projectRoot = "";
targets = (
2841C7DB15C91CC100F4F15F /* Battery Time Remaining */,
);
};
/* End PBXProject section */

/* Begin PBXReferenceProxy section */
28FEDA6B15DA5EB200320B72 /* LaunchAtLoginHelper.app */ = {
isa = PBXReferenceProxy;
fileType = wrapper.application;
path = LaunchAtLoginHelper.app;
remoteRef = 28FEDA6A15DA5EB200320B72 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
/* End PBXReferenceProxy section */

/* Begin PBXResourcesBuildPhase section */
2841C7DA15C91CC100F4F15F /* Resources */ = {
isa = PBXResourcesBuildPhase;
Expand All @@ -190,6 +260,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
28FEDA6F15DA5F8C00320B72 /* LLManager.m in Sources */,
2841C7ED15C91CC100F4F15F /* main.m in Sources */,
2841C7F415C91CC100F4F15F /* AppDelegate.m in Sources */,
D58C7EF815CD7C6100C07E0C /* StartAtLoginHelper.m in Sources */,
Expand All @@ -199,6 +270,14 @@
};
/* End PBXSourcesBuildPhase section */

/* Begin PBXTargetDependency section */
28FEDA6D15DA5EC200320B72 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
name = LaunchAtLoginHelper;
targetProxy = 28FEDA6C15DA5EC200320B72 /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */

/* Begin PBXVariantGroup section */
2841C7E915C91CC100F4F15F /* InfoPlist.strings */ = {
isa = PBXVariantGroup;
Expand Down Expand Up @@ -271,6 +350,7 @@
2841C7FB15C91CC200F4F15F /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_ENTITLEMENTS = "Battery Time Remaining/Battery Time Remaining.entitlements";
CODE_SIGN_IDENTITY = "Developer ID Application: Han Lin Yap";
COMBINE_HIDPI_IMAGES = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
Expand All @@ -285,6 +365,7 @@
2841C7FC15C91CC200F4F15F /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_ENTITLEMENTS = "Battery Time Remaining/Battery Time Remaining.entitlements";
CODE_SIGN_IDENTITY = "Developer ID Application: Han Lin Yap";
COMBINE_HIDPI_IMAGES = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
Expand Down
14 changes: 12 additions & 2 deletions Battery Time Remaining/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#import "AppDelegate.h"
#import "HttpGet.h"
#import "LLManager.h"
#import "StartAtLoginHelper.h"
#import <IOKit/ps/IOPowerSources.h>
#import <IOKit/ps/IOPSKeys.h>
Expand Down Expand Up @@ -53,7 +54,8 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
// Create the startup at login toggle
self.startupToggle = [[NSMenuItem alloc] initWithTitle:@"Start at login" action:@selector(toggleStartAtLogin:) keyEquivalent:@""];
self.startupToggle.target = self;
self.startupToggle.state = ([StartAtLoginHelper isInLoginItems]) ? NSOnState : NSOffState;
self.startupToggle.state = ([LLManager launchAtLogin]) ? NSOnState : NSOffState;
//self.startupToggle.state = ([StartAtLoginHelper isInLoginItems]) ? NSOnState : NSOffState;
#endif

// Build the notification submenu
Expand Down Expand Up @@ -255,6 +257,14 @@ - (void)openHomeUrl:(id)sender
#ifndef SANDBOX
- (void)toggleStartAtLogin:(id)sender
{
if ([LLManager launchAtLogin]) {
[LLManager setLaunchAtLogin:NO];
self.startupToggle.state = NSOffState;
} else {
[LLManager setLaunchAtLogin:YES];
self.startupToggle.state = NSOnState;
}
/*
// Check the state of start at login
if ([StartAtLoginHelper isInLoginItems])
{
Expand All @@ -265,7 +275,7 @@ - (void)toggleStartAtLogin:(id)sender
{
[StartAtLoginHelper addToLoginItems];
self.startupToggle.state = NSOnState;
}
}*/
}
#endif

Expand Down
17 changes: 15 additions & 2 deletions Battery Time Remaining/Battery Time Remaining-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,24 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.3</string>
<string>1.4</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>CFBundleURLName</key>
<string>com.codler.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleURLSchemes</key>
<array>
<string>com.codler.Battery-Time-Remaining</string>
</array>
</dict>
</array>
<key>CFBundleVersion</key>
<string>6</string>
<string>7</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key>
Expand Down

0 comments on commit dfc2e6b

Please sign in to comment.