Fixed issues with 10.4-10.5 not having IORegistryEntryGetRegistryEntryID and issue where the name of the notes file was .txt instead of rtf. Updated version to 0.2.1

This commit is contained in:
GRMrGecko 2011-03-03 14:26:49 -06:00
parent 2d15716b4a
commit e8d4bced4e
9 changed files with 48 additions and 62 deletions

View File

@ -19,6 +19,8 @@ extern NSString * const MGMNIcon;
extern NSString * const MGMNSound; extern NSString * const MGMNSound;
extern NSString * const MGMNTask; extern NSString * const MGMNTask;
@protocol NSWindowDelegate;
@interface MGMController : NSObject <NSWindowDelegate> { @interface MGMController : NSObject <NSWindowDelegate> {
NSWindow *instructions; NSWindow *instructions;

View File

@ -43,7 +43,7 @@ NSString * const MGMVersion = @"MGMVersion";
NSString * const MGMLaunchCount = @"MGMLaunchCount"; NSString * const MGMLaunchCount = @"MGMLaunchCount";
NSString * const MGMApplicationSupportPath = @"~/Library/Application Support/MrGeckosMedia/SoundNote/"; NSString * const MGMApplicationSupportPath = @"~/Library/Application Support/MrGeckosMedia/SoundNote/";
NSString * const MGMNotesName = @"notes.txt"; NSString * const MGMNotesName = @"notes.rtf";
NSString * const MGMGrowlName = @"growl.plist"; NSString * const MGMGrowlName = @"growl.plist";
NSString * const MGMDisabledName = @"disabled.plist"; NSString * const MGMDisabledName = @"disabled.plist";
NSString * const MGMSoundEndedNotification = @"MGMSoundEndedNotification"; NSString * const MGMSoundEndedNotification = @"MGMSoundEndedNotification";
@ -103,15 +103,15 @@ static MGMController *MGMSharedController;
NSFileManager *manager = [NSFileManager defaultManager]; NSFileManager *manager = [NSFileManager defaultManager];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if ([defaults objectForKey:MGMVersion]==nil) { if ([defaults objectForKey:MGMVersion]==nil || [[defaults objectForKey:MGMVersion] isEqual:@"0.2"]) {
if ([manager fileExistsAtPath:[MGMApplicationSupportPath stringByExpandingTildeInPath]]) { if ([manager fileExistsAtPath:[MGMApplicationSupportPath stringByExpandingTildeInPath]]) {
[manager copyItemAtPath:[[NSBundle mainBundle] pathForResource:[MGMNotesName stringByDeletingPathExtension] ofType:[MGMNotesName pathExtension]] toPath:[[MGMApplicationSupportPath stringByExpandingTildeInPath] stringByAppendingPathComponent:MGMNotesName]]; [manager copyItemAtPath:[[NSBundle mainBundle] pathForResource:[MGMNotesName stringByDeletingPathExtension] ofType:[MGMNotesName pathExtension]] toPath:[[MGMApplicationSupportPath stringByExpandingTildeInPath] stringByAppendingPathComponent:MGMNotesName]];
[manager copyItemAtPath:[[NSBundle mainBundle] pathForResource:[MGMGrowlName stringByDeletingPathExtension] ofType:[MGMGrowlName pathExtension]] toPath:[[MGMApplicationSupportPath stringByExpandingTildeInPath] stringByAppendingPathComponent:MGMGrowlName]]; [manager copyItemAtPath:[[NSBundle mainBundle] pathForResource:[MGMGrowlName stringByDeletingPathExtension] ofType:[MGMGrowlName pathExtension]] toPath:[[MGMApplicationSupportPath stringByExpandingTildeInPath] stringByAppendingPathComponent:MGMGrowlName]];
[manager copyItemAtPath:[[NSBundle mainBundle] pathForResource:[MGMDisabledName stringByDeletingPathExtension] ofType:[MGMDisabledName pathExtension]] toPath:[[MGMApplicationSupportPath stringByExpandingTildeInPath] stringByAppendingPathComponent:MGMDisabledName]]; [manager copyItemAtPath:[[NSBundle mainBundle] pathForResource:[MGMDisabledName stringByDeletingPathExtension] ofType:[MGMDisabledName pathExtension]] toPath:[[MGMApplicationSupportPath stringByExpandingTildeInPath] stringByAppendingPathComponent:MGMDisabledName]];
[manager removeItemAtPath:[[MGMApplicationSupportPath stringByExpandingTildeInPath] stringByAppendingPathComponent:@"note.txt"]]; [manager removeItemAtPath:[[MGMApplicationSupportPath stringByExpandingTildeInPath] stringByAppendingPathComponent:@"note.txt"]];
[self showInstructions]; [self showInstructions];
[defaults setObject:[[MGMSystemInfo info] applicationVersion] forKey:MGMVersion];
} }
[defaults setObject:[[MGMSystemInfo info] applicationVersion] forKey:MGMVersion];
} }
[self registerDefaults]; [self registerDefaults];
if (![manager fileExistsAtPath:[MGMApplicationSupportPath stringByExpandingTildeInPath]]) { if (![manager fileExistsAtPath:[MGMApplicationSupportPath stringByExpandingTildeInPath]]) {

View File

@ -19,6 +19,8 @@
- (void)soundDidFinishPlaying:(MGMSound *)theSound; - (void)soundDidFinishPlaying:(MGMSound *)theSound;
@end @end
@protocol NSSoundDelegate;
@interface MGMSound : NSObject @interface MGMSound : NSObject
#if TARGET_OS_IPHONE #if TARGET_OS_IPHONE
<AVAudioPlayerDelegate> <AVAudioPlayerDelegate>

View File

@ -88,8 +88,8 @@ static void receivedNotification(AXObserverRef observer, AXUIElementRef element,
[self observe:kAXMenuOpenedNotification element:element observer:observer application:theApplication]; [self observe:kAXMenuOpenedNotification element:element observer:observer application:theApplication];
[self observe:kAXMenuClosedNotification element:element observer:observer application:theApplication]; [self observe:kAXMenuClosedNotification element:element observer:observer application:theApplication];
[self observe:kAXMenuItemSelectedNotification element:element observer:observer application:theApplication]; [self observe:kAXMenuItemSelectedNotification element:element observer:observer application:theApplication];
[self observe:kAXRowExpandedNotification element:element observer:observer application:theApplication]; [self observe:CFSTR("AXRowExpanded") element:element observer:observer application:theApplication];
[self observe:kAXRowCollapsedNotification element:element observer:observer application:theApplication]; [self observe:CFSTR("AXRowCollapsed") element:element observer:observer application:theApplication];
[self observe:kAXSelectedRowsChangedNotification element:element observer:observer application:theApplication]; [self observe:kAXSelectedRowsChangedNotification element:element observer:observer application:theApplication];
if (![[MGMSystemInfo info] isAfterSnowLeopard]) { if (![[MGMSystemInfo info] isAfterSnowLeopard]) {
[self observe:kAXApplicationHiddenNotification element:element observer:observer application:theApplication]; [self observe:kAXApplicationHiddenNotification element:element observer:observer application:theApplication];
@ -145,9 +145,9 @@ static void receivedNotification(AXObserverRef observer, AXUIElementRef element,
[[MGMController sharedController] startNotificationWithInfo:[NSDictionary dictionaryWithObjectsAndKeys:@"menuitemselected", MGMNName, @"Menu Item Selected", MGMNTitle, [NSString stringWithFormat:@"%@ in %@", (NSString *)title, [information objectForKey:(NSString *)kCFBundleNameKey]], MGMNDescription, [[NSWorkspace sharedWorkspace] iconForFile:[information objectForKey:MGMBundlePath]], MGMNIcon, nil]]; [[MGMController sharedController] startNotificationWithInfo:[NSDictionary dictionaryWithObjectsAndKeys:@"menuitemselected", MGMNName, @"Menu Item Selected", MGMNTitle, [NSString stringWithFormat:@"%@ in %@", (NSString *)title, [information objectForKey:(NSString *)kCFBundleNameKey]], MGMNDescription, [[NSWorkspace sharedWorkspace] iconForFile:[information objectForKey:MGMBundlePath]], MGMNIcon, nil]];
if (title!=NULL) if (title!=NULL)
CFRelease(title); CFRelease(title);
} else if ([theName isEqual:(NSString *)kAXRowExpandedNotification]) { } else if ([theName isEqual:@"AXRowExpanded"]) {
[[MGMController sharedController] startNotificationWithInfo:[NSDictionary dictionaryWithObjectsAndKeys:@"rowexpanded", MGMNName, @"Row Expanded", MGMNTitle, [information objectForKey:(NSString *)kCFBundleNameKey], MGMNDescription, [[NSWorkspace sharedWorkspace] iconForFile:[information objectForKey:MGMBundlePath]], MGMNIcon, nil]]; [[MGMController sharedController] startNotificationWithInfo:[NSDictionary dictionaryWithObjectsAndKeys:@"rowexpanded", MGMNName, @"Row Expanded", MGMNTitle, [information objectForKey:(NSString *)kCFBundleNameKey], MGMNDescription, [[NSWorkspace sharedWorkspace] iconForFile:[information objectForKey:MGMBundlePath]], MGMNIcon, nil]];
} else if ([theName isEqual:(NSString *)kAXRowCollapsedNotification]) { } else if ([theName isEqual:@"AXRowCollapsed"]) {
[[MGMController sharedController] startNotificationWithInfo:[NSDictionary dictionaryWithObjectsAndKeys:@"rowcollapsed", MGMNName, @"Row Collapsed", MGMNTitle, [information objectForKey:(NSString *)kCFBundleNameKey], MGMNDescription, [[NSWorkspace sharedWorkspace] iconForFile:[information objectForKey:MGMBundlePath]], MGMNIcon, nil]]; [[MGMController sharedController] startNotificationWithInfo:[NSDictionary dictionaryWithObjectsAndKeys:@"rowcollapsed", MGMNName, @"Row Collapsed", MGMNTitle, [information objectForKey:(NSString *)kCFBundleNameKey], MGMNDescription, [[NSWorkspace sharedWorkspace] iconForFile:[information objectForKey:MGMBundlePath]], MGMNIcon, nil]];
} else if ([theName isEqual:(NSString *)kAXSelectedRowsChangedNotification]) { } else if ([theName isEqual:(NSString *)kAXSelectedRowsChangedNotification]) {
[[MGMController sharedController] startNotificationWithInfo:[NSDictionary dictionaryWithObjectsAndKeys:@"selectedrowschanged", MGMNName, @"Selected Rows Changed", MGMNTitle, [information objectForKey:(NSString *)kCFBundleNameKey], MGMNDescription, [[NSWorkspace sharedWorkspace] iconForFile:[information objectForKey:MGMBundlePath]], MGMNIcon, nil]]; [[MGMController sharedController] startNotificationWithInfo:[NSDictionary dictionaryWithObjectsAndKeys:@"selectedrowschanged", MGMNName, @"Selected Rows Changed", MGMNTitle, [information objectForKey:(NSString *)kCFBundleNameKey], MGMNDescription, [[NSWorkspace sharedWorkspace] iconForFile:[information objectForKey:MGMBundlePath]], MGMNIcon, nil]];

View File

@ -27,6 +27,8 @@ OSStatus frontAppChanged(EventHandlerCallRef nextHandler, EventRef theEvent, voi
return (CallNextEventHandler(nextHandler, theEvent)); return (CallNextEventHandler(nextHandler, theEvent));
} }
@class NSRunningApplication;
@implementation MGMApplicationWatcher @implementation MGMApplicationWatcher
- (id)init { - (id)init {
if ((self = [super init])) { if ((self = [super init])) {

View File

@ -49,17 +49,6 @@ static NSString *nameForIOFW(io_object_t object) {
return @"Unnamed Device"; return @"Unnamed Device";
} }
static NSString *idForIOFW(io_object_t object) {
uint64_t ioDeviceID;
NSString *deviceID = nil;
kern_return_t result = IORegistryEntryGetRegistryEntryID(object, &ioDeviceID);
if (result==noErr)
deviceID = [NSString stringWithFormat:@"%11x", ioDeviceID];
if (deviceID!=nil)
return deviceID;
return @"Unknown ID";
}
@implementation MGMFireWireWatcher @implementation MGMFireWireWatcher
- (id)init { - (id)init {
@ -77,9 +66,9 @@ static NSString *idForIOFW(io_object_t object) {
NSLog(@"Unable to register for firewire add %d", result); NSLog(@"Unable to register for firewire add %d", result);
io_object_t object; io_object_t object;
while ((object = IOIteratorNext(found))) { while ((object = IOIteratorNext(found))) {
NSString *deviceID = idForIOFW(object); NSString *deviceName = nameForIOFW(object);
if (![firewireDevices containsObject:deviceID]) if (![firewireDevices containsObject:deviceName])
[firewireDevices addObject:deviceID]; [firewireDevices addObject:deviceName];
IOObjectRelease(object); IOObjectRelease(object);
} }
@ -89,9 +78,9 @@ static NSString *idForIOFW(io_object_t object) {
NSLog(@"Unable to register for firewire remove %d", result); NSLog(@"Unable to register for firewire remove %d", result);
else { else {
while ((object = IOIteratorNext(found))) { while ((object = IOIteratorNext(found))) {
NSString *deviceID = idForIOFW(object); NSString *deviceName = nameForIOFW(object);
if ([firewireDevices containsObject:deviceID]) if ([firewireDevices containsObject:deviceName])
[firewireDevices removeObject:deviceID]; [firewireDevices removeObject:deviceName];
IOObjectRelease(object); IOObjectRelease(object);
} }
} }
@ -108,17 +97,17 @@ static NSString *idForIOFW(io_object_t object) {
} }
- (void)firewireDeviceConnected:(io_object_t)theDevice { - (void)firewireDeviceConnected:(io_object_t)theDevice {
NSString *deviceID = idForIOFW(theDevice); NSString *deviceName = nameForIOFW(theDevice);
if (![firewireDevices containsObject:deviceID]) { if (![firewireDevices containsObject:deviceName]) {
[firewireDevices addObject:deviceID]; [firewireDevices addObject:deviceName];
[[MGMController sharedController] startNotificationWithInfo:[NSDictionary dictionaryWithObjectsAndKeys:@"firewireconnected", MGMNName, @"FireWire Connected", MGMNTitle, nameForIOFW(theDevice), MGMNDescription, [NSImage imageNamed:@"FireWire"], MGMNIcon, nil]]; [[MGMController sharedController] startNotificationWithInfo:[NSDictionary dictionaryWithObjectsAndKeys:@"firewireconnected", MGMNName, @"FireWire Connected", MGMNTitle, deviceName, MGMNDescription, [NSImage imageNamed:@"FireWire"], MGMNIcon, nil]];
} }
} }
- (void)firewireDeviceDisconnected:(io_object_t)theDevice { - (void)firewireDeviceDisconnected:(io_object_t)theDevice {
NSString *deviceID = idForIOFW(theDevice); NSString *deviceName = nameForIOFW(theDevice);
if ([firewireDevices containsObject:deviceID]) { if ([firewireDevices containsObject:deviceName]) {
[firewireDevices removeObject:deviceID]; [firewireDevices removeObject:deviceName];
[[MGMController sharedController] startNotificationWithInfo:[NSDictionary dictionaryWithObjectsAndKeys:@"firewiredisconnected", MGMNName, @"FireWire Disconnected", MGMNTitle, nameForIOFW(theDevice), MGMNDescription, [NSImage imageNamed:@"FireWire"], MGMNIcon, nil]]; [[MGMController sharedController] startNotificationWithInfo:[NSDictionary dictionaryWithObjectsAndKeys:@"firewiredisconnected", MGMNName, @"FireWire Disconnected", MGMNTitle, deviceName, MGMNDescription, [NSImage imageNamed:@"FireWire"], MGMNIcon, nil]];
} }
} }
@end @end

View File

@ -38,17 +38,6 @@ static NSString *nameForIOUSB(io_object_t object) {
return @"Unnamed Device"; return @"Unnamed Device";
} }
static NSString *idForIOUSB(io_object_t object) {
uint64_t ioDeviceID;
NSString *deviceID = nil;
kern_return_t result = IORegistryEntryGetRegistryEntryID(object, &ioDeviceID);
if (result==noErr)
deviceID = [NSString stringWithFormat:@"%11x", ioDeviceID];
if (deviceID!=nil)
return deviceID;
return @"Unknown ID";
}
@implementation MGMUSBWatcher @implementation MGMUSBWatcher
- (id)init { - (id)init {
@ -66,9 +55,9 @@ static NSString *idForIOUSB(io_object_t object) {
NSLog(@"Unable to register for usb add %d", result); NSLog(@"Unable to register for usb add %d", result);
io_object_t object; io_object_t object;
while ((object = IOIteratorNext(found))) { while ((object = IOIteratorNext(found))) {
NSString *deviceID = idForIOUSB(object); NSString *deviceName = nameForIOUSB(object);
if (![USBDevices containsObject:deviceID]) if (![USBDevices containsObject:deviceName])
[USBDevices addObject:deviceID]; [USBDevices addObject:deviceName];
IOObjectRelease(object); IOObjectRelease(object);
} }
@ -78,9 +67,9 @@ static NSString *idForIOUSB(io_object_t object) {
NSLog(@"Unable to register for usb remove %d", result); NSLog(@"Unable to register for usb remove %d", result);
else { else {
while ((object = IOIteratorNext(found))) { while ((object = IOIteratorNext(found))) {
NSString *deviceID = idForIOUSB(object); NSString *deviceName = nameForIOUSB(object);
if ([USBDevices containsObject:deviceID]) if ([USBDevices containsObject:deviceName])
[USBDevices removeObject:deviceID]; [USBDevices removeObject:deviceName];
IOObjectRelease(object); IOObjectRelease(object);
} }
} }
@ -97,17 +86,17 @@ static NSString *idForIOUSB(io_object_t object) {
} }
- (void)usbDeviceConnected:(io_object_t)theDevice { - (void)usbDeviceConnected:(io_object_t)theDevice {
NSString *deviceID = idForIOUSB(theDevice); NSString *deviceName = nameForIOUSB(theDevice);
if (![USBDevices containsObject:deviceID]) { if (![USBDevices containsObject:deviceName]) {
[USBDevices addObject:deviceID]; [USBDevices addObject:deviceName];
[[MGMController sharedController] startNotificationWithInfo:[NSDictionary dictionaryWithObjectsAndKeys:@"usbconnected", MGMNName, @"USB Connected", MGMNTitle, nameForIOUSB(theDevice), MGMNDescription, [NSImage imageNamed:@"USB"], MGMNIcon, nil]]; [[MGMController sharedController] startNotificationWithInfo:[NSDictionary dictionaryWithObjectsAndKeys:@"usbconnected", MGMNName, @"USB Connected", MGMNTitle, deviceName, MGMNDescription, [NSImage imageNamed:@"USB"], MGMNIcon, nil]];
} }
} }
- (void)usbDeviceDisconnected:(io_object_t)theDevice { - (void)usbDeviceDisconnected:(io_object_t)theDevice {
NSString *deviceID = idForIOUSB(theDevice); NSString *deviceName = nameForIOUSB(theDevice);
if ([USBDevices containsObject:deviceID]) { if ([USBDevices containsObject:deviceName]) {
[USBDevices removeObject:deviceID]; [USBDevices removeObject:deviceName];
[[MGMController sharedController] startNotificationWithInfo:[NSDictionary dictionaryWithObjectsAndKeys:@"usbdisconnected", MGMNName, @"USB Disconnected", MGMNTitle, nameForIOUSB(theDevice), MGMNDescription, [NSImage imageNamed:@"USB"], MGMNIcon, nil]]; [[MGMController sharedController] startNotificationWithInfo:[NSDictionary dictionaryWithObjectsAndKeys:@"usbdisconnected", MGMNName, @"USB Disconnected", MGMNTitle, deviceName, MGMNDescription, [NSImage imageNamed:@"USB"], MGMNIcon, nil]];
} }
} }
@end @end

View File

@ -19,13 +19,15 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>APPL</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>0.2</string> <string>0.2.1</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleURLTypes</key> <key>CFBundleURLTypes</key>
<array/> <array/>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>0.2</string> <string>0.2.1</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key> <key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string> <string>${MACOSX_DEPLOYMENT_TARGET}</string>
<key>LSUIElement</key> <key>LSUIElement</key>
@ -60,8 +62,6 @@
<string>dsa_pub.pem</string> <string>dsa_pub.pem</string>
<key>SUScheduledCheckInterval</key> <key>SUScheduledCheckInterval</key>
<integer>86400</integer> <integer>86400</integer>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>UTExportedTypeDeclarations</key> <key>UTExportedTypeDeclarations</key>
<array/> <array/>
<key>UTImportedTypeDeclarations</key> <key>UTImportedTypeDeclarations</key>

View File

@ -179,8 +179,8 @@
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */, 8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */,
2A34E62611E237380032F02E /* IOKit.framework in Frameworks */,
2A34E68911E241CA0032F02E /* SystemConfiguration.framework in Frameworks */, 2A34E68911E241CA0032F02E /* SystemConfiguration.framework in Frameworks */,
2A34E62611E237380032F02E /* IOKit.framework in Frameworks */,
2A34E7DC11E276C80032F02E /* IOBluetooth.framework in Frameworks */, 2A34E7DC11E276C80032F02E /* IOBluetooth.framework in Frameworks */,
2A34E89E11E286500032F02E /* GeckoReporter.framework in Frameworks */, 2A34E89E11E286500032F02E /* GeckoReporter.framework in Frameworks */,
2A34E89F11E286500032F02E /* Sparkle.framework in Frameworks */, 2A34E89F11E286500032F02E /* Sparkle.framework in Frameworks */,
@ -514,6 +514,7 @@
INSTALL_PATH = "$(HOME)/Applications"; INSTALL_PATH = "$(HOME)/Applications";
"MACOSX_DEPLOYMENT_TARGET[arch=x86_64]" = 10.5; "MACOSX_DEPLOYMENT_TARGET[arch=x86_64]" = 10.5;
PRODUCT_NAME = SoundNote; PRODUCT_NAME = SoundNote;
SDKROOT = macosx10.6;
}; };
name = Debug; name = Debug;
}; };
@ -533,6 +534,7 @@
INSTALL_PATH = "$(HOME)/Applications"; INSTALL_PATH = "$(HOME)/Applications";
"MACOSX_DEPLOYMENT_TARGET[arch=x86_64]" = 10.5; "MACOSX_DEPLOYMENT_TARGET[arch=x86_64]" = 10.5;
PRODUCT_NAME = SoundNote; PRODUCT_NAME = SoundNote;
SDKROOT = macosx10.6;
}; };
name = Release; name = Release;
}; };