2007-10-05 13:28:11 +00:00
|
|
|
// Berkeley Open Infrastructure for Network Computing
|
|
|
|
// http://boinc.berkeley.edu
|
|
|
|
// Copyright (C) 2005 University of California
|
|
|
|
//
|
|
|
|
// This 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 2.1 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This software is distributed in the hope that it will be useful,
|
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
// To view the GNU Lesser General Public License visit
|
|
|
|
// http://www.gnu.org/copyleft/lesser.html
|
|
|
|
// or write to the Free Software Foundation, Inc.,
|
2007-10-09 11:35:47 +00:00
|
|
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int initBOINCSaver(Boolean ispreview);
|
2008-02-19 13:26:26 +00:00
|
|
|
int getSSMessage(char **theMessage);
|
|
|
|
void drawPreview(CGContextRef myContext);
|
2007-10-05 13:28:11 +00:00
|
|
|
void closeBOINCSaver(void);
|
2008-02-14 12:26:13 +00:00
|
|
|
void print_to_log_file(const char *format, ...);
|
|
|
|
void strip_cr(char *buf);
|
2007-10-05 13:28:11 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
} // extern "C"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// 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-01-30 02:47:06 +00:00
|
|
|
void UpdateProgressText(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);
|
|
|
|
char m_gfx_Switcher_Path[MAXPATHLEN];
|
|
|
|
bool m_bErrorMode; // Whether to display an error
|
|
|
|
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_iStatusUpdateCounter;
|
|
|
|
int m_iGraphicsStartingMsgCounter;
|
2008-02-19 13:26:26 +00:00
|
|
|
int m_iLastResultShown;
|
|
|
|
int m_tLastResultChangeCounter;
|
2007-10-09 10:00:53 +00:00
|
|
|
bool m_StatusMessageUpdated;
|
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 );
|
|
|
|
int terminate_screensaver(int& graphics_application, RESULT *worker_app);
|
|
|
|
int launch_screensaver(RESULT* rp, int& graphics_application);
|
|
|
|
void HandleRPCError(void);
|
|
|
|
OSErr KillScreenSaver(void);
|
|
|
|
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);
|
|
|
|
|
|
|
|
// Choose a ramdom graphics application from the vector that
|
|
|
|
// was passed in.
|
|
|
|
|
|
|
|
RESULT* get_random_graphics_app(RESULTS& results, RESULT* exclude = NULL);
|
|
|
|
|
|
|
|
RPC_CLIENT *rpc;
|
|
|
|
CC_STATE state;
|
|
|
|
RESULTS results;
|
|
|
|
RESULT m_running_result;
|
|
|
|
bool m_updating_results;
|
|
|
|
|
|
|
|
bool m_bResetCoreState;
|
|
|
|
bool m_QuitDataManagementProc;
|
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:
|
|
|
|
char m_MsgBuf[2048];
|
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-19 13:26:26 +00:00
|
|
|
int getSSMessage(char **theMessage);
|
|
|
|
void drawPreview(CGContextRef myContext);
|
2007-10-05 13:28:11 +00:00
|
|
|
void ShutdownSaver();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|