From 4f09c1979b6a5c0c9e991a8d1e6d783081d13c63 Mon Sep 17 00:00:00 2001 From: Charlie Fenton Date: Sat, 14 Jul 2018 04:59:06 -0700 Subject: [PATCH] Move client_version_check_url, client_download_url and client_new_version_text tags from cc_config.xml into new nvc_config.xml file. If nvc_config.cml file is absent, use default values. Branded installers can create or replace this file to customize these values. Standard (unbranded) BOINC installers should either delete the file or create or replace it with one containing default values. --- client/current_version.cpp | 92 +++++++++++++++++-- client/current_version.h | 14 +++ client/file_names.h | 1 + client/gui_rpc_server_ops.cpp | 2 +- client/log_flags.cpp | 11 --- client/main.cpp | 4 +- lib/cc_config.cpp | 23 ----- lib/cc_config.h | 3 - mac_installer/WCGridInstaller.environment | 2 + mac_installer/release_brand.sh | 5 + .../installerv2/redist/WCG/nvc_config.xml | 5 + 11 files changed, 117 insertions(+), 45 deletions(-) create mode 100644 win_build/installerv2/redist/WCG/nvc_config.xml diff --git a/client/current_version.cpp b/client/current_version.cpp index 1fb691edc1..ba72b8506f 100644 --- a/client/current_version.cpp +++ b/client/current_version.cpp @@ -24,15 +24,95 @@ #include "client_msgs.h" #include "client_state.h" -#include "log_flags.h" +#include "file_names.h" #include "current_version.h" +NVC_CONFIG nvc_config; + +NVC_CONFIG::NVC_CONFIG() { + defaults(); +} + +// this is called first thing by client +// +void NVC_CONFIG::defaults() { + client_download_url = "https://boinc.berkeley.edu/download.php"; + client_new_version_text = ""; + client_version_check_url = "https://boinc.berkeley.edu/download.php?xml=1"; +}; + +int NVC_CONFIG::parse(FILE* f) { + MIOFILE mf; + XML_PARSER xp(&mf); + + mf.init_file(f); + if (!xp.parse_start("nvc_config")) { + msg_printf_notice(NULL, false, + "https://boinc.berkeley.edu/manager_links.php?target=notice&controlid=config", + "%s", + _("Missing start tag in nvc_config.xml") + ); + return ERR_XML_PARSE; + } + while (!xp.get_tag()) { + if (!xp.is_tag) { + msg_printf_notice(NULL, false, + "https://boinc.berkeley.edu/manager_links.php?target=notice&controlid=config", + "%s: %s", + _("Unexpected text in nvc_config.xml"), + xp.parsed_tag + ); + continue; + } + if (xp.match_tag("/nvc_config")) { + notices.remove_notices(NULL, REMOVE_CONFIG_MSG); + return 0; + } + if (xp.parse_string("client_download_url", client_download_url)) { + downcase_string(client_download_url); + continue; + } + if (xp.parse_string("client_new_version_text", client_new_version_text)) { + continue; + } + if (xp.parse_string("client_version_check_url", client_version_check_url)) { + downcase_string(client_version_check_url); + continue; + } + msg_printf_notice(NULL, false, + "https://boinc.berkeley.edu/manager_links.php?target=notice&controlid=config", + "%s: <%s>", + _("Unrecognized tag in nvc_config.xml"), + xp.parsed_tag + ); + xp.skip_unexpected(true, "NVC_CONFIG.parse"); + } + msg_printf_notice(NULL, false, + "https://boinc.berkeley.edu/manager_links.php?target=notice&controlid=config", + "%s", + _("Missing end tag in nvc_config.xml") + ); + return ERR_XML_PARSE; +} + +int read_vc_config_file() { + nvc_config.defaults(); + FILE* f = boinc_fopen(NVC_CONFIG_FILE, "r"); + if (!f) { + msg_printf(NULL, MSG_INFO, "nvc_config.xml not found - using defaults"); + return ERR_FOPEN; + } + nvc_config.parse(f); + fclose(f); + return 0; +} + int GET_CURRENT_VERSION_OP::do_rpc() { int retval; retval = gui_http->do_rpc( - this, cc_config.client_version_check_url.c_str(), + this, nvc_config.client_version_check_url.c_str(), GET_CURRENT_VERSION_FILENAME, true ); @@ -84,21 +164,21 @@ static bool parse_version(FILE* f, char* new_version, int len) { } static void show_newer_version_msg(const char* new_vers) { - if (cc_config.client_new_version_text.empty()) { + if (nvc_config.client_new_version_text.empty()) { msg_printf_notice(0, true, "https://boinc.berkeley.edu/manager_links.php?target=notice&controlid=download", "%s (%s). %s", _("A new version of BOINC is available"), new_vers, - cc_config.client_download_url.c_str(), + nvc_config.client_download_url.c_str(), _("Download") ); } else { msg_printf_notice(0, true, NULL, "%s (%s). %s", - cc_config.client_new_version_text.c_str(), + nvc_config.client_new_version_text.c_str(), new_vers, - cc_config.client_download_url.c_str(), + nvc_config.client_download_url.c_str(), _("Download") ); } diff --git a/client/current_version.h b/client/current_version.h index a24a165c4c..c7229a1e05 100644 --- a/client/current_version.h +++ b/client/current_version.h @@ -34,4 +34,18 @@ struct GET_CURRENT_VERSION_OP: public GUI_HTTP_OP { extern void newer_version_startup_check(); +struct NVC_CONFIG { + std::string client_download_url; + std::string client_new_version_text; + std::string client_version_check_url; + + NVC_CONFIG(); + void defaults(); + int parse(FILE*); +}; + +extern NVC_CONFIG nvc_config; + +extern int read_vc_config_file(void); + #endif diff --git a/client/file_names.h b/client/file_names.h index d52c034079..bc5df19b92 100644 --- a/client/file_names.h +++ b/client/file_names.h @@ -70,6 +70,7 @@ extern void send_log_after(const char* filename, double t, MIOFILE& mf); #endif #define CLIENT_OPAQUE_FILENAME "client_opaque.txt" #define CONFIG_FILE "cc_config.xml" +#define NVC_CONFIG_FILE "nvc_config.xml" #define COPROC_INFO_FILENAME "coproc_info.xml" #define CPU_BENCHMARKS_FILE_NAME "cpu_benchmarks" #define CREATE_ACCOUNT_FILENAME "create_account.xml" diff --git a/client/gui_rpc_server_ops.cpp b/client/gui_rpc_server_ops.cpp index 5f1318a1e3..ec73b79307 100644 --- a/client/gui_rpc_server_ops.cpp +++ b/client/gui_rpc_server_ops.cpp @@ -1030,7 +1030,7 @@ static void handle_get_newer_version(GUI_RPC_CONN& grc) { "%s\n" "%s\n", gstate.newer_version.c_str(), - cc_config.client_download_url.c_str() + nvc_config.client_download_url.c_str() ); } diff --git a/client/log_flags.cpp b/client/log_flags.cpp index a5ade346d0..4f11d747d6 100644 --- a/client/log_flags.cpp +++ b/client/log_flags.cpp @@ -331,17 +331,6 @@ int CC_CONFIG::parse_options_client(XML_PARSER& xp) { alt_platforms.push_back(s); continue; } - if (xp.parse_string("client_download_url", client_download_url)) { - downcase_string(client_download_url); - continue; - } - if (xp.parse_string("client_new_version_text", client_new_version_text)) { - continue; - } - if (xp.parse_string("client_version_check_url", client_version_check_url)) { - downcase_string(client_version_check_url); - continue; - } if (xp.match_tag("coproc")) { COPROC c; retval = c.parse(xp); diff --git a/client/main.cpp b/client/main.cpp index c0c01abc2d..1691c770f5 100644 --- a/client/main.cpp +++ b/client/main.cpp @@ -185,6 +185,7 @@ static void init_core_client(int argc, char** argv) { setbuf(stderr, 0); cc_config.defaults(); + nvc_config.defaults(); gstate.parse_cmdline(argc, argv); gstate.now = dtime(); @@ -233,7 +234,8 @@ static void init_core_client(int argc, char** argv) { #endif read_config_file(true); - + read_vc_config_file(); + // Win32 - detach from console if requested #ifdef _WIN32 if (gstate.detach_console) { diff --git a/lib/cc_config.cpp b/lib/cc_config.cpp index 211b6fd896..dee112eb66 100644 --- a/lib/cc_config.cpp +++ b/lib/cc_config.cpp @@ -210,9 +210,6 @@ void CC_CONFIG::defaults() { allow_multiple_clients = false; allow_remote_gui_rpc = false; alt_platforms.clear(); - client_download_url = "https://boinc.berkeley.edu/download.php"; - client_new_version_text = ""; - client_version_check_url = "https://boinc.berkeley.edu/download.php?xml=1"; config_coprocs.clear(); disallow_attach = false; dont_check_file_sizes = false; @@ -330,17 +327,6 @@ int CC_CONFIG::parse_options(XML_PARSER& xp) { alt_platforms.push_back(s); continue; } - if (xp.parse_string("client_download_url", client_download_url)) { - downcase_string(client_download_url); - continue; - } - if (xp.parse_string("client_new_version_text", client_new_version_text)) { - continue; - } - if (xp.parse_string("client_version_check_url", client_version_check_url)) { - downcase_string(client_version_check_url); - continue; - } if (xp.match_tag("coproc")) { COPROC c; retval = c.parse(xp); @@ -524,15 +510,6 @@ int CC_CONFIG::write(MIOFILE& out, LOG_FLAGS& log_flags) { ); } - out.printf( - " %s\n" - " %s\n" - " %s\n", - client_version_check_url.c_str(), - client_new_version_text.c_str(), - client_download_url.c_str() - ); - for (int k=1; k alt_platforms; - std::string client_download_url; - std::string client_new_version_text; - std::string client_version_check_url; COPROCS config_coprocs; bool disallow_attach; bool dont_check_file_sizes; diff --git a/mac_installer/WCGridInstaller.environment b/mac_installer/WCGridInstaller.environment index 5820fea45d..699808c0ed 100644 --- a/mac_installer/WCGridInstaller.environment +++ b/mac_installer/WCGridInstaller.environment @@ -19,3 +19,5 @@ INSTALLERICON="WCGrid" READMEFILE="WCGrid-ReadMe.rtf" BRANDING_INFO="BrandId=4" + +NEWVERSIONCHECKDIR="WCG" diff --git a/mac_installer/release_brand.sh b/mac_installer/release_brand.sh index 189bb38941..f55de10b71 100755 --- a/mac_installer/release_brand.sh +++ b/mac_installer/release_brand.sh @@ -42,6 +42,7 @@ ## INSTALLERICON="WCGridInstaller.icns" ##The icon for the branded installer ## READMEFILE="WCGrid-ReadMe.rtf" ##The branded readme file ## BRANDING_INFO="BrandId=4" ##Info to write into the branding file +## NEWVERSIONCHECKDIR="WCG" ##The nvc_config.xml file to use, or empty string if none ## ## NOTE: This script requires Mac OS 10.6 or later, and uses XCode developer ## tools. So you must have installed XCode Developer Tools on the Mac @@ -191,6 +192,10 @@ cp -fp curl/ca-bundle.crt ../BOINC_Installer/Pkg_Root/Library/Application\ Suppo cp -fp win_build/installerv2/redist/all_projects_list.xml ../BOINC_Installer/Pkg_Root/Library/Application\ Support/BOINC\ Data/installer_projects_list.xml +if [ -n "${NEWVERSIONCHECKDIR}" ]; then + cp -fp "win_build/installerv2/redist/${NEWVERSIONCHECKDIR}/nvc_config.xml" ../BOINC_Installer/Pkg_Root/Library/Application\ Support/BOINC\ Data/installer_projects_list.xml +fi + cp -fp clientscr/res/boinc_logo_black.jpg ../BOINC_Installer/Pkg_Root/Library/Application\ Support/BOINC\ Data/ cp -fp api/ttf/liberation-fonts-ttf-2.00.0/LiberationSans-Regular.ttf ../BOINC_Installer/Pkg_Root/Library/Application\ Support/BOINC\ Data/LiberationSans-Regular.ttf cp -fp clientscr/ss_config.xml ../BOINC_Installer/Pkg_Root/Library/Application\ Support/BOINC\ Data/ diff --git a/win_build/installerv2/redist/WCG/nvc_config.xml b/win_build/installerv2/redist/WCG/nvc_config.xml new file mode 100644 index 0000000000..f050313f63 --- /dev/null +++ b/win_build/installerv2/redist/WCG/nvc_config.xml @@ -0,0 +1,5 @@ + + https://www.worldcommunitygrid.org/reg/ms/viewDownloadAgain.do + https://www.worldcommunitygrid.org/download_all.php?xml=1 + "A new version of World Community Grid is available" +