Coder Social home page Coder Social logo

kglib's Introduction

##OSX/KGAppExperation.h

###@interface KGAppExperation : NSObject

Here's an example of how to block and quit an application that has expired:

- (void)applicationWillFinishLaunching:(NSNotification *)notification{
    NSInteger daysLeft = [KGAppExperation daysLeftUntilExpiration:14 withCompileTimeZone:[NSTimeZone timeZoneWithName:@"PST"]];
    NSLog(@"days left: %lu", daysLeft);

    if(daysLeft == 0){
        NSString *appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleName"];
        NSString *appVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"];

        NSLog(@"%@ %@ has expired", appName, appVersion);
        NSAlert *alert = [[NSAlert alloc] init];
        [alert addButtonWithTitle:@"OK"];
        [alert setMessageText:[NSString stringWithFormat:@"%@ has expired", appName]];
        [alert setInformativeText:[NSString stringWithFormat:@"The beta period for version %@ has expired.", appVersion]];
        [alert setAlertStyle:NSCriticalAlertStyle];
        [alert runModal];

        [NSApp terminate:self];
    }
}

Days left = compile day - current day <= expiration

The time zone should be set to the time zone the code was compiled in

+ (NSUInteger)daysLeftUntilExpiration:(NSUInteger)days withCompileTimeZone:(NSTimeZone *)timeZone;

##OSX/KGDivider.h

###@interface KGDivider : NSSplitView

###@interface KGDividerDelegate : NSObject

##OSX/KGGrowl.h

###@interface KGGrowl : NSObject

@property (strong, readonly) NSString *notification;
- (id)initWithNotification:(NSString *)newNotification;
- (void)displayMessage:(NSString *)message withTitle:(NSString *)title;

##OSX/KGLogin.h

###@interface KGLogin : NSObject

+ (NSURL *)appURL;
+ (BOOL)willStartAtLogin;
+ (BOOL)willStartAtLogin:(NSURL *)itemURL;
+ (void)setStartAtLogin:(BOOL)enabled;
+ (void)setStartAtLogin:(NSURL *)itemURL enabled:(BOOL)enabled;

##OSX/KGMenuBarPopup.h

###@interface KGMenuBarPopup : NSObject

@property (nonatomic, strong) NSString *title;
@property (nonatomic, strong) NSImage *image;
@property (nonatomic, strong) NSImage *alternateImage;
@property (nonatomic) CGFloat width;
- (id)initWithWidth:(CGFloat)width view:(NSView *)view;
- (id)initWithWidth:(CGFloat)width view:(NSView *)view offset:(CGFloat)offset;
- (void)hideView;
- (void)centerView;

##OSX/KGPasteboard.h

###@interface KGPasteboard : NSObject

The general use pasteboard

+ (NSString *)generalPasteBoardString;

Copy a strig to the general pasteboard

+ (void)copyString:(NSString *)string;

Copy a string to the general pasteboard and html to the general html pasteboard

+ (void)copyString:(NSString *)string andHTML:(NSString *)html;

##OSX/KGPopUpButtonImageCell.h

###@interface KGPopUpButtonImageCell : NSPopUpButtonCell

##OSX/KGProcess.h

###@interface KGProcess : NSObject

Transform the process into a forground application

+ (void)transformToForegroundApplication;

Set the application as the front most one

+ (void)setApplicationFront;

##OSX/KGRatingView.h

###@interface KGRatingView : NSView

@property (nonatomic, getter=isEnabled) BOOL enabled;
@property (nonatomic) BOOL allowHalfRating;
@property (nonatomic) NSUInteger rating;
@property (nonatomic) NSTimeInterval hoverDelay;
- (void)setRatingChangedCallback:(KGRatingViewCallback)block;

##OSX/KGURLHandler.h

###@interface KGURLHandler : NSObject

+ (id)handlerWithScheme:(NSString *)scheme andIdentifier:(NSString *)identifier;
- (id)initWithScheme:(NSString *)scheme andIdentifier:(NSString *)identifier;
- (void)registerDefaultAction:(KGURLHandlerAction)action;
- (void)registerCommandPath:(NSString *)path withAction:(KGURLHandlerAction)action;

##OSX/ScriptingBridge/KGFinder.h

###@interface KGFinder : NSObject {}

+ (FinderApplication *)finder;
+ (NSString *)activeFinderWindowURL;
+ (NSArray *)selectedFinderURLs;

##OSX/ScriptingBridge/KGTerminal.h

###@interface KGTerminal : NSObject

