Skip to content

Commit

Permalink
Merge branch '1.3.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
integralpro committed Aug 16, 2012
2 parents eaf815c + 03eb3fb commit de2a92c
Show file tree
Hide file tree
Showing 133 changed files with 5,161 additions and 202 deletions.
1,721 changes: 1,721 additions & 0 deletions Icons/Zz16x16.ai

Large diffs are not rendered by default.

36 changes: 34 additions & 2 deletions Installer/NoSleepPkg.pkgproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<key>GID</key>
<integer>80</integer>
<key>PATH</key>
<string>../DerivedData/NoSleep/Build/Products/Release/NoSleepHelper.app</string>
<string>../DerivedData/NoSleep/Build/Products/Release/NoSleep.app</string>
<key>PATH_TYPE</key>
<integer>1</integer>
<key>PERMISSIONS</key>
Expand Down Expand Up @@ -490,6 +490,22 @@
</dict>
<key>RESOURCES</key>
<array>
<dict>
<key>CHILDREN</key>
<array/>
<key>GID</key>
<integer>0</integer>
<key>PATH</key>
<string>Scripts/Common.sh</string>
<key>PATH_TYPE</key>
<integer>1</integer>
<key>PERMISSIONS</key>
<integer>493</integer>
<key>TYPE</key>
<integer>3</integer>
<key>UID</key>
<integer>0</integer>
</dict>
<dict>
<key>CHILDREN</key>
<array/>
Expand Down Expand Up @@ -522,12 +538,28 @@
<key>UID</key>
<integer>0</integer>
</dict>
<dict>
<key>CHILDREN</key>
<array/>
<key>GID</key>
<integer>0</integer>
<key>PATH</key>
<string>Scripts/Uninstall_1.3.1.sh</string>
<key>PATH_TYPE</key>
<integer>1</integer>
<key>PERMISSIONS</key>
<integer>493</integer>
<key>TYPE</key>
<integer>3</integer>
<key>UID</key>
<integer>0</integer>
</dict>
</array>
</dict>
<key>PACKAGE_SETTINGS</key>
<dict>
<key>AUTHENTICATION</key>
<integer>1</integer>
<true/>
<key>CONCLUSION_ACTION</key>
<integer>0</integer>
<key>IDENTIFIER</key>
Expand Down
Binary file modified Installer/Resources/Readme.html
Binary file not shown.
17 changes: 17 additions & 0 deletions Installer/Scripts/Common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh

COMMON_DEFINED=yes

KEXT_ID=com.protech.NoSleep
KEXT_PATH=/System/Library/Extensions/NoSleep.kext
PERF_PATH=/Library/PreferencePanes/NoSleep.prefPane
HELPER_PATH=/Applications/Utilities/NoSleep.app

USER_SUDO_CMD=""

if [ "$SUDO_USER" != "" ]; then
USER_SUDO_CMD="sudo -u $SUDO_USER"
else if [ "$USER" != "" ]; then
USER_SUDO_CMD="sudo -u $USER"
fi
fi
11 changes: 5 additions & 6 deletions Installer/Scripts/Postinstall.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
#!/bin/sh

KEXT_PATH=/System/Library/Extensions/NoSleep.kext
HELPER_PATH=/Applications/Utilities/NoSleepHelper.app
if [ "$COMMON_DEFINED" = "" ]; then
source `dirname "$0"`/Common.sh
fi

sudo kextload "$KEXT_PATH"

#defaults write loginwindow AutoLaunchedApplicationDictionary -array-add \
#'<dict><key>Hide</key><false/><key>Path</key><string>'$HELPER_PATH'</string></dict>'

open "$HELPER_PATH" --args --register-loginitem
defaults write /Library/Preferences/loginwindow AutoLaunchedApplicationDictionary -array-add '{Path="$HELPER_PATH";}'
open $HELPER_PATH

echo "Done"
8 changes: 4 additions & 4 deletions Installer/Scripts/Preinstall.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

echo "Enter your password"
sudo echo
f=`dirname "$0"`

./Uninstall_1.2.1.sh
./Uninstall_1.3.0.sh
$f/./Uninstall_1.2.1.sh
$f/./Uninstall_1.3.0.sh
$f/./Uninstall_1.3.1.sh
2 changes: 1 addition & 1 deletion Installer/Scripts/Uninstall_1.2.1.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

echo "Uninstalling 1.2.1 and previous"
sudo echo
sudo true

KEXT_ID=com.protech.nosleep
KEXT_PATH=/System/Library/Extensions/nosleep.kext
Expand Down
6 changes: 3 additions & 3 deletions Installer/Scripts/Uninstall_1.3.0.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
#!/bin/sh

echo "Uninstalling 1.3.0"
sudo echo
sudo true

