Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

73 lines (60 sloc) 1.77 kb
//
// mongoPref.m
// mongodb.prefpane
//
// Created by Iv‡n ValdŽs Castillo on 4/12/10.
// Copyright (c) 2010 Iv‡n ValdŽs Castillo, released under the MIT license
//
#import "mongoPref.h"
#import "MBSliderButton.h"
#import "DaemonController.h"
@implementation mongoPref
@synthesize theSlider;
@synthesize theArguments;
- (void) mainViewDidLoad;
{
dC = [[DaemonController alloc] initWithDelegate:self andArguments:[theArguments stringValue]];
[theSlider setState:[dC isRunning] ? NSOnState : NSOffState];
preferences = [[NSUserDefaults standardUserDefaults] retain];
preferencesDict = [NSDictionary dictionaryWithObjectsAndKeys:@"", @"arguments", nil];
[preferences registerDefaults:preferencesDict];
[theArguments setStringValue:[preferences objectForKey:@"arguments"]];
}
- (void) daemonStopped;
{
[theSlider setState:NSOffState animate:YES];
}
- (void) daemonStarted;
{
[theSlider setState:NSOnState animate:YES];
}
- (void) dealloc;
{
[dC release];
[preferences release];
[preferencesDict release];
[super dealloc];
}
- (IBAction) startStopDaemon:(id)sender;
{
if (![dC locateBinary]) {
[NSAlert alertWithMessageText:@"Cannot locate mongod :("
defaultButton:@"Ok"
alternateButton:nil
otherButton:nil
informativeTextWithFormat:@"Please make sure you have the mongod binary either in /usr/local/bin, /usr/bin, /bin, or /opt/bin"];
[theSlider setState:NSOffState];
return;
}
if (theSlider.state == NSOffState) {
[dC stop];
} else {
[dC setArguments:[theArguments stringValue]];
[dC start];
}
}
- (IBAction) changeArguments:(id)sender;
{
[preferences setObject:[theArguments stringValue] forKey:@"arguments"];
}
@end
Jump to Line
Something went wrong with that request. Please try again.