From 671035c9b1bae40b0144bab9f97ff1d163127c92 Mon Sep 17 00:00:00 2001 From: Jan Boon Date: Tue, 26 Nov 2019 08:40:33 +0800 Subject: [PATCH 01/10] Add source of old Qt based BNP make gui from sfb --- code/nel/tools/misc/bnp_make_qt/main.cpp | 11 + code/nel/tools/misc/bnp_make_qt/main.h | 8 + .../nel/tools/misc/bnp_make_qt/mainwindow.cpp | 253 ++++++++++++++ code/nel/tools/misc/bnp_make_qt/mainwindow.h | 61 ++++ code/nel/tools/misc/bnp_make_qt/mainwindow.ui | 322 ++++++++++++++++++ 5 files changed, 655 insertions(+) create mode 100644 code/nel/tools/misc/bnp_make_qt/main.cpp create mode 100644 code/nel/tools/misc/bnp_make_qt/main.h create mode 100644 code/nel/tools/misc/bnp_make_qt/mainwindow.cpp create mode 100644 code/nel/tools/misc/bnp_make_qt/mainwindow.h create mode 100644 code/nel/tools/misc/bnp_make_qt/mainwindow.ui diff --git a/code/nel/tools/misc/bnp_make_qt/main.cpp b/code/nel/tools/misc/bnp_make_qt/main.cpp new file mode 100644 index 000000000..4efc51df3 --- /dev/null +++ b/code/nel/tools/misc/bnp_make_qt/main.cpp @@ -0,0 +1,11 @@ +#include "main.h" + +int main(int argc, char * argv[]) +{ + QApplication application(argc, argv); + MainWindow window; + + window.show(); + + return application.exec(); +} diff --git a/code/nel/tools/misc/bnp_make_qt/main.h b/code/nel/tools/misc/bnp_make_qt/main.h new file mode 100644 index 000000000..a8a4b8652 --- /dev/null +++ b/code/nel/tools/misc/bnp_make_qt/main.h @@ -0,0 +1,8 @@ +#ifndef MAIN_H +#define MAIN_H + +#include + +#include "mainwindow.h" + +#endif // MAIN_H diff --git a/code/nel/tools/misc/bnp_make_qt/mainwindow.cpp b/code/nel/tools/misc/bnp_make_qt/mainwindow.cpp new file mode 100644 index 000000000..888330a80 --- /dev/null +++ b/code/nel/tools/misc/bnp_make_qt/mainwindow.cpp @@ -0,0 +1,253 @@ +#include "mainwindow.h" + +MainWindow::MainWindow(QWidget * parent) : + QMainWindow(parent), + uiMainWindow_(new Ui::MainWindow), + processList_(new QProcess(this)), + processSearch_(new QProcess(this)), + processPack_(new QProcess(this)), + processUnpack_(new QProcess(this)) +{ + uiMainWindow_->setupUi(this); + + settings_ = new QSettings("bnp_make_frontend.cfg", QSettings::IniFormat); + bnpMakeBinary_ = settings_->value("BnpMakeBinary").toString(); + dataPath_ = settings_->value("DataPath").toString(); + + uiMainWindow_->lineEditSearchPath->setText(dataPath_); + uiMainWindow_->lineEditBnpMake->setText(bnpMakeBinary_); + uiMainWindow_->lineEditDataPath->setText(dataPath_); + + connect(uiMainWindow_->pushButtonListBrowse, SIGNAL(clicked()), this, SLOT(onButtonListBrowseClicked())); + connect(uiMainWindow_->pushButtonList, SIGNAL(clicked()), this, SLOT(onButtonListClicked())); + connect(processList_, SIGNAL(finished(int)), this, SLOT(onProcessListComplete())); + + connect(uiMainWindow_->pushButtonSearchBrowse, SIGNAL(clicked()), this, SLOT(onButtonSearchBrowseClicked())); + connect(uiMainWindow_->pushButtonSearch, SIGNAL(clicked()), this, SLOT(onButtonSearchClicked())); + connect(processSearch_, SIGNAL(finished(int)), this, SLOT(onProcessSearchComplete())); + + connect(uiMainWindow_->pushButtonPackBrowse, SIGNAL(clicked()), this, SLOT(onButtonPackBrowseClicked())); + connect(uiMainWindow_->pushButtonPack, SIGNAL(clicked()), this, SLOT(onButtonPackClicked())); + connect(processPack_, SIGNAL(finished(int)), this, SLOT(onProcessPackComplete())); + + connect(uiMainWindow_->pushButtonUnpackBrowse, SIGNAL(clicked()), this, SLOT(onButtonUnpackBrowseClicked())); + connect(uiMainWindow_->pushButtonUnpack, SIGNAL(clicked()), this, SLOT(onButtonUnpackClicked())); + connect(processUnpack_, SIGNAL(finished(int)), this, SLOT(onProcessUnpackComplete())); + + connect(uiMainWindow_->pushButtonBnpMakeBrowse, SIGNAL(clicked()), this, SLOT(onButtonBnpMakeBrowseClicked())); + connect(uiMainWindow_->pushButtonDataPathBrowse, SIGNAL(clicked()), this, SLOT(onButtonDataPathBrowseClicked())); +} + +MainWindow::~MainWindow() +{ + delete uiMainWindow_; +} + +void MainWindow::onButtonListBrowseClicked() +{ + QString fileName; + + fileName = QFileDialog::getOpenFileName(this, "Choose a BNP file", dataPath_, "BNP file (*.bnp)"); + uiMainWindow_->lineEditList->setText(fileName); +} + +void MainWindow::onButtonListClicked() +{ + QStringList arguments; + + uiMainWindow_->textEditList->clear(); + + if (bnpMakeBinary_ != "") + if (uiMainWindow_->lineEditList->text() != "") + { + arguments << "/l" << uiMainWindow_->lineEditList->text(); + processList_->start(bnpMakeBinary_, arguments); + } + else + uiMainWindow_->textEditList->append("Choose a BNP file."); + else + uiMainWindow_->textEditList->append("Check bnp_make path."); +} + +void MainWindow::onProcessListComplete() +{ + QString output; + + output = processList_->readAllStandardOutput(); + uiMainWindow_->textEditList->append(output); + uiMainWindow_->textEditList->append("List complete."); +} + +void MainWindow::onButtonSearchBrowseClicked() +{ + QString directory; + + directory = QFileDialog::getExistingDirectory(this, tr("Choose a directory"), dataPath_, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); + uiMainWindow_->lineEditSearchPath->setText(directory); +} + +void MainWindow::onButtonSearchClicked() +{ + QDir dir; + QStringList nameFilters; + + uiMainWindow_->textEditSearch->clear(); + + if (bnpMakeBinary_ != "") + if (uiMainWindow_->lineEditSearchPath->text() != "") + { + dir.cd(uiMainWindow_->lineEditSearchPath->text()); + + nameFilters << "*.bnp"; + dir.setNameFilters(nameFilters); + dir.setFilter(QDir::Files); + + fileInfoList_ = dir.entryInfoList(); + fileInfoListIndex_ = 0; + + onProcessSearchComplete(); + } + else + uiMainWindow_->textEditSearch->append("Choose a directory."); + else + uiMainWindow_->textEditSearch->append("Check bnp_make path."); +} + +void MainWindow::onProcessSearchComplete() +{ + QFileInfo fileInfo; + QStringList arguments; + QString output; + QStringList outputList; + QString line; + + if (fileInfoListIndex_ > 0) + { + output = processSearch_->readAllStandardOutput(); + + if (uiMainWindow_->lineEditSearchString->text() == "") + uiMainWindow_->textEditSearch->append(output); + else + { + outputList = output.split("\n"); + + foreach (line, outputList) + if (line.contains(uiMainWindow_->lineEditSearchString->text())) + uiMainWindow_->textEditSearch->append(line.trimmed()); + } + } + + if (fileInfoListIndex_ < fileInfoList_.count()) + { + fileInfo = fileInfoList_.at(fileInfoListIndex_++); + uiMainWindow_->textEditSearch->append("===> " + uiMainWindow_->lineEditSearchPath->text() + "/" + fileInfo.fileName() + ":"); + arguments << "/l" << uiMainWindow_->lineEditSearchPath->text() + "/" + fileInfo.fileName(); + processSearch_->start(bnpMakeBinary_, arguments); + } + else + { + uiMainWindow_->textEditSearch->append("Search complete."); + } +} + +void MainWindow::onButtonPackBrowseClicked() +{ + QString directory; + + directory = QFileDialog::getExistingDirectory(this, tr("Choose the source directory"), dataPath_, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); + uiMainWindow_->lineEditPack->setText(directory); +} + +void MainWindow::onButtonPackClicked() +{ + QStringList arguments; + + uiMainWindow_->textEditPack->clear(); + + if (bnpMakeBinary_ != "") + if (uiMainWindow_->lineEditPack->text() != "") + { + uiMainWindow_->textEditPack->append("Pack in progress..."); + + arguments << "/p" << uiMainWindow_->lineEditPack->text(); + processPack_->start(bnpMakeBinary_, arguments); + } + else + uiMainWindow_->textEditPack->append("Choose the source directory."); + else + uiMainWindow_->textEditPack->append("Check bnp_make path."); +} + +void MainWindow::onProcessPackComplete() +{ + QString output; + + output = processPack_->readAllStandardOutput(); + uiMainWindow_->textEditPack->append(output); + uiMainWindow_->textEditPack->append("Pack complete."); +} + +void MainWindow::onButtonUnpackBrowseClicked() +{ + QString fileName; + + fileName = QFileDialog::getOpenFileName(this, "Choose a BNP file", dataPath_, "BNP file (*.bnp)"); + uiMainWindow_->lineEditUnpack->setText(fileName); +} + +void MainWindow::onButtonUnpackClicked() +{ + QStringList arguments; + + uiMainWindow_->textEditUnpack->clear(); + + if (bnpMakeBinary_ != "") + if (uiMainWindow_->lineEditUnpack->text() != "") + { + uiMainWindow_->textEditUnpack->append("Unpack in progress..."); + + arguments << "/u" << uiMainWindow_->lineEditUnpack->text(); + processUnpack_->start(bnpMakeBinary_, arguments); + } + else + uiMainWindow_->textEditUnpack->append("Choose a BNP file."); + else + uiMainWindow_->textEditUnpack->append("Check bnp_make path."); +} + +void MainWindow::onProcessUnpackComplete() +{ + uiMainWindow_->textEditUnpack->append("Unpack complete."); +} + +void MainWindow::onButtonBnpMakeBrowseClicked() +{ + QString fileName; + + fileName = QFileDialog::getOpenFileName(this, "Locate the bnp_make binary", dataPath_); + uiMainWindow_->lineEditBnpMake->setText(fileName); + + bnpMakeBinary_ = fileName; + settings_->setValue("BnpMakeBinary", fileName); + + uiMainWindow_->textEditSettings->clear(); + if (fileName != "") + uiMainWindow_->textEditSettings->append("bnp_make path changed."); + else + uiMainWindow_->textEditSettings->append("Locate the bnp_make binary."); +} + +void MainWindow::onButtonDataPathBrowseClicked() +{ + QString directory; + + directory = QFileDialog::getExistingDirectory(this, tr("Choose a directory"), dataPath_, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); + uiMainWindow_->lineEditDataPath->setText(directory); + + dataPath_ = directory; + settings_->setValue("DataPath", directory); + uiMainWindow_->lineEditSearchPath->setText(directory); + + uiMainWindow_->textEditSettings->clear(); + uiMainWindow_->textEditSettings->append("Data path changed."); +} diff --git a/code/nel/tools/misc/bnp_make_qt/mainwindow.h b/code/nel/tools/misc/bnp_make_qt/mainwindow.h new file mode 100644 index 000000000..776b5fe01 --- /dev/null +++ b/code/nel/tools/misc/bnp_make_qt/mainwindow.h @@ -0,0 +1,61 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include +#include +#include +#include + +#include "ui_mainwindow.h" + +namespace Ui +{ + class MainWindow; +} + +class MainWindow : public QMainWindow +{ + Q_OBJECT + + public: + explicit MainWindow(QWidget * parent = 0); + ~MainWindow(); + + public slots: + void onButtonListBrowseClicked(); + void onButtonListClicked(); + void onProcessListComplete(); + + void onButtonSearchBrowseClicked(); + void onButtonSearchClicked(); + void onProcessSearchComplete(); + + void onButtonPackBrowseClicked(); + void onButtonPackClicked(); + void onProcessPackComplete(); + + void onButtonUnpackBrowseClicked(); + void onButtonUnpackClicked(); + void onProcessUnpackComplete(); + + void onButtonBnpMakeBrowseClicked(); + void onButtonDataPathBrowseClicked(); + + private: + Ui::MainWindow * uiMainWindow_; + QSettings * settings_; + QString bnpMakeBinary_; + QString dataPath_; + + QProcess * processList_; + + QProcess * processSearch_; + int fileInfoListIndex_; + QFileInfoList fileInfoList_; + + QProcess * processPack_; + + QProcess * processUnpack_; +}; + +#endif // MAINWINDOW_H diff --git a/code/nel/tools/misc/bnp_make_qt/mainwindow.ui b/code/nel/tools/misc/bnp_make_qt/mainwindow.ui new file mode 100644 index 000000000..37097744e --- /dev/null +++ b/code/nel/tools/misc/bnp_make_qt/mainwindow.ui @@ -0,0 +1,322 @@ + + + MainWindow + + + + 0 + 0 + 800 + 600 + + + + bnp-make-frontend + + + + :/images/bnp-make-frontend.ico:/images/bnp-make-frontend.ico + + + QTabWidget::Rounded + + + + + + + 0 + + + + List + + + + + + + + + + BNP file: + + + + + + + true + + + + + + + Browse + + + + + + + + + List + + + + + + + true + + + + + + + + + + Search + + + + + + + + + + Search path: + + + + + + + true + + + + + + + Browse + + + + + + + + + + + Search string: + + + + + + + + + + + + Search + + + + + + + true + + + + + + + + + + Pack + + + + + + + + + + Source path: + + + + + + + true + + + + + + + Browse + + + + + + + + + Pack + + + + + + + true + + + + + + + + + + Unpack + + + + + + + + + + BNP file: + + + + + + + true + + + + + + + Browse + + + + + + + + + Unpack + + + + + + + true + + + + + + + + + + Settings + + + + + + + + + + bnp_make path: + + + + + + + true + + + + + + + Browse + + + + + + + + + + + Data path: + + + + + + + true + + + + + + + Browse + + + + + + + + + true + + + + + + + + + + + + + + + + + + From df21e21085f278095662f3aa2672d9c41760505b Mon Sep 17 00:00:00 2001 From: Nimetu Date: Tue, 26 Nov 2019 11:43:23 +0200 Subject: [PATCH 02/10] Fixed: nelmisc linker error --HG-- branch : develop --- code/CMakeLists.txt | 3 ++- code/nel/src/gui/CMakeLists.txt | 4 ++-- code/nel/src/misc/CMakeLists.txt | 6 +++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index 46900daa6..71910d8f7 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -220,6 +220,8 @@ IF(WITH_NEL) IF(WITH_GUI) FIND_PACKAGE(Luabind REQUIRED) + ENDIF() + FIND_PACKAGE(CURL REQUIRED) IF((WIN32 OR CURL_LIBRARIES MATCHES "\\.a") AND WITH_STATIC_CURL) @@ -269,7 +271,6 @@ IF(WITH_NEL) ENDIF() ENDIF() ENDIF() - ENDIF() INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/nel/include) ADD_SUBDIRECTORY(nel) diff --git a/code/nel/src/gui/CMakeLists.txt b/code/nel/src/gui/CMakeLists.txt index cb7bbe23a..19c0cfea8 100644 --- a/code/nel/src/gui/CMakeLists.txt +++ b/code/nel/src/gui/CMakeLists.txt @@ -6,9 +6,9 @@ SOURCE_GROUP("src" FILES ${SRC}) NL_TARGET_LIB(nelgui ${SRC} ${HEADERS}) -INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR} ${LUA_INCLUDE_DIR} ${LUABIND_INCLUDE_DIR} ${CURL_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR}) +INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR} ${LUA_INCLUDE_DIR} ${LUABIND_INCLUDE_DIR} ${CURL_INCLUDE_DIRS}) -TARGET_LINK_LIBRARIES(nelgui nelmisc nel3d ${LUA_LIBRARIES} ${LUABIND_LIBRARIES} ${CURL_LIBRARIES} ${OPENSSL_LIBRARIES}) +TARGET_LINK_LIBRARIES(nelgui nelmisc nel3d ${LUA_LIBRARIES} ${LUABIND_LIBRARIES} ${CURL_LIBRARIES}) NL_DEFAULT_PROPS(nelgui "NeL, Library: NeL GUI") NL_ADD_RUNTIME_FLAGS(nelgui) diff --git a/code/nel/src/misc/CMakeLists.txt b/code/nel/src/misc/CMakeLists.txt index ec0dcd357..e8470983c 100644 --- a/code/nel/src/misc/CMakeLists.txt +++ b/code/nel/src/misc/CMakeLists.txt @@ -209,15 +209,15 @@ IF(UNIX) ENDIF() ENDIF() -INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR} ${PNG_INCLUDE_DIR} config_file) +INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR} ${PNG_INCLUDE_DIR} ${CURL_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR} config_file) -TARGET_LINK_LIBRARIES(nelmisc ${CMAKE_THREAD_LIBS_INIT} ${LIBXML2_LIBRARIES} ${ZLIB_LIBRARY}) +TARGET_LINK_LIBRARIES(nelmisc ${CMAKE_THREAD_LIBS_INIT} ${LIBXML2_LIBRARIES} ${ZLIB_LIBRARY} ${CURL_LIBRARIES} ${OPENSSL_LIBRARIES}) NL_DEFAULT_PROPS(nelmisc "NeL, Library: NeL Misc") NL_ADD_RUNTIME_FLAGS(nelmisc) NL_ADD_LIB_SUFFIX(nelmisc) -ADD_DEFINITIONS(${LIBXML2_DEFINITIONS}) +ADD_DEFINITIONS(${LIBXML2_DEFINITIONS} ${CURL_DEFINITIONS} ) IF(WITH_PCH) ADD_NATIVE_PRECOMPILED_HEADER(nelmisc ${CMAKE_CURRENT_SOURCE_DIR}/stdmisc.h ${CMAKE_CURRENT_SOURCE_DIR}/stdmisc.cpp) From 02e7393c1414c225897e706255e63d7e30cffa53 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Tue, 26 Nov 2019 11:43:26 +0200 Subject: [PATCH 03/10] Changed: Move hardcoded urls to cmake. --HG-- branch : develop --- code/CMakeLists.txt | 19 +++++++++++++++++++ code/CMakeModules/nel.cmake | 2 ++ code/config.h.cmake | 8 ++++++++ code/ryzom/client/src/client_cfg.cpp | 14 +++++++++----- .../tools/client/client_patcher/main.cpp | 2 +- 5 files changed, 39 insertions(+), 6 deletions(-) diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index 71910d8f7..67d516ba5 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -63,6 +63,25 @@ SET(RYZOM_VERSION_MAJOR 3) SET(RYZOM_VERSION_MINOR 5) SET(RYZOM_VERSION_PATCH 0) +SET(RYZOM_CLIENT_CREATE_ACCOUNT_URL "https://open.ryzom.dev/ams/" CACHE STRING "Ryzom Client Create Account URL") +SET(RYZOM_CLIENT_EDIT_ACCOUNT_URL "https://open.ryzom.dev/ams/" CACHE STRING "Ryzom Client Edit Account URL") +SET(RYZOM_CLIENT_FORGET_PASSWORD_URL "https://open.ryzom.dev/ams/" CACHE STRING "Ryzom Client Forget Password URL") +SET(RYZOM_CLIENT_PATCH_URL "https://cdn.ryzom.dev/open/patch/" CACHE STRING "Ryzom Client Patch URL") + +SET(RYZOM_WEBIG_MAIN_URL "https://open.ryzom.dev/" CACHE STRING "Ryzom Client WebIG Main URL") +SET(RYZOM_WEBIG_TRUSTED_DOMAIN "open.ryzom.dev" CACHE STRING "Ryzom Client WebIG Trusted Domain") + +# urls when compiling ryzom live client +IF(WITH_RYZOM_LIVE) + SET(RYZOM_CLIENT_CREATE_ACCOUNT_URL "https://account.ryzom.com/signup/from_client.php") + SET(RYZOM_CLIENT_EDIT_ACCOUNT_URL "https://account.ryzom.com/payment_profile/index.php") + SET(RYZOM_CLIENT_FORGET_PASSWORD_URL "https://account.ryzom.com/payment_profile/lost_secure_password.php") + SET(RYZOM_CLIENT_PATCH_URL "http://dl.ryzom.com/patch_live") + + SET(RYZOM_WEBIG_MAIN_URL "https://app.ryzom.com/") + SET(RYZOM_WEBIG_TRUSTED_DOMAIN "app.ryzom.com") +ENDIF() + #----------------------------------------------------------------------------- # Redirect output files SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) diff --git a/code/CMakeModules/nel.cmake b/code/CMakeModules/nel.cmake index bd70dd2ff..bac079fb6 100644 --- a/code/CMakeModules/nel.cmake +++ b/code/CMakeModules/nel.cmake @@ -281,6 +281,8 @@ MACRO(NL_SETUP_DEFAULT_OPTIONS) OPTION(WITH_RYZOM "Build Ryzom Core." ON ) OPTION(WITH_SNOWBALLS "Build Snowballs." OFF) OPTION(WITH_TOOLS "Build Tools" OFF) + + OPTION(WITH_RYZOM_LIVE "Use ryzom.com urls" OFF) ENDMACRO(NL_SETUP_DEFAULT_OPTIONS) MACRO(NL_SETUP_NEL_DEFAULT_OPTIONS) diff --git a/code/config.h.cmake b/code/config.h.cmake index 9d698ac08..fa4749cb2 100644 --- a/code/config.h.cmake +++ b/code/config.h.cmake @@ -33,6 +33,14 @@ #cmakedefine RYZOM_VERSION_RC ${RYZOM_VERSION_RC} #cmakedefine RYZOM_PRODUCT_VERSION "${RYZOM_PRODUCT_VERSION}" +#cmakedefine RYZOM_CLIENT_CREATE_ACCOUNT_URL "${RYZOM_CLIENT_CREATE_ACCOUNT_URL}" +#cmakedefine RYZOM_CLIENT_EDIT_ACCOUNT_URL "${RYZOM_CLIENT_EDIT_ACCOUNT_URL}" +#cmakedefine RYZOM_CLIENT_FORGET_PASSWORD_URL "${RYZOM_CLIENT_FORGET_PASSWORD_URL}" +#cmakedefine RYZOM_CLIENT_PATCH_URL "${RYZOM_CLIENT_PATCH_URL}" + +#cmakedefine RYZOM_WEBIG_MAIN_URL "${RYZOM_WEBIG_MAIN_URL}" +#cmakedefine RYZOM_WEBIG_TRUSTED_DOMAIN "${RYZOM_WEBIG_TRUSTED_DOMAIN}" + #cmakedefine AUTHOR "${AUTHOR}" #cmakedefine YEAR "${YEAR}" #cmakedefine COPYRIGHT "${COPYRIGHT}" diff --git a/code/ryzom/client/src/client_cfg.cpp b/code/ryzom/client/src/client_cfg.cpp index bfd6452ee..aac38c885 100644 --- a/code/ryzom/client/src/client_cfg.cpp +++ b/code/ryzom/client/src/client_cfg.cpp @@ -42,6 +42,10 @@ // Game Share. #include "game_share/time_weather_season/time_and_season.h" +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #ifdef NL_OS_MAC #include "app_bundle_utils.h" #endif // NL_OS_MAC @@ -330,9 +334,9 @@ CClientConfig::CClientConfig() TexturesLoginInterface.push_back("texture_interfaces_v3_login"); DisplayAccountButtons = true; - CreateAccountURL = "https://open.ryzom.dev/ams/"; - EditAccountURL = "https://open.ryzom.dev/ams/"; - ForgetPwdURL = "https://open.ryzom.dev/ams/"; + CreateAccountURL = RYZOM_CLIENT_CREATE_ACCOUNT_URL; // "https://open.ryzom.dev/ams/"; + EditAccountURL = RYZOM_CLIENT_EDIT_ACCOUNT_URL; // "https://open.ryzom.dev/ams/"; + ForgetPwdURL = RYZOM_CLIENT_FORGET_PASSWORD_URL; // "https://open.ryzom.dev/ams/"; Position = CVector(0.f, 0.f, 0.f); // Default Position. Heading = CVector(0.f, 1.f, 0.f); // Default Heading. EyesHeight = 1.5f; // Default User Eyes Height. @@ -428,8 +432,8 @@ CClientConfig::CClientConfig() PatchletUrl.clear(); PatchVersion.clear(); - WebIgMainDomain = "https://open.ryzom.dev"; - WebIgTrustedDomains.push_back("open.ryzom.dev"); + WebIgMainDomain = RYZOM_WEBIG_MAIN_URL; // https://open.ryzom.dev/" + WebIgTrustedDomains.push_back(RYZOM_WEBIG_TRUSTED_DOMAIN); // open.ryzom.dev WebIgNotifInterval = 10; // time in minutes CurlMaxConnections = 5; diff --git a/code/ryzom/tools/client/client_patcher/main.cpp b/code/ryzom/tools/client/client_patcher/main.cpp index 0c1a13832..e7d57a335 100644 --- a/code/ryzom/tools/client/client_patcher/main.cpp +++ b/code/ryzom/tools/client/client_patcher/main.cpp @@ -191,7 +191,7 @@ struct CClientPatcherTranslations : public NLMISC::CI18N::ILoadProxy }; // hardcoded URL to not depend on external files -static const std::string PatchUrl = "https://cdn.ryzom.dev/open/patch"; +static const std::string PatchUrl = RYZOM_CLIENT_PATCH_URL; // "https://cdn.ryzom.dev/open/patch"; int main(int argc, char *argv[]) { From 03340ee875a349080f761a4ce2a7fb762b7d76eb Mon Sep 17 00:00:00 2001 From: Jan Boon Date: Wed, 27 Nov 2019 09:16:28 +0800 Subject: [PATCH 04/10] Tag cleanup --HG-- branch : develop --- .hgtags | 55 +++++++++++++++++++++++++++---------------------------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/.hgtags b/.hgtags index 6eeec5b9a..38ed6cd84 100644 --- a/.hgtags +++ b/.hgtags @@ -1,28 +1,27 @@ -4eddbaff0c5e5d685db96ee3e8427aa0fd96ac83 ryzomcore/v0.8.0 -00d9b6e29e95f56785fbf85abe60afd34674f402 ryzomcore/v0.9.0 -79776c337176dd5b02e1a74fe5dfb703b91747aa ryzomcore/v0.9.1 -fedf2aa443d09707beed814b0f499c6a5519cc84 ryzomcore/v0.10.0 -edaa3624a56420b02ccc64c26059801a389927ee ryzomcore/v0.11.0 -e3fe4855f22c3e75722e015dc33c091c340b3ad7 ryzomcore/v0.11.1 -9e583b717fd63be0be9fd60b99087abf1691ea49 ryzomcore/v0.11.2 -bfe5628e14a024ba7ea32e4b326ae433a07856b9 ryzomcore/v0.11.3 -9a6120735daa97c96ac5d85ca35c7f21f607bd87 ryzomcore/v0.12.0 -3e17907af67e8d66d80e6b714707bbf912607f2a ryzom-patch-3.0.0 -153e0b605c9e0c83ba05b6428c62838b49cc84b2 ryzom-patch-3.0.1 -9d41f2994d44b9aad92b83f945f114e4b6bed44a ryzom-patch-3.0.2 -4300cc14aad098b1f86ea4c55577b7fa4a4cb5d2 ryzom-patch-3.1.0 -d4060f217f4f834cc62a33f2f1ccdf3c28298066 ryzom-patch-3.1.0-hotfix -043aaeb3d8a2a54177581b57bda87a9deaad510e ryzom-patch-3.1.0-april_patch -4036ecf59e83960f03acebc2089eb2ff5eeaed0a ryzom-patch-3.2.0 -18403bb9485da3d9742c6f007a16d5619ebfb196 ryzom-patch-3.2.1 -822ff8f8917ad66e09e2c21c983282f6f693b9f6 ryzom-patch-3.3.0 -00dde390a394fce9da06c2f3264140282158d39f ryzom-patch-3.3.0 -0000000000000000000000000000000000000000 3.3.0 -dcd4c4d161ef775136e18c7e8f5072b75dede27e ryzom-patch-3.3.1 -fc4be8ebec5ca754ef4453bc6a9faef90837c674 ryzom-patch-3.4.0 -70eba02e8eab6920586dbabf74e9e8180c729980 ryzom-patch-3.4.0 Steam Fix -3941482843f9cd130cfc16634efc08d34a98ed35 ryzom-patch-3.4.0 Atysmas -ecae9feb4cceb78103e5d7236caccaf450796cdb ryzom-patch-3.5.0 -95783afa226f241062134eb62f4323295d29ac84 ryzom-patch-3.5.0.9637 -8eb94c3549be898fdc4a7c6d791d2477bdc11a18 ryzomcore/v1.0.1 -3e92c7104c20d6bc6c2147b4b5fc289e8621d322 ryzomcore/v1.0.0 +4eddbaff0c5e5d685db96ee3e8427aa0fd96ac83 v0.8.0 +00d9b6e29e95f56785fbf85abe60afd34674f402 v0.9.0 +79776c337176dd5b02e1a74fe5dfb703b91747aa v0.9.1 +fedf2aa443d09707beed814b0f499c6a5519cc84 v0.10.0 +edaa3624a56420b02ccc64c26059801a389927ee v0.11.0 +e3fe4855f22c3e75722e015dc33c091c340b3ad7 v0.11.1 +9e583b717fd63be0be9fd60b99087abf1691ea49 v0.11.2 +bfe5628e14a024ba7ea32e4b326ae433a07856b9 v0.11.3 +9a6120735daa97c96ac5d85ca35c7f21f607bd87 v0.12.0 +3e92c7104c20d6bc6c2147b4b5fc289e8621d322 v1.0.0 +8eb94c3549be898fdc4a7c6d791d2477bdc11a18 v1.0.1 +3e17907af67e8d66d80e6b714707bbf912607f2a ryzom/3.0.0 +153e0b605c9e0c83ba05b6428c62838b49cc84b2 ryzom/3.0.1 +9d41f2994d44b9aad92b83f945f114e4b6bed44a ryzom/3.0.2 +4300cc14aad098b1f86ea4c55577b7fa4a4cb5d2 ryzom/3.1.0 +d4060f217f4f834cc62a33f2f1ccdf3c28298066 ryzom/3.1.0-hotfix +043aaeb3d8a2a54177581b57bda87a9deaad510e ryzom/3.1.0-april_patch +4036ecf59e83960f03acebc2089eb2ff5eeaed0a ryzom/3.2.0 +18403bb9485da3d9742c6f007a16d5619ebfb196 ryzom/3.2.1 +822ff8f8917ad66e09e2c21c983282f6f693b9f6 ryzom/3.3.0 +00dde390a394fce9da06c2f3264140282158d39f ryzom/3.3.0 +dcd4c4d161ef775136e18c7e8f5072b75dede27e ryzom/3.3.1 +fc4be8ebec5ca754ef4453bc6a9faef90837c674 ryzom/3.4.0 +70eba02e8eab6920586dbabf74e9e8180c729980 ryzom/3.4.0-steam_fix +3941482843f9cd130cfc16634efc08d34a98ed35 ryzom/3.4.0-atysmas +ecae9feb4cceb78103e5d7236caccaf450796cdb ryzom/3.5.0 +95783afa226f241062134eb62f4323295d29ac84 ryzom/3.5.0.9637 From b32b1becec0f63e67e57eecb16076b249db33fff Mon Sep 17 00:00:00 2001 From: kaetemi Date: Wed, 27 Nov 2019 17:38:29 +0800 Subject: [PATCH 05/10] Decouple downloader from streamed package manager --- .../include/nel/misc/http_package_provider.h | 50 ++++++ .../nel/misc/i_streamed_package_provider.h | 44 ++++++ code/nel/include/nel/misc/streamed_package.h | 2 + .../nel/misc/streamed_package_manager.h | 15 +- code/nel/include/nel/misc/types_nl.h | 6 + code/nel/src/misc/http_package_provider.cpp | 145 ++++++++++++++++++ .../src/misc/i_streamed_package_provider.cpp | 37 +++++ .../nel/src/misc/streamed_package_manager.cpp | 102 +----------- code/ryzom/client/src/global.cpp | 3 + code/ryzom/client/src/global.h | 8 + code/ryzom/client/src/init.cpp | 10 +- code/ryzom/client/src/release.cpp | 2 + 12 files changed, 319 insertions(+), 105 deletions(-) create mode 100644 code/nel/include/nel/misc/http_package_provider.h create mode 100644 code/nel/include/nel/misc/i_streamed_package_provider.h create mode 100644 code/nel/src/misc/http_package_provider.cpp create mode 100644 code/nel/src/misc/i_streamed_package_provider.cpp diff --git a/code/nel/include/nel/misc/http_package_provider.h b/code/nel/include/nel/misc/http_package_provider.h new file mode 100644 index 000000000..b4b82d70a --- /dev/null +++ b/code/nel/include/nel/misc/http_package_provider.h @@ -0,0 +1,50 @@ +// NeL - MMORPG Framework +// Copyright (C) 2019 Jan BOON (jan.boon@kaetemi.be) +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef NLMISC_HTTP_PACKAGE_PROVIDER_H +#define NLMISC_HTTP_PACKAGE_PROVIDER_H + +#include +#include + +namespace NLMISC { + +class CHttpPackageProvider : public IStreamedPackageProvider +{ +public: + CHttpPackageProvider(); + virtual ~CHttpPackageProvider(); + + /// Download a file. This call is blocking + /// filePath: [out] ex. /games/nel/stream/00/00/000000000.. + /// hash: [in] + virtual bool getFile(std::string &filePath, const CHashKey &hash, const std::string &name) NL_OVERRIDE; + +public: + /// Set storage path (ex. stream/) + std::string Path; + + /// Loads a package into the package manager (ex. http://cdn.ryzom.dev/open/stream/) + typedef std::vector THosts; + THosts Hosts; + +}; /* class CHttpPackageProvider */ + +} /* namespace NLMISC */ + +#endif /* #ifndef NLMISC_STREAMED_PACKAGE_MANAGER_H */ + +/* end of file */ diff --git a/code/nel/include/nel/misc/i_streamed_package_provider.h b/code/nel/include/nel/misc/i_streamed_package_provider.h new file mode 100644 index 000000000..6e74d866d --- /dev/null +++ b/code/nel/include/nel/misc/i_streamed_package_provider.h @@ -0,0 +1,44 @@ +// NeL - MMORPG Framework +// Copyright (C) 2019 Jan BOON (jan.boon@kaetemi.be) +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef NLMISC_STREAMED_PACKAGE_PROVIDER_H +#define NLMISC_STREAMED_PACKAGE_PROVIDER_H + +#include +#include +#include + +namespace NLMISC { + +class IStreamedPackageProvider +{ +public: + IStreamedPackageProvider(); + virtual ~IStreamedPackageProvider(); + + /// Download a file. This call is blocking + /// filePath: [out] ex. /games/nel/stream/00/00/000000000.. + /// hash: [in] + /// name: [in] name for debugging + virtual bool getFile(std::string &filePath, const CHashKey &hash, const std::string &name = ""); + +}; /* class IStreamedPackageProvider */ + +} /* namespace NLMISC */ + +#endif /* #ifndef NLMISC_STREAMED_PACKAGE_PROVIDER_H */ + +/* end of file */ diff --git a/code/nel/include/nel/misc/streamed_package.h b/code/nel/include/nel/misc/streamed_package.h index c777d8a02..9040598d6 100644 --- a/code/nel/include/nel/misc/streamed_package.h +++ b/code/nel/include/nel/misc/streamed_package.h @@ -42,6 +42,8 @@ public: void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + /// result: [out] ex. /00/00/000000000.. + /// hash: [in] static void makePath(std::string &result, const CHashKey &hash); public: diff --git a/code/nel/include/nel/misc/streamed_package_manager.h b/code/nel/include/nel/misc/streamed_package_manager.h index e23344a70..85d13db59 100644 --- a/code/nel/include/nel/misc/streamed_package_manager.h +++ b/code/nel/include/nel/misc/streamed_package_manager.h @@ -20,6 +20,7 @@ #include #include #include +#include namespace NLMISC { @@ -40,21 +41,19 @@ public: /// Unload all packages void unloadAll(); - /// Get an existing file or download if necessary + /// Get an existing file or download if necessary. This call is blocking /// filePath: [out] ex. /games/nel/stream/00/00/000000000.. - /// fileName: ex. fy_hof_underwear.dds + /// fileName: [in] ex. fy_hof_underwear.dds bool getFile(std::string &filePath, const std::string &fileName); /// Get file size + /// fileSize: [out] + /// fileName: [in] ex. fy_hof_underwear.dds bool getFileSize(uint32 &fileSize, const std::string &fileName); public: - /// Set storage path (ex. stream/) - std::string Path; - - /// Loads a package into the package manager (ex. http://patch.live.polyverse.org/stream/) - typedef std::vector THosts; - THosts Hosts; + /// Streamed package provider. This downloads the files + IStreamedPackageProvider *Provider; private: typedef std::map TPackages; diff --git a/code/nel/include/nel/misc/types_nl.h b/code/nel/include/nel/misc/types_nl.h index 353f50490..f42f410e6 100644 --- a/code/nel/include/nel/misc/types_nl.h +++ b/code/nel/include/nel/misc/types_nl.h @@ -479,6 +479,7 @@ extern void operator delete[](void *p) throw(); # define CHashMultiMap NL_ISO_STDTR1_NAMESPACE::unordered_multimap # define CUniquePtr ::std::auto_ptr # define CUniquePtrMove +# define NL_OVERRIDE #elif defined(NL_COMP_VC) && (NL_COMP_VC_VERSION >= 70 && NL_COMP_VC_VERSION <= 90) // VC7 through 9 # include # include @@ -487,6 +488,7 @@ extern void operator delete[](void *p) throw(); # define CHashMultiMap stdext::hash_multimap # define CUniquePtr ::std::auto_ptr # define CUniquePtrMove +# define NL_OVERRIDE #elif defined(NL_COMP_GCC) // GCC4 # include # include @@ -526,6 +528,10 @@ template<> struct hash */ typedef uint16 ucchar; +#ifndef NL_OVERRIDE +#define NL_OVERRIDE override +#endif + #if defined(NL_OS_WINDOWS) && (defined(UNICODE) || defined(_UNICODE)) #define nltmain wmain #define nltWinMain wWinMain diff --git a/code/nel/src/misc/http_package_provider.cpp b/code/nel/src/misc/http_package_provider.cpp new file mode 100644 index 000000000..035fa2a5d --- /dev/null +++ b/code/nel/src/misc/http_package_provider.cpp @@ -0,0 +1,145 @@ +// NeL - MMORPG Framework +// Copyright (C) 2019 Jan BOON (jan.boon@kaetemi.be) +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#include "stdmisc.h" + +// 3rd Party includes +#include + +// Project includes +#include +#include +#include +#include +#include +#include + +namespace NLMISC +{ + +CHttpPackageProvider::CHttpPackageProvider() +{ + // init +} + +CHttpPackageProvider::~CHttpPackageProvider() +{ + // release +} + +bool CHttpPackageProvider::getFile(std::string &filePath, const CHashKey &hash, const std::string &name) +{ + CStreamedPackage::makePath(filePath, hash); + std::string downloadUrlFile = filePath + ".lzma"; + filePath = Path + filePath; + std::string downloadPath = filePath + ".download." + toString(rand() * rand()); + + std::string storageDirectory = CFile::getPath(downloadPath); + CFile::createDirectoryTree(storageDirectory); + /*if (!CFile::isDirectory(storageDirectory) || !CFile::createDirectoryTree(storageDirectory)) + { + nldebug("Unable to create directory '%s'", storageDirectory.c_str()); + return false; + }*/ + + // download + for (;;) + { + if (CFile::fileExists(filePath)) + return true; + + std::string downloadUrl = Hosts[rand() % Hosts.size()] + downloadUrlFile; + nldebug("Download streamed package '%s' from '%s'", name.c_str(), downloadUrl.c_str()); + + FILE *fp = fopen(downloadPath.c_str(), "wb"); + if (fp == NULL) + { + nldebug("Unable to create file '%s' for '%s'", downloadPath.c_str(), name.c_str()); + return false; + } + + CURL *curl; + CURLcode res; + curl = curl_easy_init(); + if (curl) + { + curl_easy_setopt(curl, CURLOPT_URL, downloadUrl.c_str()); + curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); + curl_easy_setopt(curl, CURLOPT_FILE, fp); + res = curl_easy_perform(curl); + long r; + curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &r); + curl_easy_cleanup(curl); + + bool diskFull = ferror(fp) && errno == 28 /*ENOSPC*/; + fclose(fp); + + if (diskFull) + { + CFile::deleteFile(downloadPath); + throw EDiskFullError(downloadPath); + } + + if (res != CURLE_OK || r < 200 || r >= 300) + { + CFile::deleteFile(downloadPath); + nldebug("Download failed '%s', retry in 1s", downloadUrl.c_str()); + nlSleep(1000); + continue; + } + } + else + { + nldebug("Curl initialize failed"); + fclose(fp); + CFile::deleteFile(downloadPath); + return false; + } + + // ok! + break; + } + + // extract into file + std::string unpackPath = filePath + ".extract." + toString(rand() * rand()); + + CHashKey outHash; + if (!unpackLZMA(downloadPath, unpackPath, outHash)) + { + return false; + } + + if (!(outHash == hash)) + { + std::string wantHashS = hash.toString(); + std::string outHashS = outHash.toString(); + nlwarning("Invalid SHA1 hash for file '%s', download has hash '%s'", wantHashS.c_str(), outHashS.c_str()); + return false; + } + + if (!CFile::moveFile(filePath.c_str(), unpackPath.c_str())) + { + nldebug("Failed moving '%s' to '%s'", unpackPath.c_str(), filePath.c_str()); + // in case downloaded from another thread + return CFile::fileExists(filePath); + } + + return true; +} + +} /* namespace NLMISC */ + +/* end of file */ diff --git a/code/nel/src/misc/i_streamed_package_provider.cpp b/code/nel/src/misc/i_streamed_package_provider.cpp new file mode 100644 index 000000000..12c873760 --- /dev/null +++ b/code/nel/src/misc/i_streamed_package_provider.cpp @@ -0,0 +1,37 @@ +// NeL - MMORPG Framework +// Copyright (C) 2019 Jan BOON (jan.boon@kaetemi.be) +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#include "stdmisc.h" + +// Project includes +#include + +namespace NLMISC +{ + +IStreamedPackageProvider::IStreamedPackageProvider() +{ + // init +} + +IStreamedPackageProvider::~IStreamedPackageProvider() +{ + // release +} + +} /* namespace NLMISC */ + +/* end of file */ diff --git a/code/nel/src/misc/streamed_package_manager.cpp b/code/nel/src/misc/streamed_package_manager.cpp index 483df6a52..ac605b049 100644 --- a/code/nel/src/misc/streamed_package_manager.cpp +++ b/code/nel/src/misc/streamed_package_manager.cpp @@ -16,14 +16,10 @@ #include "stdmisc.h" -// 3rd Party includes -#include - // Project includes #include #include #include -#include #include namespace NLMISC @@ -96,105 +92,21 @@ bool CStreamedPackageManager::getFile(std::string &filePath, const std::string & { // nldebug("Get file path for streamed file '%s'", fileName.c_str()); - TEntries::iterator it = m_Entries.find(fileName); - if (it == m_Entries.end()) - return false; - const CStreamedPackage::CEntry *entry = it->second; - - CStreamedPackage::makePath(filePath, entry->Hash); - std::string downloadUrlFile = filePath + ".lzma"; - filePath = Path + filePath; - std::string downloadPath = filePath + ".download." + toString(rand() * rand()); - - std::string storageDirectory = CFile::getPath(downloadPath); - CFile::createDirectoryTree(storageDirectory); - /*if (!CFile::isDirectory(storageDirectory) || !CFile::createDirectoryTree(storageDirectory)) + IStreamedPackageProvider *provider = Provider; + if (!provider) { - nldebug("Unable to create directory '%s'", storageDirectory.c_str()); + nlerrornoex("No streamed package provider was set"); return false; - }*/ - - // download - for (;;) - { - if (CFile::fileExists(filePath)) - return true; - - std::string downloadUrl = Hosts[rand() % Hosts.size()] + downloadUrlFile; - nldebug("Download streamed package '%s' from '%s'", fileName.c_str(), downloadUrl.c_str()); - - FILE *fp = fopen(downloadPath.c_str(), "wb"); - if (fp == NULL) - { - nldebug("Unable to create file '%s' for '%s'", downloadPath.c_str(), fileName.c_str()); - return false; - } - - CURL *curl; - CURLcode res; - curl = curl_easy_init(); - if (curl) - { - curl_easy_setopt(curl, CURLOPT_URL, downloadUrl.c_str()); - curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); - curl_easy_setopt(curl, CURLOPT_FILE, fp); - res = curl_easy_perform(curl); - long r; - curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &r); - curl_easy_cleanup(curl); - - bool diskFull = ferror(fp) && errno == 28 /*ENOSPC*/; - fclose(fp); - - if (diskFull) - { - CFile::deleteFile(downloadPath); - throw EDiskFullError(downloadPath); - } - - if (res != CURLE_OK || r < 200 || r >= 300) - { - CFile::deleteFile(downloadPath); - nldebug("Download failed '%s', retry in 1s", downloadUrl.c_str()); - nlSleep(1000); - continue; - } - } - else - { - nldebug("Curl initialize failed"); - fclose(fp); - CFile::deleteFile(downloadPath); - return false; - } - - // ok! - break; } - // extract into file - std::string unpackPath = filePath + ".extract." + toString(rand() * rand()); - - CHashKey outHash; - if (!unpackLZMA(downloadPath, unpackPath, outHash)) - { - return false; - } - - if (!(outHash == entry->Hash)) + TEntries::iterator it = m_Entries.find(fileName); + if (it == m_Entries.end()) { - std::string wantHashS = entry->Hash.toString(); - std::string outHashS = outHash.toString(); - nlwarning("Invalid SHA1 hash for file '%s', download has hash '%s'", wantHashS.c_str(), outHashS.c_str()); return false; } + const CStreamedPackage::CEntry *entry = it->second; - if (!CFile::moveFile(filePath.c_str(), unpackPath.c_str())) - { - nldebug("Failed moving '%s' to '%s'", unpackPath.c_str(), filePath.c_str()); - // in case downloaded from another thread - return CFile::fileExists(filePath); - } + return provider->getFile(filePath, entry->Hash, fileName); return true; } diff --git a/code/ryzom/client/src/global.cpp b/code/ryzom/client/src/global.cpp index 4b8e1aad7..41d41160c 100644 --- a/code/ryzom/client/src/global.cpp +++ b/code/ryzom/client/src/global.cpp @@ -24,6 +24,9 @@ using namespace NLMISC; // *************************************************************************** +// Data +NLMISC::CHttpPackageProvider *HttpPackageProvider = NULL; + // Main System NL3D::UDriver *Driver = NULL; // The main 3D Driver NL3D::IStereoDisplay *StereoDisplay = NULL; // Stereo display diff --git a/code/ryzom/client/src/global.h b/code/ryzom/client/src/global.h index 78cebcec9..75ba2381d 100644 --- a/code/ryzom/client/src/global.h +++ b/code/ryzom/client/src/global.h @@ -28,6 +28,11 @@ // *************************************************************************** +namespace NLMISC +{ + class CHttpPackageProvider; +} + namespace NL3D { class UDriver; @@ -78,6 +83,9 @@ const float ExtraZoneLoadingVision = 100.f; // *************************************************************************** +// Data +extern NLMISC::CHttpPackageProvider *HttpPackageProvider; // Http provider from on-the-fly downloaded game data + // Main System extern NL3D::UDriver *Driver; // The main 3D Driver extern NL3D::IStereoDisplay *StereoDisplay; // Stereo display diff --git a/code/ryzom/client/src/init.cpp b/code/ryzom/client/src/init.cpp index 1f9c10b34..85eb50b51 100644 --- a/code/ryzom/client/src/init.cpp +++ b/code/ryzom/client/src/init.cpp @@ -35,6 +35,7 @@ #include "nel/misc/block_memory.h" #include "nel/misc/system_utils.h" #include "nel/misc/streamed_package_manager.h" +#include "nel/misc/http_package_provider.h" #include "nel/misc/cmd_args.h" // 3D Interface. #include "nel/3d/bloom_effect.h" @@ -740,9 +741,14 @@ static void addPaths(IProgressCallback &progress, const std::vector void initStreamedPackageManager(NLMISC::IProgressCallback &progress) { CStreamedPackageManager &spm = CStreamedPackageManager::getInstance(); - spm.Path = ClientCfg.StreamedPackagePath; + nlassert(!spm.Provider); // If this asserts, init was called twice without release + nlassert(!HttpPackageProvider); // Idem + CHttpPackageProvider *hpp = new CHttpPackageProvider(); + hpp->Path = ClientCfg.StreamedPackagePath; for (uint i = 0; i < ClientCfg.StreamedPackageHosts.size(); i++) - spm.Hosts.push_back(ClientCfg.StreamedPackageHosts[i]); + hpp->Hosts.push_back(ClientCfg.StreamedPackageHosts[i]); + spm.Provider = hpp; + HttpPackageProvider = hpp; } void addSearchPaths(IProgressCallback &progress) diff --git a/code/ryzom/client/src/release.cpp b/code/ryzom/client/src/release.cpp index be34d9ba8..6686fea5d 100644 --- a/code/ryzom/client/src/release.cpp +++ b/code/ryzom/client/src/release.cpp @@ -668,6 +668,8 @@ void release() NLMISC::CBigFile::getInstance().removeAll(); NLMISC::CBigFile::releaseInstance(); NLMISC::CStreamedPackageManager::releaseInstance(); + delete HttpPackageProvider; + HttpPackageProvider = NULL; NL3D::CFastHLSModifier::releaseInstance(); CLandscapePolyDrawer::releaseInstance(); NL3D::CParticleSystemShape::releaseInstance(); From 09e31cf75a2e883a2bcc1fb2db84fb9a531aacf3 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Wed, 27 Nov 2019 17:48:54 +0800 Subject: [PATCH 06/10] Fix --- code/nel/include/nel/misc/i_streamed_package_provider.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/nel/include/nel/misc/i_streamed_package_provider.h b/code/nel/include/nel/misc/i_streamed_package_provider.h index 6e74d866d..320e3cdfd 100644 --- a/code/nel/include/nel/misc/i_streamed_package_provider.h +++ b/code/nel/include/nel/misc/i_streamed_package_provider.h @@ -33,7 +33,7 @@ public: /// filePath: [out] ex. /games/nel/stream/00/00/000000000.. /// hash: [in] /// name: [in] name for debugging - virtual bool getFile(std::string &filePath, const CHashKey &hash, const std::string &name = ""); + virtual bool getFile(std::string &filePath, const CHashKey &hash, const std::string &name = "") = 0; }; /* class IStreamedPackageProvider */ From 1cf2a792aef1d3d7c4258ee6b19103494f51e1a1 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Wed, 27 Nov 2019 17:53:41 +0800 Subject: [PATCH 07/10] Reverse unneeded change from merge --- code/nel/include/nel/misc/path.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/nel/include/nel/misc/path.h b/code/nel/include/nel/misc/path.h index de46532b7..5a9c417a2 100644 --- a/code/nel/include/nel/misc/path.h +++ b/code/nel/include/nel/misc/path.h @@ -279,8 +279,8 @@ private: struct CMCFileEntry { char *Name; // Normal case (the search is done by using nlstricmp) - uint32 idPath : 20; // Path (not with file at the end) - look in the SSMpath (1048576 different path allowed) - uint32 idExt : 11; // real extension of the file if remapped - look in the SSMext (2048 different extension allowed) + uint32 idPath : 16; // Path (not with file at the end) - look in the SSMpath (65536 different path allowed) + uint32 idExt : 15; // real extension of the file if remapped - look in the SSMext (32768 different extension allowed) uint32 Remapped : 1; // true if the file is remapped }; From 76e0e9c105090b0d8de9f3dad2979fd32ad2aaf1 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Wed, 27 Nov 2019 18:40:31 +0800 Subject: [PATCH 08/10] Move HTTP related code into new NLWEB library --- code/CMakeModules/nel.cmake | 1 + code/nel/include/nel/CMakeLists.txt | 4 + code/nel/include/nel/web/CMakeLists.txt | 2 + .../nel/{misc => web}/curl_certificates.h | 2 +- .../nel/{misc => web}/http_client_curl.h | 2 +- .../nel/{misc => web}/http_package_provider.h | 12 +-- code/nel/src/CMakeLists.txt | 4 + code/nel/src/gui/CMakeLists.txt | 2 +- code/nel/src/gui/group_html.cpp | 6 +- code/nel/src/misc/CMakeLists.txt | 6 +- code/nel/src/web/CMakeLists.txt | 28 ++++++ .../src/{misc => web}/curl_certificates.cpp | 21 ++--- .../src/{misc => web}/http_client_curl.cpp | 15 ++-- .../{misc => web}/http_package_provider.cpp | 13 +-- code/nel/src/web/stdweb.cpp | 17 ++++ code/nel/src/web/stdweb.h | 85 +++++++++++++++++++ code/ryzom/client/src/global.cpp | 2 +- code/ryzom/client/src/global.h | 4 +- code/ryzom/client/src/init.cpp | 4 +- code/ryzom/client/src/init_main_loop.cpp | 6 +- .../src/interface_v3/group_html_webig.cpp | 4 +- .../src/interface_v3/interface_manager.cpp | 4 +- code/ryzom/client/src/login.cpp | 3 +- code/ryzom/client/src/login.h | 4 +- code/ryzom/client/src/login_patch.cpp | 6 +- .../client/client_patcher/CMakeLists.txt | 1 + 26 files changed, 195 insertions(+), 63 deletions(-) create mode 100644 code/nel/include/nel/web/CMakeLists.txt rename code/nel/include/nel/{misc => web}/curl_certificates.h (98%) rename code/nel/include/nel/{misc => web}/http_client_curl.h (99%) rename code/nel/include/nel/{misc => web}/http_package_provider.h (80%) create mode 100644 code/nel/src/web/CMakeLists.txt rename code/nel/src/{misc => web}/curl_certificates.cpp (97%) rename code/nel/src/{misc => web}/http_client_curl.cpp (97%) rename code/nel/src/{misc => web}/http_package_provider.cpp (96%) create mode 100644 code/nel/src/web/stdweb.cpp create mode 100644 code/nel/src/web/stdweb.h diff --git a/code/CMakeModules/nel.cmake b/code/CMakeModules/nel.cmake index bac079fb6..f8d01a0bc 100644 --- a/code/CMakeModules/nel.cmake +++ b/code/CMakeModules/nel.cmake @@ -291,6 +291,7 @@ MACRO(NL_SETUP_NEL_DEFAULT_OPTIONS) ### OPTION(WITH_NET "Build NLNET" ON ) OPTION(WITH_3D "Build NL3D" ON ) + OPTION(WITH_WEB "Build WEB" ON ) OPTION(WITH_GUI "Build GUI" ON ) OPTION(WITH_PACS "Build NLPACS" ON ) OPTION(WITH_GEORGES "Build NLGEORGES" ON ) diff --git a/code/nel/include/nel/CMakeLists.txt b/code/nel/include/nel/CMakeLists.txt index 4df9413b5..fda0ddbe9 100644 --- a/code/nel/include/nel/CMakeLists.txt +++ b/code/nel/include/nel/CMakeLists.txt @@ -4,6 +4,10 @@ IF(WITH_3D) SUBDIRS(3d) ENDIF() +IF(WITH_WEB OR WITH_GUI) + ADD_SUBDIRECTORY(web) +ENDIF() + IF(WITH_GUI) ADD_SUBDIRECTORY(gui) ENDIF() diff --git a/code/nel/include/nel/web/CMakeLists.txt b/code/nel/include/nel/web/CMakeLists.txt new file mode 100644 index 000000000..5e560aed8 --- /dev/null +++ b/code/nel/include/nel/web/CMakeLists.txt @@ -0,0 +1,2 @@ +FILE(GLOB HEADERS *.h) +INSTALL(FILES ${HEADERS} DESTINATION include/nel/web COMPONENT headers) diff --git a/code/nel/include/nel/misc/curl_certificates.h b/code/nel/include/nel/web/curl_certificates.h similarity index 98% rename from code/nel/include/nel/misc/curl_certificates.h rename to code/nel/include/nel/web/curl_certificates.h index 778074ca1..b2b031a1a 100644 --- a/code/nel/include/nel/misc/curl_certificates.h +++ b/code/nel/include/nel/web/curl_certificates.h @@ -22,7 +22,7 @@ // forward declaration to avoid curl.h inclusion everywhere typedef void CURL; -namespace NLMISC +namespace NLWEB { class CCurlCertificates { diff --git a/code/nel/include/nel/misc/http_client_curl.h b/code/nel/include/nel/web/http_client_curl.h similarity index 99% rename from code/nel/include/nel/misc/http_client_curl.h rename to code/nel/include/nel/web/http_client_curl.h index b282c2b70..ca005462c 100644 --- a/code/nel/include/nel/misc/http_client_curl.h +++ b/code/nel/include/nel/web/http_client_curl.h @@ -20,7 +20,7 @@ #include "nel/misc/types_nl.h" #include -namespace NLMISC +namespace NLWEB { /** diff --git a/code/nel/include/nel/misc/http_package_provider.h b/code/nel/include/nel/web/http_package_provider.h similarity index 80% rename from code/nel/include/nel/misc/http_package_provider.h rename to code/nel/include/nel/web/http_package_provider.h index b4b82d70a..99cb01b6e 100644 --- a/code/nel/include/nel/misc/http_package_provider.h +++ b/code/nel/include/nel/web/http_package_provider.h @@ -14,15 +14,15 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -#ifndef NLMISC_HTTP_PACKAGE_PROVIDER_H -#define NLMISC_HTTP_PACKAGE_PROVIDER_H +#ifndef NLWEB_HTTP_PACKAGE_PROVIDER_H +#define NLWEB_HTTP_PACKAGE_PROVIDER_H #include #include -namespace NLMISC { +namespace NLWEB { -class CHttpPackageProvider : public IStreamedPackageProvider +class CHttpPackageProvider : public NLMISC::IStreamedPackageProvider { public: CHttpPackageProvider(); @@ -31,7 +31,7 @@ public: /// Download a file. This call is blocking /// filePath: [out] ex. /games/nel/stream/00/00/000000000.. /// hash: [in] - virtual bool getFile(std::string &filePath, const CHashKey &hash, const std::string &name) NL_OVERRIDE; + virtual bool getFile(std::string &filePath, const NLMISC::CHashKey &hash, const std::string &name) NL_OVERRIDE; public: /// Set storage path (ex. stream/) @@ -45,6 +45,6 @@ public: } /* namespace NLMISC */ -#endif /* #ifndef NLMISC_STREAMED_PACKAGE_MANAGER_H */ +#endif /* #ifndef NLWEB_HTTP_PACKAGE_PROVIDER_H */ /* end of file */ diff --git a/code/nel/src/CMakeLists.txt b/code/nel/src/CMakeLists.txt index 2b140340a..6da34b0d0 100644 --- a/code/nel/src/CMakeLists.txt +++ b/code/nel/src/CMakeLists.txt @@ -4,6 +4,10 @@ IF(WITH_3D) ADD_SUBDIRECTORY(3d) ENDIF() +IF(WITH_WEB OR WITH_GUI) + ADD_SUBDIRECTORY(web) +ENDIF() + IF(WITH_GUI) ADD_SUBDIRECTORY(gui) ENDIF() diff --git a/code/nel/src/gui/CMakeLists.txt b/code/nel/src/gui/CMakeLists.txt index 19c0cfea8..bb5a0b7f2 100644 --- a/code/nel/src/gui/CMakeLists.txt +++ b/code/nel/src/gui/CMakeLists.txt @@ -8,7 +8,7 @@ NL_TARGET_LIB(nelgui ${SRC} ${HEADERS}) INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR} ${LUA_INCLUDE_DIR} ${LUABIND_INCLUDE_DIR} ${CURL_INCLUDE_DIRS}) -TARGET_LINK_LIBRARIES(nelgui nelmisc nel3d ${LUA_LIBRARIES} ${LUABIND_LIBRARIES} ${CURL_LIBRARIES}) +TARGET_LINK_LIBRARIES(nelgui nelmisc nelweb nel3d ${LUA_LIBRARIES} ${LUABIND_LIBRARIES} ${CURL_LIBRARIES}) NL_DEFAULT_PROPS(nelgui "NeL, Library: NeL GUI") NL_ADD_RUNTIME_FLAGS(nelgui) diff --git a/code/nel/src/gui/group_html.cpp b/code/nel/src/gui/group_html.cpp index ce719f4b0..8179a6af0 100644 --- a/code/nel/src/gui/group_html.cpp +++ b/code/nel/src/gui/group_html.cpp @@ -47,7 +47,7 @@ #include "nel/gui/url_parser.h" #include "nel/gui/http_cache.h" #include "nel/gui/http_hsts.h" -#include "nel/misc/curl_certificates.h" +#include "nel/web/curl_certificates.h" #include "nel/gui/html_parser.h" #include "nel/gui/html_element.h" #include "nel/gui/css_style.h" @@ -550,7 +550,7 @@ namespace NLGUI if (toLower(download.url.substr(0, 8)) == "https://") { // if supported, use custom SSL context function to load certificates - CCurlCertificates::useCertificates(curl); + NLWEB::CCurlCertificates::useCertificates(curl); } download.data = new CCurlWWWData(curl, download.url); @@ -3823,7 +3823,7 @@ namespace NLGUI if (toLower(url.substr(0, 8)) == "https://") { // if supported, use custom SSL context function to load certificates - CCurlCertificates::useCertificates(curl); + NLWEB::CCurlCertificates::useCertificates(curl); } // do not follow redirects, we have own handler diff --git a/code/nel/src/misc/CMakeLists.txt b/code/nel/src/misc/CMakeLists.txt index 091e181cc..e7b422592 100644 --- a/code/nel/src/misc/CMakeLists.txt +++ b/code/nel/src/misc/CMakeLists.txt @@ -212,16 +212,16 @@ IF(UNIX) ENDIF() INCLUDE_DIRECTORIES(../../3rdparty) -INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR} ${PNG_INCLUDE_DIR} ${CURL_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR} config_file) +INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR} ${PNG_INCLUDE_DIR} config_file) -TARGET_LINK_LIBRARIES(nelmisc ${CMAKE_THREAD_LIBS_INIT} ${LIBXML2_LIBRARIES} ${ZLIB_LIBRARY} ${CURL_LIBRARIES} ${OPENSSL_LIBRARIES} nel_sevenzip) +TARGET_LINK_LIBRARIES(nelmisc ${CMAKE_THREAD_LIBS_INIT} ${LIBXML2_LIBRARIES} ${ZLIB_LIBRARY} nel_sevenzip) NL_DEFAULT_PROPS(nelmisc "NeL, Library: NeL Misc") NL_ADD_RUNTIME_FLAGS(nelmisc) NL_ADD_LIB_SUFFIX(nelmisc) -ADD_DEFINITIONS(${LIBXML2_DEFINITIONS} ${CURL_DEFINITIONS}) +ADD_DEFINITIONS(${LIBXML2_DEFINITIONS}) IF(WITH_PCH) ADD_NATIVE_PRECOMPILED_HEADER(nelmisc ${CMAKE_CURRENT_SOURCE_DIR}/stdmisc.h ${CMAKE_CURRENT_SOURCE_DIR}/stdmisc.cpp) diff --git a/code/nel/src/web/CMakeLists.txt b/code/nel/src/web/CMakeLists.txt new file mode 100644 index 000000000..042967fa2 --- /dev/null +++ b/code/nel/src/web/CMakeLists.txt @@ -0,0 +1,28 @@ +FILE(GLOB SRC *.cpp *.h) +FILE(GLOB HEADERS ../../include/nel/web/*.h) + +SOURCE_GROUP("" FILES ${SRC} ${HEADERS}) + +NL_TARGET_LIB(nelweb ${HEADERS} ${SRC}) + +INCLUDE_DIRECTORIES(../../3rdparty) +INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR} ${CURL_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR}) + +TARGET_LINK_LIBRARIES(nelweb ${LIBXML2_LIBRARIES} ${CURL_LIBRARIES} ${OPENSSL_LIBRARIES} nelmisc nel_sevenzip) + +NL_DEFAULT_PROPS(nelweb "NeL, Library: NeL Web") +NL_ADD_RUNTIME_FLAGS(nelweb) + +NL_ADD_LIB_SUFFIX(nelweb) + +ADD_DEFINITIONS(${LIBXML2_DEFINITIONS} ${CURL_DEFINITIONS}) + +IF(WITH_PCH) + ADD_NATIVE_PRECOMPILED_HEADER(nelweb ${CMAKE_CURRENT_SOURCE_DIR}/stdweb.h ${CMAKE_CURRENT_SOURCE_DIR}/stdweb.cpp) +ENDIF() + +NL_GEN_PC(nel-web.pc) + +IF((WITH_INSTALL_LIBRARIES AND WITH_STATIC) OR NOT WITH_STATIC) + INSTALL(TARGETS nelweb LIBRARY DESTINATION ${NL_LIB_PREFIX} ARCHIVE DESTINATION ${NL_LIB_PREFIX} COMPONENT libraries) +ENDIF() diff --git a/code/nel/src/misc/curl_certificates.cpp b/code/nel/src/web/curl_certificates.cpp similarity index 97% rename from code/nel/src/misc/curl_certificates.cpp rename to code/nel/src/web/curl_certificates.cpp index 9dcdc72db..84b41e609 100644 --- a/code/nel/src/misc/curl_certificates.cpp +++ b/code/nel/src/web/curl_certificates.cpp @@ -14,26 +14,14 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -#include "stdmisc.h" -#include +#include "stdweb.h" +#include + #include #include #include #include -#include -#include -#include - -#include - -#ifdef NL_OS_WINDOWS -#include -#ifdef X509_NAME -#undef X509_NAME -#endif -#endif - // for compatibility with older versions #ifndef CURL_AT_LEAST_VERSION #define CURL_VERSION_BITS(x,y,z) ((x)<<16|(y)<<8|z) @@ -44,12 +32,13 @@ using namespace std; using namespace NLMISC; +using namespace NLWEB; #ifdef DEBUG_NEW #define new DEBUG_NEW #endif -namespace NLMISC +namespace NLWEB { // // x509CertList lifetime manager diff --git a/code/nel/src/misc/http_client_curl.cpp b/code/nel/src/web/http_client_curl.cpp similarity index 97% rename from code/nel/src/misc/http_client_curl.cpp rename to code/nel/src/web/http_client_curl.cpp index d335716b0..31d54767d 100644 --- a/code/nel/src/misc/http_client_curl.cpp +++ b/code/nel/src/web/http_client_curl.cpp @@ -14,16 +14,15 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -#include "stdmisc.h" -#include -#include - -#include +#include "stdweb.h" +#include -#include +#include +#include -using namespace NLMISC; using namespace std; +using namespace NLMISC; +using namespace NLWEB; #ifdef DEBUG_NEW #define new DEBUG_NEW @@ -31,7 +30,7 @@ using namespace std; #define _Curl (CURL *)_CurlStruct -namespace NLMISC +namespace NLWEB { // Ugly CURL callback diff --git a/code/nel/src/misc/http_package_provider.cpp b/code/nel/src/web/http_package_provider.cpp similarity index 96% rename from code/nel/src/misc/http_package_provider.cpp rename to code/nel/src/web/http_package_provider.cpp index 035fa2a5d..2ddc665b9 100644 --- a/code/nel/src/misc/http_package_provider.cpp +++ b/code/nel/src/web/http_package_provider.cpp @@ -14,20 +14,21 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -#include "stdmisc.h" - -// 3rd Party includes -#include +#include "stdweb.h" +#include // Project includes -#include #include #include #include #include #include -namespace NLMISC +using namespace std; +using namespace NLMISC; +using namespace NLWEB; + +namespace NLWEB { CHttpPackageProvider::CHttpPackageProvider() diff --git a/code/nel/src/web/stdweb.cpp b/code/nel/src/web/stdweb.cpp new file mode 100644 index 000000000..d85dbcdc5 --- /dev/null +++ b/code/nel/src/web/stdweb.cpp @@ -0,0 +1,17 @@ +// NeL - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#include "stdweb.h" diff --git a/code/nel/src/web/stdweb.h b/code/nel/src/web/stdweb.h new file mode 100644 index 000000000..7234cd50d --- /dev/null +++ b/code/nel/src/web/stdweb.h @@ -0,0 +1,85 @@ +// NeL - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef NL_STDWEB_H +#define NL_STDWEB_H + +#if defined(_MSC_VER) && defined(_DEBUG) + #define _CRTDBG_MAP_ALLOC + #include + #include + #include + #define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__) +#elif defined(_MSC_VER) + #include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#ifdef NL_OS_WINDOWS +# define WIN32_LEAN_AND_MEAN +# define _WIN32_WINDOWS 0x0500 +# ifndef _WIN32_WINNT +# define _WIN32_WINNT 0x0500 +# endif +# ifndef NL_COMP_MINGW +# define WINVER 0x0500 +# define NOMINMAX +# endif +# include +# include +# include +# ifdef X509_NAME +# undef X509_NAME +# endif +#endif + +#include + +#include +#include +#include + +#include + +#include + +#endif // NL_STDWEB_H diff --git a/code/ryzom/client/src/global.cpp b/code/ryzom/client/src/global.cpp index 41d41160c..9789b3b5b 100644 --- a/code/ryzom/client/src/global.cpp +++ b/code/ryzom/client/src/global.cpp @@ -25,7 +25,7 @@ using namespace NLMISC; // *************************************************************************** // Data -NLMISC::CHttpPackageProvider *HttpPackageProvider = NULL; +NLWEB::CHttpPackageProvider *HttpPackageProvider = NULL; // Main System NL3D::UDriver *Driver = NULL; // The main 3D Driver diff --git a/code/ryzom/client/src/global.h b/code/ryzom/client/src/global.h index 75ba2381d..8929f150c 100644 --- a/code/ryzom/client/src/global.h +++ b/code/ryzom/client/src/global.h @@ -28,7 +28,7 @@ // *************************************************************************** -namespace NLMISC +namespace NLWEB { class CHttpPackageProvider; } @@ -84,7 +84,7 @@ const float ExtraZoneLoadingVision = 100.f; // *************************************************************************** // Data -extern NLMISC::CHttpPackageProvider *HttpPackageProvider; // Http provider from on-the-fly downloaded game data +extern NLWEB::CHttpPackageProvider *HttpPackageProvider; // Http provider from on-the-fly downloaded game data // Main System extern NL3D::UDriver *Driver; // The main 3D Driver diff --git a/code/ryzom/client/src/init.cpp b/code/ryzom/client/src/init.cpp index 85eb50b51..b9287d884 100644 --- a/code/ryzom/client/src/init.cpp +++ b/code/ryzom/client/src/init.cpp @@ -35,7 +35,7 @@ #include "nel/misc/block_memory.h" #include "nel/misc/system_utils.h" #include "nel/misc/streamed_package_manager.h" -#include "nel/misc/http_package_provider.h" +#include "nel/web/http_package_provider.h" #include "nel/misc/cmd_args.h" // 3D Interface. #include "nel/3d/bloom_effect.h" @@ -743,7 +743,7 @@ void initStreamedPackageManager(NLMISC::IProgressCallback &progress) CStreamedPackageManager &spm = CStreamedPackageManager::getInstance(); nlassert(!spm.Provider); // If this asserts, init was called twice without release nlassert(!HttpPackageProvider); // Idem - CHttpPackageProvider *hpp = new CHttpPackageProvider(); + NLWEB::CHttpPackageProvider *hpp = new NLWEB::CHttpPackageProvider(); hpp->Path = ClientCfg.StreamedPackagePath; for (uint i = 0; i < ClientCfg.StreamedPackageHosts.size(); i++) hpp->Hosts.push_back(ClientCfg.StreamedPackageHosts[i]); diff --git a/code/ryzom/client/src/init_main_loop.cpp b/code/ryzom/client/src/init_main_loop.cpp index 47c11d899..e22aba478 100644 --- a/code/ryzom/client/src/init_main_loop.cpp +++ b/code/ryzom/client/src/init_main_loop.cpp @@ -28,7 +28,7 @@ #include "nel/misc/path.h" #include "nel/misc/sheet_id.h" #include "nel/misc/big_file.h" -#include "nel/misc/curl_certificates.h" +#include "nel/web/curl_certificates.h" // 3D Interface. #include "nel/3d/bloom_effect.h" #include "nel/3d/u_driver.h" @@ -190,8 +190,8 @@ struct CStatThread : public NLMISC::IRunnable curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); if (url.length() > 8 && (url[4] == 's' || url[4] == 'S')) // 01234 https { - NLMISC::CCurlCertificates::addCertificateFile("cacert.pem"); - NLMISC::CCurlCertificates::useCertificates(curl); + NLWEB::CCurlCertificates::addCertificateFile("cacert.pem"); + NLWEB::CCurlCertificates::useCertificates(curl); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 1L); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 2L); } diff --git a/code/ryzom/client/src/interface_v3/group_html_webig.cpp b/code/ryzom/client/src/interface_v3/group_html_webig.cpp index 5ec107bcb..0cb00ded0 100644 --- a/code/ryzom/client/src/interface_v3/group_html_webig.cpp +++ b/code/ryzom/client/src/interface_v3/group_html_webig.cpp @@ -30,7 +30,7 @@ #include "../connection.h" #include -#include "nel/misc/curl_certificates.h" +#include "nel/web/curl_certificates.h" using namespace std; using namespace NLMISC; @@ -188,7 +188,7 @@ public: curl_easy_setopt(Curl, CURLOPT_FOLLOWLOCATION, 1); curl_easy_setopt(Curl, CURLOPT_WRITEFUNCTION, writeDataFromCurl); - NLMISC::CCurlCertificates::useCertificates(Curl); + NLWEB::CCurlCertificates::useCertificates(Curl); } ~CWebigNotificationThread() diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index d01e89a24..a1efa5d1a 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -113,7 +113,7 @@ #include "nel/gui/lua_helper.h" using namespace NLGUI; #include "nel/gui/lua_ihm.h" -#include "nel/misc/curl_certificates.h" +#include "nel/web/curl_certificates.h" #include "lua_ihm_ryzom.h" @@ -480,7 +480,7 @@ CInterfaceManager::CInterfaceManager() if (!ClientCfg.CurlCABundle.empty()) { // specify custom CA certs, lookup will be made in this function - NLMISC::CCurlCertificates::addCertificateFile(ClientCfg.CurlCABundle); + NLWEB::CCurlCertificates::addCertificateFile(ClientCfg.CurlCABundle); } NLGUI::CDBManager::getInstance()->resizeBanks( NB_CDB_BANKS ); diff --git a/code/ryzom/client/src/login.cpp b/code/ryzom/client/src/login.cpp index 4bc8c10be..7cc58dfd7 100644 --- a/code/ryzom/client/src/login.cpp +++ b/code/ryzom/client/src/login.cpp @@ -51,7 +51,7 @@ #include "global.h" #include "input.h" #include "nel/gui/libwww.h" -#include "nel/misc/http_client_curl.h" +#include "nel/web/http_client_curl.h" #include "login_progress_post_thread.h" #include "init.h" @@ -69,6 +69,7 @@ void ConnectToShard(); // *************************************************************************** using namespace NLMISC; +using namespace NLWEB; using namespace NLNET; using namespace NL3D; using namespace std; diff --git a/code/ryzom/client/src/login.h b/code/ryzom/client/src/login.h index d01f0ea8a..d3025837d 100644 --- a/code/ryzom/client/src/login.h +++ b/code/ryzom/client/src/login.h @@ -19,7 +19,7 @@ #define CL_LOGIN_H #include -#include +#include #include #include @@ -74,7 +74,7 @@ extern sint32 ShardSelected; /* * HTTP client preconfigured to connect to the startup login host */ -class CStartupHttpClient : public NLMISC::CCurlHttpClient +class CStartupHttpClient : public NLWEB::CCurlHttpClient { public: diff --git a/code/ryzom/client/src/login_patch.cpp b/code/ryzom/client/src/login_patch.cpp index ca91fcbfa..3814d3a46 100644 --- a/code/ryzom/client/src/login_patch.cpp +++ b/code/ryzom/client/src/login_patch.cpp @@ -49,7 +49,7 @@ #include "nel/misc/i18n.h" #include "nel/misc/cmd_args.h" #include "nel/misc/seven_zip.h" -#include "nel/misc/curl_certificates.h" +#include "nel/web/curl_certificates.h" #include "game_share/bg_downloader_msg.h" @@ -1431,8 +1431,8 @@ void CPatchManager::downloadFileWithCurl (const string &source, const string &de curl_easy_setopt(curl, CURLOPT_URL, source.c_str()); if (source.length() > 8 && (source[4] == 's' || source[4] == 'S')) // 01234 https { - NLMISC::CCurlCertificates::addCertificateFile("cacert.pem"); - NLMISC::CCurlCertificates::useCertificates(curl); + NLWEB::CCurlCertificates::addCertificateFile("cacert.pem"); + NLWEB::CCurlCertificates::useCertificates(curl); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 1L); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 2L); } diff --git a/code/ryzom/tools/client/client_patcher/CMakeLists.txt b/code/ryzom/tools/client/client_patcher/CMakeLists.txt index 810f4ccfd..fa6648c38 100644 --- a/code/ryzom/tools/client/client_patcher/CMakeLists.txt +++ b/code/ryzom/tools/client/client_patcher/CMakeLists.txt @@ -21,6 +21,7 @@ INCLUDE_DIRECTORIES( TARGET_LINK_LIBRARIES(ryzom_client_patcher nelmisc + nelweb nelnet ryzom_gameshare nel_sevenzip From ef058b10ffcdf8e09509f2c454e5594b28d853bc Mon Sep 17 00:00:00 2001 From: kaetemi Date: Wed, 27 Nov 2019 18:49:33 +0800 Subject: [PATCH 09/10] Add some documentation what this http provider is for --- .../include/nel/web/http_package_provider.h | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/code/nel/include/nel/web/http_package_provider.h b/code/nel/include/nel/web/http_package_provider.h index 99cb01b6e..fdda80937 100644 --- a/code/nel/include/nel/web/http_package_provider.h +++ b/code/nel/include/nel/web/http_package_provider.h @@ -20,6 +20,26 @@ #include #include +/// NeL Streamed Packages are like NeL Big Packages, but storing only +/// the file hash, allowing to load the file from a remote source instead. + +/// Technically, this works, because NeL 3D already loads resources +/// asynchronously. However, NeL 3D will not simultaneously load more +/// than one file, so on connections with high latency a backlog builds up. +/// It will need further changes in NeL 3D to be practical. + +/// Alternatively, it could be modified to plug in dynamic data packages +/// at runtime, for example to load in user models for Ring. It would +/// need an adjustment to download all files as soon as the package is +/// enabled. Advantage is that existing files are automatically matched +/// by their hash, so will only be downloaded once, and that files are +/// accessed in the same way as files inside bnp packages. + +/// The extension `.snp` is used for streamed packages. + +/// This class uses an HTTP server with LZMA compressed resources as +/// the package data source. + namespace NLWEB { class CHttpPackageProvider : public NLMISC::IStreamedPackageProvider From f66a8b8fdc4e9dafd40b1b1bc54ee3023979598e Mon Sep 17 00:00:00 2001 From: kaetemi Date: Wed, 27 Nov 2019 18:50:06 +0800 Subject: [PATCH 10/10] Document parameters --- code/nel/include/nel/misc/i_streamed_package_provider.h | 2 +- code/nel/include/nel/web/http_package_provider.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/code/nel/include/nel/misc/i_streamed_package_provider.h b/code/nel/include/nel/misc/i_streamed_package_provider.h index 320e3cdfd..da2618d85 100644 --- a/code/nel/include/nel/misc/i_streamed_package_provider.h +++ b/code/nel/include/nel/misc/i_streamed_package_provider.h @@ -32,7 +32,7 @@ public: /// Download a file. This call is blocking /// filePath: [out] ex. /games/nel/stream/00/00/000000000.. /// hash: [in] - /// name: [in] name for debugging + /// name: [in] name for debugging purposes virtual bool getFile(std::string &filePath, const CHashKey &hash, const std::string &name = "") = 0; }; /* class IStreamedPackageProvider */ diff --git a/code/nel/include/nel/web/http_package_provider.h b/code/nel/include/nel/web/http_package_provider.h index fdda80937..e1d1bb8a4 100644 --- a/code/nel/include/nel/web/http_package_provider.h +++ b/code/nel/include/nel/web/http_package_provider.h @@ -51,6 +51,7 @@ public: /// Download a file. This call is blocking /// filePath: [out] ex. /games/nel/stream/00/00/000000000.. /// hash: [in] + /// name: [in] name for debugging purposes virtual bool getFile(std::string &filePath, const NLMISC::CHashKey &hash, const std::string &name) NL_OVERRIDE; public: