00001 // This file is part of BOINC. 00002 // http://boinc.berkeley.edu 00003 // Copyright (C) 2008 University of California 00004 // 00005 // BOINC is free software; you can redistribute it and/or modify it 00006 // under the terms of the GNU Lesser General Public License 00007 // as published by the Free Software Foundation, 00008 // either version 3 of the License, or (at your option) any later version. 00009 // 00010 // BOINC is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00013 // See the GNU Lesser General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU Lesser General Public License 00016 // along with BOINC. If not, see <http://www.gnu.org/licenses/>. 00017 00018 #ifndef _ACCT_MGR_ 00019 #define _ACCT_MGR_ 00020 00021 #include <string> 00022 #include <vector> 00023 00024 #include "miofile.h" 00025 #include "parse.h" 00026 #include "gui_http.h" 00027 #include "client_types.h" 00028 00030 00031 struct ACCT_MGR_INFO { 00032 // the following used to be std::string but there 00033 // were mysterious bugs where setting it to "" didn't work 00034 // 00035 char acct_mgr_name[256]; 00036 char acct_mgr_url[256]; 00037 char login_name[256]; 00039 char password_hash[256]; 00041 char opaque[256]; 00042 char signing_key[MAX_KEY_LEN]; 00044 char previous_host_cpid[64]; 00045 double next_rpc_time; 00048 bool send_gui_rpc_info; 00049 bool password_error; 00050 00051 ACCT_MGR_INFO(); 00052 int parse_login_file(FILE*); 00053 int write_info(); 00054 int init(); 00055 void clear(); 00056 bool poll(); 00057 }; 00058 00059 struct OPTIONAL_BOOL { 00060 bool present; 00061 bool value; 00062 inline void init() {present=false;} 00063 inline void set(bool v) {value=v; present=true;} 00064 }; 00065 00066 struct OPTIONAL_DOUBLE { 00067 bool present; 00068 double value; 00069 inline void init() {present=false;} 00070 inline void set(double v) {value=v; present=true;} 00071 }; 00072 00073 // stuff after here related to RPCs to account managers 00074 00075 struct AM_ACCOUNT { 00076 std::string url; 00077 std::string authenticator; 00078 char url_signature[MAX_SIGNATURE_LEN]; 00079 bool detach; 00080 bool update; 00081 OPTIONAL_BOOL dont_request_more_work; 00082 OPTIONAL_BOOL detach_when_done; 00083 OPTIONAL_DOUBLE resource_share; 00084 00085 int parse(XML_PARSER&); 00086 AM_ACCOUNT() {} 00087 ~AM_ACCOUNT() {} 00088 }; 00089 00090 struct ACCT_MGR_OP: public GUI_HTTP_OP { 00091 bool via_gui; 00092 int error_num; 00093 ACCT_MGR_INFO ami; 00094 // a temporary copy while doing RPC. 00095 // CLIENT_STATE::acct_mgr_info is authoratative 00096 std::string error_str; 00097 std::vector<AM_ACCOUNT> accounts; 00098 double repeat_sec; 00099 char* global_prefs_xml; 00100 char host_venue[256]; 00101 00102 int do_rpc( 00103 std::string url, std::string name, std::string password, 00104 bool via_gui 00105 ); 00106 int parse(FILE*); 00107 virtual void handle_reply(int http_op_retval); 00108 00109 ACCT_MGR_OP(); 00110 virtual ~ACCT_MGR_OP(){} 00111 }; 00112 00113 #endif
1.5.6