*** empty log message ***

svn path=/trunk/boinc/; revision=4554
This commit is contained in:
Rom Walton 2004-11-14 08:29:32 +00:00
parent 028a2cd364
commit 369fe9f965
30 changed files with 212 additions and 158 deletions

View File

@ -34,7 +34,23 @@ BOOL win_loop_done;
static bool visible = true;
void KillWindow();
void KillWindow() {
wglMakeCurrent(NULL,NULL); // release GL rendering context
if (hRC) {
wglDeleteContext(hRC);
hRC=NULL;
}
if (hWnd && hDC) {
ReleaseDC(hWnd,hDC);
}
hDC = NULL;
if (hWnd) {
DestroyWindow(hWnd);
}
hWnd = NULL;
}
void SetupPixelFormat(HDC hDC) {
int nPixelFormat;
@ -125,24 +141,6 @@ static void make_new_window(int mode) {
app_graphics_init();
}
void KillWindow() {
wglMakeCurrent(NULL,NULL); // release GL rendering context
if (hRC) {
wglDeleteContext(hRC);
hRC=NULL;
}
if (hWnd && hDC) {
ReleaseDC(hWnd,hDC);
}
hDC = NULL;
if (hWnd) {
DestroyWindow(hWnd);
}
hWnd = NULL;
}
// switch to the given graphics mode. This is called:
// - on initialization
// - when get mode change msg (via shared mem)
@ -375,82 +373,3 @@ void win_graphics_event_loop() {
SetEvent(hQuitEvent); // Signal the worker thread that we're quitting
}
static inline bool osIsNT()
{
OSVERSIONINFO osv;
osv.dwOSVersionInfoSize = sizeof(osv);
GetVersionEx(&osv);
return (osv.dwPlatformId == VER_PLATFORM_WIN32_NT);
}
BOOL VerifyPassword(HWND hwnd)
{
// Under NT, we return TRUE immediately. This lets the saver quit, and the
// system manages passwords. Under '95, we call VerifyScreenSavePwd. This
// checks the appropriate registry key and, if necessary, pops up a verify
// dialog
if (osIsNT())
return TRUE;
HINSTANCE hpwdcpl=::LoadLibrary("PASSWORD.CPL");
if (hpwdcpl==NULL) return TRUE;
typedef BOOL (WINAPI *VERIFYSCREENSAVEPWD)(HWND hwnd);
VERIFYSCREENSAVEPWD VerifyScreenSavePwd;
VerifyScreenSavePwd =
(VERIFYSCREENSAVEPWD)GetProcAddress(hpwdcpl,"VerifyScreenSavePwd");
if (VerifyScreenSavePwd==NULL)
{
FreeLibrary(hpwdcpl);return TRUE;
}
BOOL bres = VerifyScreenSavePwd(hwnd);
FreeLibrary(hpwdcpl);
return bres;
}
#if 0
float txt_widths[256];
unsigned int MyCreateFont(char *fontName, int Size, int weight) {
// windows font
HFONT hFont;
unsigned int mylistbase =0;
// Create space for 96 characters.
mylistbase= glGenLists(256);
if(stricmp(fontName, "symbol")==0) {
hFont = CreateFont(
Size, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE,
SYMBOL_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS,
ANTIALIASED_QUALITY, FF_DONTCARE | DEFAULT_PITCH, fontName
);
} else {
hFont = CreateFont(
Size, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE,
ANSI_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS,
ANTIALIASED_QUALITY, FF_DONTCARE | DEFAULT_PITCH, fontName
);
}
if(!hFont) return -1;
SelectObject(myhDC, hFont);
#if 1 //no idea why this has to be twice
wglUseFontBitmaps(myhDC, 0, 256, mylistbase);
wglUseFontBitmaps(myhDC, 0, 256, mylistbase);
#endif
#if 0
wglUseFontOutlines(hDC,0,255,mylistbase,0.0f,0.2f,WGL_FONT_POLYGONS,gmf);
#endif
TEXTMETRIC met;
GetTextMetrics(myhDC,&met);
GetCharWidthFloat(myhDC,met.tmFirstChar,met.tmLastChar,txt_widths);
return mylistbase;
}
float get_char_width(unsigned char c) {
return txt_widths[c];
}
#endif

View File

@ -19384,3 +19384,23 @@ Bruce Allen 13 Nov 2004
db_ops.inc
profile.inc
db_action.inc
Rom 14 Nov 2004
- Updated the core screensaver code to use the GUI RPC's instead of passing
Window messages.
- Added two new GUI RPC's, set_screensaver_mode, and get_screensaver_mode.
- Added ID tags to the top of several files.
- Cleanup screensaver code
api/
windows_opengl.C
client/
gui_rpc_server.C
main.C
ss_logic.C
client/win/
boinc_ss.rc
win_screensaver.cpp, .h
win_util.cpp, .h
lib/
gui_rpc_client.C, .h

View File

@ -394,6 +394,24 @@ static void handle_get_host_info(char*, MIOFILE& fout) {
gstate.host_info.write(fout);
}
static void handle_get_screensaver_mode(char*, MIOFILE& fout) {
ACTIVE_TASK* atp = gstate.active_tasks.get_ss_app();
fout.printf("<screensaver_mode>\n");
if (atp) fout.printf(" <enabled/>\n");
fout.printf("</screensaver_mode>\n");
}
static void handle_set_screensaver_mode(char* buf, MIOFILE& fout) {
double blank_time = 0.0;
if (match_tag(buf, "<blank_time")) {
parse_double(buf, "<blank_time>", blank_time);
}
if (match_tag(buf, "<enabled")) {
gstate.ss_logic.start_ss( blank_time );
}
fout.printf("<success/>\n");
}
int GUI_RPC_CONN::handle_rpc() {
char request_msg[1024];
int n;
@ -480,6 +498,10 @@ int GUI_RPC_CONN::handle_rpc() {
handle_result_op(request_msg, mf, "resume");
} else if (match_tag(request_msg, "<get_host_info")) {
handle_get_host_info(request_msg, mf);
} else if (match_tag(request_msg, "<get_screensaver_mode")) {
handle_get_screensaver_mode(request_msg, mf);
} else if (match_tag(request_msg, "<set_screensaver_mode")) {
handle_set_screensaver_mode(request_msg, mf);
} else {
mf.printf("<error>unrecognized op</error>\n");
}

View File

@ -50,8 +50,6 @@
#include "main.h"
// dummies
void create_curtain(){}
void delete_curtain(){}
void guiOnBenchmarksBegin(){}
void guiOnBenchmarksEnd(){}

View File

@ -25,9 +25,6 @@
#include "client_msgs.h"
#include "ss_logic.h"
extern void create_curtain();
extern void delete_curtain();
SS_LOGIC::SS_LOGIC() {
do_ss = false;
do_boinc_logo_ss = false;
@ -49,7 +46,6 @@ void SS_LOGIC::start_ss(double new_blank_time) {
blank_time = new_blank_time;
gstate.active_tasks.save_app_modes();
gstate.active_tasks.hide_apps();
create_curtain();
if (!gstate.activities_suspended) {
atp = gstate.get_next_graphics_capable_app();
if (atp) {
@ -66,7 +62,6 @@ void SS_LOGIC::stop_ss() {
if (!do_ss) return;
reset();
do_ss = do_boinc_logo_ss = do_blank = false;
delete_curtain();
gstate.active_tasks.restore_apps();
}

View File

@ -136,7 +136,6 @@ BEGIN
"BOINC is not running.\n\nPlease launch BOINC to display graphics."
IDS_ERR_BOINCNOTDETECTEDSTARTUP
"BOINC is not running.\n(Automatic Startup not detected)\n\nWe recommend running BOINC at startup;\nplease reinstall BOINC and select this option."
IDS_ERR_BOINCNOTFOUND "Secure Windows Desktop Detected.\n\nYou must uncheck the password checkbox to\ndisplay the screensaver.\n\nThis will be fixed in an upcoming release."
IDS_ERR_OUTOFMEMORY "Not enough memory."
END

View File

@ -1,3 +1,5 @@
// $Id$
//
// The contents of this file are subject to the BOINC Public License
// Version 1.0 (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at
@ -42,9 +44,12 @@ static CScreensaver* gs_pScreensaver = NULL;
INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
HRESULT hr;
HRESULT hr;
int retval;
WSADATA wsdata;
CScreensaver BOINCSS;
#ifdef _DEBUG
// Initialize Diagnostics when compiled for debug
try {
@ -63,13 +68,30 @@ INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
}
#endif
retval = WSAStartup( MAKEWORD( 1, 1 ), &wsdata);
if (retval)
{
BOINCTRACE("WinMain - Winsock Initialization Failure '%d'", retval);
return retval;
}
if( FAILED( hr = BOINCSS.Create( hInstance ) ) )
{
BOINCSS.DisplayErrorMsg( hr );
WSACleanup();
return 0;
}
return BOINCSS.Run();
retval = BOINCSS.Run();
WSACleanup();
return retval;
}
@ -121,20 +143,17 @@ HRESULT CScreensaver::Create( HINSTANCE hInstance )
// Parse the command line and do the appropriate thing
m_SaverMode = ParseCommandLine( GetCommandLine() );
EnumMonitors();
// Figure out if we're on Win9x
OSVERSIONINFO osvi;
osvi.dwOSVersionInfoSize = sizeof(osvi);
GetVersionEx( &osvi );
m_bIs9x = (osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS);
// Initialize the RPC client
rpc.init( NULL );
// Register global messages
BOINC_SS_START_MSG = RegisterWindowMessage( START_SS_MSG );
BOINC_SS_STOP_MSG = RegisterWindowMessage( STOP_SS_MSG );
// Enumerate Monitors
EnumMonitors();
// Create the screen saver window(s)
@ -233,16 +252,12 @@ INT CScreensaver::Run()
//-----------------------------------------------------------------------------
VOID CScreensaver::StartupBOINC()
{
HWND hWnd;
HANDLE boinc_mutex;
bool bScreensaverEnabled;
if( m_SaverMode != sm_preview )
{
boinc_mutex = CreateMutex(NULL, false, RUN_MUTEX);
if(boinc_mutex != NULL && GetLastError() != ERROR_ALREADY_EXISTS)
if(rpc.get_screensaver_mode(bScreensaverEnabled) != 0)
{
CloseHandle(boinc_mutex);
// Create a screen saver window on the primary display if the boinc client crashes
CreateSaverWindow();
@ -261,29 +276,22 @@ VOID CScreensaver::StartupBOINC()
}
else
{
hWnd = FindWindow(TEXT("BOINCWindowClass"), NULL);
if(NULL == hWnd)
if( (NULL != m_Monitors[0].hWnd) && (m_bBOINCCoreNotified == FALSE) )
{
// Create a screen saver window on the primary display if the boinc client crashes
CreateSaverWindow();
DWORD blank_time;
int retval;
m_bErrorMode = TRUE;
m_hrError = SCRAPPERR_BOINCNOTFOUND;
// Retrieve the blank screen timeout
// make sure you check return value of registry queries
// in case the item in question doesn't happen to exist.
retval = UtilGetRegKey( REG_BLANK_TIME, blank_time );
if ( retval < 0 ) { blank_time=0; }
m_bBOINCCoreNotified = FALSE;
}
else
{
INTERNALMONITORINFO* pMonitorInfo;
pMonitorInfo = &m_Monitors[0];
if( (NULL != pMonitorInfo->hWnd) && (m_bBOINCCoreNotified == FALSE) )
{
// Tell the boinc client to start the screen saver
SendMessage(hWnd, BOINC_SS_START_MSG, NULL, NULL);
// Tell the boinc client to start the screen saver
rpc.set_screensaver_mode(true, blank_time);
// We have now notified the boinc client
m_bBOINCCoreNotified = TRUE;
}
// We have now notified the boinc client
m_bBOINCCoreNotified = TRUE;
}
}
}
@ -298,13 +306,13 @@ VOID CScreensaver::StartupBOINC()
//-----------------------------------------------------------------------------
VOID CScreensaver::ShutdownBOINC()
{
HWND hWnd;
if( m_bBOINCCoreNotified )
{
hWnd = FindWindow(TEXT("BOINCWindowClass"), NULL);
if(NULL != hWnd)
PostMessage(hWnd, BOINC_SS_STOP_MSG, NULL, NULL);
// Tell the boinc client to stop the screen saver
rpc.set_screensaver_mode(false, 0.0);
// We have now notified the boinc client
m_bBOINCCoreNotified = FALSE;
}
}
@ -570,8 +578,10 @@ HRESULT CScreensaver::CreateSaverWindow()
}
if( pMonitorInfo->hWnd == NULL )
return E_FAIL;
if( m_hWnd == NULL )
if( m_hWnd == NULL )
m_hWnd = pMonitorInfo->hWnd;
SetTimer(pMonitorInfo->hWnd, 2, 1000, NULL);
}
}
@ -757,7 +767,19 @@ LRESULT CScreensaver::PrimarySaverProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPA
}
else
{
StartupBOINC();
if (!m_bBOINCCoreNotified)
{
StartupBOINC();
}
else
{
bool bScreensaverEnabled = false;
rpc.get_screensaver_mode( bScreensaverEnabled );
if (!bScreensaverEnabled)
{
ShutdownSaver();
}
}
}
return 0;
}
@ -910,10 +932,6 @@ LRESULT CScreensaver::GenericSaverProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPA
{
UpdateErrorBox();
}
else
{
StartupBOINC();
}
return 0;
}
break;
@ -1227,7 +1245,6 @@ BOOL CScreensaver::GetTextForError( HRESULT hr, TCHAR* pszError,
E_OUTOFMEMORY, IDS_ERR_OUTOFMEMORY,
SCRAPPERR_BOINCNOTDETECTED, IDS_ERR_BOINCNOTDETECTED,
SCRAPPERR_BOINCNOTDETECTEDSTARTUP, IDS_ERR_BOINCNOTDETECTEDSTARTUP,
SCRAPPERR_BOINCNOTFOUND, IDS_ERR_BOINCNOTFOUND,
SCRAPPERR_NOPREVIEW, IDS_ERR_NOPREVIEW
};
const DWORD dwErrorMapSize = sizeof(dwErrorMap) / sizeof(DWORD[2]);
@ -1526,7 +1543,7 @@ BOOL CScreensaver::IsConfigStartupBOINC()
if (SUCCEEDED((pfnMySHGetFolderPath)(NULL, CSIDL_STARTUP|CSIDL_FLAG_CREATE, NULL, SHGFP_TYPE_CURRENT, szBuffer)))
{
BOINCTRACE(TEXT("IsConfigStartupBOINC: pfnMySHGetFolderPath - CSIDL_STARTUP - '%s'\n"), szBuffer);
if (SUCCEEDED(StringCchCatN(szBuffer, 512, TEXT("\\BOINC.lnk"), 10)))
if (SUCCEEDED(StringCchCatN(szBuffer, 512, TEXT("\\BOINC Manager.lnk"), 36)))
{
BOINCTRACE(TEXT("IsConfigStartupBOINC: Final pfnMySHGetFolderPath - CSIDL_STARTUP - '%s'\n"), szBuffer);
bCheckFileExists = TRUE;
@ -1572,7 +1589,7 @@ BOOL CScreensaver::IsConfigStartupBOINC()
if (SUCCEEDED((pfnMySHGetFolderPath)(NULL, CSIDL_COMMON_STARTUP|CSIDL_FLAG_CREATE, NULL, SHGFP_TYPE_CURRENT, szBuffer)))
{
BOINCTRACE(TEXT("IsConfigStartupBOINC: pfnMySHGetFolderPath - CSIDL_COMMON_STARTUP - '%s'\n"), szBuffer);
if (SUCCEEDED(StringCchCatN(szBuffer, 512, TEXT("\\BOINC.lnk"), 10)))
if (SUCCEEDED(StringCchCatN(szBuffer, 512, TEXT("\\BOINC Manager.lnk"), 36)))
{
BOINCTRACE(TEXT("IsConfigStartupBOINC: Final pfnMySHGetFolderPath - CSIDL_COMMON_STARTUP - '%s'\n"), szBuffer);
bCheckFileExists = TRUE;

View File

@ -1,3 +1,5 @@
// $Id$
//
// The contents of this file are subject to the BOINC Public License
// Version 1.0 (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at
@ -22,13 +24,15 @@
#ifndef _BOINC_H
#define _BOINC_H
#include "gui_rpc_client.h"
//-----------------------------------------------------------------------------
// Error codes
//-----------------------------------------------------------------------------
#define SCRAPPERR_BOINCNOTDETECTED 0x82000001
#define SCRAPPERR_BOINCNOTDETECTEDSTARTUP 0x82000002
#define SCRAPPERR_BOINCNOTFOUND 0x82000003
#define SCRAPPERR_NOPREVIEW 0x8200000f
@ -138,6 +142,8 @@ protected:
static INT_PTR CALLBACK ConfigureDialogProcStub( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
protected:
RPC_CLIENT rpc;
SaverMode m_SaverMode; // sm_config, sm_full, sm_preview, etc.
BOOL m_bAllScreensSame; // If TRUE, show same image on all screens
HWND m_hWnd; // Focus window and device window on primary
@ -168,7 +174,6 @@ protected:
BOOL m_bLogMessagePump;
// Global Messages
int BOINC_SS_START_MSG;
int BOINC_SS_STOP_MSG;
};

View File

@ -1,3 +1,5 @@
// $Id$
//
// The contents of this file are subject to the BOINC Public License
// Version 1.0 (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at

View File

@ -1,3 +1,5 @@
// $Id$
//
// The contents of this file are subject to the BOINC Public License
// Version 1.0 (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at

View File

@ -1,3 +1,5 @@
// $Id$
//
// The contents of this file are subject to the BOINC Public License
// Version 1.0 (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at

View File

@ -1,3 +1,5 @@
// $Id$
//
// The contents of this file are subject to the BOINC Public License
// Version 1.0 (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at

View File

@ -1,3 +1,5 @@
// $Id$
//
// The contents of this file are subject to the BOINC Public License
// Version 1.0 (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at

View File

@ -1,3 +1,5 @@
// $Id$
//
// The contents of this file are subject to the BOINC Public License
// Version 1.0 (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at

View File

@ -1,3 +1,5 @@
// $Id$
//
// The contents of this file are subject to the BOINC Public License
// Version 1.0 (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at

View File

@ -1,3 +1,5 @@
// $Id$
//
// The contents of this file are subject to the BOINC Public License
// Version 1.0 (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at

View File

@ -1,3 +1,5 @@
// $Id$
//
// The contents of this file are subject to the BOINC Public License
// Version 1.0 (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at

View File

@ -1,3 +1,5 @@
// $Id$
//
// The contents of this file are subject to the BOINC Public License
// Version 1.0 (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at
@ -1258,6 +1260,41 @@ int RPC_CLIENT::get_network_mode(int& mode) {
return 0;
}
int RPC_CLIENT::get_screensaver_mode(bool& enabled) {
char buf[256];
RPC rpc(this);
int retval;
retval = rpc.do_rpc("<get_screensaver_mode/>\n");
if (retval) return retval;
enabled = false;
while (rpc.fin.fgets(buf, 256)) {
if (match_tag(buf, "</screensaver_mode>")) break;
else if (match_tag(buf, "<enabled/>")) {
enabled = true;
continue;
}
}
return 0;
}
int RPC_CLIENT::set_screensaver_mode(bool enabled, double blank_time) {
char buf[256];
RPC rpc(this);
sprintf(buf,
"<set_screensaver_mode>\n"
" %s\n"
" <blank_time>%f</blank_time>\n"
"</set_screensaver_mode>\n",
enabled ? "<enabled/>" : "",
blank_time
);
return rpc.do_rpc(buf);
}
int RPC_CLIENT::run_benchmarks() {
RPC rpc(this);

View File

@ -1,3 +1,5 @@
// $Id$
//
// The contents of this file are subject to the BOINC Public License
// Version 1.0 (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at
@ -357,6 +359,8 @@ public:
int get_run_mode(int& mode);
int set_network_mode(int mode);
int get_network_mode(int& mode);
int get_screensaver_mode(bool& enabled);
int set_screensaver_mode(bool enabled, double blank_time);
int run_benchmarks();
int set_proxy_settings(PROXY_INFO&);
int get_proxy_settings(PROXY_INFO&);

View File

@ -1,3 +1,5 @@
// $Id$
//
// The contents of this file are subject to the BOINC Public License
// Version 1.0 (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at

View File

@ -1,3 +1,5 @@
// $Id$
//
// The contents of this file are subject to the BOINC Public License
// Version 1.0 (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at

View File

@ -1,3 +1,5 @@
// $Id$
//
// The contents of this file are subject to the BOINC Public License
// Version 1.0 (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at

View File

@ -1,3 +1,5 @@
// $Id$
//
// The contents of this file are subject to the BOINC Public License
// Version 1.0 (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at

View File

@ -1,3 +1,5 @@
// $Id$
//
// The contents of this file are subject to the BOINC Public License
// Version 1.0 (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at

View File

@ -1,3 +1,5 @@
// $Id$
//
// The contents of this file are subject to the BOINC Public License
// Version 1.0 (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at

View File

@ -1,3 +1,5 @@
// $Id$
//
/*////////////////////////////////////////////////////////////////////////////
* Project:
* Memory_and_Exception_Trace

View File

@ -1,3 +1,5 @@
// $Id$
//
/*////////////////////////////////////////////////////////////////////////////
* Project:
* Memory_and_Exception_Trace

View File

@ -1,3 +1,5 @@
// $Id$
//
// The contents of this file are subject to the BOINC Public License
// Version 1.0 (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at

View File

@ -1,3 +1,5 @@
// $Id$
//
// The contents of this file are subject to the BOINC Public License
// Version 1.0 (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at

View File

@ -1,3 +1,3 @@
#define BOINC_MAJOR_VERSION 4
#define BOINC_MINOR_VERSION 55
#define BOINC_VERSION_STRING "4.55"
#define BOINC_MINOR_VERSION 56
#define BOINC_VERSION_STRING "4.56"