// Copyright GreenKeeper Software 2005 #import "StartupController.h" #import "ClientState.h" #import "Preferences.h" #import "BOINCController.h" @implementation StartupController - (void)awakeFromNib { [super init]; // Makes sure a BOINC Data directory exists; creates one if not NSString *homeBDPath = [[Preferences prefs] objectForKey:@"boincDataDirectory"]; NSString *rootBDPath = @"/Library/Application Support/BOINC Data/"; BOOL cbdExists = NO; BOOL rbdExists = NO; [[NSFileManager defaultManager] fileExistsAtPath:homeBDPath isDirectory:&cbdExists]; [[NSFileManager defaultManager] fileExistsAtPath:rootBDPath isDirectory:&rbdExists]; if(!cbdExists && !rbdExists) [[NSFileManager defaultManager] createDirectoryAtPath:homeBDPath attributes:nil]; else if(!cbdExists && rbdExists) { [[Preferences prefs] setObject:rootBDPath forKey:@"boincDataDirectory"]; [[Preferences prefs] setBool:YES forKey:@"shareData"]; } // Prevents freezing caused when BOINC Menubar is started automatically at login and then hidden [NSApp unhide]; // If there are no projects, guide the user through setup if(![[[ClientState clientState] projects] count]) [self firstLaunch]; // If the preferences indicate the user wants to start BOINC at application startup, do so if([[Preferences prefs] boolForKey:@"startBoincOnAppLaunch"]) [BOINCController startBOINC]; } // Displays a welcome and recommends viewing the help - (void)firstLaunch { [NSApp activateIgnoringOtherApps:YES]; NSString *message = @"Welcome to BOINC Menubar!"; NSString *informativeText = @"Before you start, it is recommended that you take a moment to read the built-in Help.\n\nAt the very least, please take a quick look at the \"Getting Started\" section.\n\nWould you like to view the built-in Help at this time.\n"; int choice = NSRunAlertPanel(message, informativeText, @"Yes", @"No", nil); // User wishes to view the help if (choice == NSAlertDefaultReturn) { [NSApp showHelp:self]; } } @end