*** empty log message ***

svn path=/trunk/boinc/; revision=8141
This commit is contained in:
Rom Walton 2005-09-22 08:46:51 +00:00
parent 76de784439
commit fc2bd7133e
12 changed files with 316 additions and 144 deletions

View File

@ -56,7 +56,7 @@ using namespace std;
#ifdef __cplusplus
extern "C" {
#endif
extern int boinc_shutdown_graphics();
//extern int boinc_shutdown_graphics();
#ifdef __cplusplus
}
#endif
@ -381,7 +381,7 @@ void boinc_exit(int status) {
#ifdef BOINC_APP_GRAPHICS
// Shutdown graphics if it is running
//
boinc_shutdown_graphics();
//boinc_shutdown_graphics();
#endif
// Unlock the lock file

View File

@ -11975,3 +11975,28 @@ David 21 Sept 2005
boinc_db.C,h
sched/
feeder.C
Rom 21 Sept 2005
- check-in core client support for project_init.xml
- delete project_init.xml if we detach from that project
- add the notion of cached credentials to acct_mgr_rpc and
project_attach so that way we don't put any username
and password stuff over the wire for remote core clients
- disable boinc_shutdown_graphics() until the design can be
finalized
- adjust the boinc manager menus a bit
api/
boinc_api.C
client/
acct_mgr.C
acct_setup.C, .h
client_state.C, .h
file_names.h
gui_rpc_server_ops.C
clientgui/
MainFrame.cpp
lib/
gui_rpc_client.h
gui_rpc_client_ops.C

View File

@ -228,4 +228,5 @@ int ACCT_MGR_INFO::init() {
}
return 0;
}
const char *BOINC_RCSID_8fd9e873bf="$Id$";

View File

@ -20,10 +20,54 @@
#include "client_state.h"
#include "file_names.h"
#include "parse.h"
#include "filesys.h"
#include "util.h"
#include "acct_setup.h"
void PROJECT_INIT::clear() {
strcpy(url, "");
strcpy(name, "");
strcpy(account_key, "");
has_project_init = false;
has_url = false;
has_account_key = false;
}
PROJECT_INIT::PROJECT_INIT() {
clear();
}
int PROJECT_INIT::init() {
char buf[256];
MIOFILE mf;
FILE* p;
clear();
p = fopen(PROJECT_INIT_FILENAME, "r");
if (p) {
has_project_init = true;
mf.init_file(p);
while(mf.fgets(buf, sizeof(buf))) {
if (match_tag(buf, "</project_init>")) break;
else if (parse_str(buf, "<name>", name, 256)) continue;
else if (parse_str(buf, "<url>", url, 256)) {
has_url = true;
continue;
} else if (parse_str(buf, "<account_key>", account_key, 256)) {
has_account_key = true;
continue;
}
}
fclose(p);
}
return 0;
}
int PROJECT_INIT::remove() {
return boinc_delete_file(PROJECT_INIT_FILENAME);
}
void ACCOUNT_IN::parse(char* buf) {
url = "";
email_addr = "";

View File

@ -23,6 +23,22 @@
#include "gui_http.h"
#include "error_numbers.h"
// represents info stored on files
//
struct PROJECT_INIT {
char url[256];
char name[256];
char account_key[256];
bool has_project_init;
bool has_url;
bool has_account_key;
PROJECT_INIT();
int init();
int remove();
void clear();
};
struct ACCOUNT_IN {
std::string url;
std::string email_addr;

View File

@ -362,13 +362,17 @@ int CLIENT_STATE::init() {
//
set_client_state_dirty("init");
// initialize GUI RPC data structures before we start accepting
// GUI RPC's.
//
acct_mgr_info.init();
project_init.init();
if (!no_gui_rpc) {
retval = gui_rpcs.init();
if (retval) return retval;
}
acct_mgr_info.init();
return 0;
}
@ -1377,6 +1381,22 @@ int CLIENT_STATE::detach_project(PROJECT* project) {
);
}
// if the project init file contains this projects master url
// then delete the project init file otherwise we'll just
// reattach the next time the core client starts
//
if (project_init.has_project_init && project_init.has_url) {
canonicalize_master_url(project_init.url);
if (strcmp(project->master_url, project_init.url) == 0) {
retval = project_init.remove();
if (retval) {
msg_printf(project, MSG_ERROR,
"Can't delete project init file: %s\n", boincerror(retval)
);
}
}
}
// remove project directory and its contents
//
retval = remove_project_dir(*project);
@ -1385,6 +1405,7 @@ int CLIENT_STATE::detach_project(PROJECT* project) {
"Can't delete project directory: %s\n", boincerror(retval)
);
}
delete project;
write_state_file();

