diff --git a/clientscr/Mac_Saver_Module.h b/clientscr/Mac_Saver_Module.h index 49e2f4fdd6..3ebd9ea39c 100644 --- a/clientscr/Mac_Saver_Module.h +++ b/clientscr/Mac_Saver_Module.h @@ -86,7 +86,6 @@ protected: int GetBrandID(void); char* PersistentFGets(char *buf, size_t buflen, FILE *f); pid_t FindProcessPID(char* name, pid_t thePID); - OSErr GetpathToBOINCManagerApp(char* path, int maxLen); bool SetError( bool bErrorMode, unsigned int hrError ); void setSSMessageText(const char *msg); void updateSSMessageText(char *msg); diff --git a/clientscr/Mac_Saver_ModuleView.h b/clientscr/Mac_Saver_ModuleView.h index 3adfeced3a..4eac285204 100644 --- a/clientscr/Mac_Saver_ModuleView.h +++ b/clientscr/Mac_Saver_ModuleView.h @@ -38,6 +38,8 @@ NSString *mChangePeriodString; } +@property (strong) NSArray *NIBTopLevel; + - (IBAction)closeSheetSave:(id) sender; - (IBAction)closeSheetCancel:(id) sender; diff --git a/clientscr/Mac_Saver_ModuleView.m b/clientscr/Mac_Saver_ModuleView.m index 9f1afac10e..99983f5545 100644 --- a/clientscr/Mac_Saver_ModuleView.m +++ b/clientscr/Mac_Saver_ModuleView.m @@ -27,6 +27,7 @@ #include #include #include +#include "mac_util.h" #ifndef NSInteger #if __LP64__ || NS_BUILD_32_LIKE_64 @@ -40,8 +41,6 @@ typedef int NSInteger; typedef float CGFloat; #endif -static int compareOSVersionTo(int toMajor, int toMinor); - void print_to_log_file(const char *format, ...); void strip_cr(char *buf); @@ -507,8 +506,24 @@ int signof(float x) { int period; // if we haven't loaded our configure sheet, load the nib named MyScreenSaver.nib - if (!mConfigureSheet) - [ NSBundle loadNibNamed:@"BOINCSaver" owner:self ]; + if (!mConfigureSheet) { + if (! [NSBundle respondsToSelector: @selector(loadNibNamed: owner: topLevelObjects:)]) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wobjc-method-access" + // [NSBundle loadNibNamed: owner: topLevelObjects:] is not available before OS 10.8 + [ NSBundle loadNibNamed:@"BOINCSaver" owner:self topLevelObjects:&_NIBTopLevel ]; +#pragma clang diagnostic pop + } +#if __MAC_OS_X_VERSION_MIN_REQUIRED < 1080 + else { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + // [NSBundle loadNibNamed: owner:] is deprecated in OS 10.8 + [ NSBundle loadNibNamed:@"BOINCSaver" owner:self ]; +#pragma clang diagnostic pop + } +#endif + } // set the UI state [ mGoToBlankCheckbox setState:gGoToBlank ]; @@ -604,27 +619,3 @@ Bad: } @end - - -static int compareOSVersionTo(int toMajor, int toMinor) { - SInt32 major, minor; - OSStatus err = noErr; - - err = Gestalt(gestaltSystemVersionMajor, &major); - if (err != noErr) { - fprintf(stderr, "Gestalt(gestaltSystemVersionMajor) returned error %ld\n", (long)err); - fflush(stderr); - return -1; // gestaltSystemVersionMajor selector was not available before OS 10.4 - } - if (major < toMajor) return -1; - if (major > toMajor) return 1; - err = Gestalt(gestaltSystemVersionMinor, &minor); - if (err != noErr) { - fprintf(stderr, "Gestalt(gestaltSystemVersionMinor) returned error %ld\n", (long)err); - fflush(stderr); - return -1; // gestaltSystemVersionMajor selector was not available before OS 10.4 - } - if (minor < toMinor) return -1; - if (minor > toMinor) return 1; - return 0; -} diff --git a/clientscr/mac_saver_module.cpp b/clientscr/mac_saver_module.cpp index 06430a667e..963e2de1ed 100644 --- a/clientscr/mac_saver_module.cpp +++ b/clientscr/mac_saver_module.cpp @@ -51,6 +51,7 @@ extern "C" { #include "screensaver.h" #include "diagnostics.h" #include "str_replace.h" +#include "mac_util.h" //#include @@ -388,7 +389,7 @@ OSStatus CScreensaver::initBOINCApp() { // If not at default path, search for it by creator code and bundle identifier if (!boinc_file_exists(boincPath)) { - err = GetpathToBOINCManagerApp(boincPath, sizeof(boincPath)); + err = GetPathToAppFromID('BNC!', CFSTR("edu.berkeley.boinc"), boincPath, sizeof(boincPath)); if (err) { saverState = SaverState_CantLaunchCoreClient; return err; @@ -810,7 +811,7 @@ int CScreensaver::GetBrandID() if (f == NULL) { // If we couldn't find our Branding file in the BOINC Data Directory, // look in our application bundle - err = GetpathToBOINCManagerApp(buf, sizeof(buf)); + err = GetPathToAppFromID('BNC!', CFSTR("edu.berkeley.boinc"), buf, sizeof(buf)); if (err == noErr) { strcat(buf, "/Contents/Resources/Branding"); f = fopen(buf, "r"); @@ -880,27 +881,6 @@ pid_t CScreensaver::FindProcessPID(char* name, pid_t thePID) } -OSErr CScreensaver::GetpathToBOINCManagerApp(char* path, int maxLen) -{ - CFStringRef bundleID = CFSTR("edu.berkeley.boinc"); - OSType creator = 'BNC!'; - CFURLRef appURL = NULL; - OSStatus status = noErr; - - status = LSFindApplicationForInfo(creator, bundleID, NULL, NULL, &appURL); - if (status == noErr) { - CFStringRef CFPath = CFURLCopyFileSystemPath(appURL, kCFURLPOSIXPathStyle); - CFStringGetCString(CFPath, path, maxLen, kCFStringEncodingUTF8); - CFRelease(CFPath); - } - if (appURL) { - CFRelease(appURL); - } - - return status; -} - - // Send a Quit AppleEvent to the process which called this module // (i.e., tell the ScreenSaver engine to quit) OSErr CScreensaver::KillScreenSaver() {