From: Jer Noble Date: Tue, 30 Oct 2012 16:28:31 +0000 (-0700) Subject: Added the BetterAway extension. X-Git-Url: http://id.pley.net/textual_plugins.git/commitdiff_plain/dcd01c6bf0c465bd35c3a938b4041a61d67ca101 Added the BetterAway extension. --- dcd01c6bf0c465bd35c3a938b4041a61d67ca101 diff --git a/BetterAway/BetterAway Extension.xcodeproj/project.pbxproj b/BetterAway/BetterAway Extension.xcodeproj/project.pbxproj new file mode 100644 index 0000000..b14aa8f --- /dev/null +++ b/BetterAway/BetterAway Extension.xcodeproj/project.pbxproj @@ -0,0 +1,286 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + CDCB39BB15B9C981005149B3 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CDCB39BA15B9C981005149B3 /* Cocoa.framework */; }; + CDCB39C515B9C981005149B3 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = CDCB39C315B9C981005149B3 /* InfoPlist.strings */; }; + CDCB39CE15B9CA2A005149B3 /* TPIBetterAway.m in Sources */ = {isa = PBXBuildFile; fileRef = CDCB39CD15B9CA2A005149B3 /* TPIBetterAway.m */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + CDCB39B715B9C981005149B3 /* BetterAway.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = BetterAway.bundle; sourceTree = BUILT_PRODUCTS_DIR; }; + CDCB39BA15B9C981005149B3 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; }; + CDCB39BD15B9C981005149B3 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; }; + CDCB39BE15B9C981005149B3 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; }; + CDCB39BF15B9C981005149B3 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + CDCB39C215B9C981005149B3 /* BetterAway-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "BetterAway-Info.plist"; sourceTree = ""; }; + CDCB39C415B9C981005149B3 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; + CDCB39C615B9C981005149B3 /* BetterAway-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "BetterAway-Prefix.pch"; sourceTree = ""; }; + CDCB39CC15B9CA2A005149B3 /* TPIBetterAway.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TPIBetterAway.h; path = BetterAway/TPIBetterAway.h; sourceTree = ""; }; + CDCB39CD15B9CA2A005149B3 /* TPIBetterAway.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TPIBetterAway.m; path = BetterAway/TPIBetterAway.m; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + CDCB39B415B9C981005149B3 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + CDCB39BB15B9C981005149B3 /* Cocoa.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + CDCB39AC15B9C981005149B3 = { + isa = PBXGroup; + children = ( + CDCB39CF15B9CA31005149B3 /* Classes */, + CDCB39C015B9C981005149B3 /* BetterAway */, + CDCB39B915B9C981005149B3 /* Frameworks */, + CDCB39B815B9C981005149B3 /* Products */, + ); + sourceTree = ""; + }; + CDCB39B815B9C981005149B3 /* Products */ = { + isa = PBXGroup; + children = ( + CDCB39B715B9C981005149B3 /* BetterAway.bundle */, + ); + name = Products; + sourceTree = ""; + }; + CDCB39B915B9C981005149B3 /* Frameworks */ = { + isa = PBXGroup; + children = ( + CDCB39BA15B9C981005149B3 /* Cocoa.framework */, + CDCB39BC15B9C981005149B3 /* Other Frameworks */, + ); + name = Frameworks; + sourceTree = ""; + }; + CDCB39BC15B9C981005149B3 /* Other Frameworks */ = { + isa = PBXGroup; + children = ( + CDCB39BD15B9C981005149B3 /* AppKit.framework */, + CDCB39BE15B9C981005149B3 /* CoreData.framework */, + CDCB39BF15B9C981005149B3 /* Foundation.framework */, + ); + name = "Other Frameworks"; + sourceTree = ""; + }; + CDCB39C015B9C981005149B3 /* BetterAway */ = { + isa = PBXGroup; + children = ( + CDCB39C115B9C981005149B3 /* Supporting Files */, + ); + path = BetterAway; + sourceTree = ""; + }; + CDCB39C115B9C981005149B3 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + CDCB39C215B9C981005149B3 /* BetterAway-Info.plist */, + CDCB39C315B9C981005149B3 /* InfoPlist.strings */, + CDCB39C615B9C981005149B3 /* BetterAway-Prefix.pch */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + CDCB39CF15B9CA31005149B3 /* Classes */ = { + isa = PBXGroup; + children = ( + CDCB39CC15B9CA2A005149B3 /* TPIBetterAway.h */, + CDCB39CD15B9CA2A005149B3 /* TPIBetterAway.m */, + ); + name = Classes; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + CDCB39B615B9C981005149B3 /* BetterAway */ = { + isa = PBXNativeTarget; + buildConfigurationList = CDCB39C915B9C981005149B3 /* Build configuration list for PBXNativeTarget "BetterAway" */; + buildPhases = ( + CDCB39B315B9C981005149B3 /* Sources */, + CDCB39B415B9C981005149B3 /* Frameworks */, + CDCB39B515B9C981005149B3 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = BetterAway; + productName = BetterAway; + productReference = CDCB39B715B9C981005149B3 /* BetterAway.bundle */; + productType = "com.apple.product-type.bundle"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + CDCB39AE15B9C981005149B3 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0450; + ORGANIZATIONNAME = "Jer Noble"; + }; + buildConfigurationList = CDCB39B115B9C981005149B3 /* Build configuration list for PBXProject "BetterAway Extension" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = CDCB39AC15B9C981005149B3; + productRefGroup = CDCB39B815B9C981005149B3 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + CDCB39B615B9C981005149B3 /* BetterAway */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + CDCB39B515B9C981005149B3 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + CDCB39C515B9C981005149B3 /* InfoPlist.strings in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + CDCB39B315B9C981005149B3 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + CDCB39CE15B9CA2A005149B3 /* TPIBetterAway.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + CDCB39C315B9C981005149B3 /* InfoPlist.strings */ = { + isa = PBXVariantGroup; + children = ( + CDCB39C415B9C981005149B3 /* en */, + ); + name = InfoPlist.strings; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + CDCB39C715B9C981005149B3 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + FRAMEWORK_SEARCH_PATHS = "\"${PROJECT_DIR}/../../Frameworks/**\""; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = "\"${PROJECT_DIR}/../../Classes/Headers/**\""; + MACOSX_DEPLOYMENT_TARGET = 10.8; + ONLY_ACTIVE_ARCH = NO; + SDKROOT = ""; + }; + name = Debug; + }; + CDCB39C815B9C981005149B3 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + FRAMEWORK_SEARCH_PATHS = "\"${PROJECT_DIR}/../../Frameworks/**\""; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = "\"${PROJECT_DIR}/../../Classes/Headers/**\""; + MACOSX_DEPLOYMENT_TARGET = 10.8; + SDKROOT = ""; + }; + name = Release; + }; + CDCB39CA15B9C981005149B3 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + COMBINE_HIDPI_IMAGES = YES; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "BetterAway/BetterAway-Prefix.pch"; + INFOPLIST_FILE = "BetterAway/BetterAway-Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Bundles"; + PRODUCT_NAME = "$(TARGET_NAME)"; + WRAPPER_EXTENSION = bundle; + }; + name = Debug; + }; + CDCB39CB15B9C981005149B3 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + COMBINE_HIDPI_IMAGES = YES; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "BetterAway/BetterAway-Prefix.pch"; + INFOPLIST_FILE = "BetterAway/BetterAway-Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Bundles"; + PRODUCT_NAME = "$(TARGET_NAME)"; + WRAPPER_EXTENSION = bundle; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + CDCB39B115B9C981005149B3 /* Build configuration list for PBXProject "BetterAway Extension" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + CDCB39C715B9C981005149B3 /* Debug */, + CDCB39C815B9C981005149B3 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + CDCB39C915B9C981005149B3 /* Build configuration list for PBXNativeTarget "BetterAway" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + CDCB39CA15B9C981005149B3 /* Debug */, + CDCB39CB15B9C981005149B3 /* Release */, + ); + defaultConfigurationIsVisible = 0; + }; +/* End XCConfigurationList section */ + }; + rootObject = CDCB39AE15B9C981005149B3 /* Project object */; +} diff --git a/BetterAway/BetterAway/BetterAway-Info.plist b/BetterAway/BetterAway/BetterAway-Info.plist new file mode 100644 index 0000000..3c9f664 --- /dev/null +++ b/BetterAway/BetterAway/BetterAway-Info.plist @@ -0,0 +1,30 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIconFile + + CFBundleIdentifier + com.apple.${PRODUCT_NAME:rfc1034identifier} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + NSHumanReadableCopyright + Copyright © 2012 Jer Noble. All rights reserved. + NSPrincipalClass + TPIBetterAway + + diff --git a/BetterAway/BetterAway/BetterAway-Prefix.pch b/BetterAway/BetterAway/BetterAway-Prefix.pch new file mode 100644 index 0000000..b5d13da --- /dev/null +++ b/BetterAway/BetterAway/BetterAway-Prefix.pch @@ -0,0 +1,7 @@ +// +// Prefix header for all source files of the 'BetterAway' target in the 'BetterAway' project +// + +#ifdef __OBJC__ + #import +#endif diff --git a/BetterAway/BetterAway/TPIBetterAway.h b/BetterAway/BetterAway/TPIBetterAway.h new file mode 100644 index 0000000..7a67c34 --- /dev/null +++ b/BetterAway/BetterAway/TPIBetterAway.h @@ -0,0 +1,29 @@ +// +// BetterAway.h +// BetterAway Extension +// +// Created by Jer Noble on 7/20/12. +// Copyright (c) 2012 Jer Noble. All rights reserved. +// + +#import "TextualApplication.h" + +#import + +@interface TPIBetterAway : NSObject { + IRCWorld* _world; + NSString* _idleSuffix; +} + +@property (retain) NSString* idleSuffix; + +- (void)pluginLoadedIntoMemory:(IRCWorld *)world; +- (void)pluginUnloadedFromMemory; + +- (NSArray *)pluginSupportsUserInputCommands; + +- (void)messageSentByUser:(IRCClient *)client + message:(NSString *)messageString + command:(NSString *)commandString; + +@end diff --git a/BetterAway/BetterAway/TPIBetterAway.m b/BetterAway/BetterAway/TPIBetterAway.m new file mode 100644 index 0000000..e9c1b8e --- /dev/null +++ b/BetterAway/BetterAway/TPIBetterAway.m @@ -0,0 +1,85 @@ +// +// BetterAway.m +// BetterAway Extension +// +// Created by Jer Noble on 7/20/12. +// Copyright (c) 2012 Jer Noble. All rights reserved. +// + +#import "TPIBetterAway.h" +#import + +static NSString* kBetterAwayIdleSuffix = @"BetterIdleIdleSuffix"; +static NSString* kBetterAwayIdleCommand = @"betteraway"; + +@implementation TPIBetterAway + +#pragma mark -- Initialization -- +- (void)pluginLoadedIntoMemory:(IRCWorld *)world +{ + _world = world; + [[NSUserDefaults standardUserDefaults] registerDefaults:@{ kBetterAwayIdleSuffix: @"afk"}]; + _idleSuffix = [[[NSUserDefaults standardUserDefaults] stringForKey:kBetterAwayIdleSuffix] retain]; + NSNotificationCenter* nc = [[NSWorkspace sharedWorkspace] notificationCenter]; + [nc addObserver:self selector:@selector(onDisplaySleep:) name:NSWorkspaceScreensDidSleepNotification object:nil]; + [nc addObserver:self selector:@selector(onDisplayWake:) name:NSWorkspaceScreensDidSleepNotification object:nil]; +} + +- (void)pluginUnloadedFromMemory +{ + [[[NSWorkspace sharedWorkspace] notificationCenter] removeObserver:self]; + _world = nil; +} + +#pragma mark -- Properties -- +@dynamic idleSuffix; +- (NSString*)idleSuffix +{ + return _idleSuffix; +} + +- (void)setIdleSuffix:(NSString*)idleSuffix +{ + [idleSuffix retain]; + [_idleSuffix release]; + _idleSuffix = idleSuffix; + [[NSUserDefaults standardUserDefaults] setObject:idleSuffix forKey:kBetterAwayIdleSuffix]; +} + +#pragma mark -- NSWorkspace Notifications -- + +- (void)onDisplaySleep:(id)sender +{ + for (IRCClient* client in _world.clients) + [client changeNick:[NSString stringWithFormat:@"%@|%@", client.config.nick, [self idleSuffix]]]; +} + +- (void)onDisplayWake:(id)sender +{ + for (IRCClient* client in _world.clients) + [client changeNick:client.config.nick]; +} + +#pragma mark -- Plugin API -- +- (NSArray *)pluginSupportsUserInputCommands +{ + return @[ kBetterAwayIdleCommand ]; +} + +- (void)messageSentByUser:(IRCClient *)client + message:(NSString *)messageString + command:(NSString *)commandString +{ + if ([[commandString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] isEqualTo:kBetterAwayIdleCommand]) { + NSString* idleSuffix = [messageString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; + if (![idleSuffix length]) + [client printBoth:client.world.selectedChannel type:TVCLogLineSystemType text:[@"Idle suffix is currently " stringByAppendingString:[self idleSuffix]]]; + else { + [self setIdleSuffix:idleSuffix]; + [client printBoth:client.world.selectedChannel type:TVCLogLineSystemType text:[@"Set idle suffix to " stringByAppendingString:idleSuffix]]; + } + } +} + +@end + diff --git a/BetterAway/BetterAway/en.lproj/InfoPlist.strings b/BetterAway/BetterAway/en.lproj/InfoPlist.strings new file mode 100644 index 0000000..477b28f --- /dev/null +++ b/BetterAway/BetterAway/en.lproj/InfoPlist.strings @@ -0,0 +1,2 @@ +/* Localized versions of Info.plist keys */ +