2008-08-15 07:13:00 +00:00
|
|
|
// This file is part of BOINC.
|
2008-07-18 14:38:27 +00:00
|
|
|
// http://boinc.berkeley.edu
|
2008-08-15 07:13:00 +00:00
|
|
|
// Copyright (C) 2008 University of California
|
2008-07-18 14:38:27 +00:00
|
|
|
//
|
2008-08-15 07:13:00 +00:00
|
|
|
// BOINC 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 3 of the License, or (at your option) any later version.
|
2008-07-18 14:38:27 +00:00
|
|
|
//
|
2008-08-15 07:13:00 +00:00
|
|
|
// BOINC is distributed in the hope that it will be useful,
|
2008-07-18 14:38:27 +00:00
|
|
|
// 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.
|
|
|
|
//
|
2008-08-15 07:13:00 +00:00
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
2008-07-18 14:38:27 +00:00
|
|
|
|
|
|
|
#ifndef _ASYNCRPC_H_
|
|
|
|
#define _ASYNCRPC_H_
|
|
|
|
|
|
|
|
#if defined(__GNUG__) && !defined(__APPLE__)
|
|
|
|
#pragma interface "AsyncRPC.cpp"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "wx/thread.h"
|
|
|
|
|
2008-07-23 14:16:59 +00:00
|
|
|
//#include "BOINCBaseFrame.h"
|
2008-07-18 14:38:27 +00:00
|
|
|
|
|
|
|
//#include "common_defs.h"
|
|
|
|
//#include "gui_rpc_client.h"
|
|
|
|
|
2008-07-23 14:16:59 +00:00
|
|
|
class CBOINCGUIApp; // Forward declaration
|
2008-07-18 14:38:27 +00:00
|
|
|
class CMainDocument; // Forward declaration
|
|
|
|
|
|
|
|
|
|
|
|
enum RPC_SELECTOR {
|
2008-07-23 03:54:49 +00:00
|
|
|
RPC_AUTHORIZE = 1,
|
2008-07-18 14:38:27 +00:00
|
|
|
RPC_EXCHANGE_VERSIONS,
|
|
|
|
RPC_GET_STATE,
|
|
|
|
RPC_GET_RESULTS,
|
|
|
|
RPC_GET_FILE_TRANSFERS,
|
2008-07-23 03:54:49 +00:00
|
|
|
RPC_GET_SIMPLE_GUI_INFO1,
|
|
|
|
RPC_GET_SIMPLE_GUI_INFO2,
|
|
|
|
RPC_GET_PROJECT_STATUS1,
|
|
|
|
RPC_GET_PROJECT_STATUS2,
|
2008-07-23 14:16:59 +00:00
|
|
|
RPC_GET_ALL_PROJECTS_LIST, // 10
|
2008-07-18 14:38:27 +00:00
|
|
|
RPC_GET_DISK_USAGE,
|
2008-07-23 03:54:49 +00:00
|
|
|
RPC_SHOW_GRAPHICS,
|
|
|
|
RPC_PROJECT_OP,
|
2008-07-18 14:38:27 +00:00
|
|
|
RPC_SET_RUN_MODE,
|
|
|
|
RPC_SET_NETWORK_MODE,
|
2008-07-23 03:54:49 +00:00
|
|
|
RPC_GET_SCREENSAVER_TASKS,
|
2008-07-18 14:38:27 +00:00
|
|
|
RPC_RUN_BENCHMARKS,
|
|
|
|
RPC_SET_PROXY_SETTINGS,
|
2008-07-23 03:54:49 +00:00
|
|
|
RPC_GET_PROXY_SETTINGS,
|
2008-07-23 14:16:59 +00:00
|
|
|
RPC_GET_MESSAGES, // 20
|
2008-07-18 14:38:27 +00:00
|
|
|
RPC_FILE_TRANSFER_OP,
|
2008-07-23 03:54:49 +00:00
|
|
|
RPC_RESULT_OP,
|
|
|
|
RPC_GET_HOST_INFO,
|
|
|
|
RPC_QUIT,
|
2008-07-18 14:38:27 +00:00
|
|
|
RPC_ACCT_MGR_INFO,
|
2008-07-23 03:54:49 +00:00
|
|
|
RPC_GET_STATISTICS,
|
2008-07-18 14:38:27 +00:00
|
|
|
RPC_NETWORK_AVAILABLE,
|
|
|
|
RPC_GET_PROJECT_INIT_STATUS,
|
2008-07-23 03:54:49 +00:00
|
|
|
RPC_GET_PROJECT_CONFIG,
|
2008-07-23 14:16:59 +00:00
|
|
|
RPC_GET_PROJECT_CONFIG_POLL, // 30
|
2008-07-18 14:38:27 +00:00
|
|
|
RPC_LOOKUP_ACCOUNT,
|
|
|
|
RPC_LOOKUP_ACCOUNT_POLL,
|
2008-07-23 03:54:49 +00:00
|
|
|
RPC_CREATE_ACCOUNT,
|
|
|
|
RPC_CREATE_ACCOUNT_POLL,
|
2008-07-18 14:38:27 +00:00
|
|
|
RPC_PROJECT_ATTACH,
|
|
|
|
RPC_PROJECT_ATTACH_FROM_FILE,
|
|
|
|
RPC_PROJECT_ATTACH_POLL,
|
2008-07-23 03:54:49 +00:00
|
|
|
RPC_ACCT_MGR_RPC,
|
|
|
|
RPC_ACCT_MGR_RPC_POLL,
|
2008-07-23 14:16:59 +00:00
|
|
|
RPC_GET_NEWER_VERSION, // 40
|
2008-07-23 03:54:49 +00:00
|
|
|
RPC_READ_GLOBAL_PREFS_OVERRIDE,
|
|
|
|
RPC_READ_CC_CONFIG,
|
|
|
|
RPC_GET_CC_STATUS,
|
|
|
|
RPC_GET_GLOBAL_PREFS_FILE,
|
|
|
|
RPC_GET_GLOBAL_PREFS_WORKING,
|
|
|
|
RPC_GET_GLOBAL_PREFS_WORKING_STRUCT,
|
|
|
|
RPC_GET_GLOBAL_PREFS_OVERRIDE,
|
|
|
|
RPC_SET_GLOBAL_PREFS_OVERRIDE,
|
|
|
|
RPC_GET_GLOBAL_PREFS_OVERRIDE_STRUCT,
|
2008-07-23 14:16:59 +00:00
|
|
|
RPC_SET_GLOBAL_PREFS_OVERRIDE_STRUCT, // 50
|
2008-07-23 03:54:49 +00:00
|
|
|
RPC_SET_DEBTS,
|
|
|
|
NUM_RPC_SELECTORS
|
2008-07-18 14:38:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct ASYNC_RPC_REQUEST {
|
|
|
|
RPC_SELECTOR which_rpc;
|
2008-07-23 03:54:49 +00:00
|
|
|
void *arg1;
|
2008-07-18 14:38:27 +00:00
|
|
|
void *exchangeBuf;
|
2008-07-23 03:54:49 +00:00
|
|
|
void *arg2;
|
|
|
|
void *arg3;
|
|
|
|
void *arg4;
|
2008-07-18 14:38:27 +00:00
|
|
|
wxEvent *event;
|
|
|
|
wxEvtHandler *eventHandler;
|
|
|
|
wxDateTime *completionTime;
|
2008-07-27 01:06:01 +00:00
|
|
|
int *resultPtr;
|
|
|
|
int retval;
|
2008-07-18 14:38:27 +00:00
|
|
|
bool isActive;
|
|
|
|
|
|
|
|
ASYNC_RPC_REQUEST();
|
|
|
|
~ASYNC_RPC_REQUEST();
|
|
|
|
|
2008-07-23 03:54:49 +00:00
|
|
|
void clear();
|
|
|
|
bool isSameAs(ASYNC_RPC_REQUEST& otherRequest);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class AsyncRPC
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
AsyncRPC(CMainDocument *pDoc);
|
|
|
|
~AsyncRPC();
|
|
|
|
|
2008-07-23 14:16:59 +00:00
|
|
|
int RPC_Wait(
|
|
|
|
RPC_SELECTOR which_rpc, void* arg1 = NULL, void*
|
|
|
|
arg2 = NULL, void* arg3 = NULL, void* arg4 = NULL,
|
|
|
|
bool hasPriority = false
|
|
|
|
);
|
2008-07-23 03:54:49 +00:00
|
|
|
|
|
|
|
// Manager must do all RPC data transfers through AsyncRPC calls, so
|
|
|
|
// this class must have methods corresponding to all RPC_CLIENT data
|
|
|
|
// transfer operations, but NOT init(), init_async(), close(), etc.
|
|
|
|
int authorize(const char* passwd)
|
|
|
|
{ return RPC_Wait(RPC_AUTHORIZE, (void*)passwd); }
|
|
|
|
int exchange_versions(VERSION_INFO& arg1)
|
|
|
|
{ return RPC_Wait(RPC_EXCHANGE_VERSIONS, (void*)&arg1); }
|
|
|
|
int get_state(CC_STATE& arg1)
|
|
|
|
{ return RPC_Wait(RPC_GET_STATE, (void*)&arg1); }
|
|
|
|
int get_results(RESULTS& arg1)
|
|
|
|
{ return RPC_Wait(RPC_GET_RESULTS, (void*)&arg1); }
|
|
|
|
int get_file_transfers(FILE_TRANSFERS& arg1)
|
|
|
|
{ return RPC_Wait(RPC_GET_FILE_TRANSFERS, (void*)&arg1); }
|
|
|
|
int get_simple_gui_info(SIMPLE_GUI_INFO& arg1)
|
|
|
|
{ return RPC_Wait(RPC_GET_SIMPLE_GUI_INFO1, (void*)&arg1); }
|
|
|
|
int get_simple_gui_info(CC_STATE& ccbuf, RESULTS& rbuf)
|
|
|
|
{ return RPC_Wait(RPC_GET_SIMPLE_GUI_INFO2, (void*)&ccbuf, (void*)&rbuf); }
|
|
|
|
int get_project_status(CC_STATE& arg1)
|
|
|
|
{ return RPC_Wait(RPC_GET_PROJECT_STATUS1, (void*)&arg1); }
|
|
|
|
int get_project_status(PROJECTS& arg1)
|
|
|
|
{ return RPC_Wait(RPC_GET_PROJECT_STATUS2, (void*)&arg1); }
|
|
|
|
int get_all_projects_list(ALL_PROJECTS_LIST& arg1)
|
|
|
|
{ return RPC_Wait(RPC_GET_ALL_PROJECTS_LIST, (void*)&arg1); }
|
|
|
|
int get_disk_usage(DISK_USAGE& arg1)
|
|
|
|
{ return RPC_Wait(RPC_GET_DISK_USAGE, (void*)&arg1); }
|
|
|
|
int show_graphics(
|
|
|
|
const char* project, const char* result_name, int graphics_mode, DISPLAY_INFO& di)
|
|
|
|
{ return RPC_Wait(RPC_SHOW_GRAPHICS, (void*)&project, (void*)result_name, (void*)&graphics_mode, (void*)&di); }
|
|
|
|
int project_op(PROJECT& arg1, const char* op)
|
|
|
|
{ return RPC_Wait(RPC_PROJECT_OP, (void*)&arg1, (void*)op); }
|
|
|
|
int set_run_mode(int mode, double duration)
|
|
|
|
{ return RPC_Wait(RPC_SET_RUN_MODE, (void*)&mode, (void*)&duration); }
|
|
|
|
// if duration is zero, change is permanent.
|
|
|
|
// otherwise, after duration expires,
|
|
|
|
// restore last permanent mode
|
|
|
|
int set_network_mode(int mode, double duration)
|
|
|
|
{ return RPC_Wait(RPC_SET_NETWORK_MODE, (void*)&mode, (void*)&duration); }
|
|
|
|
int get_screensaver_tasks(int& suspend_reason, RESULTS& rbuf)
|
|
|
|
{ return RPC_Wait(RPC_GET_SCREENSAVER_TASKS, (void*)&suspend_reason, (void*)&rbuf); }
|
|
|
|
int run_benchmarks()
|
|
|
|
{ return RPC_Wait(RPC_RUN_BENCHMARKS); }
|
|
|
|
int set_proxy_settings(GR_PROXY_INFO& arg1)
|
|
|
|
{ return RPC_Wait(RPC_SET_PROXY_SETTINGS, (void*)&arg1); }
|
|
|
|
int get_proxy_settings(GR_PROXY_INFO& arg1)
|
|
|
|
{ return RPC_Wait(RPC_GET_PROXY_SETTINGS, (void*)&arg1); }
|
|
|
|
int get_messages(int seqno, MESSAGES& arg1)
|
2008-07-23 14:16:59 +00:00
|
|
|
{ return RPC_Wait(RPC_GET_MESSAGES, (void*)&seqno, (void*)&arg1); }
|
2008-07-23 03:54:49 +00:00
|
|
|
int file_transfer_op(FILE_TRANSFER& arg1, const char* op)
|
|
|
|
{ return RPC_Wait(RPC_FILE_TRANSFER_OP, (void*)&arg1, (void*)op); }
|
|
|
|
int result_op(RESULT& arg1, const char* op)
|
|
|
|
{ return RPC_Wait(RPC_RESULT_OP, (void*)&arg1, (void*)op); }
|
|
|
|
int get_host_info(HOST_INFO& arg1)
|
|
|
|
{ return RPC_Wait(RPC_GET_HOST_INFO, (void*)&arg1); }
|
|
|
|
int quit()
|
|
|
|
{ return RPC_Wait(RPC_QUIT); }
|
|
|
|
int acct_mgr_info(ACCT_MGR_INFO& arg1)
|
|
|
|
{ return RPC_Wait(RPC_ACCT_MGR_INFO, (void*)&arg1); }
|
|
|
|
int get_statistics(PROJECTS& arg1)
|
|
|
|
{ return RPC_Wait(RPC_GET_STATISTICS, (void*)&arg1); }
|
|
|
|
int network_available()
|
|
|
|
{ return RPC_Wait(RPC_NETWORK_AVAILABLE); }
|
|
|
|
int get_project_init_status(PROJECT_INIT_STATUS& pis)
|
|
|
|
{ return RPC_Wait(RPC_GET_PROJECT_INIT_STATUS, (void*)&pis); }
|
|
|
|
|
|
|
|
// 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
|
|
|
|
//
|
|
|
|
int get_project_config(std::string url)
|
|
|
|
{ return RPC_Wait(RPC_GET_PROJECT_CONFIG, (void*)&url); }
|
|
|
|
int get_project_config_poll(PROJECT_CONFIG& arg1)
|
|
|
|
{ return RPC_Wait(RPC_GET_PROJECT_CONFIG_POLL, (void*)&arg1); }
|
|
|
|
int lookup_account(ACCOUNT_IN& arg1)
|
|
|
|
{ return RPC_Wait(RPC_LOOKUP_ACCOUNT, (void*)&arg1); }
|
|
|
|
int lookup_account_poll(ACCOUNT_OUT& arg1)
|
|
|
|
{ return RPC_Wait(RPC_LOOKUP_ACCOUNT_POLL, (void*)&arg1); }
|
|
|
|
int create_account(ACCOUNT_IN& arg1)
|
|
|
|
{ return RPC_Wait(RPC_CREATE_ACCOUNT, (void*)&arg1); }
|
|
|
|
int create_account_poll(ACCOUNT_OUT& arg1)
|
|
|
|
{ return RPC_Wait(RPC_CREATE_ACCOUNT_POLL, (void*)&arg1); }
|
|
|
|
int project_attach(
|
|
|
|
const char* url, const char* auth, const char* project_name
|
|
|
|
) { return RPC_Wait(RPC_PROJECT_ATTACH, (void*)url, (void*)auth, (void*)project_name); }
|
|
|
|
int project_attach_from_file()
|
|
|
|
{ return RPC_Wait(RPC_PROJECT_ATTACH_FROM_FILE); }
|
|
|
|
int project_attach_poll(PROJECT_ATTACH_REPLY& arg1)
|
|
|
|
{ return RPC_Wait(RPC_PROJECT_ATTACH_POLL, (void*)&arg1); }
|
|
|
|
int acct_mgr_rpc(
|
|
|
|
const char* url, const char* name, const char* passwd,
|
|
|
|
bool use_config_file=false
|
|
|
|
) { return RPC_Wait(RPC_ACCT_MGR_RPC, (void*)url, (void*)name, (void*)passwd, (void*)&use_config_file); }
|
|
|
|
int acct_mgr_rpc_poll(ACCT_MGR_RPC_REPLY& arg1)
|
|
|
|
{ return RPC_Wait(RPC_ACCT_MGR_RPC_POLL, (void*)&arg1); }
|
|
|
|
|
|
|
|
int get_newer_version(std::string& arg1)
|
|
|
|
{ return RPC_Wait(RPC_GET_NEWER_VERSION, (void*)&arg1); }
|
|
|
|
int read_global_prefs_override()
|
|
|
|
{ return RPC_Wait(RPC_READ_GLOBAL_PREFS_OVERRIDE); }
|
|
|
|
int read_cc_config()
|
|
|
|
{ return RPC_Wait(RPC_READ_CC_CONFIG); }
|
|
|
|
int get_cc_status(CC_STATUS& arg1)
|
|
|
|
{ return RPC_Wait(RPC_GET_CC_STATUS, (void*)&arg1); }
|
|
|
|
int get_global_prefs_file(std::string& arg1)
|
|
|
|
{ return RPC_Wait(RPC_GET_GLOBAL_PREFS_FILE, (void*)&arg1); }
|
|
|
|
int get_global_prefs_working(std::string& arg1)
|
|
|
|
{ return RPC_Wait(RPC_GET_GLOBAL_PREFS_WORKING, (void*)&arg1); }
|
|
|
|
int get_global_prefs_working_struct(GLOBAL_PREFS& arg1, GLOBAL_PREFS_MASK& arg2)
|
|
|
|
{ return RPC_Wait(RPC_GET_GLOBAL_PREFS_WORKING_STRUCT, (void*)&arg1, (void*)&arg2); }
|
|
|
|
int get_global_prefs_override(std::string& arg1)
|
|
|
|
{ return RPC_Wait(RPC_GET_GLOBAL_PREFS_OVERRIDE, (void*)&arg1); }
|
|
|
|
int set_global_prefs_override(std::string& arg1)
|
|
|
|
{ return RPC_Wait(RPC_SET_GLOBAL_PREFS_OVERRIDE, (void*)&arg1); }
|
|
|
|
int get_global_prefs_override_struct(GLOBAL_PREFS& arg1, GLOBAL_PREFS_MASK& arg2)
|
|
|
|
{ return RPC_Wait(RPC_GET_GLOBAL_PREFS_OVERRIDE_STRUCT, (void*)&arg1, (void*)&arg2); }
|
|
|
|
int set_global_prefs_override_struct(GLOBAL_PREFS& arg1, GLOBAL_PREFS_MASK& arg2)
|
|
|
|
{ return RPC_Wait(RPC_SET_GLOBAL_PREFS_OVERRIDE_STRUCT, (void*)&arg1, (void*)&arg2); }
|
|
|
|
int set_debts(std::vector<PROJECT> arg1)
|
|
|
|
{ return RPC_Wait(RPC_SET_DEBTS, (void*)&arg1); }
|
|
|
|
|
|
|
|
private:
|
|
|
|
CMainDocument *m_Doc;
|
2008-07-18 14:38:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class RPCThread : public wxThread
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
RPCThread(CMainDocument *pDoc);
|
2008-07-23 03:54:49 +00:00
|
|
|
virtual void *Entry();
|
|
|
|
virtual void OnExit();
|
2008-07-18 14:38:27 +00:00
|
|
|
|
|
|
|
private:
|
2008-07-23 03:54:49 +00:00
|
|
|
int ProcessRPCRequest();
|
|
|
|
CMainDocument *m_Doc;
|
2008-07-18 14:38:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class AsyncRPCDlg : public wxDialog
|
|
|
|
{
|
|
|
|
DECLARE_DYNAMIC_CLASS( AsyncRPCDlg )
|
|
|
|
|
|
|
|
public:
|
|
|
|
AsyncRPCDlg();
|
2008-07-23 03:54:49 +00:00
|
|
|
void OnRPCDlgTimer(wxTimerEvent &event);
|
2008-07-18 14:38:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class CRPCFinishedEvent : public wxEvent
|
|
|
|
{
|
|
|
|
public:
|
2008-07-23 14:16:59 +00:00
|
|
|
CRPCFinishedEvent(wxEventType evtType)
|
2008-07-18 14:38:27 +00:00
|
|
|
: wxEvent(-1, evtType)
|
|
|
|
{
|
2008-07-23 14:16:59 +00:00
|
|
|
SetEventObject(wxTheApp);
|
2008-07-18 14:38:27 +00:00
|
|
|
}
|
|
|
|
|
2008-07-29 13:06:28 +00:00
|
|
|
virtual wxEvent *Clone() const { return new CRPCFinishedEvent(*this); }
|
2008-07-18 14:38:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
BEGIN_DECLARE_EVENT_TYPES()
|
|
|
|
DECLARE_EVENT_TYPE( wxEVT_RPC_FINISHED, -1 )
|
|
|
|
END_DECLARE_EVENT_TYPES()
|
|
|
|
|
|
|
|
#define EVT_RPC_FINISHED(fn) \
|
|
|
|
DECLARE_EVENT_TABLE_ENTRY(wxEVT_RPC_FINISHED, -1, -1, (wxObjectEventFunction) (wxEventFunction) &fn, NULL),
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-07-22 13:26:52 +00:00
|
|
|
#endif // _ASYNCRPC_H_
|