2003-06-11 23:36:48 +00:00
|
|
|
// The contents of this file are subject to the BOINC Public License
|
2003-05-15 17:10:26 +00:00
|
|
|
// 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
|
2003-06-11 23:36:48 +00:00
|
|
|
// http://boinc.berkeley.edu/license_1.0.txt
|
2003-05-15 17:10:26 +00:00
|
|
|
//
|
|
|
|
// Software distributed under the License is distributed on an "AS IS"
|
|
|
|
// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
|
|
|
// License for the specific language governing rights and limitations
|
|
|
|
// under the License.
|
|
|
|
//
|
|
|
|
// The Original Code is the Berkeley Open Infrastructure for Network Computing.
|
|
|
|
//
|
|
|
|
// The Initial Developer of the Original Code is the SETI@home project.
|
|
|
|
// Portions created by the SETI@home project are Copyright (C) 2002
|
|
|
|
// University of California at Berkeley. All Rights Reserved.
|
|
|
|
//
|
|
|
|
// Contributor(s):
|
|
|
|
//
|
|
|
|
|
2004-03-05 04:37:53 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
#include "stdafx.h"
|
|
|
|
#endif
|
2003-05-08 18:11:05 +00:00
|
|
|
|
2004-03-05 04:37:53 +00:00
|
|
|
#include "client_state.h"
|
2003-05-08 18:11:05 +00:00
|
|
|
#include "ss_logic.h"
|
|
|
|
|
|
|
|
extern void create_curtain();
|
|
|
|
extern void delete_curtain();
|
|
|
|
|
|
|
|
SS_LOGIC::SS_LOGIC() {
|
|
|
|
do_ss = false;
|
|
|
|
do_boinc_logo_ss = false;
|
|
|
|
do_blank = false;
|
|
|
|
blank_time = 0;
|
|
|
|
ack_deadline = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// this is called when the core client receives a message
|
|
|
|
// from the screensaver module.
|
|
|
|
//
|
|
|
|
void SS_LOGIC::start_ss(time_t new_blank_time) {
|
|
|
|
ACTIVE_TASK* atp;
|
|
|
|
|
|
|
|
if (do_ss) return;
|
|
|
|
do_ss = true;
|
|
|
|
do_blank = do_boinc_logo_ss = false;
|
2003-05-12 17:44:40 +00:00
|
|
|
strcpy(ss_msg, "");
|
2003-05-08 18:11:05 +00:00
|
|
|
blank_time = new_blank_time;
|
|
|
|
gstate.active_tasks.save_app_modes();
|
|
|
|
gstate.active_tasks.hide_apps();
|
|
|
|
create_curtain();
|
2004-05-03 23:35:45 +00:00
|
|
|
if (!gstate.activities_suspended) {
|
|
|
|
atp = gstate.active_tasks.get_graphics_capable_app();
|
|
|
|
if (atp) {
|
|
|
|
atp->request_graphics_mode(MODE_FULLSCREEN);
|
|
|
|
ack_deadline = time(0) + 5;
|
|
|
|
} else {
|
|
|
|
do_boinc_logo_ss = true;
|
|
|
|
}
|
2003-05-08 18:11:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SS_LOGIC::stop_ss() {
|
2003-05-09 20:33:57 +00:00
|
|
|
if (!do_ss) return;
|
2003-05-08 18:11:05 +00:00
|
|
|
do_ss = do_boinc_logo_ss = do_blank = false;
|
|
|
|
delete_curtain();
|
|
|
|
gstate.active_tasks.restore_apps();
|
|
|
|
}
|
|
|
|
|
2003-05-09 00:00:39 +00:00
|
|
|
|
2003-05-08 18:11:05 +00:00
|
|
|
// called every second
|
|
|
|
//
|
|
|
|
void SS_LOGIC::poll() {
|
|
|
|
ACTIVE_TASK* atp;
|
|
|
|
|
2004-05-03 23:35:45 +00:00
|
|
|
if (!gstate.activities_suspended) {
|
2003-05-09 00:00:39 +00:00
|
|
|
|
2004-05-03 23:35:45 +00:00
|
|
|
gstate.active_tasks.check_graphics_mode_ack();
|
|
|
|
|
|
|
|
if (do_ss) {
|
|
|
|
if (blank_time && (time(0) > blank_time)) {
|
|
|
|
if (!do_blank) {
|
|
|
|
atp = gstate.active_tasks.get_app_requested(MODE_FULLSCREEN);
|
|
|
|
if (atp) {
|
|
|
|
atp->request_graphics_mode(MODE_HIDE_GRAPHICS);
|
2003-05-09 20:33:57 +00:00
|
|
|
}
|
2004-05-03 23:35:45 +00:00
|
|
|
do_blank = true;
|
2003-05-08 18:11:05 +00:00
|
|
|
}
|
2004-05-03 23:35:45 +00:00
|
|
|
do_boinc_logo_ss = false;
|
|
|
|
strcpy(ss_msg, "");
|
2003-05-08 18:11:05 +00:00
|
|
|
} else {
|
2004-05-03 23:35:45 +00:00
|
|
|
atp = gstate.active_tasks.get_app_requested(MODE_FULLSCREEN);
|
2003-05-08 18:11:05 +00:00
|
|
|
if (atp) {
|
2004-05-03 23:35:45 +00:00
|
|
|
if (atp->graphics_acked_mode == MODE_FULLSCREEN) {
|
|
|
|
do_boinc_logo_ss = false;
|
|
|
|
strcpy(ss_msg, "");
|
|
|
|
} else {
|
|
|
|
if (time(0)>ack_deadline) {
|
|
|
|
do_boinc_logo_ss = true;
|
|
|
|
strcpy(ss_msg, "App can't display graphics");
|
|
|
|
}
|
|
|
|
}
|
2003-05-08 18:11:05 +00:00
|
|
|
} else {
|
2004-05-03 23:35:45 +00:00
|
|
|
atp = gstate.active_tasks.get_graphics_capable_app();
|
|
|
|
if (atp) {
|
|
|
|
atp->request_graphics_mode(MODE_FULLSCREEN);
|
|
|
|
ack_deadline = time(0) + 5;
|
|
|
|
} else {
|
|
|
|
do_boinc_logo_ss = true;
|
|
|
|
strcpy(ss_msg, "No work available");
|
|
|
|
}
|
2003-05-08 18:11:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-05-03 23:35:45 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
do_boinc_logo_ss = true;
|
|
|
|
strcpy(ss_msg, "App can't display graphics, BOINC Suspended");
|
|
|
|
}
|
2003-05-08 18:11:05 +00:00
|
|
|
}
|