View File

@ -178,6 +178,10 @@ private:
public:
ACCT_MGR_INFO acct_mgr_info;
// --------------- acct_setup.C:
public:
PROJECT_INIT project_init;
// --------------- client_state.C:
public:
CLIENT_STATE();

View File

@ -70,6 +70,7 @@ extern void get_master_filename(PROJECT&, char*);
#define FILE_LIST_NAME "file_list.xml"
#define ACCT_MGR_REPLY_FILENAME "acct_mgr_reply.xml"
#define GUI_RPC_PASSWD_FILE "gui_rpc_auth.cfg"
#define PROJECT_INIT_FILENAME "project_init.xml"
#define ACCT_MGR_URL_FILENAME "acct_mgr_url.xml"
#define ACCT_MGR_LOGIN_FILENAME "acct_mgr_login.xml"
#define GET_PROJECT_CONFIG_FILENAME "get_project_config.xml"

View File

@ -190,46 +190,6 @@ static void handle_project_op(char* buf, MIOFILE& fout, const char* op) {
fout.printf("<success/>\n");
}
static void handle_project_attach_poll(char*, MIOFILE& fout) {
fout.printf(
"<attach_project_status>\n"
" <error_num>%d</error_num>\n"
"</attach_project_status>\n",
gstate.project_attach.error_num
);
}
static void handle_project_attach(char* buf, MIOFILE& fout) {
string url, authenticator;
PROJECT* p = NULL;
bool already_attached = false;
unsigned int i;
if (!parse_str(buf, "<project_url>", url)) {
fout.printf("<error>Missing URL</error>\n");
return;
}
for (i=0; i<gstate.projects.size(); i++) {
p = gstate.projects[i];
if (url == p->master_url) already_attached = true;
}
if (already_attached) {
fout.printf("<error>Already attached to project</error>\n");
return;
}
if (!parse_str(buf, "<authenticator>", authenticator)) {
fout.printf("<error>Missing authenticator</error>\n");
return;
}
gstate.add_project(url.c_str(), authenticator.c_str());
gstate.project_attach.error_num = ERR_IN_PROGRESS;
fout.printf("<success/>\n");
}
static void handle_set_run_mode(char* buf, MIOFILE& fout) {
if (match_tag(buf, "<always")) {
gstate.user_run_request = USER_RUN_REQUEST_ALWAYS;
@ -488,45 +448,6 @@ static void handle_quit(char* buf, MIOFILE& fout) {
fout.printf("<success/>\n");
}
static void handle_acct_mgr_rpc(char* buf, MIOFILE& fout) {
std::string url, name, password;
bool bad_arg = false;
if (!parse_str(buf, "<url>", url)) bad_arg = true;
if (!parse_str(buf, "<name>", name)) bad_arg = true;
if (!parse_str(buf, "<password>", password)) bad_arg = true;
if (bad_arg) {
fout.printf("<error>bad arg</error>\n");
} else {
gstate.acct_mgr_op.do_rpc(url, name, password);
fout.printf("<success/>\n");
}
}
static void handle_acct_mgr_rpc_poll(char*, MIOFILE& fout) {
if (gstate.acct_mgr_op.error_num) {
fout.printf(
"<acct_mgr_rpc_reply>\n"
" <error_num>%d</error_num>\n",
gstate.acct_mgr_op.error_num
);
if (gstate.acct_mgr_op.error_str.size()) {
fout.printf(
" <error_msg>%s</error_msg>\n",
gstate.acct_mgr_op.error_str.c_str()
);
}
fout.printf(
"</acct_mgr_rpc_reply>\n"
);
} else {
fout.printf(
"<acct_mgr_rpc_reply>\n"
" <error_num>0</error_num>\n"
"</acct_mgr_rpc_reply>\n"
);
}
}
static void handle_acct_mgr_info(char*, MIOFILE& fout) {
fout.printf(
"<acct_mgr_info>\n"
@ -563,6 +484,19 @@ static void handle_network_available(char*, MIOFILE&) {
gstate.network_available();
}
static void handle_get_project_init_status(char*, MIOFILE& fout) {
fout.printf(
"<get_project_init_status>\n"
" <has_project_init>%d</has_project_init>\n"
" <has_url>%d</has_url>\n"
" <has_account_key>%d</has_account_key>\n"
"</get_project_init_status>\n",
gstate.project_init.has_project_init?1:0,
gstate.project_init.has_url?1:0,
gstate.project_init.has_account_key?1:0
);
}
static void handle_get_project_config(char* buf, MIOFILE& fout) {
string url;
@ -654,6 +588,112 @@ static void handle_lookup_website_poll(char*, MIOFILE& fout) {
);
}
static void handle_project_attach(char* buf, MIOFILE& fout) {
string url, authenticator;
PROJECT* p = NULL;
bool use_cached_credentials = false;
bool already_attached = false;
unsigned int i;
if (!parse_bool(buf, "use_cached_credentials", use_cached_credentials)) {
if (!parse_str(buf, "<project_url>", url)) {
fout.printf("<error>Missing URL</error>\n");
return;
}
for (i=0; i<gstate.projects.size(); i++) {
p = gstate.projects[i];
if (url == p->master_url) already_attached = true;
}
if (already_attached) {
fout.printf("<error>Already attached to project</error>\n");
return;
}
if (!parse_str(buf, "<authenticator>", authenticator)) {
fout.printf("<error>Missing authenticator</error>\n");
return;
}
} else {
if (!gstate.project_init.has_url) {
fout.printf("<error>Missing URL</error>\n");
return;
}
if (!gstate.project_init.has_account_key) {
fout.printf("<error>Missing authenticator</error>\n");
return;
}
url = gstate.project_init.url;
authenticator = gstate.project_init.account_key;
}
gstate.add_project(url.c_str(), authenticator.c_str());
gstate.project_attach.error_num = ERR_IN_PROGRESS;
fout.printf("<success/>\n");
}
static void handle_project_attach_poll(char*, MIOFILE& fout) {
fout.printf(
"<attach_project_status>\n"
" <error_num>%d</error_num>\n"
"</attach_project_status>\n",
gstate.project_attach.error_num
);
}
static void handle_acct_mgr_rpc(char* buf, MIOFILE& fout) {
std::string url, name, password;
bool use_cached_credentials = false;
bool bad_arg = false;
if (!parse_bool(buf, "use_cached_credentials", use_cached_credentials)) {
if (!parse_str(buf, "<url>", url)) bad_arg = true;
if (!parse_str(buf, "<name>", name)) bad_arg = true;
if (!parse_str(buf, "<password>", password)) bad_arg = true;
} else {
if (!strlen(gstate.acct_mgr_info.acct_mgr_url) || !strlen(gstate.acct_mgr_info.acct_mgr_url) || !strlen(gstate.acct_mgr_info.acct_mgr_url)) {
bad_arg = true;
} else {
url = gstate.acct_mgr_info.acct_mgr_url;
name = gstate.acct_mgr_info.acct_mgr_name;
password = gstate.acct_mgr_info.password;
}
}
if (bad_arg) {
fout.printf("<error>bad arg</error>\n");
} else {
gstate.acct_mgr_op.do_rpc(url, name, password);
fout.printf("<success/>\n");
}
}
static void handle_acct_mgr_rpc_poll(char*, MIOFILE& fout) {
if (gstate.acct_mgr_op.error_num) {
fout.printf(
"<acct_mgr_rpc_reply>\n"
" <error_num>%d</error_num>\n",
gstate.acct_mgr_op.error_num
);
if (gstate.acct_mgr_op.error_str.size()) {
fout.printf(
" <error_msg>%s</error_msg>\n",
gstate.acct_mgr_op.error_str.c_str()
);
}
fout.printf(
"</acct_mgr_rpc_reply>\n"
);
} else {
fout.printf(
"<acct_mgr_rpc_reply>\n"
" <error_num>0</error_num>\n"
"</acct_mgr_rpc_reply>\n"
);
}
}
int GUI_RPC_CONN::handle_rpc() {
char request_msg[4096];
int n;
@ -725,10 +765,6 @@ int GUI_RPC_CONN::handle_rpc() {
handle_result_show_graphics(request_msg, mf);
} else if (match_tag(request_msg, "<project_reset")) {
handle_project_op(request_msg, mf, "reset");
} else if (match_tag(request_msg, "<project_attach>")) {
handle_project_attach(request_msg, mf);
} else if (match_tag(request_msg, "<project_attach_poll")) {
handle_project_attach_poll(request_msg, mf);
} else if (match_tag(request_msg, "<project_detach")) {
handle_project_op(request_msg, mf, "detach");
} else if (match_tag(request_msg, "<project_update")) {
@ -773,10 +809,6 @@ int GUI_RPC_CONN::handle_rpc() {
handle_get_host_info(request_msg, mf);
} else if (match_tag(request_msg, "<quit")) {
handle_quit(request_msg, mf);
} else if (match_tag(request_msg, "<acct_mgr_rpc>")) {
handle_acct_mgr_rpc(request_msg, mf);
} else if (match_tag(request_msg, "<acct_mgr_rpc_poll")) {
handle_acct_mgr_rpc_poll(request_msg, mf);
} else if (match_tag(request_msg, "<acct_mgr_info")) {
handle_acct_mgr_info(request_msg, mf);
} else if (match_tag(request_msg, "<get_statistics")) {
@ -785,6 +817,8 @@ int GUI_RPC_CONN::handle_rpc() {
handle_network_query(request_msg, mf);
} else if (match_tag(request_msg, "<network_available")) {
handle_network_available(request_msg, mf);
} else if (match_tag(request_msg, "<get_project_init_status")) {
handle_get_project_init_status(request_msg, mf);
} else if (match_tag(request_msg, "<get_project_config>")) {
handle_get_project_config(request_msg, mf);
} else if (match_tag(request_msg, "<get_project_config_poll")) {
@ -801,6 +835,14 @@ int GUI_RPC_CONN::handle_rpc() {
handle_lookup_website(request_msg, mf);
} else if (match_tag(request_msg, "<lookup_website_poll")) {
handle_lookup_website_poll(request_msg, mf);
} else if (match_tag(request_msg, "<project_attach>")) {
handle_project_attach(request_msg, mf);
} else if (match_tag(request_msg, "<project_attach_poll")) {
handle_project_attach_poll(request_msg, mf);
} else if (match_tag(request_msg, "<acct_mgr_rpc>")) {
handle_acct_mgr_rpc(request_msg, mf);
} else if (match_tag(request_msg, "<acct_mgr_rpc_poll")) {
handle_acct_mgr_rpc_poll(request_msg, mf);
} else {
mf.printf("<error>unrecognized op</error>\n");
}

View File

@ -323,7 +323,7 @@ bool CMainFrame::CreateMenu() {
menuFile->Append(
ID_FILESELECTCOMPUTER,
_("Select Computer..."),
_("Select computer..."),
_("Connect to another computer running BOINC")
);
@ -374,21 +374,21 @@ bool CMainFrame::CreateMenu() {
menuCommands->Append(
ID_FILERUNBENCHMARKS,
_("Run &Benchmarks"),
_("Run &benchmarks"),
_("Runs BOINC CPU benchmarks")
);
// Projects menu
wxMenu *menuProjects = new wxMenu;
menuProjects->Append(
ID_PROJECTSATTACHACCOUNTMANAGER,
_("Manage &Account Manager"),
_("Attach to an account manager")
ID_PROJECTSATTACHPROJECT,
_("&Attach to &project"),
_("Attach to a project to begin processing work")
);
menuProjects->Append(
ID_PROJECTSATTACHPROJECT,
_("&Attach to &Project"),
_("Attach to a project to begin processing work")
ID_PROJECTSATTACHACCOUNTMANAGER,
_("&Account manager"),
_("Attach to an account manager")
);
// Options menu
@ -409,7 +409,7 @@ bool CMainFrame::CreateMenu() {
menuHelp->Append(
ID_HELPBOINC,
_("BOINC &Website"),
_("BOINC &website"),
_("Show information about BOINC and BOINC Manager")
);

View File

@ -535,7 +535,6 @@ public:
DISPLAY_INFO&
);
int project_op(PROJECT&, const char* op);
int project_attach(const char* url, const char* auth);
int set_run_mode(int mode);
int get_run_mode(int& mode);
int set_network_mode(int mode);
@ -553,18 +552,17 @@ public:
int result_op(RESULT&, const char*);
int get_host_info(HOST_INFO&);
int quit();
int acct_mgr_rpc(const char* url, const char* name, const char* passwd);
int acct_mgr_rpc_poll(ACCT_MGR_RPC_REPLY&);
int acct_mgr_info(ACCT_MGR_INFO&);
const char* mode_name(int mode);
int get_statistics(PROJECTS&);
int network_query(int&);
int network_available();
int get_project_init_status(bool& has_project_init, bool& has_url, bool& has_account_key);
// the following are asynch operations.
// Make the first call to start the op,
// call the second one periodically until it returns zero.
// TODO: do project update and account manager RPC this way too
// TODO: do project update
//
int get_project_config(std::string url);
int get_project_config_poll(PROJECT_CONFIG&);
@ -574,7 +572,10 @@ public:
int create_account_poll(ACCOUNT_OUT&);
int lookup_website(int);
int lookup_website_poll();
int project_attach(const char* url, const char* auth, bool use_cached_credentials = false);
int project_attach_poll();
int acct_mgr_rpc(const char* url, const char* name, const char* passwd, bool use_cached_credentials = false);
int acct_mgr_rpc_poll(ACCT_MGR_RPC_REPLY&);
};
struct RPC {

View File

@ -770,10 +770,10 @@ int ACCT_MGR_INFO::parse(MIOFILE& in) {
password = "";
while (in.fgets(buf, 256)) {
if (match_tag(buf, "</acct_mgr_info>")) return 0;
if (parse_str(buf, "<acct_mgr_name>", acct_mgr_name)) continue;
if (parse_str(buf, "<acct_mgr_url>", acct_mgr_url)) continue;
if (parse_str(buf, "<login_name>", login_name)) continue;
if (parse_str(buf, "<password>", password)) continue;
else if (parse_str(buf, "<acct_mgr_name>", acct_mgr_name)) continue;
else if (parse_str(buf, "<acct_mgr_url>", acct_mgr_url)) continue;
else if (parse_str(buf, "<login_name>", login_name)) continue;
else if (parse_str(buf, "<password>", password)) continue;
}
return ERR_XML_PARSE;
}
@ -835,8 +835,8 @@ int ACCOUNT_OUT::parse(MIOFILE& in) {
clear();
while (in.fgets(buf, 256)) {
if (match_tag(buf, "</account_out>")) return 0;
if (parse_int(buf, "<error_num>", error_num)) return error_num;
if (parse_str(buf, "<authenticator>", authenticator)) continue;
else if (parse_int(buf, "<error_num>", error_num)) return error_num;
else if (parse_str(buf, "<authenticator>", authenticator)) continue;
}
return ERR_XML_PARSE;
}
@ -851,7 +851,7 @@ int LOOKUP_WEBSITE::parse(MIOFILE& in) {
clear();
while (in.fgets(buf, 256)) {
if (match_tag(buf, "</lookup_website>")) return 0;
if (parse_int(buf, "<error_num>", error_num)) return error_num;
else if (parse_int(buf, "<error_num>", error_num)) return error_num;
}
return ERR_XML_PARSE;
}
@ -1167,24 +1167,46 @@ int RPC_CLIENT::project_op(PROJECT& project, const char* op) {
return rpc.parse_reply();
}
int RPC_CLIENT::project_attach(const char* url, const char* auth) {
int RPC_CLIENT::project_attach(const char* url, const char* auth, bool use_cached_credentials) {
char buf[256];
int retval;
RPC rpc(this);
sprintf(buf,
"<project_attach>\n"
" <project_url>%s</project_url>\n"
" <authenticator>%s</authenticator>\n"
"</project_attach>\n",
url, auth
);
if (use_cached_credentials) {
sprintf(buf,
"<project_attach>\n"
" <use_cached_credentials/>\n"
"</project_attach>\n"
);
} else {
sprintf(buf,
"<project_attach>\n"
" <project_url>%s</project_url>\n"
" <authenticator>%s</authenticator>\n"
"</project_attach>\n",
url, auth
);
}
retval = rpc.do_rpc(buf);
if (retval) return retval;
return rpc.parse_reply();
}
int RPC_CLIENT::project_attach_poll() {
RPC rpc(this);
char buf[256];
int retval;
retval = rpc.do_rpc("<project_attach_poll/>\n");
if (retval) return retval;
retval = ERR_XML_PARSE;
while (rpc.fin.fgets(buf, 256)) {
parse_int(buf, "<error_num>", retval);
}
return retval;
}
const char* RPC_CLIENT::mode_name(int mode) {
const char* p = NULL;
switch (mode) {
@ -1214,9 +1236,9 @@ int RPC_CLIENT::get_run_mode(int& mode) {
mode = -1;
while (rpc.fin.fgets(buf, 256)) {
if (match_tag(buf, "</run_mode>")) break;
if (match_tag(buf, mode_name(RUN_MODE_ALWAYS))) mode = RUN_MODE_ALWAYS;
if (match_tag(buf, mode_name(RUN_MODE_NEVER))) mode = RUN_MODE_NEVER;
if (match_tag(buf, mode_name(RUN_MODE_AUTO))) mode = RUN_MODE_AUTO;
else if (match_tag(buf, mode_name(RUN_MODE_ALWAYS))) mode = RUN_MODE_ALWAYS;
else if (match_tag(buf, mode_name(RUN_MODE_NEVER))) mode = RUN_MODE_NEVER;
else if (match_tag(buf, mode_name(RUN_MODE_AUTO))) mode = RUN_MODE_AUTO;
}
return 0;
}
@ -1459,17 +1481,25 @@ int RPC_CLIENT::quit() {
return rpc.do_rpc("<quit/>\n");
}
int RPC_CLIENT::acct_mgr_rpc(const char* url, const char* name, const char* password) {
int RPC_CLIENT::acct_mgr_rpc(const char* url, const char* name, const char* password, bool use_cached_credentials) {
char buf[4096];
RPC rpc(this);
sprintf(buf,
"<acct_mgr_rpc>\n"
" <url>%s</url>\n"
" <name>%s</name>\n"
" <password>%s</password>\n"
"</acct_mgr_rpc>\n",
url, name, password
);
if (use_cached_credentials) {
sprintf(buf,
"<acct_mgr_rpc>\n"
" <use_cached_credentials/>\n"
"</acct_mgr_rpc>\n"
);
}else {
sprintf(buf,
"<acct_mgr_rpc>\n"
" <url>%s</url>\n"
" <name>%s</name>\n"
" <password>%s</password>\n"
"</acct_mgr_rpc>\n",
url, name, password
);
}
return rpc.do_rpc(buf);
}
@ -1616,17 +1646,4 @@ int RPC_CLIENT::lookup_website_poll() {
return lw.parse(rpc.fin);
}
int RPC_CLIENT::project_attach_poll() {
RPC rpc(this);
char buf[256];
int retval;
retval = rpc.do_rpc("<project_attach_poll/>\n");
if (retval) return retval;
retval = ERR_XML_PARSE;
while (rpc.fin.fgets(buf, 256)) {
parse_int(buf, "<error_num>", retval);
}
return retval;
}
const char *BOINC_RCSID_90e8b8d168="$Id$";