KEXT_ID=com.protech.NoSleep
KEXT_PATH=/System/Library/Extensions/NoSleep.kext
PERF_PATH=/Library/PreferencePanes/NoSleep.prefPane
HELPER_PATH=/Applications/Utilities/NoSleepHelper.app

ps aux|grep NoSleepHelper|awk '{print $2}'|xargs kill -9 &> /dev/null
ps aux|grep NoSleepHelper.app|awk '{print $2}'|xargs kill -9 &> /dev/null

if [ -e "$HELPER_PATH" ]; then
echo "Removing NoSleepHelper..."
open "$HELPER_PATH" --args --unregister-loginitem
sleep 5
ps aux|grep NoSleepHelper|awk '{print $2}'|xargs kill -9 &> /dev/null
ps aux|grep NoSleepHelper.app|awk '{print $2}'|xargs kill -9 &> /dev/null
sudo rm -rf "$HELPER_PATH"
fi

Expand Down
33 changes: 33 additions & 0 deletions Installer/Scripts/Uninstall_1.3.1.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/sh

echo "Uninstalling 1.3.1"
sudo true

if [ "$COMMON_DEFINED" = "" ]; then
source `dirname "$0"`/Common.sh
fi

if [ -e "$HELPER_PATH" ]; then
echo "Removing NoSleep.app..."
ps aux|grep NoSleep.app|awk '{print $2}'|xargs kill &> /dev/null
sudo rm -rf "$HELPER_PATH"
fi

if kextstat | grep "$KEXT_ID" > /dev/null; then
echo "Unloading kernel extension..."
sudo kextunload -b "$KEXT_ID"
fi

if [ -e "$KEXT_PATH" ]; then
echo "Removing kernel extension..."
sudo rm -rf "$KEXT_PATH"
fi

if [ -e "$PERF_PATH" ]; then
echo "Removing preferences plug-in..."
sudo rm -rf "$PERF_PATH"
fi

sudo pkgutil --forget "com.protech.pkg.NoSleep" &> /dev/null

echo "Done"
8 changes: 5 additions & 3 deletions Installer/Scripts/Uninstall_Cli_1.3.0.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

echo "Uninstaling NoSleepCtrl"
sudo echo
echo "Uninstalling NoSleepCtrl"
sudo true

CLI_PATH=/usr/local/bin/NoSleepCtrl

Expand All @@ -10,4 +10,6 @@ if [ -e "$CLI_PATH" ]; then
sudo rm -rf "$CLI_PATH"
fi

echo "Done"
sudo pkgutil --forget "com.protech.pkg.NoSleepCtrl" &> /dev/null

