2005-01-20 23:22:22 +00:00
|
|
|
// Berkeley Open Infrastructure for Network Computing
|
|
|
|
// http://boinc.berkeley.edu
|
|
|
|
// Copyright (C) 2005 University of California
|
2004-07-13 10:36:18 +00:00
|
|
|
//
|
2005-01-20 23:22:22 +00:00
|
|
|
// 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.
|
2004-07-13 10:36:18 +00:00
|
|
|
//
|
2005-01-20 23:22:22 +00:00
|
|
|
// 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.
|
2003-10-18 19:35:58 +00:00
|
|
|
//
|
2005-01-20 23:22:22 +00:00
|
|
|
// To view the GNU Lesser General Public License visit
|
|
|
|
// http://www.gnu.org/copyleft/lesser.html
|
|
|
|
// or write to the Free Software Foundation, Inc.,
|
|
|
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2003-10-18 19:35:58 +00:00
|
|
|
|
2004-03-05 04:37:53 +00:00
|
|
|
#ifdef _WIN32
|
2004-06-16 23:16:08 +00:00
|
|
|
#include "boinc_win.h"
|
2005-11-21 18:34:44 +00:00
|
|
|
#else
|
|
|
|
#include "config.h"
|
2004-03-05 04:37:53 +00:00
|
|
|
#endif
|
|
|
|
|
2003-10-18 19:35:58 +00:00
|
|
|
#include "parse.h"
|
2007-02-21 16:26:51 +00:00
|
|
|
#include "str_util.h"
|
2007-02-21 17:06:11 +00:00
|
|
|
#include "util.h"
|
2003-10-18 19:35:58 +00:00
|
|
|
#include "error_numbers.h"
|
|
|
|
#include "filesys.h"
|
|
|
|
#include "file_names.h"
|
2004-04-08 08:15:23 +00:00
|
|
|
#include "client_msgs.h"
|
2003-10-18 19:35:58 +00:00
|
|
|
#include "client_state.h"
|
2007-07-10 09:01:07 +00:00
|
|
|
#ifdef __APPLE__
|
|
|
|
#include <cerrno>
|
|
|
|
#endif
|
2003-10-18 19:35:58 +00:00
|
|
|
|
2005-02-16 23:17:43 +00:00
|
|
|
void CLIENT_STATE::set_client_state_dirty(const char* source) {
|
2006-06-22 19:40:30 +00:00
|
|
|
if (log_flags.state_debug) {
|
2006-09-07 20:39:25 +00:00
|
|
|
msg_printf(0, MSG_INFO, "[state_debug] set dirty: %s\n", source);
|
2006-06-22 19:40:30 +00:00
|
|
|
}
|
2003-11-02 22:51:49 +00:00
|
|
|
client_state_dirty = true;
|
|
|
|
}
|
|
|
|
|
2006-02-06 21:03:36 +00:00
|
|
|
static bool valid_state_file(const char* fname) {
|
2006-02-01 07:04:24 +00:00
|
|
|
char buf[256];
|
|
|
|
FILE* f = boinc_fopen(fname, "r");
|
|
|
|
if (!f) return false;
|
2007-03-04 02:30:48 +00:00
|
|
|
if (!fgets(buf, 256, f)) {
|
|
|
|
fclose(f);
|
|
|
|
return false;
|
|
|
|
}
|
2006-02-01 07:04:24 +00:00
|
|
|
if (!match_tag(buf, "<client_state>")) {
|
|
|
|
fclose(f);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
while (fgets(buf, 256, f)) {
|
|
|
|
if (match_tag(buf, "</client_state>")) {
|
|
|
|
fclose(f);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fclose(f);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2003-10-18 19:35:58 +00:00
|
|
|
// Parse the client_state.xml file
|
|
|
|
//
|
|
|
|
int CLIENT_STATE::parse_state_file() {
|
2004-08-12 11:57:51 +00:00
|
|
|
PROJECT *project=NULL;
|
2006-02-01 07:04:24 +00:00
|
|
|
char buf[256];
|
2003-10-18 19:35:58 +00:00
|
|
|
int retval=0;
|
|
|
|
int failnum;
|
2005-02-16 23:17:43 +00:00
|
|
|
const char *fname;
|
2003-10-18 19:35:58 +00:00
|
|
|
|
2004-09-21 19:58:30 +00:00
|
|
|
// Look for a valid state file:
|
|
|
|
// First the regular one, then the "next" one.
|
|
|
|
//
|
2006-02-01 07:04:24 +00:00
|
|
|
if (valid_state_file(STATE_FILE_NEXT)) {
|
2004-09-21 19:58:30 +00:00
|
|
|
fname = STATE_FILE_NEXT;
|
2006-02-01 07:04:24 +00:00
|
|
|
} else if (valid_state_file(STATE_FILE_NAME)) {
|
|
|
|
fname = STATE_FILE_NAME;
|
2006-02-02 20:46:37 +00:00
|
|
|
} else if (valid_state_file(STATE_FILE_PREV)) {
|
2006-02-01 07:04:24 +00:00
|
|
|
fname = STATE_FILE_PREV;
|
2004-09-21 19:58:30 +00:00
|
|
|
} else {
|
2006-06-22 19:40:30 +00:00
|
|
|
if (log_flags.state_debug) {
|
|
|
|
msg_printf(0, MSG_INFO,
|
2006-09-07 20:39:25 +00:00
|
|
|
"[state_debug] CLIENT_STATE::parse_state_file(): No state file; will create one"
|
2006-06-22 19:40:30 +00:00
|
|
|
);
|
|
|
|
}
|
2003-10-18 19:35:58 +00:00
|
|
|
|
|
|
|
// avoid warning messages about version
|
|
|
|
//
|
2004-07-13 10:36:18 +00:00
|
|
|
old_major_version = BOINC_MAJOR_VERSION;
|
|
|
|
old_minor_version = BOINC_MINOR_VERSION;
|
2005-09-01 19:27:04 +00:00
|
|
|
old_release = BOINC_RELEASE;
|
2003-10-18 19:35:58 +00:00
|
|
|
return ERR_FOPEN;
|
|
|
|
}
|
2004-03-01 19:11:12 +00:00
|
|
|
|
2004-09-21 19:58:30 +00:00
|
|
|
FILE* f = fopen(fname, "r");
|
2004-06-12 04:45:36 +00:00
|
|
|
MIOFILE mf;
|
|
|
|
mf.init_file(f);
|
2003-10-18 19:35:58 +00:00
|
|
|
while (fgets(buf, 256, f)) {
|
|
|
|
if (match_tag(buf, "</client_state>")) {
|
2006-02-01 07:04:24 +00:00
|
|
|
break;
|
2007-06-11 18:34:26 +00:00
|
|
|
}
|
|
|
|
if (match_tag(buf, "<client_state>")) {
|
2006-07-11 22:52:17 +00:00
|
|
|
continue;
|
2007-06-11 18:34:26 +00:00
|
|
|
}
|
|
|
|
if (match_tag(buf, "<project>")) {
|
2004-08-12 11:57:51 +00:00
|
|
|
PROJECT temp_project;
|
|
|
|
retval = temp_project.parse_state(mf);
|
|
|
|
if (retval) {
|
2007-01-25 23:39:06 +00:00
|
|
|
msg_printf(NULL, MSG_INTERNAL_ERROR, "Can't parse project in state file");
|
2003-10-18 19:35:58 +00:00
|
|
|
} else {
|
2004-08-12 11:57:51 +00:00
|
|
|
project = lookup_project(temp_project.master_url);
|
|
|
|
if (project) {
|
|
|
|
project->copy_state_fields(temp_project);
|
|
|
|
} else {
|
2007-01-25 23:39:06 +00:00
|
|
|
msg_printf(&temp_project, MSG_INTERNAL_ERROR,
|
2004-09-22 21:08:26 +00:00
|
|
|
"Project %s is in state file but no account file found",
|
2004-08-12 11:57:51 +00:00
|
|
|
temp_project.get_project_name()
|
|
|
|
);
|
|
|
|
}
|
2003-10-18 19:35:58 +00:00
|
|
|
}
|
2007-06-11 18:34:26 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (match_tag(buf, "<app>")) {
|
2003-10-18 19:35:58 +00:00
|
|
|
APP* app = new APP;
|
2004-08-12 11:57:51 +00:00
|
|
|
retval = app->parse(mf);
|
2006-07-20 22:02:29 +00:00
|
|
|
if (!project) {
|
2007-01-25 23:39:06 +00:00
|
|
|
msg_printf(NULL, MSG_INTERNAL_ERROR,
|
2006-07-20 22:02:29 +00:00
|
|
|
"Application %s outside project in state file",
|
|
|
|
app->name
|
|
|
|
);
|
|
|
|
delete app;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (project->anonymous_platform) {
|
2005-07-26 11:55:28 +00:00
|
|
|
delete app;
|
|
|
|
continue;
|
|
|
|
}
|
2004-08-12 11:57:51 +00:00
|
|
|
if (retval) {
|
2007-01-25 23:39:06 +00:00
|
|
|
msg_printf(NULL, MSG_INTERNAL_ERROR,
|
2006-01-17 22:48:09 +00:00
|
|
|
"Can't parse application in state file"
|
|
|
|
);
|
2003-10-18 19:35:58 +00:00
|
|
|
delete app;
|
2006-07-20 22:02:29 +00:00
|
|
|
continue;
|
2003-10-18 19:35:58 +00:00
|
|
|
}
|
2006-07-20 22:02:29 +00:00
|
|
|
retval = link_app(project, app);
|
|
|
|
if (retval) {
|
2007-01-25 23:39:06 +00:00
|
|
|
msg_printf(project, MSG_INTERNAL_ERROR,
|
2006-07-20 22:02:29 +00:00
|
|
|
"Can't handle application %s in state file",
|
|
|
|
app->name
|
|
|
|
);
|
|
|
|
delete app;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
apps.push_back(app);
|
2007-06-11 18:34:26 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (match_tag(buf, "<file_info>")) {
|
2003-10-18 19:35:58 +00:00
|
|
|
FILE_INFO* fip = new FILE_INFO;
|
2004-08-12 11:57:51 +00:00
|
|
|
retval = fip->parse(mf, false);
|
2006-07-20 22:02:29 +00:00
|
|
|
if (!project) {
|
2007-01-25 23:39:06 +00:00
|
|
|
msg_printf(NULL, MSG_INTERNAL_ERROR,
|
2006-07-20 22:02:29 +00:00
|
|
|
"File info outside project in state file"
|
|
|
|
);
|
|
|
|
delete fip;
|
|
|
|
continue;
|
|
|
|
}
|
2004-08-12 11:57:51 +00:00
|
|
|
if (retval) {
|
2007-01-25 23:39:06 +00:00
|
|
|
msg_printf(NULL, MSG_INTERNAL_ERROR,
|
2006-01-17 22:48:09 +00:00
|
|
|
"Can't handle file info in state file"
|
|
|
|
);
|
2003-10-18 19:35:58 +00:00
|
|
|
delete fip;
|
2006-07-20 22:02:29 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
retval = link_file_info(project, fip);
|
|
|
|
if (project->anonymous_platform && retval == ERR_NOT_UNIQUE) {
|
|
|
|
delete fip;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (retval) {
|
2007-01-25 23:39:06 +00:00
|
|
|
msg_printf(project, MSG_INTERNAL_ERROR,
|
2006-07-20 22:02:29 +00:00
|
|
|
"Can't handle file info %s in state file",
|
|
|
|
fip->name
|
|
|
|
);
|
|
|
|
delete fip;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
file_infos.push_back(fip);
|
|
|
|
// If the file had a failure before,
|
|
|
|
// don't start another file transfer
|
|
|
|
//
|
|
|
|
if (fip->had_failure(failnum)) {
|
|
|
|
if (fip->pers_file_xfer) {
|
|
|
|
delete fip->pers_file_xfer;
|
|
|
|
fip->pers_file_xfer = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (fip->pers_file_xfer) {
|
|
|
|
retval = fip->pers_file_xfer->init(fip, fip->upload_when_present);
|
|
|
|
if (retval) {
|
2007-01-25 23:39:06 +00:00
|
|
|
msg_printf(project, MSG_INTERNAL_ERROR,
|
2006-07-20 22:02:29 +00:00
|
|
|
"Can't initialize file transfer for %s",
|
|
|
|
fip->name
|
|
|
|
);
|
|
|
|
}
|
|
|
|
retval = pers_file_xfers->insert(fip->pers_file_xfer);
|
|
|
|
if (retval) {
|
2007-01-25 23:39:06 +00:00
|
|
|
msg_printf(project, MSG_INTERNAL_ERROR,
|
2006-07-20 22:02:29 +00:00
|
|
|
"Can't start persistent file transfer for %s",
|
|
|
|
fip->name
|
2006-01-17 22:48:09 +00:00
|
|
|
);
|
2004-08-12 11:57:51 +00:00
|
|
|
}
|
2003-10-18 19:35:58 +00:00
|
|
|
}
|
2007-06-11 18:34:26 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (match_tag(buf, "<app_version>")) {
|
2003-10-18 19:35:58 +00:00
|
|
|
APP_VERSION* avp = new APP_VERSION;
|
2004-08-12 11:57:51 +00:00
|
|
|
retval = avp->parse(mf);
|
2006-07-20 22:02:29 +00:00
|
|
|
if (!project) {
|
2007-01-25 23:39:06 +00:00
|
|
|
msg_printf(NULL, MSG_INTERNAL_ERROR,
|
2006-07-20 22:02:29 +00:00
|
|
|
"Application version outside project in state file"
|
|
|
|
);
|
|
|
|
delete avp;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (project->anonymous_platform) {
|
2005-07-26 11:55:28 +00:00
|
|
|
delete avp;
|
|
|
|
continue;
|
|
|
|
}
|
2004-08-12 11:57:51 +00:00
|
|
|
if (retval) {
|
2007-01-25 23:39:06 +00:00
|
|
|
msg_printf(NULL, MSG_INTERNAL_ERROR,
|
|
|
|
"Can't parse application version in state file"
|
2006-01-17 22:48:09 +00:00
|
|
|
);
|
2003-10-18 19:35:58 +00:00
|
|
|
delete avp;
|
2006-07-20 22:02:29 +00:00
|
|
|
continue;
|
|
|
|
}
|
2007-05-03 17:14:30 +00:00
|
|
|
if (strlen(avp->platform) == 0) {
|
|
|
|
strcpy(avp->platform, get_primary_platform());
|
2007-05-06 20:22:39 +00:00
|
|
|
} else {
|
|
|
|
if (!is_supported_platform(avp->platform)) {
|
2007-06-11 18:52:51 +00:00
|
|
|
// if it's a platform we haven't heard of,
|
|
|
|
// must be that the user tried out a 64 bit client
|
|
|
|
// and then reverted to a 32-bit client.
|
|
|
|
// Let's not throw away the app version and its WUs
|
|
|
|
//
|
2007-05-06 20:22:39 +00:00
|
|
|
msg_printf(project, MSG_INTERNAL_ERROR,
|
2007-06-11 18:52:51 +00:00
|
|
|
"App version has unsupported platform %s; changing to %s",
|
|
|
|
avp->platform, get_primary_platform()
|
2007-05-06 20:22:39 +00:00
|
|
|
);
|
2007-06-11 18:52:51 +00:00
|
|
|
strcpy(avp->platform, get_primary_platform());
|
2007-05-06 20:22:39 +00:00
|
|
|
}
|
2007-05-03 17:14:30 +00:00
|
|
|
}
|
2007-05-14 17:36:16 +00:00
|
|
|
retval = link_app_version(project, avp);
|
|
|
|
if (retval) {
|
|
|
|
delete avp;
|
|
|
|
continue;
|
|
|
|
}
|
2006-07-20 22:02:29 +00:00
|
|
|
app_versions.push_back(avp);
|
2007-06-11 18:34:26 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (match_tag(buf, "<workunit>")) {
|
2003-10-18 19:35:58 +00:00
|
|
|
WORKUNIT* wup = new WORKUNIT;
|
2004-08-12 11:57:51 +00:00
|
|
|
retval = wup->parse(mf);
|
2006-07-20 22:02:29 +00:00
|
|
|
if (!project) {
|
2007-01-25 23:39:06 +00:00
|
|
|
msg_printf(NULL, MSG_INTERNAL_ERROR,
|
2006-07-20 22:02:29 +00:00
|
|
|
"Workunit outside project in state file"
|
|
|
|
);
|
|
|
|
delete wup;
|
|
|
|
continue;
|
|
|
|
}
|
2004-08-12 11:57:51 +00:00
|
|
|
if (retval) {
|
2007-01-25 23:39:06 +00:00
|
|
|
msg_printf(NULL, MSG_INTERNAL_ERROR,
|
2006-01-17 22:48:09 +00:00
|
|
|
"Can't parse workunit in state file"
|
|
|
|
);
|
2003-10-18 19:35:58 +00:00
|
|
|
delete wup;
|
2006-07-20 22:02:29 +00:00
|
|
|
continue;
|
2003-10-18 19:35:58 +00:00
|
|
|
}
|
2006-07-20 22:02:29 +00:00
|
|
|
retval = link_workunit(project, wup);
|
|
|
|
if (retval) {
|
2007-01-25 23:39:06 +00:00
|
|
|
msg_printf(project, MSG_INTERNAL_ERROR,
|
2006-07-20 22:02:29 +00:00
|
|
|
"Can't handle workunit in state file"
|
|
|
|
);
|
|
|
|
delete wup;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
workunits.push_back(wup);
|
2007-06-11 18:34:26 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (match_tag(buf, "<result>")) {
|
2003-10-18 19:35:58 +00:00
|
|
|
RESULT* rp = new RESULT;
|
2004-08-12 11:57:51 +00:00
|
|
|
retval = rp->parse_state(mf);
|
2006-07-20 22:02:29 +00:00
|
|
|
if (!project) {
|
2007-01-25 23:39:06 +00:00
|
|
|
msg_printf(NULL, MSG_INTERNAL_ERROR,
|
2006-07-20 22:02:29 +00:00
|
|
|
"Task %s outside project in state file",
|
|
|
|
rp->name
|
|
|
|
);
|
|
|
|
delete rp;
|
|
|
|
continue;
|
|
|
|
}
|
2004-08-12 11:57:51 +00:00
|
|
|
if (retval) {
|
2007-01-25 23:39:06 +00:00
|
|
|
msg_printf(NULL, MSG_INTERNAL_ERROR,
|
2006-01-17 22:48:09 +00:00
|
|
|
"Can't parse task in state file"
|
|
|
|
);
|
2003-10-18 19:35:58 +00:00
|
|
|
delete rp;
|
2006-07-20 22:02:29 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
retval = link_result(project, rp);
|
|
|
|
if (retval) {
|
2007-01-25 23:39:06 +00:00
|
|
|
msg_printf(project, MSG_INTERNAL_ERROR,
|
2006-07-20 22:02:29 +00:00
|
|
|
"Can't link task %s in state file",
|
|
|
|
rp->name
|
|
|
|
);
|
|
|
|
delete rp;
|
|
|
|
continue;
|
2003-10-18 19:35:58 +00:00
|
|
|
}
|
2007-06-12 16:15:53 +00:00
|
|
|
if (!strlen(rp->platform) || !is_supported_platform(rp->platform)) {
|
2007-05-03 17:14:30 +00:00
|
|
|
strcpy(rp->platform, get_primary_platform());
|
|
|
|
rp->version_num = latest_version(rp->wup->app, rp->platform);
|
|
|
|
}
|
|
|
|
rp->avp = lookup_app_version(rp->wup->app, rp->platform, rp->version_num);
|
|
|
|
if (!rp->avp) {
|
|
|
|
msg_printf(project, MSG_INTERNAL_ERROR,
|
|
|
|
"No app version for result: %s %d",
|
|
|
|
rp->platform, rp->version_num
|
|
|
|
);
|
|
|
|
delete rp;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
rp->wup->version_num = rp->version_num;
|
2006-07-20 22:02:29 +00:00
|
|
|
results.push_back(rp);
|
2007-06-11 18:34:26 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (match_tag(buf, "<project_files>")) {
|
2006-07-20 22:02:29 +00:00
|
|
|
if (!project) {
|
2007-01-25 23:39:06 +00:00
|
|
|
msg_printf(NULL, MSG_INTERNAL_ERROR,
|
2006-07-20 22:02:29 +00:00
|
|
|
"Project files outside project in state file"
|
|
|
|
);
|
2007-06-08 07:55:27 +00:00
|
|
|
skip_unrecognized(buf, mf);
|
2006-07-20 22:02:29 +00:00
|
|
|
continue;
|
|
|
|
}
|
2006-10-09 18:58:52 +00:00
|
|
|
project->parse_project_files(mf, false);
|
2006-10-09 21:43:59 +00:00
|
|
|
project->link_project_files(false);
|
2007-06-11 18:34:26 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (match_tag(buf, "<host_info>")) {
|
2004-06-12 04:45:36 +00:00
|
|
|
retval = host_info.parse(mf);
|
2004-08-12 11:57:51 +00:00
|
|
|
if (retval) {
|
2007-01-25 23:39:06 +00:00
|
|
|
msg_printf(NULL, MSG_INTERNAL_ERROR,
|
2006-01-17 22:48:09 +00:00
|
|
|
"Can't parse host info in state file"
|
|
|
|
);
|
2004-08-12 11:57:51 +00:00
|
|
|
}
|
2007-06-11 18:34:26 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (match_tag(buf, "<time_stats>")) {
|
2004-06-12 04:45:36 +00:00
|
|
|
retval = time_stats.parse(mf);
|
2004-08-12 11:57:51 +00:00
|
|
|
if (retval) {
|
2007-01-25 23:39:06 +00:00
|
|
|
msg_printf(NULL, MSG_INTERNAL_ERROR,
|
2006-01-17 22:48:09 +00:00
|
|
|
"Can't parse time stats in state file"
|
|
|
|
);
|
2004-08-12 11:57:51 +00:00
|
|
|
}
|
2007-06-11 18:34:26 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (match_tag(buf, "<net_stats>")) {
|
2004-06-12 04:45:36 +00:00
|
|
|
retval = net_stats.parse(mf);
|
2004-08-12 11:57:51 +00:00
|
|
|
if (retval) {
|
2007-01-25 23:39:06 +00:00
|
|
|
msg_printf(NULL, MSG_INTERNAL_ERROR,
|
2006-01-17 22:48:09 +00:00
|
|
|
"Can't parse network stats in state file"
|
|
|
|
);
|
2004-08-12 11:57:51 +00:00
|
|
|
}
|
2007-06-11 18:34:26 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (match_tag(buf, "<active_task_set>")) {
|
2004-06-12 04:45:36 +00:00
|
|
|
retval = active_tasks.parse(mf);
|
2004-08-12 11:57:51 +00:00
|
|
|
if (retval) {
|
2007-01-25 23:39:06 +00:00
|
|
|
msg_printf(NULL, MSG_INTERNAL_ERROR,
|
2006-01-17 22:48:09 +00:00
|
|
|
"Can't parse active tasks in state file"
|
|
|
|
);
|
2004-08-12 11:57:51 +00:00
|
|
|
}
|
2006-02-18 08:33:23 +00:00
|
|
|
continue;
|
2007-06-11 18:34:26 +00:00
|
|
|
}
|
|
|
|
if (parse_str(buf, "<platform_name>", statefile_platform_name)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (match_tag(buf, "<alt_platform>")) {
|
2007-05-03 17:14:30 +00:00
|
|
|
continue;
|
2007-06-11 18:34:26 +00:00
|
|
|
}
|
|
|
|
if (parse_int(buf, "<user_run_request>", retval)) {
|
2006-11-10 17:55:22 +00:00
|
|
|
run_mode.set(retval, 0);
|
2004-10-21 00:23:19 +00:00
|
|
|
continue;
|
2007-06-11 18:34:26 +00:00
|
|
|
}
|
|
|
|
if (parse_int(buf, "<user_network_request>", retval)) {
|
2006-11-10 17:55:22 +00:00
|
|
|
network_mode.set(retval, 0);
|
2004-10-21 00:23:19 +00:00
|
|
|
continue;
|
2007-06-11 18:34:26 +00:00
|
|
|
}
|
|
|
|
if (parse_int(buf, "<core_client_major_version>", old_major_version)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (parse_int(buf, "<core_client_minor_version>", old_minor_version)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (parse_int(buf, "<core_client_release>", old_release)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (match_tag(buf, "<cpu_benchmarks_pending/>")) {
|
2005-07-24 18:23:56 +00:00
|
|
|
run_cpu_benchmarks = true;
|
2007-06-11 18:34:26 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (match_tag(buf, "<work_fetch_no_new_work/>")) {
|
2005-07-24 18:23:56 +00:00
|
|
|
work_fetch_no_new_work = true;
|
2007-06-11 18:34:26 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (match_tag(buf, "<proxy_info>")) {
|
2004-09-26 04:16:52 +00:00
|
|
|
retval = proxy_info.parse(mf);
|
2004-08-12 11:57:51 +00:00
|
|
|
if (retval) {
|
2007-01-25 23:39:06 +00:00
|
|
|
msg_printf(NULL, MSG_INTERNAL_ERROR,
|
2006-01-17 22:48:09 +00:00
|
|
|
"Can't parse proxy info in state file"
|
|
|
|
);
|
2004-08-12 11:57:51 +00:00
|
|
|
}
|
2007-06-11 18:34:26 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (parse_str(buf, "<host_venue>", main_host_venue, sizeof(main_host_venue))) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (parse_double(buf, "<new_version_check_time>", new_version_check_time)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (parse_double(buf, "<all_projects_list_check_time>", all_projects_list_check_time)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (parse_str(buf, "<newer_version>", newer_version)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (match_tag(buf, "<auto_update>")) {
|
2006-12-11 23:42:54 +00:00
|
|
|
if (!project) {
|
2007-01-25 23:39:06 +00:00
|
|
|
msg_printf(NULL, MSG_INTERNAL_ERROR,
|
2006-12-11 23:42:54 +00:00
|
|
|
"auto update outside project in state file"
|
|
|
|
);
|
2007-06-08 07:55:27 +00:00
|
|
|
skip_unrecognized(buf, mf);
|
2006-12-11 23:42:54 +00:00
|
|
|
continue;
|
|
|
|
}
|
2006-12-14 00:42:43 +00:00
|
|
|
if (!auto_update.parse(mf) && !auto_update.validate_and_link(project)) {
|
2006-12-11 23:42:54 +00:00
|
|
|
auto_update.present = true;
|
|
|
|
}
|
2007-06-11 18:34:26 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (log_flags.unparsed_xml) {
|
|
|
|
msg_printf(0, MSG_INFO,
|
|
|
|
"[unparsed_xml] state_file: unrecognized: %s", buf
|
|
|
|
);
|
2006-06-22 19:40:30 +00:00
|
|
|
}
|
2007-06-11 18:34:26 +00:00
|
|
|
skip_unrecognized(buf, mf);
|
2003-10-18 19:35:58 +00:00
|
|
|
}
|
|
|
|
fclose(f);
|
2006-02-01 07:04:24 +00:00
|
|
|
return 0;
|
2003-10-18 19:35:58 +00:00
|
|
|
}
|
|
|
|
|
2003-10-27 17:10:48 +00:00
|
|
|
|
2003-10-18 19:35:58 +00:00
|
|
|
// Write the client_state.xml file
|
|
|
|
//
|
|
|
|
int CLIENT_STATE::write_state_file() {
|
2005-12-22 00:55:15 +00:00
|
|
|
MFILE mf;
|
|
|
|
int retval, ret1, ret2;
|
2006-10-20 05:30:41 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
char win_error_msg[4096];
|
|
|
|
#endif
|
2003-10-18 19:35:58 +00:00
|
|
|
|
2006-06-22 19:40:30 +00:00
|
|
|
if (log_flags.state_debug) {
|
|
|
|
msg_printf(0, MSG_INFO,
|
2006-09-07 20:39:25 +00:00
|
|
|
"[status_debug] CLIENT_STATE::write_state_file(): Writing state file"
|
2006-06-22 19:40:30 +00:00
|
|
|
);
|
|
|
|
}
|
2006-02-14 21:35:26 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
retval = mf.open(STATE_FILE_NEXT, "wc");
|
|
|
|
#else
|
2005-12-22 00:55:15 +00:00
|
|
|
retval = mf.open(STATE_FILE_NEXT, "w");
|
2006-02-14 21:35:26 +00:00
|
|
|
#endif
|
2005-12-22 00:55:15 +00:00
|
|
|
if (retval) {
|
2007-01-25 23:39:06 +00:00
|
|
|
msg_printf(0, MSG_INTERNAL_ERROR,
|
2006-12-14 00:42:43 +00:00
|
|
|
"Can't open %s: %s",
|
2006-01-17 22:48:09 +00:00
|
|
|
STATE_FILE_NEXT, boincerror(retval)
|
|
|
|
);
|
2003-10-18 19:35:58 +00:00
|
|
|
return ERR_FOPEN;
|
|
|
|
}
|
2005-12-22 00:55:15 +00:00
|
|
|
MIOFILE miof;
|
|
|
|
miof.init_mfile(&mf);
|
|
|
|
ret1 = write_state(miof);
|
|
|
|
ret2 = mf.close();
|
|
|
|
if (ret1) return ret1;
|
|
|
|
if (ret2) return ret2;
|
2004-07-16 21:23:43 +00:00
|
|
|
|
2006-12-14 00:42:43 +00:00
|
|
|
// only attempt to rename the current state file if it exists.
|
2004-07-16 21:23:43 +00:00
|
|
|
//
|
2006-10-20 05:30:41 +00:00
|
|
|
if (boinc_file_exists(STATE_FILE_NAME)) {
|
2006-12-14 00:42:43 +00:00
|
|
|
if (boinc_file_exists(STATE_FILE_PREV)) {
|
2006-10-20 05:30:41 +00:00
|
|
|
retval = boinc_delete_file(STATE_FILE_PREV);
|
|
|
|
#ifdef _WIN32
|
|
|
|
if (retval) {
|
2007-01-25 23:39:06 +00:00
|
|
|
msg_printf(0, MSG_USER_ERROR,
|
2006-10-20 05:30:41 +00:00
|
|
|
"Can't delete previous state file; %s",
|
|
|
|
windows_error_string(win_error_msg, sizeof(win_error_msg))
|
|
|
|
);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
retval = boinc_rename(STATE_FILE_NAME, STATE_FILE_PREV);
|
|
|
|
#ifdef _WIN32
|
|
|
|
if (retval) {
|
2007-01-25 23:39:06 +00:00
|
|
|
msg_printf(0, MSG_USER_ERROR,
|
2006-10-20 05:30:41 +00:00
|
|
|
"Can't rename current state file to previous state file; %s",
|
|
|
|
windows_error_string(win_error_msg, sizeof(win_error_msg))
|
|
|
|
);
|
|
|
|
}
|
2007-07-16 08:59:14 +00:00
|
|
|
#endif
|
|
|
|
#ifdef __APPLE__
|
|
|
|
if (retval) {
|
|
|
|
msg_printf(0, MSG_USER_ERROR,
|
|
|
|
"rename current state file to previous state file returned error %d: %s",
|
|
|
|
errno, strerror(errno)
|
|
|
|
);
|
|
|
|
}
|
2006-10-20 05:30:41 +00:00
|
|
|
#endif
|
|
|
|
}
|
2004-07-16 21:23:43 +00:00
|
|
|
|
2004-07-15 23:58:43 +00:00
|
|
|
retval = boinc_rename(STATE_FILE_NEXT, STATE_FILE_NAME);
|
2006-06-22 19:40:30 +00:00
|
|
|
if (log_flags.state_debug) {
|
|
|
|
msg_printf(0, MSG_INFO,
|
2006-09-07 20:39:25 +00:00
|
|
|
"[status_debug] CLIENT_STATE::write_state_file(): Done writing state file"
|
2006-06-22 19:40:30 +00:00
|
|
|
);
|
|
|
|
}
|
2006-01-17 22:48:09 +00:00
|
|
|
if (retval) {
|
2006-10-19 23:58:04 +00:00
|
|
|
#ifdef _WIN32
|
2006-12-14 00:42:43 +00:00
|
|
|
if (retval == ERROR_ACCESS_DENIED) {
|
2007-01-25 23:39:06 +00:00
|
|
|
msg_printf(0, MSG_USER_ERROR,
|
2006-10-20 01:46:46 +00:00
|
|
|
"Can't rename state file; access denied; check file and directory permissions"
|
2006-10-19 23:58:04 +00:00
|
|
|
);
|
|
|
|
} else {
|
2007-01-25 23:39:06 +00:00
|
|
|
msg_printf(0, MSG_USER_ERROR,
|
2006-10-20 01:46:46 +00:00
|
|
|
"Can't rename state file; %s",
|
2006-10-20 05:30:41 +00:00
|
|
|
windows_error_string(win_error_msg, sizeof(win_error_msg))
|
2006-10-19 23:58:04 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
#else
|
2007-01-25 23:39:06 +00:00
|
|
|
msg_printf(0, MSG_USER_ERROR,
|
2006-12-14 00:42:43 +00:00
|
|
|
"Can't rename %s to %s; check file and directory permissions",
|
|
|
|
STATE_FILE_NEXT, STATE_FILE_NAME
|
2006-01-17 22:48:09 +00:00
|
|
|
);
|
2007-06-23 08:42:02 +00:00
|
|
|
#endif
|
|
|
|
#ifdef __APPLE__
|
|
|
|
msg_printf(0, MSG_USER_ERROR,
|
2007-07-10 09:01:07 +00:00
|
|
|
"rename %s to %s returned error %d: %s",
|
2007-07-16 08:59:14 +00:00
|
|
|
STATE_FILE_NEXT, STATE_FILE_NAME, errno, strerror(errno)
|
|
|
|
);
|
|
|
|
if (log_flags.state_debug) {
|
|
|
|
system("ls -al /Library/Application\\ Support/BOINC\\ Data/client*.*");
|
|
|
|
}
|
2006-10-19 23:58:04 +00:00
|
|
|
#endif
|
2006-01-17 22:48:09 +00:00
|
|
|
return ERR_RENAME;
|
|
|
|
}
|
2004-01-22 19:30:42 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-06-12 04:45:36 +00:00
|
|
|
int CLIENT_STATE::write_state(MIOFILE& f) {
|
2004-01-22 19:30:42 +00:00
|
|
|
unsigned int i, j;
|
|
|
|
int retval;
|
|
|
|
|
2004-06-12 04:45:36 +00:00
|
|
|
f.printf("<client_state>\n");
|
2007-03-13 19:33:27 +00:00
|
|
|
retval = host_info.write(f, false);
|
2003-10-18 19:35:58 +00:00
|
|
|
if (retval) return retval;
|
|
|
|
retval = time_stats.write(f, false);
|
|
|
|
if (retval) return retval;
|
2004-09-22 21:08:26 +00:00
|
|
|
retval = net_stats.write(f);
|
2003-10-18 19:35:58 +00:00
|
|
|
if (retval) return retval;
|
|
|
|
for (j=0; j<projects.size(); j++) {
|
|
|
|
PROJECT* p = projects[j];
|
|
|
|
retval = p->write_state(f);
|
|
|
|
if (retval) return retval;
|
|
|
|
for (i=0; i<apps.size(); i++) {
|
|
|
|
if (apps[i]->project == p) {
|
|
|
|
retval = apps[i]->write(f);
|
|
|
|
if (retval) return retval;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (i=0; i<file_infos.size(); i++) {
|
|
|
|
if (file_infos[i]->project == p) {
|
|
|
|
retval = file_infos[i]->write(f, false);
|
|
|
|
if (retval) return retval;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (i=0; i<app_versions.size(); i++) {
|
|
|
|
if (app_versions[i]->project == p) app_versions[i]->write(f);
|
|
|
|
}
|
|
|
|
for (i=0; i<workunits.size(); i++) {
|
|
|
|
if (workunits[i]->project == p) workunits[i]->write(f);
|
|
|
|
}
|
|
|
|
for (i=0; i<results.size(); i++) {
|
|
|
|
if (results[i]->project == p) results[i]->write(f, false);
|
|
|
|
}
|
2006-06-27 17:31:43 +00:00
|
|
|
p->write_project_files(f);
|
2006-12-11 23:42:54 +00:00
|
|
|
if (auto_update.present && auto_update.project==p) {
|
|
|
|
auto_update.write(f);
|
|
|
|
}
|
2003-10-18 19:35:58 +00:00
|
|
|
}
|
|
|
|
active_tasks.write(f);
|
2004-06-12 04:45:36 +00:00
|
|
|
f.printf(
|
2003-10-18 19:35:58 +00:00
|
|
|
"<platform_name>%s</platform_name>\n"
|
|
|
|
"<core_client_major_version>%d</core_client_major_version>\n"
|
2004-10-21 00:23:19 +00:00
|
|
|
"<core_client_minor_version>%d</core_client_minor_version>\n"
|
2005-09-01 19:27:04 +00:00
|
|
|
"<core_client_release>%d</core_client_release>\n"
|
2004-10-21 00:23:19 +00:00
|
|
|
"<user_run_request>%d</user_run_request>\n"
|
2006-01-30 21:13:49 +00:00
|
|
|
"<user_network_request>%d</user_network_request>\n"
|
2005-11-10 06:03:39 +00:00
|
|
|
"%s"
|
2007-03-04 02:30:48 +00:00
|
|
|
"<new_version_check_time>%f</new_version_check_time>\n"
|
2007-03-19 19:13:40 +00:00
|
|
|
"<all_projects_list_check_time>%f</all_projects_list_check_time>\n",
|
2007-05-02 17:53:35 +00:00
|
|
|
get_primary_platform(),
|
2006-12-14 00:42:43 +00:00
|
|
|
core_client_version.major,
|
|
|
|
core_client_version.minor,
|
|
|
|
core_client_version.release,
|
2006-11-10 17:55:22 +00:00
|
|
|
run_mode.get_perm(),
|
|
|
|
network_mode.get_perm(),
|
2005-11-10 06:03:39 +00:00
|
|
|
cpu_benchmarks_pending?"<cpu_benchmarks_pending/>\n":"",
|
2007-03-04 02:30:48 +00:00
|
|
|
new_version_check_time,
|
2007-03-19 19:13:40 +00:00
|
|
|
all_projects_list_check_time
|
2003-10-18 19:35:58 +00:00
|
|
|
);
|
2005-11-12 06:14:10 +00:00
|
|
|
if (newer_version.size()) {
|
2005-11-13 05:50:11 +00:00
|
|
|
f.printf("<newer_version>%s</newer_version>\n", newer_version.c_str());
|
2005-11-12 06:14:10 +00:00
|
|
|
}
|
2007-05-03 17:14:30 +00:00
|
|
|
for (i=1; i<platforms.size(); i++) {
|
2007-05-07 19:38:27 +00:00
|
|
|
f.printf("<alt_platform>%s</alt_platform>\n", platforms[i].name.c_str());
|
2007-05-03 17:14:30 +00:00
|
|
|
}
|
2004-09-26 04:16:52 +00:00
|
|
|
proxy_info.write(f);
|
2004-10-01 08:15:58 +00:00
|
|
|
if (strlen(main_host_venue)) {
|
|
|
|
f.printf("<host_venue>%s</host_venue>\n", main_host_venue);
|
2003-10-18 19:35:58 +00:00
|
|
|
}
|
2004-06-12 04:45:36 +00:00
|
|
|
f.printf("</client_state>\n");
|
2003-10-18 19:35:58 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Write the client_state.xml file if necessary
|
|
|
|
// TODO: write no more often than X seconds
|
|
|
|
//
|
|
|
|
int CLIENT_STATE::write_state_file_if_needed() {
|
|
|
|
int retval;
|
|
|
|
if (client_state_dirty) {
|
|
|
|
client_state_dirty = false;
|
|
|
|
retval = write_state_file();
|
|
|
|
if (retval) return retval;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-01-26 19:42:39 +00:00
|
|
|
// look for app_versions.xml file in project dir.
|
|
|
|
// If find, get app versions from there,
|
|
|
|
// and use "anonymous platform" mechanism for this project
|
|
|
|
//
|
|
|
|
void CLIENT_STATE::check_anonymous() {
|
2005-03-10 00:43:22 +00:00
|
|
|
unsigned int i;
|
|
|
|
char dir[256], path[256];
|
|
|
|
FILE* f;
|
|
|
|
int retval;
|
|
|
|
|
|
|
|
for (i=0; i<projects.size(); i++) {
|
|
|
|
PROJECT* p = projects[i];
|
2007-03-13 19:33:27 +00:00
|
|
|
get_project_dir(p, dir, sizeof(dir));
|
2006-03-03 21:34:03 +00:00
|
|
|
sprintf(path, "%s/%s", dir, APP_INFO_FILE_NAME);
|
2005-03-10 00:43:22 +00:00
|
|
|
f = fopen(path, "r");
|
|
|
|
if (!f) continue;
|
2004-04-23 00:05:16 +00:00
|
|
|
msg_printf(p, MSG_INFO,
|
2006-01-17 22:48:09 +00:00
|
|
|
"Found %s; using anonymous platform", APP_INFO_FILE_NAME
|
2004-04-23 00:05:16 +00:00
|
|
|
);
|
2004-01-26 19:42:39 +00:00
|
|
|
|
2005-03-10 00:43:22 +00:00
|
|
|
p->anonymous_platform = true;
|
|
|
|
// flag as anonymous even if can't parse file
|
|
|
|
retval = parse_app_info(p, f);
|
|
|
|
fclose(f);
|
|
|
|
}
|
2004-01-26 19:42:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int CLIENT_STATE::parse_app_info(PROJECT* p, FILE* in) {
|
2005-03-10 00:43:22 +00:00
|
|
|
char buf[256];
|
2004-06-12 04:45:36 +00:00
|
|
|
MIOFILE mf;
|
|
|
|
mf.init_file(in);
|
2004-01-26 19:42:39 +00:00
|
|
|
|
2005-03-10 00:43:22 +00:00
|
|
|
while (fgets(buf, 256, in)) {
|
|
|
|
if (match_tag(buf, "<app_info>")) continue;
|
|
|
|
if (match_tag(buf, "</app_info>")) return 0;
|
|
|
|
if (match_tag(buf, "<file_info>")) {
|
|
|
|
FILE_INFO* fip = new FILE_INFO;
|
|
|
|
if (fip->parse(mf, false)) {
|
|
|
|
delete fip;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (link_file_info(p, fip)) {
|
|
|
|
delete fip;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
fip->status = FILE_PRESENT;
|
|
|
|
file_infos.push_back(fip);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (match_tag(buf, "<app>")) {
|
|
|
|
APP* app = new APP;
|
|
|
|
if (app->parse(mf)) {
|
|
|
|
delete app;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (lookup_app(p, app->name)) {
|
|
|
|
delete app;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
link_app(p, app);
|
|
|
|
apps.push_back(app);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (match_tag(buf, "<app_version>")) {
|
|
|
|
APP_VERSION* avp = new APP_VERSION;
|
|
|
|
if (avp->parse(mf)) {
|
|
|
|
delete avp;
|
|
|
|
continue;
|
|
|
|
}
|
2007-05-14 17:36:16 +00:00
|
|
|
if (strlen(avp->platform) == 0) {
|
|
|
|
strcpy(avp->platform, get_primary_platform());
|
|
|
|
}
|
2007-05-10 16:23:10 +00:00
|
|
|
if (link_app_version(p, avp)) {
|
2005-03-10 00:43:22 +00:00
|
|
|
delete avp;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
app_versions.push_back(avp);
|
|
|
|
continue;
|
|
|
|
}
|
2007-01-25 23:39:06 +00:00
|
|
|
if (log_flags.unparsed_xml) {
|
|
|
|
msg_printf(p, MSG_INFO,
|
|
|
|
"[unparsed_xml] Unparsed line in app_info.xml: %s", buf
|
|
|
|
);
|
|
|
|
}
|
2005-03-10 00:43:22 +00:00
|
|
|
}
|
|
|
|
return ERR_XML_PARSE;
|
2004-01-26 19:42:39 +00:00
|
|
|
}
|
2004-07-13 23:51:09 +00:00
|
|
|
|
|
|
|
int CLIENT_STATE::write_state_gui(MIOFILE& f) {
|
|
|
|
unsigned int i, j;
|
|
|
|
int retval;
|
|
|
|
|
|
|
|
f.printf("<client_state>\n");
|
2004-09-05 18:46:19 +00:00
|
|
|
|
2007-03-13 19:33:27 +00:00
|
|
|
retval = host_info.write(f, false);
|
2004-09-05 18:46:19 +00:00
|
|
|
if (retval) return retval;
|
|
|
|
retval = time_stats.write(f, false);
|
|
|
|
if (retval) return retval;
|
2004-09-22 21:08:26 +00:00
|
|
|
retval = net_stats.write(f);
|
2004-09-05 18:46:19 +00:00
|
|
|
if (retval) return retval;
|
|
|
|
|
2005-03-10 00:43:22 +00:00
|
|
|
for (j=0; j<projects.size(); j++) {
|
2004-07-13 23:51:09 +00:00
|
|
|
PROJECT* p = projects[j];
|
2004-07-19 19:40:06 +00:00
|
|
|
retval = p->write_state(f, true);
|
2004-07-13 23:51:09 +00:00
|
|
|
if (retval) return retval;
|
|
|
|
for (i=0; i<apps.size(); i++) {
|
|
|
|
if (apps[i]->project == p) {
|
|
|
|
retval = apps[i]->write(f);
|
|
|
|
if (retval) return retval;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (i=0; i<app_versions.size(); i++) {
|
|
|
|
if (app_versions[i]->project == p) app_versions[i]->write(f);
|
|
|
|
}
|
|
|
|
for (i=0; i<workunits.size(); i++) {
|
|
|
|
if (workunits[i]->project == p) workunits[i]->write(f);
|
|
|
|
}
|
|
|
|
for (i=0; i<results.size(); i++) {
|
2004-07-19 19:40:06 +00:00
|
|
|
if (results[i]->project == p) results[i]->write_gui(f);
|
2004-07-13 23:51:09 +00:00
|
|
|
}
|
|
|
|
}
|
2004-09-05 18:46:19 +00:00
|
|
|
f.printf(
|
|
|
|
"<platform_name>%s</platform_name>\n"
|
|
|
|
"<core_client_major_version>%d</core_client_major_version>\n"
|
2005-07-24 18:23:56 +00:00
|
|
|
"<core_client_minor_version>%d</core_client_minor_version>\n"
|
2005-09-01 19:27:04 +00:00
|
|
|
"<core_client_release>%d</core_client_release>\n"
|
2006-06-21 02:24:40 +00:00
|
|
|
"%s",
|
2007-05-02 17:53:35 +00:00
|
|
|
get_primary_platform(),
|
2006-12-14 00:42:43 +00:00
|
|
|
core_client_version.major,
|
|
|
|
core_client_version.minor,
|
|
|
|
core_client_version.release,
|
2006-06-15 23:15:27 +00:00
|
|
|
work_fetch_no_new_work?"<work_fetch_no_new_work/>\n":""
|
2004-09-05 18:46:19 +00:00
|
|
|
);
|
|
|
|
|
2005-06-22 10:51:34 +00:00
|
|
|
global_prefs.write(f);
|
2005-03-02 07:15:15 +00:00
|
|
|
|
|
|
|
if (strlen(main_host_venue)) {
|
|
|
|
f.printf("<host_venue>%s</host_venue>\n", main_host_venue);
|
|
|
|
}
|
|
|
|
|
2004-09-05 18:46:19 +00:00
|
|
|
f.printf("</client_state>\n");
|
2004-07-13 23:51:09 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-08-23 22:16:19 +00:00
|
|
|
int CLIENT_STATE::write_tasks_gui(MIOFILE& f) {
|
2004-07-13 23:51:09 +00:00
|
|
|
unsigned int i;
|
2004-09-05 18:46:19 +00:00
|
|
|
|
2006-06-27 21:46:50 +00:00
|
|
|
for (i=0; i<results.size(); i++) {
|
2004-07-13 23:51:09 +00:00
|
|
|
RESULT* rp = results[i];
|
|
|
|
rp->write_gui(f);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int CLIENT_STATE::write_file_transfers_gui(MIOFILE& f) {
|
|
|
|
unsigned int i;
|
2004-09-05 18:46:19 +00:00
|
|
|
|
2005-03-10 00:43:22 +00:00
|
|
|
f.printf("<file_transfers>\n");
|
2004-07-13 23:51:09 +00:00
|
|
|
for (i=0; i<file_infos.size(); i++) {
|
|
|
|
FILE_INFO* fip = file_infos[i];
|
2006-03-04 00:53:20 +00:00
|
|
|
if (fip->pers_file_xfer
|
|
|
|
|| (fip->upload_when_present && fip->status == FILE_PRESENT && !fip->uploaded)
|
|
|
|
) {
|
2004-07-13 23:51:09 +00:00
|
|
|
fip->write_gui(f);
|
|
|
|
}
|
|
|
|
}
|
2005-03-10 00:43:22 +00:00
|
|
|
f.printf("</file_transfers>\n");
|
2004-09-05 18:46:19 +00:00
|
|
|
|
2004-07-13 23:51:09 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2004-12-08 00:40:19 +00:00
|
|
|
|
2005-01-02 18:29:53 +00:00
|
|
|
const char *BOINC_RCSID_375ec798cc = "$Id$";
|