2004-11-14 08:29:32 +00:00
|
|
|
// $Id$
|
|
|
|
//
|
2004-06-01 17:02:14 +00:00
|
|
|
// 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
|
|
|
|
// http://boinc.berkeley.edu/license_1.0.txt
|
|
|
|
//
|
|
|
|
// 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-09-30 21:55:19 +00:00
|
|
|
// a C++ interface to BOINC GUI RPC
|
|
|
|
|
2004-06-10 07:49:50 +00:00
|
|
|
#ifndef _WIN32
|
2004-01-21 07:07:16 +00:00
|
|
|
#include <stdio.h>
|
2004-01-23 21:57:47 +00:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2004-06-10 07:49:50 +00:00
|
|
|
#endif
|
2004-01-23 21:57:47 +00:00
|
|
|
|
2004-06-12 04:45:36 +00:00
|
|
|
#include "miofile.h"
|
|
|
|
|
2004-11-17 09:27:06 +00:00
|
|
|
#define GUI_RPC_PORT 1043
|
|
|
|
|
|
|
|
#define RUN_MODE_ALWAYS 0
|
|
|
|
#define RUN_MODE_NEVER 1
|
|
|
|
#define RUN_MODE_AUTO 2
|
|
|
|
|
|
|
|
#define RESULT_NEW 0
|
|
|
|
#define RESULT_FILES_DOWNLOADING 1
|
|
|
|
#define RESULT_FILES_DOWNLOADED 2
|
|
|
|
#define RESULT_COMPUTE_ERROR 3
|
|
|
|
#define RESULT_FILES_UPLOADING 4
|
|
|
|
#define RESULT_FILES_UPLOADED 5
|
|
|
|
|
|
|
|
#define CPU_SCHED_UNINITIALIZED 0
|
|
|
|
#define CPU_SCHED_PREEMPTED 1
|
|
|
|
#define CPU_SCHED_SCHEDULED 2
|
|
|
|
|
|
|
|
#define SS_STATUS_ENABLED 1
|
|
|
|
#define SS_STATUS_RESTARTREQUEST 2
|
|
|
|
#define SS_STATUS_BLANKED 3
|
|
|
|
#define SS_STATUS_BOINCSUSPENDED 4
|
|
|
|
#define SS_STATUS_NOTGRAPHICSCAPABLE 5
|
|
|
|
#define SS_STATUS_NOAPPSEXECUTING 6
|
|
|
|
#define SS_STATUS_NOGRAPHICSAPPSEXECUTING 7
|
2004-11-18 01:52:07 +00:00
|
|
|
#define SS_STATUS_QUIT 8
|
2004-07-08 17:59:46 +00:00
|
|
|
|
2004-09-27 23:35:21 +00:00
|
|
|
struct GUI_URL {
|
|
|
|
std::string name;
|
|
|
|
std::string description;
|
|
|
|
std::string url;
|
|
|
|
|
|
|
|
int parse(MIOFILE&);
|
|
|
|
void print();
|
|
|
|
};
|
|
|
|
|
2004-09-14 15:52:06 +00:00
|
|
|
class PROJECT {
|
|
|
|
public:
|
2004-07-01 17:37:26 +00:00
|
|
|
std::string master_url;
|
2004-01-23 21:57:47 +00:00
|
|
|
double resource_share;
|
2004-07-01 17:37:26 +00:00
|
|
|
std::string project_name;
|
|
|
|
std::string user_name;
|
|
|
|
std::string team_name;
|
2004-09-27 23:35:21 +00:00
|
|
|
std::vector<GUI_URL> gui_urls;
|
2004-01-23 21:57:47 +00:00
|
|
|
double user_total_credit;
|
|
|
|
double user_expavg_credit;
|
|
|
|
double host_total_credit; // as reported by server
|
|
|
|
double host_expavg_credit; // as reported by server
|
2004-10-22 22:37:11 +00:00
|
|
|
double disk_usage;
|
2004-01-23 21:57:47 +00:00
|
|
|
int nrpc_failures; // # of consecutive times we've failed to
|
|
|
|
// contact all scheduling servers
|
|
|
|
int master_fetch_failures;
|
2004-11-15 19:23:58 +00:00
|
|
|
double min_rpc_time; // earliest time to contact any server
|
2004-01-23 21:57:47 +00:00
|
|
|
|
|
|
|
bool master_url_fetch_pending; // need to fetch and parse the master URL
|
|
|
|
bool sched_rpc_pending; // contact scheduling server for preferences
|
|
|
|
bool tentative; // master URL and account ID not confirmed
|
2004-09-27 23:35:21 +00:00
|
|
|
bool suspended_via_gui;
|
2004-12-30 03:03:26 +00:00
|
|
|
bool dont_request_more_work;
|
2004-01-23 21:57:47 +00:00
|
|
|
|
2004-09-14 15:52:06 +00:00
|
|
|
PROJECT();
|
|
|
|
~PROJECT();
|
|
|
|
|
2004-06-12 04:45:36 +00:00
|
|
|
int parse(MIOFILE&);
|
2004-01-23 21:57:47 +00:00
|
|
|
void print();
|
2004-09-14 15:52:06 +00:00
|
|
|
void clear();
|
2004-01-23 21:57:47 +00:00
|
|
|
};
|
|
|
|
|
2004-09-14 15:52:06 +00:00
|
|
|
class APP {
|
|
|
|
public:
|
2004-07-01 17:37:26 +00:00
|
|
|
std::string name;
|
2004-01-23 21:57:47 +00:00
|
|
|
PROJECT* project;
|
|
|
|
|
2004-09-14 15:52:06 +00:00
|
|
|
APP();
|
|
|
|
~APP();
|
|
|
|
|
2004-06-12 04:45:36 +00:00
|
|
|
int parse(MIOFILE&);
|
2004-01-23 21:57:47 +00:00
|
|
|
void print();
|
2004-09-14 15:52:06 +00:00
|
|
|
void clear();
|
2004-01-23 21:57:47 +00:00
|
|
|
};
|
|
|
|
|
2004-09-14 15:52:06 +00:00
|
|
|
class APP_VERSION {
|
|
|
|
public:
|
2004-07-01 17:37:26 +00:00
|
|
|
std::string app_name;
|
2004-01-23 21:57:47 +00:00
|
|
|
int version_num;
|
|
|
|
APP* app;
|
|
|
|
PROJECT* project;
|
|
|
|
|
2004-09-14 15:52:06 +00:00
|
|
|
APP_VERSION();
|
|
|
|
~APP_VERSION();
|
|
|
|
|
2004-06-12 04:45:36 +00:00
|
|
|
int parse(MIOFILE&);
|
2004-01-23 21:57:47 +00:00
|
|
|
void print();
|
2004-09-14 15:52:06 +00:00
|
|
|
void clear();
|
2004-01-23 21:57:47 +00:00
|
|
|
};
|
|
|
|
|
2004-09-14 15:52:06 +00:00
|
|
|
class WORKUNIT {
|
|
|
|
public:
|
2004-07-01 17:37:26 +00:00
|
|
|
std::string name;
|
|
|
|
std::string app_name;
|
2004-01-23 21:57:47 +00:00
|
|
|
int version_num;
|
|
|
|
double rsc_fpops_est;
|
|
|
|
double rsc_fpops_bound;
|
|
|
|
double rsc_memory_bound;
|
|
|
|
double rsc_disk_bound;
|
|
|
|
PROJECT* project;
|
|
|
|
APP* app;
|
|
|
|
APP_VERSION* avp;
|
|
|
|
|
2004-09-14 15:52:06 +00:00
|
|
|
WORKUNIT();
|
|
|
|
~WORKUNIT();
|
|
|
|
|
2004-06-12 04:45:36 +00:00
|
|
|
int parse(MIOFILE&);
|
2004-01-23 21:57:47 +00:00
|
|
|
void print();
|
2004-09-14 15:52:06 +00:00
|
|
|
void clear();
|
2004-01-23 21:57:47 +00:00
|
|
|
};
|
|
|
|
|
2004-09-14 15:52:06 +00:00
|
|
|
class RESULT {
|
|
|
|
public:
|
2004-07-01 17:37:26 +00:00
|
|
|
std::string name;
|
|
|
|
std::string wu_name;
|
2004-10-19 21:48:17 +00:00
|
|
|
std::string project_url;
|
2004-01-23 21:57:47 +00:00
|
|
|
int report_deadline;
|
|
|
|
bool ready_to_report;
|
|
|
|
bool got_server_ack;
|
|
|
|
double final_cpu_time;
|
|
|
|
int state;
|
2004-10-19 18:14:40 +00:00
|
|
|
int scheduler_state;
|
2004-01-23 21:57:47 +00:00
|
|
|
int exit_status;
|
|
|
|
int signal;
|
2004-10-26 20:53:24 +00:00
|
|
|
std::string stderr_out;
|
2004-07-19 19:40:06 +00:00
|
|
|
// the following defined if active
|
2004-10-20 23:38:56 +00:00
|
|
|
bool active_task;
|
2004-10-26 20:53:24 +00:00
|
|
|
int active_task_state;
|
2004-01-31 23:21:07 +00:00
|
|
|
int app_version_num;
|
|
|
|
double checkpoint_cpu_time;
|
|
|
|
double current_cpu_time;
|
|
|
|
double fraction_done;
|
2004-12-14 20:28:13 +00:00
|
|
|
double vm_bytes;
|
|
|
|
double rss_bytes;
|
2004-10-20 21:50:28 +00:00
|
|
|
double estimated_cpu_time_remaining;
|
2004-09-27 23:35:21 +00:00
|
|
|
bool suspended_via_gui;
|
2004-10-26 22:54:43 +00:00
|
|
|
bool supports_graphics;
|
2004-07-14 00:53:12 +00:00
|
|
|
|
|
|
|
APP* app;
|
|
|
|
WORKUNIT* wup;
|
2004-01-31 23:21:07 +00:00
|
|
|
PROJECT* project;
|
|
|
|
|
2004-09-14 15:52:06 +00:00
|
|
|
RESULT();
|
|
|
|
~RESULT();
|
|
|
|
|
2004-06-12 04:45:36 +00:00
|
|
|
int parse(MIOFILE&);
|
2004-01-31 23:21:07 +00:00
|
|
|
void print();
|
2004-09-14 15:52:06 +00:00
|
|
|
void clear();
|
2004-01-31 23:21:07 +00:00
|
|
|
};
|
|
|
|
|
2004-09-14 15:52:06 +00:00
|
|
|
class FILE_TRANSFER {
|
|
|
|
public:
|
|
|
|
std::string name;
|
2004-10-19 21:48:17 +00:00
|
|
|
std::string project_url;
|
2004-10-22 20:11:38 +00:00
|
|
|
std::string project_name;
|
2004-10-22 00:22:11 +00:00
|
|
|
double nbytes;
|
2004-09-14 15:52:06 +00:00
|
|
|
bool generated_locally;
|
|
|
|
bool uploaded;
|
|
|
|
bool upload_when_present;
|
|
|
|
bool sticky;
|
|
|
|
bool pers_xfer_active;
|
|
|
|
bool xfer_active;
|
|
|
|
int num_retries;
|
2004-10-22 18:39:21 +00:00
|
|
|
int first_request_time;
|
|
|
|
int next_request_time;
|
|
|
|
int status;
|
|
|
|
double time_so_far;
|
2004-09-14 15:52:06 +00:00
|
|
|
double bytes_xferred;
|
|
|
|
double file_offset;
|
|
|
|
double xfer_speed;
|
|
|
|
std::string hostname;
|
|
|
|
PROJECT* project;
|
|
|
|
|
|
|
|
FILE_TRANSFER();
|
|
|
|
~FILE_TRANSFER();
|
|
|
|
|
|
|
|
int parse(MIOFILE&);
|
|
|
|
void print();
|
|
|
|
void clear();
|
2004-04-02 00:19:22 +00:00
|
|
|
};
|
|
|
|
|
2004-09-14 15:52:06 +00:00
|
|
|
class MESSAGE {
|
|
|
|
public:
|
2004-07-01 17:37:26 +00:00
|
|
|
std::string project;
|
2004-04-02 00:19:22 +00:00
|
|
|
int priority;
|
2004-09-28 22:48:42 +00:00
|
|
|
int seqno;
|
2004-04-02 00:19:22 +00:00
|
|
|
int timestamp;
|
2004-07-01 17:37:26 +00:00
|
|
|
std::string body;
|
2004-09-14 15:52:06 +00:00
|
|
|
|
|
|
|
MESSAGE();
|
|
|
|
~MESSAGE();
|
|
|
|
|
|
|
|
int parse(MIOFILE&);
|
|
|
|
void print();
|
|
|
|
void clear();
|
2004-04-02 00:19:22 +00:00
|
|
|
};
|
|
|
|
|
2004-09-14 15:52:06 +00:00
|
|
|
class PROXY_INFO {
|
|
|
|
public:
|
|
|
|
bool use_http_proxy;
|
|
|
|
bool use_socks_proxy;
|
2004-09-25 19:33:30 +00:00
|
|
|
bool use_http_authentication;
|
2004-09-14 15:52:06 +00:00
|
|
|
int socks_version;
|
|
|
|
std::string socks_server_name;
|
|
|
|
std::string http_server_name;
|
|
|
|
int socks_server_port;
|
|
|
|
int http_server_port;
|
|
|
|
std::string http_user_name;
|
|
|
|
std::string http_user_passwd;
|
|
|
|
std::string socks5_user_name;
|
|
|
|
std::string socks5_user_passwd;
|
|
|
|
|
|
|
|
PROXY_INFO();
|
|
|
|
~PROXY_INFO();
|
|
|
|
|
|
|
|
int parse(MIOFILE&);
|
|
|
|
void print();
|
|
|
|
void clear();
|
|
|
|
};
|
|
|
|
|
2004-10-12 00:27:48 +00:00
|
|
|
struct HOST_INFO {
|
|
|
|
int timezone; // seconds added to local time to get UTC
|
|
|
|
char domain_name[256];
|
|
|
|
char serialnum[256];
|
|
|
|
char ip_addr[256];
|
|
|
|
|
|
|
|
int p_ncpus;
|
|
|
|
char p_vendor[256];
|
|
|
|
char p_model[256];
|
|
|
|
double p_fpops;
|
|
|
|
double p_iops;
|
|
|
|
double p_membw;
|
|
|
|
int p_fpop_err;
|
|
|
|
int p_iop_err;
|
|
|
|
int p_membw_err;
|
|
|
|
double p_calculated; //needs to be initialized to zero
|
|
|
|
|
|
|
|
char os_name[256];
|
|
|
|
char os_version[256];
|
|
|
|
|
|
|
|
double m_nbytes;
|
|
|
|
double m_cache;
|
|
|
|
double m_swap;
|
|
|
|
|
|
|
|
double d_total;
|
|
|
|
double d_free;
|
|
|
|
|
2004-10-20 01:29:53 +00:00
|
|
|
HOST_INFO();
|
|
|
|
~HOST_INFO();
|
|
|
|
|
2004-10-12 00:27:48 +00:00
|
|
|
int parse(MIOFILE&);
|
2004-10-20 01:29:53 +00:00
|
|
|
void clear();
|
2004-10-12 00:27:48 +00:00
|
|
|
};
|
|
|
|
|
2004-09-14 15:52:06 +00:00
|
|
|
class CC_STATE {
|
|
|
|
public:
|
2004-06-30 18:17:21 +00:00
|
|
|
std::vector<PROJECT*> projects;
|
|
|
|
std::vector<APP*> apps;
|
|
|
|
std::vector<APP_VERSION*> app_versions;
|
|
|
|
std::vector<WORKUNIT*> wus;
|
|
|
|
std::vector<RESULT*> results;
|
2004-01-23 21:57:47 +00:00
|
|
|
|
2004-09-14 15:52:06 +00:00
|
|
|
CC_STATE();
|
|
|
|
~CC_STATE();
|
|
|
|
|
2004-10-09 03:05:01 +00:00
|
|
|
PROJECT* lookup_project(std::string&);
|
2004-10-19 22:41:26 +00:00
|
|
|
APP* lookup_app(std::string&, std::string&);
|
2004-10-19 20:11:40 +00:00
|
|
|
APP* lookup_app(PROJECT*, std::string&);
|
2004-10-19 22:41:26 +00:00
|
|
|
APP_VERSION* lookup_app_version(std::string&, std::string&, int);
|
2004-10-19 20:11:40 +00:00
|
|
|
APP_VERSION* lookup_app_version(PROJECT*, std::string&, int);
|
2004-10-19 22:41:26 +00:00
|
|
|
WORKUNIT* lookup_wu(std::string&, std::string&);
|
2004-10-19 20:11:40 +00:00
|
|
|
WORKUNIT* lookup_wu(PROJECT*, std::string&);
|
2004-10-19 22:41:26 +00:00
|
|
|
RESULT* lookup_result(std::string&, std::string&);
|
2004-10-19 20:11:40 +00:00
|
|
|
RESULT* lookup_result(PROJECT*, std::string&);
|
2004-09-14 15:52:06 +00:00
|
|
|
|
2004-07-13 23:51:09 +00:00
|
|
|
void print();
|
2004-09-14 15:52:06 +00:00
|
|
|
void clear();
|
2004-07-13 23:51:09 +00:00
|
|
|
};
|
2004-01-23 21:57:47 +00:00
|
|
|
|
2004-09-14 15:52:06 +00:00
|
|
|
class PROJECTS {
|
|
|
|
public:
|
|
|
|
std::vector<PROJECT*> projects;
|
|
|
|
|
|
|
|
PROJECTS();
|
|
|
|
~PROJECTS();
|
|
|
|
|
|
|
|
void print();
|
|
|
|
void clear();
|
|
|
|
};
|
|
|
|
|
|
|
|
class RESULTS {
|
|
|
|
public:
|
2004-07-13 23:51:09 +00:00
|
|
|
std::vector<RESULT*> results;
|
2004-09-14 15:52:06 +00:00
|
|
|
|
|
|
|
RESULTS();
|
|
|
|
~RESULTS();
|
|
|
|
|
2004-07-13 23:51:09 +00:00
|
|
|
void print();
|
2004-09-14 15:52:06 +00:00
|
|
|
void clear();
|
2004-07-13 23:51:09 +00:00
|
|
|
};
|
|
|
|
|
2004-09-14 15:52:06 +00:00
|
|
|
class FILE_TRANSFERS {
|
|
|
|
public:
|
2004-07-13 23:51:09 +00:00
|
|
|
std::vector<FILE_TRANSFER*> file_transfers;
|
2004-09-14 15:52:06 +00:00
|
|
|
|
|
|
|
FILE_TRANSFERS();
|
|
|
|
~FILE_TRANSFERS();
|
|
|
|
|
2004-07-13 23:51:09 +00:00
|
|
|
void print();
|
2004-09-14 15:52:06 +00:00
|
|
|
void clear();
|
|
|
|
};
|
|
|
|
|
|
|
|
class MESSAGES {
|
|
|
|
public:
|
|
|
|
std::vector<MESSAGE*> messages;
|
|
|
|
|
|
|
|
MESSAGES();
|
|
|
|
~MESSAGES();
|
|
|
|
|
|
|
|
void print();
|
|
|
|
void clear();
|
2004-07-13 23:51:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class RPC_CLIENT {
|
2004-09-25 19:33:30 +00:00
|
|
|
public:
|
2004-11-18 01:30:37 +00:00
|
|
|
int sock;
|
2004-07-13 23:51:09 +00:00
|
|
|
int send_request(char*);
|
|
|
|
int get_reply(char*&);
|
2004-09-14 15:52:06 +00:00
|
|
|
|
2004-07-13 23:51:09 +00:00
|
|
|
public:
|
2004-01-23 21:57:47 +00:00
|
|
|
|
2004-09-14 15:52:06 +00:00
|
|
|
RPC_CLIENT();
|
2004-01-21 07:07:16 +00:00
|
|
|
~RPC_CLIENT();
|
2004-10-28 19:10:50 +00:00
|
|
|
int init(const char* host);
|
2004-09-30 21:55:19 +00:00
|
|
|
void close();
|
2004-07-13 23:51:09 +00:00
|
|
|
int get_state(CC_STATE&);
|
|
|
|
int get_results(RESULTS&);
|
|
|
|
int get_file_transfers(FILE_TRANSFERS&);
|
2004-09-14 15:52:06 +00:00
|
|
|
int get_project_status(PROJECTS&);
|
|
|
|
int get_disk_usage(PROJECTS&);
|
2004-11-17 09:27:06 +00:00
|
|
|
int show_graphics(const char* project, const char* result_name, bool full_screen, const char* window_station, const char* desktop);
|
2004-09-26 04:16:52 +00:00
|
|
|
int project_op(PROJECT&, char* op);
|
2004-04-01 23:19:13 +00:00
|
|
|
int project_attach(char* url, char* auth);
|
2004-09-05 18:46:19 +00:00
|
|
|
int set_run_mode(int mode);
|
|
|
|
int get_run_mode(int& mode);
|
|
|
|
int set_network_mode(int mode);
|
2004-09-05 18:51:41 +00:00
|
|
|
int get_network_mode(int& mode);
|
2004-11-17 09:27:06 +00:00
|
|
|
int get_screensaver_mode(int& status);
|
2004-11-15 06:44:50 +00:00
|
|
|
int set_screensaver_mode(bool enabled, const char* window_station, const char* desktop, double blank_time);
|
2004-04-01 23:19:13 +00:00
|
|
|
int run_benchmarks();
|
|
|
|
int set_proxy_settings(PROXY_INFO&);
|
2004-09-26 04:16:52 +00:00
|
|
|
int get_proxy_settings(PROXY_INFO&);
|
2004-09-30 21:41:09 +00:00
|
|
|
int get_messages(int seqno, MESSAGES&);
|
2004-09-26 04:16:52 +00:00
|
|
|
int file_transfer_op(FILE_TRANSFER&, char*);
|
|
|
|
int result_op(RESULT&, char*);
|
2004-10-12 00:27:48 +00:00
|
|
|
int get_host_info(HOST_INFO&);
|
2004-11-23 07:45:11 +00:00
|
|
|
int quit();
|
2004-09-14 15:52:06 +00:00
|
|
|
char* mode_name(int mode);
|
2004-01-21 07:07:16 +00:00
|
|
|
};
|
2004-09-25 19:33:30 +00:00
|
|
|
|
|
|
|
struct RPC {
|
|
|
|
char* mbuf;
|
|
|
|
MIOFILE fin;
|
|
|
|
RPC_CLIENT* rpc_client;
|
|
|
|
|
|
|
|
RPC(RPC_CLIENT*);
|
|
|
|
~RPC();
|
|
|
|
int do_rpc(char*);
|
|
|
|
};
|