echo "Done"
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ delivery:
$(MAKE) clean
$(MAKE) package
mkdir Delivery
cat Installer/Scripts/Uninstall_1.3.0.sh > Delivery/Uninstall.command
cat Installer/Scripts/Common.sh > Delivery/Uninstall.command
cat Installer/Scripts/Uninstall_1.3.1.sh >> Delivery/Uninstall.command
echo >> Delivery/Uninstall.command
cat Installer/Scripts/Uninstall_Cli_1.3.0.sh >> Delivery/Uninstall.command
chmod +x Delivery/Uninstall.command
Expand Down
3 changes: 3 additions & 0 deletions NoSleep/NoSleepCtrl/NoSleepCtrl.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@
/* Begin PBXProject section */
9299A85B14F6108B00F1DB9F /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0430;
};
buildConfigurationList = 9299A85E14F6108B00F1DB9F /* Build configuration list for PBXProject "NoSleepCtrl" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@
/* Begin PBXProject section */
921DD83E14EAE2D9000EC9D0 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0440;
};
buildConfigurationList = 921DD84114EAE2D9000EC9D0 /* Build configuration list for PBXProject "NoSleepFramework" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
Expand Down Expand Up @@ -300,6 +303,7 @@
921DD85E14EAE2D9000EC9D0 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
COMBINE_HIDPI_IMAGES = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
FRAMEWORK_VERSION = A;
Expand All @@ -315,6 +319,7 @@
921DD85F14EAE2D9000EC9D0 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
COMBINE_HIDPI_IMAGES = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
FRAMEWORK_VERSION = A;
Expand All @@ -330,6 +335,7 @@
92987E8C14EC2F5700DA7075 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
COMBINE_HIDPI_IMAGES = YES;
EXECUTABLE_PREFIX = lib;
MACOSX_DEPLOYMENT_TARGET = 10.7;
PRODUCT_NAME = NoSleep;
Expand All @@ -339,6 +345,7 @@
92987E8D14EC2F5700DA7075 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
COMBINE_HIDPI_IMAGES = YES;
EXECUTABLE_PREFIX = lib;
MACOSX_DEPLOYMENT_TARGET = 10.7;
PRODUCT_NAME = NoSleep;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#define SHOW_UI_ALERT_KEXT_NOT_LOADED() NSRunAlertPanel(@"Oops!", @"NoSleep Kernel Extension is not loaded.", @"OK", nil, nil)

//#define LAUNCH_AGENT "com.protech.nosleep.launch.plist"
#define NOSLEEP_HELPER_PATH "/Applications/Utilities/NoSleepHelper.app"
#define NOSLEEP_HELPER_PATH "/Applications/Utilities/NoSleep.app"
#define NOSLEEP_PREFPANE_PATH "/Library/PreferencePanes/NoSleep.prefPane"
//#define LAUNCH_AGENTS_PATH "/Library/LaunchAgents/"
//#define NOSLEEP_HELPER_IDENTIFIER @"com.protech.NoSleepHelper"
Expand Down
Binary file not shown.
Binary file not shown.
4 changes: 3 additions & 1 deletion NoSleep/NoSleepFramework/NoSleepFramework/NoSleepInterface.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,11 @@ NoSleepInterestNotification NoSleep_ReceiveStateChanged(NoSleepInterfaceService
}
return 0;
}

return (NoSleepInterfaceConnect)notifyObj;
}

return (NoSleepInterfaceConnect)notifyObj;
return 0;
}

void NoSleep_ReleaseStateChanged(NoSleepInterestNotification notifyObj)
Expand Down
58 changes: 30 additions & 28 deletions NoSleep/NoSleepFramework/NoSleepFramework/Utilities.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,43 +12,45 @@

BOOL registerLoginItem(LoginItemAction action) {
UInt32 seedValue;
LSSharedFileListItemRef existingItem = NULL;

NSURL *itemURL = [NSURL fileURLWithPath:@NOSLEEP_HELPER_PATH];

LSSharedFileListRef loginItemsRefs = LSSharedFileListCreate(NULL, kLSSharedFileListSessionLoginItems, NULL);
if(!loginItemsRefs) {
return NO;
}

NSArray *loginItemsArray = (NSArray *)LSSharedFileListCopySnapshot(loginItemsRefs, &seedValue);
NSArray *loginItemsArray = [NSMakeCollectable(LSSharedFileListCopySnapshot(loginItemsRefs, &seedValue)) autorelease];
for (id item in loginItemsArray) {
LSSharedFileListItemRef itemRef = (LSSharedFileListItemRef)item;
NSString *displayName = (NSString *)LSSharedFileListItemCopyDisplayName(itemRef);
if([[@NOSLEEP_HELPER_PATH lastPathComponent] isEqualToString:displayName]) {
//CFURLRef path;
//if (LSSharedFileListItemResolve(itemRef, 0, (CFURLRef*)&path, NULL) == noErr) {
// NSString *url = [(NSURL *)path path];
//if ([url isEqualToString:@NOSLEEP_HELPER_PATH]) {
// if exists
if(action == kLIUnregister) {
LSSharedFileListItemRemove(loginItemsRefs, itemRef);
}

return YES;
//}
//CFRelease(path);
//}

UInt32 resolutionFlags = kLSSharedFileListNoUserInteraction | kLSSharedFileListDoNotMountVolumes;
CFURLRef URL = NULL;
OSStatus err = LSSharedFileListItemResolve(itemRef, resolutionFlags, &URL, /*outRef*/ NULL);
if (err == noErr) {
Boolean foundIt = CFEqual(URL, itemURL);
CFRelease(URL);

if (foundIt) {
existingItem = itemRef;
break;
}
}
[displayName release];
}

if(action == kLIRegister) {
//CFURLRef url1 = (CFURLRef)[[NSWorkspace sharedWorkspace] URLForApplicationWithBundleIdentifier:NOSLEEP_HELPER_IDENTIFIER];
//NSURL *url11 = (NSURL*)url1;
NSURL *url = [[NSURL alloc] initFileURLWithPath:@NOSLEEP_HELPER_PATH];

LSSharedFileListItemRef item = LSSharedFileListInsertItemURL(loginItemsRefs, kLSSharedFileListItemLast,
NULL, NULL, (CFURLRef)url, NULL, NULL);

if (item) {
CFRelease(item);
}
if(action == kLICheck) {
return existingItem != NULL;
} else if (action == kLIRegister && (existingItem == NULL)) {
LSSharedFileListInsertItemURL(loginItemsRefs, kLSSharedFileListItemBeforeFirst,
NULL, NULL, (CFURLRef)itemURL, NULL, NULL);
return YES;
} else if (action == kLIUnregister && (existingItem != NULL)) {
LSSharedFileListItemRemove(loginItemsRefs, existingItem);
return YES;
}

CFRelease(loginItemsRefs);

return NO;
}
Loading

0 comments on commit de2a92c

Please sign in to comment.