+ (NSString *)appId;
+ (TerminalApplication *)terminal;
+ (NSString *)escapePath:(NSString*)path;
+ (void)shellTo:(NSString *)path;
+ (void)shellTo:(NSString *)path clear:(BOOL)clear additionalCommand:(NSString *)additionalCommand;
+ (void)runCommand:(NSString *)command;

##Shared/KGFoundation.h

##Shared/KGImageCache.h

###@interface KGImageCache : NSObject

- (id)initWithCapacity:(NSUInteger)capacity;
- (void)retainKey:(id)key;
- (BOOL)didLoad:(id)key;
- (void)setDidLoad:(id)key;
- (KGImageCacheImage *)imageForKey:(id)key;
- (void)setImage:(KGImageCacheImage *)image forKey:(id)key;
- (void)releaseKey:(id)key;
- (void)removeKey:(id)key;

##Shared/KGKeychain.h

###@interface KGKeychain : NSObject

+ (BOOL)passwordExistsForService:(NSString *)serviceName andAccount:(NSString *)accountName;
+ (BOOL)setPassword:(NSString *)password forService:(NSString *)serviceName andAccount:(NSString *)accountName;
+ (NSString *)passwordForService:(NSString *)serviceName andAccount:(NSString *)accountName;
+ (BOOL)removeEntryForService:(NSString *)serviceName andAccount:(NSString *)accountName;

##Shared/KGXPath.h

##Shared/NSArray+KG.h

###@interface NSArray(KG)

Return the first object in the array

- (id)firstObject;

Return the first n objects in the array

- (NSArray *)firstObjects:(NSUInteger)count;

Return the last n objects in the array

- (NSArray *)lastObjects:(NSUInteger)count;

##Shared/NSDictionary+KGJSON.h

###@interface NSDictionary(KGJSON)

- (NSUInteger)uintSafelyFromKey:(id)key;
- (NSString *)stringSafelyFromKey:(id)key;
- (NSURL *)URLSafelyFromKey:(id)key;
- (id)objectSafelyFromKey:(id)key;

##Shared/NSMutableAttributedString+KG.h

###@interface NSMutableAttributedString(KG)

- (NSRange)replaceString:(NSString *)src withString:(NSString *)dst;
- (void)replaceString:(NSString *)src withString:(NSString *)dst andAttributes:(NSDictionary *)attributes;
- (void)replaceString:(NSString *)src withString:(NSString *)dst andLink:(NSURL *)url withTooltip:(NSString *)tooltip;
- (void)addTextShadow:(NSShadow *)shadow;

##Shared/NSString+KGFile.h

###@interface NSString(KGFile)

Return a valid filename

- (NSString *)validFilename;

Return a valid filename, if allowHidden is YES then periods will be allows as the first character

- (NSString *)validFilenameAllowHidden:(BOOL)allowHidden;

Transform a path into it's true mount path, or return nil

Example: /Volumes/slave1 -> afp://Slave%20One/slave1

- (NSString *)volumeMountURLWithError:(NSError **)error;

##Shared/NSString+KGHTTP.h

###@interface NSString(KGHTTP)

Encode a dictionary into a url string.

Example: {name:'David Keegan', age:26} -> name=David%20Keegan&age=26

+ (NSString *)urlEncodedStringForArgs:(NSDictionary *)args;

URL encode a string, this encodes more characters than [NSString stringByAddingPercentEscapesUsingEncoding:]

- (NSString *)stringWithURLEncoding;

kglib's People

Contributors

kgn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

kglib's Issues

Mount code doesn't work on SL if compiled on Lion

I think what we need to do is do a runtime check

if(floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6){ // TODO: remove with hard coded value
    if(![[NSURL fileURLWithPath:self] getResourceValue:&volURL 
                                                forKey:NSURLVolumeURLForRemountingKey // TODO: replace with hard coded value
                                                 error:error]){
        return nil;
    }
}else{
    FSRef pathRef;
    FSPathMakeRef((UInt8*)[self fileSystemRepresentation], &pathRef, NULL);
    FSCatalogInfo catalogInfo;
    OSErr osErr = FSGetCatalogInfo(&pathRef, kFSCatInfoVolume, &catalogInfo, NULL, NULL, NULL);
    FSVolumeRefNum volumeRefNum = 0;
    if(osErr == noErr){
        volumeRefNum = catalogInfo.volume;
    }
    CFURLRef serverLocation;
    OSStatus result = FSCopyURLForVolume(volumeRefNum, &serverLocation);
    if(result == noErr){
        volURL = (NSURL *)serverLocation;
    }else{
        return nil;
    }   
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.