2008-08-06 18:36:30 +00:00
|
|
|
// This file is part of BOINC.
|
2007-10-05 13:28:11 +00:00
|
|
|
// http://boinc.berkeley.edu
|
2008-08-06 18:36:30 +00:00
|
|
|
// Copyright (C) 2008 University of California
|
2007-10-05 13:28:11 +00:00
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// BOINC is free software; you can redistribute it and/or modify it
|
|
|
|
// under the terms of the GNU Lesser General Public License
|
|
|
|
// as published by the Free Software Foundation,
|
|
|
|
// either version 3 of the License, or (at your option) any later version.
|
2007-10-05 13:28:11 +00:00
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// BOINC is distributed in the hope that it will be useful,
|
2007-10-05 13:28:11 +00:00
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
// See the GNU Lesser General Public License for more details.
|
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
2007-10-05 13:28:11 +00:00
|
|
|
|
|
|
|
// Mac_Saver_Module.h
|
|
|
|
// BOINC_Saver_Module
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef _SCREENSAVER_MAC_H
|
|
|
|
#define _SCREENSAVER_MAC_H
|
|
|
|
|
|
|
|
#include <Carbon/Carbon.h>
|
|
|
|
|
2008-09-05 02:47:10 +00:00
|
|
|
#ifdef _DEBUG
|
|
|
|
#define _T(x) x
|
|
|
|
#endif
|
2007-10-05 13:28:11 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2009-12-14 13:10:49 +00:00
|
|
|
void initBOINCSaver(void);
|
|
|
|
int startBOINCSaver(void);
|
|
|
|
int getSSMessage(char **theMessage, int* coveredFreq);
|
|
|
|
void windowIsCovered();
|
|
|
|
void drawPreview(CGContextRef myContext);
|
|
|
|
void closeBOINCSaver(void);
|
|
|
|
void setDefaultDisplayPeriods(void);
|
|
|
|
bool getShow_default_ss_first();
|
|
|
|
double getGFXDefaultPeriod();
|
|
|
|
double getGFXSciencePeriod();
|
|
|
|
double getGGFXChangePeriod();
|
|
|
|
bool validateNumericString(CFStringRef s);
|
|
|
|
void setShow_default_ss_first(bool value);
|
|
|
|
void setGFXDefaultPeriod(double value);
|
|
|
|
void setGFXSciencePeriod(double value);
|
|
|
|
void setGGFXChangePeriod(double value);
|
2011-07-27 11:42:22 +00:00
|
|
|
double getDTime();
|
2009-12-14 13:10:49 +00:00
|
|
|
void print_to_log_file(const char *format, ...);
|
|
|
|
void strip_cr(char *buf);
|
|
|
|
void PrintBacktrace(void);
|
2007-10-05 13:28:11 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
} // extern "C"
|
|
|
|
#endif
|
|
|
|
|
2009-12-14 13:10:49 +00:00
|
|
|
struct ss_periods
|
|
|
|
{
|
|
|
|
double GFXDefaultPeriod;
|
|
|
|
double GFXSciencePeriod;
|
|
|
|
double GFXChangePeriod;
|
|
|
|
bool Show_default_ss_first;
|
|
|
|
};
|
2007-10-05 13:28:11 +00:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Name: class CScreensaver
|
|
|
|
// Desc: Screensaver class
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
class CScreensaver
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CScreensaver();
|
|
|
|
|
|
|
|
int Create();
|
|
|
|
int Run();
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Infrastructure layer
|
|
|
|
//
|
|
|
|
protected:
|
|
|
|
OSStatus initBOINCApp(void);
|
|
|
|
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);
|
2007-10-09 10:00:53 +00:00
|
|
|
bool SetError( bool bErrorMode, unsigned int hrError );
|
2008-02-19 13:26:26 +00:00
|
|
|
void setSSMessageText(const char *msg);
|
|
|
|
void updateSSMessageText(char *msg);
|
2007-10-05 13:28:11 +00:00
|
|
|
void strip_cr(char *buf);
|
2009-12-04 14:39:35 +00:00
|
|
|
char m_gfx_Switcher_Path[PATH_MAX];
|
2013-05-29 13:11:14 +00:00
|
|
|
void SetDiscreteGPU(bool setDiscrete);
|
|
|
|
void CheckDualGPUStatus();
|
|
|
|
bool Host_is_running_on_batteries();
|
|
|
|
|
2009-02-27 11:20:08 +00:00
|
|
|
bool m_bErrorMode; // Whether to draw moving logo and possibly display an error
|
2007-10-05 13:28:11 +00:00
|
|
|
unsigned int m_hrError; // Error code to display
|
|
|
|
|
|
|
|
bool m_wasAlreadyRunning;
|
|
|
|
pid_t m_CoreClientPID;
|
|
|
|
int m_dwBlankScreen;
|
|
|
|
time_t m_dwBlankTime;
|
2008-02-26 01:53:36 +00:00
|
|
|
int m_iGraphicsStartingMsgCounter;
|
2009-02-06 02:17:45 +00:00
|
|
|
bool m_bDefault_ss_exists;
|
2009-02-10 12:35:12 +00:00
|
|
|
bool m_bScience_gfx_running;
|
|
|
|
bool m_bDefault_gfx_running;
|
2009-02-20 11:49:49 +00:00
|
|
|
bool m_bConnected;
|
2007-10-05 13:28:11 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Data management layer
|
|
|
|
//
|
|
|
|
protected:
|
|
|
|
bool CreateDataManagementThread();
|
2007-10-09 10:00:53 +00:00
|
|
|
bool DestroyDataManagementThread();
|
2007-10-05 13:28:11 +00:00
|
|
|
|
|
|
|
void* DataManagementProc();
|
|
|
|
static void* DataManagementProcStub( void* param );
|
2009-04-15 08:28:51 +00:00
|
|
|
int terminate_v6_screensaver(int& graphics_application);
|
2007-10-05 13:28:11 +00:00
|
|
|
int terminate_screensaver(int& graphics_application, RESULT *worker_app);
|
2009-04-02 10:25:16 +00:00
|
|
|
int terminate_default_screensaver(int& graphics_application);
|
2007-10-05 13:28:11 +00:00
|
|
|
int launch_screensaver(RESULT* rp, int& graphics_application);
|
2009-02-05 12:32:16 +00:00
|
|
|
int launch_default_screensaver(char *dir_path, int& graphics_application);
|
2007-10-05 13:28:11 +00:00
|
|
|
void HandleRPCError(void);
|
|
|
|
OSErr KillScreenSaver(void);
|
2009-12-14 13:10:49 +00:00
|
|
|
void GetDefaultDisplayPeriods(struct ss_periods &periods);
|
2009-02-20 11:49:49 +00:00
|
|
|
bool HasProcessExited(pid_t pid, int &exitCode);
|
2007-10-05 13:28:11 +00:00
|
|
|
pthread_t m_hDataManagementThread;
|
|
|
|
pid_t m_hGraphicsApplication;
|
|
|
|
|
|
|
|
// Determine if two RESULT pointers refer to the same task
|
|
|
|
bool is_same_task(RESULT* taska, RESULT* taskb);
|
|
|
|
|
|
|
|
// Count the number of active graphics-capable apps
|
|
|
|
int count_active_graphic_apps(RESULTS& results, RESULT* exclude = NULL);
|
|
|
|
|
2009-02-20 11:49:49 +00:00
|
|
|
// Choose a random graphics application from the vector that
|
2007-10-05 13:28:11 +00:00
|
|
|
// was passed in.
|
|
|
|
|
|
|
|
RESULT* get_random_graphics_app(RESULTS& results, RESULT* exclude = NULL);
|
|
|
|
|
|
|
|
RPC_CLIENT *rpc;
|
|
|
|
CC_STATE state;
|
|
|
|
RESULTS results;
|
2009-02-27 11:20:08 +00:00
|
|
|
|
2007-10-05 13:28:11 +00:00
|
|
|
bool m_bResetCoreState;
|
2011-03-14 18:58:04 +00:00
|
|
|
bool m_bQuitDataManagementProc;
|
|
|
|
bool m_bDataManagementProcStopped;
|
2008-01-30 02:47:06 +00:00
|
|
|
bool m_bV5_GFX_app_is_running;
|
2007-10-05 13:28:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Presentation layer
|
|
|
|
//
|
|
|
|
protected:
|
2008-02-19 13:26:26 +00:00
|
|
|
char m_MessageText[2048];
|
2008-02-14 12:26:13 +00:00
|
|
|
char* m_CurrentBannerMessage;
|
2007-10-05 13:28:11 +00:00
|
|
|
char* m_BrandText;
|
|
|
|
public:
|
2008-02-27 03:21:46 +00:00
|
|
|
int getSSMessage(char **theMessage, int* coveredFreq);
|
2009-02-27 11:20:08 +00:00
|
|
|
void windowIsCovered(void);
|
2008-02-19 13:26:26 +00:00
|
|
|
void drawPreview(CGContextRef myContext);
|
2007-10-05 13:28:11 +00:00
|
|
|
void ShutdownSaver();
|
|
|
|
|
2009-12-14 13:10:49 +00:00
|
|
|
double m_fGFXDefaultPeriod;
|
|
|
|
double m_fGFXSciencePeriod;
|
|
|
|
double m_fGFXChangePeriod;
|
|
|
|
bool m_bShow_default_ss_first;
|
|
|
|
|
2007-10-05 13:28:11 +00:00
|
|
|
protected:
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|